You've already forked FFmpeg
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:
@ -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)
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user