From patchwork Thu Apr 13 14:12:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41148 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1286965pzb; Thu, 13 Apr 2023 07:16:32 -0700 (PDT) X-Google-Smtp-Source: AKy350ZKgoftddRaXWsjMHAdEdjqhfXNHY/FKq89FDe8Cy37ywzVJD5sBtOiDLe2GGv+eEAwN8Qh X-Received: by 2002:a05:6402:156:b0:506:6002:da69 with SMTP id s22-20020a056402015600b005066002da69mr3010744edu.15.1681395392149; Thu, 13 Apr 2023 07:16:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681395392; cv=none; d=google.com; s=arc-20160816; b=WmR7FbOL5Ent3Vi2ymWhd6q6L9kyapnMsXWTVUVzTqko8taTVQR266rADMHOfVtPX5 nuJoHf/L5vlilYppOm1p4q2L8lWlH7XmS6dRKMeACdO+RaiahvEQN6EykBWApVxOX4Nx y2JapevB1ni1s3qyT/FwxH20CDKjL96sDP0MehK18AwI+VZUp1wDwxquHtbnAsxGgpFX mhmq00uE0GN5j/c8mQGwLAd07Kp0GbKvKmHNEnNOGy3G48/BmsqJ4iikATPLU6N6RHaO BZZQxdwwcKKbYhLXUR7kee88yQXSwgJy42P0M6mK64a6wwZzzS9evBavYCFea4EJE2rR Nrtg== 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=LCIcn57DIlW2XAbodNuFrIV4znVQuAAKGBdRQ5I+hII=; b=fXzB3tMlpN8DWgh5g6U3Z3Cd2iXRwAoynw6xX8VrYfdMC8lPOROnFQ3KQHAq2WhH0g /0MN7Wy+adOaI34RyubgYzYIt7WBNxwo8ehGrhv5E/5Zb4dscJ16QcEIMDbpbenbpexO nNKfmJqh7R02o9OKru8XP6t29s6MDtExja/q+oIZiILFmqx7f/6wKkaVyJfd/jn7jQ5i DDMMdgETmz3AY23pSJwsqbloCuv83Dkz1qBv2Lsb/btleqiv/4CTjRWZPHQA8KpC0OUu IYqIkeU8CkkNqeCiJ5la+qX+pFRxWlo3PrBd0GaobLxLrGac+Hgdb0CLRSkcf5NSVQfK y8wQ== 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 b5-20020aa7cd05000000b0050296642330si1802561edw.2.2023.04.13.07.16.31; Thu, 13 Apr 2023 07:16:32 -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 8727268BE1B; Thu, 13 Apr 2023 17:16:03 +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 0B327680A2D for ; Thu, 13 Apr 2023 17:15:55 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id C67682404EC for ; Thu, 13 Apr 2023 16:15:54 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id kaaGPbGWknDy for ; Thu, 13 Apr 2023 16:15:54 +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 2E60C2404F8 for ; Thu, 13 Apr 2023 16:15:53 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 0DF4A3A0567 for ; Thu, 13 Apr 2023 16:15:53 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 13 Apr 2023 16:12:04 +0200 Message-Id: <20230413141223.17245-6-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230413141223.17245-1-anton@khirnov.net> References: <20230413141223.17245-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 06/25] fftools/ffmpeg: move a check to a more appropriate place 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: N667x1+2+PcO reap_filters() no longer needs to access the encoding context. --- fftools/ffmpeg.c | 21 +-------------------- fftools/ffmpeg_enc.c | 7 +++++++ 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 700fa5fbe1..4d4cbf6aaf 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -669,7 +669,6 @@ static int reap_filters(int flush) /* Reap all buffers present in the buffer sinks */ for (OutputStream *ost = ost_iter(NULL); ost; ost = ost_iter(ost)) { AVFilterContext *filter; - AVCodecContext *enc = ost->enc_ctx; int ret = 0; if (!ost->filter || !ost->filter->graph->graph) @@ -709,25 +708,7 @@ static int reap_filters(int flush) tb.num, tb.den); } - switch (av_buffersink_get_type(filter)) { - case AVMEDIA_TYPE_VIDEO: - enc_frame(ost, filtered_frame); - break; - case AVMEDIA_TYPE_AUDIO: - if (!(enc->codec->capabilities & AV_CODEC_CAP_PARAM_CHANGE) && - avcodec_is_open(enc) && - enc->ch_layout.nb_channels != filtered_frame->ch_layout.nb_channels) { - av_log(NULL, AV_LOG_ERROR, - "Audio filter graph output is not normalized and encoder does not support parameter changes\n"); - break; - } - enc_frame(ost, filtered_frame); - break; - default: - // TODO support subtitle filters - av_assert0(0); - } - + enc_frame(ost, filtered_frame); av_frame_unref(filtered_frame); } } diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index 0236e50e38..063053623f 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -789,6 +789,13 @@ static void do_audio_out(OutputFile *of, OutputStream *ost, AVCodecContext *enc = ost->enc_ctx; int ret; + if (!(enc->codec->capabilities & AV_CODEC_CAP_PARAM_CHANGE) && + enc->ch_layout.nb_channels != frame->ch_layout.nb_channels) { + av_log(ost, AV_LOG_ERROR, + "Audio channel count changed and encoder does not support parameter changes\n"); + return; + } + if (frame->pts == AV_NOPTS_VALUE) frame->pts = e->next_pts; else {