118737 Commits

Author SHA1 Message Date
9899da8175 libavfilter: guard against ff_draw_init/ff_draw_init2 failures
The return value of ff_draw_init and ff_draw_init2 are not checked in
most usages. However, if they return an error, they don't get to the
point where they set the attributes of the FFDrawContext. These
functions are typically used in conjunction with ff_draw_color, which
checks draw->desc->flags, causing a null pointer dereference.

Signed-off-by: Nil Fons Miret <nilf@netflix.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-11 14:17:01 +01:00
bdc07f372a hwcontext_vulkan: add support for mapping multiplane images into CUDA
This patch refactors the CUDA import code to allow for Vulkan images
with multiple planes to be mapped.

Currently, a driver bug exists which causes NV12 images to be mapped
incorrectly when the memory being mapped contains both planes, the
issue has been reported to NVIDIA.
yuv420p does work correctly, however.

This is still an improvement, as the code used to crash when trying to
map the memory, unless disable_multiplane=1 was given as an option.
2025-03-11 13:42:19 +01:00
49c8f33262 lsws/ppc/yuv2rgb_altivec: Fix build in non-VSX environments with Clang v2
v2: test for function if AltiVec is enabled instead of with AltiVec and without VSX
2025-03-11 00:31:47 -04:00
6a7a77023e avcodec/dvdsubenc: Remove pointless wrapper
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-11 04:37:21 +01:00
ede2b391cc avcodec/put_bits: Add and use put_bits63()
When using a 64bit PutBitContext (i.e. on x64), put_bits_no_assert()
can naturally write up to 63 bits. So one can avoid treating the
cases <32bits, 32 bits and <63 bits differently.

As it turns out, no user actually wants to write 64 bit at once
(maybe except testprograms).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-11 04:37:21 +01:00
512e597932 avcodec/vc2enc: Simplify writing dirac golomb codes
The earlier code used a loop to determine the number of bits used
and called ff_log2() on a power of two (and it would be easy to
keep track of the exponent of said power-of-two); neither GCC nor
Clang optimized the loop away or avoided the ff_log2().
This patch replaces the loop and the log2 with a single av_log2().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-11 04:37:21 +01:00
27c82af2fe avutil/vulkan: Remove unused ff_vk_create_avbuf()
Unused since aea4d4b423c62aecf326ef3ae1578710faa3eca6.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-11 04:35:53 +01:00
e499c85999 avutil/refstruct: Fix documentation
Reviewed-by: Stefano Sabatini <stefasab@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-11 04:35:06 +01:00
04d7a6d3db avcodec/exr: use luma+alpha float pixel formats
Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-10 10:15:42 -03:00
468577d1a5 swscale/input: add support for YAF16 and YAF32
Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-10 10:15:42 -03:00
61fc9b6fee avutil/pixfmt: add YAF16 and YAF32 pixel formats
Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-10 10:15:42 -03:00
5f5ab22639 avfilter/vsrc_testsrc: add support for semi planar formats to yuvtestsrc
Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-10 10:15:33 -03:00
73f4668ef8 swscale: aarch64: Simplify the assignment of lumToYV12
We normally don't need else statements here; the common pattern
is to assign lower level SIMD implementations first, then
conditionally reassign higher level ones afterwards, if supported.

Signed-off-by: Martin Storsjö <martin@martin.st>
2025-03-10 14:03:58 +02:00
87e5da9067 avcodec/wmaenc: Don't unnecessarily reset AVPacket.size
The packet is unreferenced generically lateron anyway.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-10 04:52:31 +01:00
196ee9fc86 avcodec/wma: Mark ff_wma_end() as av_cold
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-10 04:52:15 +01:00
b98beb3704 all: Use put_bytes_output() instead of put_bits_ptr - pb->buf
Avoids accessing internals of PutBitContext.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-10 04:51:57 +01:00
0971fcf0a0 avcodec/codec_internal, all: Use macros to set deprecated AVCodec fields
The aim of this is twofold: a) Clang warns when setting a deprecated
field in a definition and because several of the widely set
AVCodec fields are deprecated, one gets several hundred warnings
from Clang for an ordinary build. Yet fortunately Clang (unlike GCC)
allows to disable deprecation warnings inside a definition, so
that one can create simple macros to set these fields that also suppress
deprecation warnings for Clang. This has already been done in
fdff1b9cbfd8cf5a9810c29efa4baf13a4786742 for AVCodec.channel_layouts.
b) Using macros will allow to easily migrate these fields to internal ones.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-10 00:57:23 +01:00
0349ae3ec4 avcodec/vp8: Remove always-false hwaccel checks for VP7
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-10 00:51:04 +01:00
a41baa743d avcodec/vp8: Move VPx specific functions inside #if CONFIG_VPx block
where appropriate. Avoids including ff_vp8_decode_frame()
when the VP8 decoder is disabled.

Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-10 00:50:57 +01:00
4040dc0782 avcodec/vp8: Move codec-specific init code out of common init
While just at it, also move the init functions inside
the #if CONFIG_VP?_DECODER (to avoid linking failures).
While just at it, also declare these init functions
as av_cold and uninline the remaining common init function.

Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-10 00:50:49 +01:00
b6602a17e1 avcodec/vp8: Fix wrong #endif comment
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-10 00:50:24 +01:00
20a6eb1ca3 lavc/vvc: Stricter bound on pps_exp_slice_height_in_ctus_minus1
When pps_num_exp_slices_in_tile[i] is nonzero, the ith tile is made up
of pps_num_exp_slices_in_tile[i] slices stacked atop one another, where
the height of the jth slice in the ith tile is given by
pps_exp_slice_height_in_ctus_minus1[i][j].  The sum of the heights of
the slices in the tile should not exceed the height of the tile itself.

Signed-off-by: Frank Plowman <post@frankplowman.com>
2025-03-09 21:35:53 +08:00
e934fd96c1 avcodec/snow: Remove outdated assert
It comes from a time before frames were refcounted; it has indeed been
added in a follow-up commit to c13e490dce1a66d79e1f053d8a38fb9b2eb53267:
"codec_release_buffer: fix handling of non user buffers". This type
of check is obsolete now.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-09 04:23:40 +01:00
d7820a2b6f avcodec/sbcenc: Don't use deprecated AVCodec.supported_samplerates
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-09 04:20:52 +01:00
1b6f37ac13 avcodec/sbcenc: Mark sbc_encode_init() as av_cold
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-09 04:20:52 +01:00
1bce40cb73 avcodec/ffv1: Use dual run coder for fltmap
This improves compression by 0.1% overall and 44% for the changed table
I tried several other things but so far this is the best
compromise between complexity and compression

This can also be extended to 32 and 64bit floats

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-08 20:55:39 +01:00
9bad2634ee avcodec/ffv1: Store remap flag per slice
This allows switching it on conditionally and also for non float,
it may improve compression for RGB data that was paletted
or other synthetic images

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-08 20:55:38 +01:00
4a0c285dfe avcodec/ffv1: flip half of float16 and Compactify floats
float16 (and more so float32) have many odd values
half the values are negative, many are larger than "1.0"
and many values are very close to 0.

Storing the 16bits as is, looses compression because of the mixture
of dense and sparse regions and also many completely unused ones.

This simply remaps the 65536 values so no unused values remain
This improves compression by about 1.5% for the ACES_OT_VWG_SampleFrames testset
(this testset contains all kind of funny values including many images
 with negative rgb values)

The space needed for the map is insignificant compared to the
compression gained

This patch also flips half the float range as it can be done
using the same table.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-08 20:55:38 +01:00
c1b330bf24 avcodec/ffv1: Basic float16 support
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-08 20:55:38 +01:00
114e9864e1 avcodec/sanm: ignore unknown codecs in FOBJs
Don't error out, just ignore unknown codec numbers and pretend
decode succeeded.  This is useful for older LucasArts titles
which stack a lot of different FOBJs with different codecs into
a single frame.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-08 20:55:37 +01:00
f641c6846a avutil/log: Set AVClass* in av_expr_eval()
Otherwise it is possible for av_log() to receive a non-NULL object
with a NULL AVClass pointer; the default log callback handles it
gracefully, yet this is probably an API violation.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-08 01:05:47 +01:00
39286d97f2 avcodec: Don't log to private context
While it is save for these codecs (they all have private contexts),
it is customary to always use the AVCodecContext for logging.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-08 01:05:46 +01:00
e6d07e45e0 avcodec/{h263,ituh263,msmpeg4,snow}dec: Use proper logcontext
The logging functions here can be reached by codecs without
private class, so that the log callback will receive a non-NULL
object whose AVClass pointer is NULL. Although the default log
callback handles this gracefully, it is probably an API violation.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-08 01:05:46 +01:00
ce1cec673e avcodec/mpeg12dec: Use CHROMA_* defines
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-07 15:19:03 +01:00
8940a6153f avcodec/mjpegenc: Constify parent ctx in encode_block()
Said parent is shared between all slice contexts and encode_block()
can be run concurrently by slice threads, so the parent context
must not be (and is not) modified. So constify the pointers.

Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-07 15:19:03 +01:00
60cae5019a avcodec/mjpegenc_common: Constify ff_mjpeg_encode_{dc,picture_header}()
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-07 15:19:03 +01:00
5689d9c0f4 avcodec/mjpegenc: Don't use ff_ prefix for static functions
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-07 15:19:03 +01:00
455ca92b31 avcodec/mjpegenc: Use forward decl for MpegEncContext, MJpegHuffmanCode
Avoids an indirect inclusion of mpegvideo.h in mjpegenc_common.c.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-07 15:19:03 +01:00
85138c1434 avcodec/mpegvideo_enc, motion_est: Pre-center fcode_tab
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-07 15:19:03 +01:00
c709a3d424 avcodec/mpegvideo: Move vbv_delay to Mpeg1Context
Only used there and only by the main thread.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-07 15:19:03 +01:00
6e225123d8 avcodec/mpeg12enc: Simplify writing bits
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-07 15:19:03 +01:00
d5db4ee30c avcodec/mjpegenc: Don't log to private context
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-07 15:19:03 +01:00
6cdcf15e0a avcodec/mjpegenc: Remove nonsensical AMV options
Both these options are unsupported and silently ignored for AMV;
so it is better to not offer them at all.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-07 15:19:03 +01:00
fc158f3d40 avcodec/speedhqenc: Inline ff_speedhq_mb_y_order_to_mb()
It is an extremely simple function that is only called once,
so it should be inlined.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-07 15:19:03 +01:00
49c38761f1 avcodec/speedhqenc: Don't log to the private context
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-07 15:19:03 +01:00
e117faddbf avcodec/mpegvideo: Mark ff_mpv_common_defaults() as av_cold
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-07 15:19:03 +01:00
89a8033fc9 avcodec/mpegvideo: Move temp ratecontrol bufs to RateControlContext
Also only allocate them when they are needed (namely iff
adaptive quant is true) and allocate them jointly.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-07 15:19:03 +01:00
6844e96116 avcodec/mpegvideo: Move ratecontrol-only options to RateControlContext
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-07 15:19:03 +01:00
1ec1f1e236 avcodec/mpegvideo_enc: Move H.263 specific check to ituh263enc.c
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-07 15:19:03 +01:00
c3ab7362dd avcodec/mpegvideo_enc: Move vbv_delay warning to mpeg12enc.c
It is MPEG-1/2 only.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-07 15:19:02 +01:00