1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-02 03:06:28 +02:00
Commit Graph

49597 Commits

Author SHA1 Message Date
Matthieu Bouron
ad227a41d4 avcodec/mediacodec_wrapper: remove unnecessary NULL checks before calling Delete{Global,Local}Ref()
Delete{Global,Local}Ref already handle NULL.
2024-03-23 11:37:44 +01:00
Matthieu Bouron
b1a683a2fd avcodec/mediacodec_wrapper: use an OFFSET() macro where relevant
Reduces a bit the horizontal spacing.
2024-03-23 11:37:44 +01:00
Matthieu Bouron
dab4124350 avcodec/jni: remove unnecessary NULL checks before calling DeleteLocalRef()
Delete{Global,Local}Ref() already handle NULL.
2024-03-23 11:37:44 +01:00
Matthieu Bouron
70ba15d2cf avcodec/jni: use size_t to store structure offsets 2024-03-23 11:37:44 +01:00
Matthieu Bouron
f17e18d292 avcodec: add av_jni_{get,set}_android_app_ctx() helpers
This will allow users to pass the Android ApplicationContext which is mandatory
to retrieve the ContentResolver responsible to resolve/open Android content URIS.
2024-03-23 11:34:34 +01:00
Andreas Rheinhardt
b7bec5d3c9 avutil/frame: Rename av_frame_side_data_get and add wrapper for it
av_frame_side_data_get() has a const AVFrameSideData * const *sd
parameter; so calling it with an AVFramesSideData **sd like
AVCodecContext.decoded_side_data (or with a AVFramesSideData * const
*sd) is safe, but the conversion is not performed automatically
in C. All users of this function therefore resort to a cast.

This commit changes this: av_frame_side_data_get() is renamed
to av_frame_side_data_get_c(); furthermore, a static inline
wrapper for it name av_frame_side_data_get() is added
that accepts an AVFramesSideData * const * and converts this
to const AVFramesSideData * const * in a Wcast-qual safe way.

This also allows to remove the casts from the current users.

Reviewed-by: Jan Ekström <jeebjp@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-22 23:38:16 +01:00
Andreas Rheinhardt
b9fcc135c5 avcodec/libx265: Pass logctx as void*, not AVClass**
The latter need not be save, because av_log() expects
to get a pointer to an AVClass-enabled structure
and not only a fake object. If this function were actually
be called in the following way:

const AVClass *avcl = avctx->av_class;
handle_mdcv(&avcl, );

the AVClass's item_name would expect to point to an actual
AVCodecContext, potentially leading to a segfault.

Reviewed-by: Jan Ekström <jeebjp@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-22 23:32:15 +01:00
Andreas Rheinhardt
244db71037 avcodec/libx265: Don't use AVBPrint unnecessarily
This code uses the AVBPrint API for exactly one av_bprintf()
in a scenario in which a good upper bound for the needed
size of the buffer is available (with said upper bound being
much smaller than sizeof(AVBPrint)). So one can simply use
snprintf() instead. This also avoids the (always-false due to
the current size of the internal AVBPrint buffer) check for
whether the AVBPrint is complete.

Furthermore, the old code used AV_BPRINT_SIZE_AUTOMATIC
which implies that the AVBPrint buffer will never be
(re)allocated and yet it used av_bprint_finalize().
This has of course also been removed.

Reviewed-by: Jan Ekström <jeebjp@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-22 23:31:58 +01:00
Andreas Rheinhardt
6ecc2f0f6f avcodec/libx264: Remove unused variable
Reviewed-by: Zhao Zhili <quinkblack@foxmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-22 22:10:26 +01:00
Andreas Rheinhardt
3fd047ee30 avcodec/librav1e: Don't unnecessarily create new references
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-22 17:04:05 +01:00
Andreas Rheinhardt
c89f6ae689 avcodec/libdav1d: Stop mangling AVPacket.opaque
Unnecessary since 67e7f0b05e
as there are no longer two opaque fields.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-22 16:33:53 +01:00
Niklas Haas
f04a2ba302 avcodec/dovi_rpu: fix off-by-one in loop
Otherwise the last VDR would never get copied.
2024-03-22 14:05:30 +01:00
Niklas Haas
d5648a806f avcodec/dovi_rpu: use OR instead of addition 2024-03-22 14:05:22 +01:00
Zhao Zhili
5229778440 avcodec/libx264: fix extradata when config annexb=0
AVCodecContext extradata should be an AVCDecoderConfigurationRecord
when bitstream format is avcc. Simply concatenating the NALUs output
by x264_encoder_headers does not form a standard
AVCDecoderConfigurationRecord. The following cmd generates broken
file before the patch:

ffmpeg -i foo.mp4 -c:v libx264 -x264-params annexb=0 bar.mp4

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2024-03-22 20:26:53 +08:00
Zhao Zhili
c775163a8c avcodec/decode: log hwaccel name
Many users mistakenly think that hwaccel is an instance of a decoder,
and cannot find the corresponding decoder name in the logs. Log
hwaccel name so user know hwaccel has taken effect.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2024-03-22 20:26:53 +08:00
James Almer
535b1a93f5 avcodec/hevc_ps: fix setting HEVCHdrParams fields
These were defined in a way compatible with the Vulkan HEVC acceleration, which
expects bitmasks, yet the fields were being overwritting on each loop with the
latest read value.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-21 11:31:32 -03:00
James Almer
456c8ebe7c avcodec/hevc_ps: allocate only the required HEVCHdrParams within a VPS
Fixes: timeout
Fixes: 64033/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5332101272305664

Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-21 09:59:20 -03:00
Jan Ekström
d7d2213a6b avcodec/libx265: add support for writing out CLL and MDCV
The newer of these two are the separate integers for content light
level, introduced in 3952bf3e98c76c31594529a3fe34e056d3e3e2ea ,
with X265_BUILD 75. As we already require X265_BUILD of at least
89, no further conditions are required.
2024-03-20 19:15:05 +02:00
Jan Ekström
471c0a34c1 avcodec/libx264: add support for writing out CLL and MDCV
Both of these two structures were first available with X264_BUILD
163, so make relevant functionality conditional on the version
being at least such.

Keep handle_side_data available in all cases as this way X264_init
does not require additional version based conditions within it.

Finally, add a FATE test which verifies that pass-through of the
MDCV/CLL side data is working during encoding.
2024-03-20 19:15:05 +02:00
Jan Ekström
f4b89b6e54 avcodec/libsvtav1: add support for writing out CLL and MDCV
These two were added in 28e23d7f348c78d49a726c7469f9d4e38edec341
and 3558c1f2e97455e0b89edef31b9a72ab7fa30550 for version 0.9.0 of
SVT-AV1, which is also our minimum requirement right now.

In other words, no additional version limiting conditions seem
to be required.

Additionally, add a FATE test which verifies that pass-through of
the MDCV/CLL side data is working during encoding.
2024-03-20 19:15:05 +02:00
Jan Ekström
0d36844ddf avcodec: add frame side data array to AVCodecContext
This allows configuring an encoder by using AVFrameSideData.
2024-03-20 19:15:05 +02:00
Frank Plowman
dfcf5f828d lavc/vvc: Fix check whether QG is in first tile col
The second part of this condition is intended to check whether the
current quantisation group is in the first CTU column of the current
tile.  The issue is that ctb_to_col_bd gives the x-ordinate of the first
column of the current tile *in CTUs*, while xQg gives the x-ordinate of
the quantisation group *in samples*.  Rectify this by shifting xQg by
ctb_log2_size to get xQg in CTUs before comparing.

Fixes FFVVC issues #201 and #203.
2024-03-20 22:27:19 +08:00
Marth64
0b342a2f15 avcodec/mpeg12dec: extract only one type of CC substream
In MPEG-2 user data, there can be different types of Closed Captions
formats embedded (A53, SCTE-20, or DVD). The current behavior of the
CC extraction code in the MPEG-2 decoder is to not be aware of
multiple formats if multiple exist, therefore allowing one format
to overwrite the other during the extraction process since the CC
extraction shares one output buffer for the normalized bytes.

This causes sources that have two CC formats to produce flawed output.
There exist real-world samples which contain both A53 and SCTE-20 captions
in the same MPEG-2 stream, and that manifest this problem. Example of symptom:
THANK YOU (expected) --> THTHANANK K YOYOUU (actual)

The solution is to pick only the first CC substream observed with valid bytes,
and ignore the other types. Additionally, provide an option for users
to manually "force" a type in the event that this matters for a particular
source.

Signed-off-by: Marth64 <marth64@proxyid.net>
2024-03-19 15:52:05 +01:00
James Almer
61519cc654 avcodec/libdav1d: use named constants for ITU-T T.35 metadata
Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-19 09:44:59 -03:00
James Almer
a1f714d197 avcodec/h2645_sei: use named constants for ITU-T T.35 metadata
Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-19 09:44:59 -03:00
James Almer
4ca5d45193 avcodec/av1dec: use named constants for ITU-T T.35 metadata
Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-19 09:44:59 -03:00
Fei Wang
8962e2b1aa lavc/vaapi_decode: Don't update buffer number if allocataion fail
Signed-off-by: Fei Wang <fei.w.wang@intel.com>
2024-03-18 12:00:14 +08:00
Fei Wang
a8d9fab06b lavc/vaapi_encode: Enable block level bitrate control
Signed-off-by: Fei Wang <fei.w.wang@intel.com>
2024-03-18 12:00:14 +08:00
Haihao Xiang
697251bb0c lavc/qsvdec: Do not print warning when draining cached frames
When all cached frames are drained, the output mfxSyncPoint pointer is
NULL and  MFX_ERR_MORE_DATA is returned, hence needn't print warning for
this expected behavior, otherwise the user might think the output from
qsv decoders are wrong.

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2024-03-18 12:00:14 +08:00
Andreas Rheinhardt
2a0194bafa avcodec/ccaption_dec: Use static_assert instead of _Static_assert
The latter is not supported by MSVC 19.27.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-18 01:49:38 +01:00
Andreas Rheinhardt
f1b08b8a65 avcodec/mips/aaccoder_mips: Remove MIPS-specific aaccoder
ff_aac_coder_init_mips() modifies a static const structure of
function pointers. This will crash if the binary uses relro
and is a data race in any case.

Furthermore it points to a maintainability issue: The
AACCoefficientsEncoder structures have been constified
in commit fd9212f2ed,
a Libav commit merged in 318778de9e.
Libav did not have the MIPS-specific AAC code and so this was
fine for them; yet FFmpeg had them, but this was not recognized.

Commit 75a099fc73 points to another
maintainability issue: Contrary to ordinary DSP code, this code
here is way more complex and needs to be constantly kept in sync
with the ordinary code which it mimicks and replaces. Said commit
is the only commit actually changing aaccoder.c in the last few
years and the same change has not been performed for the MIPS
clone; before that, it even happened several times that the mips
code was broken due to changes of the generic code (see commits
97437bd17a and
de262d018d or
860dbe0275 or
933309a6ca or
b65ffa316e). This might even lead
to scenarios where someone changing non-dsp aacenc code would
have to modify mips inline asm in order to keep them in sync.
This is obviously a significant burden (if the AAC encoder were
actively developed).

Finally, the code does not even compile here due to errors like
"Error: float register should be even, was 1".

Reviewed-by: Lynne <dev@lynne.ee>
Reviewed-by: Jean-Baptiste Kempf <jb@videolan.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-18 01:49:38 +01:00
Andreas Rheinhardt
3f7ee34efe avcodec/mpegaudio(data|dsp): Mark symbols as hidden
Avoids .got entries for ff_mpa_bitrate_tab, ff_mpa_synth_window_fixed,
ff_band_size_long, ff_mpa_pretab, ff_band_size_short,
ff_mpa_synth_window_float and ff_band_index_long here.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-17 15:10:05 +01:00
Andreas Rheinhardt
333ff3e98d avcodec/vorbis_data: Mark symbols as hidden
Avoids .got entries for ff_vorbis_ch_layouts.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-17 15:10:05 +01:00
Andreas Rheinhardt
6ffdf2f370 avcodec/dirac_arith: Only include x86/asm.h for ARCH_X86
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-17 15:10:05 +01:00
Andreas Rheinhardt
ff15edf15a avcodec/ac3tab: Remove enum CustomChannelMapLocation
Forgotten in 4c8d9b1d09.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-17 15:10:05 +01:00
Andreas Rheinhardt
5f7eb4240a avcodec/tests/snowenc: Fix mixed declaration and code
Reviewed-by: Sean McGovern <gseanmcg@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-15 15:31:58 +01:00
Andreas Rheinhardt
c00cd007e8 configure: Remove av_restrict
All versions of MSVC that support C11 (namely >= v19.27)
also support the restrict keyword, therefore av_restrict
is no longer necessary since 75697836b1.

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-15 12:51:15 +01:00
Andreas Rheinhardt
09e6840cf7 avcodec/ppc/vp8dsp_altivec: Fix out-of-bounds access
h_subpel_filters_inner[i] and h_subpel_filters_outer[i / 2]
belong together and the former allows the range 0..6,
so the latter needs to support 0..3. But it has only three
elements. Add another one.
The value for the last element has been guesstimated
from subpel_filters in libavcodec/vp8dsp.c.

This is also intended to fix FATE-failures with UBSan here:
https://fate.ffmpeg.org/report.cgi?time=20240312011016&slot=ppc-linux-gcc-13.2-ubsan-altivec-qemu

Tested-by: Sean McGovern <gseanmcg@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-14 22:20:00 +01:00
Andreas Rheinhardt
8e207bf463 avcodec/mpeg4videodec: Align idct-block appropriately
It is accessed via AV_RN64A in ff_simple_idct_put_int32_10bit().
Should fix the UBSan failures in the mpeg4-simple-studio-profile
test here:
https://fate.ffmpeg.org/report.cgi?time=20240312011016&slot=ppc-linux-gcc-13.2-ubsan-altivec-qemu

Reviewed-by: Kieran Kunhya <kierank@obe.tv>
Tested-by: Sean McGovern <gseanmcg@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-14 21:52:16 +01:00
Andreas Rheinhardt
cc2d2b665e avcodec/lossless_videoencdsp: Fix unaligned access
HAVE_FAST_UNALIGNED being true does not imply that
one can simply read from any pointer via *(long*).
It is undefined behaviour in case the pointer is not
sufficiently aligned; and even if it is, it is (likely)
a violation of the effective-type rules. Fix both
of these by using the appropriate AV_[RW]N macros.

Also, the current code used sizeof(long) as if this
were the CPU's native arithmetic size, but this is
not true on 64bit Windows. This has been fixed, too.

This affected huffyuv FATE-tests.

Tested-by: Sean McGovern <gseanmcg@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-14 21:22:45 +01:00
Andreas Rheinhardt
f9aa5457ff avcodec/ppc/h264dsp: Fix unaligned stores
Also fix an effective-type violation.
Exposed by https://fate.ffmpeg.org/report.cgi?time=20240312011016&slot=ppc-linux-gcc-13.2-ubsan-altivec-qemu

Tested-by: Sean McGovern <gseanmcg@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-14 20:37:25 +01:00
Andreas Rheinhardt
f032f1326b avcodec/tiff_data: Remove incorrect GeoTIFF entries
They are incorrect according to [1]. They also share keys with valid
entries, so that it is unspecified which entry bsearch returns
in this case. Fix this by removing the incorrect values.

[1]: https://www.earthdata.nasa.gov/s3fs-public/imported/19-008r4.pdf

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-14 20:37:03 +01:00
Andreas Rheinhardt
282812d6dc avcodec/tiff_data: Avoid relocations for TiffGeoTagNameType
Instead store all the strings in one continugous string
(with internal \0) and use offsets to access the actual
substrings. This replaces the pointers to the strings
and therefore avoids relocations (and on x64, it actually
shrinks TiffGeoTagNameType by reusing padding to store
the offset field).

This saves 720B of .data.rel.ro and 1080B of .rela.dyn
(containing the relocation records) here while increasing
.rodata by 384B.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-14 20:37:03 +01:00
Martin Storsjö
0c5da7be59 aarch64: Fix ff_hevc_put_hevc_epel_h48_8_neon_i8mm
The first 32 elements of each row were correct, while the
last 16 were scrambled.

This hasn't been noticed, because the checkasm test erroneously
only checked half of the output (for 8 bit functions), and
apparently none of the samples as part of "fate-hevc" seem to
trigger this specific function.

Signed-off-by: J. Dekker <jdek@itanimul.li>
2024-03-14 13:42:39 +01:00
Marton Balint
9eebeea4dd avcodec/bsf/pcm_rechunk: add some more supported PCM formats
Signed-off-by: Marton Balint <cus@passwd.hu>
2024-03-14 01:37:31 +01:00
Marton Balint
66e6272917 avcodec/bsf/pcm_rechunk: reorder supported codec list
Use lexical order.

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-03-14 01:37:31 +01:00
Kieran Kunhya
110d8549d5 avcodec/vvcdec: Mark as experimental
Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-13 20:46:10 -03:00
Andreas Rheinhardt
c1cdaef5ce avcodec/hevc_cabac: Let compiler count offsets
This is easily possible with an X macro.
Using an enum for the offsets also allows to remove
two arrays which are not really needed and will typically
be optimized away by the compiler: The first just exists
to count the number of syntax elements*, the second one
exists to get offset[CONSTANT]. These constants were
of type enum SyntaxElement and this enum was only used
in hevc_cabac.c (although it was declared in hevcdec.h);
it is now no longer needed at all and has therefore been
removed.

The first of these arrays led to a warning from Clang
which is fixed by this commit:
warning: variable 'num_bins_in_se' is not needed and will
not be emitted [-Wunneeded-internal-declaration]

*: One could also just added a trailing SYNTAX_ELEMENT_NB
to the SyntaxElement enum for this purpose.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-13 23:29:02 +01:00
Mark Thompson
98a2ade630 avcodec: Fix doxygen comment marker 2024-03-13 21:56:59 +00:00
Reimar Döffinger
605fc72f19
avcodec/parser: Reset *buf_size on realloc failure
Fixes: out of array access
Fixes: crash-0d640731c7da52415670eb47a2af701cbe2e1a3b
Fixes: crash-e745864ead6ea418959c8df56de2765571201dae

Found-by: Catena cyber <contact@catenacyber.fr>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-03-13 00:52:30 +01:00