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

avcodec/mpegvideo: Support custom slice context sizes

This is in preparation for adding a special slice context for
the encoders and moving all the encoder-specific fields to it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt
2025-03-16 14:52:36 +01:00
parent 1b537de8d4
commit f293f95632
2 changed files with 5 additions and 1 deletions

View File

@ -375,6 +375,7 @@ static av_cold int init_duplicate_context(MpegEncContext *s)
av_cold int ff_mpv_init_duplicate_contexts(MpegEncContext *s)
{
int nb_slices = s->slice_context_count, ret;
size_t slice_size = s->slice_ctx_size ? s->slice_ctx_size : sizeof(*s);
s->parent = s;
@ -382,7 +383,7 @@ av_cold int ff_mpv_init_duplicate_contexts(MpegEncContext *s)
* fields allocated in init_duplicate_context are NULL after
* copying. This prevents double-frees upon allocation error. */
for (int i = 1; i < nb_slices; i++) {
s->thread_context[i] = av_memdup(s, sizeof(MpegEncContext));
s->thread_context[i] = av_memdup(s, slice_size);
if (!s->thread_context[i])
return AVERROR(ENOMEM);
if ((ret = init_duplicate_context(s->thread_context[i])) < 0)

View File

@ -469,6 +469,9 @@ typedef struct MpegEncContext {
* a frame size change */
int context_reinit;
/// If set, ff_mpv_common_init() will allocate slice contexts of this size
unsigned slice_ctx_size;
ERContext er;
int error_rate;