diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-08-31 20:30:34 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-09-01 11:05:38 +0200 |
commit | 7332a23b848555780f3d24370c8314dd9f348a35 (patch) | |
tree | 63823bc49a841a0b40f363f084787a16eb9296dd /libavcodec/wmaprodata.h | |
parent | 809d6aeffc5d6975156f1a791f5bed25622538ca (diff) | |
download | ffmpeg-7332a23b848555780f3d24370c8314dd9f348a35.tar.gz |
avcodec/magicyuv: Don't invert Huffman table symbols twice
When the MagicYUV decoder builds Huffman tables from an array of code
lengths, it proceeds as follows: First it copies the entries of the
array of lengths into an array of HuffEntries (a struct which contains
a length and a symbol field); it also sets the symbol field in
descending order from nb_elem - 1 to 0, where nb_elem is the common number
of elements of the length and HuffEntry arrays. Then the HuffEntry array
is sorted lexicographically: a > b iff a.len > b.len or a.len == b.len and
a.sym > b.sym. Afterwards the symbols of the so sorted array are
inverted again (i.e. each symbol sym is replaced by nb_elem - sym).
Yet inverting can easily be avoided altogether: Just modify the order so
that smaller symbols correspond to bigger HuffEntries. This leads to the
same permutation as the current code does and given that the two
inversions just cancel each other out, the result is the same.
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec/wmaprodata.h')
0 files changed, 0 insertions, 0 deletions