[FFmpeg-devel] [PATCH 7/7] mlp: check huff_lsbs only when codebook is used

Jai Luthra me at jailuthra.in
Thu Feb 6 11:29:03 EET 2020


On Tue, Feb 04, 2020 at 10:24:50PM +0100, Michael Niedermayer wrote:
>On Mon, Feb 03, 2020 at 12:33:00AM +0530, Jai Luthra wrote:
>> When no codebook is used, huff_lsbs can be more than 24 and still decode to
>> original values once filters are applied.
>
>huff_lsbs can but get_bits() is limited to 25, you need get_bits_long() beyond

I see, thx Michael!

There are two ways to deal with this:

1) Use get_bits_long() where get_bits() is used to read the lsb_bits from the 
bitstream as it is certainly going to be within 32.

2) Limit huff_lsbs to 25 bits even if no codebook.

I tested encoding various samples and it does not go above 25 bits. It hits 25 
in mlpenc because at the matrixing stage L+R channels get added together in a 
single channel, but I am not sure if other encoders would also adhere to that.

(I was previously wrong in assuming that it hits more than 24 at the filtering 
stage, I tested it [1] and it does so after the re-matrixing stage, before any 
FIR filters)

I prefer (1) as it is cleaner. Let me know if that is OK and I'll send a 
patch.

Cheers,
Jai

[1]: https://github.com/jailuthra/FFmpeg/commit/04cf7262496cd296be3b3beaf049bdb1887f2d84
     with https://lynne.ee/files/sample.flac

>
>thx
>
>[...]
>-- 
>Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
>If you think the mosad wants you dead since a long time then you are either
>wrong or dead since a long time.


More information about the ffmpeg-devel mailing list