[FFmpeg-cvslog] avcodec/mpeg12dec: Move resetting last_dc to decoder

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


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Wed Jun 19 21:51:21 2024 +0200| [9a46c0160f3c22ba585c6ca139455bfc5c0520ff] | committer: Andreas Rheinhardt

avcodec/mpeg12dec: Move resetting last_dc to decoder

Only the MPEG-1/2, MSMPEG4V1, MPEG-4 and RV.10 decoders use last_dc
at all. Of these, RV.10 only uses it for intra frames; it does not
need these predictors reset in ff_mpv_reconstruct_mb(). MSMPEG4V1
has h263_pred set, so that last_dc is already not reset in
ff_mpv_reconstruct_mb() (instead it is reset at the beginning
of every line). MPEG-4 also has h263_pred set (and uses last_dc only
for the intra-only studio profile and needs them reset to sligthly
different values anyway).

So only the MPEG-1/2 decoders need these values reset. So move
resetting them there. This avoids resetting them unnecessarily
for FLV1, H.261, H.263I, RV.10, RV.20 and H.263(+)
(for the latter it depends upon whether h263_aic is in use).

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

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

 libavcodec/mpeg12dec.c                   | 2 ++
 libavcodec/mpv_reconstruct_mb_template.c | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 0002f016e9..262e213a61 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -713,6 +713,7 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64])
         }
 
         s->mb_intra = 0;
+        s->last_dc[0] = s->last_dc[1] = s->last_dc[2] = 128 << s->intra_dc_precision;
         if (HAS_CBP(mb_type)) {
             s->bdsp.clear_blocks(s->block[0]);
 
@@ -1631,6 +1632,7 @@ static int mpeg_decode_slice(MpegEncContext *s, int mb_y,
                 s->mb_intra = 0;
                 for (i = 0; i < 12; i++)
                     s->block_last_index[i] = -1;
+                s->last_dc[0] = s->last_dc[1] = s->last_dc[2] = 128 << s->intra_dc_precision;
                 if (s->picture_structure == PICT_FRAME)
                     s->mv_type = MV_TYPE_16X16;
                 else
diff --git a/libavcodec/mpv_reconstruct_mb_template.c b/libavcodec/mpv_reconstruct_mb_template.c
index dca982ae0f..4db85afef6 100644
--- a/libavcodec/mpv_reconstruct_mb_template.c
+++ b/libavcodec/mpv_reconstruct_mb_template.c
@@ -66,7 +66,7 @@ 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 {
+        } else if (IS_ENCODER) {
             s->last_dc[0] =
             s->last_dc[1] =
             s->last_dc[2] = 128 << s->intra_dc_precision;



More information about the ffmpeg-cvslog mailing list