[FFmpeg-devel] [PATCH v2 64/69] avcodec/mpegvideo: Move coded_picture_number to MPVMainContext

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Tue Feb 1 15:07:01 EET 2022


It is not used by slice threads at all.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 libavcodec/mpegvideo.c     | 2 +-
 libavcodec/mpegvideo.h     | 3 ++-
 libavcodec/mpegvideo_dec.c | 4 ++--
 libavcodec/mpegvideo_enc.c | 6 +++---
 4 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index be18b428f5..8debf4d6ab 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -519,7 +519,7 @@ void ff_mpv_common_defaults(MPVMainContext *m)
     s->progressive_sequence  = 1;
     s->picture_structure     = PICT_FRAME;
 
-    s->coded_picture_number  = 0;
+    m->coded_picture_number  = 0;
     s->picture_number        = 0;
 
     s->f_code                = 1;
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index df5a51577a..99d474991a 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -103,7 +103,6 @@ typedef struct MPVContext {
     /* the following fields are managed internally by the encoder */
 
     /* sequence parameters */
-    int coded_picture_number;  ///< used to set pic->coded_picture_number, should not be used for/by anything else
     int picture_number;       //FIXME remove, unclear definition
     int mb_width, mb_height;   ///< number of MBs horizontally & vertically
     int mb_stride;             ///< mb_width+1 used for some arrays to allow simple addressing of left & top MBs without sig11
@@ -505,6 +504,8 @@ typedef struct MPVMainContext {
      * a frame size change */
     int context_reinit;
 
+    int coded_picture_number;  ///< used to set pic->coded_picture_number, should not be used for/by anything else
+
     int slice_context_count;   ///< number of used thread_contexts
     /* The first entry of this array points to the above MPVContext. */
     MPVContext *thread_context[MAX_THREADS];
diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
index a4f751af71..48371aa886 100644
--- a/libavcodec/mpegvideo_dec.c
+++ b/libavcodec/mpegvideo_dec.c
@@ -105,7 +105,7 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst,
 
     s->quarter_sample       = s1->quarter_sample;
 
-    s->coded_picture_number = s1->coded_picture_number;
+    m->coded_picture_number = m1->coded_picture_number;
     s->picture_number       = s1->picture_number;
 
     av_assert0(!s->picture || s->picture != s1->picture);
@@ -339,7 +339,7 @@ int ff_mpv_frame_start(MPVMainDecContext *m, AVCodecContext *avctx)
             pic->reference = 3;
     }
 
-    pic->f->coded_picture_number = s->coded_picture_number++;
+    pic->f->coded_picture_number = m->coded_picture_number++;
 
     if (alloc_picture(s, pic) < 0)
         return -1;
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 2fbcfd56e1..3e9f8b4e42 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -1459,7 +1459,7 @@ static int select_input_picture(MPVMainEncContext *m)
             m->reordered_input_picture[0] = m->input_picture[0];
             m->reordered_input_picture[0]->f->pict_type = AV_PICTURE_TYPE_I;
             m->reordered_input_picture[0]->f->coded_picture_number =
-                s->coded_picture_number++;
+                m2->coded_picture_number++;
         } else {
             int b_frames = 0;
 
@@ -1545,13 +1545,13 @@ static int select_input_picture(MPVMainEncContext *m)
             if (m->reordered_input_picture[0]->f->pict_type != AV_PICTURE_TYPE_I)
                 m->reordered_input_picture[0]->f->pict_type = AV_PICTURE_TYPE_P;
             m->reordered_input_picture[0]->f->coded_picture_number =
-                s->coded_picture_number++;
+                m2->coded_picture_number++;
             for (i = 0; i < b_frames; i++) {
                 m->reordered_input_picture[i + 1] = m->input_picture[i];
                 m->reordered_input_picture[i + 1]->f->pict_type =
                     AV_PICTURE_TYPE_B;
                 m->reordered_input_picture[i + 1]->f->coded_picture_number =
-                    s->coded_picture_number++;
+                    m2->coded_picture_number++;
             }
         }
     }
-- 
2.32.0



More information about the ffmpeg-devel mailing list