[FFmpeg-cvslog] avcodec/mjpegenc_common: Don't call function unnecessarily

Andreas Rheinhardt git at videolan.org
Tue Jan 4 18:20:36 EET 2022


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Wed Dec 22 03:39:16 2021 +0100| [3867b18120e11174b3d775699ce74339b0b1bc4c] | committer: Andreas Rheinhardt

avcodec/mjpegenc_common: Don't call function unnecessarily

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

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

 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 d75ae6b6a7..27438df5eb 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;



More information about the ffmpeg-cvslog mailing list