Commit Graph

108013 Commits

Author SHA1 Message Date
Anton Khirnov 1ef4620290 lavf/dv: do not update AVCodecParameters.sample_rate while demuxing
Demuxers are not allowed to do this and few callers, if any, will handle
this correctly. Send the AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE side data
instead.
2022-09-05 08:13:57 +02:00
Anton Khirnov 6def44128a lavf/dv: set audio bitrate only at stream creation
Demuxers are not supposed to update AVCodecParameters after the stream
was seen by the caller. This value is not important enough to support
dynamic updates for.
2022-09-05 08:13:09 +02:00
Anton Khirnov 000b8d2acc lavf/dv: set non-changing AVStream fields only once 2022-09-05 08:12:26 +02:00
Anton Khirnov b2e1d1443c lavf/dv: forward errors from avformat_new_stream() 2022-09-05 08:11:48 +02:00
Anton Khirnov f0283f278a lavf/dv: return a meaningful error code from avpriv_dv_produce_packet() 2022-09-05 08:11:27 +02:00
Anton Khirnov 090f12b157 lavf/dv: make returning the video packet optional
The mov demuxer only returns DV audio, video packets are discarded.

It first reads the data to be parsed into a packet. Then both this
packet and the pointer to its data are passed together to
avpriv_dv_produce_packet(), which parses the data and partially
overwrites the packet. This is confusing and potentially dangerous, so
just pass NULL and avoid pointless packet modification.
2022-09-05 08:10:55 +02:00
Anton Khirnov f7b3fc4afe lavc/dv: rename constants to follow our naming conventions
CamelCase for enum tags, ALL_CAPS for enum values.
2022-09-05 08:10:26 +02:00
Anton Khirnov 7203bb6a59 lavc/dv.h: move encoder/decoder-specific code to a new header
dv.h is also used by libavformat, so avoid exposing encoder/decoder code
to it.
2022-09-05 08:09:00 +02:00
Anton Khirnov 828ec6ef43 lavc/dvenc: stop using DVVideoContext
Move the parts of it used by the encoder into a new DVEncContext and
remove DVVideoContext.
2022-09-05 08:08:08 +02:00
Anton Khirnov 4e73ed8366 lavc/dvdec: stop using DVVideoContext
The struct is quite small and the decoder and the encoder use different
fields from it, so benefits from reusing it are small.

This allows making the buf field const.
2022-09-05 08:07:16 +02:00
Anton Khirnov 69bad628ec lavc/dv: do not pass DVVideoContext to dv_calculate_mb_xy()
Pass the two variables needed from it directly.

This is done in preparation to splitting DVVideoContext.
2022-09-05 08:06:57 +02:00
Anton Khirnov 91c51dac6d lavc/dv: do not pass DVVideoContext to ff_dv_init_dynamic_tables()
It only needs work_chunks from it, so pass that directly.

This is done in preparation to splitting DVVideoContext.
2022-09-05 08:06:35 +02:00
Anton Khirnov d1ba5d883e lavc/dv: remove ff_dvvideo_init()
The function contains only two assignments, setting DVVideoContext.avctx
and AVCodecContext.chroma_sample_location. However, the decoder does not
use the former, and the encoder should not be setting the latter.

Therefore move the first assignment to dvenc and the second to dvdec.
Make the encoder warn if the user-signalled chroma sample location does
not match the supported one, and return an error on higher compliance
levels.
2022-09-05 08:02:28 +02:00
Anton Khirnov b62d41df07 lavc/dvdec: drop the only use of DVVideoContext.avctx
The function gets the codec context parameter directly.
2022-09-05 08:02:09 +02:00
Anton Khirnov b6196cb2ef lavf/dv: always provide avpriv_dv_* symbols
They are used from libavdevice.
2022-09-05 08:01:17 +02:00
Anton Khirnov dcc4704a4e lavf/dv: remove DVMuxContext declaration from dv.h
DVMuxContext is only used inside dvenc.c, there is no reason for it to
be visible outside of that file.
2022-09-05 08:00:57 +02:00
Andreas Rheinhardt f89949afed avutil/tests/.gitignore: Add channel_layout testtool
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-05 02:00:08 +02:00
Michael Niedermayer f0395f9ef6
avcodec/speedhq: Check width
Fixes: out of array access
Fixes: 50014/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SPEEDHQ_fuzzer-4748914632294400

Alternatively the buffer size can be increased

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-05 01:42:28 +02:00
Stephen Hutchinson 6195a0ee19 avformat/avisynth: reindent
Signed-off-by: Stephen Hutchinson <qyot27@gmail.com>
2022-09-04 15:03:32 -04:00
Stephen Hutchinson adead1ccd6 avformat/avisynth: implement avisynth_flags option
Signed-off-by: Stephen Hutchinson <qyot27@gmail.com>
2022-09-04 15:03:28 -04:00
Stephen Hutchinson c49beead19 avformat/avisynth: read _SARNum/_SARDen from frame properties
Initialized to 1:1, but if the script sets these properties, it
will be set to those instead (0:0 disables it, apparently).

Signed-off-by: Stephen Hutchinson <qyot27@gmail.com>
2022-09-04 15:03:23 -04:00
Paul B Mahol 49a1de26ec avfilter/vf_gblur: handle cases when parameters become invalid 2022-09-04 16:41:44 +02:00
Paul B Mahol b6e8fc1c20 avcodec/speexdec: improve support for speex in non-ogg 2022-09-04 11:31:57 +02:00
Philip Langdale 2f9b8bbd1f lavu/hwcontext_vulkan: support mapping VUYX, P012, and XV36
If we want to be able to map between VAAPI and Vulkan (to do Vulkan
filtering), we need to have matching formats on each side.

The mappings here are not exact. In the same way that P010 is still
mapped to full 16 bit formats, P012 has to be mapped that way as well.

Similarly, VUYX has to be mapped to an alpha-equipped format, and XV36
has to be mapped to a fully 16bit alpha-equipped format.

While Vulkan seems to fundamentally lack formats with an undefined,
but physically present, alpha channel, it has have 10X6 and 12X4
formats that you could imagine using for P010, P012 and XV36, but these
formats don't support the STORAGE usage flag. Today, hwcontext_vulkan
requires all formats to be storable because it wants to be able to use
them to create writable images. Until that changes, which might happen,
we have to restrict the set of formats we use.

Finally, when mapping a Vulkan image back to vaapi, I observed that
the VK_FORMAT_R16G16B16A16_UNORM format we have to use for XV36 going
to Vulkan is mapped to Y416 when going to vaapi (which makes sense as
it's the exact matching format) so I had to add an entry for it even
though we don't use it directly.
2022-09-03 16:19:40 -07:00
Philip Langdale b982dd0d83 lavc/vaapi: Add support for remaining 10/12bit profiles
With the necessary pixel formats defined, we can now expose support for
the remaining 10/12bit combinations that VAAPI can handle.

Specifically, we are adding support for:

* HEVC
** 12bit 420
** 10bit 422
** 12bit 422
** 10bit 444
** 12bit 444

* VP9
** 10bit 444
** 12bit 444

These obviously require actual hardware support to be usable, but where
that exists, it is now enabled.

Note that unlike YUVA/YUVX, the Intel driver does not formally expose
support for the alphaless formats XV30 and XV360, and so we are
implicitly discarding the alpha from the decoder and passing undefined
values for the alpha to the encoder. If a future encoder iteration was
to actually do something with the alpha bits, we would need to use a
formal alpha capable format or the encoder would need to explicitly
accept the alphaless format.
2022-09-03 16:19:40 -07:00
Philip Langdale d75c4693fe lavu/pixfmt: Add P012, Y212, XV30, and XV36 formats
These are the formats we want/need to use when dealing with the Intel
VAAPI decoder for 12bit 4:2:0, 12bit 4:2:2, 10bit 4:4:4 and 12bit 4:4:4
respectively.

As with the already supported Y210 and YUVX (XVUY) formats, they are
based on formats Microsoft picked as their preferred 4:2:2 and 4:4:4
video formats, and Intel ran with it.

P12 and Y212 are simply an extension of 10 bit formats to say 12 bits
will be used, with 4 unused bits instead of 6.

XV30, and XV36, as exotic as they sound, are variants of Y410 and Y412
where the alpha channel is left formally undefined. We prefer these
over the alpha versions because the hardware cannot actually do
anything with the alpha channel and respecting it is just overhead.

Y412/XV46 is a normal looking packed 4 channel format where each
channel is 16bits wide but only the 12msb are used (like P012).

Y410/XV30 packs three 10bit channels in 32bits with 2bits of alpha,
like A/X2RGB10 style formats. This annoying layout forced me to define
the BE version as a bitstream format. It seems like our pixdesc
infrastructure can handle the LE version being byte-defined, but not
when it's reversed. If there's a better way to handle this, please
let me know. Our existing X2 formats all have the 2 bits at the MSB
end, but this format places them at the LSB end and that seems to be
the root of the problem.
2022-09-03 16:19:40 -07:00
Rémi Denis-Courmont 620e6e1487 arm: relax byte-swap assembler constraints
There are no particular reasons to force the compiler to use the same
register as output and input operand. This forces an extra MOV
instruction if the input value needs to be reused after the swap.

In most cases, this makes no differences, as the compiler will seleect
the same register for both operands either way.

Signed-off-by: Martin Storsjö <martin@martin.st>
2022-09-03 23:54:05 +03:00
Rémi Denis-Courmont 164021423a aarch64: relax byte-swap assembler constraints
There are no particular reasons to force the compiler to use the same
register as output and input operand. This forces an extra MOV
instruction if the input value needs to be reused after the swap.

In most cases, this makes no differences, as the compiler will seleect
the same register for both operands either way.

Signed-off-by: Martin Storsjö <martin@martin.st>
2022-09-03 23:54:05 +03:00
Andreas Rheinhardt 0b95a6a1d0 avcodec/mathops: Set hidden visibility where advantageous
It is advantageous for ff_crop_tab, as the base pointer used to
access this table is not the first element of it. But the real
base pointer is still at a constant offset from the code/the GOT
and can therefore be accessed relative to the instruction pointer
(if supported by the arch) or relative to the GOT; without this,
one has to first load address of ff_crop_tab (potentially via
the GOT) and then offset manually (which is what the earlier code
did).

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-03 22:37:33 +02:00
Timo Rothenpieler 6512dd6cb5 avfilter/vf_bilateral_cuda: refactor use of pow to simple multiplication 2022-09-03 20:27:34 +02:00
Timo Rothenpieler 416923346a compat/cuda: switch from powf to __powf intrinsic
The powf builtin causes crashes on older clang, so manually implement
the (faster) intrinsic.
The code it spawns is identical to that of nvcc.
2022-09-03 20:27:34 +02:00
Andreas Rheinhardt 73fada029c avcodec/codec_internal: Add macros for update_thread_context(_for_user)
It reduces typing: Before this patch, there were 11 callbacks
that exceeded the 80 char line length limit; now there are zero.
It also allows to remove ONLY_IF_THREADS_ENABLED() in
libavutil/internal.h.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-03 15:42:57 +02:00
Andreas Rheinhardt 48286d4d98 avcodec/codec_internal: Add macro to set AVCodec.long_name
It reduces typing: Before this patch, there were 105 codecs
whose long_name-definition exceeded the 80 char line length
limit. Now there are only nine of them.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-03 15:42:57 +02:00
Andreas Rheinhardt dea9744560 avutil/file: Properly deprecate av_tempfile()
It has been deprecated in b4f59beeb4,
but the attribute_deprecated was not set and there was no entry
in APIchanges. This commit adds these and schedules it for removal.
Given that the reason behind the deprecation is exactly the same
as in av_fopen_utf8(), reuse its FF_API_AV_FOPEN_UTF8.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-03 15:42:40 +02:00
Andreas Rheinhardt 72c601e0f7 avutil/internal: Move avpriv-file API to a header of its own
It is not used by the large majority of files that include
lavu/internal.h.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-03 15:41:44 +02:00
Andreas Rheinhardt 04b7217872 avutil/dict: Move avpriv_dict_set_timestamp() to a header of its own
It is used almost nowhere, so it needn't be auto-included
almost everywhere.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-03 15:41:44 +02:00
Andreas Rheinhardt 26325cceb0 avutil/internal: Remove unused FF_SYMVER
They are unused since d63443b968.
Furthermore, they were always in the wrong header:
libavutil/internal.h is auto-included almost everywhere, but
FF_SYMVER would only ever be used at a few places, so a proper
header of its own would be appropriate for it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-03 15:41:44 +02:00
Andreas Rheinhardt 5b0856d2b9 avutil/internal: Remove unused ff_rint64_clip()
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-03 15:41:44 +02:00
Andreas Rheinhardt 65f6851448 avcodec/frame_thread_encoder: Stop serializing unreferencing AVFrames
Currently, the frame-threaded decoding API still supports thread-unsafe
callbacks. If one uses a thread-unsafe get_buffer2() callback,
calls to av_frame_unref() by the decoder are serialized, because
it is presumed that the underlying deallocator is thread-unsafe.

The frame-threaded encoder seems to have been written with this
restriction in mind: It always serializes unreferencing its AVFrames,
although no documentation forces it to do so.

This commit schedules to change this behaviour as soon as thread-unsafe
callbacks are removed. For this reason, the FF_API_THREAD_SAFE_CALLBACKS
define is reused.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-03 15:41:19 +02:00
Andreas Rheinhardt 25ea90b733 avcodec/encode: Avoid unreferencing blank AVFrames
ff_thread_video_encode_frame() already returns blank frames.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-03 15:41:19 +02:00
Mohamed Khaled Mohamed 1a5cd79f51 avfilter: add bilateral_cuda filter
GSoC 2022

Signed-off-by: Mohamed Khaled <mohamed.elbassiony00@eng-st.cu.edu.eg>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2022-09-03 15:18:56 +02:00
Paul B Mahol d1513e7f9c avfilter: add 3D scope multimedia filter 2022-09-03 14:44:59 +02:00
Paul B Mahol 4beac58e90 avcodec/cfhd: fix escape handling for old codebook 2022-09-03 14:44:58 +02:00
Paul B Mahol 10ed73e933 avcodec/cfhddata: remove unused defines 2022-09-03 14:44:58 +02:00
Martin Storsjö e4ac156b7c libavcodec: Set hidden visibility on global symbols accessed from AArch64 assembly
The AArch64 assembly accesses those symbols directly, without
indirection via e.g. the GOT on ELF. In order for this not to
require text relocations, those symbols need to be resolved fully
at link time, i.e. those symbols can't be interposable.

Normally, so far, this is achieved when linking shared libraries
in two ways; we have a version script (libavcodec/libavcodec.v) which
marks all symbols that don't start with av* as local. Additionally,
we try to add -Wl,-Bsymbolic to the linker options if supported,
making sure that such symbol references are resolved fully at link
time, instead of making them interposable.

When the libavcodec static library is linked into another shared
library, there's no guarantee that it uses similar options (even though
that would be favourable), which would end up requiring text relocations
in the AArch64 assembly.

Explicitly mark the symbols that are accessed from AArch64 assembly
as hidden, so that they are resolved fully at link time even without
the version script and -Wl,-Bsymbolic.

Signed-off-by: Martin Storsjö <martin@martin.st>
2022-09-02 23:13:29 +03:00
Martin Storsjö 0dd8fe6f4b arm: Check the build time constants in av_clip_*intp2
This fixes building for arm targets with optimizations disabled.

Signed-off-by: Martin Storsjö <martin@martin.st>
2022-09-02 23:12:26 +03:00
Martin Storsjö 3f456dc245 arm: rv40dsp: Change stride parameters to ptrdiff_t
These were missed when h264_chroma_mc_func was changed in
e4a94d8b36.

Signed-off-by: Martin Storsjö <martin@martin.st>
2022-09-02 23:04:58 +03:00
Martin Storsjö 826cd5e098 arm: vc1sdp: Change stride parameters to ptrdiff_t
This was missed in db54426975.

Signed-off-by: Martin Storsjö <martin@martin.st>
2022-09-02 23:04:55 +03:00
Andreas Rheinhardt 7de9c0e9d7 avcodec/flac: Don't use bytestream API unnecessarily
It makes no sense here, as flac_parse_block_header()
is not even supposed to advance the caller's pointer.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-02 11:55:22 +02:00
Andreas Rheinhardt 5089884e3c avcodec/flac: Move decoder+parser stuff into a new header, flac_parse.h
(The FLAC parser currently ignores the streaminfo block;
therefore some of this is decoder-only. Given that the FLAC
parser should probably use the streaminfo block, this stuff
is moved to flac_parse.h.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-02 11:55:22 +02:00