[FFmpeg-devel] [PATCH 07/48] avcodec/mpegvideo_dec: Factor debugging dct coefficients out

Andreas Rheinhardt ffmpegagent at gmail.com
Mon Jun 23 16:36:07 EEST 2025


From: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

This allows to hint to the compiler that the branch is likely
not taken by marking the factored out function as av_cold.
It is also in preparation for further commits.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 libavcodec/mpegvideo_dec.c | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
index f8551b93c8..c687f3a972 100644
--- a/libavcodec/mpegvideo_dec.c
+++ b/libavcodec/mpegvideo_dec.c
@@ -1064,6 +1064,19 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t block[12][64],
     }
 }
 
+static av_cold void debug_dct_coeffs(MPVContext *s, const int16_t block[][64])
+{
+       /* print DCT coefficients */
+       av_log(s->avctx, AV_LOG_DEBUG, "DCT coeffs of MB at %dx%d:\n", s->mb_x, s->mb_y);
+       for (int i = 0; i < 6; i++) {
+           for (int j = 0; j < 64; j++) {
+               av_log(s->avctx, AV_LOG_DEBUG, "%5d",
+                      block[i][s->idsp.idct_permutation[j]]);
+           }
+           av_log(s->avctx, AV_LOG_DEBUG, "\n");
+       }
+}
+
 void ff_mpv_reconstruct_mb(MpegEncContext *s, int16_t block[12][64])
 {
     const int mb_xy = s->mb_y * s->mb_stride + s->mb_x;
@@ -1082,17 +1095,8 @@ void ff_mpv_reconstruct_mb(MpegEncContext *s, int16_t block[12][64])
         *mbskip_ptr = 0; /* not skipped */
     }
 
-    if (s->avctx->debug & FF_DEBUG_DCT_COEFF) {
-       /* print DCT coefficients */
-       av_log(s->avctx, AV_LOG_DEBUG, "DCT coeffs of MB at %dx%d:\n", s->mb_x, s->mb_y);
-       for (int i = 0; i < 6; i++) {
-           for (int j = 0; j < 64; j++) {
-               av_log(s->avctx, AV_LOG_DEBUG, "%5d",
-                      block[i][s->idsp.idct_permutation[j]]);
-           }
-           av_log(s->avctx, AV_LOG_DEBUG, "\n");
-       }
-    }
+    if (s->avctx->debug & FF_DEBUG_DCT_COEFF)
+        debug_dct_coeffs(s, block);
 
     av_assert2((s->out_format <= FMT_H261) == (s->out_format == FMT_H261 || s->out_format == FMT_MPEG1));
     if (!s->avctx->lowres) {
-- 
ffmpeg-codebot



More information about the ffmpeg-devel mailing list