[FFmpeg-devel] [PATCH v2 013/162] avcodec/imc: Make Huffman tables smaller

2020-11-19 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 v2 162/162] avcodec/mpegaudio_tablegen: Make exponential LUT shared

2020-11-19 Thread Andreas Rheinhardt
Both the fixed as well as the floating point mpegaudio decoders use LUTs of type int8_t and uint32_t with 32K entries each; these tables are completely the same, yet they are not shared. This commit makes them shared. When both fixed as well as floating point decoders are enabled, this saves 160KiB

[FFmpeg-devel] [PATCH v2 161/162] avcodec/mpegaudiodec: Hardcode tables to save space

2020-11-19 Thread Andreas Rheinhardt
The csa_tables (which always consist of 32 entries of four byte each, but the type depends upon whether the decoder is fixed or floating-point) are currently initialized once during decoder initialization; yet it turns out that this is actually no benefit: The code used to initialize these tables t

[FFmpeg-devel] [PATCH v2 160/162] avcodec/mpegaudio_tablegen: Don't inappropriately use static array

2020-11-19 Thread Andreas Rheinhardt
Each invocation of this function is only entered once, so using a static array makes no sense (and given that the whole array is reinitialized at the beginning of this function, it wouldn't even make sense if the function were called multiple times). Signed-off-by: Andreas Rheinhardt --- libavco

[FFmpeg-devel] [PATCH v2 159/162] avcodec/mpegaudio_tablegen: Avoid write-only buffers

2020-11-19 Thread Andreas Rheinhardt
The mpegaudio_tablegen header contains code to initialize several tables; it is included in both the fixed as well as the floating point mpegaudio decoders and some of these tables are only used by the fixed resp. floating point decoders; yet both types are always initialized, leaving the compiler

[FFmpeg-devel] [PATCH v2 158/162] avcodec/mpegaudiodec: Share fixed and floating point data and init code

2020-11-19 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/Makefile | 2 +- libavcodec/mpegaudiodata.h| 31 ...pegaudiodectab.h => mpegaudiodec_common.c} | 127 ++-- libavcodec/mpegaudiodec_template.c| 137 +++--- 4 f

[FFmpeg-devel] [PATCH v2 157/162] avcodec/mpegaudiodec_template: Apply shift during init

2020-11-19 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegaudiodec_template.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/mpegaudiodec_template.c b/libavcodec/mpegaudiodec_template.c index 1faaa0ae52..3fb09511bc 100644 --- a/libavcodec/mpegaudiodec_template.c

[FFmpeg-devel] [PATCH v2 156/162] avcodec/mpegaudiodec: Make decoders init-threadsafe

2020-11-19 Thread Andreas Rheinhardt
Simple now that ff_mpadsp_init() and ff_mpa_synth_init_* are thread-safe. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegaudiodec_fixed.c| 6 +- libavcodec/mpegaudiodec_float.c| 6 +- libavcodec/mpegaudiodec_template.c | 10 -- 3 files changed, 14 insertions(+), 8

[FFmpeg-devel] [PATCH v2 154/162] avcodec/mpegaudiodec: Reduce the size of tables used to initialize VLCs

2020-11-19 Thread Andreas Rheinhardt
By switching from ff_init_vlc_sparse() to ff_init_vlc_from_lengths() one can replace tables of codes of type uint16_t by tables of symbols of type uint8_t; this saves about 1.3KB for both the fixed and floating point decoders (if enabled). Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegaud

[FFmpeg-devel] [PATCH v2 155/162] avcodec/mpegaudiodec: Combine tables used to initialize VLCs

2020-11-19 Thread Andreas Rheinhardt
Up until now, there were several indiviual tables which were accessed via pointers to them; by combining the tables, one can avoid said pointers, saving space. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegaudiodec_template.c | 15 +-- libavcodec/mpegaudiodectab.h | 144 +++

[FFmpeg-devel] [PATCH v2 153/162] avcodec/mpegaudiotab: Avoid unused entry in table

2020-11-19 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegaudiodec_template.c | 6 +++--- libavcodec/mpegaudiodectab.h | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/libavcodec/mpegaudiodec_template.c b/libavcodec/mpegaudiodec_template.c index 53db13d0d4..88679723fc 100

[FFmpeg-devel] [PATCH v2 152/162] avcodec/mpegaudiodec_template: Avoid VLC size tables

2020-11-19 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegaudiodec_template.c | 18 +++--- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/libavcodec/mpegaudiodec_template.c b/libavcodec/mpegaudiodec_template.c index 0634f70b05..53db13d0d4 100644 --- a/libavcodec/mpegaudiod

[FFmpeg-devel] [PATCH v2 151/162] avcodec/mpegaudiodec_template: Don't use unnecessarily many VLC bits

2020-11-19 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegaudiodec_template.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/mpegaudiodec_template.c b/libavcodec/mpegaudiodec_template.c index 849e3e5c09..0634f70b05 100644 --- a/libavcodec/mpegaudiodec_template.c

[FFmpeg-devel] [PATCH v2 150/162] avcodec/mv30: Inline constants

2020-11-19 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/mv30.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/mv30.c b/libavcodec/mv30.c index 1ee6be0c99..0894a4f88d 100644 --- a/libavcodec/mv30.c +++ b/libavcodec/mv30.c @@ -379,7 +379,7 @@ static int decode_coeffs(GetBit

[FFmpeg-devel] [PATCH v2 149/162] avcodec/mv30: Reduce the size of tables used to initialize VLCs

2020-11-19 Thread Andreas Rheinhardt
By switching from ff_init_vlc_sparse() to ff_init_vlc_from_lengths() one can remove the array of codes of type uint16_t here; given that the symbols are the default ones (0,1,2,...), no explicit symbols table needs to be added. Signed-off-by: Andreas Rheinhardt --- libavcodec/mv30.c | 10 ---

[FFmpeg-devel] [PATCH v2 148/162] avcodec/mv30: Don't check for errors for complete VLCs

2020-11-19 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/mv30.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/libavcodec/mv30.c b/libavcodec/mv30.c index 9f28199478..5bfe4b0614 100644 --- a/libavcodec/mv30.c +++ b/libavcodec/mv30.c @@ -379,9 +379,6 @@ static int decode_coeffs(GetBitContext *gb, i

[FFmpeg-devel] [PATCH v2 147/162] avcodec/imm4: Inline constants

2020-11-19 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/imm4.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libavcodec/imm4.c b/libavcodec/imm4.c index cee8e39773..4cbafffd9d 100644 --- a/libavcodec/imm4.c +++ b/libavcodec/imm4.c @@ -34,6 +34,7 @@ #include "internal.h"

[FFmpeg-devel] [PATCH v2 146/162] avcodec/imm4: Reduce the size of tables used to initialize VLCs

2020-11-19 Thread Andreas Rheinhardt
By switching from ff_init_vlc_sparse() to ff_init_vlc_from_lengths() one can remove arrays of codes in cases where there were already symbols tables. Signed-off-by: Andreas Rheinhardt --- libavcodec/imm4.c | 90 --- 1 file changed, 38 insertions(+), 52

[FFmpeg-devel] [PATCH v2 145/162] avcodec/imm4: Make better use of symbols table

2020-11-19 Thread Andreas Rheinhardt
Also inline the VLC's number of bits while at it. Signed-off-by: Andreas Rheinhardt --- libavcodec/imm4.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/imm4.c b/libavcodec/imm4.c index 85d8526bc8..85046f7d06 100644 --- a/libavcodec/imm4.c +++ b/libavcodec/imm

[FFmpeg-devel] [PATCH v2 144/162] avcodec/imm4: Don't use too big VLC table

2020-11-19 Thread Andreas Rheinhardt
Using more bits than the longest code has makes no sense. Signed-off-by: Andreas Rheinhardt --- libavcodec/imm4.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libavcodec/imm4.c b/libavcodec/imm4.c index d92bc30ddc..85d8526bc8 100644 --- a/libavcodec/imm4.c +++ b/lib

[FFmpeg-devel] [PATCH v2 143/162] avcodec/aac*: Make initializing ff_aac_pow*sf_tab thread-safe

2020-11-19 Thread Andreas Rheinhardt
This table is currently initialized up to three times: Once by the encoder and twice by the decoders (once by the fixed and once by the floating-point decoder); each of these initializations is guarded by an AVOnce, yet the fact that there are three of them implies that there might be data races (t

[FFmpeg-devel] [PATCH v2 142/162] avcodec/aactab: Fix conflicting types for ff_aac_codebook*

2020-11-19 Thread Andreas Rheinhardt
The header missed that these are arrays of const pointers (to const data). Signed-off-by: Andreas Rheinhardt --- libavcodec/aactab.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/aactab.h b/libavcodec/aactab.h index 7cd8128231..29df6a43f0 100644 --- a/libav

[FFmpeg-devel] [PATCH v2 141/162] avcodec/aacdec_template: Use VLC symbols table

2020-11-19 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 several VLCs used by the AAC decoders. Signed-off-by: Andreas Rheinhardt --- libavcodec/aacdec_template.c | 25 +

[FFmpeg-devel] [PATCH v2 140/162] avcodec/aacdec_template: Avoid code duplication when initializing VLCs

2020-11-19 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/aacdec_template.c | 32 +--- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c index 76fffedfcb..473a075201 100644 --- a/libavcodec/aacdec_templat

[FFmpeg-devel] [PATCH v2 139/162] avcodec/qdmc: Avoid code duplication when initializing VLC

2020-11-19 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/qdmc.c | 60 --- 1 file changed, 26 insertions(+), 34 deletions(-) diff --git a/libavcodec/qdmc.c b/libavcodec/qdmc.c index 2c870fcc1b..eca64b056e 100644 --- a/libavcodec/qdmc.c +++ b/libavcodec/qdmc.c @

[FFmpeg-devel] [PATCH v2 138/162] avcodec/qdmc: Apply offset when creating VLC

2020-11-19 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/qdmc.c | 56 ++- 1 file changed, 17 insertions(+), 39 deletions(-) diff --git a/libavcodec/qdmc.c b/libavcodec/qdmc.c index 8b50fbf30a..2c870fcc1b 100644 --- a/libavcodec/qdmc.c +++ b/libavcodec/qdmc.c @

[FFmpeg-devel] [PATCH v2 137/162] avcodec/qdmc: Make tables used to initialize VLCs smaller

2020-11-19 Thread Andreas Rheinhardt
This is possible by switching to ff_init_vlc_from_lengths() which allows to replace tables of codes of size uint16_t or uint32_t by tables of symbols of size uint8_t; in case there already were symbols tables the savings are even bigger. Signed-off-by: Andreas Rheinhardt --- libavcodec/qdmc.c |

[FFmpeg-devel] [PATCH v2 136/162] avcodec/qdmc: Don't check for errors for complete VLCs

2020-11-19 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/qdmc.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libavcodec/qdmc.c b/libavcodec/qdmc.c index ff1cc86c6b..f4e507fa60 100644 --- a/libavcodec/qdmc.c +++ b/libavcodec/qdmc.c @@ -370,8 +370,6 @@ static int qdmc_get_vlc(GetBitContext *gb, VLC

[FFmpeg-devel] [PATCH v2 135/162] avcodec/magicyuv: Optimize creating Huffman tables

2020-11-19 Thread Andreas Rheinhardt
MagicYUV transmits its Huffman trees by providing the length of the code corresponding to each symbol; then the decoder has to assemble the table in such a way that (i) longer codes are to the left of the tree and (ii) for codes of the same length the symbols are ascending from left to right. Up u

[FFmpeg-devel] [PATCH v2 134/162] avcodec/utvideodec: Avoid implicit qsort when creating Huffman tables

2020-11-19 Thread Andreas Rheinhardt
The Huffman trees used by Ut Video have two important characteristics: (i) Longer codes are on the left of the tree and (ii) for codes of the same length, the symbol is descending from left to right in the tree. Therefore all the information that needs to be transmitted is how long the code corresp

[FFmpeg-devel] [PATCH v2 133/162] avcodec/hqx: Don't check for errors for complete VLCs

2020-11-19 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/hqx.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libavcodec/hqx.c b/libavcodec/hqx.c index 44c6c1883c..aa4ff22a8f 100644 --- a/libavcodec/hqx.c +++ b/libavcodec/hqx.c @@ -122,8 +122,6 @@ static int decode_block(GetBitContext *gb, VLC *vlc

[FFmpeg-devel] [PATCH v2 132/162] avcodec/hqx: Inline constants

2020-11-19 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/hqx.c| 4 ++-- libavcodec/hqx.h| 1 + libavcodec/hqxvlc.c | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libavcodec/hqx.c b/libavcodec/hqx.c index e2b895ac40..44c6c1883c 100644 --- a/libavcodec/hqx.c +++ b/libavcodec

[FFmpeg-devel] [PATCH v2 131/162] avcodec/atrac3: Use symbols table

2020-11-19 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 several VLCs used by ATRAC3, therefore this commit implements this. This comes without any additional costs when using ff_init_vlc_from_len

[FFmpeg-devel] [PATCH v2 130/162] avcodec/intrax8: Make ff_intrax8_common_init() thread-safe

2020-11-19 Thread Andreas Rheinhardt
In particular, don't reinitialize VLCs every time an IntraX8Context is initialized. Signed-off-by: Andreas Rheinhardt --- libavcodec/intrax8.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c index b62bff3b48..0bd0db29c4 100644 -

[FFmpeg-devel] [PATCH v2 128/162] avcodec/intrax8: Avoid code duplication when initializing VLCs

2020-11-19 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/intrax8.c | 46 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c index 2a93e5efd7..9a2984c15b 100644 --- a/libavcodec/intrax8.c +++ b/libavcodec

[FFmpeg-devel] [PATCH v2 127/162] avcodec/intrax8: Remove VLC offsets table

2020-11-19 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/intrax8.c | 30 +- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c index 390c10272e..2a93e5efd7 100644 --- a/libavcodec/intrax8.c +++ b/libavcodec/intrax8.c @@ -

[FFmpeg-devel] [PATCH v2 126/162] avcodec/intrax8: Replace always-false check by assert

2020-11-19 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/intrax8.c | 16 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c index f385423dc1..390c10272e 100644 --- a/libavcodec/intrax8.c +++ b/libavcodec/intrax8.c @@ -46,7 +46,7 @@

[FFmpeg-devel] [PATCH v2 125/162] avcodec/vp3: Remove code duplication when initializing Theora VLCs

2020-11-19 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 | 21 ++--- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c index 2f43de757e..cf64a8c61

[FFmpeg-devel] [PATCH v2 124/162] avcodec/vp3: Use symbols table for VP3 motion vectors

2020-11-19 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 v2 122/162] avcodec/vp3: Apply VLC offset during init

2020-11-19 Thread Andreas Rheinhardt
By switching to ff_init_vlc_from_lengths() one can apply both positive as well as negative offsets for free; in this case it even saves space because one replaces codes tables that don't fit into an uint8_t by symbols tables that fit into an uint8_t or can even be completely avoided as they are tri

[FFmpeg-devel] [PATCH v2 121/162] avcodec/atrac9tab: Add missing static to internal table

2020-11-19 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 v2 120/162] avcodec/atrac9dec: Replace av_free() by av_freep() in close function

2020-11-19 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 6849296ac0..f0fcd0cb13 100644 --- a/libavcodec/atrac9dec.c +++ b/libavcodec/atrac9dec.c @@ -833,7 +833,7 @@ static

[FFmpeg-devel] [PATCH v2 119/162] avcodec/atrac9dec: Make VLCs static

2020-11-19 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 | 129 + 1 file changed, 67 insertions(+), 62 deletions(-) diff --git a/libavcodec/atrac9dec.c

[FFmpeg-devel] [PATCH v2 117/162] avcodec/atrac9tab: Unify tables used to initialize VLCs

2020-11-19 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 v2 114/162] avcodec/atrac9dec: Use least max_depth in calls to get_vlc2()

2020-11-19 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 v2 118/162] avcodec/atrac9dec: Don't create VLCs that are never used

2020-11-19 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 v2 113/162] avcodec/atrac9dec: Don't confuse max_depth of VLC with max codelength

2020-11-19 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 v2 112/162] avcodec/rv34: Make initializing static VLC tables thread-safe

2020-11-19 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/rv34.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c index e633c348bd..13f9b609e2 100644 --- a/libavcodec/rv34.c +++ b/libavcodec/rv34.c @@ -27,6 +27,7 @@ #include "libavutil/avasser

[FFmpeg-devel] [PATCH v2 111/162] avcodec/rv34: Avoid offsets table for initialization of static VLCs

2020-11-19 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/rv34.c | 68 +-- 1 file changed, 30 insertions(+), 38 deletions(-) diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c index 09fa962b2f..e633c348bd 100644 --- a/libavcodec/rv34.c +++ b/libavcodec/rv34.c @

[FFmpeg-devel] [PATCH v2 115/162] avcodec/atrac9dec: Don't use unnecessarily large VLC tables

2020-11-19 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 v2 110/162] avcodec/vc1: Reindentation

2020-11-19 Thread Andreas Rheinhardt
Also combine two loops while at it. Signed-off-by: Andreas Rheinhardt --- libavcodec/vc1.c | 29 + 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c index ed31b03a8a..a4f72c1808 100644 --- a/libavcodec/vc1.c +++ b/liba

[FFmpeg-devel] [PATCH v2 109/162] avcodec/vc1: Avoid code duplication when initializing VLCs

2020-11-19 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 v2 108/162] avcodec/vc1: Make ff_vc1_init_common() thread-safe

2020-11-19 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/vc1.c | 32 ++-- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c index c2a440d2e7..d4378cbae9 100644 --- a/libavcodec/vc1.c +++ b/libavcodec/vc1.c @@ -27,6 +27,7 @@ *

[FFmpeg-devel] [PATCH v2 106/162] avcodec/vc1: Make tables used to initialize VLCs smaller

2020-11-19 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 v2 107/162] avcodec/vc1data: Remove declaration of inexistent array

2020-11-19 Thread Andreas Rheinhardt
ff_vc1_norm6_spec has been removed in commit 356be9307cbffa1226bed52b26aa2ac9c7af174f (and it seems that it has never been used). Signed-off-by: Andreas Rheinhardt --- libavcodec/vc1data.h | 1 - 1 file changed, 1 deletion(-) diff --git a/libavcodec/vc1data.h b/libavcodec/vc1data.h index d376b3

[FFmpeg-devel] [PATCH v2 105/162] avcodec/vc1: Don't check for errors for complete VLC

2020-11-19 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 84617913ba..23a0743813 100644 --- a/libavcodec/vc1.c +++ b/libavcodec/vc1.c @@ -614,7 +614,7 @@ static void rotate_luts(VC1Context *

[FFmpeg-devel] [PATCH v2 104/162] avcodec/vc1: Use symbols table to parse macroblock mode

2020-11-19 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 v2 103/162] avcodec/vc1: Use symbols table to decode MV differentials

2020-11-19 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 v2 102/162] avcodec/vc1_block: Use local variables inside macro

2020-11-19 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 v2 101/162] avcodec/vc1: Use symbols table to decode AC coefficients

2020-11-19 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 v2 100/162] avcodec/vc1_block: Don't use 0 for NULL

2020-11-19 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 v2 012/162] avcodec/on2avc: Apply offset when initializing VLC

2020-11-19 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 64480c0701..3885f9acd7 100644 --- a/libavcodec/on2avc.c +++ b/libavcodec/on2avc.c @@ -169,7 +169,7 @@ static int on2avc

[FFmpeg-devel] [PATCH v2 006/162] avcodec/tscc2: Make VLC tables static

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

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

2020-11-19 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 v2 000/162] VLC, esp. init_vlc patches

2020-11-19 Thread Andreas Rheinhardt
This is the second version of my init_vlc patchset [1]. Given the feedback I received for the last version I stressed thread-safety of init functions of decoders. As a consequence, the amount of decoders with FF_CODEC_CAP_INIT_THREADSAFE increased by 25 (some of them were already thread-safe, just

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

2020-11-19 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 v2 098/162] avcodec/vc1: Use a symbols table to decode interlaced MV vector VLCs

2020-11-19 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 v2 097/162] avcodec/vc1: Use symbols table for VLC for Block-level Transform Type

2020-11-19 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 v2 096/162] avcodec/vc1: Already offset subblock VLC tables during init

2020-11-19 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 --- All the VC1 patches have imp

[FFmpeg-devel] [PATCH v2 093/162] avcodec/atrac3plus: Combine symbols tables

2020-11-19 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 v2 095/162] avcodec/atrac3plus: Run-length encode length tables to make them smaller

2020-11-19 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 v2 094/162] avcodec/atrac3plus: Combine codebooks into one array

2020-11-19 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 v2 092/162] avcodec/atrac3plus: Simplify getting offset of VLC in VLC_TYPE buf

2020-11-19 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 v2 091/162] avcodec/atrac3plus: Make tables used to initialize VLCs smaller

2020-11-19 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 v2 090/162] avcodec/atrac3plus: Simplify creating VLCs

2020-11-19 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..f527d3b9fc 100644

[FFmpeg-devel] [PATCH v2 089/162] avcodec/truemotion2: Mark decoder as init-threadsafe

2020-11-19 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/truemotion2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/truemotion2.c b/libavcodec/truemotion2.c index d6375ad489..012ad4ffde 100644 --- a/libavcodec/truemotion2.c +++ b/libavcodec/truemotion2.c @@ -1018,5 +1018

[FFmpeg-devel] [PATCH v2 088/162] avcodec/truemotion2: Simplify creating VLC table

2020-11-19 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 v2 087/162] avcodec/mpeg4videodec: Make studio VLCs static

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

[FFmpeg-devel] [PATCH v2 086/162] avcodec/mpeg4video: Make tables used to initialize VLCs smaller

2020-11-19 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 v2 085/162] avcodec/indeo2: Make decoder thread-safe

2020-11-19 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/indeo2.c | 14 +++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/libavcodec/indeo2.c b/libavcodec/indeo2.c index 5a9c0e77be..5721308267 100644 --- a/libavcodec/indeo2.c +++ b/libavcodec/indeo2.c @@ -25,6 +25,7 @@ */

[FFmpeg-devel] [PATCH v2 084/162] avcodec/indeo2: Make tables used to initialize VLCs smaller

2020-11-19 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 v2 083/162] avcodec/mjpegdec: Simplify creating VLC table

2020-11-19 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 | 23 +-- 1 file changed, 9 insertions(+), 1

[FFmpeg-devel] [PATCH v2 082/162] avcodec/g2meet: Use least max_depth in get_vlc2()

2020-11-19 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 v2 081/162] avcodec/sheervideo: Simplify creating VLC table

2020-11-19 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 v2 080/162] avcodec/sheervideo: Add av_cold to build_vlc()

2020-11-19 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 v2 079/162] avcodec/mss4: Make VLCs static

2020-11-19 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/mss4.c | 74 +++ 1 file changed, 30 insertions(+), 44 deletions(-) diff --git a/libavcodec/mss4.c b/libavcodec/mss4.c index f8edaac4cd..7f11f30dc8 100644 --- a/libavcodec/mss4.c +++ b/libavcodec/mss4.c @

[FFmpeg-devel] [PATCH v2 078/162] avcodec/mss4: Mark decoder as init-threadsafe

2020-11-19 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/mss4.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/mss4.c b/libavcodec/mss4.c index 74132fd7c1..f8edaac4cd 100644 --- a/libavcodec/mss4.c +++ b/libavcodec/mss4.c @@ -628,5 +628,5 @@ AVCodec ff_mts2_decoder = {

[FFmpeg-devel] [PATCH v2 077/162] avcodec/mss4: Don't duplicate standard JPEG tables

2020-11-19 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 51e43fbf66..10cf61007b 100755 --- a/configure +++ b/configure @@ -28

[FFmpeg-devel] [PATCH v2 076/162] avcodec/mss4: Simplify creating VLC tables

2020-11-19 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 v2 075/162] avcodec/rv40: Avoid code duplication when initializing VLCs

2020-11-19 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 v2 073/162] avcodec/rv40: Make better use of VLC symbols table

2020-11-19 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 v2 074/162] avcodec/rv40: Avoid offset table when initializing static VLCs

2020-11-19 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/rv40.c | 14 +- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/libavcodec/rv40.c b/libavcodec/rv40.c index 6f9f2c5665..b1c434d8f4 100644 --- a/libavcodec/rv40.c +++ b/libavcodec/rv40.c @@ -41,11 +41,6 @@ static VLC aic_to

[FFmpeg-devel] [PATCH v2 072/162] avcodec/rv40: Make the tables used to initialize VLCs smaller

2020-11-19 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 v2 071/162] avcodec/rv40vlc2: Make VLC smaller

2020-11-19 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 v2 070/162] avcodec/qdm2: Remove outdated comment

2020-11-19 Thread Andreas Rheinhardt
Forgotten in f054e309c58894450a5d18cce9799ef58aab9f14. Signed-off-by: Andreas Rheinhardt --- libavcodec/qdm2.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c index b1465750c2..fbc4c0cfdd 100644 --- a/libavcodec/qdm2.c +++ b/libavcodec/qdm2.c @@ -1595,8

[FFmpeg-devel] [PATCH v2 069/162] avcodec/qdm2: Make decoder init-threadsafe

2020-11-19 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/qdm2.c | 14 +- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c index f2e78c3fa2..b1465750c2 100644 --- a/libavcodec/qdm2.c +++ b/libavcodec/qdm2.c @@ -36,6 +36,7 @@ #include #inc

[FFmpeg-devel] [PATCH v2 068/162] avcodec/qdm2: Avoid offsets table when initializing VLCs

2020-11-19 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt --- libavcodec/qdm2_tablegen.h | 42 ++ 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/libavcodec/qdm2_tablegen.h b/libavcodec/qdm2_tablegen.h index 2ae8449c14..ca47fea2dc 100644 --- a/libavcodec/qdm2_tablegen.

[FFmpeg-devel] [PATCH v2 067/162] avcodec/qdm2: Initialize array of VLCs in a loop

2020-11-19 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 e948e92295..2ae8449c14 1

[FFmpeg-devel] [PATCH v2 066/162] avcodec/qdm2: Apply offsets when initializing VLCs

2020-11-19 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 bd365739ce..f2e78c3fa2 100644 --- a/libavcodec/qdm2.c +++ b/libavcodec/qdm2.c @@ -

[FFmpeg-devel] [PATCH v2 065/162] avcodec/qdm2: Make tables used to initialize VLCs smaller

2020-11-19 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

  1   2   >