[FFmpeg-cvslog] avcodec/mpeg12enc: Move resetting last_dc to encoder

Andreas Rheinhardt git at videolan.org
Sun Feb 23 03:18:44 EET 2025


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Wed Jun 19 22:35:03 2024 +0200| [58f9e497dcd9b180405fbcb59453d86f59e6e09e] | committer: Andreas Rheinhardt

avcodec/mpeg12enc: Move resetting last_dc to encoder

The MPEG-1/2 encoders are the only non-intra-only mpegvideo
encoders that want last_dc reset when encoding non-intra macroblocks.
Therefore move resetting it to mpeg12enc.c.

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

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

 libavcodec/mpeg12enc.c                   | 2 ++
 libavcodec/mpv_reconstruct_mb_template.c | 4 ----
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index e56571da03..720ac287fc 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -1067,6 +1067,8 @@ static av_always_inline void mpeg1_encode_mb_internal(MpegEncContext *s,
 void ff_mpeg1_encode_mb(MpegEncContext *s, int16_t block[8][64],
                         int motion_x, int motion_y)
 {
+    if (!s->mb_intra)
+        s->last_dc[0] = s->last_dc[1] = s->last_dc[2] = 128 << s->intra_dc_precision;
     if (s->chroma_format == CHROMA_420)
         mpeg1_encode_mb_internal(s, block, motion_x, motion_y, 6, 1);
     else
diff --git a/libavcodec/mpv_reconstruct_mb_template.c b/libavcodec/mpv_reconstruct_mb_template.c
index 4db85afef6..f1cb0d7989 100644
--- a/libavcodec/mpv_reconstruct_mb_template.c
+++ b/libavcodec/mpv_reconstruct_mb_template.c
@@ -66,10 +66,6 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t block[12][64],
         if (is_mpeg12 != DEFINITELY_MPEG12_H261 && (s->h263_pred || s->h263_aic)) {
             if (s->mbintra_table[mb_xy])
                 ff_clean_intra_table_entries(s);
-        } else if (IS_ENCODER) {
-            s->last_dc[0] =
-            s->last_dc[1] =
-            s->last_dc[2] = 128 << s->intra_dc_precision;
         }
     } else if (is_mpeg12 != DEFINITELY_MPEG12_H261 && (s->h263_pred || s->h263_aic))
         s->mbintra_table[mb_xy] = 1;



More information about the ffmpeg-cvslog mailing list