[FFmpeg-devel] [PATCH] Moves yuv2yuvX_sse3 to yasm, unrolls main loop and other small optimizations for ~20% speedup.

2020-11-10 Thread Alan Kelly
--- yuv2yuvX.asm: Ports yuv2yuvX to asm, unrolls main loop and adds other small optimizations for ~20% speed-up. Copyright updated to include the original from swscale.c swscale.c: Removes yuv2yuvX_sse3 and calls new function ff_yuv2yuvX_sse3. Calls yuv2yuvX_mmxext on remainining elements if r

[FFmpeg-devel] libffmpeg.so with h264 codec support

2020-11-10 Thread Budi
I tried to build libffmpeg.so with h264 and h265 codec so go to compile as on: https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu but cannot find the exact explanation of this dynamic link build as all refer tostandalone executable build How is actually the definitive way to compile/build libff

Re: [FFmpeg-devel] libffmpeg.so with h264 codec support

2020-11-10 Thread Nicolas George
Budi (12020-11-10): > I tried to build libffmpeg.so with h264 and h265 codec so go to compile > as on: https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu > > but cannot find the exact explanation of this dynamic link build as all refer > tostandalone executable build > How is actually the defin

[FFmpeg-devel] [PATCH 000/114] VLC, esp. init_vlc patches

2020-11-10 Thread Andreas Rheinhardt
This patchset provides an alternative to ff_init_vlc_sparse() to initialize VLCs: ff_init_vlc_from_lengths(). It is based upon the observation that the codes of a complete VLC can be easily computed from the lengths if the lengths are ordered according to "left elements in the tree first". This ena

[FFmpeg-devel] [PATCH 005/114] avcodec/tscc2: Make VLC tables static

2020-11-10 Thread Andreas Rheinhardt
Also use a named constant for the number of bits of the VLC tables. Signed-off-by: Andreas Rheinhardt --- libavcodec/tscc2.c | 73 -- 1 file changed, 32 insertions(+), 41 deletions(-) diff --git a/libavcodec/tscc2.c b/libavcodec/tscc2.c index 7a591899

[FFmpeg-devel] [PATCH 002/114] avcodec/tscc2: Reduce the size of the tables used to initialize VLCs

2020-11-10 Thread Andreas Rheinhardt
After permuting both the codes, lengths and symbols tables so that the codes tables are ordered from left to right in the tree, the codes tables can be easily computed from the lengths tables at runtime and therefore omitted. This saves about 2KB from the binary. Signed-off-by: Andreas Rheinhardt

[FFmpeg-devel] [PATCH 001/114] avcodec/bitstream: Add second function to create VLCs

2020-11-10 Thread Andreas Rheinhardt
When using ff_init_vlc_sparse() to create a VLC, three input tables are used: A table for lengths, one for codes and one for symbols; the latter one can be omitted, then a default one will be used. These input tables will be traversed twice, once to get the long codes (which will be put into subtab

[FFmpeg-devel] [PATCH 006/114] avcodec/cllc: Improve creating VLCs

2020-11-10 Thread Andreas Rheinhardt
One can offload the computation of the codes to ff_init_vlc_from_lengths(); this also improves performance: The number of decicycles for one call to read_code_table() decreased from 198343 to 148338 with the sample sample-cllc-rgb.avi from the FATE suite; it has been looped 100 times and the test r

[FFmpeg-devel] [PATCH 007/114] avcodec/smacker: Improve creating Huffman VLC tables

2020-11-10 Thread Andreas Rheinhardt
The Smacker Huffman tables are already stored in a tree-like structure; in particular, they are naturally ordered from left to right in the tree and are therefore suitable to be initialized by ff_init_vlc_from_lengths() which avoids traversing the data twice in order to sort only the codes that are

[FFmpeg-devel] [PATCH 003/114] avcodec/tscc2: Combine tables for initializing VLCs

2020-11-10 Thread Andreas Rheinhardt
Using one big table for the symbols and lengths makes it possible to remove the pointers to the individual tables. Signed-off-by: Andreas Rheinhardt --- libavcodec/tscc2.c | 8 ++- libavcodec/tscc2data.h | 116 ++--- 2 files changed, 34 insertions(+), 90

[FFmpeg-devel] [PATCH 004/114] avcodec/bitstream: Allow static VLC tables to be bigger than needed

2020-11-10 Thread Andreas Rheinhardt
Right now the allocated size of the VLC table of a static VLC has to exactly match the size actually used for the VLC: If it is not enough, abort is called; if it is more than enough, an error message is emitted. This is no problem when one wants to initialize an individual VLC via one of the INIT_

[FFmpeg-devel] [PATCH 010/114] avcodec/on2avc: Apply offset when initializing VLC

2020-11-10 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/on2avc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/on2avc.c b/libavcodec/on2avc.c index 54afe8b13a..c79d3d64fb 100644 --- a/libavcodec/on2avc.c +++ b/libavcodec/on2avc.c @@ -169,7 +169,7 @@ static int on2avc

[FFmpeg-devel] [PATCH 009/114] avcodec/on2avcdata: Combine tables for codebooks

2020-11-10 Thread Andreas Rheinhardt
Using one big table for the codebook symbols and lengths makes it possible to remove the pointers to the individual tables. Signed-off-by: Andreas Rheinhardt --- libavcodec/on2avc.c | 8 ++- libavcodec/on2avcdata.c | 132 ++-- libavcodec/on2avcdata.h |

[FFmpeg-devel] [PATCH 011/114] avcodec/imc: Make Huffman tables smaller

2020-11-10 Thread Andreas Rheinhardt
The IMC decoder uses Huffman tables which are created at runtime from length tables of type uint8_t and code tables of type uint16_t together with an implicit symbols table (i.e. symbol[i] == i). This commit changes this: All three tables are subjected to the same permutation to order the codes fro

[FFmpeg-devel] [PATCH 012/114] avcodec/imc: Avoid offsets table when creating VLCs

2020-11-10 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/imc.c | 12 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/libavcodec/imc.c b/libavcodec/imc.c index 19a323e17d..a9e8a9c7e3 100644 --- a/libavcodec/imc.c +++ b/libavcodec/imc.c @@ -113,11 +113,6 @@ static VLC huffman_vlc

[FFmpeg-devel] [PATCH 014/114] avcodec/clearvideo: Avoid code duplication when initializing VLCs

2020-11-10 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/clearvideo.c | 202 +++- libavcodec/clearvideodata.h | 104 ++- 2 files changed, 90 insertions(+), 216 deletions(-) diff --git a/libavcodec/clearvideo.c b/libavcodec/clearvideo.c index fd11d88b7a

[FFmpeg-devel] [PATCH 015/114] avcodec/clearvideo: Avoid huge VLC length tables

2020-11-10 Thread Andreas Rheinhardt
After the motion vector and bias values tables have been reordered so that the codes are ordered from left to right, it emerged that the length of these entries are actually ascending for every table. Therefore it is possible to encode them in a run-length style and create the actual length tables

[FFmpeg-devel] [PATCH 016/114] avcodec/clearvideo: Inline constants

2020-11-10 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/clearvideo.c | 21 - 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/libavcodec/clearvideo.c b/libavcodec/clearvideo.c index 162dc13ce7..dd5720bda4 100644 --- a/libavcodec/clearvideo.c +++ b/libavcodec/clearvideo.

[FFmpeg-devel] [PATCH 017/114] avcodec/clearvideo: Use minimal max_depth in get_vlc2()

2020-11-10 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/clearvideo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/clearvideo.c b/libavcodec/clearvideo.c index dd5720bda4..1d88a9a776 100644 --- a/libavcodec/clearvideo.c +++ b/libavcodec/clearvideo.c @@ -371,7 +371,7 @@ s

[FFmpeg-devel] [PATCH 018/114] avcodec/clearvideo: Apply VLC offset during init

2020-11-10 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/clearvideo.c | 7 +++-- libavcodec/clearvideodata.h | 54 ++--- 2 files changed, 23 insertions(+), 38 deletions(-) diff --git a/libavcodec/clearvideo.c b/libavcodec/clearvideo.c index 1d88a9a776..9b4f03d15e 100

[FFmpeg-devel] [PATCH 020/114] avcodec/wnv1: Make array for initializing VLC smaller

2020-11-10 Thread Andreas Rheinhardt
This is possible by switching to ff_init_vlc_from_lengths() which allows to replace the table for the codes (which need an uint16_t) by a table of symbols which fit into an uint8_t. Also switch to an ordinary INIT_VLC macro while just at it. Signed-off-by: Andreas Rheinhardt --- libavcodec/wnv1.

[FFmpeg-devel] [PATCH 021/114] avcodec/wnv1: Apply offset during init, not later every time

2020-11-10 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/wnv1.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/wnv1.c b/libavcodec/wnv1.c index f8a9b94746..7dd0e72596 100644 --- a/libavcodec/wnv1.c +++ b/libavcodec/wnv1.c @@ -43,10 +43,10 @@ static inline int wnv1_ge

[FFmpeg-devel] [PATCH 019/114] avcodec/clearvideo: Make VLC tables static

2020-11-10 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/clearvideo.c | 94 ++--- 1 file changed, 40 insertions(+), 54 deletions(-) diff --git a/libavcodec/clearvideo.c b/libavcodec/clearvideo.c index 9b4f03d15e..33b94bb086 100644 --- a/libavcodec/clearvideo.c +++ b/l

[FFmpeg-devel] [PATCH 023/114] avcodec/cook: Apply offset when initializing VLC table

2020-11-10 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/cook.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/cook.c b/libavcodec/cook.c index 7b24868f57..9f44df5332 100644 --- a/libavcodec/cook.c +++ b/libavcodec/cook.c @@ -200,7 +200,7 @@ static av_cold int init_coo

[FFmpeg-devel] [PATCH 022/114] avcodec/cook: Make tables to initialize VLCs smaller

2020-11-10 Thread Andreas Rheinhardt
Up until now, the Cook decoder used tables for the lengths of codes and tables of the codes itself to initialize VLCs; the tables for the codes were of type uint16_t because the codes were so long. It did not use explicit symbol tables. This commit instead reorders the tables so that the code table

[FFmpeg-devel] [PATCH 025/114] avcodec/cook: Inline constants

2020-11-10 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/cook.c | 11 +++ 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libavcodec/cook.c b/libavcodec/cook.c index 75422d18aa..0fa42d681d 100644 --- a/libavcodec/cook.c +++ b/libavcodec/cook.c @@ -65,6 +65,9 @@ #define SUBBAND_SIZE

[FFmpeg-devel] [PATCH 026/114] avcodec/rv10: Reduce the size of the tables used to initialize VLCs

2020-11-10 Thread Andreas Rheinhardt
This can be achieved by switching to ff_init_vlc_from_lengths() which allows to replace two uint16_t tables for codes with uint8_t tables for the symbols by permuting the tables so that the codes are ordered from left to right in the tree in which case they can be easily computed from the lengths a

[FFmpeg-devel] [PATCH 024/114] avcodec/cook: Avoid big length tables for VLC initialization

2020-11-10 Thread Andreas Rheinhardt
Permuting the tables used to initialize the Cook VLCs so that the code tables are ordered from left to right in the tree revealed that the length of the codes are ascending from left to right. Therefore one can run-length encode them to avoid the big length tables; this saves a bit more than 1KB.

[FFmpeg-devel] [PATCH 029/114] avcodec/rv10: Make VLC tables smaller

2020-11-10 Thread Andreas Rheinhardt
These tables were huge (14 bits) because one needed 14 bits in order to find out whether a code is valid and in the VLC table or a valid code that required hacky workarounds due to RealVideo 1.0 using multiple codes for the same symbol and the code predating the introduction of symbols tables for V

[FFmpeg-devel] [PATCH 027/114] avcodec/rv10: Reduce number of exceptions when reading VLC value

2020-11-10 Thread Andreas Rheinhardt
RealVideo 1.0 uses an insane way to encode DC coefficients: There are several symbols that (for no good reason whatsoever) have multiple encodings, leading to longer codes than necessary. More specifically, the tree for the 256 luma symbols contains 255 codes belonging to 255 different symbols on

[FFmpeg-devel] [PATCH 030/114] avcodec/rv10: Simplify handling of skip VLC entries

2020-11-10 Thread Andreas Rheinhardt
The VLC tables to be used for parsing RealVideo 1.0 DC coefficients are weird: The luma table contains a block of 2^11 codes beginning with the same prefix and length that all have the same symbol (i.e. value only depends upon the prefix); the same goes for the chroma block (except it's only 2^9 co

[FFmpeg-devel] [PATCH 031/114] avcodec/mimic: Reduce size of tables used to initialize VLCs

2020-11-10 Thread Andreas Rheinhardt
By switching to ff_init_vlc_from_lengths() one can replace a table of codes of type uint32_t with a table of symbols of type uint8_t saving space. The old tables also had holes in it (because of the symbols) which are now superfluous, saving ever more space. Signed-off-by: Andreas Rheinhardt ---

[FFmpeg-devel] [PATCH 028/114] avcodec/rv10: Use symbol table more effectively

2020-11-10 Thread Andreas Rheinhardt
The RealVideo 1.0 decoder uses VLCs to parse DC coefficients. But the values returned from get_vlc2() are not directly used; instead -(val - 128) (which is in the range -127..128) is. This transformation is unnecessary as it can effectively be done when initializing the VLC by modifying the symbols

[FFmpeg-devel] [PATCH 033/114] avcodec/motionpixels: Only create VLC iff it is going to be used

2020-11-10 Thread Andreas Rheinhardt
If the Huffman tree consists of only one entry (which has length zero), no tree is used at all for parsing as the VLC API currently can't handle this. So it makes no sense to create a VLC in this case. Commit 41b7389cade702383e59343561776f83bb26e17f added a check for whether creating the VLC shoul

[FFmpeg-devel] [PATCH 032/114] avcodec/mimic: Make VLC static

2020-11-10 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/mimic.c | 18 +++--- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/libavcodec/mimic.c b/libavcodec/mimic.c index 32f02d4b61..3e4d7c2576 100644 --- a/libavcodec/mimic.c +++ b/libavcodec/mimic.c @@ -58,13 +58,14 @@ typede

[FFmpeg-devel] [PATCH 035/114] avcodec/motionpixels: Don't check for complete VLC

2020-11-10 Thread Andreas Rheinhardt
The algorithm used here always creates a complete VLC, so it is unnecessary to check this again. Signed-off-by: Andreas Rheinhardt --- libavcodec/motionpixels.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libavcodec/motionpixels.c b/libavcodec/motionpixels.c index 4b9830fbed..a65250efe5

[FFmpeg-devel] [PATCH 034/114] avcodec/motionpixels: Be more strict when parsing Huffman trees

2020-11-10 Thread Andreas Rheinhardt
This ensures that the number of leafs in the Huffman tree equals the number it is supposed to be and therefore ensures that the VLC tree is complete, allowing us to remove checks. Signed-off-by: Andreas Rheinhardt --- Alternatively one could use mp->current_codes_count when initializing the VLC.

[FFmpeg-devel] [PATCH 038/114] avcodec/mpc7: Reduce size of tables used to initialize VLCs

2020-11-10 Thread Andreas Rheinhardt
By switching to ff_init_vlc_from_lengths() one can replace tables of codes of type uint16_t with tables of symbols of type uint8_t, saving space. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpc7.c | 27 libavcodec/mpc7data.h | 156 -- 2

[FFmpeg-devel] [PATCH 037/114] avcodec/motionpixels: Simplify creating VLC tables

2020-11-10 Thread Andreas Rheinhardt
By using ff_init_vlc_from_lengths(), we do not have to keep track of the codes themselves, but can offload this to ff_init_vlc_from_lengths(). Furthermore, the old code presumed sizeof(int) == 4; this is no longer so. Signed-off-by: Andreas Rheinhardt --- libavcodec/motionpixels.c | 19

[FFmpeg-devel] [PATCH 036/114] avcodec/motionpixels: Use symbols table

2020-11-10 Thread Andreas Rheinhardt
If allows us to directly store the deltas in the VLC table and therefore avoids a level of indirection. Signed-off-by: Andreas Rheinhardt --- libavcodec/motionpixels.c | 17 ++--- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/libavcodec/motionpixels.c b/libavcodec/mo

[FFmpeg-devel] [PATCH 042/114] avcodec/mpc8: Apply offsets when initializing VLCs

2020-11-10 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/mpc8.c | 21 + 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/libavcodec/mpc8.c b/libavcodec/mpc8.c index 339ee515b8..31b7ad14ac 100644 --- a/libavcodec/mpc8.c +++ b/libavcodec/mpc8.c @@ -39,9 +39,6 @@ static VL

[FFmpeg-devel] [PATCH 040/114] avcodec/mpc7: Avoid offsets table when creating VLCs

2020-11-10 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/mpc7.c | 17 + 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/libavcodec/mpc7.c b/libavcodec/mpc7.c index 3c1a8578dd..7f6a01d444 100644 --- a/libavcodec/mpc7.c +++ b/libavcodec/mpc7.c @@ -38,22 +38,15 @@ static VL

[FFmpeg-devel] [PATCH 039/114] avcodec/mpc7: Apply offsets when creating VLCs

2020-11-10 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/mpc7.c | 12 ++-- libavcodec/mpc7data.h | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libavcodec/mpc7.c b/libavcodec/mpc7.c index 532ea113c2..3c1a8578dd 100644 --- a/libavcodec/mpc7.c +++ b/libavcodec/mpc7.c

[FFmpeg-devel] [PATCH 041/114] avcodec/mpc8: Reduce size of tables used to initialize VLCs

2020-11-10 Thread Andreas Rheinhardt
By switching to ff_init_vlc_from_lengths() one can make a table of codes of type uint8_t superfluous, saving space. Other VLCs (for which there was no dedicated symbols table and where the codes where already of type uint8_t) have been made to use ff_init_vlc_from_lengths(), too, because it reduce

[FFmpeg-devel] [PATCH 043/114] avcodec/mpc8: Reduce the size of the length tables to initialize VLCs

2020-11-10 Thread Andreas Rheinhardt
After permuting both length, code as well as symbol tables so that the codes are ordered from left to right in the tree, it became apparent that the length of the codes decreases from left to right. Therefore one can run-length encode the lengths to save space. This commit implements this. Signed-

[FFmpeg-devel] [PATCH 049/114] avcodec/qdm2: Make tables used to initialize VLCs smaller

2020-11-10 Thread Andreas Rheinhardt
After permuting the codes, symbols and lengths tables used to initialize the VLCs so that the codes are ordered from left to right in the Huffman tree, the codes become redundant as they can be easily computed from the lengths at runtime (or at compile time with --enable-hardcoded-tables); in this

[FFmpeg-devel] [PATCH 050/114] avcodec/qdm2_tablegen: Avoid code duplication when creating VLCs

2020-11-10 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/qdm2_tablegen.h | 159 +++-- 1 file changed, 27 insertions(+), 132 deletions(-) diff --git a/libavcodec/qdm2_tablegen.h b/libavcodec/qdm2_tablegen.h index 309bb4b53c..0e57902fc9 100644 --- a/libavcodec/qdm2_tablegen

[FFmpeg-devel] [PATCH 048/114] avcodec/mobiclip: Reindentation

2020-11-10 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/mobiclip.c | 132 +- 1 file changed, 66 insertions(+), 66 deletions(-) diff --git a/libavcodec/mobiclip.c b/libavcodec/mobiclip.c index e4a2594954..2d3225f464 100644 --- a/libavcodec/mobiclip.c +++ b/libavco

[FFmpeg-devel] [PATCH 044/114] avcodec/mpc8: Reduce the size of some VLCs

2020-11-10 Thread Andreas Rheinhardt
Several of the quantisation VLCs come in pairs and up until now the number of bits used for each VLC was set to the same value for both VLCs in such a pair even when one of the two required only a lower number. This is a waste given that the get_vlc2() call is compatible with these two VLCs using a

[FFmpeg-devel] [PATCH 045/114] avcodec/mpc8: Avoid code duplication when initializing VLCs

2020-11-10 Thread Andreas Rheinhardt
Up until now, VLCs that were part of an array of VLCs were often not initialized in a loop, but separately. The probable reason for this was that these VLCs differed slightly in the parameters to be used for them (i.e. the number of codes or the number of bits to be used differs), so that one would

[FFmpeg-devel] [PATCH 052/114] avcodec/qdm2: Initialize array of VLCs in a loop

2020-11-10 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/qdm2_tablegen.h | 12 +++- libavcodec/qdm2data.h | 28 ++-- 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/libavcodec/qdm2_tablegen.h b/libavcodec/qdm2_tablegen.h index aaa7356caf..b60989e343 1

[FFmpeg-devel] [PATCH 046/114] avcodec/mobiclip: Avoid redundant codes table to initialize VLCs

2020-11-10 Thread Andreas Rheinhardt
If both codes, lengths and symbols tables are ordered so that the codes are sorted from left to right in the tree, the codes can be easily derived from the lengths and therefore become redundant. This is exploited in this commit to remove the codes tables for the mobiclip decoder; notice that table

[FFmpeg-devel] [PATCH 051/114] avcodec/qdm2: Apply offsets when initializing VLCs

2020-11-10 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/qdm2.c | 2 +- libavcodec/qdm2_tablegen.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c index 657b2da64d..bdfe710840 100644 --- a/libavcodec/qdm2.c +++ b/libavcodec/qdm2.c @@ -

[FFmpeg-devel] [PATCH 047/114] avcodec/mobiclip: Avoid code duplication when initializing VLCs

2020-11-10 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/mobiclip.c | 106 -- 1 file changed, 51 insertions(+), 55 deletions(-) diff --git a/libavcodec/mobiclip.c b/libavcodec/mobiclip.c index cb17832898..e4a2594954 100644 --- a/libavcodec/mobiclip.c +++ b/libavco

[FFmpeg-devel] [PATCH 054/114] avcodec/rv40vlc2: Make VLC smaller

2020-11-10 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/rv40vlc2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/rv40vlc2.h b/libavcodec/rv40vlc2.h index 15119a145b..4cdc7a4193 100644 --- a/libavcodec/rv40vlc2.h +++ b/libavcodec/rv40vlc2.h @@ -33,7 +33,7 @@ * codes use

[FFmpeg-devel] [PATCH 053/114] avcodec/qdm2: Avoid offsets table when initializing VLCs

2020-11-10 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/qdm2_tablegen.h | 40 ++ 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/libavcodec/qdm2_tablegen.h b/libavcodec/qdm2_tablegen.h index b60989e343..e492f7bb60 100644 --- a/libavcodec/qdm2_tablegen.

[FFmpeg-devel] [PATCH 057/114] avcodec/rv40: Avoid offset table when initializing static VLCs

2020-11-10 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/rv40.c | 12 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/libavcodec/rv40.c b/libavcodec/rv40.c index 81e08af5f1..7ed599cd69 100644 --- a/libavcodec/rv40.c +++ b/libavcodec/rv40.c @@ -41,11 +41,6 @@ static VLC aic_top_

[FFmpeg-devel] [PATCH 056/114] avcodec/rv40: Make better use of VLC symbols table

2020-11-10 Thread Andreas Rheinhardt
RealVideo 4.0 has a VLC that encodes two intra types per code; each intra type is in the range 0..8 (inclusive) and up until now the VLC used symbols in the range 0..80; one type was encoded as the remainder when dividing the symbol by 9 whereas the other type was encoded as symbol / 9. This is sub

[FFmpeg-devel] [PATCH 058/114] avcodec/rv40: Avoid code duplication when initializing VLCs

2020-11-10 Thread Andreas Rheinhardt
Besides removing code duplication the method for determining the offset of each VLC table in the VLC_TYPE buffer also has the advantage of not wasting space for skipped AIC mode 1 VLCs. Signed-off-by: Andreas Rheinhardt --- libavcodec/rv40.c | 52 +++--- libavcodec/rv40vlc2.h | 383

[FFmpeg-devel] [PATCH 055/114] avcodec/rv40: Make the tables used to initialize VLCs smaller

2020-11-10 Thread Andreas Rheinhardt
After permuting the codes, symbols and lengths tables used to initialize the VLC so that the codes are ordered from left to right in the Huffman tree, the codes become redundant as they can be easily computed from the lengths at runtime; in this case one has to use explicit symbol tables, but all t

[FFmpeg-devel] [PATCH 060/114] avcodec/mss4: Don't duplicate standard JPEG tables

2020-11-10 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- configure | 2 +- libavcodec/mss4.c | 58 +-- 2 files changed, 7 insertions(+), 53 deletions(-) diff --git a/configure b/configure index 8a9e9b3cd7..4b47832cd7 100755 --- a/configure +++ b/configure @@ -28

[FFmpeg-devel] [PATCH 059/114] avcodec/mss4: Simplify creating VLC tables

2020-11-10 Thread Andreas Rheinhardt
The lengths of the codes used by the mss4 decoder are ascending from left to right and therefore the lengths can be run-length encoded and the codes can be easily derived from them. And this is how it is indeed done. Yet some things can nevertheless be improved: a) The number of entries of the cur

[FFmpeg-devel] [PATCH 061/114] avcodec/mss4: Make VLCs static

2020-11-10 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/mss4.c | 73 +++ 1 file changed, 29 insertions(+), 44 deletions(-) diff --git a/libavcodec/mss4.c b/libavcodec/mss4.c index 9c257dc873..9b343c9b2b 100644 --- a/libavcodec/mss4.c +++ b/libavcodec/mss4.c @

[FFmpeg-devel] [PATCH 065/114] avcodec/mjpegdec: Simplify creating VLC table

2020-11-10 Thread Andreas Rheinhardt
ff_init_vlc_from_lengths() can be used to offload the computation of the codes; it also allows to omit the check whether the codes are already properly ordered (they are). Signed-off-by: Andreas Rheinhardt --- libavcodec/mjpegdec.c | 15 +-- 1 file changed, 5 insertions(+), 10 deleti

[FFmpeg-devel] [PATCH 063/114] avcodec/sheervideo: Simplify creating VLC table

2020-11-10 Thread Andreas Rheinhardt
ff_init_vlc_from_lengths() can be used to offload the computation of the codes; it also needn't check whether the codes are already properly ordered (they are). Signed-off-by: Andreas Rheinhardt --- libavcodec/sheervideo.c | 13 - 1 file changed, 4 insertions(+), 9 deletions(-) diff

[FFmpeg-devel] [PATCH 064/114] avcodec/g2meet: Use least max_depth in get_vlc2()

2020-11-10 Thread Andreas Rheinhardt
The longest AC codes of the standard JPEG tables are 16 bits long; for the DC tables, the maximum is 11, so using max_depth of two is sufficient. Signed-off-by: Andreas Rheinhardt --- libavcodec/g2meet.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/g2meet.c

[FFmpeg-devel] [PATCH 066/114] avcodec/indeo2: Make tables used to initialize VLCs smaller

2020-11-10 Thread Andreas Rheinhardt
Switching from ff_init_vlc_sparse() to ff_init_vlc_from_lengths() allows to replace codes which are so long that they need to be stored in an uint16_t by symbols which fit into an uint8_t; furthermore, it is also easily possible to already incorporate the offset (the real range of Indeo 2 symbols s

[FFmpeg-devel] [PATCH 062/114] avcodec/sheervideo: Add av_cold to build_vlc()

2020-11-10 Thread Andreas Rheinhardt
It is an init function even when called from decode_frame(). Signed-off-by: Andreas Rheinhardt --- libavcodec/sheervideo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/sheervideo.c b/libavcodec/sheervideo.c index 976c21c445..3e60ef26a5 100644 --- a/libavcodec/sh

[FFmpeg-devel] [PATCH 070/114] avcodec/atrac3plus: Simplify creating VLCs

2020-11-10 Thread Andreas Rheinhardt
Use ff_init_vlc_from_lengths() to offload the computation of the codes. Signed-off-by: Andreas Rheinhardt --- libavcodec/atrac3plus.c | 8 ++-- 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/libavcodec/atrac3plus.c b/libavcodec/atrac3plus.c index 6b046a887e..8ae5d6b8f9 100644

[FFmpeg-devel] [PATCH 068/114] avcodec/mpeg4videodec: Make studio VLCs static

2020-11-10 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/mpeg4video.h| 4 -- libavcodec/mpeg4videodec.c | 87 -- 2 files changed, 36 insertions(+), 55 deletions(-) diff --git a/libavcodec/mpeg4video.h b/libavcodec/mpeg4video.h index 3de598465f..e919db87a5 100644

[FFmpeg-devel] [PATCH 067/114] avcodec/mpeg4video: Make tables used to initialize VLCs smaller

2020-11-10 Thread Andreas Rheinhardt
Switching from ff_init_vlc_sparse() to ff_init_vlc_from_lengths() allows to replace codes which are so long that they need to be stored in an uint16_t by symbols which fit into an uint8_t; and even these can be avoided in case of the sprite trajectory VLC. Signed-off-by: Andreas Rheinhardt --- l

[FFmpeg-devel] [PATCH 069/114] avcodec/truemotion2: Simplify creating VLC table

2020-11-10 Thread Andreas Rheinhardt
ff_init_vlc_from_lengths() can be used to offload the computation of the codes; it also allows to omit the check whether the codes are already properly ordered (they are). In this case, this also allows to avoid the allocation of the buffer for the codes. This improves performance: The amount of d

[FFmpeg-devel] [PATCH 072/114] avcodec/atrac3plus: Simplify getting offset of VLC in VLC_TYPE buf

2020-11-10 Thread Andreas Rheinhardt
The earlier code used several different offset parameters that were initialized to magic values. This is unnecessary. Signed-off-by: Andreas Rheinhardt --- libavcodec/atrac3plus.c | 25 ++--- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/libavcodec/atrac3plu

[FFmpeg-devel] [PATCH 071/114] avcodec/atrac3plus: Make tables used to initialize VLCs smaller

2020-11-10 Thread Andreas Rheinhardt
The ATRAC3+ decoder currently uses ff_init_vlc_sparse() to initialize several VLCs; sometimes a symbols table is used, sometimes not; some of the codes tables are uint16_t, some are uint8_t. Because of these two latter facts it makes sense to switch to ff_init_vlc_from_lengths() because it allows t

[FFmpeg-devel] [PATCH 074/114] avcodec/atrac3plus: Combine codebooks into one array

2020-11-10 Thread Andreas Rheinhardt
ATRAC3+ uses VLCs whose code lengths are ascending from left to right in the tree; ergo it is possible (and done) to run-length encode the lengths into so-called codebooks. These codebooks were variable-sized: The first byte contained the minimum length of a code, the second the maximum length; thi

[FFmpeg-devel] [PATCH 075/114] avcodec/atrac3plus: Run-length encode length tables to make them smaller

2020-11-10 Thread Andreas Rheinhardt
This is very beneficial for the scale factor tables where 4*64+4*15 bytes of length information can be replaced by eight codebooks of 12 bytes each; furthermore the number of codes as well as the maximum length of a code can be easily derived from said codebooks, making tables containing said infor

[FFmpeg-devel] [PATCH 076/114] avcodec/vc1: Already offset subblock VLC tables during init

2020-11-10 Thread Andreas Rheinhardt
Offseting by +1 is possible without adding dummy elements to the beginning of the codes and lengths tables by switching to ff_init_vlc_from_lengths() as this allows one to set the symbols arbitrarily without incurring any penalty. Signed-off-by: Andreas Rheinhardt --- I wonder whether the tables

[FFmpeg-devel] [PATCH 079/114] avcodec/vc1_block, msmpeg4dec: Don't check for errors for complete VLCs

2020-11-10 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/msmpeg4dec.c | 5 - libavcodec/vc1_block.c | 12 2 files changed, 17 deletions(-) diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c index 49df06a9d7..b3964457d6 100644 --- a/libavcodec/msmpeg4dec.c +++ b/libavcodec/

[FFmpeg-devel] [PATCH 073/114] avcodec/atrac3plus: Combine symbols tables

2020-11-10 Thread Andreas Rheinhardt
This allows to remove lots of pointers (130) to small symbol tables; it has the downside that some of the default tables must now be coded explicitly, but this costs only 6 + 4 + 8 + 16 + 8 bytes and is therefore dwarfed by the gains. Signed-off-by: Andreas Rheinhardt --- libavcodec/atrac3plus.c

[FFmpeg-devel] [PATCH 077/114] avcodec/vc1: Use symbols table for VLC for Block-level Transform Type

2020-11-10 Thread Andreas Rheinhardt
Expressions like array[get_vlc2()] can be optimized by using a symbols table if the array is always the same for a given VLC. This requirement is fulfilled for the VLC for the Block-level Transform Type and therefore this commit implements this; switching from ff_init_vlc_sparse() to ff_init_vlc_fr

[FFmpeg-devel] [PATCH 080/114] avcodec/vc1_block: Don't use 0 for NULL

2020-11-10 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/vc1_block.c | 20 ++-- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/libavcodec/vc1_block.c b/libavcodec/vc1_block.c index 714b3cdea0..3c9d1d4b8d 100644 --- a/libavcodec/vc1_block.c +++ b/libavcodec/vc1_block.c @@

[FFmpeg-devel] [PATCH 078/114] avcodec/vc1: Use a symbols table to decode interlaced MV vector VLCs

2020-11-10 Thread Andreas Rheinhardt
The VC1 decoder currently follows the spec very closely when decoding interlaced MV vector variable-length codes: The spec uses tables with contiguous indexes. The last of these is an escape code, for every other two values are encoded via (index + 1) / 9 and (index + 1) % 9. The decoder did exactl

[FFmpeg-devel] [PATCH 082/114] avcodec/vc1_block: Use local variables inside macro

2020-11-10 Thread Andreas Rheinhardt
This makes it clearer which variables are really just temporary variables of the macro and which are actually used externally. Signed-off-by: Andreas Rheinhardt --- libavcodec/vc1_block.c | 18 -- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/libavcodec/vc1_block

[FFmpeg-devel] [PATCH 081/114] avcodec/vc1: Use symbols table to decode AC coefficients

2020-11-10 Thread Andreas Rheinhardt
The VC1 decoder currently follows the spec very closely when decoding AC coefficients: The spec uses tables with contiguous indexes. The last of each of these is an escape code; the other codes encode three other variables via tables: run, length and whether this is the last coefficient. This comm

[FFmpeg-devel] [PATCH 084/114] avcodec/vc1: Use symbols table to parse macroblock mode

2020-11-10 Thread Andreas Rheinhardt
Expressions like array[get_vlc2()] can be optimized by using a symbols table if the array is always the same for a given VLC. This requirement is fulfilled for the VLCs used to parse the macroblock mode (MBMODE) element for frame P and B pictures. MBMODE consists of four pieces of information which

[FFmpeg-devel] [PATCH 083/114] avcodec/vc1: Use symbols table to decode MV differentials

2020-11-10 Thread Andreas Rheinhardt
The VC1 decoder currently follows the spec very closely when decoding MV differentials: The spec uses tables with contiguous indexes and derives four values from it using a pseudo-code procedure: Two flags and two values with a range of 0..5 each; the latter are obtained as the result resp. the rem

[FFmpeg-devel] [PATCH 085/114] avcodec/vc1: Don't check for errors for complete VLC

2020-11-10 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/vc1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c index 9eb02f88b3..305cc8c075 100644 --- a/libavcodec/vc1.c +++ b/libavcodec/vc1.c @@ -614,7 +614,7 @@ static void rotate_luts(VC1Context *

[FFmpeg-devel] [PATCH 086/114] avcodec/vc1: Make tables used to initialize VLCs smaller

2020-11-10 Thread Andreas Rheinhardt
By switching to ff_init_vlc_from_lengths() from ff_init_vlc_sparse() one can replace codes of type uint16_t by symbols of type uint8_t, saving space. Signed-off-by: Andreas Rheinhardt --- libavcodec/vc1.c | 27 +-- libavcodec/vc1data.c | 488 --- liba

[FFmpeg-devel] [PATCH 087/114] avcodec/vc1: Avoid code duplication when initializing VLCs

2020-11-10 Thread Andreas Rheinhardt
This has been achieved by switching those VLCs that still used ff_init_vlc_sparse() to ff_init_vlc_lengths() even though the codes tables used uint8_t in these cases. But it allows to use one auxiliary function to initialize the VLCs and by using tables that interleave symbols and lengths said func

[FFmpeg-devel] [PATCH 091/114] avcodec/atrac9dec: Don't use unnecessarily large VLC tables

2020-11-10 Thread Andreas Rheinhardt
Using more bits for a VLC than the longest code has has no advantage. Signed-off-by: Andreas Rheinhardt --- libavcodec/atrac9dec.c | 15 ++- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/libavcodec/atrac9dec.c b/libavcodec/atrac9dec.c index ecf95f1777..0477b304d2 100

[FFmpeg-devel] [PATCH 089/114] avcodec/atrac9dec: Don't confuse max_depth of VLC with max codelength

2020-11-10 Thread Andreas Rheinhardt
The whole point of VLCs with their tables is to read more than one bit at a time; therefore max_depth, the number of times one has to (maximally) read further bits is given by ceil(max_code_length / table_bits) which in the case of ATRAC9's coefficient VLCs gives an upper bound of two. Instead the

[FFmpeg-devel] [PATCH 088/114] avcodec/rv34: Avoid offsets table for initialization of static VLCs

2020-11-10 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/rv34.c | 66 +-- 1 file changed, 29 insertions(+), 37 deletions(-) diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c index 09fa962b2f..00fbcef8ec 100644 --- a/libavcodec/rv34.c +++ b/libavcodec/rv34.c @

[FFmpeg-devel] [PATCH 090/114] avcodec/atrac9dec: Use least max_depth in call to get_vlc2()

2020-11-10 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/atrac9dec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/atrac9dec.c b/libavcodec/atrac9dec.c index a1af3c22ef..ecf95f1777 100644 --- a/libavcodec/atrac9dec.c +++ b/libavcodec/atrac9dec.c @@ -272,7 +272,7 @@

[FFmpeg-devel] [PATCH 093/114] avcodec/atrac9tab: Unify tables used to initialize VLCs

2020-11-10 Thread Andreas Rheinhardt
Using separate tables has the downside that one needs a big number of pointers to the separate tables (currently 77); unifying them avoids this. Signed-off-by: Andreas Rheinhardt --- libavcodec/atrac9dec.c | 19 ++- libavcodec/atrac9tab.h | 310 ++--- 2 files

[FFmpeg-devel] [PATCH 094/114] avcodec/atrac9dec: Don't create VLCs that are never used

2020-11-10 Thread Andreas Rheinhardt
The ATRAC9 decoder creates VLCs with parameters contained in HuffmanCodebooks; some of these HuffmanCodebooks are empty and yet VLCs (that were completely unused*) were created from them. Said VLC contained a single table with 512 VLC_TYPE[2] entries, each of which indicated that this is an invalid

[FFmpeg-devel] [PATCH 095/114] avcodec/atrac9dec: Make VLCs static

2020-11-10 Thread Andreas Rheinhardt
Also remove code duplication and use a named constant for the number of VLC bits while just at it. Signed-off-by: Andreas Rheinhardt --- libavcodec/atrac9dec.c | 69 +- 1 file changed, 34 insertions(+), 35 deletions(-) diff --git a/libavcodec/atrac9dec.c

[FFmpeg-devel] [PATCH 097/114] avcodec/atrac9tab: Add missing static to internal table

2020-11-10 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/atrac9tab.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/atrac9tab.h b/libavcodec/atrac9tab.h index 1882bf9f43..b169035aad 100644 --- a/libavcodec/atrac9tab.h +++ b/libavcodec/atrac9tab.h @@ -104,7 +104,7 @@ static

[FFmpeg-devel] [PATCH 096/114] avcodec/atrac9dec: Replace av_free() by av_freep() in close function

2020-11-10 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/atrac9dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/atrac9dec.c b/libavcodec/atrac9dec.c index d2dbffe92a..585c68f33a 100644 --- a/libavcodec/atrac9dec.c +++ b/libavcodec/atrac9dec.c @@ -831,7 +831,7 @@ static

[FFmpeg-devel] [PATCH 100/114] avcodec/vp3: Use symbols table for VP3 motion vectors

2020-11-10 Thread Andreas Rheinhardt
Expressions like array[get_vlc2()] can be optimized by using a symbols table if the array is always the same for a given VLC. This requirement is fulfilled for the VLC used for VP3 motion vectors. The reason it hasn't been done before is probably that the array in this case contained entries in the

[FFmpeg-devel] [PATCH 101/114] avcodec/vp3: Remove code duplication when initializing Theora VLCs

2020-11-10 Thread Andreas Rheinhardt
theora_init_huffman_tables() does essentially the same as ff_init_vlcs_from_lengths(). Signed-off-by: Andreas Rheinhardt --- libavcodec/vp3.c | 20 +--- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c index f288a53fe1..743d00390c

  1   2   >