Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXhmikosR <xhmikosr@users.sourceforge.net>2010-11-21 04:58:19 +0300
committerXhmikosR <xhmikosr@users.sourceforge.net>2010-11-21 04:58:19 +0300
commit8fa93233427fe98b06546294348bf98dd0da408b (patch)
tree001457fff403418d8282941d6f8dc851e156ff4e /src/filters/transform/MpaDecFilter
parentda2d38799a41d94416f1e41f24f4bbd423c28487 (diff)
missed the ogg files
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@2737 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/filters/transform/MpaDecFilter')
-rw-r--r--src/filters/transform/MpaDecFilter/libflac/src/libFLAC/Ogg/bitwise.c157
-rw-r--r--src/filters/transform/MpaDecFilter/libflac/src/libFLAC/Ogg/framing.c37
2 files changed, 122 insertions, 72 deletions
diff --git a/src/filters/transform/MpaDecFilter/libflac/src/libFLAC/Ogg/bitwise.c b/src/filters/transform/MpaDecFilter/libflac/src/libFLAC/Ogg/bitwise.c
index e8009016e..3d0219809 100644
--- a/src/filters/transform/MpaDecFilter/libflac/src/libFLAC/Ogg/bitwise.c
+++ b/src/filters/transform/MpaDecFilter/libflac/src/libFLAC/Ogg/bitwise.c
@@ -11,7 +11,7 @@
********************************************************************
function: packing variable sized words into an octet stream
- last mod: $Id: bitwise.c 16993 2010-03-21 23:15:46Z xiphmont $
+ last mod: $Id: bitwise.c 17287 2010-06-10 13:42:06Z tterribe $
********************************************************************/
@@ -20,6 +20,7 @@
#include <string.h>
#include <stdlib.h>
+#include <limits.h>
#include <ogg/ogg.h>
#define BUFFER_INCREMENT 256
@@ -80,14 +81,13 @@ void oggpackB_writetrunc(oggpack_buffer *b,long bits){
/* Takes only up to 32 bits. */
void oggpack_write(oggpack_buffer *b,unsigned long value,int bits){
- if(b->endbyte+4>=b->storage){
+ if(bits<0 || bits>32) goto err;
+ if(b->endbyte>=b->storage-4){
void *ret;
if(!b->ptr)return;
+ if(b->storage>LONG_MAX-BUFFER_INCREMENT) goto err;
ret=_ogg_realloc(b->buffer,b->storage+BUFFER_INCREMENT);
- if(!ret){
- oggpack_writeclear(b);
- return;
- }
+ if(!ret) goto err;
b->buffer=ret;
b->storage+=BUFFER_INCREMENT;
b->ptr=b->buffer+b->endbyte;
@@ -117,18 +117,20 @@ void oggpack_write(oggpack_buffer *b,unsigned long value,int bits){
b->endbyte+=bits/8;
b->ptr+=bits/8;
b->endbit=bits&7;
+ return;
+ err:
+ oggpack_writeclear(b);
}
/* Takes only up to 32 bits. */
void oggpackB_write(oggpack_buffer *b,unsigned long value,int bits){
- if(b->endbyte+4>=b->storage){
+ if(bits<0 || bits>32) goto err;
+ if(b->endbyte>=b->storage-4){
void *ret;
if(!b->ptr)return;
+ if(b->storage>LONG_MAX-BUFFER_INCREMENT) goto err;
ret=_ogg_realloc(b->buffer,b->storage+BUFFER_INCREMENT);
- if(!ret){
- oggpack_writeclear(b);
- return;
- }
+ if(!ret) goto err;
b->buffer=ret;
b->storage+=BUFFER_INCREMENT;
b->ptr=b->buffer+b->endbyte;
@@ -158,6 +160,9 @@ void oggpackB_write(oggpack_buffer *b,unsigned long value,int bits){
b->endbyte+=bits/8;
b->ptr+=bits/8;
b->endbit=bits&7;
+ return;
+ err:
+ oggpack_writeclear(b);
}
void oggpack_writealign(oggpack_buffer *b){
@@ -193,13 +198,11 @@ static void oggpack_writecopy_helper(oggpack_buffer *b,
/* aligned block copy */
if(b->endbyte+bytes+1>=b->storage){
void *ret;
- if(!b->ptr)return;
+ if(!b->ptr) goto err;
+ if(b->endbyte+bytes+BUFFER_INCREMENT>b->storage) goto err;
b->storage=b->endbyte+bytes+BUFFER_INCREMENT;
ret=_ogg_realloc(b->buffer,b->storage);
- if(!ret){
- oggpack_writeclear(b);
- return;
- }
+ if(!ret) goto err;
b->buffer=ret;
b->ptr=b->buffer+b->endbyte;
}
@@ -216,6 +219,9 @@ static void oggpack_writecopy_helper(oggpack_buffer *b,
else
w(b,(unsigned long)(ptr[bytes]),bits);
}
+ return;
+ err:
+ oggpack_writeclear(b);
}
void oggpack_writecopy(oggpack_buffer *b,void *source,long bits){
@@ -259,15 +265,20 @@ void oggpackB_readinit(oggpack_buffer *b,unsigned char *buf,int bytes){
/* Read in bits without advancing the bitptr; bits <= 32 */
long oggpack_look(oggpack_buffer *b,int bits){
unsigned long ret;
- unsigned long m=mask[bits];
+ unsigned long m;
+ if(bits<0 || bits>32) return -1;
+ m=mask[bits];
bits+=b->endbit;
- if(b->endbyte+4>=b->storage){
+ if(b->endbyte >= b->storage-4){
/* not the main path */
- if(b->endbyte*8+bits>b->storage*8)return(-1);
+ if(b->endbyte > b->storage-((bits+7)>>3)) return -1;
+ /* special case to avoid reading b->ptr[0], which might be past the end of
+ the buffer; also skips some useless accounting */
+ else if(!bits)return(0L);
}
-
+
ret=b->ptr[0]>>b->endbit;
if(bits>8){
ret|=b->ptr[1]<<(8-b->endbit);
@@ -288,13 +299,17 @@ long oggpackB_look(oggpack_buffer *b,int bits){
unsigned long ret;
int m=32-bits;
+ if(m<0 || m>32) return -1;
bits+=b->endbit;
- if(b->endbyte+4>=b->storage){
+ if(b->endbyte >= b->storage-4){
/* not the main path */
- if(b->endbyte*8+bits>b->storage*8)return(-1);
+ if(b->endbyte > b->storage-((bits+7)>>3)) return -1;
+ /* special case to avoid reading b->ptr[0], which might be past the end of
+ the buffer; also skips some useless accounting */
+ else if(!bits)return(0L);
}
-
+
ret=b->ptr[0]<<(24+b->endbit);
if(bits>8){
ret|=b->ptr[1]<<(16+b->endbit);
@@ -322,9 +337,18 @@ long oggpackB_look1(oggpack_buffer *b){
void oggpack_adv(oggpack_buffer *b,int bits){
bits+=b->endbit;
+
+ if(b->endbyte > b->storage-((bits+7)>>3)) goto overflow;
+
b->ptr+=bits/8;
b->endbyte+=bits/8;
b->endbit=bits&7;
+ return;
+
+ overflow:
+ b->ptr=NULL;
+ b->endbyte=b->storage;
+ b->endbit=1;
}
void oggpackB_adv(oggpack_buffer *b,int bits){
@@ -346,16 +370,20 @@ void oggpackB_adv1(oggpack_buffer *b){
/* bits <= 32 */
long oggpack_read(oggpack_buffer *b,int bits){
long ret;
- unsigned long m=mask[bits];
+ unsigned long m;
+ if(bits<0 || bits>32) goto err;
+ m=mask[bits];
bits+=b->endbit;
- if(b->endbyte+4>=b->storage){
+ if(b->endbyte >= b->storage-4){
/* not the main path */
- ret=-1L;
- if(b->endbyte*8+bits>b->storage*8)goto overflow;
+ if(b->endbyte > b->storage-((bits+7)>>3)) goto overflow;
+ /* special case to avoid reading b->ptr[0], which might be past the end of
+ the buffer; also skips some useless accounting */
+ else if(!bits)return(0L);
}
-
+
ret=b->ptr[0]>>b->endbit;
if(bits>8){
ret|=b->ptr[1]<<(8-b->endbit);
@@ -370,31 +398,35 @@ long oggpack_read(oggpack_buffer *b,int bits){
}
}
ret&=m;
-
- overflow:
-
b->ptr+=bits/8;
b->endbyte+=bits/8;
b->endbit=bits&7;
- return(ret);
+ return ret;
+
+ overflow:
+ err:
+ b->ptr=NULL;
+ b->endbyte=b->storage;
+ b->endbit=1;
+ return -1L;
}
/* bits <= 32 */
long oggpackB_read(oggpack_buffer *b,int bits){
long ret;
long m=32-bits;
-
+
+ if(m<0 || m>32) goto err;
bits+=b->endbit;
if(b->endbyte+4>=b->storage){
/* not the main path */
- ret=-1L;
- if(b->endbyte*8+bits>b->storage*8)goto overflow;
+ if(b->endbyte > b->storage-((bits+7)>>3)) goto overflow;
/* special case to avoid reading b->ptr[0], which might be past the end of
the buffer; also skips some useless accounting */
else if(!bits)return(0L);
}
-
+
ret=b->ptr[0]<<(24+b->endbit);
if(bits>8){
ret|=b->ptr[1]<<(16+b->endbit);
@@ -408,27 +440,25 @@ long oggpackB_read(oggpack_buffer *b,int bits){
}
}
ret=((ret&0xffffffffUL)>>(m>>1))>>((m+1)>>1);
-
- overflow:
b->ptr+=bits/8;
b->endbyte+=bits/8;
b->endbit=bits&7;
- return(ret);
+ return ret;
+
+ overflow:
+ err:
+ b->ptr=NULL;
+ b->endbyte=b->storage;
+ b->endbit=1;
+ return -1L;
}
long oggpack_read1(oggpack_buffer *b){
long ret;
-
- if(b->endbyte>=b->storage){
- /* not the main path */
- ret=-1L;
- goto overflow;
- }
+ if(b->endbyte >= b->storage) goto overflow;
ret=(b->ptr[0]>>b->endbit)&1;
-
- overflow:
b->endbit++;
if(b->endbit>7){
@@ -436,21 +466,20 @@ long oggpack_read1(oggpack_buffer *b){
b->ptr++;
b->endbyte++;
}
- return(ret);
+ return ret;
+
+ overflow:
+ b->ptr=NULL;
+ b->endbyte=b->storage;
+ b->endbit=1;
+ return -1L;
}
long oggpackB_read1(oggpack_buffer *b){
long ret;
-
- if(b->endbyte>=b->storage){
- /* not the main path */
- ret=-1L;
- goto overflow;
- }
+ if(b->endbyte >= b->storage) goto overflow;
ret=(b->ptr[0]>>(7-b->endbit))&1;
-
- overflow:
b->endbit++;
if(b->endbit>7){
@@ -458,7 +487,13 @@ long oggpackB_read1(oggpack_buffer *b){
b->ptr++;
b->endbyte++;
}
- return(ret);
+ return ret;
+
+ overflow:
+ b->ptr=NULL;
+ b->endbyte=b->storage;
+ b->endbit=1;
+ return -1L;
}
long oggpack_bytes(oggpack_buffer *b){
@@ -692,7 +727,7 @@ int main(void){
fprintf(stderr,"ok.");
fprintf(stderr,"\nTesting read past end (LSb): ");
- oggpack_readinit(&r,"\0\0\0\0\0\0\0\0",8);
+ oggpack_readinit(&r,(unsigned char *)"\0\0\0\0\0\0\0\0",8);
for(i=0;i<64;i++){
if(oggpack_read(&r,1)!=0){
fprintf(stderr,"failed; got -1 prematurely.\n");
@@ -704,7 +739,7 @@ int main(void){
fprintf(stderr,"failed; read past end without -1.\n");
exit(1);
}
- oggpack_readinit(&r,"\0\0\0\0\0\0\0\0",8);
+ oggpack_readinit(&r,(unsigned char *)"\0\0\0\0\0\0\0\0",8);
if(oggpack_read(&r,30)!=0 || oggpack_read(&r,16)!=0){
fprintf(stderr,"failed 2; got -1 prematurely.\n");
exit(1);
@@ -778,7 +813,7 @@ int main(void){
fprintf(stderr,"ok.");
fprintf(stderr,"\nTesting read past end (MSb): ");
- oggpackB_readinit(&r,"\0\0\0\0\0\0\0\0",8);
+ oggpackB_readinit(&r,(unsigned char *)"\0\0\0\0\0\0\0\0",8);
for(i=0;i<64;i++){
if(oggpackB_read(&r,1)!=0){
fprintf(stderr,"failed; got -1 prematurely.\n");
@@ -790,7 +825,7 @@ int main(void){
fprintf(stderr,"failed; read past end without -1.\n");
exit(1);
}
- oggpackB_readinit(&r,"\0\0\0\0\0\0\0\0",8);
+ oggpackB_readinit(&r,(unsigned char *)"\0\0\0\0\0\0\0\0",8);
if(oggpackB_read(&r,30)!=0 || oggpackB_read(&r,16)!=0){
fprintf(stderr,"failed 2; got -1 prematurely.\n");
exit(1);
diff --git a/src/filters/transform/MpaDecFilter/libflac/src/libFLAC/Ogg/framing.c b/src/filters/transform/MpaDecFilter/libflac/src/libFLAC/Ogg/framing.c
index 24749565a..25f0e88db 100644
--- a/src/filters/transform/MpaDecFilter/libflac/src/libFLAC/Ogg/framing.c
+++ b/src/filters/transform/MpaDecFilter/libflac/src/libFLAC/Ogg/framing.c
@@ -12,7 +12,7 @@
function: code raw packets into framed OggSquish stream and
decode Ogg streams back into raw packets
- last mod: $Id: framing.c 17039 2010-03-26 00:34:54Z xiphmont $
+ last mod: $Id: framing.c 17592 2010-11-01 20:27:54Z xiphmont $
note: The CRC code is directly derived from public domain code by
Ross Williams (ross@guest.adelaide.edu.au). See docs/framing.html
@@ -275,7 +275,7 @@ static int _os_lacing_expand(ogg_stream_state *os,int needed){
/* checksum the page */
/* Direct table CRC; note that this will be faster in the future if we
- perform the checksum silmultaneously with other copies */
+ perform the checksum simultaneously with other copies */
void ogg_page_checksum_set(ogg_page *og){
if(og){
@@ -369,7 +369,7 @@ int ogg_stream_packetin(ogg_stream_state *os,ogg_packet *op){
/* Conditionally flush a page; force==0 will only flush nominal-size
pages, force==1 forces us to flush a page regardless of page size
so long as there's any data available at all. */
-static int ogg_stream_flush_i(ogg_stream_state *os,ogg_page *og, int force){
+static int ogg_stream_flush_i(ogg_stream_state *os,ogg_page *og, int force, int nfill){
int i;
int vals=0;
int maxvals=(os->lacing_fill>255?255:os->lacing_fill);
@@ -407,7 +407,7 @@ static int ogg_stream_flush_i(ogg_stream_state *os,ogg_page *og, int force){
int packets_done=0;
int packet_just_done=0;
for(vals=0;vals<maxvals;vals++){
- if(acc>4096 && packet_just_done>=4){
+ if(acc>nfill && packet_just_done>=4){
force=1;
break;
}
@@ -515,7 +515,7 @@ static int ogg_stream_flush_i(ogg_stream_state *os,ogg_page *og, int force){
an page regardless of size in the middle of a stream. */
int ogg_stream_flush(ogg_stream_state *os,ogg_page *og){
- return ogg_stream_flush_i(os,og,1);
+ return ogg_stream_flush_i(os,og,1,4096);
}
/* This constructs pages from buffered packet segments. The pointers
@@ -530,7 +530,22 @@ int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og){
(os->lacing_fill&&!os->b_o_s)) /* 'initial header page' case */
force=1;
- return(ogg_stream_flush_i(os,og,force));
+ return(ogg_stream_flush_i(os,og,force,4096));
+}
+
+/* Like the above, but an argument is provided to adjust the nominal
+page size for applications which are smart enough to provide their
+own delay based flushing */
+
+int ogg_stream_pageout_fill(ogg_stream_state *os, ogg_page *og, int nfill){
+ int force=0;
+ if(ogg_stream_check(os)) return 0;
+
+ if((os->e_o_s&&os->lacing_fill) || /* 'were done, now flush' case */
+ (os->lacing_fill&&!os->b_o_s)) /* 'initial header page' case */
+ force=1;
+
+ return(ogg_stream_flush_i(os,og,force,nfill));
}
int ogg_stream_eos(ogg_stream_state *os){
@@ -721,7 +736,7 @@ long ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og){
}
/* sync the stream and get a page. Keep trying until we find a page.
- Supress 'sync errors' after reporting the first.
+ Suppress 'sync errors' after reporting the first.
return values:
-1) recapture (hole in data)
@@ -957,7 +972,7 @@ static int _packetout(ogg_stream_state *os,ogg_packet *op,int adv){
/* Gather the whole packet. We'll have no holes or a partial packet */
{
int size=os->lacing_vals[ptr]&0xff;
- int bytes=size;
+ long bytes=size;
int eos=os->lacing_vals[ptr]&0x200; /* last packet of the stream? */
int bos=os->lacing_vals[ptr]&0x100; /* first packet of the stream? */
@@ -1007,13 +1022,13 @@ void ogg_packet_clear(ogg_packet *op) {
ogg_stream_state os_en, os_de;
ogg_sync_state oy;
-void checkpacket(ogg_packet *op,int len, int no, int pos){
+void checkpacket(ogg_packet *op,long len, int no, long pos){
long j;
static int sequence=0;
static int lastno=0;
if(op->bytes!=len){
- fprintf(stderr,"incorrect packet length (%d != %d)!\n",op->bytes,len);
+ fprintf(stderr,"incorrect packet length (%ld != %ld)!\n",op->bytes,len);
exit(1);
}
if(op->granulepos!=pos){
@@ -1544,7 +1559,7 @@ void test_pack(const int *pl, const int **headers, int byteskip,
if(ret<0)continue;
/* got a page. Happy happy. Verify that it's good. */
- fprintf(stderr,"(%ld), ",pageout);
+ fprintf(stderr,"(%d), ",pageout);
check_page(data+deptr,headers[pageout],&og_de);
deptr+=og_de.body_len;