diff mbox series

[FFmpeg-devel,3/3] lavc/videotoolbox: fix warnings

Message ID 20230403122518.1132660-3-mypopydev@gmail.com
State Accepted
Commit 639ded10e3599b7dd52a4bd7c06589689d177d08
Headers show
Series [FFmpeg-devel,1/3] lavfi/metal: fix mixing declarations and code warning | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Jun Zhao April 3, 2023, 12:25 p.m. UTC
fix mixing declarations and code warnings

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
---
 libavcodec/videotoolbox.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
index e42fea6f32..6444325591 100644
--- a/libavcodec/videotoolbox.c
+++ b/libavcodec/videotoolbox.c
@@ -799,6 +799,9 @@  static CFDictionaryRef videotoolbox_buffer_attributes_create(int width,
 static CFDictionaryRef videotoolbox_decoder_config_create(CMVideoCodecType codec_type,
                                                           AVCodecContext *avctx)
 {
+    CFMutableDictionaryRef avc_info;
+    CFDataRef data = NULL;
+
     CFMutableDictionaryRef config_info = CFDictionaryCreateMutable(kCFAllocatorDefault,
                                                                    0,
                                                                    &kCFTypeDictionaryKeyCallBacks,
@@ -810,9 +813,6 @@  static CFDictionaryRef videotoolbox_decoder_config_create(CMVideoCodecType codec
                             kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder,
                          kCFBooleanTrue);
 
-    CFMutableDictionaryRef avc_info;
-    CFDataRef data = NULL;
-
     avc_info = CFDictionaryCreateMutable(kCFAllocatorDefault,
                                          1,
                                          &kCFTypeDictionaryKeyCallBacks,
@@ -1072,13 +1072,14 @@  static int videotoolbox_hevc_end_frame(AVCodecContext *avctx)
     HEVCContext *h = avctx->priv_data;
     AVFrame *frame = h->ref->frame;
     VTContext *vtctx = avctx->internal->hwaccel_priv_data;
+    int ret;
 
     h->output_frame->crop_right = 0;
     h->output_frame->crop_left = 0;
     h->output_frame->crop_top = 0;
     h->output_frame->crop_bottom = 0;
 
-    int ret = ff_videotoolbox_common_end_frame(avctx, frame);
+    ret = ff_videotoolbox_common_end_frame(avctx, frame);
     vtctx->bitstream_size = 0;
     return ret;
 }
@@ -1132,15 +1133,17 @@  static int videotoolbox_prores_end_frame(AVCodecContext *avctx)
 }
 
 static enum AVPixelFormat videotoolbox_best_pixel_format(AVCodecContext *avctx) {
+    int depth;
     const AVPixFmtDescriptor *descriptor = av_pix_fmt_desc_get(avctx->sw_pix_fmt);
     if (!descriptor)
         return AV_PIX_FMT_NV12; // same as av_videotoolbox_alloc_context()
 
-    int depth = descriptor->comp[0].depth;
 
     if (descriptor->flags & AV_PIX_FMT_FLAG_ALPHA)
         return AV_PIX_FMT_AYUV64;
 
+    depth = descriptor->comp[0].depth;
+
 #if HAVE_KCVPIXELFORMATTYPE_444YPCBCR16BIPLANARVIDEORANGE
     if (depth > 10)
         return descriptor->log2_chroma_w == 0 ? AV_PIX_FMT_P416 : AV_PIX_FMT_P216;
@@ -1194,6 +1197,7 @@  int ff_videotoolbox_common_init(AVCodecContext *avctx)
     VTContext *vtctx = avctx->internal->hwaccel_priv_data;
     AVHWFramesContext *hw_frames;
     int err;
+    bool full_range;
 
     vtctx->logctx = avctx;
 
@@ -1241,7 +1245,7 @@  int ff_videotoolbox_common_init(AVCodecContext *avctx)
         goto fail;
     }
 
-    bool full_range = avctx->color_range == AVCOL_RANGE_JPEG;
+    full_range = avctx->color_range == AVCOL_RANGE_JPEG;
     vtctx->vt_ctx->cv_pix_fmt_type =
         av_map_videotoolbox_format_from_pixfmt2(hw_frames->sw_format, full_range);
     if (!vtctx->vt_ctx->cv_pix_fmt_type) {