[FFmpeg-cvslog] avcodec/mpeg4video: Move ff_mpeg4_pred_dc() to decoder

Andreas Rheinhardt git at videolan.org
Sat Jun 21 23:21:32 EEST 2025


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Fri Jun 13 23:15:08 2025 +0200| [689cde75ee6f5aa4d3ba8e3d63ab542f1e2cb1ff] | committer: Andreas Rheinhardt

avcodec/mpeg4video: Move ff_mpeg4_pred_dc() to decoder

Only used by the decoder now that the encoder solves
out-of-slice predictions by setting the out-of-slice
values appropriately.

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

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

 libavcodec/mpeg4video.h    | 44 -------------------------------------------
 libavcodec/mpeg4videodec.c | 47 ++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 45 insertions(+), 46 deletions(-)

diff --git a/libavcodec/mpeg4video.h b/libavcodec/mpeg4video.h
index 059ea025e2..274b21a067 100644
--- a/libavcodec/mpeg4video.h
+++ b/libavcodec/mpeg4video.h
@@ -37,48 +37,4 @@ void ff_mpeg4_init_direct_mv(MpegEncContext *s);
  */
 int ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my);
 
-/**
- * Predict the dc.
- * @param n block index (0-3 are luma, 4-5 are chroma)
- * @param dir_ptr pointer to an integer where the prediction direction will be stored
- */
-static inline int ff_mpeg4_pred_dc(MpegEncContext *s, int n, int *dir_ptr)
-{
-    int a, b, c, wrap, pred;
-    const int16_t *const dc_val = s->dc_val + s->block_index[n];
-
-    /* find prediction */
-
-    wrap   = s->block_wrap[n];
-
-    /* B C
-     * A X
-     */
-    a = dc_val[-1];
-    b = dc_val[-1 - wrap];
-    c = dc_val[-wrap];
-
-    /* outside slice handling (we can't do that by memset as we need the
-     * dc for error resilience) */
-    if (s->first_slice_line && n != 3) {
-        if (n != 2)
-            b = c = 1024;
-        if (n != 1 && s->mb_x == s->resync_mb_x)
-            b = a = 1024;
-    }
-    if (s->mb_x == s->resync_mb_x && s->mb_y == s->resync_mb_y + 1) {
-        if (n == 0 || n == 4 || n == 5)
-            b = 1024;
-    }
-
-    if (abs(a - b) < abs(b - c)) {
-        pred     = c;
-        *dir_ptr = 1; /* top */
-    } else {
-        pred     = a;
-        *dir_ptr = 0; /* left */
-    }
-    return pred;
-}
-
 #endif /* AVCODEC_MPEG4VIDEO_H */
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index 654e8eee3b..522242de40 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -888,6 +888,49 @@ static inline int get_amv(Mpeg4DecContext *ctx, int n)
     return sum;
 }
 
+/**
+ * Predict the dc.
+ * @param n block index (0-3 are luma, 4-5 are chroma)
+ * @param dir_ptr pointer to an integer where the prediction direction will be stored
+ */
+static inline int mpeg4_pred_dc(MpegEncContext *s, int n, int *dir_ptr)
+{
+    const int16_t *const dc_val = s->dc_val + s->block_index[n];
+    const int wrap = s->block_wrap[n];
+    int pred;
+
+    /* find prediction */
+
+    /* B C
+     * A X
+     */
+    int a = dc_val[-1];
+    int b = dc_val[-1 - wrap];
+    int c = dc_val[-wrap];
+
+    /* outside slice handling (we can't do that by memset as we need the
+     * dc for error resilience) */
+    if (s->first_slice_line && n != 3) {
+        if (n != 2)
+            b = c = 1024;
+        if (n != 1 && s->mb_x == s->resync_mb_x)
+            b = a = 1024;
+    }
+    if (s->mb_x == s->resync_mb_x && s->mb_y == s->resync_mb_y + 1) {
+        if (n == 0 || n == 4 || n == 5)
+            b = 1024;
+    }
+
+    if (abs(a - b) < abs(b - c)) {
+        pred     = c;
+        *dir_ptr = 1; /* top */
+    } else {
+        pred     = a;
+        *dir_ptr = 0; /* left */
+    }
+    return pred;
+}
+
 static inline int mpeg4_get_level_dc(MpegEncContext *s, int n, int pred, int level)
 {
     int scale = n < 4 ? s->y_dc_scale : s->c_dc_scale;
@@ -971,7 +1014,7 @@ static inline int mpeg4_decode_dc(MpegEncContext *s, int n, int *dir_ptr)
         }
     }
 
-    pred = ff_mpeg4_pred_dc(s, n, dir_ptr);
+    pred = mpeg4_pred_dc(s, n, dir_ptr);
     return mpeg4_get_level_dc(s, n, pred, level);
 }
 
@@ -1362,7 +1405,7 @@ static inline int mpeg4_decode_block(Mpeg4DecContext *ctx, int16_t *block,
             i        = 0;
         } else {
             i = -1;
-            pred = ff_mpeg4_pred_dc(s, n, &dc_pred_dir);
+            pred = mpeg4_pred_dc(s, n, &dc_pred_dir);
         }
         if (!coded)
             goto not_coded;



More information about the ffmpeg-cvslog mailing list