1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-04 22:03:09 +02:00
Commit Graph

118872 Commits

Author SHA1 Message Date
Andreas Rheinhardt
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
Andreas Rheinhardt
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
fdff1b9cbf 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
Andreas Rheinhardt
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
Andreas Rheinhardt
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
Andreas Rheinhardt
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
Andreas Rheinhardt
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
Frank Plowman
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
Andreas Rheinhardt
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 c13e490dce:
"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
Andreas Rheinhardt
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
Andreas Rheinhardt
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
Michael Niedermayer
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
Michael Niedermayer
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
Michael Niedermayer
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
Michael Niedermayer
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
Manuel Lauss
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
Andreas Rheinhardt
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
Andreas Rheinhardt
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
Andreas Rheinhardt
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
Andreas Rheinhardt
ce1cec673e avcodec/mpeg12dec: Use CHROMA_* defines
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-07 15:19:03 +01:00
Andreas Rheinhardt
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
Andreas Rheinhardt
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
Andreas Rheinhardt
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
Andreas Rheinhardt
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
Andreas Rheinhardt
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
Andreas Rheinhardt
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
Andreas Rheinhardt
6e225123d8 avcodec/mpeg12enc: Simplify writing bits
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-07 15:19:03 +01:00
Andreas Rheinhardt
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
Andreas Rheinhardt
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
Andreas Rheinhardt
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
Andreas Rheinhardt
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
Andreas Rheinhardt
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
Andreas Rheinhardt
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
Andreas Rheinhardt
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
Andreas Rheinhardt
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
Andreas Rheinhardt
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
Andreas Rheinhardt
137060d586 avcodec/mpegvideo_enc: Move q_scale_type check to mpeg12enc.c
The MPEG-2 encoder is the only encoder supporting q_scale_type.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-07 15:19:02 +01:00
Andreas Rheinhardt
0c4b091bd6 avcodec/mpegvideo_enc: Move q_matrix init to init_matrices()
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-07 15:19:02 +01:00
Andreas Rheinhardt
726adfafc6 avcodec/mpegvideo_enc: Don't init matrices unnecessarily for MJPEG
The MJPEG initialization happens later.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-07 15:19:02 +01:00
Andreas Rheinhardt
41451b4eef avcodec/mpegvideo_enc: Only allocate inter matrices when needed
Also allocate them jointly with intra matrices when needed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-07 15:19:02 +01:00
Andreas Rheinhardt
a43124452f avcodec/mpegvideo_enc: Factor checks out of loop
Also move this code to init_matrices().

Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-07 15:19:02 +01:00
Andreas Rheinhardt
7223363ccb avcodec/mpegvideo_enc: Set chroma_intra_matrix for SpeedHQ
Used with trellis; notice that inter_matrix is unused for
(intra-only) SpeedHQ, so it is irrelevant that its value changes.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-07 15:19:02 +01:00
Andreas Rheinhardt
daff2df1a0 avcodec/mpegvideo_enc: Only allocate chroma intra matrices when needed
Also start factoring the matrix-init code out into a function
of its own to declutter ff_mpv_encode_init().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-07 15:19:02 +01:00
Andreas Rheinhardt
70359de69f avcodec/mpeg4video: Move IS_3IV1 macro to mpeg4videodec.c
Also add parentheses around the replacement to make it safer.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-07 15:19:02 +01:00
Andreas Rheinhardt
5df8c86b24 avcodec/mpeg4video: Split ff_mpeg4_pred_dc()
It currently does two things: a) Get a prediction for the dc
and the dc direction and b) process said prediction. Processing
the prediction differs for encoding (getting a diff) and decoding
(getting the level via diff+prediction). So having a common function
performing b) makes no sense.

Even worse, there is a decoding mode where the dc coefficient (diff)
is not coded specially and therefore unavailable before entering
the block decoding loop, so that one can only perform a). Before
this commit, the decoder simply called ff_mpeg4_pred_dc() twice;
the results of the b) part of the call before the loop were ignored
(but the compiler could not elide them because they involved error
messages) and a) was also performed twice.

This commit changes this by splitting b) out of ff_mpeg4_pred_dc()
and moving this code to decoder and encoder.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-07 15:19:02 +01:00
Andreas Rheinhardt
c050269eda avcodec/mpeg4videodec: Bail out earlier when parsing
The scantables are unused for the parser (and in fact
the IDCT permutation used has not been initialized at all).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-07 15:19:02 +01:00
Andreas Rheinhardt
f5f2c37a52 avcodec/ituh263dec: Reorder branches
(To perform this optimization a compiler would have to look
at both ff_rv_decode_dc() and av_log(). The latter seems very
unlikely.)

Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-07 15:19:02 +01:00
Andreas Rheinhardt
17ff442adb avcodec/flvenc: Remove redundant setting of dc_scale_tables
h263_aic is always zero for FLV and ff_mpeg1_dc_scale_table
is already the default dc_scale table for both y and c.
h263_aic is also always zero for the FLV decoder.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-07 15:19:02 +01:00
Andreas Rheinhardt
9e5a1b8693 avcodec/ituh263enc: Use memset where appropriate
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-07 15:19:02 +01:00
Andreas Rheinhardt
607bc17b52 avcodec/ituh263enc: Make SVQ1+Snowenc stop calling ff_h263_encode_init()
They only do it for the mv_penalty table. Factor initializating
the static tables out into a function of its own; also move
everything not needed by SVQ1 or Snow behind #if CONFIG_H263_ENCODER
(this involved moving ff_h263_encode_motion() which is used
by svq1enc).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-07 15:19:02 +01:00
Andreas Rheinhardt
9ca97756ac avcodec/ituh263enc: Combine branches
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-07 15:19:02 +01:00