From patchwork Sat Jul 23 14:09:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 36916 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp1047703pzb; Sat, 23 Jul 2022 07:12:54 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vzeWyA7jFL1d4CjEV6jOWiCG5ygleynkYzN+G6yPPpKQwK7e85ZP0SquUnuwAoY6Ze53v9 X-Received: by 2002:a05:6402:3705:b0:43a:214b:5f40 with SMTP id ek5-20020a056402370500b0043a214b5f40mr4506317edb.83.1658585574754; Sat, 23 Jul 2022 07:12:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658585574; cv=none; d=google.com; s=arc-20160816; b=fv4/KEPXJTBbMRRjG6/H7EZ4WNFdhbCktOEa741f3yEm/acMZseUmnLLXfn7/+p0s+ CDU+y71zlgNre01vQemnzvdxtXqntB/F1RG5UB98omColeBkbNSJqJuJK7U0uQANpxno YTFPI62HDrutBC+KLeV2WFW1HejBYmc0i+pbfO1gUSvcBccMoz97lhWvEZ77S2A4BYfq yyaPJtF5fbtaMYYoyy7zSOCOn6JUgltX/7zBkTAvU6BbhC6FUMNy4xkyoBE5EFtDtKD4 AnqWlXB2VquaVLLpYQu+1XEO43bCe3AC4poja+L/6SrtCwYOPnh/1EMu8yzAVjIgaaWJ S5ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=wfk+/Ijy6FNnfenEWoonb6jYvuq9dR5pcu2pVgdhCWw=; b=nzhQe/KkWhXHEiK1liEh5+Mre7EZ5/H6/+xTYrRiHIvP7OvhgQLGB14vMuC36dGEN2 Ot5XQy0ZdxplW/ChG8rLs9iewhEOFkzLgmU8c1CwsvbnFZgnaLgPe+mwKBkKHtO/7wW2 KgDDh8XokXVjTnzuwVfdfFBsT690vHCyz3HrLS6O0vQnO4GvjE17Txt/zJUMbov6TSX+ 68PPkBV/0HyybUB2v9m+cAcjqIuqF6oXJRRlEos1GSzQukEgXruePOOKVtpa1+2cJTeZ 98Jn3FpuCMFtfdh3MOer3lf+0Ub2gxO1KM6TR4R+wkf+XSFTbFkvyExtQ3jj7oe1Ov4M ydIg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id h10-20020a0564020e0a00b0043aa5c04926si8068471edh.150.2022.07.23.07.12.54; Sat, 23 Jul 2022 07:12:54 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B198168B8BF; Sat, 23 Jul 2022 17:10:43 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 96E3868B7E6 for ; Sat, 23 Jul 2022 17:10:28 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id F15A324056A for ; Sat, 23 Jul 2022 16:10:27 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id dl7nwS9zu-qo for ; Sat, 23 Jul 2022 16:10:27 +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 mail0.khirnov.net (Postfix) with ESMTPS id C974424068D for ; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id B6E8D3A0592; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 23 Jul 2022 16:09:48 +0200 Message-Id: <20220723140952.31814-23-anton@khirnov.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220723140952.31814-1-anton@khirnov.net> References: <20220723140952.31814-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 23/27] fftools/ffmpeg_opt: reduce indentation in map_auto_subtitle() 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: jmFGCSEunm48 Fix indentation after the previous commit. Also use an early return to save one extra indentation level. --- fftools/ffmpeg_opt.c | 60 +++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index da74b0265a..04f4abb88a 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -2583,36 +2583,38 @@ static void map_auto_audio(OutputFile *of, AVFormatContext *oc, static void map_auto_subtitle(OutputFile *of, AVFormatContext *oc, OptionsContext *o) { - char *subtitle_codec_name = NULL; + char *subtitle_codec_name = NULL; + /* subtitles: pick first */ - MATCH_PER_TYPE_OPT(codec_names, str, subtitle_codec_name, oc, "s"); - if ((avcodec_find_encoder(oc->oformat->subtitle_codec) || subtitle_codec_name)) { - for (int i = 0; i < nb_input_streams; i++) - if (input_streams[i]->st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) { - AVCodecDescriptor const *input_descriptor = - avcodec_descriptor_get(input_streams[i]->st->codecpar->codec_id); - AVCodecDescriptor const *output_descriptor = NULL; - AVCodec const *output_codec = - avcodec_find_encoder(oc->oformat->subtitle_codec); - int input_props = 0, output_props = 0; - if (input_streams[i]->user_set_discard == AVDISCARD_ALL) - continue; - if (output_codec) - output_descriptor = avcodec_descriptor_get(output_codec->id); - if (input_descriptor) - input_props = input_descriptor->props & (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB); - if (output_descriptor) - output_props = output_descriptor->props & (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB); - if (subtitle_codec_name || - input_props & output_props || - // Map dvb teletext which has neither property to any output subtitle encoder - input_descriptor && output_descriptor && - (!input_descriptor->props || - !output_descriptor->props)) { - new_subtitle_stream(o, oc, i); - break; - } - } + MATCH_PER_TYPE_OPT(codec_names, str, subtitle_codec_name, oc, "s"); + if (!avcodec_find_encoder(oc->oformat->subtitle_codec) && !subtitle_codec_name) + return; + + for (int i = 0; i < nb_input_streams; i++) + if (input_streams[i]->st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) { + AVCodecDescriptor const *input_descriptor = + avcodec_descriptor_get(input_streams[i]->st->codecpar->codec_id); + AVCodecDescriptor const *output_descriptor = NULL; + AVCodec const *output_codec = + avcodec_find_encoder(oc->oformat->subtitle_codec); + int input_props = 0, output_props = 0; + if (input_streams[i]->user_set_discard == AVDISCARD_ALL) + continue; + if (output_codec) + output_descriptor = avcodec_descriptor_get(output_codec->id); + if (input_descriptor) + input_props = input_descriptor->props & (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB); + if (output_descriptor) + output_props = output_descriptor->props & (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB); + if (subtitle_codec_name || + input_props & output_props || + // Map dvb teletext which has neither property to any output subtitle encoder + input_descriptor && output_descriptor && + (!input_descriptor->props || + !output_descriptor->props)) { + new_subtitle_stream(o, oc, i); + break; + } } }