[FFmpeg-cvslog] avcodec/mpegvideo: Move parent to MPVEncContext
Andreas Rheinhardt
git at videolan.org
Fri May 16 03:15:12 EEST 2025
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Wed Apr 30 04:09:11 2025 +0200| [505510acdad5bc08b67e01d66c5b339c8fe27d39] | committer: Andreas Rheinhardt
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 at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=505510acdad5bc08b67e01d66c5b339c8fe27d39
---
libavcodec/mpegvideo.c | 2 --
libavcodec/mpegvideo.h | 4 ----
libavcodec/mpegvideo_enc.c | 1 +
libavcodec/mpegvideoenc.h | 4 +++-
4 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index a783ccdbdd..55f7178bed 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -142,8 +142,6 @@ 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;
-
/* We initialize the copies before the original so that
* fields allocated in init_duplicate_context are NULL after
* copying. This prevents double-frees upon allocation error. */
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index de3ebd5ed2..20a5759958 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -80,10 +80,6 @@ typedef struct MpegEncContext {
uint8_t permutated_intra_v_scantable[64];
struct AVCodecContext *avctx;
- union {
- const struct MpegEncContext *parent;
- const struct MPVMainEncContext *encparent;
- };
/* The following pointer is intended for codecs sharing code
* between decoder and encoder and in need of a common context to do so. */
void *private_ctx;
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index ce9315c1b8..6e9533ebc9 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -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
* to the slice contexts, so we initialize various fields of it
* before calling ff_mpv_common_init(). */
+ s->parent = m;
ff_mpv_idct_init(&s->c);
init_unquantize(&s->c, avctx);
ff_fdctdsp_init(&s->fdsp, avctx);
diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h
index 76e3780923..ec0304c4a0 100644
--- a/libavcodec/mpegvideoenc.h
+++ b/libavcodec/mpegvideoenc.h
@@ -69,6 +69,8 @@ typedef struct MPVEncContext {
*/
AVFrame *new_pic;
+ struct MPVMainEncContext *parent;
+
FDCTDSPContext fdsp;
MpegvideoEncDSPContext mpvencdsp;
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));
return (const MPVMainEncContext*)s;
#else
- return s->c.encparent;
+ return s->parent;
#endif
}
More information about the ffmpeg-cvslog
mailing list