]> git.sesse.net Git - ffmpeg/commit
avcodec/magicyuv: Avoid copying values around pointlessly
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Mon, 31 Aug 2020 16:55:19 +0000 (18:55 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Tue, 1 Sep 2020 09:05:38 +0000 (11:05 +0200)
commitd0b0fc7cb94f02a7de0d67cb3ba06a243b323a1d
treeb6c98d2f2df64c767ccca2a4aeac91f92792c329
parent7332a23b848555780f3d24370c8314dd9f348a35
avcodec/magicyuv: Avoid copying values around pointlessly

When parsing Huffman tables, an array of HuffEntries (a struct
containing a code's bitlength, its bits and its symbol) is used as
intermediate tables in order to sort the entries (the order depends on
both the length of the entries as well as on their symbols). After sorting
them, the symbol and len components are copied into other arrays (the
HuffEntries' code has never been set or used, despite using quite a lot
of stack space) and the codes are generated. Afterwards, the VLC is
created.

Yet ff_init_vlc_sparse() can handle non-continuous arrays as input;
there is no need to copy the entries at all. This commit implements
this.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavcodec/magicyuv.c