[FFmpeg-soc] [soc]: r4285 - in wmapro: wma3.h wma3dec.c

faust3 subversion at mplayerhq.hu
Fri May 22 15:35:44 CEST 2009


Author: faust3
Date: Fri May 22 15:35:44 2009
New Revision: 4285

Log:
estimated how many bits might get read by
wma_get_large_val
wma_decode_channel_transform
wma_decode_tilehdr and
wma_decode_scale_factors

in order to decide how many bits might get read beyond the
end of the bitstream for damaged streams

(The exact numbers might be lower)

Modified:
   wmapro/wma3.h
   wmapro/wma3dec.c

Modified: wmapro/wma3.h
==============================================================================
--- wmapro/wma3.h	Fri May 22 12:51:24 2009	(r4284)
+++ wmapro/wma3.h	Fri May 22 15:35:44 2009	(r4285)
@@ -40,6 +40,7 @@
 /* size of block defines taken from wma.h */
 #define BLOCK_MIN_BITS  7                                    ///< log2 of min block size
 #define BLOCK_MAX_BITS 12                                    ///< log2 of max block size
+#define BLOCK_MIN_SIZE (1 << BLOCK_MIN_BITS)                 ///< minimum block size
 #define BLOCK_MAX_SIZE (1 << BLOCK_MAX_BITS)                 ///< maximum block size
 #define BLOCK_NB_SIZES (BLOCK_MAX_BITS - BLOCK_MIN_BITS + 1) ///< possible block sizes
 

Modified: wmapro/wma3dec.c
==============================================================================
--- wmapro/wma3dec.c	Fri May 22 12:51:24 2009	(r4284)
+++ wmapro/wma3dec.c	Fri May 22 15:35:44 2009	(r4285)
@@ -418,6 +418,12 @@ static int wma_decode_tilehdr(WMA3Decode
     int c;
     int missing_samples = s->num_channels * s->samples_per_frame;
 
+    /* should never consume more than 3073 bits (256 iterations for the
+     * while loop when always the minimum amount of 128 samples is substracted
+     * from missing samples in the 8 channel case)
+     * 1 + BLOCK_MAX_SIZE * MAX_CHANNELS / BLOCK_MIN_SIZE * (MAX_CHANNELS  + 4)
+     */
+
     /** reset tiling information */
     for(c=0;c<s->num_channels;c++){
         s->channel[c].num_subframes = 0;
@@ -569,6 +575,10 @@ static int wma_decode_tilehdr(WMA3Decode
 static int wma_decode_channel_transform(WMA3DecodeContext* s)
 {
     int i;
+    /* should never consume more than 1921 bits for the 8 channel case
+     * 1 + MAX_CHANNELS * ( MAX_CHANNELS + 2 + 3 * MAX_CHANNELS * MAX_CHANNELS + MAX_CHANNELS + MAX_BANDS + 1)
+     */
+
     for(i=0;i< s->num_channels;i++){
         memset(s->chgroup[i].decorrelation_matrix,0,4*s->num_channels * s->num_channels);
     }
@@ -718,6 +728,7 @@ static int wma_decode_channel_transform(
  */
 static unsigned int wma_get_large_val(WMA3DecodeContext* s)
 {
+    /* consumes up to 34 bits */
     int n_bits = 8;
     /** decode length */
     if(get_bits(&s->getbit,1)){
@@ -764,6 +775,8 @@ static int decode_coeffs(WMA3DecodeConte
         level = ff_wma3_coef0_level;
     }
 
+    /* read coefficients (consumes up to 167 bits per iteration for
+      4 vector coded large values) */
     while(cur_coeff < s->subframe_len){
         if(rl_mode){
             unsigned int idx;
@@ -799,7 +812,7 @@ static int decode_coeffs(WMA3DecodeConte
             int i = 0;
             unsigned int idx;
 
-            // read 4 values
+            /* read 4 values at once */
             idx = get_vlc2(&s->getbit, s->vec4_vlc.table, VLCBITS, ((FF_WMA3_HUFF_VEC4_MAXBITS+VLCBITS-1)/VLCBITS));
 
             if ( idx == FF_WMA3_HUFF_VEC4_SIZE - 1 ){
@@ -851,6 +864,11 @@ static int decode_coeffs(WMA3DecodeConte
 static int wma_decode_scale_factors(WMA3DecodeContext* s)
 {
     int i;
+
+    /* should never consume more than 5344 bits
+     *  MAX_CHANNELS * (1 +  MAX_BANDS * 23)
+     */
+
     for(i=0;i<s->channels_for_cur_subframe;i++){
         int c = s->channel_indexes_for_cur_subframe[i];
 


More information about the FFmpeg-soc mailing list