Commit Graph

114948 Commits

Author SHA1 Message Date
Lynne
5c026e6637
aacdec: remove unnecessary decode_spectrum_and_dequant arguments
Small cleanup to reduce number of arguments.
2024-04-23 08:31:35 +02:00
Lynne
eef9100a8e
aacdec: template LTP windowing separately
The function is called only internally in DSP, so we do not
need to expose it.

apply_ltp on MIPS uses this function, but due to the function
being just a glue function with no real optimizations,
duplicate it there.
2024-04-23 08:31:35 +02:00
Lynne
091d85217d
aacdec: template windowing and transforms separately 2024-04-23 08:31:34 +02:00
Lynne
a309aa4127
aacdec: duplicate table initialization
Preparation to move all table init and support windowing functions.
2024-04-23 08:31:34 +02:00
Lynne
e9fc7661da
aacdec: template LTP application separately 2024-04-23 08:31:33 +02:00
Lynne
db5128ef70
aacdec: template TNS application separately 2024-04-23 08:31:33 +02:00
Lynne
ad16349f9b
aacdec: template intensity stereo application separately 2024-04-23 08:31:33 +02:00
Lynne
9f3fa77e0d
aacdec: template mid/side stereo application separately 2024-04-23 08:31:32 +02:00
Lynne
a6295586f5
aacdec: template scalefactor dequantization separately 2024-04-23 08:31:32 +02:00
Lynne
7f3b3e2df1
aacdec: switch-ify scalefactor decoding
Brings it in line with dequantization.
2024-04-23 08:31:31 +02:00
Lynne
77a88bbdda
aacdec: give spectrum dequant+decode SCE rather than an ICS
Eliminates using templated values in function definition.
2024-04-23 08:31:31 +02:00
Lynne
60b60dd635
aacdec: separate out scalefactor dequantization from decoding
Allows to template away dequantization.
2024-04-23 08:31:31 +02:00
Lynne
ed009bfd3d
aacdec: add a decoder DSP structure
To be used to abstract away DSP functions.
2024-04-23 08:31:30 +02:00
Andreas Rheinhardt
9de66fd449
avcodec/aacdec_template: Deduplicate common part of aac_decode_init()
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-04-23 08:31:30 +02:00
Andreas Rheinhardt
980a55fb46
avcodec/aacdec_template: Deduplicate AVClass+AVOptions
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-04-23 08:31:29 +02:00
Andreas Rheinhardt
e3693c6f56
avcodec/aacdec_template: Deduplicate aac_decode_close()
This is possible now that both AAC decoders share the same
context.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-04-23 08:31:29 +02:00
Andreas Rheinhardt
7117e0c7be
avcodec/aacdec: Use same AACDecContext for fixed and float
Up until now, there was one AACDecContext for the fixed
and one for the floating point decoder. These differed
mostly in certain arrays which were int for the fixed-point
and float for the floating point decoder; there were also
differences in corresponding function pointers.

Yet in order to deduplicate the enormous amount of currently
duplicated code between the float and the fixed-point decoder,
one needs common contexts. Given that int and float have the
same size on all common systems, this commit replaces these
arrays by unions of int arrays and of float arrays. The names
of these arrays have been chosen to be compatible with
AAC_RENAME().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-04-23 08:31:29 +02:00
Andreas Rheinhardt
fc3c2ea8dc
avcodec/aacdec: PredictorState array out of SingleChannelElement
sizeof(PredictorState) is different for the floating-point and
the fixed-point AAC decoders; this is an obstacle for deduplicating
code between these decoders. So don't include this array in
SingleChannelElement, instead add a union of pointers to the
fixed-point PredictorState and the floating-point PredictorState.
The actual arrays are part of the extended ChannelElement
to be allocated by ff_aac_sbr_ctx_alloc_init(); it also
sets the pointers.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-04-23 08:31:28 +02:00
Andreas Rheinhardt
8b2261e573
avcodec/aacdec: Always include AV(Fixed|Float)DSPContext in AACDecContext
Up until now, AACDecContext included pointers to one of these
contexts depending upon USE_FIXED. Yet deduplicating
the common parts of the float and fixed-point AAC decoders
needs common structures, so we put both of these pointers
in a union.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-04-23 08:31:28 +02:00
Andreas Rheinhardt
5bd7b8d999
avcodec/aacdec: Split SBR context from ChannelElement
The AAC fixed-point and floating-point decoders have
a lot of duplicated code; the main obstacle to
deduplicating it is that several structures with the
same name are actually different types, because
they contain INTFLOATs (int or float) and AAC_FLOATs
(SoftFloat or float). SoftFloat and float typically
have different sizes, so dealing with it is the more
complicated of the two.

AAC_FLOAT is mainly used in the sbr code and structures,
so one can still deduplicate the code by only exposing
the common part of ChannelElement (without SBR context)
to the common decoder part. One prerequisite of this
is to move allocating the whole ChannelElement to
code that will stay unduplicated. It is most natural
to move said allocation to ff_aac_sbr_ctx_init().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-04-23 08:31:28 +02:00
Andreas Rheinhardt
6975d965fc
avcodec/aacsbr: Make ff_aac_sbr_* funcs accept ChannelElement*
Each ChannelElement contains exactly one SpectralBandReplication
structure; the latter structure contains lots of buffers
whose size depend upon USE_FIXED (i.e. AAC_FLOAT arrays).
This complicates deduplicating the parts of the AAC decoder
that are duplicated between the fixed-point and the floating
point decoder.

In order to fix this, the SpectralBandReplication structure
will be moved from the part of ChannelElement visible to
the common code. Therefore the ff_aac_sbr_* functions
are ported to accept a ChannelElement*; they will then have
to translate that to the corresponding SpectralBandReplication*
themselves (which is possible, because there are floating-point
and fixed-point versions of these functions).

While just at it, also ensure that these functions are properly
namespaced.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-04-23 08:31:27 +02:00
Lynne
3600f757db
aacsbr_template: include mem.h
Future AAC changes remove the need to include this header.
2024-04-23 08:31:27 +02:00
Lynne
f55b587820
aacdec: move aacdec_common to aac/aacdec_tab
Start to clean up the decoder.
Also renames a confusingly named file.
2024-04-23 08:31:18 +02:00
Jun Zhao
fc02b910ad lavc/libxevd: Fixed the has_b_frames setting
has_b_frames used in decoder for size of the frame
reordering buffer, and we don't used the max_b_frames
in decoder.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2024-04-23 07:27:38 +08:00
Mark Thompson
ba6b08c75b av1dec: Fix RefFrameSignBias calculation 2024-04-22 21:41:50 +01:00
Haihao Xiang
3032a74cac configure: fix rpuenc typos
Otherwise there are link errors:
LD      ffprobe_g
/usr/bin/ld: libavcodec/libavcodec.so: undefined reference to
`ff_dovi_rpu_generate'
/usr/bin/ld: libavcodec/libavcodec.so: undefined reference to
`ff_dovi_configure'
collect2: error: ld returned 1 exit status

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
Reviewed-by: Jan Ekström <jeebjp@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2024-04-22 17:20:16 -03:00
Niklas Haas
2f3c1e1641 avcodec/libsvtav1: implement dolby vision coding 2024-04-22 12:17:56 +02:00
Niklas Haas
39ca87ed1e avcodec/libx265: implement dolby vision coding
libx265 supports these natively, we just need to attach the generated
NALs to the x265picture, as well as setting the appropriate DV profile.
2024-04-22 12:17:56 +02:00
Niklas Haas
8dea94a146 avcodec/libaomenc: implement dolby vision coding 2024-04-22 12:17:56 +02:00
Niklas Haas
69e45a627c avformat/movenc: warn if dovi cfg ignored
Since this is guarded behind strict unofficial, we should warn if the
user feeds a dolby vision stream to this muxer, as it will otherwise
result in a broken file.
2024-04-22 12:17:56 +02:00
Niklas Haas
3306766608 avcodec/dovi_rpuenc: add ff_dovi_rpu_generate()
This function takes a decoded AVDOVIMetadata struct and turns it back
into a binary RPU. Verified using existing tools, and matches the
bitstream in official reference files.

I decided to just roll the EMDF and NAL encapsulation into this function
because the end user will need to do it otherwise anyways.
2024-04-22 12:17:56 +02:00
Niklas Haas
f140935005 avcodec/dovi_rpuenc: add ff_dovi_configure()
We need to set up the configuration struct appropriately based on the
codec type, colorspace metadata, and presence/absence of an EL (though,
we currently don't support an EL).

When present, we use the signalled RPU data header to help infer (and
validate) the right values.

Behavior can be controlled by a new DOVIContext.enable flag.
2024-04-22 12:17:51 +02:00
Niklas Haas
f131086a70 avcodec/dovi_rpu: split into dovi_rpu.c and dovi_rpudec.c
To allow compiling the decoding objects without the encoding objects and
vice versa. Common helpers that users of both APIs need are put into the
shared dovi_rpu.c.
2024-04-22 12:17:05 +02:00
Niklas Haas
783734d979 configure: rename dovi_rpu subsystem to dovi_rpudec
To distinguish it from the to-be-added dovi_rpuenc.
2024-04-22 12:17:05 +02:00
Niklas Haas
2a99d3527b avcodec/dovi_rpu: expose guess_profile(), clarify semantics
To allow internally re-using it for both the encoder and decoder.

This is based on HEVC only, H.264/AV1 use their own (hopefully correctly
signalled) profiles (and in particular, the AV1 decoders implicitly
default the correct profile in the absence of a configuration record).
2024-04-22 12:17:05 +02:00
Niklas Haas
dbfd979c1b avcodec/dovi_rpu: clarify error on missing RPU VDR
The code was written under the misguided assumption that these fields
would only be present when the value changes, however this does not
match the actual patent specification, which says that streams are
required to either always signal this metadata, or never signal it.

That said, the specification does not really clarify what the defaults
of these fields should be in the event that this metadata is missing, so
without any sample file or other reference I don't wish to hazard
a guess at how to interpret these fields.

Fix the current behavior by making sure we always throw this error, even
for files that have the vdr sequence info in one frame but are missing
it in the next frame.
2024-04-22 12:17:05 +02:00
Niklas Haas
fc616de1a5 avcodec/dovi_rpu: properly replace context header
This was never set in ff_dovi_ctx_replace(), leading to possibly
out-of-date when copying from one thread to another.
2024-04-22 12:17:05 +02:00
Niklas Haas
d0392619a7 avcodec/dovi_rpu: store entire config record
And make it public.

For encoding, users may also be interested in the configured level and
compatibility ID. So generalize the dv_profile field and just expose the
whole configuration record.

This makes the already rather reductive ff_dovi_update_cfg() function
almost wholly redundant, since users can just directly assign
DOVIContext.cfg.
2024-04-22 12:17:05 +02:00
Andreas Rheinhardt
20206e14d7 avcodec/av1dec: Make av1_frame_replace() out of av1_frame_ref()
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-04-21 16:31:42 +02:00
Andreas Rheinhardt
0f8763fbea avcodec/av1dec: Use ProgressFrames
AV1 can put a frame into multiple reference slots;
up until now, this involved creating a new reference
to the underlying AVFrame; therefore av1_frame_ref()
could fail.
This commit changes this by using the ProgressFrame API
to share the underlying AVFrames.

(Hint: vaapi_av1_surface_id() checked whether the AV1Frames
contained in the AV1DecContext were NULL or not (of course
they were not); this has been changed to actually check for
whether said AV1Frame is blank or not.)

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-04-21 16:31:42 +02:00
Andreas Rheinhardt
0ec886ddc7 avcodec/hevcdec: Use union for AVFrame* and ProgressFrame
It avoids having to sync ProgressFrame.f and the pointer
typically used to access the AVFrame.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-04-21 16:31:42 +02:00
Andreas Rheinhardt
1d17d84b7d avcodec/progressframe: Explain how unnamed union can simplify accesses
This relies on the common initial seqence guarantee
(and on C11 support for unnamed members).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-04-21 16:31:42 +02:00
Jun Zhao
822e2843ca lavc/vvc/refs: Use dpb_max_num_reorder_pics to control output
Use dpb_max_num_reorder_pics to control output instead of
dpb_max_dec_pic_buffering, when dpb_max_dec_pic_buffering
is much larger than dpb_max_num_reorder_pics, it may cause
dpb overflow error.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
Signed-off-by: elinyhuang <elinyhuang@tencent.com>
2024-04-21 21:06:50 +08:00
Jun Zhao
50b8666dc6 lavc/vvc_parser: Fixed the has_b_frames setting
has_b_frames used in decoder for size of the frame reordering
buffer, setting this field from dpb_max_num_reorder_pics.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2024-04-21 21:06:50 +08:00
Jun Zhao
d9f72eb107 lavc/vvc_parser: Remove max_b_frames setting
We don't used the max_b_frames field in decoder normally

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2024-04-21 21:06:50 +08:00
Andreas Rheinhardt
277f051ff6 avcodec/pthread_frame: Fix leak of coded side data
Happens in the mov-elst-ends-betn-b-and-i and mov-ibi-elst-starts-b
FATE tests with frame-threading.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-04-21 13:34:33 +02:00
Matthieu Bouron
8cdf1bae94 avcodec/jni: fix mixed declaration and code 2024-04-21 09:43:17 +02:00
Wu Jianhua
a44c346312 avcodec/x86/vvc/vvcdsp_init: fix linking error when configuring with --disable-ssse3 --disable-optimizations options
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
2024-04-20 12:11:43 +08:00
Wu Jianhua
2f3aaef1b5 avcodec/x86/vvc/vvcdsp_init: add avg prototypes
When we used the --disable-ssse3 --disable-optimizations options,
the compiler would not skip the MC_LINKS like the compilation that
enabled the optimization, so it would fail to find the function
prototypes. Hence, this commit uses the same way to add prototypes
for the functions as HEVC DSP.

And, when prototypes are added for the functions, we cannot add the static qualifier.
Therefore, the ff_vvc prefix is needed to avoid the naming conflict.

Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
2024-04-20 12:11:43 +08:00
Wu Jianhua
4358f49568 avcodec/x86/vvc/vvcdsp_init: add put prototypes
When we used the --disable-ssse3 --disable-optimizations options,
the compiler would not skip the MC_LINKS like the compilation that
enabled the optimization, so it would fail to find the function
prototypes. Hence, this commit uses the same way to add prototypes
for the functions as HEVC DSP.

Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
2024-04-20 12:11:43 +08:00