On 07/09/2012 07:14 PM, Alex Converse wrote:
> On Mon, Jul 9, 2012 at 2:24 PM, Justin Ruggles <justin.rugg...@gmail.com> 
> wrote:
>> allows for a larger sample size than MIN_CACHE_BITS
>> ---
>>  libavcodec/alac.c |    9 ++-------
>>  1 files changed, 2 insertions(+), 7 deletions(-)
>>
>> diff --git a/libavcodec/alac.c b/libavcodec/alac.c
>> index 5f2c8a0..0e62adb 100644
>> --- a/libavcodec/alac.c
>> +++ b/libavcodec/alac.c
>> @@ -84,7 +84,7 @@ static inline int decode_scalar(GetBitContext *gb, int k, 
>> int readsamplesize)
>>
>>      if (x > 8) { /* RICE THRESHOLD */
>>          /* use alternative encoding */
>> -        x = get_bits(gb, readsamplesize);
>> +        x = get_bits_long(gb, readsamplesize);
>>      } else if (k != 1) {
>>          int extrabits = show_bits(gb, k);
>>
>> @@ -294,6 +294,7 @@ static int alac_decode_frame(AVCodecContext *avctx, void 
>> *data,
>>      hassize = get_bits1(&alac->gb);
>>
>>      alac->extra_bits = get_bits(&alac->gb, 2) << 3;
>> +    readsamplesize = alac->sample_size - alac->extra_bits + channels - 1;
>>
>>      /* whether the frame is compressed */
>>      is_compressed = !get_bits1(&alac->gb);
>> @@ -321,12 +322,6 @@ static int alac_decode_frame(AVCodecContext *avctx, 
>> void *data,
>>              alac->output_samples_buffer[ch] = (int32_t 
>> *)alac->frame.data[ch];
>>      }
>>
>> -    readsamplesize = alac->sample_size - alac->extra_bits + channels - 1;
>> -    if (readsamplesize > MIN_CACHE_BITS) {
>> -        av_log(avctx, AV_LOG_ERROR, "readsamplesize too big (%d)\n", 
>> readsamplesize);
>> -        return -1;
>> -    }
>> -
> 
> What about the case where sample_size = 32, channels = 6, and
> extra_bits is 0? It seems possible and results in readsamplesize = 37
> which is still too big.

Yeah, I suppose we should check for that case. In practice it won't
happen though. For one thing, channels cannot be 6 here. It's 1 or 2
because it is per-element. The most it could be is 33. The reference
alac encoder uses 16 extra bits for 32-bit, so it's really only a
theoretical problem. I'll send an updated patch that handles the corner
cases.

Thanks,
Justin
_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to