From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 29892469E8 for ; Sun, 1 Oct 2023 12:56:24 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3A24468CDC1; Sun, 1 Oct 2023 15:56:14 +0300 (EEST) Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4E06268CCAB for ; Sun, 1 Oct 2023 15:56:07 +0300 (EEST) Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id DC7B0522A for ; Sun, 1 Oct 2023 14:56:06 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id Jeq5mwD_uXse for ; Sun, 1 Oct 2023 14:56:06 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id F0B7F11C for ; Sun, 1 Oct 2023 14:56:01 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id A75DB3A25BE for ; Sun, 1 Oct 2023 14:55:54 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 1 Oct 2023 14:55:47 +0200 Message-Id: <20231001125552.23976-4-anton@khirnov.net> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231001125552.23976-1-anton@khirnov.net> References: <20231001125552.23976-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/9] lavc/mpegvideo_parser: reduce variable scopes X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Drop some variables only used in a switch(). --- libavcodec/mpegvideo_parser.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/libavcodec/mpegvideo_parser.c b/libavcodec/mpegvideo_parser.c index d0b22634bb..76cd2a5131 100644 --- a/libavcodec/mpegvideo_parser.c +++ b/libavcodec/mpegvideo_parser.c @@ -105,22 +105,17 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s, { struct MpvParseContext *pc = s->priv_data; const uint8_t *buf_end = buf + buf_size; - uint32_t start_code; - int frame_rate_index, ext_type, bytes_left; - int frame_rate_ext_n, frame_rate_ext_d; - int top_field_first, repeat_first_field, progressive_frame; - int horiz_size_ext, vert_size_ext, bit_rate_ext; + int bytes_left; int did_set_size=0; int set_dim_ret = 0; int bit_rate = 0; int vbv_delay = 0; - int chroma_format; enum AVPixelFormat pix_fmt = AV_PIX_FMT_NONE; //FIXME replace the crap with get_bits() s->repeat_pict = 0; while (buf < buf_end) { - start_code= -1; + uint32_t start_code = -1; buf= avpriv_find_start_code(buf, buf_end, &start_code); bytes_left = buf_end - buf; switch(start_code) { @@ -134,6 +129,8 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s, break; case SEQ_START_CODE: if (bytes_left >= 7) { + int frame_rate_index; + pc->width = (buf[0] << 4) | (buf[1] >> 4); pc->height = ((buf[1] & 0x0f) << 8) | buf[2]; if(!avctx->width || !avctx->height || !avctx->coded_width || !avctx->coded_height){ @@ -154,20 +151,18 @@ FF_ENABLE_DEPRECATION_WARNINGS break; case EXT_START_CODE: if (bytes_left >= 1) { - ext_type = (buf[0] >> 4); - switch(ext_type) { + switch (buf[0] >> 4) { // ext_type case 0x1: /* sequence extension */ if (bytes_left >= 6) { - horiz_size_ext = ((buf[1] & 1) << 1) | (buf[2] >> 7); - vert_size_ext = (buf[2] >> 5) & 3; - bit_rate_ext = ((buf[2] & 0x1F)<<7) | (buf[3]>>1); - frame_rate_ext_n = (buf[5] >> 5) & 3; - frame_rate_ext_d = (buf[5] & 0x1f); + int horiz_size_ext = ((buf[1] & 1) << 1) | (buf[2] >> 7); + int vert_size_ext = (buf[2] >> 5) & 3; + int bit_rate_ext = ((buf[2] & 0x1F)<<7) | (buf[3]>>1); + int frame_rate_ext_n = (buf[5] >> 5) & 3; + int frame_rate_ext_d = (buf[5] & 0x1f); pc->progressive_sequence = buf[1] & (1 << 3); avctx->has_b_frames= !(buf[5] >> 7); - chroma_format = (buf[1] >> 1) & 3; - switch (chroma_format) { + switch ((buf[1] >> 1) & 3) { // chroma_format case 1: pix_fmt = AV_PIX_FMT_YUV420P; break; case 2: pix_fmt = AV_PIX_FMT_YUV422P; break; case 3: pix_fmt = AV_PIX_FMT_YUV444P; break; @@ -190,9 +185,9 @@ FF_ENABLE_DEPRECATION_WARNINGS break; case 0x8: /* picture coding extension */ if (bytes_left >= 5) { - top_field_first = buf[3] & (1 << 7); - repeat_first_field = buf[3] & (1 << 1); - progressive_frame = buf[4] & (1 << 7); + int top_field_first = buf[3] & (1 << 7); + int repeat_first_field = buf[3] & (1 << 1); + int progressive_frame = buf[4] & (1 << 7); /* check if we must repeat the frame */ if (repeat_first_field) { -- 2.40.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".