From patchwork Sat Jul 23 14:09:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 36900 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp1046463pzb; Sat, 23 Jul 2022 07:10:32 -0700 (PDT) X-Google-Smtp-Source: AGRyM1veYwGNuHIM/qNcm0WIzOj8vRfqYj1ReutQ2vGAijMvNt4px729GNujHHZ2aX0f7C941mQo X-Received: by 2002:a17:906:cc5a:b0:72b:1459:6faa with SMTP id mm26-20020a170906cc5a00b0072b14596faamr3706833ejb.221.1658585431976; Sat, 23 Jul 2022 07:10:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658585431; cv=none; d=google.com; s=arc-20160816; b=o+5+1mYvBxQcAiPps8+EIrG5Wc3e9A3FXU0CAaO+PI7jtN3TgA78FuATGuJTU6ZxU3 UCSMGKxthX8lku5YRQ0e3QUbTNwQNn7iUsF4hfflZkcT36WhuRSqGmWJfEvTosgjj+xY lszz7fUK38aDTLQj1Apahi9kqTKRItEf0XC31W1f4U8qrSQXKBJ50T+PC4FSbZT4qhVx YgaFCGQZmJa+ytyD4hZ1CJk5Gp0sf6xlPRBIqkOGk6vrK2LKwv01h88vl0WLWky3fPfR GBoHmrA1FyQEcFRNnobD83zCY3ZjNUYe8DqT2zDmAD9SPqGfPhoCQr6ORSKM4c3tD+CW SmjA== 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:message-id:date:to:from :delivered-to; bh=35UeNxSzq5Nq56u7mlv0KFgyL0no5TXOcZIZzke0314=; b=XJFMJ/0adboNJUQPIc1Gp0OBOIfMsSuwoO/p9/K4AUJYTHzbyRrExgxpG2HwVXCAyv jOA+6cZ6Pq4KHq59BdP/l1SQ40tWO4sY+NqPoYOmUoJnZAkdabJPGpSHvqKYiOGg/68t YXuCzKMhhg9S/SKMfrk/fh1jcIFd5eWJ2ZL+Iarkut8msJJwx/cKb5RNQHrimJ2AM0HV jH3Mm+V7PXJg5HZnTOgKklKmTlHPu9ZnuwAe4Iw+Jx6F2Tw6XbMNGFDtJTSDjIebZ7rh Dlilnv3fdB5LEGQS526mWrDHBJZcK3Kj1EBae/CVlRiRvzx7sCp+bacdrrH8wt9vH7e3 i7kA== 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 hb10-20020a170907160a00b0072b394cb930si9201042ejc.784.2022.07.23.07.10.30; Sat, 23 Jul 2022 07:10:31 -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 C035468B743; Sat, 23 Jul 2022 17:10:27 +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 27F1A68B704 for ; Sat, 23 Jul 2022 17:10:21 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 99F4A240691 for ; Sat, 23 Jul 2022 16:10:20 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id ePAhN0afOWBu for ; Sat, 23 Jul 2022 16:10:19 +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 459672400F5 for ; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 51CE43A03A9; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 23 Jul 2022 16:09:26 +0200 Message-Id: <20220723140952.31814-1-anton@khirnov.net> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 01/27] fftools/ffmpeg: replace AVFrame.pkt_duration with duration 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: 1vm5atlggWV4 Mistakenly reintroduced in 4740fea7ddf. --- fftools/ffmpeg.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 632ac25cb2..841dd6f08a 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1216,18 +1216,18 @@ static void do_video_out(OutputFile *of, if (delta0 > 1.1) nb0_frames = llrintf(delta0 - 0.6); } - next_picture->pkt_duration = 1; + next_picture->duration = 1; break; case VSYNC_VFR: if (delta <= -0.6) nb_frames = 0; else if (delta > 0.6) ost->sync_opts = llrint(sync_ipts); - next_picture->pkt_duration = duration; + next_picture->duration = duration; break; case VSYNC_DROP: case VSYNC_PASSTHROUGH: - next_picture->pkt_duration = duration; + next_picture->duration = duration; ost->sync_opts = llrint(sync_ipts); break; default: From patchwork Sat Jul 23 14:09:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 36901 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp1046534pzb; Sat, 23 Jul 2022 07:10:40 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vEueyFyC+PAg8WBN04p5a4sFwlug/+hLHDfe5uU68kESTfkQVyiK9O/GjDriQHoVcCA5YU X-Received: by 2002:aa7:ce02:0:b0:43b:c381:5e19 with SMTP id d2-20020aa7ce02000000b0043bc3815e19mr4499590edv.295.1658585440792; Sat, 23 Jul 2022 07:10:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658585440; cv=none; d=google.com; s=arc-20160816; b=E6g2dcKQtLftvBrKM2sbv1PBFcH38xm88Te8sGVxCn3eYLL6340FYjGmPqcDVeucIx IYKMsLpMdQVSuK7np1BrYbdMXpeP8W7aOtoF2Y2oEWx1fC6yOpjvZjde9hYy3YShT5ft 3KqyQEDmoWq8Qt1JaWNOLA8hU5dMjDt06ql88qOsMc3nVTdemmiipobObbHeYMp157mk /VF+bRC1O1sN3DKPSLVZIjKLvy6DCPJIAMk0c4J3IK6mthKtr2AfUUu+8G4p4R3BQgGi IX8wz9Jg29QDpmZyVGsZyraSxOmB5QAklaZF9qFOAPX40wLR1ZqK7k34s15mg7plrLfm en/w== 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=45QO3C6SA2VkFuOx7DmSHA8hkf9+t6flly8EUtJacHw=; b=O+wdtEAptGS390Hbb0ktoSr85zTnBmFU+C77tVsCEtUY2WTtCHkWrVMSw53C2Po3j7 wNFbz6FmY22uEHDkzJYjtwxN8uLwSn1ON7YQ5Egek/+Cj14utfXq1u+r1R/WOPRzBYXt iAHCC7sycH1D4DPnKl4DWo9v4kNwFi1SUb5KaUhL43KDB9cxhzSFj8isfIywSMBKVQOj 9qV97X7Xk5R3W/qfNPyLZtj0ZvcXyChF3yJx2KXeGnYrLFQg0/nknoByew/JmSls92sF GOYyANTUmkSLHkMMa2EYIfM4wth53udP2VWKDYPybXr/os3+wUOTr9sxRMjXgDC4g3vK XHsA== 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 oz9-20020a1709077d8900b0072abb95e8e4si10291718ejc.598.2022.07.23.07.10.40; Sat, 23 Jul 2022 07:10:40 -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 C125668B7DC; Sat, 23 Jul 2022 17:10:28 +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 B2D1368B704 for ; Sat, 23 Jul 2022 17:10:21 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 36F522400F5 for ; Sat, 23 Jul 2022 16:10:21 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id yPci9xQOYTce for ; Sat, 23 Jul 2022 16:10:20 +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 50011240179 for ; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 544E83A0232; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 23 Jul 2022 16:09:27 +0200 Message-Id: <20220723140952.31814-2-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 02/27] fftools/ffmpeg: stop accessing the encoder context unnecessarily 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: 6siq4tbdc33V The same information is available from AVStream.codecpar. This will allow to stop allocating an encoder unless encoding is actually performed. --- fftools/ffmpeg.c | 15 ++++++++------- fftools/ffmpeg_mux.c | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 841dd6f08a..7c340f4570 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1454,13 +1454,14 @@ static void print_final_stats(int64_t total_size) for (i = 0; i < nb_output_streams; i++) { OutputStream *ost = output_streams[i]; - switch (ost->enc_ctx->codec_type) { + AVCodecParameters *par = ost->st->codecpar; + switch (par->codec_type) { case AVMEDIA_TYPE_VIDEO: video_size += ost->data_size; break; case AVMEDIA_TYPE_AUDIO: audio_size += ost->data_size; break; case AVMEDIA_TYPE_SUBTITLE: subtitle_size += ost->data_size; break; default: other_size += ost->data_size; break; } - extra_size += ost->enc_ctx->extradata_size; + extra_size += par->extradata_size; data_size += ost->data_size; if ( (ost->enc_ctx->flags & (AV_CODEC_FLAG_PASS1 | AV_CODEC_FLAG_PASS2)) != AV_CODEC_FLAG_PASS1) @@ -1526,7 +1527,7 @@ static void print_final_stats(int64_t total_size) for (j = 0; j < of->nb_streams; j++) { OutputStream *ost = output_streams[of->ost_index + j]; - enum AVMediaType type = ost->enc_ctx->codec_type; + enum AVMediaType type = ost->st->codecpar->codec_type; total_size += ost->data_size; total_packets += atomic_load(&ost->packets_written); @@ -1603,12 +1604,12 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti if (!ost->stream_copy) q = ost->quality / (float) FF_QP2LAMBDA; - if (vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) { + if (vid && ost->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { av_bprintf(&buf, "q=%2.1f ", q); av_bprintf(&buf_script, "stream_%d_%d_q=%.1f\n", ost->file_index, ost->index, q); } - if (!vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) { + if (!vid && ost->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { float fps; uint64_t frame_number = atomic_load(&ost->packets_written); @@ -3362,8 +3363,8 @@ static int transcode_init(void) */ for (i = 0; i < nb_output_streams; i++) { if (!output_streams[i]->stream_copy && - (output_streams[i]->enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO || - output_streams[i]->enc_ctx->codec_type == AVMEDIA_TYPE_AUDIO)) + (output_streams[i]->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO || + output_streams[i]->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)) continue; ret = init_output_stream_wrapper(output_streams[i], NULL, 0); diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index df9cb73d0e..7f6da997a4 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -201,7 +201,7 @@ static int write_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt) if (debug_ts) { av_log(NULL, AV_LOG_INFO, "muxer <- type:%s " "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s duration:%s duration_time:%s size:%d\n", - av_get_media_type_string(ost->enc_ctx->codec_type), + av_get_media_type_string(st->codecpar->codec_type), av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &ost->st->time_base), av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &ost->st->time_base), av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, &ost->st->time_base), From patchwork Sat Jul 23 14:09:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 36904 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp1046758pzb; Sat, 23 Jul 2022 07:11:09 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vfwbPB9zlxG/IfX6rNbOHCBhl2HG/ES0naRVCv4nVH9TMJXqdeo03acLsbdv4mECwWOHfQ X-Received: by 2002:a17:907:7f22:b0:72b:94a2:86b8 with SMTP id qf34-20020a1709077f2200b0072b94a286b8mr3738043ejc.236.1658585469754; Sat, 23 Jul 2022 07:11:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658585469; cv=none; d=google.com; s=arc-20160816; b=iBd4siq0VRMK4j8fzNpctD0ziiu1iQreA9IYmSqfdgBIueePay3oJWG8+/FPQ2hqnh zW9oKwyerTu2yRUx/xKKUMVSLXaSE3kW6sA2OWa/qDqpMcd/TIP7++y/X4e4YyzAdoPP pjc/4Ko5eeCLYkgu17ni1wexdbnm0jasDcNvKoiDN/IvPpKLp9bmDXRniBE5lD7+06ls W90+4SfRG2f16t8k9oze7mTfTToHjnSFW5Xm7gXBedo4odpPFkVpI3HkVq43qYo6NabR laDWkVTtjAy+8aQ6UsFjVlCE2uI9btNVPeFsyw+vOMnOnqizpf3EZa+mE9t3y0iQSHwp GdYA== 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=Ilf3BhbsX2fQXtxfQ97Zdw7U++Fq1h/cp2uxlYHDXt0=; b=cLDjKaxZp2Ac9MiF/1tCWyUbajCNYrOcmgGpCZueZF8rmFkgAyLRBSFWQb8TWnpHWI 6RN9jdpJ7P5SuMzimTjZsrlnlWz7SlG8c1fzugap/h6Xr/Mzg7od6mdt3qyfPT9aLjKv qIYdTu17YccgrhAgO9zWCn41xr+aDsYRxchTxgbqrz2KmhLnfFJdLuchQSiVj/8Fo4oq iuhsGGmuk7loEAZZVy12+QDXpAImoJAq7RZe8DiVwfKxmjGSqsQ4kqpG5fVmBGZRsiVM /vuJXRWMmVNboyqF4YEQwMWJn7yVZ+Uj8jwWig8gnY9pbIQCLqrJqvsGhtXaz6KYYnet IFLg== 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 cr20-20020a170906d55400b007269f7adbadsi10155337ejc.670.2022.07.23.07.11.08; Sat, 23 Jul 2022 07:11:09 -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 DAFE568B7B8; Sat, 23 Jul 2022 17:10:31 +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 9904D68B743 for ; Sat, 23 Jul 2022 17:10:22 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 1C65924017C for ; Sat, 23 Jul 2022 16:10:22 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id vBLdAktDrn9O for ; Sat, 23 Jul 2022 16:10:21 +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 67F87240506 for ; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 573CF3A03D8; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 23 Jul 2022 16:09:28 +0200 Message-Id: <20220723140952.31814-3-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 03/27] fftools/ffmpeg: remove an unnecessary avcodec_close() call 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: dUMGDvnVPo0/ No encoders can possibly be opened at this point. And even if some were, they would be closed in ffmpeg_cleanup(). --- fftools/ffmpeg.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 7c340f4570..1cf704ab82 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -3344,13 +3344,8 @@ static int transcode_init(void) /* init input streams */ for (i = 0; i < nb_input_streams; i++) - if ((ret = init_input_stream(i, error, sizeof(error))) < 0) { - for (i = 0; i < nb_output_streams; i++) { - ost = output_streams[i]; - avcodec_close(ost->enc_ctx); - } + if ((ret = init_input_stream(i, error, sizeof(error))) < 0) goto dump_format; - } /* * initialize stream copy and subtitle/data streams. From patchwork Sat Jul 23 14:09:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 36903 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp1046685pzb; Sat, 23 Jul 2022 07:11:00 -0700 (PDT) X-Google-Smtp-Source: AGRyM1txPgGvyj8xSmQMrKE2JzxdAxDIPzNY2DIr9oIU6BwoZi2Vqy403hfE95dheEh38jH2TSwp X-Received: by 2002:a17:907:7ba8:b0:72b:9186:5bff with SMTP id ne40-20020a1709077ba800b0072b91865bffmr3560219ejc.650.1658585460661; Sat, 23 Jul 2022 07:11:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658585460; cv=none; d=google.com; s=arc-20160816; b=KTBmCfLj455pNbmyMwnKcHeS6xgx/ak5fAcxNhamwEtx+Iz+HVwtW13TCore4m2LGi W15GdTIW8V4fKJb9v2AeSCdqrMb2uz6B6PkWjEC6bxa2ZzTwIu9NGdbOXTsUvXeqU44y OBiu41rSla360J+OTVeXnO/NXtNuX1I8Gl0vB+94j1hSa6CaoRm27Njl28JO48Os++KA eR17ljWjKuoy4Zxh80ejwanS9TDrRYQuw0d+S/kDzDPVIqhNxqvZC94dVU1QZUNka6Ou bLlW5i2i52nWNGkSnShh0sou0AT6Ym/scg8clYRozhMUAn570VNDHqZv8JHI/gWpHMjA 4N7w== 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=rR3Ua6XeS3YKO4+nXTwcllLeichEW+Xp5Ky14jzNVmo=; b=GOxLLvdY8G3yNPDtL1htFoLIJ0GUAKN1FfvXG2JPittgTSCKyA9yoTsKfFTrdnebRg K8v/IcTmySQaupTPtzdNCCO5TWsEaoe95S52isnmp4lAvH+/2MLQW23xp3v5LxExvVH+ GDER8dT7mvEZmwX4TtqGxEoKB2SKhEDUFYdbKJ9gQ08egayQUPhzUIrZm0thapZ3CPz7 dmn9cRoX/WBFk9Sx5xsw7sMv3otfK30+/gfwBwdsbw2smj7ELus0BAH5rxz37Eue5fzY O8qACgsfnJc5zsLpHou4QuF3e8XuRkpcH/+JCq8+8pcT3mF6mhJBYyqipaUbFgFuPTr3 7ZOQ== 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 kl7-20020a170907994700b0072643608fb8si8319125ejc.953.2022.07.23.07.10.59; Sat, 23 Jul 2022 07:11:00 -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 DFA6868B7D4; Sat, 23 Jul 2022 17:10:30 +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 56EBA68B1F1 for ; Sat, 23 Jul 2022 17:10:22 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id D055C24017E for ; Sat, 23 Jul 2022 16:10:21 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id O33wyUOq8Dd6 for ; Sat, 23 Jul 2022 16:10:19 +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 5BC7024017C for ; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 5EEA63A03EE; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 23 Jul 2022 16:09:29 +0200 Message-Id: <20220723140952.31814-4-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 04/27] fftools/ffmpeg_filter: remove unused function argument 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: 855M/ApGACsF --- fftools/ffmpeg_filter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 122b17686a..f16f4b13b1 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -52,7 +52,7 @@ static const enum AVPixelFormat *get_compliance_normal_pix_fmts(const AVCodec *c } } -static enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodecContext *enc_ctx, +static enum AVPixelFormat choose_pixel_fmt(AVCodecContext *enc_ctx, const AVCodec *codec, enum AVPixelFormat target) { if (codec && codec->pix_fmts) { @@ -102,7 +102,7 @@ static const char *choose_pix_fmts(OutputFilter *ofilter, AVBPrint *bprint) return av_get_pix_fmt_name(ost->enc_ctx->pix_fmt); } if (ost->enc_ctx->pix_fmt != AV_PIX_FMT_NONE) { - return av_get_pix_fmt_name(choose_pixel_fmt(ost->st, ost->enc_ctx, ost->enc, ost->enc_ctx->pix_fmt)); + return av_get_pix_fmt_name(choose_pixel_fmt(ost->enc_ctx, ost->enc, ost->enc_ctx->pix_fmt)); } else if (ost->enc && ost->enc->pix_fmts) { const enum AVPixelFormat *p; From patchwork Sat Jul 23 14:09:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 36902 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp1046607pzb; Sat, 23 Jul 2022 07:10:50 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uoUpAt9fBl0UIKEG2z37zQBGab/Gvy/ZPe0vgqA/qFvso7Bm58PJPsJZsPOhoLFeBcMGbw X-Received: by 2002:a17:907:e91:b0:72f:d76:b22c with SMTP id ho17-20020a1709070e9100b0072f0d76b22cmr3495011ejc.364.1658585450124; Sat, 23 Jul 2022 07:10:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658585450; cv=none; d=google.com; s=arc-20160816; b=KWDMZ8va7NbGsTcKZTVyYBNwNd6GE83W0o3eiFFavnrJxa8F6BQY4yFrQRXTyrUU3t 5mWxblasO2SwKs1kCuj1tfaWH98QfHQ0ILn/H5xg2pERV7upfzY5icqUbKvH83IndZFj aHh1+MBiN3SnBEiLTNs2AzJ722ARmOxfPqCS3TF5OnNJkdzaYtatWngw8l8uxjmvYJ5L gxTAV8TN1X+N+ysj70Wlt/mEQB2tMxrae5D9QyUbhzFQUv9RYc58ynXU5LvJ/Kc+spyJ 2Ih9VK3Tb0lAHFUr5aXHEfaRTwCytOCHFM7Q/15hzJbSpQnbhEu3NALuXmxGqfHuoUyr VCGA== 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=mVaiVa1ZGRaMicwczujfpXxb3Zaw1DxoLbprIzSi/8Y=; b=uOrd3TMaQgaRDy4MFHS2zS4TYNnpS4oWrB5i3dkLsxzBNwuw+gvFJQsnBcbiOV+37c EM3mDZ2i5BOFfbCroBoJdpAIxodyIYPifDfF1/a1gTpLmjhT/gZrUThO1UsulCtQXOog IWEt94Hypv13J+g5UwB7x9RdqCza7idwyxSoxRl6gqPC9kHQQjZJWEjQoD1wnQ/A63cu QCFj570PcQAfwsshpO2T7nfgsV8uqeRJ8r84m7/r8sfBRJTRb3PgCeDAczdAF1l+bpxY +ayb4vfx9A/P6r9ZsQ/96qOYXWpvkQXsw18xI/7XaN/Cco1lSP5UOytFWGdq/3WitR1s ARsg== 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 y13-20020a056402270d00b0043bb67ba75fsi9668094edd.489.2022.07.23.07.10.49; Sat, 23 Jul 2022 07:10:50 -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 C958168B1F1; Sat, 23 Jul 2022 17:10:29 +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 25FFC68B704 for ; Sat, 23 Jul 2022 17:10:22 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 9DC2F240179 for ; Sat, 23 Jul 2022 16:10:21 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id VGV5-QJ5OhIP for ; Sat, 23 Jul 2022 16:10:21 +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 63A8624017E for ; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 637443A03EF; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 23 Jul 2022 16:09:30 +0200 Message-Id: <20220723140952.31814-5-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 05/27] fftools/ffmpeg_filter: do not pass the entire AVCodecContext to choose_pixel_fmt() 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: xQRkklSQ99iX It only uses strict_std_compliance, so pass just that value. Makes it more clear what fields are accessed. --- fftools/ffmpeg_filter.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index f16f4b13b1..f715ecb6b6 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -52,8 +52,9 @@ static const enum AVPixelFormat *get_compliance_normal_pix_fmts(const AVCodec *c } } -static enum AVPixelFormat choose_pixel_fmt(AVCodecContext *enc_ctx, - const AVCodec *codec, enum AVPixelFormat target) +static enum AVPixelFormat +choose_pixel_fmt(const AVCodec *codec, enum AVPixelFormat target, + int strict_std_compliance) { if (codec && codec->pix_fmts) { const enum AVPixelFormat *p = codec->pix_fmts; @@ -62,7 +63,7 @@ static enum AVPixelFormat choose_pixel_fmt(AVCodecContext *enc_ctx, int has_alpha = desc ? desc->nb_components % 2 == 0 : 0; enum AVPixelFormat best= AV_PIX_FMT_NONE; - if (enc_ctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) { + if (strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) { p = get_compliance_normal_pix_fmts(codec, p); } for (; *p != AV_PIX_FMT_NONE; p++) { @@ -102,7 +103,8 @@ static const char *choose_pix_fmts(OutputFilter *ofilter, AVBPrint *bprint) return av_get_pix_fmt_name(ost->enc_ctx->pix_fmt); } if (ost->enc_ctx->pix_fmt != AV_PIX_FMT_NONE) { - return av_get_pix_fmt_name(choose_pixel_fmt(ost->enc_ctx, ost->enc, ost->enc_ctx->pix_fmt)); + return av_get_pix_fmt_name(choose_pixel_fmt(ost->enc, ost->enc_ctx->pix_fmt, + ost->enc_ctx->strict_std_compliance)); } else if (ost->enc && ost->enc->pix_fmts) { const enum AVPixelFormat *p; From patchwork Sat Jul 23 14:09:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 36921 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp1048099pzb; Sat, 23 Jul 2022 07:13:39 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ut1pjit/rLcGzpSeOjjjAoBj1OlVljfai8ofs6oY4qYGsw5yLzSRg3ktZ5VaoomyhrrzHk X-Received: by 2002:a05:6402:46:b0:43a:f611:5992 with SMTP id f6-20020a056402004600b0043af6115992mr4716253edu.18.1658585618847; Sat, 23 Jul 2022 07:13:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658585618; cv=none; d=google.com; s=arc-20160816; b=T/H5mrUB7fY98k+vHEiaD+Sgiy4QAtQsj2ks5N7tWOdldFmfCE21+QWJDgrmlbUz6l ZG2cIJCeF8aAkjff/rA84rsZL6g7OHPilvn0Ahi++TEWWQaDE8IfDKQgkFizPXJ5cmun 0XxYpV7WyTy/hLDCFf+C85cu+8gYhHBB4RBAaB4Mau4G8AnSrB12r0NoGqSLyRvhhZzp jougSSBOPxbktL3UfbLCdOt0bklTxZ1qQ+5zHqsgBf/gU3Pk833DTTl6zyusyLBxqzXY MBSxsFsN3IrcJU8Oc1aONrqBxApfJ+1YXpAbOUqD6Y77vVmBLFCsxomC1pP8xKUJL+Z3 ZKew== 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=Fur+Dy1+f5O+lI/CMpuk//7wxyvzywruT6JkmkvFY3s=; b=ZZkSNp52n34kIBhqx+nKxzKBfWMzHNFeZgN5ByOqT571/uN+gXbz9dXD2GKNiQcjAy hyrxxwu8zGQZQrBsbpt9gTk8WITAJHwMdsubUTzZx3qNmDe3/woBe0jMoQyFzC6XlZPj eGAs4GsNMqZvYCaaUx/e1XiSEG42KjKQormn4JNCi3MD/eBUUhA4QbY6SkW/zpOW5X2F fScy5Wi/q+TfOvvyDxanuSd0HZjEiMzNuZjZNPxlY2+sC1yd/Ihcw3/EgeNhkCraLmux dOWjova142pjjrdZr0617WnXY1olhQGNurluvi5uxbe1z8JQQRLnpZvn2OxWaDZoHeqY o5MA== 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 gt15-20020a1709072d8f00b00722e66b9403si10276258ejc.603.2022.07.23.07.13.38; Sat, 23 Jul 2022 07:13:38 -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 9EAC568B8E5; Sat, 23 Jul 2022 17:10:47 +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 EA1D768B7F3 for ; Sat, 23 Jul 2022 17:10:26 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id B864C240511 for ; Sat, 23 Jul 2022 16:10:22 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id Cw_oEeWodGWL for ; Sat, 23 Jul 2022 16:10:22 +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 667E92404FE for ; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 681AF3A03FD; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 23 Jul 2022 16:09:31 +0200 Message-Id: <20220723140952.31814-6-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 06/27] fftools/ffmpeg: drop the -vol option 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: 5jbNyq6Jyw+I It has been deprecated in favor of the volume filter since 2012. --- fftools/ffmpeg.c | 4 ---- fftools/ffmpeg_filter.c | 10 ---------- fftools/ffmpeg_opt.c | 3 --- 3 files changed, 17 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 1cf704ab82..1780e535ae 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2840,10 +2840,6 @@ static int init_output_stream_streamcopy(OutputStream *ost) switch (par_dst->codec_type) { case AVMEDIA_TYPE_AUDIO: - if (audio_volume != 256) { - av_log(NULL, AV_LOG_FATAL, "-acodec copy and -vol are incompatible (frames are not decoded)\n"); - exit_program(1); - } if((par_dst->block_align == 1 || par_dst->block_align == 1152 || par_dst->block_align == 576) && par_dst->codec_id == AV_CODEC_ID_MP3) par_dst->block_align= 0; if(par_dst->codec_id == AV_CODEC_ID_AC3) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index f715ecb6b6..6807bf384a 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -913,16 +913,6 @@ static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter, // av_bprint_finalize(&pan_buf, NULL); // } - if (audio_volume != 256) { - char args[256]; - - av_log(NULL, AV_LOG_WARNING, "-vol has been deprecated. Use the volume " - "audio filter instead.\n"); - - snprintf(args, sizeof(args), "%f", audio_volume / 256.); - AUTO_INSERT_FILTER_INPUT("-vol", "volume", args); - } - snprintf(name, sizeof(name), "trim for input stream %d:%d", ist->file_index, ist->st->index); if (copy_ts) { diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 8ac73c0efc..81754f7d91 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -157,7 +157,6 @@ float audio_drift_threshold = 0.1; float dts_delta_threshold = 10; float dts_error_threshold = 3600*30; -int audio_volume = 256; int audio_sync_method = 0; enum VideoSyncMethod video_sync_method = VSYNC_AUTO; float frame_drop_threshold = 0; @@ -4029,8 +4028,6 @@ const OptionDef options[] = { { "atag", OPT_AUDIO | HAS_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_old2new }, "force audio tag/fourcc", "fourcc/tag" }, - { "vol", OPT_AUDIO | HAS_ARG | OPT_INT, { &audio_volume }, - "change audio volume (256=normal)" , "volume" }, { "sample_fmt", OPT_AUDIO | HAS_ARG | OPT_EXPERT | OPT_SPEC | OPT_STRING | OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(sample_fmts) }, "set sample format", "format" }, From patchwork Sat Jul 23 14:09:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 36932 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a9d:f07:0:b0:61c:acf1:bf6b with SMTP id 7csp644810ott; Sat, 23 Jul 2022 07:14:13 -0700 (PDT) X-Google-Smtp-Source: AGRyM1srfTpIBbgmd5DeVBCfNsYEiQwc+0OdtBCGrUUVfUtvK+si4h4v0kYPO/uOL2413VlV1ma1 X-Received: by 2002:a05:6402:3282:b0:43b:e650:4352 with SMTP id f2-20020a056402328200b0043be6504352mr159880eda.376.1658585653372; Sat, 23 Jul 2022 07:14:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658585653; cv=none; d=google.com; s=arc-20160816; b=feiK/hCgGX4SfxogGA8fPvn89FT8s8G3ged+wHHnw3m0DJiK9DGVrWgAiTt92HuIBW jgveZYA3JkPS7hkDRhCXfpzotk/LDhPKrIsR++ZD8qI3UJQb+FqfWASHonj0yqYWBfKj SoK+UK7aZYg0CXr67fZ419gkj2BXp87rtpEQdi4yiZUf75T5hcqhFe3W0LWRh74eq6yO OXRr1Uj+Y3FU+T10pRyrQrCgcKCRzPTkNu3qWdagGXwdBD+d41JBXhjV8C71FO4wRbvo D+70ACwZGlYQIthVptFIuNXbzFUu+aQNsigD3IMA2DLUJ3XRRX/guPHP9IBOXvC1MC4o HiJA== 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=UDZiskUzNUnLR6nvW77zkb7KQCVn33F/KmPuCCL7oIc=; b=mtei2K8m4SujEVmEf/p6RuCrO16gGbcmVS7bmlwe0igEsHPw6cIPF4smRqgO5GhJHS vsSIPvcwVwiBaO5q1mSoYq8rbBMFIyvMEn4dxQc2FyujqHyK3w2v3YWzOf5P7Lv2Ae+T FXisn8gGv8snthJuW95CdPUn0qeVBY117ET9CK9FTVwubQIEV1OMDek16yjrPF8vRuLN ev5qxSPNcO5lsv8X/UjnvYopZ8KQgl8LLUVWYLize/mvHKO1QX0ddwnslpV7zeQBE0oG aOnYDPftB0yGzGLG2t+YjjF1CXZ5XNiQVTfbpwERNppMwHZjAX4WnK0UZrYMneItA0Fy Coiw== 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 e18-20020a17090658d200b0072f1dffedcfsi11216971ejs.588.2022.07.23.07.14.10; Sat, 23 Jul 2022 07:14:13 -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 49ED468B900; Sat, 23 Jul 2022 17:10:51 +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 8EC8168B7C9 for ; Sat, 23 Jul 2022 17:10:27 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 08C51240512 for ; Sat, 23 Jul 2022 16:10:24 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id ok0-NzkEl_g0 for ; Sat, 23 Jul 2022 16:10:23 +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 9A39024055A for ; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 6CC1C3A0404; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 23 Jul 2022 16:09:32 +0200 Message-Id: <20220723140952.31814-7-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 07/27] fftools/ffmpeg: drop OutputStream.ref_par 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: Qyi23h2ygXrF Content-Length: 5525 It serves no purpose, codec parameters can be written directly to AVStream.codecpar with the same effect. --- fftools/ffmpeg.c | 37 ++++++++++++++++--------------------- fftools/ffmpeg.h | 1 - fftools/ffmpeg_opt.c | 6 ------ 3 files changed, 16 insertions(+), 28 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 1780e535ae..cad9f1e885 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -587,7 +587,6 @@ static void ffmpeg_cleanup(int ret) if (ost->enc_ctx) av_freep(&ost->enc_ctx->stats_in); avcodec_free_context(&ost->enc_ctx); - avcodec_parameters_free(&ost->ref_par); av_freep(&output_streams[i]); } @@ -2757,11 +2756,10 @@ static int init_output_stream_streamcopy(OutputStream *ost) { OutputFile *of = output_files[ost->file_index]; InputStream *ist = get_input_stream(ost); - AVCodecParameters *par_dst = ost->st->codecpar; - AVCodecParameters *par_src = ost->ref_par; + AVCodecParameters *par = ost->st->codecpar; AVRational sar; int i, ret; - uint32_t codec_tag = par_dst->codec_tag; + uint32_t codec_tag = par->codec_tag; av_assert0(ist && !ost->filter); @@ -2774,7 +2772,7 @@ static int init_output_stream_streamcopy(OutputStream *ost) return ret; } - ret = avcodec_parameters_from_context(par_src, ost->enc_ctx); + ret = avcodec_parameters_from_context(par, ost->enc_ctx); if (ret < 0) { av_log(NULL, AV_LOG_FATAL, "Error getting reference codec parameters.\n"); @@ -2784,16 +2782,12 @@ static int init_output_stream_streamcopy(OutputStream *ost) if (!codec_tag) { unsigned int codec_tag_tmp; if (!of->format->codec_tag || - av_codec_get_id (of->format->codec_tag, par_src->codec_tag) == par_src->codec_id || - !av_codec_get_tag2(of->format->codec_tag, par_src->codec_id, &codec_tag_tmp)) - codec_tag = par_src->codec_tag; + av_codec_get_id (of->format->codec_tag, par->codec_tag) == par->codec_id || + !av_codec_get_tag2(of->format->codec_tag, par->codec_id, &codec_tag_tmp)) + codec_tag = par->codec_tag; } - ret = avcodec_parameters_copy(par_dst, par_src); - if (ret < 0) - return ret; - - par_dst->codec_tag = codec_tag; + par->codec_tag = codec_tag; if (!ost->frame_rate.num) ost->frame_rate = ist->framerate; @@ -2838,26 +2832,27 @@ static int init_output_stream_streamcopy(OutputStream *ost) av_display_rotation_set((int32_t *)sd, -ost->rotate_override_value); } - switch (par_dst->codec_type) { + switch (par->codec_type) { case AVMEDIA_TYPE_AUDIO: - if((par_dst->block_align == 1 || par_dst->block_align == 1152 || par_dst->block_align == 576) && par_dst->codec_id == AV_CODEC_ID_MP3) - par_dst->block_align= 0; - if(par_dst->codec_id == AV_CODEC_ID_AC3) - par_dst->block_align= 0; + if ((par->block_align == 1 || par->block_align == 1152 || par->block_align == 576) && + par->codec_id == AV_CODEC_ID_MP3) + par->block_align = 0; + if (par->codec_id == AV_CODEC_ID_AC3) + par->block_align = 0; break; case AVMEDIA_TYPE_VIDEO: if (ost->frame_aspect_ratio.num) { // overridden by the -aspect cli option sar = av_mul_q(ost->frame_aspect_ratio, - (AVRational){ par_dst->height, par_dst->width }); + (AVRational){ par->height, par->width }); av_log(NULL, AV_LOG_WARNING, "Overriding aspect ratio " "with stream copy may produce invalid files\n"); } else if (ist->st->sample_aspect_ratio.num) sar = ist->st->sample_aspect_ratio; else - sar = par_src->sample_aspect_ratio; - ost->st->sample_aspect_ratio = par_dst->sample_aspect_ratio = sar; + sar = par->sample_aspect_ratio; + ost->st->sample_aspect_ratio = par->sample_aspect_ratio = sar; ost->st->avg_frame_rate = ist->st->avg_frame_rate; ost->st->r_frame_rate = ist->st->r_frame_rate; break; diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 0c9498c23e..59c2f47a66 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -481,7 +481,6 @@ typedef struct OutputStream { AVBSFContext *bsf_ctx; AVCodecContext *enc_ctx; - AVCodecParameters *ref_par; /* associated input codec parameters with encoders options applied */ const AVCodec *enc; int64_t max_frames; AVFrame *filtered_frame; diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 81754f7d91..32e0d9a7ff 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -1573,12 +1573,6 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e } ost->enc_ctx->codec_type = type; - ost->ref_par = avcodec_parameters_alloc(); - if (!ost->ref_par) { - av_log(NULL, AV_LOG_ERROR, "Error allocating the encoding parameters.\n"); - exit_program(1); - } - ost->filtered_frame = av_frame_alloc(); if (!ost->filtered_frame) exit_program(1); From patchwork Sat Jul 23 14:09:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 36919 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp1047943pzb; Sat, 23 Jul 2022 07:13:21 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t4l6VYH4iYwWBW5UH0yvzPQOZGw3ri8sT+AldsDOV+tsnYOQ6Xo2vW1tbwgH98WxAJn/sA X-Received: by 2002:a05:6402:4507:b0:43b:b8df:571d with SMTP id ez7-20020a056402450700b0043bb8df571dmr4585553edb.230.1658585601486; Sat, 23 Jul 2022 07:13:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658585601; cv=none; d=google.com; s=arc-20160816; b=EtfrpZ1ZW1/kdlDfIAbsfwrsPJcpM9JIPJdxKHqVHZdai8VGYw6jNL5oU/ocVXmYrn AIURMXQ9l6FNz7ScrhP9PDdYqN73jRG0etzIcNsjxzfdGgkFW179RcfHsZppXuxp5EMy PaQXb8wSdSdlddPmwY0PjhWNsb3bVfgrY4+sUBXob570ZOMJMVruy5iAWx5x/EsGXKRd 4p2f5C14oCyww2USZpn8EDlJz0Z+qe03ka1B1k9bhtX5LrW7DGZQm5whhT8fLWsqZvsv ZapT8m1ImzqkQ47+wjeTZRJa5paUENYjr94shTB0l+w3IiVTmiRDWdqMhXf4xZZJSsHq f8Sg== 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=q8Ns7lh2ML8m4m2mcZNcEmHTbOn2085rKpYlgNbEu+Y=; b=Wd9f5RgNNg3vPIkf9RA/7LMr4vqrbIdHmAtLibOK3JU2hGGqesFToEQ+ewtSKGBMR/ 62Z+PtdrmPBpXcJueQFQYDGIFZHAFjjl8pqdPSNfuUpDyieZlSP8HhJE3TOw0b51zLjx Pp97LDW1ViFwTpmd4cl0cIHb8Ilask+9CtvuyhlLi6za5nQqD9eIUbp0dwAbjydWIyoB lZV0iGmzc8ENWRABfTJM/wYwoesAKnpujP+GX90ZT/SwevLEae2MD35V68zmaaY0ziWX 80N3GCaPxMubBHFIQGP6emqwKX02vLNDEE4UsOCg4Hxb7rNUE0ZmBA3kPPO0BxVnoj2P wr9w== 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 g6-20020a1709065d0600b00704dc5420adsi10121631ejt.38.2022.07.23.07.13.21; Sat, 23 Jul 2022 07:13:21 -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 D836F68B8D6; Sat, 23 Jul 2022 17:10:45 +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 60C4968B777 for ; Sat, 23 Jul 2022 17:10:26 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 405A9240506 for ; Sat, 23 Jul 2022 16:10:22 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id NoTGCU8Ex65A for ; Sat, 23 Jul 2022 16:10:21 +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 73805240507 for ; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 7157C3A0449; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 23 Jul 2022 16:09:33 +0200 Message-Id: <20220723140952.31814-8-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 08/27] fftools/ffmpeg: do not use the encoder context for streamcopy 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: nZ9ejLc2/gJf The streamcopy initialization code briefly needs an AVCodecContext to apply AVOptions to. Allocate a temporary codec context, do not use the encoding one. --- fftools/ffmpeg.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index cad9f1e885..0e30f8ce01 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2757,22 +2757,29 @@ static int init_output_stream_streamcopy(OutputStream *ost) OutputFile *of = output_files[ost->file_index]; InputStream *ist = get_input_stream(ost); AVCodecParameters *par = ost->st->codecpar; + AVCodecContext *codec_ctx; AVRational sar; int i, ret; uint32_t codec_tag = par->codec_tag; av_assert0(ist && !ost->filter); - ret = avcodec_parameters_to_context(ost->enc_ctx, ist->st->codecpar); + codec_ctx = avcodec_alloc_context3(NULL); + if (!codec_ctx) + return AVERROR(ENOMEM); + + ret = avcodec_parameters_to_context(codec_ctx, ist->st->codecpar); if (ret >= 0) - ret = av_opt_set_dict(ost->enc_ctx, &ost->encoder_opts); + ret = av_opt_set_dict(codec_ctx, &ost->encoder_opts); if (ret < 0) { av_log(NULL, AV_LOG_FATAL, "Error setting up codec context options.\n"); + avcodec_free_context(&codec_ctx); return ret; } - ret = avcodec_parameters_from_context(par, ost->enc_ctx); + ret = avcodec_parameters_from_context(par, codec_ctx); + avcodec_free_context(&codec_ctx); if (ret < 0) { av_log(NULL, AV_LOG_FATAL, "Error getting reference codec parameters.\n"); From patchwork Sat Jul 23 14:09:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 36915 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp1047632pzb; Sat, 23 Jul 2022 07:12:46 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s0mMLrWjsZ0tQO13mHri2da1MSfZvI1g/9WG7HZyA50hVaAWtvrkSd+Shjr8ry/KbjZXRl X-Received: by 2002:a05:6402:28a1:b0:43b:a0d5:d30a with SMTP id eg33-20020a05640228a100b0043ba0d5d30amr4562770edb.278.1658585566369; Sat, 23 Jul 2022 07:12:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658585566; cv=none; d=google.com; s=arc-20160816; b=uWhPVOX2gOVyTC4X6v01pVRrZeHUCrRV9h3F9j5xCR+WO4WPShYScdDBMck5FS+sJE CqK2H2srUSSjBmD8JTxcFNrUwqGaK6MuvAG2N1Ra2wZojLIhODXARvZSwxpQnjLZMfx9 oSr8qr5dVlMc2CCRkC9dwFNiEUrVW1SjY4Ysr3d3wNZomDQ7xzcex1WeexSkx0SmJZx2 FnKNg3F1IWANL++O1fLCgvC5mACowyjyJVsiVAv0SwcK++UEoqAFKpdetIP94qF+SQaa kCTCzthkqQpyM3eCToJHqcv/A6bvOHbXY/l021R2KRIU9w/DLchlz3ZBiClRZnbkTTvs Bz5w== 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=BRhLEwReSzKIHZxNhqDRPMcO116lEq0tUtKeOmiWhWQ=; b=gvH8H5t/yEHNoxeL97AonQTZygK1DYfNoMMzl25Vwj4B316Goxy5H6Ht37gWkapPDX oBvIrz9pDlUo6NEdbxewVwhBItSBX150DCBl26t8xpMYKPYhML6b99rLW8biXPKEMnfF uuZM3AMde8IEv8C2TxPDR2cLNbY7KmPjrrqbQ+lt/JtMjnZkIYcSVMK2RDllr5EHvWZD SsjE1ugMi2jD/j2yyG0Qx0sYjzwU9UnLnuypYXZ/j+MYu6m6QM3i7ZjSOotpb6Ghb0MO OHL+wn/rJ+qMwWunNPvbK1fZowH7VLhrtfNM6DMnxaI4hhnvyiHdjTgv6ZS37KaIyLvK ovmQ== 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 w9-20020a056402070900b0043a67b8dc66si7451879edx.267.2022.07.23.07.12.46; Sat, 23 Jul 2022 07:12:46 -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 068A068B8B7; 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 91B5068B7DF for ; Sat, 23 Jul 2022 17:10:28 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 8C67F24017C 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 rxnXSZ03OdPe 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 BEC6B240685 for ; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 75F773A0451; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 23 Jul 2022 16:09:34 +0200 Message-Id: <20220723140952.31814-9-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 09/27] fftools/ffmpeg: deprecate -psnr 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: vShESs0YEi1V It is entirely redundant with -flags +psnr. --- doc/ffmpeg.texi | 3 ++- fftools/ffmpeg.h | 3 +++ fftools/ffmpeg_opt.c | 12 ++++++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 0e657b0138..974d1c108f 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -992,7 +992,8 @@ to keep the interlaced format for minimum losses. The alternative is to deinterlace the input stream by use of a filter such as @code{yadif} or @code{bwdif}, but deinterlacing introduces losses. @item -psnr -Calculate PSNR of compressed frames. +Calculate PSNR of compressed frames. This option is deprecated, pass the +PSNR flag to the encoder instead, using @code{-flags +psnr}. @item -vstats Dump video coding statistics to @file{vstats_HHMMSS.log}. @item -vstats_file @var{file} diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 59c2f47a66..0795a380f8 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -49,6 +49,9 @@ #include "libswresample/swresample.h" +// deprecated features +#define FFMPEG_OPT_PSNR 1 + enum VideoSyncMethod { VSYNC_AUTO = -1, VSYNC_PASSTHROUGH, diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 32e0d9a7ff..716b53d81f 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -183,7 +183,9 @@ int64_t stats_period = 500000; static int file_overwrite = 0; static int no_file_overwrite = 0; +#if FFMPEG_OPT_PSNR static int do_psnr = 0; +#endif static int input_stream_potentially_available = 0; static int ignore_unknown_streams = 0; static int copy_unknown_streams = 0; @@ -1926,8 +1928,12 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in } video_enc->rc_override_count = i; - if (do_psnr) +#if FFMPEG_OPT_PSNR + if (do_psnr) { + av_log(NULL, AV_LOG_WARNING, "The -psnr option is deprecated, use -flags +psnr\n"); video_enc->flags|= AV_CODEC_FLAG_PSNR; + } +#endif /* two pass mode */ MATCH_PER_STREAM_OPT(pass, i, do_pass, oc, st); @@ -3942,8 +3948,10 @@ const OptionDef options[] = { { "passlogfile", OPT_VIDEO | HAS_ARG | OPT_STRING | OPT_EXPERT | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(passlogfiles) }, "select two pass log file name prefix", "prefix" }, +#if FFMPEG_OPT_PSNR { "psnr", OPT_VIDEO | OPT_BOOL | OPT_EXPERT, { &do_psnr }, - "calculate PSNR of compressed frames" }, + "calculate PSNR of compressed frames (deprecated, use -flags +psnr)" }, +#endif { "vstats", OPT_VIDEO | OPT_EXPERT , { .func_arg = opt_vstats }, "dump video coding statistics to file" }, { "vstats_file", OPT_VIDEO | HAS_ARG | OPT_EXPERT , { .func_arg = opt_vstats_file }, From patchwork Sat Jul 23 14:09:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 36934 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a9d:f07:0:b0:61c:acf1:bf6b with SMTP id 7csp644533ott; Sat, 23 Jul 2022 07:13:48 -0700 (PDT) X-Google-Smtp-Source: AGRyM1teimSL/Ym8K8eW1G/jozbDVF/4xQz5QQ4V9nYDk0mXOQYzwVS6veA3N27ziLlFT9GlLwLt X-Received: by 2002:a05:6402:5489:b0:43b:b935:db37 with SMTP id fg9-20020a056402548900b0043bb935db37mr4642976edb.347.1658585628637; Sat, 23 Jul 2022 07:13:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658585628; cv=none; d=google.com; s=arc-20160816; b=U0WFKKt+nw06A02ePZohFrR1nCevFO0z3MD6qirWaP9t7z8gocSAuSOJOr7h3cjpjb 0YurlSw3uYpc135h6f04NNijCI/VeVHRTs9YwTMAX2o4/ahmqT6G82jwsjmsn1gOD3sK WUGLtppAdkfarO5HJYZ0lPp6rS3B9I9H73oYQWUnRz3jewUaWYXgy+UJFBfTXf3FYk3l Nx9KH0BFaYPQeShbcmfaWB+ZCwYYZ12CkJzM9zpyIozLXpEvMZlWqUHemyEzlUySi4Ub UQMmXWBj/1Kc4UItl9q/sXTfCT79HFUL5qBuP2Io4XGxeotNpflISRBoqYQL+BTbZOEG Q1Ow== 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=dzG1fKMAK5WAw0/ucV2rWWJUQ/p3p/FIMKY4V28A41g=; b=0dLaMITePkruekWDL8D1ks8cISdqNvzaI0Tknld7f2PHjYxB3UFmmKl9zfTBoTRTH5 3VKOkA3qVOPu5Wqy/pEAXZEIZpDiwFGbC7QBzbYZTsQb+LxQe/yJZvofS6WTXXZ/7jCI iH9030luSHe6pgHyV/ig1CtD+s4HFWCmTsJ23fUhoWKScX7rN0EV+wwXOqjLXfa1dgkY L/gY4RVoHG/8ZsiwxAe8+7JcH2jiqrXiiuB8SKi2lKXHVmhyeJ7H7M2LGL2yebMkNc2k 0uxZh4LiSqq/yc4axglpGARY3YMqmGQ3W/ylgdKaqll91LXmhQv8VnXnMW88yn/a3Umg yHag== 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 qb29-20020a1709077e9d00b00722ea4dd14csi9283772ejc.387.2022.07.23.07.13.48; Sat, 23 Jul 2022 07:13:48 -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 C63DE68B8EC; Sat, 23 Jul 2022 17:10:48 +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 006E368B803 for ; Sat, 23 Jul 2022 17:10:26 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 1CB7C2404FE for ; Sat, 23 Jul 2022 16:10:23 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id h_W_xXV5xa9n for ; Sat, 23 Jul 2022 16:10:22 +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 7C96424050B for ; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 7A6E83A046F; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 23 Jul 2022 16:09:35 +0200 Message-Id: <20220723140952.31814-10-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 10/27] fftools/ffmpeg: stop allocating an encoder context when not encoding 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: SeufzhtB28dv Content-Length: 6869 --- fftools/ffmpeg.c | 12 +++++++++--- fftools/ffmpeg_opt.c | 36 ++++++++++++++++-------------------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 0e30f8ce01..30618c6a6a 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1462,7 +1462,8 @@ static void print_final_stats(int64_t total_size) } extra_size += par->extradata_size; data_size += ost->data_size; - if ( (ost->enc_ctx->flags & (AV_CODEC_FLAG_PASS1 | AV_CODEC_FLAG_PASS2)) + if (ost->enc_ctx && + (ost->enc_ctx->flags & (AV_CODEC_FLAG_PASS1 | AV_CODEC_FLAG_PASS2)) != AV_CODEC_FLAG_PASS1) pass1_used = 0; } @@ -1630,7 +1631,8 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti av_bprintf(&buf, "%X", av_log2(qp_histogram[j] + 1)); } - if ((enc->flags & AV_CODEC_FLAG_PSNR) && (ost->pict_type != AV_PICTURE_TYPE_NONE || is_last_report)) { + if (enc && (enc->flags & AV_CODEC_FLAG_PSNR) && + (ost->pict_type != AV_PICTURE_TYPE_NONE || is_last_report)) { int j; double error, error_sum = 0; double scale, scale_sum = 0; @@ -3139,6 +3141,9 @@ static int init_output_stream_encode(OutputStream *ost, AVFrame *frame) break; } + if (ost->bitexact) + enc_ctx->flags |= AV_CODEC_FLAG_BITEXACT; + if (ost->sq_idx_encode >= 0) sq_set_tb(of->sq_encode, ost->sq_idx_encode, enc_ctx->time_base); @@ -3635,7 +3640,8 @@ static int check_keyboard_interaction(int64_t cur_time) } for(i=0;ienc_ctx->debug = debug; + if (ost->enc_ctx) + ost->enc_ctx->debug = debug; } if(debug) av_log_set_level(AV_LOG_DEBUG); fprintf(stderr,"debug=%d\n", debug); diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 716b53d81f..f6e354355b 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -1568,12 +1568,14 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e exit_program(1); } - ost->enc_ctx = avcodec_alloc_context3(ost->enc); - if (!ost->enc_ctx) { - av_log(NULL, AV_LOG_ERROR, "Error allocating the encoding context.\n"); - exit_program(1); + if (ost->enc) { + ost->enc_ctx = avcodec_alloc_context3(ost->enc); + if (!ost->enc_ctx) { + av_log(NULL, AV_LOG_ERROR, "Error allocating the encoding context.\n"); + exit_program(1); + } + ost->enc_ctx->codec_type = type; } - ost->enc_ctx->codec_type = type; ost->filtered_frame = av_frame_alloc(); if (!ost->filtered_frame) @@ -1622,9 +1624,8 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e if (o->bitexact) { - ost->enc_ctx->flags |= AV_CODEC_FLAG_BITEXACT; ost->bitexact = 1; - } else { + } else if (ost->enc_ctx) { ost->bitexact = check_opt_bitexact(ost->enc_ctx, ost->encoder_opts, "flags", AV_CODEC_FLAG_BITEXACT); } @@ -1678,12 +1679,13 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e uint32_t tag = strtol(codec_tag, &next, 0); if (*next) tag = AV_RL32(codec_tag); - ost->st->codecpar->codec_tag = - ost->enc_ctx->codec_tag = tag; + ost->st->codecpar->codec_tag = tag; + if (ost->enc_ctx) + ost->enc_ctx->codec_tag = tag; } MATCH_PER_STREAM_OPT(qscale, dbl, qscale, oc, st); - if (qscale >= 0) { + if (ost->enc_ctx && qscale >= 0) { ost->enc_ctx->flags |= AV_CODEC_FLAG_QSCALE; ost->enc_ctx->global_quality = FF_QP2LAMBDA * qscale; } @@ -1700,7 +1702,7 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e MATCH_PER_STREAM_OPT(bits_per_raw_sample, i, ost->bits_per_raw_sample, oc, st); - if (oc->oformat->flags & AVFMT_GLOBALHEADER) + if (oc->oformat->flags & AVFMT_GLOBALHEADER && ost->enc_ctx) ost->enc_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; av_dict_copy(&ost->sws_dict, o->g->sws_dict, 0); @@ -1802,12 +1804,10 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in { AVStream *st; OutputStream *ost; - AVCodecContext *video_enc; char *frame_rate = NULL, *max_frame_rate = NULL, *frame_aspect_ratio = NULL; ost = new_output_stream(o, oc, AVMEDIA_TYPE_VIDEO, source_index); st = ost->st; - video_enc = ost->enc_ctx; MATCH_PER_STREAM_OPT(frame_rates, str, frame_rate, oc, st); if (frame_rate && av_parse_video_rate(&ost->frame_rate, frame_rate) < 0) { @@ -1845,6 +1845,7 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in MATCH_PER_STREAM_OPT(filters, str, ost->filters, oc, st); if (!ost->stream_copy) { + AVCodecContext *video_enc = ost->enc_ctx; const char *p = NULL; char *frame_size = NULL; char *frame_pix_fmt = NULL; @@ -2045,18 +2046,16 @@ static OutputStream *new_audio_stream(OptionsContext *o, AVFormatContext *oc, in int n; AVStream *st; OutputStream *ost; - AVCodecContext *audio_enc; ost = new_output_stream(o, oc, AVMEDIA_TYPE_AUDIO, source_index); st = ost->st; - audio_enc = ost->enc_ctx; - audio_enc->codec_type = AVMEDIA_TYPE_AUDIO; MATCH_PER_STREAM_OPT(filter_scripts, str, ost->filters_script, oc, st); MATCH_PER_STREAM_OPT(filters, str, ost->filters, oc, st); if (!ost->stream_copy) { + AVCodecContext *audio_enc = ost->enc_ctx; int channels = 0; char *layout = NULL; char *sample_fmt = NULL; @@ -2178,15 +2177,12 @@ static OutputStream *new_subtitle_stream(OptionsContext *o, AVFormatContext *oc, { AVStream *st; OutputStream *ost; - AVCodecContext *subtitle_enc; ost = new_output_stream(o, oc, AVMEDIA_TYPE_SUBTITLE, source_index); st = ost->st; - subtitle_enc = ost->enc_ctx; - - subtitle_enc->codec_type = AVMEDIA_TYPE_SUBTITLE; if (!ost->stream_copy) { + AVCodecContext *subtitle_enc = ost->enc_ctx; char *frame_size = NULL; MATCH_PER_STREAM_OPT(frame_sizes, str, frame_size, oc, st); From patchwork Sat Jul 23 14:09:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 36920 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp1048033pzb; Sat, 23 Jul 2022 07:13:31 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tjmNQK270H8pk6nhD4LCODaLsL/3nJ9hyTDEhLjw7s8UNxQVRZszPQZe9RYfAR9/T6drpM X-Received: by 2002:a05:6402:84a:b0:426:262d:967e with SMTP id b10-20020a056402084a00b00426262d967emr4459754edz.286.1658585611032; Sat, 23 Jul 2022 07:13:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658585611; cv=none; d=google.com; s=arc-20160816; b=e8CSOU/b1GkG3T3dCcS9z3+X+x1Obbq+lOyCZmBifKiDja3Qp7AJyYFBRJEATNKpxF dJsjLb9oPSuRNOUwUetTxw5AUik6SbLyvZ+nAGmY1uDnkexWUTS5+pU1/rFm8VEPum4N RoYuS9oXcpeVk7RpxB4R6SUUzEoyvqmPgb4ldhYnVlItbvA96VqE7lRmIBIE12MpCoq0 SChWkPhMNipWe9stcrcR4syMwfucGEkTA5jRPNs6LAhA1pFWwCPkEeV3+LGIO3eXutcz La+4bh5jVVTJPF9Rbh8wCM+g24uHMzPpDrTYrAYs+z+quWS6C1QbCSoONs38gS6degG4 xVnA== 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=RMGMj0Po/lUihocO6JRk1zTUbS/XNZEqp5sF+OQ3QQA=; b=EPlXEX3+H9YvhV8nxyD0vWb9W3/wwGehDjpHrmaWemmuvCayhIoG77UhuucJbvRQBp FxDZjHrPP+wmNi6amtYG2yEEOfZVMN9rEuO7geTsQ5NneeBDfaryEhb0AljQS3T/bq00 Q8Vzg2UoqjhodM/Ij3jxrR3tC/1ItDNDVBfZc6BebQMbyMeGC3x21IMMD7/nXyAMx6T4 yXn/GDSx17eXc/4DtwwB4h9o5qHbs2/kkaP8yEiHdo9XuTnIkWQ88DWGEhh2rykskWDi mSmf/crrkC3z9DvsX2endJYMwL0/zdDXKmg7Gpqb1O9gdctbgEcgf9dEka4jFtmu5kib 3pbw== 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 sc40-20020a1709078a2800b0072b97b3288dsi9806776ejc.510.2022.07.23.07.13.30; Sat, 23 Jul 2022 07:13:31 -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 9EB6B68B8DC; Sat, 23 Jul 2022 17:10:46 +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 6846F68B7CC for ; Sat, 23 Jul 2022 17:10:26 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 738DD240507 for ; Sat, 23 Jul 2022 16:10:22 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 6a7m9MYPztOZ for ; Sat, 23 Jul 2022 16:10:22 +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 7E12D240511 for ; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 7F0EB3A0470; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 23 Jul 2022 16:09:36 +0200 Message-Id: <20220723140952.31814-11-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 11/27] fftools/ffmpeg_opt: drop a redundant assignment 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: lEH8UG5H3aj0 The codec type will be set by avcodec_alloc_context3(), there is no reason to set it manually. --- fftools/ffmpeg_opt.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index f6e354355b..29bc4fd97f 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -1574,7 +1574,6 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e av_log(NULL, AV_LOG_ERROR, "Error allocating the encoding context.\n"); exit_program(1); } - ost->enc_ctx->codec_type = type; } ost->filtered_frame = av_frame_alloc(); From patchwork Sat Jul 23 14:09:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 36908 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp1047106pzb; Sat, 23 Jul 2022 07:11:45 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vLmzgH6hUjtSoXqy2UA3CLi6d4aSiDN63lvPKm4e0GvjBuHbwo0U89/Zg+697dENMcd3BN X-Received: by 2002:a17:907:1c19:b0:72f:cc9e:3a7 with SMTP id nc25-20020a1709071c1900b0072fcc9e03a7mr65748ejc.631.1658585505615; Sat, 23 Jul 2022 07:11:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658585505; cv=none; d=google.com; s=arc-20160816; b=0wAN0JqRvkYjplRd7tajZo4+FD/bMeKkfHH7IN0r9U3i49mNCNICmjQxVfEarqqGLw YRp1Qj2Y9BhthS7WhvVfR9h8tfx5N/6aYfrHfUNv9ncXLLc0aZnx9yzSqYuPwEEIA6f0 ViIghfxtxi5lcq/Zh4Sm4S6J6sqHrLoZ/tXOgy2cKCt4U1YW3M1R4t9XTgiUbeb7lQ/D LCRPX76beB9f62eBHwmp0k0yxE3YFpLBlPnmK1xyD2ymQRebXq3uhMirnT2dIdj2t/mw AjxpYReiJeqMNymm1+myRqXbKh2DnivDTHk517PC9rxQFrj9ZjNYLRs2mLMYui6MhCaG 0m6g== 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=yck3J3gQfgAIkyMJ2NSrDiowZAj7T3QOlYCuhbherx4=; b=se0SSEEC+aibEycJf044wFhjFa+9825fGS6l429d37sl/JYg762lEq1CPOzNOYu09v lhroKL5itrA/cEsFQ66opekj0CGbPUfvt4emqtbyIjU8JS9eLXkwa/rjyyVEWDJU5DGn oacr00mjUGfgyRZv3O5FlJYAUGwaJyJHUJraGA1Jk6Em/lugAmRYmk5CXisQmjlj9ObS FjyOHjdlukh5JAKFUCLwa1ngEVQv58oTXFMTHeu3Luj0AMBoWdJVk62qN1gqG22N/CJB r/aWhxG6VtGhDsuRzAjrsBzwCOIEDbUf84kkwdCX7OzZad90tVOBkm43isCPy35A+nDq uFFw== 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 g8-20020a056402090800b004359f471717si9962710edz.0.2022.07.23.07.11.44; Sat, 23 Jul 2022 07:11:45 -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 111A668B872; Sat, 23 Jul 2022 17:10:36 +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 4E40268B7D1 for ; Sat, 23 Jul 2022 17:10:28 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 5663324062A for ; Sat, 23 Jul 2022 16:10:26 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id bXN132pSDDV8 for ; Sat, 23 Jul 2022 16:10:25 +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 AC1FC240592 for ; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 8394E3A048F; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 23 Jul 2022 16:09:37 +0200 Message-Id: <20220723140952.31814-12-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 12/27] fftools/ffmpeg: drop unused hwaccel variables 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: ChH0lStBiC8P --- fftools/ffmpeg.c | 3 --- fftools/ffmpeg.h | 6 ------ 2 files changed, 9 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 30618c6a6a..f39966f096 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2275,7 +2275,6 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output, int64_ if (err < 0) goto fail; } - ist->hwaccel_retrieved_pix_fmt = decoded_frame->format; best_effort_timestamp= decoded_frame->best_effort_timestamp; *duration_pts = decoded_frame->duration; @@ -4428,8 +4427,6 @@ static int transcode(void) ist = input_streams[i]; if (ist->decoding_needed) { avcodec_close(ist->dec_ctx); - if (ist->hwaccel_uninit) - ist->hwaccel_uninit(ist->dec_ctx); } } diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 0795a380f8..bc78570d16 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -385,12 +385,8 @@ typedef struct InputStream { char *hwaccel_device; enum AVPixelFormat hwaccel_output_format; - /* hwaccel context */ - void *hwaccel_ctx; - void (*hwaccel_uninit)(AVCodecContext *s); int (*hwaccel_retrieve_data)(AVCodecContext *s, AVFrame *frame); enum AVPixelFormat hwaccel_pix_fmt; - enum AVPixelFormat hwaccel_retrieved_pix_fmt; /* stats */ // combined size of all the packets read @@ -493,8 +489,6 @@ typedef struct OutputStream { int64_t last_dropped; int64_t last_nb0_frames[3]; - void *hwaccel_ctx; - /* video only */ AVRational frame_rate; AVRational max_frame_rate; From patchwork Sat Jul 23 14:09:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 36909 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp1047168pzb; Sat, 23 Jul 2022 07:11:53 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uphPrv55v/IU4W23m5hoF6Fs76BEoRSK1C1puOppPaBG8JlTdHvu5cKJrt2ptyuRRaTjsj X-Received: by 2002:a17:907:3f02:b0:6f3:5c42:321a with SMTP id hq2-20020a1709073f0200b006f35c42321amr3534748ejc.521.1658585513452; Sat, 23 Jul 2022 07:11:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658585513; cv=none; d=google.com; s=arc-20160816; b=tiTqs6HBgjJPJOTT6723jjTX4zwV1EdASI7UPSQTQAPpEglkBMP/oGZIJ0dr5YLwmg +ZmvtS5++sQgVnEEv+b59D7k7kW3hkje4sTZVLkIi1pW0+621DCfS0ysZKNkmkoNXDsE SX1nlmtVkPLs+/hDR/goADeDajOVHC1HW7Zv0UfPfXkc/ZSN3THBG6lUolcnAQCi7H7k o+72jQzE3WH4nNLzoVSJ+Qg60xb42UdJ4sO18xzANC1kneAMLQglKnCuCTVBkw8Y6lrE GGaPDfbXM7oYzuiOTZUlGUoIRnJp/8r9ogxajDrqgvvWBJg6J1xI0Kos6MoLXJtSgbS6 wrhg== 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=8LstLlPxjzzQjGybcptKBQq9Lm2PFTKJeylgkCJoHJM=; b=0arDi8y4khloSPt/SIiej2RX6bT7Zd+i/8U5jk9+1D1Tx3EmBQVHbr206lHwjPh4Q/ wj1xOrElsofLcgD1BC6JYesRRqgcLZotxLExMATYIKaCGFECXL5MsDQ0ueQQL2hIA0Ze jLupwqebZcjkXDdFFQfRIkv+dDzzA1i1URZc8kdH+NUDrCKSl0XBgJ74z2irvMIWUo7/ L9iN4KjYFIZtjXu08YMSxwO+B6E/7ff7D2KmLr+e4VYhHx2z0gicyfasITRq3zX41ahI ophoNO/5yqS+TYJZKx5C8NcyUnt2nzSduzAEGyFigLf5jiH2Pz0x49PP8XO1Rwg/c6Zj +RMw== 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 eb7-20020a0564020d0700b0043a6ddb2941si9695790edb.253.2022.07.23.07.11.52; Sat, 23 Jul 2022 07:11:53 -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 16F2E68B887; Sat, 23 Jul 2022 17:10:37 +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 4B5CD68B7C9 for ; Sat, 23 Jul 2022 17:10:28 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 25034240590 for ; Sat, 23 Jul 2022 16:10:25 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id c-5fTcKwjccA for ; Sat, 23 Jul 2022 16:10:24 +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 AC17C240593 for ; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 8834B3A0490; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 23 Jul 2022 16:09:38 +0200 Message-Id: <20220723140952.31814-13-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 13/27] fftools/ffmpeg: move guess_input_channel_layout() to ffmpeg_opt.c 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: 8OzO9wzxyyI1 That is the only place where it is used. Also make it static. --- fftools/ffmpeg.c | 19 ------------------- fftools/ffmpeg.h | 2 -- fftools/ffmpeg_opt.c | 19 +++++++++++++++++++ 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index f39966f096..ad20278aa2 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1934,25 +1934,6 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p ost->streamcopy_started = 1; } -int guess_input_channel_layout(InputStream *ist) -{ - AVCodecContext *dec = ist->dec_ctx; - - if (dec->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC) { - char layout_name[256]; - - if (dec->ch_layout.nb_channels > ist->guess_layout_max) - return 0; - av_channel_layout_default(&dec->ch_layout, dec->ch_layout.nb_channels); - if (dec->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC) - return 0; - av_channel_layout_describe(&dec->ch_layout, layout_name, sizeof(layout_name)); - av_log(NULL, AV_LOG_WARNING, "Guessed Channel Layout for Input Stream " - "#%d.%d : %s\n", ist->file_index, ist->st->index, layout_name); - } - return 1; -} - static void check_decode_result(InputStream *ist, int *got_output, int ret) { if (*got_output || ret<0) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index bc78570d16..66a49a0cb7 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -668,8 +668,6 @@ void show_usage(void); void remove_avoptions(AVDictionary **a, AVDictionary *b); void assert_avoptions(AVDictionary *m); -int guess_input_channel_layout(InputStream *ist); - int configure_filtergraph(FilterGraph *fg); void check_filter_outputs(void); int filtergraph_is_simple(FilterGraph *fg); diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 29bc4fd97f..444392fd45 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -862,6 +862,25 @@ static const AVCodec *choose_decoder(OptionsContext *o, AVFormatContext *s, AVSt return avcodec_find_decoder(st->codecpar->codec_id); } +static int guess_input_channel_layout(InputStream *ist) +{ + AVCodecContext *dec = ist->dec_ctx; + + if (dec->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC) { + char layout_name[256]; + + if (dec->ch_layout.nb_channels > ist->guess_layout_max) + return 0; + av_channel_layout_default(&dec->ch_layout, dec->ch_layout.nb_channels); + if (dec->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC) + return 0; + av_channel_layout_describe(&dec->ch_layout, layout_name, sizeof(layout_name)); + av_log(NULL, AV_LOG_WARNING, "Guessed Channel Layout for Input Stream " + "#%d.%d : %s\n", ist->file_index, ist->st->index, layout_name); + } + return 1; +} + /* Add all the streams from the given input file to the global * list of input streams. */ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) From patchwork Sat Jul 23 14:09:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 36933 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a9d:f07:0:b0:61c:acf1:bf6b with SMTP id 7csp644711ott; Sat, 23 Jul 2022 07:14:04 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ulAuVT6WYlKs7yLP+yb9IgF7qjQtYoAWI8bTpe8onnMN59JTJnBoXZQ4vtdhdV1xTS8ao4 X-Received: by 2002:a17:906:8456:b0:72b:88c6:a374 with SMTP id e22-20020a170906845600b0072b88c6a374mr3573740ejy.615.1658585644698; Sat, 23 Jul 2022 07:14:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658585644; cv=none; d=google.com; s=arc-20160816; b=Ufj8qEBhqWp60Qaumva6N65Aq1Te+JjuJJllddDeyQNms0Bx3YVZNkzdINy8CFTYpV w4sVLZZVyLdS+oDe75HeW3PSiilzGNzfZS9S+WuHBHWpMUbYrjeGFUfynaUAvxx7iZSw YEYdd7zQx7HOomnWNKhUfZqPvxALvnSGQ67kwloL+I5XYC8tHhJGhKac6w10Vk6Q6bGN WQTVmS2iYLVHyu9GC24DLP9jzY8PgAhv3MZ2Xp9GiI005VGE9AQr9jCrr2b8Oy7/zLlf 8mJDwvQHCFHwnymOfnIe1TwFG8W/XgCYcGYa/s+jAsiOZJFMOMRSw1PaI5uN0+g74QQM n6FA== 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=lHnZNuKNunN/j1MbehML2eiWjmfEwtqRL53PQU+KYH4=; b=Qg22lpW1+zP6Yz6FTnX0DElneCtn97oinf5WS5+2vrKYgt1Kngid6zXJngeYmYkL/8 pXIjfyUXVBbrzZYG6SwOK8uLRvORoUGGprixeXAtP6FapFuFSBOlFyJUUVkz5arF8hva cWEemwTDJaERxMmv2IcES3Bcc8oXhWLpGpdww/EqZzH6hss+jgYIHgjUW/q/JrIoKYQS S5C8L90Dd6+dbRvCfcW8QAc/Ii0xrK7LgZEHX0O4jG668w2Vosj4fwl+BibfYqZHkgtj hM17fdt5yLx1UAuoqJg2JeJ1Z49evd9WYzhU0eGjJ548o0WsvygS0Bo5jLoNpCic9oOe g83g== 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 e8-20020a170906844800b0072b29827476si7331041ejy.287.2022.07.23.07.14.04; Sat, 23 Jul 2022 07:14:04 -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 BA6D968B8F7; Sat, 23 Jul 2022 17:10:50 +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 65BA768B82E for ; Sat, 23 Jul 2022 17:10:27 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id CBEB7240555 for ; Sat, 23 Jul 2022 16:10:23 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id Vlm1wwohVWNn for ; Sat, 23 Jul 2022 16:10:23 +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 8AF28240512 for ; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 8CDB33A04A6; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 23 Jul 2022 16:09:39 +0200 Message-Id: <20220723140952.31814-14-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 14/27] fftools/ffmpeg: deprecate the -map_channel option 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: Om1WXDChlR39 Content-Length: 7669 It is now entirely redundant with audio filters, and is in fact implemented by setting up a 'pan' filter instance. --- doc/ffmpeg.texi | 4 ++++ fftools/ffmpeg.c | 2 ++ fftools/ffmpeg.h | 7 +++++++ fftools/ffmpeg_filter.c | 2 ++ fftools/ffmpeg_opt.c | 19 ++++++++++++++++--- 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 974d1c108f..2fb0bc8ffa 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -1492,6 +1492,10 @@ Allow input streams with unknown type to be copied instead of failing if copying such streams is attempted. @item -map_channel [@var{input_file_id}.@var{stream_specifier}.@var{channel_id}|-1][?][:@var{output_file_id}.@var{stream_specifier}] +This option is deprecated and will be removed. It can be replaced by the +@var{pan} filter. In some cases it may be easier to use some combination of the +@var{channelsplit}, @var{channelmap}, or @var{amerge} filters. + Map an audio channel from a given input to an output. If @var{output_file_id}.@var{stream_specifier} is not set, the audio channel will be mapped on all the audio streams. diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index ad20278aa2..19173c75e1 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -578,8 +578,10 @@ static void ffmpeg_cleanup(int ret) av_freep(&ost->avfilter); av_freep(&ost->logfile_prefix); +#if FFMPEG_OPT_MAP_CHANNEL av_freep(&ost->audio_channels_map); ost->audio_channels_mapped = 0; +#endif av_dict_free(&ost->sws_dict); av_dict_free(&ost->swr_opts); diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 66a49a0cb7..6417db03bd 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -51,6 +51,7 @@ // deprecated features #define FFMPEG_OPT_PSNR 1 +#define FFMPEG_OPT_MAP_CHANNEL 1 enum VideoSyncMethod { VSYNC_AUTO = -1, @@ -85,10 +86,12 @@ typedef struct StreamMap { char *linklabel; /* name of an output link, for mapping lavfi outputs */ } StreamMap; +#if FFMPEG_OPT_MAP_CHANNEL typedef struct { int file_idx, stream_idx, channel_idx; // input int ofile_idx, ostream_idx; // output } AudioChannelMap; +#endif typedef struct OptionsContext { OptionGroup *g; @@ -141,8 +144,10 @@ typedef struct OptionsContext { /* output options */ StreamMap *stream_maps; int nb_stream_maps; +#if FFMPEG_OPT_MAP_CHANNEL AudioChannelMap *audio_channel_maps; /* one info entry per -map_channel */ int nb_audio_channel_maps; /* number of (valid) -map_channel settings */ +#endif int metadata_global_manual; int metadata_streams_manual; int metadata_chapters_manual; @@ -516,8 +521,10 @@ typedef struct OutputStream { int dropped_keyframe; /* audio only */ +#if FFMPEG_OPT_MAP_CHANNEL int *audio_channels_map; /* list of the channels id to pick from the source stream */ int audio_channels_mapped; /* number of channels in audio_channels_map */ +#endif char *logfile_prefix; FILE *logfile; diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 6807bf384a..5d00bfe056 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -560,6 +560,7 @@ static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter, pad_idx = 0; \ } while (0) av_bprint_init(&args, 0, AV_BPRINT_SIZE_UNLIMITED); +#if FFMPEG_OPT_MAP_CHANNEL if (ost->audio_channels_mapped) { AVChannelLayout mapped_layout = { 0 }; int i; @@ -572,6 +573,7 @@ static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter, AUTO_INSERT_FILTER("-map_channel", "pan", args.str); av_bprint_clear(&args); } +#endif if (codec->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC) av_channel_layout_default(&codec->ch_layout, codec->ch_layout.nb_channels); diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 444392fd45..e6f2fb597a 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -219,7 +219,9 @@ static void uninit_options(OptionsContext *o) for (i = 0; i < o->nb_stream_maps; i++) av_freep(&o->stream_maps[i].linklabel); av_freep(&o->stream_maps); +#if FFMPEG_OPT_MAP_CHANNEL av_freep(&o->audio_channel_maps); +#endif av_freep(&o->streamid_map); av_freep(&o->attachments); } @@ -534,6 +536,7 @@ static int opt_attach(void *optctx, const char *opt, const char *arg) return 0; } +#if FFMPEG_OPT_MAP_CHANNEL static int opt_map_channel(void *optctx, const char *opt, const char *arg) { OptionsContext *o = optctx; @@ -542,6 +545,12 @@ static int opt_map_channel(void *optctx, const char *opt, const char *arg) AudioChannelMap *m; char *allow_unused; char *mapchan; + + av_log(NULL, AV_LOG_WARNING, + "The -%s option is deprecated and will be removed. " + "It can be replaced by the 'pan' filter, or in some cases by " + "combinations of 'channelsplit', 'channelmap', 'amerge' filters.\n", opt); + mapchan = av_strdup(arg); if (!mapchan) return AVERROR(ENOMEM); @@ -610,6 +619,7 @@ static int opt_map_channel(void *optctx, const char *opt, const char *arg) av_free(mapchan); return 0; } +#endif static int opt_sdp_file(void *optctx, const char *opt, const char *arg) { @@ -2061,7 +2071,6 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in static OutputStream *new_audio_stream(OptionsContext *o, AVFormatContext *oc, int source_index) { - int n; AVStream *st; OutputStream *ost; @@ -2121,8 +2130,9 @@ static OutputStream *new_audio_stream(OptionsContext *o, AVFormatContext *oc, in if (!ost->avfilter) exit_program(1); +#if FFMPEG_OPT_MAP_CHANNEL /* check for channel mapping for this audio stream */ - for (n = 0; n < o->nb_audio_channel_maps; n++) { + for (int n = 0; n < o->nb_audio_channel_maps; n++) { AudioChannelMap *map = &o->audio_channel_maps[n]; if ((map->ofile_idx == -1 || ost->file_index == map->ofile_idx) && (map->ostream_idx == -1 || ost->st->index == map->ostream_idx)) { @@ -2149,6 +2159,7 @@ static OutputStream *new_audio_stream(OptionsContext *o, AVFormatContext *oc, in } } } +#endif } if (ost->stream_copy) @@ -3759,8 +3770,10 @@ const OptionDef options[] = { OPT_OUTPUT, { .func_arg = opt_map }, "set input stream mapping", "[-]input_file_id[:stream_specifier][,sync_file_id[:stream_specifier]]" }, +#if FFMPEG_OPT_MAP_CHANNEL { "map_channel", HAS_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_map_channel }, - "map an audio channel from one stream to another", "file.stream.channel[:syncfile.syncstream]" }, + "map an audio channel from one stream to another (deprecated)", "file.stream.channel[:syncfile.syncstream]" }, +#endif { "map_metadata", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(metadata_map) }, "set metadata information of outfile from infile", From patchwork Sat Jul 23 14:09:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 36911 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp1047338pzb; Sat, 23 Jul 2022 07:12:10 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vfEaZp+cUu5yf2H2QduklEwIBfp+YuHXgcsExD4rQhAmlWvz2A/pp7yJORxXIQQ9TSk5Dj X-Received: by 2002:a17:907:6eac:b0:72b:4c75:28fb with SMTP id sh44-20020a1709076eac00b0072b4c7528fbmr3642840ejc.675.1658585530725; Sat, 23 Jul 2022 07:12:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658585530; cv=none; d=google.com; s=arc-20160816; b=N7U+slcGSCANpMYUM2BJK6euafNVtiWkg+YpY8UqyPt+iCClayHjX54n+aCmrQJNYf jLga3lwSXHqyHes2X6gZM4GZLeAzVOmsqjCXEUF0VPYhqeyn8eShWTcMawK1MGvqkfym DRr1jOd7ihUABvg+JcCg3yJfw8F2bO2KufBfcfTLpULvuzQLyPbTN+mr8m6K8LX0X8Nd Q6m4PbANHw5IwyuX2sFHJ6zGZykWFjXLfElqiK5pZe7nulU+yTKo4WmlIEav9GCWmJLN C59NRqXzYfQABNQpW0RZ+CwsvySJGF2ObS8uR3IrG+vDsAGaNBMnezaaQII7W9lHcn9Z FRPw== 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=1ZntLn0YTG6C+qNwPt2UC12MDJjBPG2Ge6MXG/adMYM=; b=ytcdar5MVSZ53SF/8kzP+BxeZ6ycaMhbRJPj3OnfhltRFvQofwdHSvh9wlR4b9kVG5 jVSYLsiZVbNmCSP7xWye82l79iHsjC3z/qsQ2nqMOIjEnmR+kMSTItyWRwMfNGezxZpp v2Sq4ZCq78THHfKotm9olXFlPAUY51lvnB2A19ZUDTsraTNoyzoEjm05u6qB8tAU2Mhu DyvffWRAcAPMbwRr8G64ChTmtyhhkd/udQk4rjNggI8A7scvP5whfdR5HcC6dk2DKPUV lwVuA6LLPXQsxqbhDvFoGxkBySYeKCsQFs2wPbvWITCqWH7oD/WGmbh+8UH3ytV2G2Ta 3/SQ== 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 t18-20020a1709067c1200b0072eece129b1si7071147ejo.753.2022.07.23.07.12.10; Sat, 23 Jul 2022 07:12:10 -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 249CC68B8A9; Sat, 23 Jul 2022 17:10:39 +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 8588668B7D1 for ; Sat, 23 Jul 2022 17:10:28 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id CAAC6240592 for ; Sat, 23 Jul 2022 16:10:26 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id yvHbBXGPP49I for ; Sat, 23 Jul 2022 16:10:26 +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 BEE52240688 for ; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 914DA3A04AB; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 23 Jul 2022 16:09:40 +0200 Message-Id: <20220723140952.31814-15-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 15/27] fftools/ffmpeg_filter: drop a block commented out since 2012 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: ndwS4uheO9r2 Since the option it relates to is deprecated, it is highly unlikely to become useful. --- fftools/ffmpeg_filter.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 5d00bfe056..f9ae76f76d 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -902,19 +902,6 @@ static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter, AUTO_INSERT_FILTER_INPUT("-async", "aresample", args); } -// if (ost->audio_channels_mapped) { -// int i; -// AVBPrint pan_buf; -// av_bprint_init(&pan_buf, 256, 8192); -// av_bprintf(&pan_buf, "0x%"PRIx64, -// av_get_default_channel_layout(ost->audio_channels_mapped)); -// for (i = 0; i < ost->audio_channels_mapped; i++) -// if (ost->audio_channels_map[i] != -1) -// av_bprintf(&pan_buf, ":c%d=c%d", i, ost->audio_channels_map[i]); -// AUTO_INSERT_FILTER_INPUT("-map_channel", "pan", pan_buf.str); -// av_bprint_finalize(&pan_buf, NULL); -// } - snprintf(name, sizeof(name), "trim for input stream %d:%d", ist->file_index, ist->st->index); if (copy_ts) { From patchwork Sat Jul 23 14:09:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 36930 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a9d:f07:0:b0:61c:acf1:bf6b with SMTP id 7csp644588ott; Sat, 23 Jul 2022 07:13:53 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sYsH0AP7gg9rSbV/mSRklRaKLYkjEwRawkntUbOn5PiXaF7aMKxJVIRJI4P5ZwjQORaP3J X-Received: by 2002:a05:6402:428c:b0:43b:cd8:b679 with SMTP id g12-20020a056402428c00b0043b0cd8b679mr4556619edc.404.1658585633236; Sat, 23 Jul 2022 07:13:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658585633; cv=none; d=google.com; s=arc-20160816; b=BAkvXmTu3+73dZzaiEriNYXMVKyiMK8PgFCMVfwkBaQRTwA5c6nohHf06IqD6/etiX ziAg3zyCvS5LQt7ryVMvPugaiv0imksfVY1h9drif4wBXcjLKUdmlzoeIC1yQ66KJ/bu EKkh3r3U85KM1m/rF0zeXdboW3CjIWEH+NhkpdOySY/0eXLAUGsDyW+UjyDyIykiMWIi PDAwLaEJJ65OEr1wxfnfKJ3hi6jS9rfjeu6N0HG7yF+7maQSuuLVEzCBgztq+wbgiBDV 1BUnWK9XUfqDe9YOhtutWGezX4Z5+VihuNsZgEkN9CC4sK7wDyn+oNSMlSBb0VBG0Dx7 ehDQ== 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=raOwEscBVZT4UBBJQ7/4Gl+DxsgxiY7Kr8w5Dqdd1lg=; b=v9BRgW9uIs75/sdsvI1DBz25ZFxtqNOjqidJrOfNTQUwyxwi57Qtt1hB08PeC8ABcO Vy1l7CpQK7DzQWVFBs9ocn77cfSSP1RK0MusioIq4ClEdFL0cVe3fVxnLdZMtxuVP21F twQeu5ls8ZeDOWstrVmp/OhvUQvVgMNG/b/wkUbgNpndH/401/Lq4fOn7L6+mVr8X18E KXuNL5HD6i2goWUImevLIjr+Elu+yBHqiqwkJr75LiNxhI9mv7nPcv0cx8j6TK2mSDtV +NPAqDNQKFTQL7OnRbbVeS8ZLFcvj965TBC55wdEYx5LCd4YdmMBq3/8QBRqgKIqOWL1 IniQ== 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 hr34-20020a1709073fa200b0072ecfeec4cbsi10140524ejc.463.2022.07.23.07.13.52; Sat, 23 Jul 2022 07:13:53 -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 410D268B8F0; Sat, 23 Jul 2022 17:10:49 +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 60FC568B808 for ; Sat, 23 Jul 2022 17:10:27 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 7214424050B for ; Sat, 23 Jul 2022 16:10:23 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id HnUetkFBqKQL for ; Sat, 23 Jul 2022 16:10:22 +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 928EC240555 for ; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 964FB3A04C6; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 23 Jul 2022 16:09:41 +0200 Message-Id: <20220723140952.31814-16-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 16/27] fftools/ffmpeg_mux: move some functions closer to their only callers 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: NDTwgc6LYbuk Content-Length: 6711 --- fftools/ffmpeg_mux.c | 196 +++++++++++++++++++++---------------------- 1 file changed, 98 insertions(+), 98 deletions(-) diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index 7f6da997a4..08a76f0066 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -74,48 +74,6 @@ struct Muxer { static int want_sdp = 1; -static int queue_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt) -{ - MuxStream *ms = &of->mux->streams[ost->index]; - AVPacket *tmp_pkt = NULL; - int ret; - - if (!av_fifo_can_write(ms->muxing_queue)) { - size_t cur_size = av_fifo_can_read(ms->muxing_queue); - size_t pkt_size = pkt ? pkt->size : 0; - unsigned int are_we_over_size = - (ms->muxing_queue_data_size + pkt_size) > ost->muxing_queue_data_threshold; - size_t limit = are_we_over_size ? ost->max_muxing_queue_size : SIZE_MAX; - size_t new_size = FFMIN(2 * cur_size, limit); - - if (new_size <= cur_size) { - av_log(NULL, AV_LOG_ERROR, - "Too many packets buffered for output stream %d:%d.\n", - ost->file_index, ost->st->index); - return AVERROR(ENOSPC); - } - ret = av_fifo_grow2(ms->muxing_queue, new_size - cur_size); - if (ret < 0) - return ret; - } - - if (pkt) { - ret = av_packet_make_refcounted(pkt); - if (ret < 0) - return ret; - - tmp_pkt = av_packet_alloc(); - if (!tmp_pkt) - return AVERROR(ENOMEM); - - av_packet_move_ref(tmp_pkt, pkt); - ms->muxing_queue_data_size += tmp_pkt->size; - } - av_fifo_write(ms->muxing_queue, &tmp_pkt, 1); - - return 0; -} - static int64_t filesize(AVIOContext *pb) { int64_t ret = -1; @@ -289,62 +247,6 @@ finish: return (void*)(intptr_t)ret; } -static int print_sdp(void) -{ - char sdp[16384]; - int i; - int j, ret; - AVIOContext *sdp_pb; - AVFormatContext **avc; - - for (i = 0; i < nb_output_files; i++) { - if (!output_files[i]->mux->header_written) - return 0; - } - - avc = av_malloc_array(nb_output_files, sizeof(*avc)); - if (!avc) - return AVERROR(ENOMEM); - for (i = 0, j = 0; i < nb_output_files; i++) { - if (!strcmp(output_files[i]->format->name, "rtp")) { - avc[j] = output_files[i]->mux->fc; - j++; - } - } - - if (!j) { - av_log(NULL, AV_LOG_ERROR, "No output streams in the SDP.\n"); - ret = AVERROR(EINVAL); - goto fail; - } - - ret = av_sdp_create(avc, j, sdp, sizeof(sdp)); - if (ret < 0) - goto fail; - - if (!sdp_filename) { - printf("SDP:\n%s\n", sdp); - fflush(stdout); - } else { - ret = avio_open2(&sdp_pb, sdp_filename, AVIO_FLAG_WRITE, &int_cb, NULL); - if (ret < 0) { - av_log(NULL, AV_LOG_ERROR, "Failed to open sdp file '%s'\n", sdp_filename); - goto fail; - } - - avio_print(sdp_pb, sdp); - avio_closep(&sdp_pb); - av_freep(&sdp_filename); - } - - // SDP successfully written, allow muxer threads to start - ret = 1; - -fail: - av_freep(&avc); - return ret; -} - static int submit_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt) { Muxer *mux = of->mux; @@ -368,6 +270,48 @@ finish: return ret == AVERROR_EOF ? 0 : ret; } +static int queue_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt) +{ + MuxStream *ms = &of->mux->streams[ost->index]; + AVPacket *tmp_pkt = NULL; + int ret; + + if (!av_fifo_can_write(ms->muxing_queue)) { + size_t cur_size = av_fifo_can_read(ms->muxing_queue); + size_t pkt_size = pkt ? pkt->size : 0; + unsigned int are_we_over_size = + (ms->muxing_queue_data_size + pkt_size) > ost->muxing_queue_data_threshold; + size_t limit = are_we_over_size ? ost->max_muxing_queue_size : SIZE_MAX; + size_t new_size = FFMIN(2 * cur_size, limit); + + if (new_size <= cur_size) { + av_log(NULL, AV_LOG_ERROR, + "Too many packets buffered for output stream %d:%d.\n", + ost->file_index, ost->st->index); + return AVERROR(ENOSPC); + } + ret = av_fifo_grow2(ms->muxing_queue, new_size - cur_size); + if (ret < 0) + return ret; + } + + if (pkt) { + ret = av_packet_make_refcounted(pkt); + if (ret < 0) + return ret; + + tmp_pkt = av_packet_alloc(); + if (!tmp_pkt) + return AVERROR(ENOMEM); + + av_packet_move_ref(tmp_pkt, pkt); + ms->muxing_queue_data_size += tmp_pkt->size; + } + av_fifo_write(ms->muxing_queue, &tmp_pkt, 1); + + return 0; +} + int of_submit_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost) { int ret; @@ -456,6 +400,62 @@ static int thread_start(OutputFile *of) return 0; } +static int print_sdp(void) +{ + char sdp[16384]; + int i; + int j, ret; + AVIOContext *sdp_pb; + AVFormatContext **avc; + + for (i = 0; i < nb_output_files; i++) { + if (!output_files[i]->mux->header_written) + return 0; + } + + avc = av_malloc_array(nb_output_files, sizeof(*avc)); + if (!avc) + return AVERROR(ENOMEM); + for (i = 0, j = 0; i < nb_output_files; i++) { + if (!strcmp(output_files[i]->format->name, "rtp")) { + avc[j] = output_files[i]->mux->fc; + j++; + } + } + + if (!j) { + av_log(NULL, AV_LOG_ERROR, "No output streams in the SDP.\n"); + ret = AVERROR(EINVAL); + goto fail; + } + + ret = av_sdp_create(avc, j, sdp, sizeof(sdp)); + if (ret < 0) + goto fail; + + if (!sdp_filename) { + printf("SDP:\n%s\n", sdp); + fflush(stdout); + } else { + ret = avio_open2(&sdp_pb, sdp_filename, AVIO_FLAG_WRITE, &int_cb, NULL); + if (ret < 0) { + av_log(NULL, AV_LOG_ERROR, "Failed to open sdp file '%s'\n", sdp_filename); + goto fail; + } + + avio_print(sdp_pb, sdp); + avio_closep(&sdp_pb); + av_freep(&sdp_filename); + } + + // SDP successfully written, allow muxer threads to start + ret = 1; + +fail: + av_freep(&avc); + return ret; +} + /* open the muxer when all the streams are initialized */ int of_check_init(OutputFile *of) { From patchwork Sat Jul 23 14:09:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 36913 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp1047502pzb; Sat, 23 Jul 2022 07:12:29 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sYNvO5AFiB/F/xYkdaGYFQoiMqHkZp07ABedM349kfnml9AdujBuPMxhvgzLxgVBWKBMIb X-Received: by 2002:a17:906:9b8b:b0:72b:13f6:8957 with SMTP id dd11-20020a1709069b8b00b0072b13f68957mr3569829ejc.239.1658585549204; Sat, 23 Jul 2022 07:12:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658585549; cv=none; d=google.com; s=arc-20160816; b=pkC5kFFOTJaeXDqoKKUv0WG5uVQg35UrwCQiagTG5MfcmySJnXimJ3rn8w7bhdCmks /3iX+4oDz7IMlZy/sVWNNRFuNP6MMafBR9Z874U5IvKpwiktnS9AVXJnYjo5QVru8sXy R69OUaqo3V9i1+ElY/3FLsLTDeGxeC9i+N6vwQQoNg/CpDm6c74xTGNmxzY6fnMIPIg+ QMpYuEMKB2WBIHMI2QXBSr8QY0UJ+a3CQG4w4XXbCBIfIqgS0AKzjtUba3U9LL2crNlg 5QHuLtSGXNLGBkdtbIa7lALnsWENfPjurioECJ+8lbewLwXdCrI1U0W3MHO8m8gDMCa8 Bhkg== 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=MQnVwqSf6WYudvRZvaik4jlLpbwSvsp2Xw5Ca9OAkb8=; b=NnlyH8Ct/cfKIomho7ChB9eXVWntxodzrkHgwBya3cpynTG6t+b3bUJtyCSAKc9WcR UqyUgXP2FpfuxcPbbqlZvK9IfF0fsybBXbWl2HW6h8Yxp3EdnccOTMrFupXnzkvsQ8Tq JJjamcEdKoRCRy01dRbvpTfhgDVz6DwCSZev0Ol/tINPC6XlY6+w0R2U2UGHXwhfwfMY 8gTt0np4Vo5DLakC1QHTZYVyri0jzpsf2abjqMeVAHIv0qOXNHBpTO5QUVDaoLFkiDLq E0+0VMmbxiWHacHFMcXgGYaOoAiMeGdTliSQjuyP0hKQdwpZA2YlI51CG4XgvwyvWITf Eh4w== 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 sy13-20020a1709076f0d00b00718c2c40965si8760221ejc.436.2022.07.23.07.12.28; Sat, 23 Jul 2022 07:12:29 -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 4BB5968B777; Sat, 23 Jul 2022 17:10:41 +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 8950D68B7DB for ; Sat, 23 Jul 2022 17:10:28 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 070B0240179 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 mWxQgw_jHub1 for ; Sat, 23 Jul 2022 16:10:26 +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 C7E5924068C for ; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 9AF083A04DA; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 23 Jul 2022 16:09:42 +0200 Message-Id: <20220723140952.31814-17-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 17/27] fftools/ffmpeg: do not log to the decoder context 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: Ls2gOd5DJY89 That should only be done from inside the decoder. Log to NULL instead, as is the current convention in ffmpeg. --- fftools/ffmpeg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 19173c75e1..cc0ede8a54 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -259,7 +259,7 @@ void sub2video_update(InputStream *ist, int64_t heartbeat_pts, AVSubtitle *sub) num_rects = 0; } if (sub2video_get_blank_frame(ist) < 0) { - av_log(ist->dec_ctx, AV_LOG_ERROR, + av_log(NULL, AV_LOG_ERROR, "Impossible to get a blank canvas.\n"); return; } @@ -2324,7 +2324,7 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output, end = av_rescale(subtitle.pts - ist->prev_sub.subtitle.pts, 1000, AV_TIME_BASE); if (end < ist->prev_sub.subtitle.end_display_time) { - av_log(ist->dec_ctx, AV_LOG_DEBUG, + av_log(NULL, AV_LOG_DEBUG, "Subtitle duration reduced from %"PRId32" to %d%s\n", ist->prev_sub.subtitle.end_display_time, end, end <= 0 ? ", dropping it" : ""); From patchwork Sat Jul 23 14:09:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 36912 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp1047435pzb; Sat, 23 Jul 2022 07:12:20 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sNaaq/aUcb9DdICdubLjC45YOprfX/lBbefuH+xzbRX4JI/83CG2Dlq1dESS9lTSBTs/n2 X-Received: by 2002:a17:907:2723:b0:72b:5af3:5a11 with SMTP id d3-20020a170907272300b0072b5af35a11mr3594557ejl.584.1658585539971; Sat, 23 Jul 2022 07:12:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658585539; cv=none; d=google.com; s=arc-20160816; b=VGezAxVMV+52t+xNAojIZeqcRDxpZrz/IaZfIcP0nPD15C0Id+hhPzB+30uBbLC+iS 4XVRtL/AXPVjZY0C651ybhnwDdAliAYzzkMs/vb1RneETzSTDOUKT7yXAus+OzRr4juC aimVwJ/sutGRaHi8C7TyT5dA6HH4q7lzSNk+75dUy6NWELvrpG9YBlhtCmRSH9yyU3ww pAgecV7ID4O0gOTtMZgxzxaHvmvR8YFuJQTuE0XxFAOcnwBT7hehalVnhunDaOR491q3 3+s2lhrB3Mf7CQZLW5y386ZMnEPS9LU8/epA8jFXPHyMl8qPXVCZcemyrB+mUEEDoAXr FhTw== 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=iZTPI4b9Y7DowVj0cJ05NCUk3u1IHQfhYa2C59kh9rA=; b=ihbQNnoRpPknvmXREDJOxtz6kwnuU9fyxJnWNqah69hLe/4tQDfxPL6V/Uw/HZ8SbU RrX+tZlGvBv+nIUDWRCyvG8nkS2e+9UsDaMkIPH+Zh04GIf0Cv1uDxDJKaQM4UhnSyhZ w5fiQqcz3DJjgtyCHmpcViu1IqZMcGrMSKseP413fGsXciaYNiFu+52elOsb/KlKSXhG aQSoS6WcesbINdmCZ4MJ5De0SAbZierjjh8rpCBLg0PRHGs1U4GfTx41jVTw1PgQqMiV 43CPTglsD7H6uhZosivMr4eKU8Bhsmt24EiCdFbGgdtUY1Gh574ZulccgD5c8YLzMs7+ b84Q== 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 c10-20020aa7c74a000000b00435799ce323si7543268eds.190.2022.07.23.07.12.19; Sat, 23 Jul 2022 07:12:19 -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 3050868B8A4; Sat, 23 Jul 2022 17:10:40 +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 895E768B7DC for ; Sat, 23 Jul 2022 17:10:28 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 5F33424017E 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 SPNEiMTnucVk for ; Sat, 23 Jul 2022 16:10:26 +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 BED16240687 for ; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 9FBCD3A03E5; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 23 Jul 2022 16:09:43 +0200 Message-Id: <20220723140952.31814-18-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 18/27] fftools/ffmpeg_opt: factor auto-mapping video out of open_output_file() 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: FqBQH+1Lvr7w --- fftools/ffmpeg_opt.c | 84 ++++++++++++++++++++++++-------------------- 1 file changed, 46 insertions(+), 38 deletions(-) diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index e6f2fb597a..4d2cd13107 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -2495,6 +2495,50 @@ static int setup_sync_queues(OutputFile *of, AVFormatContext *oc, int64_t buf_si return 0; } +static void map_auto_video(OutputFile *of, AVFormatContext *oc, + OptionsContext *o) +{ + InputStream *ist; + + /* video: highest resolution */ + if (av_guess_codec(oc->oformat, NULL, oc->url, NULL, AVMEDIA_TYPE_VIDEO) != AV_CODEC_ID_NONE) { + int best_score = 0, idx = -1; + int qcr = avformat_query_codec(oc->oformat, oc->oformat->video_codec, 0); + for (int j = 0; j < nb_input_files; j++) { + InputFile *ifile = input_files[j]; + int file_best_score = 0, file_best_idx = -1; + for (int i = 0; i < ifile->nb_streams; i++) { + int score; + ist = input_streams[ifile->ist_index + i]; + score = ist->st->codecpar->width * ist->st->codecpar->height + + 100000000 * !!(ist->st->event_flags & AVSTREAM_EVENT_FLAG_NEW_PACKETS) + + 5000000*!!(ist->st->disposition & AV_DISPOSITION_DEFAULT); + if (ist->user_set_discard == AVDISCARD_ALL) + continue; + if((qcr!=MKTAG('A', 'P', 'I', 'C')) && (ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC)) + score = 1; + if (ist->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && + score > file_best_score) { + if((qcr==MKTAG('A', 'P', 'I', 'C')) && !(ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC)) + continue; + file_best_score = score; + file_best_idx = ifile->ist_index + i; + } + } + if (file_best_idx >= 0) { + if((qcr == MKTAG('A', 'P', 'I', 'C')) || !(ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC)) + file_best_score -= 5000000*!!(input_streams[file_best_idx]->st->disposition & AV_DISPOSITION_DEFAULT); + if (file_best_score > best_score) { + best_score = file_best_score; + idx = file_best_idx; + } + } + } + if (idx >= 0) + new_video_stream(o, oc, idx); + } +} + static int open_output_file(OptionsContext *o, const char *filename) { AVFormatContext *oc; @@ -2573,44 +2617,8 @@ static int open_output_file(OptionsContext *o, const char *filename) if (!o->nb_stream_maps) { char *subtitle_codec_name = NULL; /* pick the "best" stream of each type */ - - /* video: highest resolution */ - if (!o->video_disable && av_guess_codec(oc->oformat, NULL, filename, NULL, AVMEDIA_TYPE_VIDEO) != AV_CODEC_ID_NONE) { - int best_score = 0, idx = -1; - int qcr = avformat_query_codec(oc->oformat, oc->oformat->video_codec, 0); - for (j = 0; j < nb_input_files; j++) { - InputFile *ifile = input_files[j]; - int file_best_score = 0, file_best_idx = -1; - for (i = 0; i < ifile->nb_streams; i++) { - int score; - ist = input_streams[ifile->ist_index + i]; - score = ist->st->codecpar->width * ist->st->codecpar->height - + 100000000 * !!(ist->st->event_flags & AVSTREAM_EVENT_FLAG_NEW_PACKETS) - + 5000000*!!(ist->st->disposition & AV_DISPOSITION_DEFAULT); - if (ist->user_set_discard == AVDISCARD_ALL) - continue; - if((qcr!=MKTAG('A', 'P', 'I', 'C')) && (ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC)) - score = 1; - if (ist->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && - score > file_best_score) { - if((qcr==MKTAG('A', 'P', 'I', 'C')) && !(ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC)) - continue; - file_best_score = score; - file_best_idx = ifile->ist_index + i; - } - } - if (file_best_idx >= 0) { - if((qcr == MKTAG('A', 'P', 'I', 'C')) || !(ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC)) - file_best_score -= 5000000*!!(input_streams[file_best_idx]->st->disposition & AV_DISPOSITION_DEFAULT); - if (file_best_score > best_score) { - best_score = file_best_score; - idx = file_best_idx; - } - } - } - if (idx >= 0) - new_video_stream(o, oc, idx); - } + if (!o->video_disable) + map_auto_video(of, oc, o); /* audio: most channels */ if (!o->audio_disable && av_guess_codec(oc->oformat, NULL, filename, NULL, AVMEDIA_TYPE_AUDIO) != AV_CODEC_ID_NONE) { From patchwork Sat Jul 23 14:09:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 36931 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a9d:f07:0:b0:61c:acf1:bf6b with SMTP id 7csp644890ott; Sat, 23 Jul 2022 07:14:22 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s8xxx18fNnqXq15EenypOp4WnjxD34nHuNra3IXucyA+GhMn0jDfLLYjrhd/pQejQ+h77k X-Received: by 2002:a17:906:3f51:b0:712:3945:8c0d with SMTP id f17-20020a1709063f5100b0071239458c0dmr3547865ejj.302.1658585661796; Sat, 23 Jul 2022 07:14:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658585661; cv=none; d=google.com; s=arc-20160816; b=NkrDky6zTl7+Tp+bNeCCTuSsoZNRuQBqgY4iQ01v2zbLIafpKYKOvAzfRq6557S3dJ ucNykB9jX03TdR1kK9wfkyvjYtQI0EmD+gytRsZA+QAqNUCGE/9+gVyb2CqJwMMnTEfc 1l+qMtjq+rMBD/DWs7iLP9aCBZttb1ki1I33bjsm0uNXnRd47o46a2bm4jFgKDXuB6Tf OWqYStrrl1p/QFOKDoJcIgcM9If5+It4xHfbC6taOiwOrks2S/OWAIifkFsDty4wEg9w KJhTylaJ58bfDux1TfjIYVPTdTDmmJ28Q6nVsWQzqWTErRbNtJN1i8BcbMixkHitmYLl Fd8w== 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=tTqJt57s8HQK+d7O9ATUxfEXh5XTVmqg3T1/efYICAQ=; b=Sd541ceX/HJUMKV83fxAkTHBJzEUKbUBM233Tm1NP1UIrUPbJGA/tUShf1ySYSCzAl gv3oOQ3vzj8GlSAaM0HAW48VfM8hbnyVsH9LmttaFuWfKmXCW+E7pDKV7TXvtPegMOOT u7wm5PVno7AZON6IBdOXT9goQ9BY3mqw0yZlLCpMKGdIi2WstPOGvUU1m8GSNIuLf2Y6 MTfl13NPb8UUECVSkmiNCGr9Us+/9xi1Cnz62/9kt7ieCRTwG3T3IHkZYMNgfBxQ+RWg bOxvTQikKsE1YZ4+Fhgrnw9ZXsu71HOp3Iz7UL7ZdPn5tBZReR2fqJpUULVCLjyUxHOs 0YYA== 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 ev7-20020a17090729c700b00726d6cb0258si7346161ejc.263.2022.07.23.07.14.21; Sat, 23 Jul 2022 07:14:21 -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 C719F68B90A; Sat, 23 Jul 2022 17:10:52 +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 941E468B852 for ; Sat, 23 Jul 2022 17:10:27 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 6EA3B24055A for ; Sat, 23 Jul 2022 16:10:24 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id wAa-dNCpCASO for ; Sat, 23 Jul 2022 16:10:23 +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 8DC8224052D for ; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id A48123A04EA; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 23 Jul 2022 16:09:44 +0200 Message-Id: <20220723140952.31814-19-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 19/27] fftools/ffmpeg_opt: reduce indentation in map_auto_video() 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: Pvca2ilc/rQ+ Content-Length: 4925 Fix indentation after the previous commit. Also use an early return to save one extra indentation level. --- fftools/ffmpeg_opt.c | 72 +++++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 35 deletions(-) diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 4d2cd13107..9b08c68ec5 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -2499,44 +2499,46 @@ static void map_auto_video(OutputFile *of, AVFormatContext *oc, OptionsContext *o) { InputStream *ist; + int best_score = 0, idx = -1; + int qcr; - /* video: highest resolution */ - if (av_guess_codec(oc->oformat, NULL, oc->url, NULL, AVMEDIA_TYPE_VIDEO) != AV_CODEC_ID_NONE) { - int best_score = 0, idx = -1; - int qcr = avformat_query_codec(oc->oformat, oc->oformat->video_codec, 0); - for (int j = 0; j < nb_input_files; j++) { - InputFile *ifile = input_files[j]; - int file_best_score = 0, file_best_idx = -1; - for (int i = 0; i < ifile->nb_streams; i++) { - int score; - ist = input_streams[ifile->ist_index + i]; - score = ist->st->codecpar->width * ist->st->codecpar->height - + 100000000 * !!(ist->st->event_flags & AVSTREAM_EVENT_FLAG_NEW_PACKETS) - + 5000000*!!(ist->st->disposition & AV_DISPOSITION_DEFAULT); - if (ist->user_set_discard == AVDISCARD_ALL) - continue; - if((qcr!=MKTAG('A', 'P', 'I', 'C')) && (ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC)) - score = 1; - if (ist->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && - score > file_best_score) { - if((qcr==MKTAG('A', 'P', 'I', 'C')) && !(ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC)) - continue; - file_best_score = score; - file_best_idx = ifile->ist_index + i; - } - } - if (file_best_idx >= 0) { - if((qcr == MKTAG('A', 'P', 'I', 'C')) || !(ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC)) - file_best_score -= 5000000*!!(input_streams[file_best_idx]->st->disposition & AV_DISPOSITION_DEFAULT); - if (file_best_score > best_score) { - best_score = file_best_score; - idx = file_best_idx; - } - } + /* video: highest resolution */ + if (av_guess_codec(oc->oformat, NULL, oc->url, NULL, AVMEDIA_TYPE_VIDEO) == AV_CODEC_ID_NONE) + return; + + qcr = avformat_query_codec(oc->oformat, oc->oformat->video_codec, 0); + for (int j = 0; j < nb_input_files; j++) { + InputFile *ifile = input_files[j]; + int file_best_score = 0, file_best_idx = -1; + for (int i = 0; i < ifile->nb_streams; i++) { + int score; + ist = input_streams[ifile->ist_index + i]; + score = ist->st->codecpar->width * ist->st->codecpar->height + + 100000000 * !!(ist->st->event_flags & AVSTREAM_EVENT_FLAG_NEW_PACKETS) + + 5000000*!!(ist->st->disposition & AV_DISPOSITION_DEFAULT); + if (ist->user_set_discard == AVDISCARD_ALL) + continue; + if((qcr!=MKTAG('A', 'P', 'I', 'C')) && (ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC)) + score = 1; + if (ist->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && + score > file_best_score) { + if((qcr==MKTAG('A', 'P', 'I', 'C')) && !(ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC)) + continue; + file_best_score = score; + file_best_idx = ifile->ist_index + i; } - if (idx >= 0) - new_video_stream(o, oc, idx); } + if (file_best_idx >= 0) { + if((qcr == MKTAG('A', 'P', 'I', 'C')) || !(ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC)) + file_best_score -= 5000000*!!(input_streams[file_best_idx]->st->disposition & AV_DISPOSITION_DEFAULT); + if (file_best_score > best_score) { + best_score = file_best_score; + idx = file_best_idx; + } + } + } + if (idx >= 0) + new_video_stream(o, oc, idx); } static int open_output_file(OptionsContext *o, const char *filename) From patchwork Sat Jul 23 14:09:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 36905 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp1046842pzb; Sat, 23 Jul 2022 07:11:18 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vti+oeIslQhIBT7YQ6iYIcBLLk4/0iornfU78/52q2zAFwHfWsmQqYrVXKXjUUoVs6TV71 X-Received: by 2002:a17:907:1b0e:b0:72f:9b43:b98c with SMTP id mp14-20020a1709071b0e00b0072f9b43b98cmr3714721ejc.710.1658585478343; Sat, 23 Jul 2022 07:11:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658585478; cv=none; d=google.com; s=arc-20160816; b=Sr1zHd0LOy9iIJmEzFOr39AApVLzS/1wO1DGH0K8lfecTWWc6bVy3WRLo9CUy+ZKFo us8XRBGr3+9DQnvBZxDLNcszA1KxsWAoz6YxyMYhCQTV3toS7ROm6w2OxL2VoP8s8pWa 9s08oTvPepSvauJJN11xBUzj+BJWS5ehL8/XvrfF6miH/QtMBH/qZXdNgfk9/JXwKnaE WXYUSwwTgpSuB/0i1iEDJusJBos1WGMKnDG7y33C9cALF1u5HjPGunoWXUsZhb3B5luR 8qHjWtu+pwixoSRfiqnL2xSYBN3uNXYlfphgBv/rmkqaCmevlp/MgIRF2Gg1xcOPNWh9 R/qQ== 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=6M4ZGC2V/CGXyr/0hxVhHoZAFxLXXHoHRhtkFu61JZI=; b=YyXoUJQ7Wx0BJ01EzaP3HYU4W8Ml9vNoh7wImi0U06/r8wLuuccoV+jUzYivra0C9P z3G4qxApT3PETnqdAJ+uGLzUuEin3NMN9lOPaIvnacxr4ZCCHxamNcyaP433psz/aLml oOx1Rx+39Fh7iKiEHdj8hjonsGfP/BFdPAmGM3wkSsZiTH5DyjqcTBU1n0htIl3WFxSz QM8uAHEY5iUO+lOLeK9sff0tsF7BGFA8eEBiBhwt8HO/W0F1H53HIEmWFRgfIevvGlg9 Gm+6d8lfVcSQItNH8neOsQGbcAlf1eflVh+fx+Zzncgh/V0N7B1fqLrSFtrrNh4zMIAD 1ZQw== 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 jj24-20020a170907985800b0072b3a923e6csi7662141ejc.974.2022.07.23.07.11.17; Sat, 23 Jul 2022 07:11:18 -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 01EA368B852; Sat, 23 Jul 2022 17:10:33 +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 D032B68B779 for ; Sat, 23 Jul 2022 17:10:27 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 941F024052D for ; Sat, 23 Jul 2022 16:10:24 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id MHx3g-qkggUD for ; Sat, 23 Jul 2022 16:10:24 +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 9E14524056A for ; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id A933B3A03EE; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 23 Jul 2022 16:09:45 +0200 Message-Id: <20220723140952.31814-20-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 20/27] fftools/ffmpeg_opt: factor auto-mapping audio out of open_output_file() 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: H5SbuP5mhEuM --- fftools/ffmpeg_opt.c | 71 +++++++++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 31 deletions(-) diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 9b08c68ec5..e426768f7c 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -2541,6 +2541,44 @@ static void map_auto_video(OutputFile *of, AVFormatContext *oc, new_video_stream(o, oc, idx); } +static void map_auto_audio(OutputFile *of, AVFormatContext *oc, + OptionsContext *o) +{ + InputStream *ist; + + /* audio: most channels */ + if (av_guess_codec(oc->oformat, NULL, oc->url, NULL, AVMEDIA_TYPE_AUDIO) != AV_CODEC_ID_NONE) { + int best_score = 0, idx = -1; + for (int j = 0; j < nb_input_files; j++) { + InputFile *ifile = input_files[j]; + int file_best_score = 0, file_best_idx = -1; + for (int i = 0; i < ifile->nb_streams; i++) { + int score; + ist = input_streams[ifile->ist_index + i]; + score = ist->st->codecpar->ch_layout.nb_channels + + 100000000 * !!(ist->st->event_flags & AVSTREAM_EVENT_FLAG_NEW_PACKETS) + + 5000000*!!(ist->st->disposition & AV_DISPOSITION_DEFAULT); + if (ist->user_set_discard == AVDISCARD_ALL) + continue; + if (ist->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && + score > file_best_score) { + file_best_score = score; + file_best_idx = ifile->ist_index + i; + } + } + if (file_best_idx >= 0) { + file_best_score -= 5000000*!!(input_streams[file_best_idx]->st->disposition & AV_DISPOSITION_DEFAULT); + if (file_best_score > best_score) { + best_score = file_best_score; + idx = file_best_idx; + } + } + } + if (idx >= 0) + new_audio_stream(o, oc, idx); + } +} + static int open_output_file(OptionsContext *o, const char *filename) { AVFormatContext *oc; @@ -2621,38 +2659,9 @@ static int open_output_file(OptionsContext *o, const char *filename) /* pick the "best" stream of each type */ if (!o->video_disable) map_auto_video(of, oc, o); + if (!o->audio_disable) + map_auto_audio(of, oc, o); - /* audio: most channels */ - if (!o->audio_disable && av_guess_codec(oc->oformat, NULL, filename, NULL, AVMEDIA_TYPE_AUDIO) != AV_CODEC_ID_NONE) { - int best_score = 0, idx = -1; - for (j = 0; j < nb_input_files; j++) { - InputFile *ifile = input_files[j]; - int file_best_score = 0, file_best_idx = -1; - for (i = 0; i < ifile->nb_streams; i++) { - int score; - ist = input_streams[ifile->ist_index + i]; - score = ist->st->codecpar->ch_layout.nb_channels - + 100000000 * !!(ist->st->event_flags & AVSTREAM_EVENT_FLAG_NEW_PACKETS) - + 5000000*!!(ist->st->disposition & AV_DISPOSITION_DEFAULT); - if (ist->user_set_discard == AVDISCARD_ALL) - continue; - if (ist->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && - score > file_best_score) { - file_best_score = score; - file_best_idx = ifile->ist_index + i; - } - } - if (file_best_idx >= 0) { - file_best_score -= 5000000*!!(input_streams[file_best_idx]->st->disposition & AV_DISPOSITION_DEFAULT); - if (file_best_score > best_score) { - best_score = file_best_score; - idx = file_best_idx; - } - } - } - if (idx >= 0) - new_audio_stream(o, oc, idx); - } /* subtitles: pick first */ MATCH_PER_TYPE_OPT(codec_names, str, subtitle_codec_name, oc, "s"); From patchwork Sat Jul 23 14:09:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 36917 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp1047770pzb; Sat, 23 Jul 2022 07:13:03 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t8UuNjHmSBedeQdUUKGO7rP4hmN7f7lIo9e1t0ncySyt9RYVlRmWihHZr/g38o82QYpIXK X-Received: by 2002:a05:6402:3685:b0:43b:dfd3:9487 with SMTP id ej5-20020a056402368500b0043bdfd39487mr2709917edb.32.1658585583684; Sat, 23 Jul 2022 07:13:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658585583; cv=none; d=google.com; s=arc-20160816; b=AWIreAsL/UCyfVmbSkCCxLg64QWoCmsaqP2iZMW/cH0ATSqNnJOAgatVpZG5HsWQ/3 FFkxRo1qo4LB/30xI6tlrHxNFDBPke0hX35pqxI/aFneE0bkmh1+3xKpk535V4U/VG6i or4Jpsb+E8Ltb5ZBC9oFx5H2AkhBpZnGGgHtCV5gJfG1zZvrvcLo/tdB0cmAl3+sF2wf CeEyz9RoFjV19F3f9X7Ay+F/1LHq9se7DKoTbD6OHmWkCe1FlbFg8ENs1Q5Qi8V1tlHd +oXv+6b6e0vEMPZBFiJ+6sVsCY7Ktu+xpNA2QIHLv3wFmzNCsp9FNWHK68aitYage0// kJkw== 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=1kr+ebT9aatdPg+7lECLFYH7npNSfpNzkmlXeWp/RBw=; b=PrxFFSBNHFm008Suz7r2fc1lPPWoRo67n2DAwVMTjLUFJ10ABtkCYp5eIBeuDPqJlg aZCbNZlQRKRUr6eLMWekyGT/hmirGE2ceUQGw56Nz1O5/WRdJmx0ySLsWZfrdHmQA9xG LrcL5z+piXjsAx27rek6luTdnPnO5nZLQkqqTv5514x5Gtcvmw98me2ki+tcFtkQeuuU noB4kVchn4Qrs6Ytw4H3R1h7Ml9hr8L57eZNTS7QIlAHRjUw2VkhCYz9Xwyi0hIXNSCU AkMj+iFpYP0/1VjN8bNhKYy64Qju5OGxnW1WG2WXK3kGpxySx3Oq/iikrJBOTlg8Ug3w KaYw== 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 y37-20020a50bb28000000b0043bbe1d01e2si9852683ede.410.2022.07.23.07.13.03; Sat, 23 Jul 2022 07:13:03 -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 6709168B7DF; Sat, 23 Jul 2022 17:10:44 +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 B0FF068B72C for ; Sat, 23 Jul 2022 17:10:28 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 2BAB6240590 for ; Sat, 23 Jul 2022 16:10:28 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id cmS6qViKysam 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 CA49B24068F for ; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id ADEAB3A0232; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 23 Jul 2022 16:09:46 +0200 Message-Id: <20220723140952.31814-21-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 21/27] fftools/ffmpeg_opt: reduce indentation in map_auto_audio() 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: ltQEsHVvI8KU Fix indentation after the previous commit. Also use an early return to save one extra indentation level. --- fftools/ffmpeg_opt.c | 57 ++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index e426768f7c..174b1dd0eb 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -2545,38 +2545,39 @@ static void map_auto_audio(OutputFile *of, AVFormatContext *oc, OptionsContext *o) { InputStream *ist; + int best_score = 0, idx = -1; /* audio: most channels */ - if (av_guess_codec(oc->oformat, NULL, oc->url, NULL, AVMEDIA_TYPE_AUDIO) != AV_CODEC_ID_NONE) { - int best_score = 0, idx = -1; - for (int j = 0; j < nb_input_files; j++) { - InputFile *ifile = input_files[j]; - int file_best_score = 0, file_best_idx = -1; - for (int i = 0; i < ifile->nb_streams; i++) { - int score; - ist = input_streams[ifile->ist_index + i]; - score = ist->st->codecpar->ch_layout.nb_channels - + 100000000 * !!(ist->st->event_flags & AVSTREAM_EVENT_FLAG_NEW_PACKETS) - + 5000000*!!(ist->st->disposition & AV_DISPOSITION_DEFAULT); - if (ist->user_set_discard == AVDISCARD_ALL) - continue; - if (ist->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && - score > file_best_score) { - file_best_score = score; - file_best_idx = ifile->ist_index + i; - } - } - if (file_best_idx >= 0) { - file_best_score -= 5000000*!!(input_streams[file_best_idx]->st->disposition & AV_DISPOSITION_DEFAULT); - if (file_best_score > best_score) { - best_score = file_best_score; - idx = file_best_idx; - } - } + if (av_guess_codec(oc->oformat, NULL, oc->url, NULL, AVMEDIA_TYPE_AUDIO) == AV_CODEC_ID_NONE) + return; + + for (int j = 0; j < nb_input_files; j++) { + InputFile *ifile = input_files[j]; + int file_best_score = 0, file_best_idx = -1; + for (int i = 0; i < ifile->nb_streams; i++) { + int score; + ist = input_streams[ifile->ist_index + i]; + score = ist->st->codecpar->ch_layout.nb_channels + + 100000000 * !!(ist->st->event_flags & AVSTREAM_EVENT_FLAG_NEW_PACKETS) + + 5000000*!!(ist->st->disposition & AV_DISPOSITION_DEFAULT); + if (ist->user_set_discard == AVDISCARD_ALL) + continue; + if (ist->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && + score > file_best_score) { + file_best_score = score; + file_best_idx = ifile->ist_index + i; } - if (idx >= 0) - new_audio_stream(o, oc, idx); } + if (file_best_idx >= 0) { + file_best_score -= 5000000*!!(input_streams[file_best_idx]->st->disposition & AV_DISPOSITION_DEFAULT); + if (file_best_score > best_score) { + best_score = file_best_score; + idx = file_best_idx; + } + } + } + if (idx >= 0) + new_audio_stream(o, oc, idx); } static int open_output_file(OptionsContext *o, const char *filename) From patchwork Sat Jul 23 14:09:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 36906 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp1046940pzb; Sat, 23 Jul 2022 07:11:27 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t7wPt6/f2pXa7rmSlpuKWmV5IGZJf0kiHeed5EhjOXUh3wzYdL1IxpJ+fHTCH+lyf1JlIV X-Received: by 2002:a17:907:a0c7:b0:72f:b205:112 with SMTP id hw7-20020a170907a0c700b0072fb2050112mr3559108ejc.559.1658585487367; Sat, 23 Jul 2022 07:11:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658585487; cv=none; d=google.com; s=arc-20160816; b=u8+JkrBmhfB70yTLJrPwsbnK2JHGS7PThEaJ80TUMkPf7r2gPpzHoLTQJfq3jmUqRf 87OGmKAVvMUjo8ERcMREVgewhs9XAS4n8UBumtp+Ef3eCzYJbGcMkUQB9OksdbolYnGU l5rmeIBj4+g/3fPn8uUYcK3IbAkBD4uBI1kJxEfVpd5xDxm8mSjO4BJ5ckPpvPHMHHsK M2eXD2qV9uT7sjxoZ5C9fe/0n5MT4r0KvbLZSbJcJY3wkHlY7lrOiM9aAqUCPMrlDE6p crTYn4xOjXvunPIn4/g0CcGun+VB4S4BDHNnCUOYItm8UzIvR0ix84CmlxFon0tq6qTG 48tw== 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=+wkBUizy7P+aDaKf8c4j9Av7mpHt5jIHZTiCh+QDh+Y=; b=wii5oUGHVv4KjQgFyHHIPxOGfsOuEFw3n+bTcArT3Nclei2muiyNiReoxy/9zsOgRR ncOP2IX09GeMHLPlM2nOWGDJTK/Q9jXMss3TBiMM2MGIi9tC4BF+kxSoLm29b4FZfoO5 K5tjh7mOoasYIQ9NZyxyw36IVuaAB3Q/LqNMQk/ZsAHMTt9AGb+39hilN9Llmuc2Yrhm xrkxEQQhD0l1umWBoCJcyriKgKTEssw9CkQcTIWBlIFaArKa4BDiah1Akm+zR1bGE3t3 xpDFJCw83R3HmXhqmXk6LrJkKl7qp569LCZq0nEL5WM7trxUK/X0uOO+J1TrEa/RuBQV J5sQ== 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 b11-20020a0564021f0b00b0043bca6b19e3si5990952edb.609.2022.07.23.07.11.26; Sat, 23 Jul 2022 07:11:27 -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 DD77A68B74E; Sat, 23 Jul 2022 17:10:33 +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 D23DA68B7B5 for ; Sat, 23 Jul 2022 17:10:27 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id EF82E24056A for ; Sat, 23 Jul 2022 16:10:24 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id n5yplG66vKoV for ; Sat, 23 Jul 2022 16:10:24 +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 A3C93240590 for ; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id B27D43A03EF; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 23 Jul 2022 16:09:47 +0200 Message-Id: <20220723140952.31814-22-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 22/27] fftools/ffmpeg_opt: factor auto-mapping subtitles out of open_output_file() 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: aChot7EqYbH9 --- fftools/ffmpeg_opt.c | 70 ++++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 32 deletions(-) diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 174b1dd0eb..da74b0265a 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -2580,6 +2580,42 @@ static void map_auto_audio(OutputFile *of, AVFormatContext *oc, new_audio_stream(o, oc, idx); } +static void map_auto_subtitle(OutputFile *of, AVFormatContext *oc, + OptionsContext *o) +{ + 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; + } + } + } +} + static int open_output_file(OptionsContext *o, const char *filename) { AVFormatContext *oc; @@ -2656,44 +2692,14 @@ static int open_output_file(OptionsContext *o, const char *filename) } if (!o->nb_stream_maps) { - char *subtitle_codec_name = NULL; /* pick the "best" stream of each type */ if (!o->video_disable) map_auto_video(of, oc, o); if (!o->audio_disable) map_auto_audio(of, oc, o); + if (!o->subtitle_disable) + map_auto_subtitle(of, oc, o); - - /* subtitles: pick first */ - MATCH_PER_TYPE_OPT(codec_names, str, subtitle_codec_name, oc, "s"); - if (!o->subtitle_disable && (avcodec_find_encoder(oc->oformat->subtitle_codec) || subtitle_codec_name)) { - for (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; - } - } - } /* Data only if codec id match */ if (!o->data_disable ) { enum AVCodecID codec_id = av_guess_codec(oc->oformat, NULL, filename, NULL, AVMEDIA_TYPE_DATA); 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; + } } } From patchwork Sat Jul 23 14:09:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 36907 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp1047012pzb; Sat, 23 Jul 2022 07:11:36 -0700 (PDT) X-Google-Smtp-Source: AGRyM1veA8zfAexjxvEoURdi+/OSUU+xiH7NiXlpbzBgTp7l7QfFWi43nH5WqZKFg2fb6DNwt3Ul X-Received: by 2002:a17:907:3e03:b0:722:e694:438 with SMTP id hp3-20020a1709073e0300b00722e6940438mr3612642ejc.755.1658585495801; Sat, 23 Jul 2022 07:11:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658585495; cv=none; d=google.com; s=arc-20160816; b=VzD6GPGHsie2v0OYfa+RFKxotrU6zWxRj75vsOoMKypKI0g+jMYLiMBCw+WZBRn22M o6iflSidNcygYlZidOSGXemudE/Z6v38BCFOd9JuA2EB7k0yrGfwLdAkuEjny0Z/30nC seaxzFQ3IO0NUx516jYcW2HdDO916vEDf9HMB6ry8LsL8e4i06Ftv4oQUYJ0P8M+hx3k 4T8T6B/NK8ynK/CKL+uhxu8VnA0Gt5txpv5wlRQ+qvidDl2blS2UTLXpI5CGT43g+oTI QQ/fAXTxuFoDajLA2mXBaDiXHb3MdCj2/AImKf7A+vzTE42tTkqd5Y/crXw0/zLifTmZ 1dbw== 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=Qs5OPJeTBc2xg8stPA+l7WuqFwjxH+3WNXq6BtDmOJg=; b=HZfrv4tbh8MyGDk1xwUjnGAQQF8lU81scAxduIH65+VK9TGiALE5yA8xRk+gniUbCY CKzbjMndTxWfHGcYWJEiYFwNqSaMBzCzChoCdU1d3jKSJR54IOnHe9+WnbSSMSdn0Aos Ylubn4U5lAo+CXe8OWX1ziZwTTPGiM1u6unQJ1yBZD5zyd+efmVzvxit7NPXV4D8ZvsO z29qEPiRDQ7f44E5daIrxKJZqKqCjYgMtNgm+iV+ApxARBrbQnFEiasLAePgaPIPfwMF jO+FFw1RBz8TzieEe1yWq1iNYBinViVYSnay73DmtyeGfUgs3NqF9jrrfF0Qmui538Go 2IwA== 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 eq5-20020a056402298500b0043a90a31070si7264910edb.284.2022.07.23.07.11.35; Sat, 23 Jul 2022 07:11:35 -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 F37EC68B870; Sat, 23 Jul 2022 17:10:34 +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 4B83068B7CF for ; Sat, 23 Jul 2022 17:10:28 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 7A116240593 for ; Sat, 23 Jul 2022 16:10:25 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id hM8dOVXoDrHa for ; Sat, 23 Jul 2022 16:10:25 +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 AF2322405F5 for ; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id BB91C3A03D8; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 23 Jul 2022 16:09:49 +0200 Message-Id: <20220723140952.31814-24-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 24/27] fftools/ffmpeg_opt: factor auto-mapping data streams out of open_output_file() 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: Wc7BtrIbtTgp --- fftools/ffmpeg_opt.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 04f4abb88a..287527f478 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -2618,6 +2618,20 @@ static void map_auto_subtitle(OutputFile *of, AVFormatContext *oc, } } +static void map_auto_data(OutputFile *of, AVFormatContext *oc, + OptionsContext *o) +{ + /* Data only if codec id match */ + enum AVCodecID codec_id = av_guess_codec(oc->oformat, NULL, oc->url, NULL, AVMEDIA_TYPE_DATA); + for (int i = 0; codec_id != AV_CODEC_ID_NONE && i < nb_input_streams; i++) { + if (input_streams[i]->user_set_discard == AVDISCARD_ALL) + continue; + if (input_streams[i]->st->codecpar->codec_type == AVMEDIA_TYPE_DATA + && input_streams[i]->st->codecpar->codec_id == codec_id ) + new_data_stream(o, oc, i); + } +} + static int open_output_file(OptionsContext *o, const char *filename) { AVFormatContext *oc; @@ -2701,18 +2715,8 @@ static int open_output_file(OptionsContext *o, const char *filename) map_auto_audio(of, oc, o); if (!o->subtitle_disable) map_auto_subtitle(of, oc, o); - - /* Data only if codec id match */ - if (!o->data_disable ) { - enum AVCodecID codec_id = av_guess_codec(oc->oformat, NULL, filename, NULL, AVMEDIA_TYPE_DATA); - for (i = 0; codec_id != AV_CODEC_ID_NONE && i < nb_input_streams; i++) { - if (input_streams[i]->user_set_discard == AVDISCARD_ALL) - continue; - if (input_streams[i]->st->codecpar->codec_type == AVMEDIA_TYPE_DATA - && input_streams[i]->st->codecpar->codec_id == codec_id ) - new_data_stream(o, oc, i); - } - } + if (!o->data_disable) + map_auto_data(of, oc, o); } else { for (i = 0; i < o->nb_stream_maps; i++) { StreamMap *map = &o->stream_maps[i]; From patchwork Sat Jul 23 14:09:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 36914 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp1047572pzb; Sat, 23 Jul 2022 07:12:37 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vh0ugLA99RLoMWDmUZ71G3vpPB2a+GNXQzpiYlcMUqOUQ6cZPHGbWQBL+9FA1j5hm1c0Xn X-Received: by 2002:a05:6402:4410:b0:434:f35f:132e with SMTP id y16-20020a056402441000b00434f35f132emr4609525eda.215.1658585557549; Sat, 23 Jul 2022 07:12:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658585557; cv=none; d=google.com; s=arc-20160816; b=bTe17wxjDwnHUQUgErI4bxYf1riQT5oOnKSEIk2c6ew66jPzlvr82TArz0Yq2y3/fc DtIDKLathMAVwAnQb+9CNMbZcfB1IZRh67BAa95GNYE8UF1W1nNOhuCfNY9AYMCxPi5y 0iox3cAWsZOlcliLugdnPVKiqr4Re8i0P6bxLHMTp5WlnzoIL7oAIXoi56/mm899MEcy De3km6aj9Z2NNRWgfXJj4PF60PrJX3tkQA9NRz8fsd8KceFNde/sUoLdZOJlRoUutXaC hDvYqYTtW197IFaqVTgFFBBTNt9BxGqLMutslaF/6MI2MSPlwRlt3T4GDnZWSRd5X1dX RYZg== 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=UHPchiWCqjqPdPVzQS3XvCfmqy68qFuAVB99m8L6sE8=; b=XslgSfwJd7q7RDXCVwTPAKsB80ylxFgUFMp5XWDHiSUXZZomX/8cwVBTAIvxcqwQlC YU/tmZQYB+wXDWl3cSgOJ8ZpT57B8iBFHwCTt6MFP9rRQ+RqCtj2cZJiiw0bjEbrOpuU 5MIr37qwIBvUOJTib3032Xa/qH5skJvXwloYMcPpWEgfKvMp408O5NA+pBKRjnG6cYz8 22dpQClEa7CwoznDZAUbltNvmj9uT3tEZc3W0GXUjos1CBpDURFcdf1etUpOauoKETvH D0AfDk7fc0cnjX43SOBsWjSwuyzGy0oxRfXBi9gwXiBJhCK1U98oMdj7cqvOT3ohvzFn To6A== 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 ga30-20020a1709070c1e00b0072f207e3abesi9453564ejc.783.2022.07.23.07.12.37; Sat, 23 Jul 2022 07:12:37 -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 396A168B8A3; Sat, 23 Jul 2022 17:10:42 +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 8794268B7D8 for ; Sat, 23 Jul 2022 17:10:28 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 884D82400F5 for ; Sat, 23 Jul 2022 16:10:26 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id pJCOEscxJIhr for ; Sat, 23 Jul 2022 16:10:25 +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 AE2E82405F0 for ; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id BDABA3A03A9; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 23 Jul 2022 16:09:50 +0200 Message-Id: <20220723140952.31814-25-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 25/27] fftools/ffmpeg_opt: reindent 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: EXh797xV3OEZ --- fftools/ffmpeg_opt.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 287527f478..a472b254cb 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -2621,15 +2621,15 @@ static void map_auto_subtitle(OutputFile *of, AVFormatContext *oc, static void map_auto_data(OutputFile *of, AVFormatContext *oc, OptionsContext *o) { - /* Data only if codec id match */ - enum AVCodecID codec_id = av_guess_codec(oc->oformat, NULL, oc->url, NULL, AVMEDIA_TYPE_DATA); - for (int i = 0; codec_id != AV_CODEC_ID_NONE && i < nb_input_streams; i++) { - if (input_streams[i]->user_set_discard == AVDISCARD_ALL) - continue; - if (input_streams[i]->st->codecpar->codec_type == AVMEDIA_TYPE_DATA - && input_streams[i]->st->codecpar->codec_id == codec_id ) - new_data_stream(o, oc, i); - } + /* Data only if codec id match */ + enum AVCodecID codec_id = av_guess_codec(oc->oformat, NULL, oc->url, NULL, AVMEDIA_TYPE_DATA); + for (int i = 0; codec_id != AV_CODEC_ID_NONE && i < nb_input_streams; i++) { + if (input_streams[i]->user_set_discard == AVDISCARD_ALL) + continue; + if (input_streams[i]->st->codecpar->codec_type == AVMEDIA_TYPE_DATA + && input_streams[i]->st->codecpar->codec_id == codec_id ) + new_data_stream(o, oc, i); + } } static int open_output_file(OptionsContext *o, const char *filename) From patchwork Sat Jul 23 14:09:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 36918 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp1047863pzb; Sat, 23 Jul 2022 07:13:13 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uW/6y0CXr8yNAk8cnKPuhY/SUdEH9S3WGf2+/qviQoixGFscpFppv1FzP/AIFiacaLx30H X-Received: by 2002:a17:907:948e:b0:72f:b536:57 with SMTP id dm14-20020a170907948e00b0072fb5360057mr3297068ejc.491.1658585593416; Sat, 23 Jul 2022 07:13:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658585593; cv=none; d=google.com; s=arc-20160816; b=aZRR8udFjllYk4k91TZJpE1FA+nRqkU4xQuwX1LAy96CaaVtFtyKtaqhDahVVYlMpA a5flQp6TTpsdAc0CZhyajIbMMc2J3dXvHhTlA1AyfsQ13wuNtsP8kdAlNvoKwo+y3hPu gFXMxu208Vk3ZYuVskuT4jTfOSdKws/khWJPRQ4ZhDDwpvisuhzXDV7OJNMTow3547aR Pv/W4wl1vtJ39ELhAlboiqh+rb9iZf5uINLsZ4uv4WvjSblHAuWCAntdR56OFUXBFwIS HBB4UuaPql8Yn9kEcTeeeHz7E7qveFBGIsgBgeGa2yGSf9cJsZPeaO4iHjsFFT2EcW+n qOrg== 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=pe5XubqL7IHnbMq9IHRnlpUVVJc18/cvQJlvMIPuadM=; b=TLA0WSmdW8cpxDbxTdzQwm7DgtRSjlBZsd2DvBi7vxUOgm67vh9HzIjsZs1SucPPCC 5ADSli6gYhkPIDmLqT3AGstQT8twJsSZpYfqZ2AJuhCN9E6GD/jwtFcx+flkdvjajpxn x4bMLYl6gKb4qyunynY7vzqI9oUQgLewIweWOyZml97dGUIrrdLm8ROpC0A4q+zib0/s 9YvSRQKRWIDXsPNm3M7WOlUqJFim3AijBxFl5olkzP8cOxCMLxsGD2OzB75g9BP0MCkT z5uNztmP6eOxD9sAdym8rnZrBfUxBcOo7ClesanI+fr2h92iBf2D2yjGKu4mKc7kZMuO Bg0g== 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 tk19-20020a170907c29300b007262b057924si5915454ejc.900.2022.07.23.07.13.11; Sat, 23 Jul 2022 07:13:13 -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 1ED2868B8CF; Sat, 23 Jul 2022 17:10:45 +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 619EC68B7CA for ; Sat, 23 Jul 2022 17:10:29 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id A42282400F5 for ; Sat, 23 Jul 2022 16:10:28 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id pPQ9EUwbx7Qd for ; Sat, 23 Jul 2022 16:10:28 +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 D6D8D240690 for ; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id C4A3D3A0449; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 23 Jul 2022 16:09:51 +0200 Message-Id: <20220723140952.31814-26-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 26/27] fftools/ffmpeg_opt: factor manually mapping streams out of open_output_file() 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: yCP9CCvK5F+M --- fftools/ffmpeg_opt.c | 157 ++++++++++++++++++++++--------------------- 1 file changed, 81 insertions(+), 76 deletions(-) diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index a472b254cb..672ac87b3e 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -2632,13 +2632,91 @@ static void map_auto_data(OutputFile *of, AVFormatContext *oc, } } +static void map_manual(OutputFile *of, AVFormatContext *oc, + OptionsContext *o, const StreamMap *map) +{ + InputStream *ist; + OutputStream *ost; + + if (map->disabled) + return; + + if (map->linklabel) { + FilterGraph *fg; + OutputFilter *ofilter = NULL; + int j, k; + + for (j = 0; j < nb_filtergraphs; j++) { + fg = filtergraphs[j]; + for (k = 0; k < fg->nb_outputs; k++) { + AVFilterInOut *out = fg->outputs[k]->out_tmp; + if (out && !strcmp(out->name, map->linklabel)) { + ofilter = fg->outputs[k]; + goto loop_end; + } + } + } +loop_end: + if (!ofilter) { + av_log(NULL, AV_LOG_FATAL, "Output with label '%s' does not exist " + "in any defined filter graph, or was already used elsewhere.\n", map->linklabel); + exit_program(1); + } + init_output_filter(ofilter, o, oc); + } else { + int src_idx = input_files[map->file_index]->ist_index + map->stream_index; + + ist = input_streams[input_files[map->file_index]->ist_index + map->stream_index]; + if (ist->user_set_discard == AVDISCARD_ALL) { + av_log(NULL, AV_LOG_FATAL, "Stream #%d:%d is disabled and cannot be mapped.\n", + map->file_index, map->stream_index); + exit_program(1); + } + if(o->subtitle_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) + return; + if(o-> audio_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) + return; + if(o-> video_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) + return; + if(o-> data_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_DATA) + return; + + ost = NULL; + switch (ist->st->codecpar->codec_type) { + case AVMEDIA_TYPE_VIDEO: ost = new_video_stream (o, oc, src_idx); break; + case AVMEDIA_TYPE_AUDIO: ost = new_audio_stream (o, oc, src_idx); break; + case AVMEDIA_TYPE_SUBTITLE: ost = new_subtitle_stream (o, oc, src_idx); break; + case AVMEDIA_TYPE_DATA: ost = new_data_stream (o, oc, src_idx); break; + case AVMEDIA_TYPE_ATTACHMENT: ost = new_attachment_stream(o, oc, src_idx); break; + case AVMEDIA_TYPE_UNKNOWN: + if (copy_unknown_streams) { + ost = new_unknown_stream (o, oc, src_idx); + break; + } + default: + av_log(NULL, ignore_unknown_streams ? AV_LOG_WARNING : AV_LOG_FATAL, + "Cannot map stream #%d:%d - unsupported type.\n", + map->file_index, map->stream_index); + if (!ignore_unknown_streams) { + av_log(NULL, AV_LOG_FATAL, + "If you want unsupported types ignored instead " + "of failing, please use the -ignore_unknown option\n" + "If you want them copied, please use -copy_unknown\n"); + exit_program(1); + } + } + if (ost) + ost->sync_ist = input_streams[ input_files[map->sync_file_index]->ist_index + + map->sync_stream_index]; + } +} + static int open_output_file(OptionsContext *o, const char *filename) { AVFormatContext *oc; int i, j, err; OutputFile *of; OutputStream *ost; - InputStream *ist; AVDictionary *unused_opts = NULL, *format_opts = NULL; const AVDictionaryEntry *e = NULL; @@ -2718,81 +2796,8 @@ static int open_output_file(OptionsContext *o, const char *filename) if (!o->data_disable) map_auto_data(of, oc, o); } else { - for (i = 0; i < o->nb_stream_maps; i++) { - StreamMap *map = &o->stream_maps[i]; - - if (map->disabled) - continue; - - if (map->linklabel) { - FilterGraph *fg; - OutputFilter *ofilter = NULL; - int j, k; - - for (j = 0; j < nb_filtergraphs; j++) { - fg = filtergraphs[j]; - for (k = 0; k < fg->nb_outputs; k++) { - AVFilterInOut *out = fg->outputs[k]->out_tmp; - if (out && !strcmp(out->name, map->linklabel)) { - ofilter = fg->outputs[k]; - goto loop_end; - } - } - } -loop_end: - if (!ofilter) { - av_log(NULL, AV_LOG_FATAL, "Output with label '%s' does not exist " - "in any defined filter graph, or was already used elsewhere.\n", map->linklabel); - exit_program(1); - } - init_output_filter(ofilter, o, oc); - } else { - int src_idx = input_files[map->file_index]->ist_index + map->stream_index; - - ist = input_streams[input_files[map->file_index]->ist_index + map->stream_index]; - if (ist->user_set_discard == AVDISCARD_ALL) { - av_log(NULL, AV_LOG_FATAL, "Stream #%d:%d is disabled and cannot be mapped.\n", - map->file_index, map->stream_index); - exit_program(1); - } - if(o->subtitle_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) - continue; - if(o-> audio_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) - continue; - if(o-> video_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) - continue; - if(o-> data_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_DATA) - continue; - - ost = NULL; - switch (ist->st->codecpar->codec_type) { - case AVMEDIA_TYPE_VIDEO: ost = new_video_stream (o, oc, src_idx); break; - case AVMEDIA_TYPE_AUDIO: ost = new_audio_stream (o, oc, src_idx); break; - case AVMEDIA_TYPE_SUBTITLE: ost = new_subtitle_stream (o, oc, src_idx); break; - case AVMEDIA_TYPE_DATA: ost = new_data_stream (o, oc, src_idx); break; - case AVMEDIA_TYPE_ATTACHMENT: ost = new_attachment_stream(o, oc, src_idx); break; - case AVMEDIA_TYPE_UNKNOWN: - if (copy_unknown_streams) { - ost = new_unknown_stream (o, oc, src_idx); - break; - } - default: - av_log(NULL, ignore_unknown_streams ? AV_LOG_WARNING : AV_LOG_FATAL, - "Cannot map stream #%d:%d - unsupported type.\n", - map->file_index, map->stream_index); - if (!ignore_unknown_streams) { - av_log(NULL, AV_LOG_FATAL, - "If you want unsupported types ignored instead " - "of failing, please use the -ignore_unknown option\n" - "If you want them copied, please use -copy_unknown\n"); - exit_program(1); - } - } - if (ost) - ost->sync_ist = input_streams[ input_files[map->sync_file_index]->ist_index - + map->sync_stream_index]; - } - } + for (int i = 0; i < o->nb_stream_maps; i++) + map_manual(of, oc, o, &o->stream_maps[i]); } /* handle attached files */ From patchwork Sat Jul 23 14:09:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 36910 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp1047245pzb; Sat, 23 Jul 2022 07:12:02 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s4eGu1TlpYQ88aBDXrXXOrOXfF0a3+YowRViPmR34NhUpfKvu/hh98LkMFD//MamyvKX5R X-Received: by 2002:a17:907:2cd4:b0:72b:7fa8:eafc with SMTP id hg20-20020a1709072cd400b0072b7fa8eafcmr3677587ejc.438.1658585522126; Sat, 23 Jul 2022 07:12:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658585522; cv=none; d=google.com; s=arc-20160816; b=XjbGbnXDGaupUEnJP0KuBQtPcK7p8NTZI5/QPsCfWylCNsuP9ssv7pb3dDE/iC/fNu KRJR/3W3grtkhXP5YTPwBmXqjb38XBp4amCmcaOcrDb5UVcoVNLayFoOhNBppIvqiUo3 mWD1SnGoAiSeYeSUrJ9zVABqOuAVBlLXGxILgQPQiRFqDOAuXkA5sAZoA/O+MyI9jJbc oShsVKFsdQ3XuI2TgAhJGVAoPnpo9TUViPj3S4vyYEy0L0Oy/qIRGKY5DO9ZJB2xLezI DI9ZV5aYKTtPuHOvxXNQuAWIn7Tp3NwU+UwqJja6dBHa5VZugsRGdroohkKtQk8lD4th SbeQ== 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=ZU4VzVnQaG0hQ7bl9/VzB23UDF+8pMYJaDrv7is7ssQ=; b=wzkWS6vlyv1U4qQqeZGiT14vYHAmG96rvVsFIj8AieVAox3kWXdG3POATG7ifuuD17 PrpCmT29/ZqdwP5kPpYPZsOGzYSIKBLRA2keU1u6AK2ELYeNp83TljYBYT9JZdDZofnV gJoU/QW6NVg49NpBQDN4NmsDHMPYMPh42yonR1AeOc9dZbkdmKNdUwst0gpJ8OevR5dO XfQ+ruuntMK3YiuK8AYUzqZFeq4ZuFUUdcvm6fvnqxMac3E9atTbzJ8PZo6nsQX0MYi0 CwVFiarxiIoD+86Do44cQBF+bBIJH+zz2hEAHPJgrRlL3j+/CBb1bUCTbY69EIK+zfmB ODUA== 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 h9-20020a1709070b0900b0072f2b3bdaa7si7130641ejl.359.2022.07.23.07.12.01; Sat, 23 Jul 2022 07:12:02 -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 20A0468B8A0; Sat, 23 Jul 2022 17:10:38 +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 50FA568B7D2 for ; Sat, 23 Jul 2022 17:10:28 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id D718D2405F5 for ; Sat, 23 Jul 2022 16:10:25 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id SkznOmePCRab for ; Sat, 23 Jul 2022 16:10:25 +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 AF63624062A for ; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id C9F0F3A0470; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 23 Jul 2022 16:09:52 +0200 Message-Id: <20220723140952.31814-27-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 27/27] fftools/ffmpeg_opt: reindent 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: EfHyNZMjBMLC --- fftools/ffmpeg_opt.c | 140 +++++++++++++++++++++---------------------- 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 672ac87b3e..d7049069f4 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -2635,80 +2635,80 @@ static void map_auto_data(OutputFile *of, AVFormatContext *oc, static void map_manual(OutputFile *of, AVFormatContext *oc, OptionsContext *o, const StreamMap *map) { - InputStream *ist; - OutputStream *ost; - - if (map->disabled) - return; - - if (map->linklabel) { - FilterGraph *fg; - OutputFilter *ofilter = NULL; - int j, k; - - for (j = 0; j < nb_filtergraphs; j++) { - fg = filtergraphs[j]; - for (k = 0; k < fg->nb_outputs; k++) { - AVFilterInOut *out = fg->outputs[k]->out_tmp; - if (out && !strcmp(out->name, map->linklabel)) { - ofilter = fg->outputs[k]; - goto loop_end; - } - } + InputStream *ist; + OutputStream *ost; + + if (map->disabled) + return; + + if (map->linklabel) { + FilterGraph *fg; + OutputFilter *ofilter = NULL; + int j, k; + + for (j = 0; j < nb_filtergraphs; j++) { + fg = filtergraphs[j]; + for (k = 0; k < fg->nb_outputs; k++) { + AVFilterInOut *out = fg->outputs[k]->out_tmp; + if (out && !strcmp(out->name, map->linklabel)) { + ofilter = fg->outputs[k]; + goto loop_end; } + } + } loop_end: - if (!ofilter) { - av_log(NULL, AV_LOG_FATAL, "Output with label '%s' does not exist " - "in any defined filter graph, or was already used elsewhere.\n", map->linklabel); - exit_program(1); - } - init_output_filter(ofilter, o, oc); - } else { - int src_idx = input_files[map->file_index]->ist_index + map->stream_index; + if (!ofilter) { + av_log(NULL, AV_LOG_FATAL, "Output with label '%s' does not exist " + "in any defined filter graph, or was already used elsewhere.\n", map->linklabel); + exit_program(1); + } + init_output_filter(ofilter, o, oc); + } else { + int src_idx = input_files[map->file_index]->ist_index + map->stream_index; - ist = input_streams[input_files[map->file_index]->ist_index + map->stream_index]; - if (ist->user_set_discard == AVDISCARD_ALL) { - av_log(NULL, AV_LOG_FATAL, "Stream #%d:%d is disabled and cannot be mapped.\n", - map->file_index, map->stream_index); - exit_program(1); - } - if(o->subtitle_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) - return; - if(o-> audio_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) - return; - if(o-> video_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) - return; - if(o-> data_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_DATA) - return; - - ost = NULL; - switch (ist->st->codecpar->codec_type) { - case AVMEDIA_TYPE_VIDEO: ost = new_video_stream (o, oc, src_idx); break; - case AVMEDIA_TYPE_AUDIO: ost = new_audio_stream (o, oc, src_idx); break; - case AVMEDIA_TYPE_SUBTITLE: ost = new_subtitle_stream (o, oc, src_idx); break; - case AVMEDIA_TYPE_DATA: ost = new_data_stream (o, oc, src_idx); break; - case AVMEDIA_TYPE_ATTACHMENT: ost = new_attachment_stream(o, oc, src_idx); break; - case AVMEDIA_TYPE_UNKNOWN: - if (copy_unknown_streams) { - ost = new_unknown_stream (o, oc, src_idx); - break; - } - default: - av_log(NULL, ignore_unknown_streams ? AV_LOG_WARNING : AV_LOG_FATAL, - "Cannot map stream #%d:%d - unsupported type.\n", - map->file_index, map->stream_index); - if (!ignore_unknown_streams) { - av_log(NULL, AV_LOG_FATAL, - "If you want unsupported types ignored instead " - "of failing, please use the -ignore_unknown option\n" - "If you want them copied, please use -copy_unknown\n"); - exit_program(1); - } - } - if (ost) - ost->sync_ist = input_streams[ input_files[map->sync_file_index]->ist_index - + map->sync_stream_index]; + ist = input_streams[input_files[map->file_index]->ist_index + map->stream_index]; + if (ist->user_set_discard == AVDISCARD_ALL) { + av_log(NULL, AV_LOG_FATAL, "Stream #%d:%d is disabled and cannot be mapped.\n", + map->file_index, map->stream_index); + exit_program(1); + } + if(o->subtitle_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) + return; + if(o-> audio_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) + return; + if(o-> video_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) + return; + if(o-> data_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_DATA) + return; + + ost = NULL; + switch (ist->st->codecpar->codec_type) { + case AVMEDIA_TYPE_VIDEO: ost = new_video_stream (o, oc, src_idx); break; + case AVMEDIA_TYPE_AUDIO: ost = new_audio_stream (o, oc, src_idx); break; + case AVMEDIA_TYPE_SUBTITLE: ost = new_subtitle_stream (o, oc, src_idx); break; + case AVMEDIA_TYPE_DATA: ost = new_data_stream (o, oc, src_idx); break; + case AVMEDIA_TYPE_ATTACHMENT: ost = new_attachment_stream(o, oc, src_idx); break; + case AVMEDIA_TYPE_UNKNOWN: + if (copy_unknown_streams) { + ost = new_unknown_stream (o, oc, src_idx); + break; + } + default: + av_log(NULL, ignore_unknown_streams ? AV_LOG_WARNING : AV_LOG_FATAL, + "Cannot map stream #%d:%d - unsupported type.\n", + map->file_index, map->stream_index); + if (!ignore_unknown_streams) { + av_log(NULL, AV_LOG_FATAL, + "If you want unsupported types ignored instead " + "of failing, please use the -ignore_unknown option\n" + "If you want them copied, please use -copy_unknown\n"); + exit_program(1); } + } + if (ost) + ost->sync_ist = input_streams[ input_files[map->sync_file_index]->ist_index + + map->sync_stream_index]; + } } static int open_output_file(OptionsContext *o, const char *filename)