Commit Graph

10 Commits

Author SHA1 Message Date
Andreas Rheinhardt 5dc31bc67b avcodec/aacps_common: Apply offset for VLCs during init
This avoids having to apply it later after every get_vlc2().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-10-31 21:44:48 +01:00
Andreas Rheinhardt 40a8cb9e6c avcodec/aacps_common: Combine huffman tabels
This allows to avoid the relocations inherent in an array
to individual tables; it also reduces padding.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-10-31 21:44:48 +01:00
Andreas Rheinhardt 774611a349 avcodec/aacps_common: Switch to ff_vlc_init_tables_from_lengths()
It allows to replace codes of type uint16_t or uint32_t
by symbols of type uint8_t.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-10-31 21:44:48 +01:00
Andreas Rheinhardt eb422c606a avcodec/aacps_common: Avoid superfluous VLC structures
For all VLCs here, the number of bits of the VLC is
write-only, because it is hardcoded at the call site.
Therefore one can replace these VLC structures with
the only thing that is actually used: The pointer
to the VLCElem table.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-10-31 21:44:48 +01:00
Andreas Rheinhardt 4fe91e3676 avcodec/aacps: Move initializing common stuff to aacdec_common.c
ff_ps_init() initializes some tables for AAC parametric stereo
and some of them are only valid for the fixed- or floating-point
decoder, whereas others (namely VLCs) are valid for both.
The latter are therefore initialized by ff_ps_init_common()
and because the two versions of ff_ps_init() can be run
concurrently, it is guarded by an AVOnce.

Yet now that there is ff_aacdec_common_init_once() there is
a better way to do this: Call ff_ps_init_common()
from ff_aacdec_common_init_once(). That way there is no need
to guard ff_ps_init_common() by an AVOnce any more.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-10-31 21:44:48 +01:00
Andreas Rheinhardt 8c1e71a811 avcodec/aacps: Pass logctx as void* instead of AVCodecContext*
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-10-31 20:47:00 +01:00
Andreas Rheinhardt 9cdf82c2c2 avcodec/vlc: Use proper namespace
Therefore use a proper prefix for this API, e.g.
ff_init_vlc_sparse -> ff_vlc_init_sparse
ff_free_vlc        -> ff_vlc_free
INIT_VLC_LE        -> VLC_INIT_LE
INIT_VLC_USE_NEW_STATIC -> VLC_INIT_USE_STATIC
(The ancient INIT_VLC_USE_STATIC has been removed
in 595324e143, so that
the NEW has been dropped.)
Finally, reorder the flags and change their values
accordingly.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-11 00:27:45 +02:00
Andreas Rheinhardt 2d764069be avcodec/vlc: Use structure instead of VLC_TYPE array as VLC element
In C, qualifiers for arrays are broken:
const VLC_TYPE (*foo)[2] is a pointer to an array of two const VLC_TYPE
elements and unfortunately this is not compatible with a pointer
to a const array of two VLC_TYPE, because the latter does not exist
as array types are never qualified (the qualifier applies to the base
type instead). This is the reason why get_vlc2() doesn't accept
a const VLC table despite not modifying the table at all, as
there is no automatic conversion from VLC_TYPE (*)[2] to
const VLC_TYPE (*)[2].

Fix this by using a structure VLCElem for the VLC table.
This also has the advantage of making it clear which
element is which.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-06-17 16:47:29 +02:00
Andreas Rheinhardt 4f1ae39036 avcodec/aacps_common: Use minimal VLC nb_bits/max_depth
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-12-31 23:18:55 +01:00
Andreas Rheinhardt 3693e2fcee avcodec/aacps: Factor out code shared by float and fixed point decoder
Saves about 7KiB.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-12-31 22:12:39 +01:00