[FFmpeg-cvslog] avcodec/mpeg_er: Allow to skip setting partitioned_frame, p[pb]_time

Andreas Rheinhardt git at videolan.org
Thu Jul 3 21:56:35 EEST 2025


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Sun Jun 22 13:58:11 2025 +0200| [0984724d1e6d9e1df75d6e072858dc33ca55fa36] | committer: Andreas Rheinhardt

avcodec/mpeg_er: Allow to skip setting partitioned_frame, p[pb]_time

Instead of setting these unconditionally (they are always zero
for H.261, MPEG-1/2, RV30/40, VC-1), add a variant of
ff_mpeg_er_frame_start() that sets them and remove setting them
from ff_mpeg_er_frame_start(). Also pass these values via parameters
instead of reading them from the MPVContext itself.
This will allow to move them from MPVContext.

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

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

 libavcodec/h263dec.c | 3 ++-
 libavcodec/mpeg_er.c | 3 ---
 libavcodec/mpeg_er.h | 9 +++++++++
 libavcodec/rv10.c    | 2 +-
 4 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index ef78e87901..c303cce194 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -551,7 +551,8 @@ int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame *pict,
             return ret;
     }
 
-    ff_mpeg_er_frame_start(s);
+    ff_mpv_er_frame_start_ext(s, s->partitioned_frame,
+                              s->pp_time, s->pb_time);
 
     /* the second part of the wmv2 header contains the MB skip bits which
      * are stored in current_picture->mb_type which is not available before
diff --git a/libavcodec/mpeg_er.c b/libavcodec/mpeg_er.c
index 951167a478..5df75d8e85 100644
--- a/libavcodec/mpeg_er.c
+++ b/libavcodec/mpeg_er.c
@@ -51,10 +51,7 @@ void ff_mpeg_er_frame_start(MpegEncContext *s)
     set_erpic(&er->next_pic, s->next_pic.ptr);
     set_erpic(&er->last_pic, s->last_pic.ptr);
 
-    er->pp_time           = s->pp_time;
-    er->pb_time           = s->pb_time;
     er->quarter_sample    = s->quarter_sample;
-    er->partitioned_frame = s->partitioned_frame;
 
     ff_er_frame_start(er);
 }
diff --git a/libavcodec/mpeg_er.h b/libavcodec/mpeg_er.h
index bb627a4d06..145d1866ed 100644
--- a/libavcodec/mpeg_er.h
+++ b/libavcodec/mpeg_er.h
@@ -24,4 +24,13 @@
 int ff_mpeg_er_init(MpegEncContext *s);
 void ff_mpeg_er_frame_start(MpegEncContext *s);
 
+static inline void ff_mpv_er_frame_start_ext(MPVContext *const s, int partitioned_frame,
+                                             uint16_t pp_time, uint16_t pb_time)
+{
+    s->er.partitioned_frame = partitioned_frame;
+    s->er.pp_time           = pp_time;
+    s->er.pb_time           = pb_time;
+    ff_mpeg_er_frame_start(s);
+}
+
 #endif /* AVCODEC_MPEG_ER_H */
diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c
index ed702dfb66..677db1cd42 100644
--- a/libavcodec/rv10.c
+++ b/libavcodec/rv10.c
@@ -451,7 +451,7 @@ static int rv10_decode_packet(AVCodecContext *avctx, const uint8_t *buf,
         }
         if ((ret = ff_mpv_frame_start(&h->c, avctx)) < 0)
             return ret;
-        ff_mpeg_er_frame_start(&h->c);
+        ff_mpv_er_frame_start_ext(&h->c, 0, h->c.pp_time, h->c.pb_time);
     } else {
         if (h->c.cur_pic.ptr->f->pict_type != h->c.pict_type) {
             av_log(h->c.avctx, AV_LOG_ERROR, "Slice type mismatch\n");



More information about the ffmpeg-cvslog mailing list