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

avcodec/mpegvideo: Move parent to MPVEncContext

This is more type-safe and avoids having parent contexts
when unnecessary.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt
2025-04-30 04:09:11 +02:00
parent bc81a797c4
commit 505510acda
4 changed files with 4 additions and 7 deletions

View File

@ -142,8 +142,6 @@ av_cold int ff_mpv_init_duplicate_contexts(MpegEncContext *s)
int nb_slices = s->slice_context_count, ret; int nb_slices = s->slice_context_count, ret;
size_t slice_size = s->slice_ctx_size ? s->slice_ctx_size : sizeof(*s); size_t slice_size = s->slice_ctx_size ? s->slice_ctx_size : sizeof(*s);
s->parent = s;
/* We initialize the copies before the original so that /* We initialize the copies before the original so that
* fields allocated in init_duplicate_context are NULL after * fields allocated in init_duplicate_context are NULL after
* copying. This prevents double-frees upon allocation error. */ * copying. This prevents double-frees upon allocation error. */

View File

@ -80,10 +80,6 @@ typedef struct MpegEncContext {
uint8_t permutated_intra_v_scantable[64]; uint8_t permutated_intra_v_scantable[64];
struct AVCodecContext *avctx; struct AVCodecContext *avctx;
union {
const struct MpegEncContext *parent;
const struct MPVMainEncContext *encparent;
};
/* The following pointer is intended for codecs sharing code /* The following pointer is intended for codecs sharing code
* between decoder and encoder and in need of a common context to do so. */ * between decoder and encoder and in need of a common context to do so. */
void *private_ctx; void *private_ctx;

View File

@ -1024,6 +1024,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
/* ff_mpv_common_init() will copy (memdup) the contents of the main slice /* ff_mpv_common_init() will copy (memdup) the contents of the main slice
* to the slice contexts, so we initialize various fields of it * to the slice contexts, so we initialize various fields of it
* before calling ff_mpv_common_init(). */ * before calling ff_mpv_common_init(). */
s->parent = m;
ff_mpv_idct_init(&s->c); ff_mpv_idct_init(&s->c);
init_unquantize(&s->c, avctx); init_unquantize(&s->c, avctx);
ff_fdctdsp_init(&s->fdsp, avctx); ff_fdctdsp_init(&s->fdsp, avctx);

View File

@ -69,6 +69,8 @@ typedef struct MPVEncContext {
*/ */
AVFrame *new_pic; AVFrame *new_pic;
struct MPVMainEncContext *parent;
FDCTDSPContext fdsp; FDCTDSPContext fdsp;
MpegvideoEncDSPContext mpvencdsp; MpegvideoEncDSPContext mpvencdsp;
PixblockDSPContext pdsp; PixblockDSPContext pdsp;
@ -254,7 +256,7 @@ static inline const MPVMainEncContext *slice_to_mainenc(const MPVEncContext *s)
!(s->c.avctx->codec->capabilities & AV_CODEC_CAP_SLICE_THREADS)); !(s->c.avctx->codec->capabilities & AV_CODEC_CAP_SLICE_THREADS));
return (const MPVMainEncContext*)s; return (const MPVMainEncContext*)s;
#else #else
return s->c.encparent; return s->parent;
#endif #endif
} }