[FFmpeg-cvslog] avcodec/mpegvideo_dec: Factor debugging dct coefficients out

Andreas Rheinhardt git at videolan.org
Thu Jul 3 21:55:17 EEST 2025


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Sun Jun 15 22:19:15 2025 +0200| [261d8eb5ddf0542f24b6947c913256aea6fe6388] | committer: Andreas Rheinhardt

avcodec/mpegvideo_dec: Factor debugging dct coefficients out

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>

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

 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) {



More information about the ffmpeg-cvslog mailing list