[FFmpeg-cvslog] avcodec/{h263,mpeg4video}dec: Pass MPVContext*, not Mpeg4DecContext*

Andreas Rheinhardt git at videolan.org
Thu Jul 3 21:55:52 EEST 2025


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Thu Jun 19 16:07:48 2025 +0200| [758c8dffc922184be9a11f14191ce3e243681fc9] | committer: Andreas Rheinhardt

avcodec/{h263,mpeg4video}dec: Pass MPVContext*, not Mpeg4DecContext*

The code in h263dec.c is not supposed to know that the MPEG-4
decoder uses an Mpeg4DecContext as private context at all
(said context is only exposed in a header so that hardware
accelerations can access it and for the parser to use).
Passing an MPVContext* directly also allows to remove
the indirection via AVCodecContext.priv_data.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=758c8dffc922184be9a11f14191ce3e243681fc9
---

 libavcodec/h263dec.c       |  4 ++--
 libavcodec/ituh263dec.c    |  4 ++--
 libavcodec/mpeg4videodec.c | 12 ++++++------
 libavcodec/mpeg4videodec.h |  6 +++---
 4 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 52b17663db..7e454e3406 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -194,7 +194,7 @@ static int decode_slice(MpegEncContext *s)
     ff_set_qscale(s, s->qscale);
 
     if (s->studio_profile) {
-        if ((ret = ff_mpeg4_decode_studio_slice_header(s->avctx->priv_data)) < 0)
+        if ((ret = ff_mpeg4_decode_studio_slice_header(s)) < 0)
             return ret;
     }
 
@@ -210,7 +210,7 @@ static int decode_slice(MpegEncContext *s)
         const int qscale = s->qscale;
 
         if (CONFIG_MPEG4_DECODER && s->codec_id == AV_CODEC_ID_MPEG4)
-            if ((ret = ff_mpeg4_decode_partitions(s->avctx->priv_data)) < 0)
+            if ((ret = ff_mpeg4_decode_partitions(s)) < 0)
                 return ret;
 
         /* restore variables which were modified */
diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c
index fa09ebb84b..f5001200fe 100644
--- a/libavcodec/ituh263dec.c
+++ b/libavcodec/ituh263dec.c
@@ -240,7 +240,7 @@ int ff_h263_resync(MpegEncContext *s){
     if(show_bits(&s->gb, 16)==0){
         pos= get_bits_count(&s->gb);
         if(CONFIG_MPEG4_DECODER && s->codec_id==AV_CODEC_ID_MPEG4)
-            ret= ff_mpeg4_decode_video_packet_header(s->avctx->priv_data);
+            ret = ff_mpeg4_decode_video_packet_header(s);
         else
             ret= h263_decode_gob_header(s);
         if(ret>=0)
@@ -257,7 +257,7 @@ int ff_h263_resync(MpegEncContext *s){
 
             pos= get_bits_count(&s->gb);
             if(CONFIG_MPEG4_DECODER && s->codec_id==AV_CODEC_ID_MPEG4)
-                ret= ff_mpeg4_decode_video_packet_header(s->avctx->priv_data);
+                ret = ff_mpeg4_decode_video_packet_header(s);
             else
                 ret= h263_decode_gob_header(s);
             if(ret>=0)
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index c61fd23c48..91b1687884 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -700,9 +700,9 @@ static int decode_new_pred(Mpeg4DecContext *ctx, GetBitContext *gb) {
  * Decode the next video packet.
  * @return <0 if something went wrong
  */
-int ff_mpeg4_decode_video_packet_header(Mpeg4DecContext *ctx)
+int ff_mpeg4_decode_video_packet_header(MPVContext *const s)
 {
-    MpegEncContext *s = &ctx->m;
+    Mpeg4DecContext *const ctx = (Mpeg4DecContext*)s;
 
     int mb_num_bits      = av_log2(s->mb_num - 1) + 1;
     int header_extension = 0, mb_num, len;
@@ -799,9 +799,9 @@ static void reset_studio_dc_predictors(MpegEncContext *s)
  * Decode the next video packet.
  * @return <0 if something went wrong
  */
-int ff_mpeg4_decode_studio_slice_header(Mpeg4DecContext *ctx)
+int ff_mpeg4_decode_studio_slice_header(MPVContext *const s)
 {
-    MpegEncContext *s = &ctx->m;
+    Mpeg4DecContext *const ctx = (Mpeg4DecContext*)s;
     GetBitContext *gb = &s->gb;
     unsigned vlc_len;
     uint16_t mb_num;
@@ -1307,9 +1307,9 @@ static int mpeg4_decode_partition_b(MpegEncContext *s, int mb_count)
  * Decode the first and second partition.
  * @return <0 if error (and sets error type in the error_status_table)
  */
-int ff_mpeg4_decode_partitions(Mpeg4DecContext *ctx)
+int ff_mpeg4_decode_partitions(MPVContext *const s)
 {
-    MpegEncContext *s = &ctx->m;
+    Mpeg4DecContext *const ctx = (Mpeg4DecContext*)s;
     int mb_num;
     int ret;
     const int part_a_error = s->pict_type == AV_PICTURE_TYPE_I ? (ER_DC_ERROR | ER_MV_ERROR) : ER_MV_ERROR;
diff --git a/libavcodec/mpeg4videodec.h b/libavcodec/mpeg4videodec.h
index ae8428fd2b..32ad081df3 100644
--- a/libavcodec/mpeg4videodec.h
+++ b/libavcodec/mpeg4videodec.h
@@ -116,9 +116,9 @@ void ff_mpeg4_decode_studio(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb
 void ff_mpeg4_mcsel_motion(MpegEncContext *s,
                            uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
                            uint8_t *const *ref_picture);
-int ff_mpeg4_decode_partitions(Mpeg4DecContext *ctx);
-int ff_mpeg4_decode_video_packet_header(Mpeg4DecContext *ctx);
-int ff_mpeg4_decode_studio_slice_header(Mpeg4DecContext *ctx);
+int ff_mpeg4_decode_partitions(MPVContext *const s);
+int ff_mpeg4_decode_video_packet_header(MPVContext *const s);
+int ff_mpeg4_decode_studio_slice_header(MPVContext *const s);
 void ff_mpeg4_workaround_bugs(AVCodecContext *avctx);
 void ff_mpeg4_pred_ac(MpegEncContext *s, int16_t *block, int n,
                       int dir);



More information about the ffmpeg-cvslog mailing list