Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

libtremor: merge upstream revision 17528-17530, more error checking and bug fixes

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28768 a1c6a512-1295-4272-9138-f99709370657

+29 -26
+12 -11
apps/codecs/libtremor/codebook.c
··· 26 26 27 27 /* unpacks a codebook from the packet buffer into the codebook struct, 28 28 readies the codebook auxiliary structures for decode *************/ 29 - int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){ 29 + static_codebook *vorbis_staticbook_unpack(oggpack_buffer *opb){ 30 30 long i,j; 31 - memset(s,0,sizeof(*s)); 31 + static_codebook *s=_ogg_calloc(1,sizeof(*s)); 32 32 33 33 /* make sure alignment is correct */ 34 34 if(oggpack_read(opb,24)!=0x564342)goto _eofout; ··· 75 75 s->lengthlist=(long *)_ogg_malloc(sizeof(*s->lengthlist)*s->entries); 76 76 77 77 for(i=0;i<s->entries;){ 78 - long num=oggpack_read(opb,_ilog(s->entries-i)); 79 - if(num==-1)goto _eofout; 80 - for(j=0;j<num && i<s->entries;j++,i++) 81 - s->lengthlist[i]=length; 82 - length++; 78 + long num=oggpack_read(opb,_ilog(s->entries-i)); 79 + if(num==-1)goto _eofout; 80 + if(length>32)goto _errout; 81 + for(j=0;j<num && i<s->entries;j++,i++) 82 + s->lengthlist[i]=length; 83 + length++; 83 84 } 84 85 } 85 86 break; 86 87 default: 87 88 /* EOF */ 88 - return(-1); 89 + goto _eofout; 89 90 } 90 91 91 92 /* Do we have a mapping to unpack? */ ··· 127 128 } 128 129 129 130 /* all set */ 130 - return(0); 131 + return(s); 131 132 132 133 _errout: 133 134 _eofout: 134 - vorbis_staticbook_clear(s); 135 - return(-1); 135 + vorbis_staticbook_destroy(s); 136 + return(NULL); 136 137 } 137 138 138 139 /* the 'eliminate the decode tree' optimization actually requires the
+1 -2
apps/codecs/libtremor/codebook.h
··· 76 76 77 77 } codebook; 78 78 79 - extern void vorbis_staticbook_clear(static_codebook *b); 80 79 extern void vorbis_staticbook_destroy(static_codebook *b); 81 80 extern int vorbis_book_init_decode(codebook *dest,const static_codebook *source); 82 81 83 82 extern void vorbis_book_clear(codebook *b); 84 83 extern long _book_maptype1_quantvals(const static_codebook *b); 85 84 86 - extern int vorbis_staticbook_unpack(oggpack_buffer *b,static_codebook *c); 85 + extern static_codebook *vorbis_staticbook_unpack(oggpack_buffer *b); 87 86 88 87 extern long vorbis_book_decode(codebook *book, oggpack_buffer *b); 89 88 extern long vorbis_book_decodevs_add(codebook *book, ogg_int32_t *a,
+2 -2
apps/codecs/libtremor/info.c
··· 168 168 ci->books=oggpack_read(opb,8)+1; 169 169 if(ci->books<=0)goto err_out; 170 170 for(i=0;i<ci->books;i++){ 171 - ci->book_param[i]=(static_codebook *)_ogg_calloc(1,sizeof(*ci->book_param[i])); 172 - if(vorbis_staticbook_unpack(opb,ci->book_param[i]))goto err_out; 171 + ci->book_param[i]=vorbis_staticbook_unpack(opb); 172 + if(!ci->book_param[i])goto err_out; 173 173 } 174 174 175 175 /* time backend settings */
+1 -6
apps/codecs/libtremor/sharedbook.c
··· 295 295 return(NULL); 296 296 } 297 297 298 - void vorbis_staticbook_clear(static_codebook *b){ 298 + void vorbis_staticbook_destroy(static_codebook *b){ 299 299 if(b->quantlist)_ogg_free(b->quantlist); 300 300 if(b->lengthlist)_ogg_free(b->lengthlist); 301 301 memset(b,0,sizeof(*b)); 302 - 303 - } 304 - 305 - void vorbis_staticbook_destroy(static_codebook *b){ 306 - vorbis_staticbook_clear(b); 307 302 _ogg_free(b); 308 303 } 309 304
+13 -5
apps/codecs/libtremor/synthesis.c
··· 28 28 static ogg_int32_t *ipcm_vect[CHANNELS] IBSS_ATTR; 29 29 30 30 static inline int _vorbis_synthesis1(vorbis_block *vb,ogg_packet *op,int decodep){ 31 - vorbis_dsp_state *vd=vb->vd; 32 - private_state *b=(private_state *)vd->backend_state; 33 - vorbis_info *vi=vd->vi; 34 - codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; 35 - oggpack_buffer *opb=&vb->opb; 31 + vorbis_dsp_state *vd= vb ? vb->vd : 0; 32 + private_state *b= vd ? (private_state *)vd->backend_state: 0; 33 + vorbis_info *vi= vd ? vd->vi : 0; 34 + codec_setup_info *ci= vi ? (codec_setup_info *)vi->codec_setup : 0; 35 + oggpack_buffer *opb=vb ? &vb->opb : 0; 36 36 int type,mode,i; 37 37 38 + if (!vd || !b || !vi || !ci || !opb) { 39 + return OV_EBADPACKET; 40 + } 41 + 38 42 /* first things first. Make sure decode is ready */ 39 43 _vorbis_block_ripcord(vb); 40 44 oggpack_readinit(opb,op->packet,op->bytes); ··· 50 54 if(mode==-1)return(OV_EBADPACKET); 51 55 52 56 vb->mode=mode; 57 + if(!ci->mode_param[mode]){ 58 + return(OV_EBADPACKET); 59 + } 60 + 53 61 vb->W=ci->mode_param[mode]->blockflag; 54 62 if(vb->W){ 55 63 vb->lW=oggpack_read(opb,1);