]> git.sesse.net Git - ffmpeg/log
ffmpeg
3 years agoswscale/rgb2rgb_template: use shuffle macro on big-endian arches
Andriy Gelman [Mon, 30 Nov 2020 05:46:51 +0000 (00:46 -0500)]
swscale/rgb2rgb_template: use shuffle macro on big-endian arches

Fixes fate-qtrle-32bit on big-endian.

The macro does a simple byte swap on uint8 array without any casts, so
it's valid on big-endian arches.

The mentioned test was failing because the byteswap function
shuffle_bytes_3210_c() is used in the pixel format conversion
(argb->bgra).

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
3 years agolavfi/dnn: check the return value from sws_getContext
Jun Zhao [Wed, 9 Dec 2020 09:53:10 +0000 (17:53 +0800)]
lavfi/dnn: check the return value from sws_getContext

sws_getContext may be return NULL, and it's will be dereferenced,
so add the check.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
3 years agolavfi/dnn: used the format name in debug message
Jun Zhao [Wed, 9 Dec 2020 09:53:09 +0000 (17:53 +0800)]
lavfi/dnn: used the format name in debug message

Used the format name in debug message.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
3 years agoavformat/iff: Check data_size
Michael Niedermayer [Thu, 10 Dec 2020 23:49:23 +0000 (00:49 +0100)]
avformat/iff: Check data_size

Fixes: infinite loop
Fixes: 27834/clusterfuzz-testcase-minimized-ffmpeg_dem_IFF_fuzzer-5694930919620608
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavfilter/vf_fade: add timeline support
Paul B Mahol [Fri, 11 Dec 2020 21:59:43 +0000 (22:59 +0100)]
avfilter/vf_fade: add timeline support

3 years agoavfilter/af_afade: add support for commands to afade filter
Paul B Mahol [Fri, 11 Dec 2020 21:56:22 +0000 (22:56 +0100)]
avfilter/af_afade: add support for commands to afade filter

3 years agoavfilter/vf_convolution: add support for commands
Paul B Mahol [Fri, 11 Dec 2020 17:28:12 +0000 (18:28 +0100)]
avfilter/vf_convolution: add support for commands

3 years agoavfilter/vf_chromanr: add options for finer controls of filtering
Paul B Mahol [Fri, 11 Dec 2020 12:35:41 +0000 (13:35 +0100)]
avfilter/vf_chromanr: add options for finer controls of filtering

3 years agoavfilter: add asuperpass and asuperstop filter
Paul B Mahol [Sun, 6 Dec 2020 21:48:12 +0000 (22:48 +0100)]
avfilter: add asuperpass and asuperstop filter

3 years agoavcodec/speedhqenc: Call correct function
Andreas Rheinhardt [Thu, 10 Dec 2020 07:50:37 +0000 (08:50 +0100)]
avcodec/speedhqenc: Call correct function

Up until now, the SpeedHQ encoder called a wrong function for init:
void ff_init_uni_ac_vlc(const uint8_t huff_size_ac[256],
                        uint8_t *uni_ac_vlc_len);
Yet the first argument actually used is of type RLTable; the size of
said struct is less than 256 if the size of a pointer is four, leading
to an access beyond the end of the RLTable.

This commit fixes this by calling the actually intended function:
init_uni_ac_vlc() from mpeg12enc.c. It was intended to use this
function [1], yet doing so was forgotten when the patch was actually
applied.

[1]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-July/266187.html

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/utils: Improve ffio_limit logic
Andreas Rheinhardt [Fri, 11 Dec 2020 00:46:15 +0000 (01:46 +0100)]
avformat/utils: Improve ffio_limit logic

The earlier code would not complain if the remaining size was one byte
short of the desired size; and the way it performed the check could run
into signed integer overflow.

Fixes: signed integer overflow: 9223372036854775807 + 1 cannot be represented in type 'long'
Fixes: Timeout
Fixes: 26434/clusterfuzz-testcase-minimized-ffmpeg_dem_MV_fuzzer-5752845451919360
Fixes: 26444/clusterfuzz-testcase-minimized-ffmpeg_dem_BINK_fuzzer-4697773380993024
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agolavf/rawdec: Return a low score if the mjpeg probe function detected one frame.
Carl Eugen Hoyos [Wed, 9 Dec 2020 22:42:33 +0000 (23:42 +0100)]
lavf/rawdec: Return a low score if the mjpeg probe function detected one frame.

Fixes ticket #9026.

3 years agoavfilter/af_earwax: fix check that was left in previous commit
Paul B Mahol [Thu, 10 Dec 2020 22:39:49 +0000 (23:39 +0100)]
avfilter/af_earwax: fix check that was left in previous commit

Makes output exact with smaller number of samples per frame than taps.

3 years agoavformat/hashenc: Reuse hash_free() for framehash muxers
Andreas Rheinhardt [Sun, 6 Dec 2020 23:41:25 +0000 (00:41 +0100)]
avformat/hashenc: Reuse hash_free() for framehash muxers

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec: set AV_CODEC_CAP_CHANNEL_CONF on decoders which set their own channels
Hendrik Leppkes [Sat, 5 Dec 2020 10:41:23 +0000 (11:41 +0100)]
avcodec: set AV_CODEC_CAP_CHANNEL_CONF on decoders which set their own channels

The decoders in this set either have a fixed channel count, or read it
from the bitstream, and thus do not require the channel count as
external information.

Fixes various regressions since
81503ac58a763a36b1f57264013b1e76acb62b68, which requires a valid channel
count for decoders which do not set this capability.

Signed-off-by: Hendrik Leppkes <h.leppkes@gmail.com>
3 years agotests/audiomatch: add free to make static analysis tools happy
Jun Zhao [Mon, 7 Dec 2020 07:47:09 +0000 (15:47 +0800)]
tests/audiomatch: add free to make static analysis tools happy

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
3 years agoavformat/mov: remove an always true condition
Zhao Zhili [Fri, 18 Sep 2020 14:33:38 +0000 (22:33 +0800)]
avformat/mov: remove an always true condition

3 years agosmvjpegdec: merge into mjpegdec
Anton Khirnov [Tue, 1 Dec 2020 18:32:00 +0000 (19:32 +0100)]
smvjpegdec: merge into mjpegdec

SMVJPEG stores frames as slices of a big JPEG image. The decoder is
implemented as a wrapper that instantiates a full internal MJPEG
decoder, then forwards the decoded frames with offset data pointers.
This is unnecessarily complex and fragile, not supporting useful decoder
capabilities like direct rendering.

Re-implement the decoder inside the MJPEG decoder, which is accomplished
by returning each decoded frame multiple times, setting cropping
information appropriately on each instance.

One peculiar aspect of the previous design is that since
- the smvjpeg decoder returns one frame per input packet
- there are multiple frames in each packets (the aformentioned slices)
the demuxer needs to return each packet multiple times.
This is now also eliminated - the demuxer now returns each packet
exactly once, with the duration set to the number of frames it decodes
to.

This also removes one of the last remaining internal uses of the old
video decoding API.

3 years agomjpegdec: convert to receive_frame()
Anton Khirnov [Tue, 1 Dec 2020 10:34:27 +0000 (11:34 +0100)]
mjpegdec: convert to receive_frame()

This will be useful in the following commit.

3 years agotests: stop using -vsync drop
Anton Khirnov [Mon, 30 Nov 2020 13:13:51 +0000 (14:13 +0100)]
tests: stop using -vsync drop

It depends on the muxer generating the timestamps, which is deprecated
and scheduled for removal on next bump.

A bunch of tests change timestamps, because of ffmpeg.c is not
generating them correctly. This should be fixed later.

3 years agoffmpeg: stop accessing deprecated stream-embedded codec context
Anton Khirnov [Sun, 29 Nov 2020 15:43:07 +0000 (16:43 +0100)]
ffmpeg: stop accessing deprecated stream-embedded codec context

3 years agolavf/mux: rewrite guessing the packet duration
Anton Khirnov [Sun, 29 Nov 2020 16:40:14 +0000 (17:40 +0100)]
lavf/mux: rewrite guessing the packet duration

Factor out the code into a separate muxing-specific function.
Stop accessing the deprecated AVStream-embedded codec context, use the
average framerate (if specified) instead.

3 years agotests: drop api-codec-param test
Anton Khirnov [Sun, 29 Nov 2020 16:12:34 +0000 (17:12 +0100)]
tests: drop api-codec-param test

It fundamentally depends on deprecated lavf internals.

3 years agolavd/caca: do not access deprecated codec context
Anton Khirnov [Sun, 29 Nov 2020 15:28:08 +0000 (16:28 +0100)]
lavd/caca: do not access deprecated codec context

Use the stream timebase instead.

3 years agocodec_desc: add SMVJPEG flags
Anton Khirnov [Tue, 1 Dec 2020 17:55:22 +0000 (18:55 +0100)]
codec_desc: add SMVJPEG flags

Same flags as MJPEG, as it's essentially the same codec.

3 years agoimg2dec: export avg_frame_rate
Anton Khirnov [Wed, 7 Oct 2020 11:02:39 +0000 (13:02 +0200)]
img2dec: export avg_frame_rate

3 years agoavcodec/hevcdec: dynamic allocate sList and HEVClcList
Nuo Mi [Sun, 29 Nov 2020 15:30:10 +0000 (23:30 +0800)]
avcodec/hevcdec: dynamic allocate sList and HEVClcList

following comandline will crash the ffmpeg
ffmpeg -threads 17 -thread_type slice -i WPP_A_ericsson_MAIN_2.bit out.yuv -y

the HEVCContext->sList size is MAX_NB_THREADS(16), any > 16 thread number will crash the application

Signed-off-by: Anton Khirnov <anton@khirnov.net>
3 years agoavcodec/snow: Use ff_thread_once() in ff_snow_common_init()
Andreas Rheinhardt [Tue, 1 Dec 2020 23:10:13 +0000 (00:10 +0100)]
avcodec/snow: Use ff_thread_once() in ff_snow_common_init()

ff_snow_common_init() currently initializes static data every time it is
invoked; given that both the Snow encoder and decoder have the
FF_CODEC_CAP_INIT_THREADSAFE flag set, this can lead to data races (and
therefore undefined behaviour) even though all threads write the same
values. This commit fixes this by using ff_thread_once() for the
initializations.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/idcinvideo: Mark decoder as init-threadsafe
Andreas Rheinhardt [Mon, 30 Nov 2020 17:24:37 +0000 (18:24 +0100)]
avcodec/idcinvideo: Mark decoder as init-threadsafe

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/cinepak: Mark decoder as init-threadsafe
Andreas Rheinhardt [Mon, 30 Nov 2020 13:46:30 +0000 (14:46 +0100)]
avcodec/cinepak: Mark decoder as init-threadsafe

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/cinepakenc: Mark encoder as init-threadsafe
Andreas Rheinhardt [Mon, 30 Nov 2020 13:44:49 +0000 (14:44 +0100)]
avcodec/cinepakenc: Mark encoder as init-threadsafe

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/matroskadec: Sanity check codec_id/track type
Michael Niedermayer [Sun, 6 Dec 2020 23:37:25 +0000 (00:37 +0100)]
avformat/matroskadec: Sanity check codec_id/track type

Fixes: memleak
Fixes: 27766/clusterfuzz-testcase-minimized-ffmpeg_dem_MATROSKA_fuzzer-5198300814508032
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/rpl: Check the number of streams
Michael Niedermayer [Tue, 8 Dec 2020 23:49:29 +0000 (00:49 +0100)]
avformat/rpl: Check the number of streams

Fixes: out of memory access
Fixes: 27787/clusterfuzz-testcase-minimized-ffmpeg_dem_RPL_fuzzer-4743666463408128.fuzz
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/vividas: Check sample_rate
Michael Niedermayer [Tue, 10 Nov 2020 21:36:25 +0000 (22:36 +0100)]
avformat/vividas: Check sample_rate

Fixes: Assertion c > 0 failed at libavutil/mathematics.c
Fixes: 27001/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVIDAS_fuzzer-5726041328582656
Fixes: 27453/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVIDAS_fuzzer-5716060384526336
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/vividas: Make len signed
Michael Niedermayer [Sun, 22 Nov 2020 16:24:20 +0000 (17:24 +0100)]
avformat/vividas: Make len signed

Fixes: out of array access
Fixes: 27424/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVIDAS_fuzzer-5682070692823040
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/vaapi_av1: fill the remaining VAFilmGrainStructAV1 fields
James Almer [Mon, 30 Nov 2020 16:55:11 +0000 (13:55 -0300)]
avcodec/vaapi_av1: fill the remaining VAFilmGrainStructAV1 fields

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/exr: preserve half-float NaN bits and add fate test
Mark Reid [Mon, 23 Nov 2020 04:32:15 +0000 (20:32 -0800)]
avcodec/exr: preserve half-float NaN bits and add fate test

Handles NaNs more like the official implementation handles them, preserving
the original bits.

3 years agoavfilter/cropdetect: add option for initial skip
Gyan Doshi [Tue, 8 Dec 2020 13:22:37 +0000 (18:52 +0530)]
avfilter/cropdetect: add option for initial skip

The cropdetect filter, at present, skips the first two frames. This
behaviour is hardcoded.

New option 'skip' allows users to change this. Convenient for when
input is a single image or a trimmed video stream.

Default is kept at 2 to preserve current behaviour.

3 years agoavcodec/mpegvideo_enc: check for SpeedHQ encoder
Gyan Doshi [Tue, 8 Dec 2020 13:32:41 +0000 (19:02 +0530)]
avcodec/mpegvideo_enc: check for SpeedHQ encoder

Avoids build failure when mpegvideo_enc is built but SpeedHQ encoder
isn't.

3 years agoavcodec/libaom: Support monochrome encoding with libaom >= 2.0.1
Philip Langdale [Tue, 8 Dec 2020 00:33:29 +0000 (16:33 -0800)]
avcodec/libaom: Support monochrome encoding with libaom >= 2.0.1

Monochrome encoding with libaom was buggy for a long time, but this was
finally sorted out in libaom 2.0.1 (2.0.0 is almost there but was still
buggy in realtime mode).

We'll keep support for libaom 1.x around until the LTS distros that
include it are EOL (which is still a long time from now).

Fixes: https://trac.ffmpeg.org/ticket/7599
3 years agoavformat/framecrcenc: Make side-data checksums endian-independent
Andreas Rheinhardt [Sun, 6 Dec 2020 02:48:22 +0000 (03:48 +0100)]
avformat/framecrcenc: Make side-data checksums endian-independent

Do this by converting big-endian side data to little endian for
checksumming.

Reviewed-by: Andriy Gelman <andriy.gelman@gmail.com>
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/framecrcenc: Don't read after the end of side-data
Andreas Rheinhardt [Sun, 6 Dec 2020 00:45:14 +0000 (01:45 +0100)]
avformat/framecrcenc: Don't read after the end of side-data

Nothing guarantees that the size of side data containing a palette
is actually divisible by four (although it should be); but for
big-endian systems, an algorithm is used that presupposed this.
So switch to an algorithm that does not overread: It processes
four bytes at a time, but only if all of them are contained in
the side data.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/wmadec: Apply VLC offset during init
Andreas Rheinhardt [Mon, 23 Nov 2020 04:12:02 +0000 (05:12 +0100)]
avcodec/wmadec: Apply VLC offset during init

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/wmadec: Reduce the size of tables used to initialize VLC
Andreas Rheinhardt [Mon, 23 Nov 2020 04:09:57 +0000 (05:09 +0100)]
avcodec/wmadec: Reduce the size of tables used to initialize VLC

By switching from ff_init_vlc_sparse() to ff_init_vlc_from_lengths() one
can replace a table of codes of type uint16_t by a table of symbols of
type uint8_t, saving space.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/ivi: Make initializing VLCs thread-safe
Andreas Rheinhardt [Mon, 23 Nov 2020 03:57:03 +0000 (04:57 +0100)]
avcodec/ivi: Make initializing VLCs thread-safe

This automatically makes indeo4/5 init-threadsafe.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/dsddec: Inline constant
Andreas Rheinhardt [Mon, 23 Nov 2020 03:33:33 +0000 (04:33 +0100)]
avcodec/dsddec: Inline constant

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/dsd: Make initializing DSD tables thread-safe
Andreas Rheinhardt [Mon, 23 Nov 2020 03:20:07 +0000 (04:20 +0100)]
avcodec/dsd: Make initializing DSD tables thread-safe

This automatically makes the DSD formats as well as DST and WavPack
init-threadsafe.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/wavpack: Fix leak on init failure
Andreas Rheinhardt [Mon, 23 Nov 2020 03:09:56 +0000 (04:09 +0100)]
avcodec/wavpack: Fix leak on init failure

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/h261enc: Remove unused function parameter
Andreas Rheinhardt [Mon, 23 Nov 2020 02:21:34 +0000 (03:21 +0100)]
avcodec/h261enc: Remove unused function parameter

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/asvdec: Reindentation
Andreas Rheinhardt [Mon, 23 Nov 2020 02:49:35 +0000 (03:49 +0100)]
avcodec/asvdec: Reindentation

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/asvdec: Make decoders init-threadsafe
Andreas Rheinhardt [Mon, 23 Nov 2020 02:49:05 +0000 (03:49 +0100)]
avcodec/asvdec: Make decoders init-threadsafe

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/sinewin: Fix wrong number of elements of array declaration
Andreas Rheinhardt [Mon, 23 Nov 2020 01:45:27 +0000 (02:45 +0100)]
avcodec/sinewin: Fix wrong number of elements of array declaration

There are actually only 14 elements in each ff_sine_windows array.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/aactab: Make AAC encoder and decoders actually init-threadsafe
Andreas Rheinhardt [Sun, 22 Nov 2020 22:42:40 +0000 (23:42 +0100)]
avcodec/aactab: Make AAC encoder and decoders actually init-threadsafe

Commit 1a29804558c13ef512d9ef73a9b0d782af4fa5f2 guarded several
initializations of static data in the AAC decoders with an AVOnce and
set the FF_CODEC_CAP_INIT_THREADSAFE flag, believing the former to be
sufficient for the latter. It wasn't, because several of these static
tables are shared with other components, so that there might be data
races if they are initialized from multiple threads. This affected
initializing the ff_sine_* tables as well as initializing the
ff_aac_pow*sf_tab tables (shared between both decoders and encoder) as
well as ff_aac_kbd_* tables (shared between encoder and floating point
decoder).

Commit 3d62e7a30fa552be52d12b31e3e0f79153aff891 set the
FF_CODEC_CAP_INIT_THREADSAFE flag for the AAC encoder. More explicitly,
this commit used the same AVOnce to guard initializing ff_aac_pow*sf_tab
in the encoder and to guard initializing the static data of each
decoder; the ensuing catastrophe was "fixed" in commit
ec0719264cb9a9d5cbaf225da48929aea24997a3 by using a single AVOnce
for each codec again. But the codec cap has not been removed and
therefore the encoder claimed to be init-threadsafe, but wasn't, because
of the same tables as above.

The ff_sine_* tables as well as ff_aac_pow*sf_tab tables have already
been fixed; this commit deals with the ff_aac_kbd_* tables, making the
encoder as well as the floating-point decoder init-threadsafe (the
fixed-point decoder is it already).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/aac: Share common init code of float decoder and encoder
Andreas Rheinhardt [Sun, 22 Nov 2020 22:33:03 +0000 (23:33 +0100)]
avcodec/aac: Share common init code of float decoder and encoder

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/aacdec, aactab: Move kbd tables to their only user
Andreas Rheinhardt [Sun, 22 Nov 2020 19:09:02 +0000 (20:09 +0100)]
avcodec/aacdec, aactab: Move kbd tables to their only user

The floating point kbd tables for 120 and 960 samples are only used by
the floating point decoder whereas the fixed point kbd tables for 128
and 1024 samples are only used by the fixed point AAC decoder. So move
these tables to their only users. This ensures that they are not
accidentally used somewhere else without ensuring that initializing
these tables stays thread-safe (as it is now because the only place from
where they are initialized is guarded by an AVOnce).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/aactab: Remove declaration of inexistent array
Andreas Rheinhardt [Sun, 22 Nov 2020 19:00:30 +0000 (20:00 +0100)]
avcodec/aactab: Remove declaration of inexistent array

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/nellymoserenc: Make encoder init-threadsafe
Andreas Rheinhardt [Sun, 22 Nov 2020 17:12:58 +0000 (18:12 +0100)]
avcodec/nellymoserenc: Make encoder init-threadsafe

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/nellymoserenc: Cleanup generically on init failure
Andreas Rheinhardt [Sun, 22 Nov 2020 17:04:02 +0000 (18:04 +0100)]
avcodec/nellymoserenc: Cleanup generically on init failure

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/nellymoserdec: Make decoder init-threadsafe
Andreas Rheinhardt [Sun, 22 Nov 2020 16:57:38 +0000 (17:57 +0100)]
avcodec/nellymoserdec: Make decoder init-threadsafe

Easy now that initializing the ff_sine_* tables is thread-safe.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/atrac3plus: Make decoders init-threadsafe
Andreas Rheinhardt [Sun, 22 Nov 2020 16:51:00 +0000 (17:51 +0100)]
avcodec/atrac3plus: Make decoders init-threadsafe

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/atrac1: Mark decoder as init-threadsafe
Andreas Rheinhardt [Sun, 22 Nov 2020 16:32:26 +0000 (17:32 +0100)]
avcodec/atrac1: Mark decoder as init-threadsafe

Possible because ff_init_ff_sine_windows() is now threadsafe.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/sinewin_tablegen: Make initializing ff_sine_windows thread-safe
Andreas Rheinhardt [Sun, 22 Nov 2020 16:29:21 +0000 (17:29 +0100)]
avcodec/sinewin_tablegen: Make initializing ff_sine_windows thread-safe

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/aacdec, sinewin: Move 120 and 960 point sine tables to aacdec
Andreas Rheinhardt [Sun, 22 Nov 2020 13:27:45 +0000 (14:27 +0100)]
avcodec/aacdec, sinewin: Move 120 and 960 point sine tables to aacdec

The floating point AAC decoder is the only user of these tables, so it
makes sense to move them there. Furthermore, initializing the ordinary
power-of-two sinetables is currently not thread-safe and if the 120- and
960-point sinetables were not moved, one would have to choose whether
to guard initializing these two tables with their own AVOnces or not.
Doing so would add unnecessary AVOnces as the AAC decoder already guards
initializing its static data by an AVOnce; not doing so would be fragile
if a second user of these tables were to be added.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/sinewin_tablegen: Use better check in assert
Andreas Rheinhardt [Sun, 22 Nov 2020 13:02:06 +0000 (14:02 +0100)]
avcodec/sinewin_tablegen: Use better check in assert

There are no ff_sine_windows for 2^i, 0 <= i < 5, so one should check
for the index being >= 5.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/atrac3: Make decoders init-threadsafe
Andreas Rheinhardt [Sun, 22 Nov 2020 12:38:44 +0000 (13:38 +0100)]
avcodec/atrac3: Make decoders init-threadsafe

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/atrac: Make generating tables thread-safe
Andreas Rheinhardt [Sun, 22 Nov 2020 12:30:07 +0000 (13:30 +0100)]
avcodec/atrac: Make generating tables thread-safe

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mpegaudio_tablegen: Make exponential LUT shared
Andreas Rheinhardt [Wed, 18 Nov 2020 12:13:45 +0000 (13:13 +0100)]
avcodec/mpegaudio_tablegen: Make exponential LUT shared

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 from the bss segment for a normal build
(translating into 160KiB less memory usage if both a shared as well as
a floating point decoder have actually been used) and 160KiB from the
binary for a build with hardcoded tables.

It also means that the code to create said LUTs is no longer duplicated
(for a normal build).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mpegaudiodec: Hardcode tables to save space
Andreas Rheinhardt [Wed, 18 Nov 2020 01:19:53 +0000 (02:19 +0100)]
avcodec/mpegaudiodec: Hardcode tables to save space

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 takes up 153 (fixed point) and 122
(floating point) bytes when compiled with GCC 9.3 with -O3 on x64, so it
is better to just hardcode these tables.

Essentially the same applies to the is_tables: They have a size of 128B
each and the code to initialize them occupies 149 (fixed point) resp.
140 (floating point) bytes. So hardcode them, too.

To make the origin of the tables clear, references to the code used to
create them have been added.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mpegaudio_tablegen: Don't inappropriately use static array
Andreas Rheinhardt [Tue, 17 Nov 2020 22:42:58 +0000 (23:42 +0100)]
avcodec/mpegaudio_tablegen: Don't inappropriately use static array

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 <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mpegaudio_tablegen: Avoid write-only buffers
Andreas Rheinhardt [Tue, 17 Nov 2020 22:20:03 +0000 (23:20 +0100)]
avcodec/mpegaudio_tablegen: Avoid write-only buffers

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 to figure out that one of them is unused.

GCC 9.3 fails at this (even with -O3):
$ readelf -s mpegaudiodec_fixed.o|grep _float
    28: 0000000000001660 32768 OBJECT  LOCAL  DEFAULT    4 expval_table_float
An actually unused table (expval_table_fixed/float) of size 32KiB is kept
and initialized (the reason for this is probably that this table is read
from, namely to initialize another table: exp_table_fixed/float; of course
the float resp. fixed tables are not used in the fixed resp. floating point
decoder).

Therefore #ifdef the unneeded tables away.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mpegaudiodec: Share fixed and floating point data and init code
Andreas Rheinhardt [Tue, 17 Nov 2020 21:25:35 +0000 (22:25 +0100)]
avcodec/mpegaudiodec: Share fixed and floating point data and init code

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mpegaudiodec_template: Apply shift during init
Andreas Rheinhardt [Tue, 17 Nov 2020 20:37:21 +0000 (21:37 +0100)]
avcodec/mpegaudiodec_template: Apply shift during init

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mpegaudiodec: Make decoders init-threadsafe
Andreas Rheinhardt [Tue, 17 Nov 2020 17:44:18 +0000 (18:44 +0100)]
avcodec/mpegaudiodec: Make decoders init-threadsafe

Simple now that ff_mpadsp_init() and ff_mpa_synth_init_* are thread-safe.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mpegaudiodec: Combine tables used to initialize VLCs
Andreas Rheinhardt [Tue, 17 Nov 2020 16:34:04 +0000 (17:34 +0100)]
avcodec/mpegaudiodec: Combine tables used to initialize VLCs

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 <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mpegaudiodec: Reduce the size of tables used to initialize VLCs
Andreas Rheinhardt [Tue, 17 Nov 2020 14:53:43 +0000 (15:53 +0100)]
avcodec/mpegaudiodec: Reduce the size of tables used to initialize VLCs

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).

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mpegaudiotab: Avoid unused entry in table
Andreas Rheinhardt [Tue, 17 Nov 2020 14:16:01 +0000 (15:16 +0100)]
avcodec/mpegaudiotab: Avoid unused entry in table

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mpegaudiodec_template: Avoid VLC size tables
Andreas Rheinhardt [Tue, 17 Nov 2020 14:03:02 +0000 (15:03 +0100)]
avcodec/mpegaudiodec_template: Avoid VLC size tables

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mv30: Inline constants
Andreas Rheinhardt [Mon, 16 Nov 2020 13:58:06 +0000 (14:58 +0100)]
avcodec/mv30: Inline constants

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mv30: Reduce the size of tables used to initialize VLCs
Andreas Rheinhardt [Mon, 16 Nov 2020 13:56:13 +0000 (14:56 +0100)]
avcodec/mv30: Reduce the size of tables used to initialize VLCs

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 <andreas.rheinhardt@gmail.com>
3 years agoavcodec/imm4: Inline constants
Andreas Rheinhardt [Mon, 16 Nov 2020 13:46:18 +0000 (14:46 +0100)]
avcodec/imm4: Inline constants

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/imm4: Reduce the size of tables used to initialize VLCs
Andreas Rheinhardt [Mon, 16 Nov 2020 13:43:01 +0000 (14:43 +0100)]
avcodec/imm4: Reduce the size of tables used to initialize VLCs

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 <andreas.rheinhardt@gmail.com>
3 years agoavcodec/imm4: Make better use of symbols table
Andreas Rheinhardt [Mon, 16 Nov 2020 12:40:08 +0000 (13:40 +0100)]
avcodec/imm4: Make better use of symbols table

Also inline the VLC's number of bits while at it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/aacdec_template: Use VLC symbols table
Andreas Rheinhardt [Thu, 19 Nov 2020 14:57:23 +0000 (15:57 +0100)]
avcodec/aacdec_template: Use VLC symbols table

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 <andreas.rheinhardt@gmail.com>
3 years agoavcodec/aacdec_template: Avoid code duplication when initializing VLCs
Andreas Rheinhardt [Thu, 19 Nov 2020 14:11:07 +0000 (15:11 +0100)]
avcodec/aacdec_template: Avoid code duplication when initializing VLCs

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/qdmc: Avoid code duplication when initializing VLC
Andreas Rheinhardt [Sun, 8 Nov 2020 10:56:23 +0000 (11:56 +0100)]
avcodec/qdmc: Avoid code duplication when initializing VLC

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/qdmc: Apply offset when creating VLC
Andreas Rheinhardt [Sun, 8 Nov 2020 10:05:15 +0000 (11:05 +0100)]
avcodec/qdmc: Apply offset when creating VLC

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/qdmc: Make tables used to initialize VLCs smaller
Andreas Rheinhardt [Sun, 8 Nov 2020 09:48:24 +0000 (10:48 +0100)]
avcodec/qdmc: Make tables used to initialize VLCs smaller

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 <andreas.rheinhardt@gmail.com>
3 years agoavcodec/magicyuv: Optimize creating Huffman tables
Andreas Rheinhardt [Mon, 9 Nov 2020 04:11:31 +0000 (05:11 +0100)]
avcodec/magicyuv: Optimize creating Huffman tables

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 until now the decoder did this as follows: It counted the number of
codes of each length and derived the first code of a given length via
(ii). Then the array of lengths is traversed a second time to create
the codes; there is one running counter for each length to do so. This
process creates a default symbol table (that is omitted).

This commit changes this as follows: Everything is indexed by the
position in the tree (with codes to the left first); given (i), we can
calculate the ranges occupied by the codes of each length; and with (ii)
we can derive the actual symbols of each code; the running counters for
each length are now used for the symbols and not for the codes.

Doing so allows us to switch to ff_init_vlc_from_lengths(); this has the
advantage that the codes table needs only be traversed once and that the
codes need not be sorted any more (right now, the codes that are so long
that they will be put into subtables need to be sorted so that codes
that end up in the same subtable are contiguous).

For a sample produced by our encoder (natural content, 4000 frames,
YUV420p, ten iterations, GCC 9.3) this decreased the amount of
decicycles for each call to build_huffman() from 1336049 to 1309401.
Notice that our encoder restricts the code lengths to 12 and our decoder
only uses subtables when the code is longer than 12 bits, so the sorting
that can be avoided does not happen at the moment. If one reduces the
decoder's tables to nine bits, the performance improvement becomes more
apparent: The amount of decicycles for build_huffman() decreased from
1165210 to 654055.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/utvideodec: Avoid implicit qsort when creating Huffman tables
Andreas Rheinhardt [Sun, 8 Nov 2020 04:15:56 +0000 (05:15 +0100)]
avcodec/utvideodec: Avoid implicit qsort when creating Huffman tables

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 corresponding to a given symbol is; and this is also all that
is transmitted.

Before 341914495e5c2f60bc920b0c6f660e5948a47f5a, the decoder used qsort
to sort the (length, symbol) pairs by ascending length and for equal
lengths by ascending symbol. Since said commit, the decoder uses
a first pass over the lengths table to count how many symbols of each
length there are; with (i) one can then easily calculate the code of
the left-most code with a given length in the tree and from there one
can calculate the codes for all entries, using one running counter for
each possible length. This eliminated the explicit qsort in
build_huff().

Yet ff_init_vlc_sparse() sorts the table itself as it has to ensure that
all the entries that will be placed in the same subtable are contiguous.
The tables created now are non-contiguous (they are ordered by symbol
and codes of different length aren't ordered at all; only codes of the
same length are ordered according to (ii)).

This commit therefore modifies the algorithm used to automatically create
tables whose codes are sorted from left to right in the tree. The key to
do so is the observation that the counts obtained in the first pass can
be used to contain the range of the codes of each length in the second
pass: If counts[i] is the count of codes with length i, then the first
counts[32] codes are of length 32, the next counts[31] codes are of
length 31 etc. So one knows the index of the lowest symbol whose code
has length 32 (if any): It is counts[32] - 1 due to (ii), whereas the
index of the lowest symbol whose code has length 31 (if any) is
counts[32] + counts[31] - 1; the index of the second-to-lowest symbol of
length 32 (if existing) is counts[32] - 2 etc.

If one follows the algorithm outlined above, one can switch to
ff_init_vlc_from_lengths() which has no implicit qsort; it also means
that one can offload the computation of the codes.

This turned out to be beneficial for performance: For the sample from
ticket #4044 it decreased the decicycles spent on one call to
build_huff() from 508480 to 340688 (GCC 9.3, looping 10 times over the
file to get enough runs and then repeating this ten times); for another
sample (YUV420p, natural content, 5500 frames, also ten iterations)
the time went down from 382346 to 275533 decicycles.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/atrac3: Use symbols table
Andreas Rheinhardt [Sat, 7 Nov 2020 08:46:17 +0000 (09:46 +0100)]
avcodec/atrac3: Use symbols table

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_lengths() as one can then remove the codes tables.

While at it, remove the arrays of pointers to the individual arrays and
put all lengths+symbol pairs in one big array.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/intrax8: Reduce the size of tables used to initialize VLCs
Andreas Rheinhardt [Fri, 6 Nov 2020 12:50:56 +0000 (13:50 +0100)]
avcodec/intrax8: Reduce the size of tables used to initialize VLCs

By switching from ff_init_vlc_sparse() to ff_init_vlc_from_lengths() one
can replace an array of codes of type uint16_t with an array of symbols
of type uint8_t, saving space.

Also remove some more code duplication while at it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/intrax8: Avoid code duplication when initializing VLCs
Andreas Rheinhardt [Fri, 6 Nov 2020 12:43:03 +0000 (13:43 +0100)]
avcodec/intrax8: Avoid code duplication when initializing VLCs

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/intrax8: Remove VLC offsets table
Andreas Rheinhardt [Fri, 6 Nov 2020 12:30:20 +0000 (13:30 +0100)]
avcodec/intrax8: Remove VLC offsets table

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/vp3: Remove code duplication when initializing Theora VLCs
Andreas Rheinhardt [Fri, 6 Nov 2020 10:03:34 +0000 (11:03 +0100)]
avcodec/vp3: Remove code duplication when initializing Theora VLCs

theora_init_huffman_tables() does essentially the same as
ff_init_vlcs_from_lengths().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/vp3: Use symbols table for VP3 motion vectors
Andreas Rheinhardt [Fri, 6 Nov 2020 09:48:55 +0000 (10:48 +0100)]
avcodec/vp3: Use symbols table for VP3 motion vectors

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 range -31..31; but this is no problem with
ff_init_vlc_from_lengths(): Just apply an offset of 31 to the symbols
before storing them in the table used to initialize VP3 motion vectors
and apply an offset of -31 when initializing the actual VLC.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/vp3: Make tables used to initialize VLCs smaller
Andreas Rheinhardt [Fri, 6 Nov 2020 09:35:12 +0000 (10:35 +0100)]
avcodec/vp3: Make tables used to initialize VLCs smaller

This is possible by switching to ff_init_vlc_from_lengths() because it
allows to replace codes of type uint16_t by symbols of type uint8_t; in
some cases (like here) it also allows to replace explicitly coded
codes by implicitly coded symbols.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/vp3: Apply VLC offset during init
Andreas Rheinhardt [Fri, 6 Nov 2020 09:14:22 +0000 (10:14 +0100)]
avcodec/vp3: Apply VLC offset during init

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 trivial.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/atrac9dec: Make VLCs static
Andreas Rheinhardt [Thu, 5 Nov 2020 02:25:47 +0000 (03:25 +0100)]
avcodec/atrac9dec: Make VLCs static

Also remove code duplication and use a named constant for the number of
VLC bits while just at it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/atrac9dec: Don't create VLCs that are never used
Andreas Rheinhardt [Thu, 5 Nov 2020 01:29:26 +0000 (02:29 +0100)]
avcodec/atrac9dec: Don't create VLCs that are never used

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 code. This commit stops creating said
VLCs.

*: read_coeffs_coarse() uses the HuffmanCodebook
at9_huffman_coeffs[cb][prec][cbi]. prec is c->precision_coarse[i] + 1
and every precision_coarse entry is in the 1..15 range after
calc_precision(), so prec is >= 2 (all codebooks with prec < 2 are
empty). The remaining empty codebooks are those with cb == 1 and cbi ==
0, yet this is impossible, too: cb is given by c->codebookset[i] and
this is always 0 if i < 8 (because those are never set to anything else
in calc_codebook_idx()) and cbi is given by at9_q_unit_to_codebookidx[i]
which is never zero if i >= 8.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/atrac9tab: Unify tables used to initialize VLCs
Andreas Rheinhardt [Wed, 4 Nov 2020 19:41:35 +0000 (20:41 +0100)]
avcodec/atrac9tab: Unify tables used to initialize VLCs

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 <andreas.rheinhardt@gmail.com>