From patchwork Mon Nov 14 15:13: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: 39272 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp2487707pzb; Mon, 14 Nov 2022 07:14:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf6b4XJLYtzeYOs9o/fFOSoSmdaY+IFavyRn/7Av4I4sXfRW9VyZYFXfrKAW9h5NearNh7tV X-Received: by 2002:a17:906:d9b:b0:7ae:acea:fca6 with SMTP id m27-20020a1709060d9b00b007aeaceafca6mr10739972eji.150.1668438873397; Mon, 14 Nov 2022 07:14:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668438873; cv=none; d=google.com; s=arc-20160816; b=Cz8oCPW0UR9TyUE4eroMUv7njexV9PXclK66ARTYUeLMrNBHFxcZ6moLN8QvCKudWz SuVndWLmlZqFaoNdAtN0wbGA+D+To4Rh3lSTqe8cVSLONLXt7OxfY0llmor2qLqnPI4O xwvl2ADvfjweWvlifDKr8kMRLjdHxkG24/B8yreKB7a7wt9ACx+lA72/+4Oo3EGkJhtT Pk4gs8Lgozhsdb6PQepDJKPnTsKQ/toHYNS7CPw/N6n0s7eNkcLHnBUlKdzUTBNmNSfn YvQggsVt0drJaQMkN/8uPeqvaChw5IY3Uqf0CXdXHnsXvpDfn9PA6LZephMRcuQj7Oxl aScQ== 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=czILdh/59YFqnxN617daqXzp2YsO09FghjmXabO94AU=; b=L7+nFTM04stAyot+xO1DO/LY03FKZ3RxQplYNlzVE1u4m613xnWCDZoVYWLUboFs/z /7POHfCBy/d2LeH0jQazR/Suaib36H0sg7mcICubfBX0FSGrUFaXP0Wnb769dkT9vimt en2pgBqkInH65cy4C94uOvjqDM75Q2R/lPZ5Y63mB0NoMRn46EdPc4Nxx4XbHYmfGKe/ u4ADXYkLfkPbw4AKLuJAbhRNbj0VkMZSRX/GfeKbNs2lEuDF9oTOZh57ugAwVKXG5SVo Mtk1CjcgfCrRgsZjqe+F+AoE9D9CqVi3BuDtz9te1E//m27YZHW2Mg7NVIhre4ikS7kd EhIQ== 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 g16-20020a1709065d1000b0079a9eed8c1bsi9030449ejt.894.2022.11.14.07.14.29; Mon, 14 Nov 2022 07:14:33 -0800 (PST) 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 E379268BE10; Mon, 14 Nov 2022 17:14:26 +0200 (EET) 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 BF9CE68BE0A for ; Mon, 14 Nov 2022 17:14:19 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 80CEE2406CA for ; Mon, 14 Nov 2022 16:14:19 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 9VYGHOEv6vJM for ; Mon, 14 Nov 2022 16:14:18 +0100 (CET) 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 E63EA2400F5 for ; Mon, 14 Nov 2022 16:14:18 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 8EE583A0212 for ; Mon, 14 Nov 2022 16:14:18 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Nov 2022 16:13:43 +0100 Message-Id: <20221114151350.5134-1-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/8] fftools/ffmpeg: simplify ost_iter() 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: y4VmmpX7INlU The inner loop never goes through more than 1 iteration, and so can be replaced by an if(). Found-by: Andreas Rheinhardt --- fftools/ffmpeg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index e6f6773f6a..0fa2fe8c52 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -612,7 +612,7 @@ static OutputStream *ost_iter(OutputStream *prev) for (; of_idx < nb_output_files; of_idx++) { OutputFile *of = output_files[of_idx]; - for (; ost_idx < of->nb_streams; ost_idx++) + if (ost_idx < of->nb_streams) return of->streams[ost_idx]; ost_idx = 0; From patchwork Mon Nov 14 15:13: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: 39277 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp2488562pzb; Mon, 14 Nov 2022 07:15:16 -0800 (PST) X-Google-Smtp-Source: AA0mqf6Y3LigRu4bfasHxN5VWIUOM4NsrOzAJeg1FveRPtfjg15CCaYm+xw49PAMWHjPoiTk98Dx X-Received: by 2002:a17:906:4113:b0:7aa:97c7:2bfe with SMTP id j19-20020a170906411300b007aa97c72bfemr10439309ejk.196.1668438916800; Mon, 14 Nov 2022 07:15:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668438916; cv=none; d=google.com; s=arc-20160816; b=OaCSntheMiZQCTsH5DSKVt8MLYDI7tKYwVjRGGx76QjCKQ8SXdvhUHi0dK6SUhKN5M 2nVOckw0rk1KZq9nmOavRAhdLwiLMZdz6fq/HK2IARv1FTSPlxH6glU2C69IzFXsiWYr /u8yEJKcapTWCM4enriM4woU0AisUT/6yB04TngY2EM1DTdmYn8IuPBTRx6uM6+9n6kh Zya5Fn8veGcsmjLShsVINhuamd3c7jpPrDsYXwU+NOWkKOXY07HRuXSR0HsMoi12ATe2 yMeB4RWdj15uMCNB6UmJsiz2zDUrzTvkEgXdbMjPyuPZHu8yw3vN44GN/JVdpKPJJJ0U W8TQ== 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=jo6PBmtSWPN5E8EVeKaG0nqUpCkfck9wN/RlQHq9uU4=; b=J4+DtODl2P/zK6gQfUOkRAhr7+9oe3r/6ZLDyQayCB78QDGB1U8wb3CawcDMsrqgd4 Lq64KDS+lzjv0warETiO6bVHTu4WpkUekmtfYvlKVHgdLfVjKJoPhUnptu/Ldt37ONdJ GWhknIoh5Z1HyFiPGxB0EiWy7tpYFR9M2y0Eb0QhCtiUr+6IJXrwFZP0XN4ei4ylsNdp OFZLtKoe4BtHlICuluWaG7lTSIhBpcM75UoS4D6HysQ7YJVwyeaMdjFVs0o4IG44nIr5 5vwRFOnPYXfSExWFJmRwq+/+G0vbyfVOoZ24O0WAMmLXFyLvOo4whdWOrr8Jap0Q0svl WNyw== 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 ga8-20020a1709070c0800b007adffbaa908si9899136ejc.916.2022.11.14.07.15.16; Mon, 14 Nov 2022 07:15:16 -0800 (PST) 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 B7DD268BE21; Mon, 14 Nov 2022 17:14:32 +0200 (EET) 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 032A768BE1E for ; Mon, 14 Nov 2022 17:14:25 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 9ADE5240591 for ; Mon, 14 Nov 2022 16:14:22 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id JuwwrumG9SJC for ; Mon, 14 Nov 2022 16:14:20 +0100 (CET) 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 146E82404F8 for ; Mon, 14 Nov 2022 16:14:19 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 9CEB43A02FD for ; Mon, 14 Nov 2022 16:14:18 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Nov 2022 16:13:44 +0100 Message-Id: <20221114151350.5134-2-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221114151350.5134-1-anton@khirnov.net> References: <20221114151350.5134-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/8] fftools/ffmpeg_mux_init: move more code from of_open() to create_streams() 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: g27S+aWdqPPz Specificaly, the of_add_attachments() call (which can add attachment streams to the output) and the check whether the output file contains any streams. They both logically belong in create_streams(). --- fftools/ffmpeg_mux_init.c | 99 ++++++++++++++++++++------------------- 1 file changed, 50 insertions(+), 49 deletions(-) diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 4755a2cc38..303bf25096 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -1062,8 +1062,50 @@ loop_end: } } +static void of_add_attachments(Muxer *mux, const OptionsContext *o) +{ + OutputStream *ost; + int err; + + for (int i = 0; i < o->nb_attachments; i++) { + AVIOContext *pb; + uint8_t *attachment; + const char *p; + int64_t len; + + if ((err = avio_open2(&pb, o->attachments[i], AVIO_FLAG_READ, &int_cb, NULL)) < 0) { + av_log(NULL, AV_LOG_FATAL, "Could not open attachment file %s.\n", + o->attachments[i]); + exit_program(1); + } + if ((len = avio_size(pb)) <= 0) { + av_log(NULL, AV_LOG_FATAL, "Could not get size of the attachment %s.\n", + o->attachments[i]); + exit_program(1); + } + if (len > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE || + !(attachment = av_malloc(len + AV_INPUT_BUFFER_PADDING_SIZE))) { + av_log(NULL, AV_LOG_FATAL, "Attachment %s too large.\n", + o->attachments[i]); + exit_program(1); + } + avio_read(pb, attachment, len); + memset(attachment + len, 0, AV_INPUT_BUFFER_PADDING_SIZE); + + ost = new_attachment_stream(mux, o, -1); + ost->attachment_filename = o->attachments[i]; + ost->st->codecpar->extradata = attachment; + ost->st->codecpar->extradata_size = len; + + p = strrchr(o->attachments[i], '/'); + av_dict_set(&ost->st->metadata, "filename", (p && *p) ? p + 1 : o->attachments[i], AV_DICT_DONT_OVERWRITE); + avio_closep(&pb); + } +} + static void create_streams(Muxer *mux, const OptionsContext *o) { + AVFormatContext *oc = mux->fc; int auto_disable_v = o->video_disable; int auto_disable_a = o->audio_disable; int auto_disable_s = o->subtitle_disable; @@ -1101,6 +1143,14 @@ static void create_streams(Muxer *mux, const OptionsContext *o) for (int i = 0; i < o->nb_stream_maps; i++) map_manual(mux, o, &o->stream_maps[i]); } + + of_add_attachments(mux, o); + + if (!oc->nb_streams && !(oc->oformat->flags & AVFMT_NOSTREAMS)) { + av_dump_format(oc, nb_output_files - 1, oc->url, 1); + av_log(NULL, AV_LOG_ERROR, "Output file #%d does not contain any stream\n", nb_output_files - 1); + exit_program(1); + } } static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, int64_t buf_size_us) @@ -1194,47 +1244,6 @@ static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, int64_t buf_size_u return 0; } -static void of_add_attachments(Muxer *mux, const OptionsContext *o) -{ - OutputStream *ost; - int err; - - for (int i = 0; i < o->nb_attachments; i++) { - AVIOContext *pb; - uint8_t *attachment; - const char *p; - int64_t len; - - if ((err = avio_open2(&pb, o->attachments[i], AVIO_FLAG_READ, &int_cb, NULL)) < 0) { - av_log(NULL, AV_LOG_FATAL, "Could not open attachment file %s.\n", - o->attachments[i]); - exit_program(1); - } - if ((len = avio_size(pb)) <= 0) { - av_log(NULL, AV_LOG_FATAL, "Could not get size of the attachment %s.\n", - o->attachments[i]); - exit_program(1); - } - if (len > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE || - !(attachment = av_malloc(len + AV_INPUT_BUFFER_PADDING_SIZE))) { - av_log(NULL, AV_LOG_FATAL, "Attachment %s too large.\n", - o->attachments[i]); - exit_program(1); - } - avio_read(pb, attachment, len); - memset(attachment + len, 0, AV_INPUT_BUFFER_PADDING_SIZE); - - ost = new_attachment_stream(mux, o, -1); - ost->attachment_filename = o->attachments[i]; - ost->st->codecpar->extradata = attachment; - ost->st->codecpar->extradata_size = len; - - p = strrchr(o->attachments[i], '/'); - av_dict_set(&ost->st->metadata, "filename", (p && *p) ? p + 1 : o->attachments[i], AV_DICT_DONT_OVERWRITE); - avio_closep(&pb); - } -} - static void of_add_programs(AVFormatContext *oc, const OptionsContext *o) { /* process manually set programs */ @@ -1782,14 +1791,6 @@ int of_open(const OptionsContext *o, const char *filename) /* create all output streams for this file */ create_streams(mux, o); - of_add_attachments(mux, o); - - if (!oc->nb_streams && !(oc->oformat->flags & AVFMT_NOSTREAMS)) { - av_dump_format(oc, nb_output_files - 1, oc->url, 1); - av_log(NULL, AV_LOG_ERROR, "Output file #%d does not contain any stream\n", nb_output_files - 1); - exit_program(1); - } - /* check if all codec options have been used */ unused_opts = strip_specifiers(o->g->codec_opts); for (int i = 0; i < of->nb_streams; i++) { From patchwork Mon Nov 14 15:13: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: 39275 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp2487937pzb; Mon, 14 Nov 2022 07:14:57 -0800 (PST) X-Google-Smtp-Source: AA0mqf6sZbHFvoiXLArHRmPS5qWc773X64EgrWwbGmgwAwIa3TDiZ9s22LoUF293cQbe02GJa7Uw X-Received: by 2002:a17:906:793:b0:78c:ad86:d3 with SMTP id l19-20020a170906079300b0078cad8600d3mr10582890ejc.643.1668438896800; Mon, 14 Nov 2022 07:14:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668438896; cv=none; d=google.com; s=arc-20160816; b=Fi4PuleQ/SX7/mxUM4y4H65DDsruDuvE+NCxPXNZHpd4FanVB7vC5pz1gIIhJu/l1m w4uW+7cO6U6vXa+pG8Od0CP/tcqliqkiKAsfPgF8nE8zeVNauXkn9RBPS+j5tuAwXhRq QPNx/73r/fnIc/OnMGEBb6omBRx7es7YX57N6Vro+0igQT9RlpDFlGbsqIzYb8Hxmx2r ZdZ3i9NvqbYlEGvz0WY7ynuPejGAnPfZSJpNBOfvHln10Fef/yfJgeBJt9UcRxSSx3Yv EcpIMiMb3k8QMclmjCZa4L77Pw+RYHFe2IcvkCO+U5Ob6RpTkguhDaDGISJBDQB91Suy sjmw== 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=zxOT3HEV5wywTxHKRqQyHgr7mR3Pl3OYSIDIiN72ChQ=; b=HaOGpnY0vLokiMSCBFPCMHt9e1G8lPdAh3crZKfai+C3/Ee2bsazIoXmExfTqBuOtl Zfl3lbwTUPC+F/h4RlD3yRXBtt/tLQ57iZYOHWmuJ8QTIVY2saBVpwV6v6dz/+cRbp61 5SjEYi5pkhsprWwSBItgfpKPzgpJ55XZ5h9Np4VL1GBwprTjnf/Jp0neIFPwZa7vCfXe jpa09tbMrrW9qLHXbS1JPSl6nhWmeZyrsjXsElW55Kjav+FnC/zwBHKIN6TRUK5Esh7j goMY0AFHan67FjNTKrv7MknTAVWtT6WjhCFYQuyp6EugkYLH3UKMFAeuq/NM1mytLzEC AwSA== 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 c73-20020a509fcf000000b004617df75676si9480833edf.245.2022.11.14.07.14.56; Mon, 14 Nov 2022 07:14:56 -0800 (PST) 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 A268668BE2B; Mon, 14 Nov 2022 17:14:30 +0200 (EET) 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 AC16268BE15 for ; Mon, 14 Nov 2022 17:14:21 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 678D1240499 for ; Mon, 14 Nov 2022 16:14:21 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id oj5U87Nl7iXn for ; Mon, 14 Nov 2022 16:14:20 +0100 (CET) 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 1EBFA2405EC for ; Mon, 14 Nov 2022 16:14:19 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id A85433A0520 for ; Mon, 14 Nov 2022 16:14:18 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Nov 2022 16:13:45 +0100 Message-Id: <20221114151350.5134-3-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221114151350.5134-1-anton@khirnov.net> References: <20221114151350.5134-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/8] fftools/ffmpeg: stop handling max_frames in do_video_out() 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: TrTDn3tk0EOy Frame limiting is now handled using sync queues. This code prevents the sync queue from triggering EOF, resulting in unnecessarily many frames being decoded, filtered, and then discarded. Found-by: U. Artie Eoff --- fftools/ffmpeg.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 0fa2fe8c52..dfdfad3ce4 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1206,14 +1206,6 @@ static void do_video_out(OutputFile *of, } } - /* - * For video, number of frames in == number of packets out. - * But there may be reordering, so we can't throw away frames on encoder - * flush, we need to limit them here, before they go into encoder. - */ - nb_frames = FFMIN(nb_frames, ost->max_frames - ost->vsync_frame_number); - nb0_frames = FFMIN(nb0_frames, nb_frames); - memmove(ost->last_nb0_frames + 1, ost->last_nb0_frames, sizeof(ost->last_nb0_frames[0]) * (FF_ARRAY_ELEMS(ost->last_nb0_frames) - 1)); @@ -1262,7 +1254,9 @@ static void do_video_out(OutputFile *of, in_picture->pict_type = forced_kf_apply(ost, in_picture, i); ret = submit_encode_frame(of, ost, in_picture); - if (ret < 0 && ret != AVERROR_EOF) + if (ret == AVERROR_EOF) + break; + else if (ret < 0) exit_program(1); ost->next_pts++; From patchwork Mon Nov 14 15:13: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: 39278 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp2488665pzb; Mon, 14 Nov 2022 07:15:25 -0800 (PST) X-Google-Smtp-Source: AA0mqf7oSnYyvc5L09NhWKh0NDS9sVwGNjTg2MSg9GA+Ye4doTjyrV+JpQrXLtiuSwfMHfZKX3sX X-Received: by 2002:aa7:cd67:0:b0:464:b8b:f594 with SMTP id ca7-20020aa7cd67000000b004640b8bf594mr11364149edb.407.1668438925749; Mon, 14 Nov 2022 07:15:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668438925; cv=none; d=google.com; s=arc-20160816; b=W0qb972SBvWB8gGSgJLULGRIjOcwnnL35mYi+zkhz/FoJGt+QvRO2Ou1Nt+shWKO14 gZ5Gmzf+CLqC6zNdkFcBJ6v0GLXZzilDnTDUSENLgcPvtlFdCF0IMHa2KLtH5iK3fyTs 8n/E6+4Jiv/zaa1XZJBFJ4xP9El47v8n6V8VpElK359p4b+R/Gv9dD9MP7TvrwrPjHNq G2P1f68LY/hSrl9zdrYe6pMmWWyTLR43afGsxtbZAkpxeTvpbIKadL8t4yDbnzv7EoLe eTdqjykCrn1/UC1oybsYbh7p+lu9fWWiVZ7LEXhb/rkMRQetPV7NoBxjya3I/v4STBYq 3krQ== 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=u7hqS6cHJqiVpNUvIoOmWPf8XwMRQ04PceACoZbScuk=; b=nv0T9EAKSI5jlUXkXUUgMiDZGkMo7k5f486cl+VYvDVvIzxixxGVL5nOIVL7mYg3zT BDd7qPhI3s/lhzfsWlYJ9iWUL1+u+LlC7J645V+fGK0iC67gvy03pNxHmcDgWvUoRXlM 2oJvUWdMMD40MIUwdny02dtXY9p8aaJq5s4ZgJzgpIp89A3yGHpqY83nM6gLHfT/r7BY UCKJUElLAv4nf6KyYHsRwzo4UlGFFUtjlbIMfiI6LyfIUAnmg4bFwfX0jGKo8B4Q15ku jk97xeF/HSIP9XSorq7YaXfoMLmIXHEtdqPygotHXEFqbFSZSWcOAKFjQ2VS5oUgnX6t F1IQ== 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 q10-20020a056402518a00b004610f91a242si10480319edd.300.2022.11.14.07.15.25; Mon, 14 Nov 2022 07:15:25 -0800 (PST) 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 AFE6A68BE3E; Mon, 14 Nov 2022 17:14:33 +0200 (EET) 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 0989468BE1F for ; Mon, 14 Nov 2022 17:14:25 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id E011A2404F8 for ; Mon, 14 Nov 2022 16:14:22 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 7YHryiR_tBqY for ; Mon, 14 Nov 2022 16:14:22 +0100 (CET) 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 2E5712405F9 for ; Mon, 14 Nov 2022 16:14:19 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id B3CAC3A054D for ; Mon, 14 Nov 2022 16:14:18 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Nov 2022 16:13:46 +0100 Message-Id: <20221114151350.5134-4-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221114151350.5134-1-anton@khirnov.net> References: <20221114151350.5134-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/8] fftools/ffmpeg: move OutputStream.max_frames to MuxStream 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: O7Jo4pwuDZD7 It no longer needs to be visible outside of the muxing code. --- fftools/ffmpeg.h | 1 - fftools/ffmpeg_mux.c | 5 ----- fftools/ffmpeg_mux.h | 7 +++++++ fftools/ffmpeg_mux_init.c | 23 +++++++++++++---------- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 23850c7573..ad53ad4ce8 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -508,7 +508,6 @@ typedef struct OutputStream { AVRational enc_timebase; AVCodecContext *enc_ctx; - int64_t max_frames; AVFrame *filtered_frame; AVFrame *last_frame; AVFrame *sq_frame; diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index 778626e20f..ad04f5049d 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -45,11 +45,6 @@ static Muxer *mux_from_of(OutputFile *of) return (Muxer*)of; } -static MuxStream *ms_from_ost(OutputStream *ost) -{ - return (MuxStream*)ost; -} - static int64_t filesize(AVIOContext *pb) { int64_t ret = -1; diff --git a/fftools/ffmpeg_mux.h b/fftools/ffmpeg_mux.h index 6ea7c692ef..6a72b9dc91 100644 --- a/fftools/ffmpeg_mux.h +++ b/fftools/ffmpeg_mux.h @@ -42,6 +42,8 @@ typedef struct MuxStream { AVBSFContext *bsf_ctx; + int64_t max_frames; + /* * The size of the AVPackets' buffers in queue. * Updated when a packet is either pushed or pulled from the queue. @@ -84,4 +86,9 @@ extern int want_sdp; int mux_check_init(Muxer *mux); +static MuxStream *ms_from_ost(OutputStream *ost) +{ + return (MuxStream*)ost; +} + #endif /* FFTOOLS_FFMPEG_MUX_H */ diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 303bf25096..150eb77ee2 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -295,8 +295,8 @@ static OutputStream *new_output_stream(Muxer *mux, const OptionsContext *o, ost->enc_timebase = q; } - ost->max_frames = INT64_MAX; - MATCH_PER_STREAM_OPT(max_frames, i64, ost->max_frames, oc, st); + ms->max_frames = INT64_MAX; + MATCH_PER_STREAM_OPT(max_frames, i64, ms->max_frames, oc, st); for (i = 0; inb_max_frames; i++) { char *p = o->max_frames[i].specifier; if (!*p && type != AVMEDIA_TYPE_VIDEO) { @@ -1165,6 +1165,7 @@ static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, int64_t buf_size_u for (int i = 0; i < oc->nb_streams; i++) { OutputStream *ost = of->streams[i]; + MuxStream *ms = ms_from_ost(ost); enum AVMediaType type = ost->st->codecpar->codec_type; ost->sq_idx_encode = -1; @@ -1173,8 +1174,8 @@ static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, int64_t buf_size_u nb_interleaved += IS_INTERLEAVED(type); nb_av_enc += IS_AV_ENC(ost, type); - limit_frames |= ost->max_frames < INT64_MAX; - limit_frames_av_enc |= (ost->max_frames < INT64_MAX) && IS_AV_ENC(ost, type); + limit_frames |= ms->max_frames < INT64_MAX; + limit_frames_av_enc |= (ms->max_frames < INT64_MAX) && IS_AV_ENC(ost, type); } if (!((nb_interleaved > 1 && of->shortest) || @@ -1191,13 +1192,14 @@ static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, int64_t buf_size_u for (int i = 0; i < oc->nb_streams; i++) { OutputStream *ost = of->streams[i]; + MuxStream *ms = ms_from_ost(ost); enum AVMediaType type = ost->st->codecpar->codec_type; if (!IS_AV_ENC(ost, type)) continue; ost->sq_idx_encode = sq_add_stream(of->sq_encode, - of->shortest || ost->max_frames < INT64_MAX); + of->shortest || ms->max_frames < INT64_MAX); if (ost->sq_idx_encode < 0) return ost->sq_idx_encode; @@ -1205,8 +1207,8 @@ static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, int64_t buf_size_u if (!ost->sq_frame) return AVERROR(ENOMEM); - if (ost->max_frames != INT64_MAX) - sq_limit_frames(of->sq_encode, ost->sq_idx_encode, ost->max_frames); + if (ms->max_frames != INT64_MAX) + sq_limit_frames(of->sq_encode, ost->sq_idx_encode, ms->max_frames); } } @@ -1223,18 +1225,19 @@ static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, int64_t buf_size_u for (int i = 0; i < oc->nb_streams; i++) { OutputStream *ost = of->streams[i]; + MuxStream *ms = ms_from_ost(ost); enum AVMediaType type = ost->st->codecpar->codec_type; if (!IS_INTERLEAVED(type)) continue; ost->sq_idx_mux = sq_add_stream(mux->sq_mux, - of->shortest || ost->max_frames < INT64_MAX); + of->shortest || ms->max_frames < INT64_MAX); if (ost->sq_idx_mux < 0) return ost->sq_idx_mux; - if (ost->max_frames != INT64_MAX) - sq_limit_frames(mux->sq_mux, ost->sq_idx_mux, ost->max_frames); + if (ms->max_frames != INT64_MAX) + sq_limit_frames(mux->sq_mux, ost->sq_idx_mux, ms->max_frames); } } From patchwork Mon Nov 14 15:13: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: 39276 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp2488546pzb; Mon, 14 Nov 2022 07:15:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf6AfVbj6eLy6EZEgZYDGQFkXajkC2q3LLsD+ozHx2ULIxiFJ7HEdsp5+PadZsuP/cR3Kuqt X-Received: by 2002:a50:d4d1:0:b0:467:6ffe:e94c with SMTP id e17-20020a50d4d1000000b004676ffee94cmr9994986edj.417.1668438915242; Mon, 14 Nov 2022 07:15:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668438915; cv=none; d=google.com; s=arc-20160816; b=toHGbxV5Q8Lr31bulytxZAw97kfQR+k20rugSDkykftWx23Tuapr0XlJL+TpgvAu+X NG4m1SXDaWAsHv3V9zTi4DRcPMQOo0w0E7lBIsZx7LAlu0CbrV7kTBtVpm1kqC3BX6X6 90yvaAEaqW8otbqbz/X2TKrL4xUkGf8KPtie3ajiCvRmHubyMQk791dyL/856W+IJWjU mJaSdDKx60mnoRTmtOhn5PYD3ArFCTum6pDP8jJtvABtkNVJZkNQlGAj/FNkGCFzbAr7 b6e4tn8quhupsDFR10JBfC8LecdPH1YpFv/IdYmBiBmwOV1TpDbg0zYc0qjLY7OwELCJ B82g== 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=g0MsofV8Gu9BGTvybyBTjPmlA5jHAV1mBaPu+qhYmhw=; b=DQkE/zmKSsuOmMBnUSnDafo9N7PPlIwFOB0KFDIKJ1zo0yzh3ZDTBh/RgbcsmYNi6v dypTxruoPg3TvbS1HbXExOFy0P5gqTlzUpM9VYVrA2jDXo3nYsn7GAHDnSK95S/y+jnU 6JgszbFScQKKL4Uzp9tX1qCBwEfsyCtU1nP5BhXncIOofjAMG9RC2vkHzxbGe6G3Sr99 P+CjWAfLp/dlyQ87G9pCq26leQT6GI0sHL+ErDyH66SK6p934CzDAPrIHONFBkW26hec K7Vnbb6RxiOOE7ujVYnoxlF9GoipHmgPjSo1JE1htZivNFYSbg4kCFz42waw4DjgcqQA Lg7g== 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 k1-20020a170906970100b007ad7e81a30csi7148421ejx.167.2022.11.14.07.15.06; Mon, 14 Nov 2022 07:15:15 -0800 (PST) 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 B15D768BE35; Mon, 14 Nov 2022 17:14:31 +0200 (EET) 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 8866E68BE1A for ; Mon, 14 Nov 2022 17:14:22 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 3126A2405EC for ; Mon, 14 Nov 2022 16:14:22 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id w9PwdQsXX6wi for ; Mon, 14 Nov 2022 16:14:21 +0100 (CET) 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 1C623240591 for ; Mon, 14 Nov 2022 16:14:19 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id BFB483A058F for ; Mon, 14 Nov 2022 16:14:18 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Nov 2022 16:13:47 +0100 Message-Id: <20221114151350.5134-5-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221114151350.5134-1-anton@khirnov.net> References: <20221114151350.5134-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 5/8] fftools/ffmpeg_mux_init: move validating codec avoptions to a separate function 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: Kx6tP25e1DjM --- fftools/ffmpeg.h | 2 +- fftools/ffmpeg_mux_init.c | 91 +++++++++++++++++++++------------------ fftools/ffmpeg_opt.c | 2 +- 3 files changed, 51 insertions(+), 44 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index ad53ad4ce8..b9262b373f 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -694,7 +694,7 @@ void assert_avoptions(AVDictionary *m); void assert_file_overwrite(const char *filename); char *file_read(const char *filename); -AVDictionary *strip_specifiers(AVDictionary *dict); +AVDictionary *strip_specifiers(const AVDictionary *dict); const AVCodec *find_codec_or_die(const char *name, enum AVMediaType type, int encoder); int parse_and_set_vsync(const char *arg, int *vsync_var, int file_idx, int st_idx, int is_global); diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 150eb77ee2..7ccaf9da78 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -1725,14 +1725,60 @@ static int set_dispositions(OutputFile *of, AVFormatContext *ctx) return 0; } +static void validate_enc_avopt(const Muxer *mux, const AVDictionary *codec_avopt) +{ + const OutputFile *of = &mux->of; + + AVDictionary *unused_opts; + const AVDictionaryEntry *e; + + unused_opts = strip_specifiers(codec_avopt); + for (int i = 0; i < of->nb_streams; i++) { + e = NULL; + while ((e = av_dict_get(of->streams[i]->encoder_opts, "", e, + AV_DICT_IGNORE_SUFFIX))) + av_dict_set(&unused_opts, e->key, NULL, 0); + } + + e = NULL; + while ((e = av_dict_get(unused_opts, "", e, AV_DICT_IGNORE_SUFFIX))) { + const AVClass *class = avcodec_get_class(); + const AVOption *option = av_opt_find(&class, e->key, NULL, 0, + AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ); + const AVClass *fclass = avformat_get_class(); + const AVOption *foption = av_opt_find(&fclass, e->key, NULL, 0, + AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ); + if (!option || foption) + continue; + + if (!(option->flags & AV_OPT_FLAG_ENCODING_PARAM)) { + av_log(NULL, AV_LOG_ERROR, "Codec AVOption %s (%s) specified for " + "output file #%d (%s) is not an encoding option.\n", e->key, + option->help ? option->help : "", nb_output_files - 1, + mux->fc->url); + exit_program(1); + } + + // gop_timecode is injected by generic code but not always used + if (!strcmp(e->key, "gop_timecode")) + continue; + + av_log(NULL, AV_LOG_WARNING, "Codec AVOption %s (%s) specified for " + "output file #%d (%s) has not been used for any stream. The most " + "likely reason is either wrong type (e.g. a video option with " + "no video streams) or that it is a private option of some encoder " + "which was not actually used for any stream.\n", e->key, + option->help ? option->help : "", nb_output_files - 1, mux->fc->url); + } + av_dict_free(&unused_opts); +} + int of_open(const OptionsContext *o, const char *filename) { Muxer *mux; AVFormatContext *oc; int err; OutputFile *of; - AVDictionary *unused_opts = NULL; - const AVDictionaryEntry *e = NULL; int64_t recording_time = o->recording_time; int64_t stop_time = o->stop_time; @@ -1795,46 +1841,7 @@ int of_open(const OptionsContext *o, const char *filename) create_streams(mux, o); /* check if all codec options have been used */ - unused_opts = strip_specifiers(o->g->codec_opts); - for (int i = 0; i < of->nb_streams; i++) { - e = NULL; - while ((e = av_dict_get(of->streams[i]->encoder_opts, "", e, - AV_DICT_IGNORE_SUFFIX))) - av_dict_set(&unused_opts, e->key, NULL, 0); - } - - e = NULL; - while ((e = av_dict_get(unused_opts, "", e, AV_DICT_IGNORE_SUFFIX))) { - const AVClass *class = avcodec_get_class(); - const AVOption *option = av_opt_find(&class, e->key, NULL, 0, - AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ); - const AVClass *fclass = avformat_get_class(); - const AVOption *foption = av_opt_find(&fclass, e->key, NULL, 0, - AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ); - if (!option || foption) - continue; - - - if (!(option->flags & AV_OPT_FLAG_ENCODING_PARAM)) { - av_log(NULL, AV_LOG_ERROR, "Codec AVOption %s (%s) specified for " - "output file #%d (%s) is not an encoding option.\n", e->key, - option->help ? option->help : "", nb_output_files - 1, - filename); - exit_program(1); - } - - // gop_timecode is injected by generic code but not always used - if (!strcmp(e->key, "gop_timecode")) - continue; - - av_log(NULL, AV_LOG_WARNING, "Codec AVOption %s (%s) specified for " - "output file #%d (%s) has not been used for any stream. The most " - "likely reason is either wrong type (e.g. a video option with " - "no video streams) or that it is a private option of some encoder " - "which was not actually used for any stream.\n", e->key, - option->help ? option->help : "", nb_output_files - 1, filename); - } - av_dict_free(&unused_opts); + validate_enc_avopt(mux, o->g->codec_opts); /* set the decoding_needed flags and create simple filtergraphs */ for (int i = 0; i < of->nb_streams; i++) { diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 0fd9d98f0f..5ab296828b 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -165,7 +165,7 @@ static int show_hwaccels(void *optctx, const char *opt, const char *arg) } /* return a copy of the input with the stream specifiers removed from the keys */ -AVDictionary *strip_specifiers(AVDictionary *dict) +AVDictionary *strip_specifiers(const AVDictionary *dict) { const AVDictionaryEntry *e = NULL; AVDictionary *ret = NULL; From patchwork Mon Nov 14 15:13: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: 39274 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp2487830pzb; Mon, 14 Nov 2022 07:14:47 -0800 (PST) X-Google-Smtp-Source: AA0mqf5PKCq5bLQHDdL+FHrDc+/Acb1dB8BZmMW7jJXqUb9s1TbtWlCu+n1KQLsWJLutcW7Jotcq X-Received: by 2002:a17:906:8052:b0:7ad:821f:a3e6 with SMTP id x18-20020a170906805200b007ad821fa3e6mr10068867ejw.688.1668438887569; Mon, 14 Nov 2022 07:14:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668438887; cv=none; d=google.com; s=arc-20160816; b=LzprF28nASdXGo05Pr/P7RmIDYR/iZhqriHw6NSQwD90+cBgSUNDR4S/3jZj6SVj37 zc4wHJIUO+SGqetTD+UaO+rzNfKOLLUqOhcSIAWN9FbPRo4REwYIGqiAIeKkx6OE0g// JU6KWXS7PHOSVhsXer6YywC6AZDdx+8tc0WF+A5JjsI71vadatC24b76LQyXkfGZKSmP gv1zJgiuLqW0GqxLC5Lw09lGUbA8vLmfmDqVG3Ee9L8SzFpLCyx4HuDo98bmC033o3wa exJ82b4x0UKWo+x81GgCSRCJOxIA+3F8vY87wUow89ASwftkiSw2kIzUFH7oG0a/L5R4 rjiA== 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=Tw6mDuSLRlYEagq0CzUvGazjHzIdRNP1R2id0OJPweI=; b=rq0z2in8XMKYxZIaJ0SsKwnp+PjIVYPtdBmcVqDkw6RAwyqQZ3qlseb0ofv50nsnuX xbyorl40YmFjxQcDDFXIB8RnQtkUbW9Ky+dvL+BjhPNRmRW3L96PkrGruNTMBwYz77YV EQVZgj+HpwyKwSe546IDR9fildhU6ybhsvQf6764i6dLA7BP4hic6hXzm8izqsJ7Ctef ByP+SRLpWMdQRs7jWyXoVSzagpE4f64P5AABXwwefyjDAyBeFfRHJRVpjICkvrC6wNL+ lCeIElG8IgpjCzKDR/oDpWpSP/VvVAfNelwjOxM5Dl/xwWfnlvgeEFsMKteKrt982Ite kdKQ== 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 pk28-20020a170906d7bc00b007a4feae7ae7si7255576ejb.575.2022.11.14.07.14.46; Mon, 14 Nov 2022 07:14:47 -0800 (PST) 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 B59BA68BE24; Mon, 14 Nov 2022 17:14:28 +0200 (EET) 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 1AB8C68BE0B for ; Mon, 14 Nov 2022 17:14:21 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id D30BF2404F7 for ; Mon, 14 Nov 2022 16:14:20 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id pIDsAYi9AT2p for ; Mon, 14 Nov 2022 16:14:19 +0100 (CET) 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 03825240499 for ; Mon, 14 Nov 2022 16:14:19 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id CB6883A05F9 for ; Mon, 14 Nov 2022 16:14:18 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Nov 2022 16:13:48 +0100 Message-Id: <20221114151350.5134-6-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221114151350.5134-1-anton@khirnov.net> References: <20221114151350.5134-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 6/8] fftools/ffmpeg_mux_init: do not call av{codec, format}_get_class() repeatedly 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: CEMUAD/DNeXF --- fftools/ffmpeg_mux_init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 7ccaf9da78..6ed30eb498 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -1727,6 +1727,8 @@ static int set_dispositions(OutputFile *of, AVFormatContext *ctx) static void validate_enc_avopt(const Muxer *mux, const AVDictionary *codec_avopt) { + const AVClass *class = avcodec_get_class(); + const AVClass *fclass = avformat_get_class(); const OutputFile *of = &mux->of; AVDictionary *unused_opts; @@ -1742,10 +1744,8 @@ static void validate_enc_avopt(const Muxer *mux, const AVDictionary *codec_avopt e = NULL; while ((e = av_dict_get(unused_opts, "", e, AV_DICT_IGNORE_SUFFIX))) { - const AVClass *class = avcodec_get_class(); const AVOption *option = av_opt_find(&class, e->key, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ); - const AVClass *fclass = avformat_get_class(); const AVOption *foption = av_opt_find(&fclass, e->key, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ); if (!option || foption) From patchwork Mon Nov 14 15:13: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: 39279 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp2488763pzb; Mon, 14 Nov 2022 07:15:34 -0800 (PST) X-Google-Smtp-Source: AA0mqf7YQkRX3WCwt0ukjHFCZuv18ZtjYkCL/Py9RD6DUOcjBBGAAfjBWRotl3wpcNDBAEAT1U/O X-Received: by 2002:a17:906:300c:b0:7ae:fbe8:a73f with SMTP id 12-20020a170906300c00b007aefbe8a73fmr3966944ejz.479.1668438934599; Mon, 14 Nov 2022 07:15:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668438934; cv=none; d=google.com; s=arc-20160816; b=d19Uv4rBPTKqPmR3GGXmVYreC4doUro8EcDK1Be4hldU90W1/Nu+4npX592MJw1tLw DP/F1/CGRqm/I5PgEQzA/s/+FXfug+p/bdmIKxVZd2Tx4Ss8FS6O2AYTJA9WbY1mIo/2 ntnsn6uxUHCIkUC0Xfo1nYGHZjwR1kEwHv9v3mvA8YcsDx8iKR3wDNmR8xzQjvw67Su6 qTKFbMFdxxuIlA7Vu91+ln/dCby0Sh5tu8wVAKGjisu3Tj8gE8FRhGEL637QCLaUCxUU 9w5Y4vPtpVUjdu8s3t20UyO8N7vLnrn8njkbxEiV/xRCEE7BLfO2s3h4MH2nHWnjcVNr SRgQ== 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=Vnut2lhMv/86wht2quUdJc6B59Om8CxtQo+mtb+c+hM=; b=VWMgvpA93LlFzZmddXLSgfwj0f8asXDQtqFWKm+6IlLUhGiPjZliBpoKUJ3995jka9 AujHoLMFbfFqfXjj/20sdRUCiS30JgrRRncPyx/GFPblO7tTB4+CbVrjH8wZLM3AKAH0 icpp4XyCXyQPXMmRBl/b+6mr++gc8L1cUnhvvrz1cYxCBRCZgN4ij74NSxe69+Gk8TP5 d7kNq5ktRvDrVwFRr3YrZoE/mKIKIJy9yUC4ESmQlZwCTtVuN8LwQL2BJW+t/eJlbs5B u/45AvCYM1SzBZTsVeEu6dTdCDgjmsjTBe50osCsh2CsM2J/6Ys7fOoNjee3w1V+jWF5 sV5A== 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 v8-20020a50a448000000b00457e9f88b90si9368499edb.246.2022.11.14.07.15.34; Mon, 14 Nov 2022 07:15:34 -0800 (PST) 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 BB96F68BE45; Mon, 14 Nov 2022 17:14:34 +0200 (EET) 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 B587868BE0A for ; Mon, 14 Nov 2022 17:14:25 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 228642405F9 for ; Mon, 14 Nov 2022 16:14:23 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 11ZdKuWZyfPN for ; Mon, 14 Nov 2022 16:14:22 +0100 (CET) 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 2F2B82406C7 for ; Mon, 14 Nov 2022 16:14:19 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id D6E1D3A0656 for ; Mon, 14 Nov 2022 16:14:18 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Nov 2022 16:13:49 +0100 Message-Id: <20221114151350.5134-7-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221114151350.5134-1-anton@khirnov.net> References: <20221114151350.5134-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 7/8] fftools/ffmpeg_mux_init: use av_dict_iterate() where appropriate 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: +wNxYZA+9gsk --- fftools/ffmpeg_mux_init.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 6ed30eb498..277cbd1f64 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -1737,13 +1737,12 @@ static void validate_enc_avopt(const Muxer *mux, const AVDictionary *codec_avopt unused_opts = strip_specifiers(codec_avopt); for (int i = 0; i < of->nb_streams; i++) { e = NULL; - while ((e = av_dict_get(of->streams[i]->encoder_opts, "", e, - AV_DICT_IGNORE_SUFFIX))) + while ((e = av_dict_iterate(of->streams[i]->encoder_opts, e))) av_dict_set(&unused_opts, e->key, NULL, 0); } e = NULL; - while ((e = av_dict_get(unused_opts, "", e, AV_DICT_IGNORE_SUFFIX))) { + while ((e = av_dict_iterate(unused_opts, e))) { const AVOption *option = av_opt_find(&class, e->key, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ); const AVOption *foption = av_opt_find(&fclass, e->key, NULL, 0, From patchwork Mon Nov 14 15:13: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: 39273 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp2487755pzb; Mon, 14 Nov 2022 07:14:38 -0800 (PST) X-Google-Smtp-Source: AA0mqf5jINiO5CD+gGndEDg+DeaLgo826wjiQ8oJu2rOFgERndaZEp+tGxPd7D3Rbg6BgktOfy3b X-Received: by 2002:a05:600c:2309:b0:3cf:d0ba:e5ff with SMTP id 9-20020a05600c230900b003cfd0bae5ffmr8205321wmo.36.1668438878637; Mon, 14 Nov 2022 07:14:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668438878; cv=none; d=google.com; s=arc-20160816; b=lJNSavuqoomRBQEnsMymiYTQHFkjqIWtXm5X9gHspnNyD+SFzQDni379Gulw83zZmx sp4sRJDgciPcBeryGMzuD/AuECC6LQccDe5rmdsIZKqvWVm3thkuyXHN/tNXpB9Gi7mo nqg0Fq2LDjoWdzOrPDJjLJsHQNmTELQD//uI6CkutxLtXEGdPNdTtmUQ3MMJnoxthhhC u8bXDbea0Vbtt1wD+yUhqIaCUsSzq3CCIJQfUKnfx5OKd64FeRybFDU6arYGO9USIG5r lLwTPSX7rW0KKEvt+2wDEfpRxUCs2AQoIGUUsGZQU6C/T5roEUzFLaiGhqOIsTju3aw3 448A== 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=X/Cd38KzGJvvQa30z16QH3+7m3RxpkpIzKPzz3c27j0=; b=A8j05U4DrK+TAzfEI15+zPUD3/3CJGyUUI30haMZcuR2KUsKf8OweQ4rUW+Du2j1Mm cCCV+YELfLJQKFNz3sK76JmE0JmPTPswnESHnJ+wsyMB3Q645s4kw2Bq9chcKHSLLeDO wowC8oHaEBHubZH3VQ/+voyGUxqI8zRTMWagMTga3/YzJs+g7WWyo2Q8eg7E0MpAAU/n /dvvKO96hwYgRareJgQNc+mZJaHf6TlZ6ZGyK+Mw6uw86sph2VNByBmr9hruGeXqrpex vkf9yFi2TiGHP0WnEo2q4geyKVa0yLvwXEBil2DHOC9wLLf5nURScjhvxjMfAvoN8RAP TREA== 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 cm25-20020a0564020c9900b004608b4f28b7si7149923edb.106.2022.11.14.07.14.37; Mon, 14 Nov 2022 07:14:38 -0800 (PST) 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 D584768BE1A; Mon, 14 Nov 2022 17:14:27 +0200 (EET) 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 6949868BE0A for ; Mon, 14 Nov 2022 17:14:20 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 2674F2400F5 for ; Mon, 14 Nov 2022 16:14:20 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id hE6PN2NSjAcL for ; Mon, 14 Nov 2022 16:14:19 +0100 (CET) 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 0F3A72404F7 for ; Mon, 14 Nov 2022 16:14:19 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id E217A3A06E5 for ; Mon, 14 Nov 2022 16:14:18 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Nov 2022 16:13:50 +0100 Message-Id: <20221114151350.5134-8-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221114151350.5134-1-anton@khirnov.net> References: <20221114151350.5134-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 8/8] fftools/ffmpeg_mux_init: drop an always-false check 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: vCkEiVMiTG/3 It cannot be true since 1959351aecf. Effectively reverts 6a3833e1411. --- fftools/ffmpeg.h | 1 - fftools/ffmpeg_demux.c | 2 -- fftools/ffmpeg_mux_init.c | 6 ------ fftools/ffmpeg_opt.c | 5 ----- 4 files changed, 14 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index b9262b373f..a96ff0d723 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -674,7 +674,6 @@ extern HWDevice *filter_hw_device; extern unsigned nb_output_dumped; extern int main_return_code; -extern int input_stream_potentially_available; extern int ignore_unknown_streams; extern int copy_unknown_streams; diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index 94fd604fd9..595a56a590 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -1097,7 +1097,5 @@ int ifile_open(const OptionsContext *o, const char *filename) } } - input_stream_potentially_available = 1; - return 0; } diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 277cbd1f64..db45fa09fa 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -1911,12 +1911,6 @@ int of_open(const OptionsContext *o, const char *filename) } } - if (!(oc->oformat->flags & AVFMT_NOSTREAMS) && !input_stream_potentially_available) { - av_log(NULL, AV_LOG_ERROR, - "No input streams but output needs an input stream\n"); - exit_program(1); - } - if (!(oc->oformat->flags & AVFMT_NOFILE)) { /* test if it already exists to avoid losing precious files */ assert_file_overwrite(filename); diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 5ab296828b..61aa0be0ab 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -95,7 +95,6 @@ static int no_file_overwrite = 0; #if FFMPEG_OPT_PSNR int do_psnr = 0; #endif -int input_stream_potentially_available = 0; int ignore_unknown_streams = 0; int copy_unknown_streams = 0; int recast_media = 0; @@ -1114,8 +1113,6 @@ static int opt_filter_complex(void *optctx, const char *opt, const char *arg) if (!fg->graph_desc) return AVERROR(ENOMEM); - input_stream_potentially_available = 1; - return 0; } @@ -1130,8 +1127,6 @@ static int opt_filter_complex_script(void *optctx, const char *opt, const char * fg->index = nb_filtergraphs - 1; fg->graph_desc = graph_desc; - input_stream_potentially_available = 1; - return 0; }