[FFmpeg-devel] [PATCH 2/3] avcodec/mlpdec: Use get_bits() instead of get_bits_long() when possible

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Thu Jan 6 11:35:21 EET 2022


Michael Niedermayer:
> On Wed, Jan 05, 2022 at 10:38:34PM +0100, Andreas Rheinhardt wrote:
>> huff_lsbs is guaranteed to be in the range of 0..24 and
>> so is lsb_bits here, so one can use get_bits().
>>
>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
>> ---
>>  libavcodec/mlpdec.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
>> index 29fac54542..61b9a641dd 100644
>> --- a/libavcodec/mlpdec.c
>> +++ b/libavcodec/mlpdec.c
>> @@ -268,7 +268,7 @@ static inline int read_huff_channels(MLPDecodeContext *m, GetBitContext *gbp,
>>              return AVERROR_INVALIDDATA;
>>  
>>          if (lsb_bits > 0)
>> -            result = (result << lsb_bits) + get_bits_long(gbp, lsb_bits);
>> +            result = (result << lsb_bits) + get_bits(gbp, lsb_bits);
>>  
>>          result  += cp->sign_huff_offset;
>>          result *= 1 << quant_step_size;
> 
> This seems not to fully work
> 
> Assertion n>0 && n<=25 failed at libavcodec/get_bits.h:403
> 
> lsb_bits and cp->huff_lsbs are 31 in this failure, it seems
> the checks that prevent this are conditional but i didnt debug/check this
> any further
> 

Seems like I misread the check at line 841: It does not apply to the
first codebook: if (cp->codebook > 0 && cp->huff_lsbs > 24) {
Thanks for testing, patch dropped.

- Andreas


More information about the ffmpeg-devel mailing list