# HG changeset patch # User michael # Date 1220222982 0 # Node ID a34931a8fea94a4bd8cac73f23f3fe0edcf26753 # Parent 73b10d25cb8d4685b3c36fe58068924820171cbc Optimize vorbis_residue_decode() so that vr->type is a constant. Based on a patch by Siarhei Siamashka. diff -r 73b10d25cb8d -r a34931a8fea9 vorbis_dec.c --- a/vorbis_dec.c Sun Aug 31 20:26:28 2008 +0000 +++ b/vorbis_dec.c Sun Aug 31 22:49:42 2008 +0000 @@ -1224,7 +1224,7 @@ // Read and decode residue -static int vorbis_residue_decode(vorbis_context *vc, vorbis_residue *vr, uint_fast8_t ch, uint_fast8_t *do_not_decode, float *vec, uint_fast16_t vlen) { +static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc, vorbis_residue *vr, uint_fast8_t ch, uint_fast8_t *do_not_decode, float *vec, uint_fast16_t vlen, int vr_type) { GetBitContext *gb=&vc->gb; uint_fast8_t c_p_c=vc->codebooks[vr->classbook].dimensions; uint_fast16_t n_to_read=vr->end-vr->begin; @@ -1235,7 +1235,7 @@ uint_fast8_t i,j,l; uint_fast16_t k; - if (vr->type==2) { + if (vr_type==2) { for(j=1;jpartition_size, dim); vorbis_codebook codebook= vc->codebooks[vqbook]; - if (vr->type==0) { + if (vr_type==0) { voffs=voffset+j*vlen; for(k=0;ktype==1) { + else if (vr_type==1) { voffs=voffset+j*vlen; for(k=0;ktype==2 && ch==2 && (voffset&1)==0 && (dim&1)==0) { // most frequent case optimized + else if (vr_type==2 && ch==2 && (voffset&1)==0 && (dim&1)==0) { // most frequent case optimized voffs=voffset>>1; if(dim==2) { @@ -1342,7 +1342,7 @@ } } - else if (vr->type==2) { + else if (vr_type==2) { voffs=voffset; for(k=0;kavccontext, AV_LOG_ERROR, " Invalid residue type while residue decode?! \n"); - return 1; } } } @@ -1369,6 +1366,20 @@ return 0; } +static inline int vorbis_residue_decode(vorbis_context *vc, vorbis_residue *vr, uint_fast8_t ch, uint_fast8_t *do_not_decode, float *vec, uint_fast16_t vlen) +{ + if (vr->type==2) + return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, 2); + else if (vr->type==1) + return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, 1); + else if (vr->type==0) + return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, 0); + else { + av_log(vc->avccontext, AV_LOG_ERROR, " Invalid residue type while residue decode?! \n"); + return 1; + } +} + void vorbis_inverse_coupling(float *mag, float *ang, int blocksize) { int i;