[FFmpeg-devel] [PATCH 11/14] avcodec/mjpegenc_common: Don't call function unnecessarily

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Wed Dec 22 05:25:11 EET 2021


Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 libavcodec/mjpegenc_common.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/libavcodec/mjpegenc_common.c b/libavcodec/mjpegenc_common.c
index 70d5fddfd5..ecc21da1b8 100644
--- a/libavcodec/mjpegenc_common.c
+++ b/libavcodec/mjpegenc_common.c
@@ -188,10 +188,6 @@ static void jpeg_put_comments(AVCodecContext *avctx, PutBitContext *p)
 
 void ff_mjpeg_init_hvsample(AVCodecContext *avctx, int hsample[4], int vsample[4])
 {
-    int chroma_h_shift, chroma_v_shift;
-
-    av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &chroma_h_shift,
-                                     &chroma_v_shift);
     if (avctx->codec->id == AV_CODEC_ID_LJPEG &&
         (   avctx->pix_fmt == AV_PIX_FMT_BGR0
          || avctx->pix_fmt == AV_PIX_FMT_BGRA
@@ -204,6 +200,9 @@ void ff_mjpeg_init_hvsample(AVCodecContext *avctx, int hsample[4], int vsample[4
         vsample[0] = vsample[1] = vsample[2] = 2;
         hsample[0] = hsample[1] = hsample[2] = 1;
     } else {
+        int chroma_h_shift, chroma_v_shift;
+        av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &chroma_h_shift,
+                                         &chroma_v_shift);
         vsample[0] = 2;
         vsample[1] = 2 >> chroma_v_shift;
         vsample[2] = 2 >> chroma_v_shift;
-- 
2.32.0



More information about the ffmpeg-devel mailing list