From patchwork Thu Aug 25 08:59: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: 37467 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp200854pzh; Thu, 25 Aug 2022 02:01:24 -0700 (PDT) X-Google-Smtp-Source: AA6agR6E2WlQo60SzsRyqNRftDLJTQl0uyfw4/bJ3WRvIE1qzFohdbVYCjtmZ9dtZo0EaqBr3/eI X-Received: by 2002:a17:907:97d3:b0:73d:8b9b:a6c1 with SMTP id js19-20020a17090797d300b0073d8b9ba6c1mr1771086ejc.71.1661418084049; Thu, 25 Aug 2022 02:01:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661418084; cv=none; d=google.com; s=arc-20160816; b=L9D4296ORyzQNeh9WqWTMlubSDastFo52ShSqLkfM0l6LfOJ8PKSck96i5h+7jdsmC YmDY09XJctwxflGMy86blFrbPzIpxwe0iw7mfxusNX4g7tnrEwrKjjamDPvzSozusxgL f5dEAkE7NXeF4OypgvkIRgFj8iFmTX/ag+tPLshtzrK5Tv6434IiKu4K7aTdSt0TWIoh t1aPce8rxgBpqt7DW1+kV4hlbL9OhJw36oxtDpk3bCzIfk3e4M14VchkVFHfec/ad1Kk fPJzt+lMnVTbkvrt6O/K1Uxeqy58vPBDNfFT5scfSPWKNAw3mwoCHzfeZEbuXU9o+mpL ftLQ== 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=91aIbgPlWOxxHLgkFaBKL/E0zzsaIvgZb4oC6d44ReA=; b=FfOYWEu3Hs5sEgGha7tWnGWRKwpEmdbOQp8v58ffKuOC1Lwf4njSyVYCudwg1N8equ jQMZimF33TRssQvAIPMu1psSmhqZy1GEJzVOepvgfk2uSw6PYzhvwJX3RyzGu/h+ZvxI XlF9tKGQC9fNFcUBf12Jr6mk8J/q6CUvYlVlYHE34raGqKfdKDOAxmsxZDA8pBoUPF7J eKb9jyOo/+58goeBYuYrQ8+LLzki1VqIu6C4/D3jadvAEg0yKM62GMTV5lLvWG2YdlFR hUgvplhvzXcVf+c/Wh6bf4nXZPRxvZVdjTNOrpjzW7k73/f4r/ZLPOhFmORHrmRj2d9l Q93Q== 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 qb24-20020a1709077e9800b00738553043e5si3937362ejc.573.2022.08.25.02.01.22; Thu, 25 Aug 2022 02:01:24 -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 7BE8568B9C6; Thu, 25 Aug 2022 12:01:18 +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 889CD68B6F0 for ; Thu, 25 Aug 2022 12:01:12 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 155E3240D03 for ; Thu, 25 Aug 2022 11:01:12 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id YXmEG4q3lfju for ; Thu, 25 Aug 2022 11:01:11 +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 064FF240D0E for ; Thu, 25 Aug 2022 11:01:11 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 773BF3A0ABF; Thu, 25 Aug 2022 11:01:04 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 25 Aug 2022 10:59:51 +0200 Message-Id: <20220825085956.4790-1-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/6] fftools/ffmpeg: remove a stale extern declaration 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: 0zW1LhbeHovB Forgotten in 8cbf229c941b3c77a756bff05d0ceb5f4f2219c5 --- fftools/ffmpeg.h | 1 - 1 file changed, 1 deletion(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 921e579c32..50654bf8db 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -650,7 +650,6 @@ extern float audio_drift_threshold; extern float dts_delta_threshold; extern float dts_error_threshold; -extern int audio_volume; extern int audio_sync_method; extern enum VideoSyncMethod video_sync_method; extern float frame_drop_threshold; From patchwork Thu Aug 25 08:59: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: 37468 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp200978pzh; Thu, 25 Aug 2022 02:01:36 -0700 (PDT) X-Google-Smtp-Source: AA6agR76sF0YwcUZe1pXqRIifT3xU74Aqq5Xa1U/UC+Pmpfp4jBL9RwLF7FGwlg0MMdnq9W6ms9m X-Received: by 2002:a05:6402:43cf:b0:446:b290:ea84 with SMTP id p15-20020a05640243cf00b00446b290ea84mr2308032edc.119.1661418094957; Thu, 25 Aug 2022 02:01:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661418094; cv=none; d=google.com; s=arc-20160816; b=RhWbIT9VCulIQyFCTWRH+3yvSlkfBDCziAeKZRngG9F4A31yczR6Ek7qjB9ycsIp5B rBwuSn87BJQjSiKs0vuDR6DobxaUjmVODwAy2yLnG1FnEwuZ5xbQumlDAPgE47o1U8Xf yUyHCt86B8Fz/gXbHCA9xLnSBqkYLSdIoCsl/p7vHjBmY3lhQMb+KaAFWk85y9WLAuHr VDtUMHzIFwnhltM67s2jLo5Sv1nT95HjaufEisfc6zUmB5BkpV7Zb3pPxwTfUqQqOtWd 6EBf68oonGpGXmHMa1dXcKRoRpwanEHGifzM/ZuTo8HlHjK4535eClPFfnYUcsfOBMbz 8jHg== 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=oueYAgi+HgPN3uK+YNmb923yjRK4qbGVB7fI0oGxsQE=; b=Twmr73A0Jf1E08HKGCNHjpIKecXtfcZpd+V1R27gvz5+2tz7LwCUbhYs0d6F5Scx4/ 1LVsER3fdyQTLRO7QiOCu+iK91Sk3pdctUEJ1jMN34nJw9UiK6obsdpFN8j4Grcj56dr AMob6o7tjrcA0SoGjeJN7BTFDJzUfDnBJFK2Ox3JEQxduU1ls6pqdsnSttTjYZGnT0rT ifw/KyEN/+yZ+G2IkLVBZQfOOZB03c+LrnwaqSsp5/neO6QDcy3PWXQQH5FcfZzWB2qQ +vTVOeTgTmKUQbLFmgq94La69sGC60rt7/Z2UTt9Rq8zTbaawPlKK9FKE0JiarN+KVq/ 3Rag== 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 dd14-20020a170906c82e00b0073ad0874d2bsi3106367ejb.97.2022.08.25.02.01.34; Thu, 25 Aug 2022 02:01:34 -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 ACBA568B9C1; Thu, 25 Aug 2022 12:01:19 +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 8CB2468B72B for ; Thu, 25 Aug 2022 12:01:12 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 49804240D0E for ; Thu, 25 Aug 2022 11:01:12 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id tsSUj6mtzvGc for ; Thu, 25 Aug 2022 11:01:11 +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 0832B240D18 for ; Thu, 25 Aug 2022 11:01:11 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 796AD3A014F; Thu, 25 Aug 2022 11:01:04 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 25 Aug 2022 10:59:52 +0200 Message-Id: <20220825085956.4790-2-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220825085956.4790-1-anton@khirnov.net> References: <20220825085956.4790-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/6] fftools/ffmpeg_filter: remove 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: XzzYd/6PGsh9 This code cannot be triggered, since after 90944ee3ab7 opening the output file will abort if an encoder cannot be found and streamcopy was not explicitly requested. --- fftools/ffmpeg_filter.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 16622e49c1..4e2787eba2 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -1095,14 +1095,6 @@ int configure_filtergraph(FilterGraph *fg) for (i = 0; i < fg->nb_outputs; i++) { OutputStream *ost = fg->outputs[i]->ost; - if (!ost->enc) { - /* identical to the same check in ffmpeg.c, needed because - complex filter graphs are initialized earlier */ - av_log(NULL, AV_LOG_ERROR, "Encoder (codec %s) not found for output stream #%d:%d\n", - avcodec_get_name(ost->st->codecpar->codec_id), ost->file_index, ost->index); - ret = AVERROR(EINVAL); - goto fail; - } if (ost->enc->type == AVMEDIA_TYPE_AUDIO && !(ost->enc->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)) av_buffersink_set_frame_size(ost->filter->filter, From patchwork Thu Aug 25 08:59:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 37469 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp201045pzh; Thu, 25 Aug 2022 02:01:45 -0700 (PDT) X-Google-Smtp-Source: AA6agR4dcbf9djQIXQC4pB9NejL1+mpZ3oM6/viGIM11/M2XKejyvh44BJRj/j1fNbKcXF2Nf8ml X-Received: by 2002:a17:907:7629:b0:73d:8d3e:4389 with SMTP id jy9-20020a170907762900b0073d8d3e4389mr1716974ejc.565.1661418104893; Thu, 25 Aug 2022 02:01:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661418104; cv=none; d=google.com; s=arc-20160816; b=k5lTrVaAi5VsJrbssCHMq9MOv+NZPehkFwEEegO+mQxecrdOmIHvdZwf3zqvvz7dDh pUm7cPtVpLE1rPVPEash27FO/ept9F9o20ItG0IH0wrOLLLSpl9IJwtixOYz+P+yvxVS eF2DZv21UgxFFHBMe0CdLJ+NZikRADrYlqEPvygUpj+fgtBYoJqOE5jVg9KKkSegnVVJ gJEpRixbudRK2bS1wDMICMqyq2ky6zvpCXgzwci7yQcqOHi9EHtZSL8SKc0LaSB5HLQr nVfzyrJB80ug9AdctND87BJrsU0AtRzjhmIM9MEbVfgAY59oP/F4fooe05bvwXUmBZL9 1KYw== 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=6Y/3Yxe9z9ibnbfvNBLJ/8+FIZD64NhXXx5ua1J2VoA=; b=SRlTWBD3ulqwzm76SSmOzRrrG+yf4/7j8WcPjys8HVRIh4O+k/ucOAHW/TcGVoRBDp fPuxjdPQF6iNybI0ATs20Rfexa3cxbmMCvK+PprytrCyLrvSIUZuZzicez+UedA5RU3Z n14SBTghFPovw+YoTZcJ721b0aCqkEcyHSx6SsearZ3m+OrHNSykdySnCbRcdTCERGl7 /GDIjaPM+tmY65iAE2OCYDjjSDzDqTee46YL+mP54Q0IInP+L2mp0fwcLvKlapgN873r fYXnhjJAvGJJ0izgHd91wxjGNsAu8v/TbzIdbt1crLqrgo2IdHkNUhX9wJ68McKCYhSG I/yQ== 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 q9-20020a1709063d4900b007396bf19f8csi3082103ejf.137.2022.08.25.02.01.44; Thu, 25 Aug 2022 02:01:44 -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 C3AFD68B72B; Thu, 25 Aug 2022 12:01:20 +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 8FE2368B9A4 for ; Thu, 25 Aug 2022 12:01:12 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id AB0FA240D1D for ; Thu, 25 Aug 2022 11:01:11 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id CxGQoY4ZBeGd for ; Thu, 25 Aug 2022 11:01:11 +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 F14A9240D03 for ; Thu, 25 Aug 2022 11:01:10 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 7BE3F3A0BDC; Thu, 25 Aug 2022 11:01:04 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 25 Aug 2022 10:59:53 +0200 Message-Id: <20220825085956.4790-3-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220825085956.4790-1-anton@khirnov.net> References: <20220825085956.4790-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/6] fftools/ffmpeg_filter: remove an always-true 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: PMeLVS4EvHQj ost->enc is always non-NULL here, since - this code is never called for streamcopy - opening the output file will fail if an encoder cannot be found, so filters are never initialized --- fftools/ffmpeg_filter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 4e2787eba2..e9479018e4 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -105,7 +105,7 @@ static const char *choose_pix_fmts(OutputFilter *ofilter, AVBPrint *bprint) if (ost->enc_ctx->pix_fmt != AV_PIX_FMT_NONE) { 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) { + } else if (ost->enc->pix_fmts) { const enum AVPixelFormat *p; p = ost->enc->pix_fmts; From patchwork Thu Aug 25 08:59:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 37471 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp201249pzh; Thu, 25 Aug 2022 02:02:05 -0700 (PDT) X-Google-Smtp-Source: AA6agR4wSibiwUAfXMvkAJHG7qIADgVjO5K8S9Cn0H2BEChdvcQrJ1A3TToIvlxhfyYJaLTHzwIS X-Received: by 2002:a50:9f4f:0:b0:447:8aff:d312 with SMTP id b73-20020a509f4f000000b004478affd312mr2335419edf.110.1661418125187; Thu, 25 Aug 2022 02:02:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661418125; cv=none; d=google.com; s=arc-20160816; b=D1jgublaBkJHRZBfZCQVGayyuCP4ir4ULw24vnQGlNbqGcaAywArw0C9qB97M4IK8f HU1uBqVOMBAx0SVtF7y94jFu85qP4yeSZu7rZFfwSYp3zdBOj7CqaqtwNjKL9rYj2oR7 3NHe9zznQQx6mY5tzg2MIjZbnI5k6i0GrgupYPj89a5ozls9WprjuaS3Np1GEqPxwOnd YL6Wh2Fe6KjCjprOWAx4KbhlLPgsGZR5BHTapd7p+jv+4PM8zuwajKE8r2luSUv3UwcI 4o5tYZ/ySZnzOudoIvpL/bsR77M02mnouylddmMaWavGoVwnTTrBU8I1sMh5dMdR4pgl YE/Q== 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=Inn3wDn+m0EpkSZdKf6+1UEhTVvVTilQtftIpfB8d3s=; b=DDUJClgNV4LWrzl7t6YNv0kHsHPMhFDBaYEJHtpez+xI4pRXSXCkCRh1KlSg9UKSgh 3Tmn6kj8ENAbmb3yVO3wHeYMugT7A/l1Fjx+bVYZIN3fSztsAAf6nkF0ekiuQS99ODbB lwCkyzfrtOLASbmq0Dn8jfAqbgbAGBXhtXpykRlRi12EwUCx0gSJrtuWH4bae3p/YweA bn+cKynu6oxqYXTc4x+uSchwGPX81Z+6dJ25Gt7visOc7BOAwYzo/nh5BD4WPcteBk/6 jmb0PmjvWhq6oGCbwwTfTFtyACG+2UL4At7fMXIZifRF8X3BBPitgBtKg2CXzVHsNL+t 7SRw== 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 ga26-20020a1709070c1a00b0072eda634546si3801002ejc.560.2022.08.25.02.02.04; Thu, 25 Aug 2022 02:02:05 -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 E656268B9F2; Thu, 25 Aug 2022 12:01:22 +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 A543D68B9C8 for ; Thu, 25 Aug 2022 12:01:13 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 66BD4240D1C for ; Thu, 25 Aug 2022 11:01:13 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 1uT6C7iw8rPL for ; Thu, 25 Aug 2022 11:01:12 +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 0C369240D1A for ; Thu, 25 Aug 2022 11:01:11 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 834733A0F7F; Thu, 25 Aug 2022 11:01:04 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 25 Aug 2022 10:59:54 +0200 Message-Id: <20220825085956.4790-4-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220825085956.4790-1-anton@khirnov.net> References: <20220825085956.4790-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/6] fftools/ffmpeg: drop OutputStream.enc 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: u+CecZ7CXKq3 It is either equal to OutputStream.enc_ctx->codec, or NULL when enc_ctx is NULL. Replace the use of enc with enc_ctx->codec, or the equivalent enc_ctx->codec_* fields where more convenient. --- fftools/ffmpeg.c | 27 +++++++++++++------------- fftools/ffmpeg.h | 1 - fftools/ffmpeg_filter.c | 13 +++++++------ fftools/ffmpeg_hw.c | 6 +++--- fftools/ffmpeg_opt.c | 43 ++++++++++++++++++++++++----------------- 5 files changed, 49 insertions(+), 41 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index ef7177fc33..4a825aa6b5 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2362,7 +2362,7 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output, OutputStream *ost = output_streams[i]; if (!check_output_constraints(ist, ost) || !ost->enc_ctx - || ost->enc->type != AVMEDIA_TYPE_SUBTITLE) + || ost->enc_ctx->codec_type != AVMEDIA_TYPE_SUBTITLE) continue; do_subtitle_out(output_files[ost->file_index], ost, &subtitle); @@ -2865,13 +2865,14 @@ static int init_output_stream_streamcopy(OutputStream *ost) static void set_encoder_id(OutputFile *of, OutputStream *ost) { + const char *cname = ost->enc_ctx->codec->name; uint8_t *encoder_string; int encoder_string_len; if (av_dict_get(ost->st->metadata, "encoder", NULL, 0)) return; - encoder_string_len = sizeof(LIBAVCODEC_IDENT) + strlen(ost->enc->name) + 2; + encoder_string_len = sizeof(LIBAVCODEC_IDENT) + strlen(cname) + 2; encoder_string = av_mallocz(encoder_string_len); if (!encoder_string) exit_program(1); @@ -2880,7 +2881,7 @@ static void set_encoder_id(OutputFile *of, OutputStream *ost) av_strlcpy(encoder_string, LIBAVCODEC_IDENT " ", encoder_string_len); else av_strlcpy(encoder_string, "Lavc ", encoder_string_len); - av_strlcat(encoder_string, ost->enc->name, encoder_string_len); + av_strlcat(encoder_string, cname, encoder_string_len); av_dict_set(&ost->st->metadata, "encoder", encoder_string, AV_DICT_DONT_STRDUP_VAL | AV_DICT_DONT_OVERWRITE); } @@ -3007,9 +3008,9 @@ static int init_output_stream_encode(OutputStream *ost, AVFrame *frame) !ost->frame_rate.den)) ost->frame_rate = ost->max_frame_rate; - if (ost->enc->supported_framerates && !ost->force_fps) { - int idx = av_find_nearest_q_idx(ost->frame_rate, ost->enc->supported_framerates); - ost->frame_rate = ost->enc->supported_framerates[idx]; + if (enc_ctx->codec->supported_framerates && !ost->force_fps) { + int idx = av_find_nearest_q_idx(ost->frame_rate, enc_ctx->codec->supported_framerates); + ost->frame_rate = enc_ctx->codec->supported_framerates[idx]; } // reduce frame rate for mpeg4 to be within the spec limits if (enc_ctx->codec_id == AV_CODEC_ID_MPEG4) { @@ -3150,7 +3151,7 @@ static int init_output_stream(OutputStream *ost, AVFrame *frame, int ret = 0; if (ost->enc_ctx) { - const AVCodec *codec = ost->enc; + const AVCodec *codec = ost->enc_ctx->codec; AVCodecContext *dec = NULL; InputStream *ist; @@ -3179,7 +3180,7 @@ static int init_output_stream(OutputStream *ost, AVFrame *frame, return ret; } - if (ist && ist->dec->type == AVMEDIA_TYPE_SUBTITLE && ost->enc->type == AVMEDIA_TYPE_SUBTITLE) { + if (ist && ist->dec->type == AVMEDIA_TYPE_SUBTITLE && codec->type == AVMEDIA_TYPE_SUBTITLE) { int input_props = 0, output_props = 0; AVCodecDescriptor const *input_descriptor = avcodec_descriptor_get(dec->codec_id); @@ -3206,8 +3207,8 @@ static int init_output_stream(OutputStream *ost, AVFrame *frame, ost->file_index, ost->index); return ret; } - if (ost->enc->type == AVMEDIA_TYPE_AUDIO && - !(ost->enc->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)) + if (codec->type == AVMEDIA_TYPE_AUDIO && + !(codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)) av_buffersink_set_frame_size(ost->filter->filter, ost->enc_ctx->frame_size); assert_avoptions(ost->encoder_opts); @@ -3419,7 +3420,7 @@ static int transcode_init(void) av_log(NULL, AV_LOG_INFO, " (graph %d)", ost->filter->graph->index); av_log(NULL, AV_LOG_INFO, " -> Stream #%d:%d (%s)\n", ost->file_index, - ost->index, ost->enc ? ost->enc->name : "?"); + ost->index, ost->enc_ctx->codec->name); continue; } @@ -3430,7 +3431,7 @@ static int transcode_init(void) ost->index); if (ost->enc_ctx) { const AVCodec *in_codec = input_streams[ost->source_index]->dec; - const AVCodec *out_codec = ost->enc; + const AVCodec *out_codec = ost->enc_ctx->codec; const char *decoder_name = "?"; const char *in_codec_name = "?"; const char *encoder_name = "?"; @@ -3826,7 +3827,7 @@ static int process_input(int file_index) OutputStream *ost = output_streams[j]; if (ost->source_index == ifile->ist_index + i && - (!ost->enc_ctx || ost->enc->type == AVMEDIA_TYPE_SUBTITLE)) { + (!ost->enc_ctx || ost->enc_ctx->codec_type == AVMEDIA_TYPE_SUBTITLE)) { OutputFile *of = output_files[ost->file_index]; output_packet(of, ost->pkt, ost, 1); } diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 50654bf8db..68f24bd1d3 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -509,7 +509,6 @@ typedef struct OutputStream { AVBSFContext *bsf_ctx; AVCodecContext *enc_ctx; - const AVCodec *enc; int64_t max_frames; AVFrame *filtered_frame; AVFrame *last_frame; diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index e9479018e4..ac8d81c8aa 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -90,6 +90,7 @@ choose_pixel_fmt(const AVCodec *codec, enum AVPixelFormat target, static const char *choose_pix_fmts(OutputFilter *ofilter, AVBPrint *bprint) { OutputStream *ost = ofilter->ost; + AVCodecContext *enc = ost->enc_ctx; const AVDictionaryEntry *strict_dict = av_dict_get(ost->encoder_opts, "strict", NULL, 0); if (strict_dict) // used by choose_pixel_fmt() and below @@ -103,14 +104,14 @@ 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, ost->enc_ctx->pix_fmt, + return av_get_pix_fmt_name(choose_pixel_fmt(enc->codec, enc->pix_fmt, ost->enc_ctx->strict_std_compliance)); - } else if (ost->enc->pix_fmts) { + } else if (enc->codec->pix_fmts) { const enum AVPixelFormat *p; - p = ost->enc->pix_fmts; + p = enc->codec->pix_fmts; if (ost->enc_ctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) { - p = get_compliance_normal_pix_fmts(ost->enc, p); + p = get_compliance_normal_pix_fmts(enc->codec, p); } for (; *p != AV_PIX_FMT_NONE; p++) { @@ -1095,8 +1096,8 @@ int configure_filtergraph(FilterGraph *fg) for (i = 0; i < fg->nb_outputs; i++) { OutputStream *ost = fg->outputs[i]->ost; - if (ost->enc->type == AVMEDIA_TYPE_AUDIO && - !(ost->enc->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)) + if (ost->enc_ctx->codec_type == AVMEDIA_TYPE_AUDIO && + !(ost->enc_ctx->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)) av_buffersink_set_frame_size(ost->filter->filter, ost->enc_ctx->frame_size); } diff --git a/fftools/ffmpeg_hw.c b/fftools/ffmpeg_hw.c index 8acfeaf08f..88fa782470 100644 --- a/fftools/ffmpeg_hw.c +++ b/fftools/ffmpeg_hw.c @@ -461,7 +461,7 @@ int hw_device_setup_for_encode(OutputStream *ost) } for (i = 0;; i++) { - config = avcodec_get_hw_config(ost->enc, i); + config = avcodec_get_hw_config(ost->enc_ctx->codec, i); if (!config) break; @@ -472,7 +472,7 @@ int hw_device_setup_for_encode(OutputStream *ost) av_log(ost->enc_ctx, AV_LOG_VERBOSE, "Using input " "frames context (format %s) with %s encoder.\n", av_get_pix_fmt_name(ost->enc_ctx->pix_fmt), - ost->enc->name); + ost->enc_ctx->codec->name); ost->enc_ctx->hw_frames_ctx = av_buffer_ref(frames_ref); if (!ost->enc_ctx->hw_frames_ctx) return AVERROR(ENOMEM); @@ -487,7 +487,7 @@ int hw_device_setup_for_encode(OutputStream *ost) if (dev) { av_log(ost->enc_ctx, AV_LOG_VERBOSE, "Using device %s " "(type %s) with %s encoder.\n", dev->name, - av_hwdevice_get_type_name(dev->type), ost->enc->name); + av_hwdevice_get_type_name(dev->type), ost->enc_ctx->codec->name); ost->enc_ctx->hw_device_ctx = av_buffer_ref(dev->device_ref); if (!ost->enc_ctx->hw_device_ctx) return AVERROR(ENOMEM); diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 1ba7950bc1..1659cf55ba 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -1513,18 +1513,21 @@ static int get_preset_file_2(const char *preset_name, const char *codec_name, AV return ret; } -static int choose_encoder(OptionsContext *o, AVFormatContext *s, OutputStream *ost) +static int choose_encoder(OptionsContext *o, AVFormatContext *s, + OutputStream *ost, const AVCodec **enc) { enum AVMediaType type = ost->st->codecpar->codec_type; char *codec_name = NULL; + *enc = NULL; + if (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO || type == AVMEDIA_TYPE_SUBTITLE) { MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, ost->st); if (!codec_name) { ost->st->codecpar->codec_id = av_guess_codec(s->oformat, NULL, s->url, NULL, ost->st->codecpar->codec_type); - ost->enc = avcodec_find_encoder(ost->st->codecpar->codec_id); - if (!ost->enc) { + *enc = avcodec_find_encoder(ost->st->codecpar->codec_id); + if (!*enc) { av_log(NULL, AV_LOG_FATAL, "Automatic encoder selection failed for " "output stream #%d:%d. Default encoder for format %s (codec %s) is " "probably disabled. Please choose an encoder manually.\n", @@ -1533,8 +1536,8 @@ static int choose_encoder(OptionsContext *o, AVFormatContext *s, OutputStream *o return AVERROR_ENCODER_NOT_FOUND; } } else if (strcmp(codec_name, "copy")) { - ost->enc = find_codec_or_die(codec_name, ost->st->codecpar->codec_type, 1); - ost->st->codecpar->codec_id = ost->enc->id; + *enc = find_codec_or_die(codec_name, ost->st->codecpar->codec_type, 1); + ost->st->codecpar->codec_id = (*enc)->id; } } @@ -1560,6 +1563,7 @@ static int check_opt_bitexact(void *ctx, const AVDictionary *opts, static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type, int source_index) { OutputStream *ost; + const AVCodec *enc; AVStream *st = avformat_new_stream(oc, NULL); int idx = oc->nb_streams - 1, ret = 0; const char *bsfs = NULL, *time_base = NULL; @@ -1583,15 +1587,15 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e ost->forced_kf_ref_pts = AV_NOPTS_VALUE; st->codecpar->codec_type = type; - ret = choose_encoder(o, oc, ost); + ret = choose_encoder(o, oc, ost, &enc); if (ret < 0) { av_log(NULL, AV_LOG_FATAL, "Error selecting an encoder for stream " "%d:%d\n", ost->file_index, ost->index); exit_program(1); } - if (ost->enc) { - ost->enc_ctx = avcodec_alloc_context3(ost->enc); + if (enc) { + ost->enc_ctx = avcodec_alloc_context3(enc); if (!ost->enc_ctx) { av_log(NULL, AV_LOG_ERROR, "Error allocating the encoding context.\n"); exit_program(1); @@ -1606,16 +1610,18 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e if (!ost->pkt) exit_program(1); - if (ost->enc) { + if (ost->enc_ctx) { + AVCodecContext *enc = ost->enc_ctx; AVIOContext *s = NULL; char *buf = NULL, *arg = NULL, *preset = NULL; - ost->encoder_opts = filter_codec_opts(o->g->codec_opts, ost->enc->id, oc, st, ost->enc); + ost->encoder_opts = filter_codec_opts(o->g->codec_opts, enc->codec_id, + oc, st, enc->codec); MATCH_PER_STREAM_OPT(presets, str, preset, oc, st); ost->autoscale = 1; MATCH_PER_STREAM_OPT(autoscale, i, ost->autoscale, oc, st); - if (preset && (!(ret = get_preset_file_2(preset, ost->enc->name, &s)))) { + if (preset && (!(ret = get_preset_file_2(preset, enc->codec->name, &s)))) { AVBPrint bprint; av_bprint_init(&bprint, 0, AV_BPRINT_SIZE_UNLIMITED); do { @@ -1729,7 +1735,7 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e av_dict_copy(&ost->sws_dict, o->g->sws_dict, 0); av_dict_copy(&ost->swr_opts, o->g->swr_opts, 0); - if (ost->enc && av_get_exact_bits_per_sample(ost->enc->id) == 24) + if (ost->enc_ctx && av_get_exact_bits_per_sample(ost->enc_ctx->codec_id) == 24) av_dict_set(&ost->swr_opts, "output_sample_bits", "24", 0); ost->source_index = source_index; @@ -1985,7 +1991,7 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in ost->logfile_prefix ? ost->logfile_prefix : DEFAULT_PASS_LOGFILENAME_PREFIX, nb_output_streams - 1); - if (!strcmp(ost->enc->name, "libx264")) { + if (!strcmp(ost->enc_ctx->codec->name, "libx264")) { av_dict_set(&ost->encoder_opts, "stats", logfilename, AV_DICT_DONT_OVERWRITE); } else { if (video_enc->flags & AV_CODEC_FLAG_PASS2) { @@ -3033,6 +3039,7 @@ static int open_output_file(OptionsContext *o, const char *filename) /* set the filter output constraints */ if (ost->filter) { + const AVCodec *c = ost->enc_ctx->codec; OutputFilter *f = ost->filter; switch (ost->enc_ctx->codec_type) { case AVMEDIA_TYPE_VIDEO: @@ -3042,24 +3049,24 @@ static int open_output_file(OptionsContext *o, const char *filename) if (ost->enc_ctx->pix_fmt != AV_PIX_FMT_NONE) { f->format = ost->enc_ctx->pix_fmt; } else { - f->formats = ost->enc->pix_fmts; + f->formats = c->pix_fmts; } break; case AVMEDIA_TYPE_AUDIO: if (ost->enc_ctx->sample_fmt != AV_SAMPLE_FMT_NONE) { f->format = ost->enc_ctx->sample_fmt; } else { - f->formats = ost->enc->sample_fmts; + f->formats = c->sample_fmts; } if (ost->enc_ctx->sample_rate) { f->sample_rate = ost->enc_ctx->sample_rate; } else { - f->sample_rates = ost->enc->supported_samplerates; + f->sample_rates = c->supported_samplerates; } if (ost->enc_ctx->ch_layout.nb_channels) { av_channel_layout_default(&f->ch_layout, ost->enc_ctx->ch_layout.nb_channels); - } else if (ost->enc->ch_layouts) { - f->ch_layouts = ost->enc->ch_layouts; + } else if (c->ch_layouts) { + f->ch_layouts = c->ch_layouts; } break; } From patchwork Thu Aug 25 08:59:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 37470 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp201160pzh; Thu, 25 Aug 2022 02:01:54 -0700 (PDT) X-Google-Smtp-Source: AA6agR4PMHgeA1OydlBOjQDRMHHiHBKobNbpz/hb9fShvbFKAGQYEK5eImU5TGS4CNZfuVMsGOg2 X-Received: by 2002:a17:907:75cd:b0:73d:8d05:1b35 with SMTP id jl13-20020a17090775cd00b0073d8d051b35mr1791569ejc.638.1661418114465; Thu, 25 Aug 2022 02:01:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661418114; cv=none; d=google.com; s=arc-20160816; b=LQW96y6XMvztfGuKFfuDzSqXEskN/Lgp555VmrZ82k2CCbJMc9/UFdrqWRAoWWhSTh /P3e87gugdT4QLjXFV6ToTDahZdqN2HeMHd4sDuSGxdhVqP4EQ22F2UES+5nDpoPGeF0 RsQJcZTiToDsx6ovIv4/Jor4BprsletK7qMMvgs4RbA+lORgAOHjQHgObQqKdnKHXHiK JxYYHWvsEm2IXmsQzo69K/3K1Uhq2hEpeOjyXPkb3PU63/HmuOVwQyeFIVUZQTiJvQfX ug3yaEb8LjQwU617pk59ra+ONBMLFu/sTmxRxaJdex1SuBZzVJyz7m3ODi8Dj4mnyJbb xKHQ== 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=z4PQU6fkPeY/cVIGxleuHp1UGtO+xcdxnBrRjffw2+o=; b=hU8CC4FD3ARZTolIaOMpiTGZokwohoBaCNFTGTiZLRQuLt3UleVNLYVpVfIEBoCgcV QePbRf0zrsREgEwX11RsWlwlxIclnXo6CyQz0DlZs2kQzsCmlyorf8XjfpBKQBE6K0kI ilydBeAa9SurAW8LsA0tPk9g0QesgDA/8NZXgZ9yvpy6Eb4gOVAsWjVVg96Rm4dCn4AI QYqNbcSyUZfs4/CSc1djPZ1TrG2R1px8rbT3UR37pgEvIXOsxNvRr0YH42Ez1qks0KuI A2XqjvjKANZFYhUcx7Pe60ta2JDZ/bvhSHh6FaP2Z2U/AfS72+eIqy/TNXoQKl6xyF4L aedw== 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 hc20-20020a170907169400b0072f66504cc1si3847102ejc.334.2022.08.25.02.01.54; Thu, 25 Aug 2022 02:01: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 CF84168B9E4; Thu, 25 Aug 2022 12:01:21 +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 CC1C368B9A4 for ; Thu, 25 Aug 2022 12:01:12 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 9589E240D18 for ; Thu, 25 Aug 2022 11:01:12 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id mEb6hcT6nBrh for ; Thu, 25 Aug 2022 11:01:12 +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 1F502240D1C for ; Thu, 25 Aug 2022 11:01:11 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 87A813A13BB; Thu, 25 Aug 2022 11:01:04 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 25 Aug 2022 10:59:55 +0200 Message-Id: <20220825085956.4790-5-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220825085956.4790-1-anton@khirnov.net> References: <20220825085956.4790-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 5/6] fftools/ffmpeg: drop OutputStream.fps_mode 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: gJzjbkLGMbp2 It is only used within new_video_stream(), so make it a local variable there. --- fftools/ffmpeg.h | 1 - fftools/ffmpeg_opt.c | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 68f24bd1d3..481b836d30 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -522,7 +522,6 @@ typedef struct OutputStream { AVRational max_frame_rate; enum VideoSyncMethod vsync_method; int is_cfr; - const char *fps_mode; int force_fps; int top_field_first; int rotate_overridden; diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 1659cf55ba..e8669afa12 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -1875,7 +1875,7 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in if (ost->enc_ctx) { AVCodecContext *video_enc = ost->enc_ctx; - const char *p = NULL; + const char *p = NULL, *fps_mode = NULL; char *frame_size = NULL; char *frame_pix_fmt = NULL; char *intra_matrix = NULL, *inter_matrix = NULL; @@ -2027,9 +2027,9 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in MATCH_PER_STREAM_OPT(top_field_first, i, ost->top_field_first, oc, st); ost->vsync_method = video_sync_method; - MATCH_PER_STREAM_OPT(fps_mode, str, ost->fps_mode, oc, st); - if (ost->fps_mode) - parse_and_set_vsync(ost->fps_mode, &ost->vsync_method, ost->file_index, ost->index, 0); + MATCH_PER_STREAM_OPT(fps_mode, str, fps_mode, oc, st); + if (fps_mode) + parse_and_set_vsync(fps_mode, &ost->vsync_method, ost->file_index, ost->index, 0); if (ost->vsync_method == VSYNC_AUTO) { if (!strcmp(oc->oformat->name, "avi")) { From patchwork Thu Aug 25 08:59:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 37472 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp201349pzh; Thu, 25 Aug 2022 02:02:16 -0700 (PDT) X-Google-Smtp-Source: AA6agR4bNu6CmR15zgn2NlJRkE5/HPod0h3TewYCWmTRyBcHQ0fpbddRM5OfSGUf99hrW3z0WvW3 X-Received: by 2002:a17:907:6e1c:b0:73d:7806:3c5e with SMTP id sd28-20020a1709076e1c00b0073d78063c5emr1797388ejc.36.1661418136369; Thu, 25 Aug 2022 02:02:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661418136; cv=none; d=google.com; s=arc-20160816; b=BDfALmL91XVz9WxouyF/C7rqlmlJUa8q3VN8++mLntzGPIVz/8cTBqgEPp24ez9e42 tgWBHKaXFGlkr4GLgGISXLLctap49VlOXO6V261nyREspmZDHJojv+4vZBmb9QyAS9SO t1Wi/D0ugFpcX+dcWpttQ56Mb5k2wGMKZQ4KFymztzNsC0BGV6nnGLQU9UTFdImPkIJT HiNjoSuyijsmjm0uScinmDB8zU4EEAghiw+keUT4tbsMgBrz+IT20EcMXsyw90TMFO9T EvUSrqoo4BqV6biTZci8a6Rxax0aZwnmF5amDW0efflq6aeCZWPdNIep5Rd2++8aju3h Wz7g== 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=e1srGVlOFyXzoyZ0e79Fphxe0io4D/oRvmF1a+sYeJk=; b=cOTTMlc8DO7hvH5nCkA7Rtp6r3kRfYVCajl75yamxHmEqY4xlZjq9PUawYDQ3Yjl8+ baC5VCF+AQu51tzcSKmW+BaGmAkIsU2HyYQ7vH30syJCDpw6vReEBy/keQf5smGSFCDs KHggdjyjVMPLMmuIYe/tZCH6c+LQXgn4wWyJ3VuEZeYFULpVyrtSCDYDXWfYYEPsD5Tk rvRIztAHHAtOTq6qbBM52RDgyTwED6l8pBX/NlGiOjvSR3t+vgzL2aA7fwkApbQWKeaM 44qoegjXMDC60Laj5/JlLTA+hQe7l6CRGnUr8AUi5WLCd2kEm3smOTTYBX73ZnPqjBZM SNJw== 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 hg6-20020a1709072cc600b0072a6c18f1fasi3354135ejc.639.2022.08.25.02.02.15; Thu, 25 Aug 2022 02:02:16 -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 1B33B68B6F0; Thu, 25 Aug 2022 12:01:24 +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 C187D68B9F2 for ; Thu, 25 Aug 2022 12:01:17 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 2EDD0240D1A for ; Thu, 25 Aug 2022 11:01:17 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id JEVitLkteA0B for ; Thu, 25 Aug 2022 11:01:12 +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 164CA240D1B for ; Thu, 25 Aug 2022 11:01:11 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 8C7E43A159F; Thu, 25 Aug 2022 11:01:04 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 25 Aug 2022 10:59:56 +0200 Message-Id: <20220825085956.4790-6-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220825085956.4790-1-anton@khirnov.net> References: <20220825085956.4790-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 6/6] fftools/ffmpeg: use a separate counter for encoded packet data size 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: DGDwqhXJc+qO update_video_stats() currently uses OutputStream.data_size to print the total size of the encoded stream so far and the average bitrate. However, that field is updated in the muxer thread, right before the packet is sent to the muxer. Not only is this racy, but the numbers may not match even if muxing was in the main thread due to bitstream filters, filesize limiting, etc. Introduce a new counter, data_size_enc, for total size of the packets received from the encoder and use that in update_video_stats(). Rename data_size to data_size_mux to indicate its semantics more clearly. No synchronization is needed for data_size_mux, because it is only read in the main thread in print_final_stats(), which runs after the muxer threads are terminated. --- fftools/ffmpeg.c | 22 +++++++++++++--------- fftools/ffmpeg.h | 6 ++++-- fftools/ffmpeg_mux.c | 2 +- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 4a825aa6b5..0bc97811b3 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -901,9 +901,9 @@ static void update_video_stats(OutputStream *ost, const AVPacket *pkt, int write ti1 = 0.01; bitrate = (pkt->size * 8) / av_q2d(enc->time_base) / 1000.0; - avg_bitrate = (double)(ost->data_size * 8) / ti1 / 1000.0; + avg_bitrate = (double)(ost->data_size_enc * 8) / ti1 / 1000.0; fprintf(vstats_file, "s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s ", - (double)ost->data_size / 1024, ti1, bitrate, avg_bitrate); + (double)ost->data_size_enc / 1024, ti1, bitrate, avg_bitrate); fprintf(vstats_file, "type= %c\n", av_get_picture_type_char(ost->pict_type)); } @@ -979,6 +979,8 @@ static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame) av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, &enc->time_base)); } + ost->data_size_enc += pkt->size; + if (enc->codec_type == AVMEDIA_TYPE_VIDEO) update_video_stats(ost, pkt, !!vstats_filename); @@ -1454,14 +1456,16 @@ static void print_final_stats(int64_t total_size) for (i = 0; i < nb_output_streams; i++) { OutputStream *ost = output_streams[i]; AVCodecParameters *par = ost->st->codecpar; + const uint64_t s = ost->data_size_mux; + 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; + case AVMEDIA_TYPE_VIDEO: video_size += s; break; + case AVMEDIA_TYPE_AUDIO: audio_size += s; break; + case AVMEDIA_TYPE_SUBTITLE: subtitle_size += s; break; + default: other_size += s; break; } extra_size += par->extradata_size; - data_size += ost->data_size; + data_size += s; if (ost->enc_ctx && (ost->enc_ctx->flags & (AV_CODEC_FLAG_PASS1 | AV_CODEC_FLAG_PASS2)) != AV_CODEC_FLAG_PASS1) @@ -1529,7 +1533,7 @@ static void print_final_stats(int64_t total_size) OutputStream *ost = output_streams[of->ost_index + j]; enum AVMediaType type = ost->st->codecpar->codec_type; - total_size += ost->data_size; + total_size += ost->data_size_mux; total_packets += atomic_load(&ost->packets_written); av_log(NULL, AV_LOG_VERBOSE, " Output stream #%d:%d (%s): ", @@ -1543,7 +1547,7 @@ static void print_final_stats(int64_t total_size) } av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" packets muxed (%"PRIu64" bytes); ", - atomic_load(&ost->packets_written), ost->data_size); + atomic_load(&ost->packets_written), ost->data_size_mux); av_log(NULL, AV_LOG_VERBOSE, "\n"); } diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 481b836d30..672f91dc13 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -579,8 +579,10 @@ typedef struct OutputStream { int keep_pix_fmt; /* stats */ - // combined size of all the packets written - uint64_t data_size; + // combined size of all the packets sent to the muxer + uint64_t data_size_mux; + // combined size of all the packets received from the encoder + uint64_t data_size_enc; // number of packets send to the muxer atomic_uint_least64_t packets_written; // number of frames/samples sent to the encoder diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index b424ef0021..b781e1f5a6 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -156,7 +156,7 @@ static int write_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt) } ms->last_mux_dts = pkt->dts; - ost->data_size += pkt->size; + ost->data_size_mux += pkt->size; atomic_fetch_add(&ost->packets_written, 1); pkt->stream_index = ost->index;