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

119008 Commits

Author SHA1 Message Date
e308292a31 avcodec/speedhqenc: Move speedhq_encode_init() down
Will avoid forward declarations later.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:30:38 +01:00
6b6b34df35 avcodec/mpegvideo: Move header_bits to MPVMainEncContext
The header is always written by the main thread, so it is
not surprising that header_bits can be moved to MPVMainEncContext
as well.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:30:07 +01:00
b038c7af0c avcodec/mpegvideo: Move macroblock-variance stats to MPVMainEncContext
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:29:35 +01:00
553fc3a764 avcodec/mpegvideoenc: Disable scenechange threshold opt for MJPEG, AMV
It makes no sense for them. Also do the same for the mv0 flag.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:29:07 +01:00
d1fd8665fb avcodec/mpegvideo: Move ratecontrol-adjacent fields to MPVMainEncContext
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:17:52 +01:00
b710698571 avcodec/mpegvideo: Move sequence-level properties to MPVMainEncContext
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:16:03 +01:00
d9dea7088d avcodec/mpegvideo_enc: Move MPEG-4 specific check to mpeg4videoenc.c
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:15:37 +01:00
fca1ac2cba avcodec/mpeg4videoenc: Add Mpeg4EncContext and move time_increment_bits
It is only ever used by the main encoder thread.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:15:05 +01:00
e8a8a13128 avutil/slicethread: Mark avpriv_slicethread_{create,free} as av_cold
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:14:41 +01:00
f9fe1e07ad avutil/slicethread: Remove NULL pointer check when freeing
avpriv_slicethread_free() is one of our functions that takes
a pointer to a pointer and resets the pointer when done.
It is legal for such functions to be passed a pointer to a NULL
pointer, yet passing a NULL pointer would be insane and should
not be tolerated.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:14:17 +01:00
7d1bf0ac7a avcodec/pthread_slice: Return error on error
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:13:53 +01:00
c82101c9ce avcodec/pthread_slice: Remove MPEG-1 height hack
This is no longer necessary given that the MPEG-1 encoder
now adapts the size of the last slice to ensure that
no slice header has an invalid slice_start_code.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:13:29 +01:00
4eb86951fc avcodec/mpeg12enc: Don't write invalid MPEG-1 slice headers
The valid values for slice_start_code are 0x1..0xAF, which implies
that one can't start a slice with row nb > 174 (zero-based).
This problem can be encountered with files of sufficient height
(more than 2800 pixels) either by using the slice option or by
imposing an RTP payload limit.

Fix this by making the last slice start on the maximum allowed
slice row if necessary and divide the first 174 rows to the remaining
slices. This will impede parallelism both in the decoder and encoder,
but that is unavoidable.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:13:04 +01:00
6ecdbcc454 avcodec/mpeg12enc: Merge ff_mpeg1_encode_init() into ordinary init
Everything except setting the dc_scale_tables can be done
before calling ff_mpv_encode_init(); setting the dc_scale_tables
unfortunately still has to be performed via a (now inlined)
callback performed by ff_mpv_encode_init() as it relies
on intra_dc_precision having been sanitized.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:12:38 +01:00
34557b1d30 avcodec/mpeg12enc: Move encode_init() to the end of the file
Will avoid forward declarations later.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:12:14 +01:00
edebd1d9a4 avcodec/mpegvideo_enc: Only set fcode_tab if unset
This is in preparation for merging ff_mpeg1_encode_init()
into the MPEG-1/2 encoder's init function.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:11:49 +01:00
24dbc4c2e8 avcodec/mjpegenc: Simplify allocating huffman table
Reuse the already computed value of macroblocks; use an array
instead of a switch, evaluate 64 * sizeof(MJpegHuffmanCode)
at compile-time.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:11:26 +01:00
dcd4daee8c avcodec/mjpegenc: Make mjpeg_encode_init() call ff_mpv_encode_init()
Right now, ff_mpv_encode_init() is set as FFCodec.init and
calls ff_speedhq_encode_init(). The opposite is more natural,
avoids a non-static function and allows to reuse e.g.
slice_context_count instead of duplicating the logic from
ff_mpv_common_init().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:11:00 +01:00
9928b9e9fa avcodec/speedhqenc: Avoid indirection
Namely use avctx directly instead of s->avctx. While just at it,
also move the switch to the other checks involving avctx.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:10:37 +01:00
565e57ea87 avcodec/speedhqenc: Make speedhq_encode_init() call ff_mpv_encode_init()
Right now, ff_mpv_encode_init() is set as FFCodec.init and
calls ff_speedhq_encode_init(). The opposite is more natural
and avoids a non-static function.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:10:12 +01:00
c757f948d1 avcodec/mpegvideo: Don't initialize [yc]_dc_scale_table by default
Only the H.263-based decoders as well as the encoders need it;
so move it to ff_h263_decode_init() as well as ff_mpv_encode_init().
Also for the latter make it only set these tables if none are
already set.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:09:47 +01:00
b7ee7994cc avcodec/h261enc: Make h261_encode_init() call ff_mpv_encode_init()
Right now, ff_mpv_encode_init() is set as FFCodec.init and
calls ff_h261_encode_init(). The opposite is more natural
and avoids a non-static function.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:09:23 +01:00
3275d788ec avcodec/mpegvideo: Move frame_skip_* fields to MPVMainEncContext
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:08:52 +01:00
4d79175b9a avcodec/mpegvideo_enc: Precalculate which frames to reconstruct
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:08:22 +01:00
d8c7925e32 avcodec/mpegvideoenc: Move ratecontrol to MPVMainEncContext
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:07:52 +01:00
bb0a72b100 avcodec/mpegvideoenc: Move tmp bframes to MPVMainEncContext
Also move b_frame_strategy and b_sensitivity and brd_scale;
they are all only used by an encoder's main thread when
b_frame_strategy == 2.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:07:22 +01:00
f507f26e47 avcodec/mpegvideoenc: Add MPVMainEncContext
This is in preparation for moving all the elements from
MpegEncContext that are only used by the main encoder thread
to MPVMainEncContext.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:06:54 +01:00
ad4f6a3d6e avcodec/mpegvideo(_enc)?: Mark init, close functions as av_cold
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:06:10 +01:00
08e334e462 avformat/movenccenc: add support for CENC AV1 encryption
Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-25 20:59:18 -03:00
5631704d83 avcodec/cbs: allow fine tunning selection of features
Core framework and AV1 only for now.
This will be useful in an upcoming commit, where CBS will be utilized by
a module outside libavcodec.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-25 20:38:29 -03:00
3e0b38ed7f avcodec/cbs_av1: also store a pointer to the start of the tile group data
This will be useful a following commit, where the offset of the Tile Group
inside a Frame OBU needs to be known.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-25 11:09:16 -03:00
d435b641a2 MAINTAINERS: Add myself
will move to specific areas once they are there.

Signed-off-by: softworkz <softworkz@hotmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-25 11:38:21 +01:00
8af28d2eb1 avcodec/ffv1enc: Eliminate index_stack and delta_stack
This reduces stack space requirements my 1.5 mb and should fix fate

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-25 11:38:20 +01:00
051fd03f6c avcodec/ffv1enc: Heuristic to select fixed in float multipliers
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-25 11:32:14 +01:00
a33908d051 avcodec/ffv1enc: Factorize s.last_val update out
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-25 11:32:14 +01:00
836add03a8 avcodec/ffv1enc: Simplify last_val update
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-25 11:32:11 +01:00
4b24c5ba69 avcodec/ffv1enc: introduce step to simplify code
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-25 11:31:08 +01:00
e9cfed35a5 avcodec/ffv1enc: eliminate if()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-25 11:24:13 +01:00
522fc389e8 avcodec/ffv1dec: replace literal 65535 by what it is
should make the code easier to understand

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-25 11:24:13 +01:00
5ca14b23f1 avcodec/ffv1dec: compute end instead of hardcoding it and test for fltmap correctly
A step toward supporting remap for integer formats less than 16 bit

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-25 11:24:12 +01:00
3813559660 avcodec/ffv1enc: remap table size is 1<<bits_per_raw_sample not fixed 65536
not a bugfix as this path was only used for float16 but it makes sense
to allow using this for integers too

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-25 11:24:12 +01:00
e619b0d817 avcodec/ffv1enc: remap mode 2 is for floats only
(you could use it for others but it makes no sense)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-25 11:24:12 +01:00
8b2372cac7 ffmpeg-filter: check for initialized graph
Don't drop frame if graph hasn't been initialized yet!
2025-03-25 01:06:03 +05:30
044664ac3b avcodec/ffv1enc: remove mixed declarations and code
Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-24 16:34:24 -03:00
a4cf0979a4 avcodec/ffv1enc: update missing Unit accesses inside av_assert2
Fixes compilation with assert-level=2.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-24 16:32:47 -03:00
702239bc50 avcodec/ffv1enc: reduce stack usage
Fixes failures in some systems since 171060d5dc.
This can be further improved by only allocating the arrays when needed.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-24 13:55:56 -03:00
fee5b0a383 fftools/ffmpeg_filter: ensure ifp is set before dereferencing it
Fixes segfaults since cbbc927a67.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-24 10:10:19 -03:00
5dcf566f69 avcodec/ffv1: Implement 2D RLE for remap
ATM this performs as well or better as any other algorithm tried.
Its simple for the decoder.
On the encoder side complexity depends on how parameters are
chosen. But with a fixed mul_count of 1 and basic heuristic
it performs as well as any more complex choice i tried so far.

The encoder code here is flexible and allows mul_count > 1
and also can easily be used to exactly test various parameters.

With mul_count=512 we can gain another 6% in remap table size
for fixed point in float data. (this is not implemented in this
patch though)

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-24 13:46:59 +01:00
0538b4c569 avcodec/ffv1dec: remove unused var 2025-03-24 13:46:58 +01:00
e19496fe71 avcodec/ffv1enc: remap allows using rice golomb with more bits
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-24 13:46:58 +01:00