From patchwork Fri Dec 29 18:50:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 45387 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6623:b0:194:e134:edd4 with SMTP id n35csp4948592pzh; Fri, 29 Dec 2023 10:51:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IFVbOsX6hJAMGPnp9nLeJZFJTTuWpiCwH7Eovkb7K0WDjcFmojp+zglKnfUkQ6nNBpOcWv8 X-Received: by 2002:a17:907:b9d7:b0:a23:748f:c3f6 with SMTP id xa23-20020a170907b9d700b00a23748fc3f6mr4869430ejc.47.1703875878954; Fri, 29 Dec 2023 10:51:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703875878; cv=none; d=google.com; s=arc-20160816; b=iIaod0YtSdaGL1ujaV6cfTZmGAQvKmS9EgF6d88SNkEpHumezyljLOrJlSMI69/Sjv tDjJ1uxF99L7RhlCaaANqU4pdcEMRUBf2ZFxZ2ahSmFKF+aXsNd4NuT9Zn2i7UXKfmvg ZP8JY3nSU5oYV774mSEpWTcQMlKK/mxXSJR272ooZNXwZokkLXWHyGXqEba/O1q824O3 LPP7POMTf3dhVNC+7dZ8Wt9AMDQfYpPY8vQ+akmytxb8K7rn9bHOL8yTSK8Zxz7iWept n83BJX/bnc3/kCLGnTEDSU9forzlJG377R9jYGKDYTrvvKMGUnHx0hQ7td5SgW1o3JDw uk8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc: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=Ii5B3sUwQKC45z2LeRMpKjBWh49iISawg1HpELBK1Xk=; fh=s+G8Ss4JbeMFkWPSp2LmIH/LXFyBlALRiww1j3FPjHY=; b=XKOSo7iz/dQMiGmY7nqxNjdTPrWaXwXzOrpxfEa3LMnYEpl9GyDxwyUsJGbm4FF7Us yU1C7xguminRSOqGtEQy3GwUF2fcN2IkLPZHDDFNRGUkrj6V7+3VLJMSVJrws1EL2RCH K4xKciXA7xRr6dC4G1ul62klSuo0g5h77tlnk3JPEBcKknmF95Nktg4VaGo4Q6VoNTIF RUhpM58Jtn7tmS4EUeaR4hfBQYnQd6bJmUbQ561hR9p2vxNPVQSrQucY8sNdgXbb9QVC Kaspj/LdvmVGXxi/n8d6BsePjs/aHV46J6urA+oWtBZhbSTb9IhDkV9zRlE+WY2MvIRG 8Zdg== 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 e22-20020a1709067e1600b00a27b5876596si83368ejr.680.2023.12.29.10.51.18; Fri, 29 Dec 2023 10:51:18 -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 1EF8D68CB90; Fri, 29 Dec 2023 20:51:15 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4986668C1DF for ; Fri, 29 Dec 2023 20:51:07 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id E992EE8086; Fri, 29 Dec 2023 19:51:06 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZCHWc3qIKjAe; Fri, 29 Dec 2023 19:51:03 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 5B981E7DBB; Fri, 29 Dec 2023 19:51:03 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Fri, 29 Dec 2023 19:50:57 +0100 Message-Id: <20231229185059.18462-1-cus@passwd.hu> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/3] all: use av_channel_layout_describe_bprint instead of av_channel_layout_describe in a few places 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 Cc: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: nor6nD7UnFM0 Where an AVBPrint buffer is used later anyway. Signed-off-by: Marton Balint --- libavcodec/avcodec.c | 7 +------ libavfilter/af_amerge.c | 7 ++----- libavfilter/graphdump.c | 4 +--- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c index 2dda310e91..a6c8629f6c 100644 --- a/libavcodec/avcodec.c +++ b/libavcodec/avcodec.c @@ -656,12 +656,7 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode) if (enc->sample_rate) { av_bprintf(&bprint, "%d Hz, ", enc->sample_rate); } - { - char buf[512]; - int ret = av_channel_layout_describe(&enc->ch_layout, buf, sizeof(buf)); - if (ret >= 0) - av_bprintf(&bprint, "%s", buf); - } + av_channel_layout_describe_bprint(&enc->ch_layout, &bprint); if (enc->sample_fmt != AV_SAMPLE_FMT_NONE && (str = av_get_sample_fmt_name(enc->sample_fmt))) { av_bprintf(&bprint, ", %s", str); diff --git a/libavfilter/af_amerge.c b/libavfilter/af_amerge.c index 83318f99e4..eabd3f8262 100644 --- a/libavfilter/af_amerge.c +++ b/libavfilter/af_amerge.c @@ -153,7 +153,6 @@ static int config_output(AVFilterLink *outlink) AVFilterContext *ctx = outlink->src; AMergeContext *s = ctx->priv; AVBPrint bp; - char buf[128]; int i; s->bps = av_get_bytes_per_sample(outlink->format); @@ -162,12 +161,10 @@ static int config_output(AVFilterLink *outlink) av_bprint_init(&bp, 0, AV_BPRINT_SIZE_AUTOMATIC); for (i = 0; i < s->nb_inputs; i++) { av_bprintf(&bp, "%sin%d:", i ? " + " : "", i); - av_channel_layout_describe(&ctx->inputs[i]->ch_layout, buf, sizeof(buf)); - av_bprintf(&bp, "%s", buf); + av_channel_layout_describe_bprint(&ctx->inputs[i]->ch_layout, &bp); } av_bprintf(&bp, " -> out:"); - av_channel_layout_describe(&outlink->ch_layout, buf, sizeof(buf)); - av_bprintf(&bp, "%s", buf); + av_channel_layout_describe_bprint(&outlink->ch_layout, &bp); av_log(ctx, AV_LOG_VERBOSE, "%s\n", bp.str); return 0; diff --git a/libavfilter/graphdump.c b/libavfilter/graphdump.c index 80f7bf6c98..df79903c52 100644 --- a/libavfilter/graphdump.c +++ b/libavfilter/graphdump.c @@ -30,7 +30,6 @@ static int print_link_prop(AVBPrint *buf, AVFilterLink *link) { const char *format; - char layout[128]; AVBPrint dummy_buffer; if (!buf) { @@ -50,8 +49,7 @@ static int print_link_prop(AVBPrint *buf, AVFilterLink *link) format = av_x_if_null(av_get_sample_fmt_name(link->format), "?"); av_bprintf(buf, "[%dHz %s:", (int)link->sample_rate, format); - av_channel_layout_describe(&link->ch_layout, layout, sizeof(layout)); - av_bprintf(buf, "%s", layout); + av_channel_layout_describe_bprint(&link->ch_layout, buf); av_bprint_chars(buf, ']', 1); break; From patchwork Fri Dec 29 18:50:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 45388 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6623:b0:194:e134:edd4 with SMTP id n35csp4948638pzh; Fri, 29 Dec 2023 10:51:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IEfpDM5oiNMghenQ72jzFZLRdLNKoZPPNrWEyJ9wK+O2KMZ8TwAjidbzhwzchSbMKnT+aHi X-Received: by 2002:a17:906:46d8:b0:a23:5eb9:367d with SMTP id k24-20020a17090646d800b00a235eb9367dmr3603458ejs.227.1703875888507; Fri, 29 Dec 2023 10:51:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703875888; cv=none; d=google.com; s=arc-20160816; b=pGEbMhYqKMMDaWxhJHDddTkhA2Pl0xoVixpKPYQfmE6KCaED2DlNbWdDCvkezPoNKD Z6iJ8GJvt3wZ8d8DpMhjI/dXKk1DMUbrtNQJWOO0RvfS+rqk7iRyoHyJNEU52STPP6QI pMAgnZw1CYSeI7wjkyWnVU1XowlEUuIriQCOVS3SvPj27yBEkmvOCR8WjemqH/l44itJ /3x6Gpz7YBjLGeLQux/idTDHpJGsk7z8OIzdnWiTK5dLl40oMPKeXsuvPuhmHx7Sn2GC 0Hj4KT1mixSa2FemRc0ZymkEI5/6ADJlp0CMcZC7euMVSbJ1gk4HmpmxrhlxRnqXCQhy IbvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc: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=1f8etfUDkLqjo4s9kUnh22Qg+oxSVxtJHYuO7x4p1NQ=; fh=s+G8Ss4JbeMFkWPSp2LmIH/LXFyBlALRiww1j3FPjHY=; b=z2yIyPco+fIS1ZnA3k8veFEAJmqnI+LE9r13Q/TPCERjoaKhGzU3H6IZBhS6at74Mx DbulcJ8ggvX10EyoCqrcnTJY10UZTDBFsLSqtnsDiXdNBcFJHG1YB9lDJ2SmnCWMCd0Z do7vUKpQtVXOD+I9BfQv1NGMLQgwC1augjr3Uk2Hk7Jdlv6lPi/75xDPdKUdPYsnP6Ir lZRe/8P9xoQeBghEY3OnnAQbvCfCWRpb7x2/glHNj+QeUZrpkMR8h9HQQYJAdGOMAp6S 8vPQ2FlGYCWvo0joHxcHSlzaImKW1nBBh8b/1J/kgIQsrf07IuGcrdtrs9ZvUs48t3bJ y6pQ== 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 ew3-20020a170907950300b00a279d3ad57bsi503734ejc.242.2023.12.29.10.51.28; Fri, 29 Dec 2023 10:51:28 -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 15E8A68CC40; Fri, 29 Dec 2023 20:51:17 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2C15068CBD1 for ; Fri, 29 Dec 2023 20:51:10 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id F2906E7DBB; Fri, 29 Dec 2023 19:51:09 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QOwEozFyD4qY; Fri, 29 Dec 2023 19:51:08 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 6800DE9298; Fri, 29 Dec 2023 19:51:08 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Fri, 29 Dec 2023 19:50:58 +0100 Message-Id: <20231229185059.18462-2-cus@passwd.hu> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20231229185059.18462-1-cus@passwd.hu> References: <20231229185059.18462-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] fftools/ffmpeg_filter: honor -reinit_filters 0 even on changed display matrix 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 Cc: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: ZIQlIebFvddl Not sure about honoring it also in case of a hwaccel change, so left that as is for now. Signed-off-by: Marton Balint --- fftools/ffmpeg_filter.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index c1c3014453..680fffb060 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -2607,13 +2607,6 @@ static int send_frame(FilterGraph *fg, FilterGraphThread *fgt, break; } - if (!ifp->ist->reinit_filters && fgt->graph) - need_reinit = 0; - - if (!!ifp->hw_frames_ctx != !!frame->hw_frames_ctx || - (ifp->hw_frames_ctx && ifp->hw_frames_ctx->data != frame->hw_frames_ctx->data)) - need_reinit = 1; - if (sd = av_frame_get_side_data(frame, AV_FRAME_DATA_DISPLAYMATRIX)) { if (!ifp->displaymatrix_present || memcmp(sd->data, ifp->displaymatrix, sizeof(ifp->displaymatrix))) @@ -2621,6 +2614,13 @@ static int send_frame(FilterGraph *fg, FilterGraphThread *fgt, } else if (ifp->displaymatrix_present) need_reinit = 1; + if (!ifp->ist->reinit_filters && fgt->graph) + need_reinit = 0; + + if (!!ifp->hw_frames_ctx != !!frame->hw_frames_ctx || + (ifp->hw_frames_ctx && ifp->hw_frames_ctx->data != frame->hw_frames_ctx->data)) + need_reinit = 1; + if (need_reinit) { ret = ifilter_parameters_from_frame(ifilter, frame); if (ret < 0) From patchwork Fri Dec 29 18:50:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 45389 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6623:b0:194:e134:edd4 with SMTP id n35csp4948693pzh; Fri, 29 Dec 2023 10:51:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IGtkUopkKOh2TirGH43s+/d8cUWcp7MLPDlScP5t0PO8lBJqXj4sQU0v2BEckVMIeVg1hwN X-Received: by 2002:a50:8d54:0:b0:554:3b5d:b09c with SMTP id t20-20020a508d54000000b005543b5db09cmr6625315edt.22.1703875895968; Fri, 29 Dec 2023 10:51:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703875895; cv=none; d=google.com; s=arc-20160816; b=Yq3EYIkqW2Qc3+SF7f2WM54vdc66AdxhYk4MidG3ZICSLkfRgd8quVi8I4LQSFQvgh OmUVUrTJ1Kfs8HlEcFf4h/A1YUz6lXjG9k9lxACIfYLmxeh9BhhVFRATiHlA0v6HVUIp AoVgOObTCyrxu78USySJGGxCJRthJdy+BIZ/1IkvsqSM5w7VbfKB5matUJyn3CIr8s5F fIc3ky0+Yv9r0ktr3T5SQa1khnbV24BF3xpOlHjoqDZCpnDlNEQWqEzUY693jHAV76kX pICvFhi6UGdDYzAvTxbtXnuBimAEiIqVqGJJZEIXLPai85DQDnAv0uMR0gzzgDIYb5MT bpiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc: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=fNaje4rn+PfL/YFW27OMwWtEPAMcEfydklPQH48gqXU=; fh=s+G8Ss4JbeMFkWPSp2LmIH/LXFyBlALRiww1j3FPjHY=; b=eqUIloG5AsGU80BDMoavgkPrBFRx2PCHmxRJjjRCHL5KjdMPrzCnEfXEG7jZiDEzUT VbYsdBdcN3IpIDwyqU47spyfNqJyaU0JrBtq/5QFgW0sMUzIQ6keqDyLF1P0yi2HaN2p 5PzUlBOCM3V1N9mmnEDUsm1clorApGe3ItX3reLR9zxJGptLW1kB3xwJkF3cE9z+FJAx NCZ6EhMsK0KQ2nZosnac95XtaiKvwY0N5Ed9Z+CexTTTl7JwF/FQa/z9yFqJQaNOCgVD gYWmxV7Ewqnh4osF4EK0i24lVfzlfnAoA4Qxu7GRT81LCbr4a+ACMDXqNC4Yo7SMvmQm 3nHA== 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 z5-20020a05640235c500b005548f2e0e55si5729760edc.222.2023.12.29.10.51.35; Fri, 29 Dec 2023 10:51:35 -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 1F98668CCB8; Fri, 29 Dec 2023 20:51:22 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 667A168CC2A for ; Fri, 29 Dec 2023 20:51:15 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 303A7E9298; Fri, 29 Dec 2023 19:51:15 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4DJi22Y0GVF7; Fri, 29 Dec 2023 19:51:13 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 5AB4AE8086; Fri, 29 Dec 2023 19:51:13 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Fri, 29 Dec 2023 19:50:59 +0100 Message-Id: <20231229185059.18462-3-cus@passwd.hu> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20231229185059.18462-1-cus@passwd.hu> References: <20231229185059.18462-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/3] fftools/ffmpeg_filter: log an information message about filter graph reconfigurations 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 Cc: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: P6Cbnl2BitKE Filter graph reconfigurations can cause nontrivial issues, e.g. PTS discontinuities, so it is better to warn the user about them. Signed-off-by: Marton Balint --- fftools/ffmpeg_filter.c | 50 ++++++++++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 680fffb060..9dfc68a130 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -2585,41 +2585,50 @@ static int send_eof(FilterGraphThread *fgt, InputFilter *ifilter, return 0; } +enum ReinitReason { + VIDEO_CHANGED = (1 << 0), + AUDIO_CHANGED = (1 << 1), + MATRIX_CHANGED = (1 << 2), + HWACCEL_CHANGED = (1 << 3) +}; + static int send_frame(FilterGraph *fg, FilterGraphThread *fgt, InputFilter *ifilter, AVFrame *frame) { InputFilterPriv *ifp = ifp_from_ifilter(ifilter); FrameData *fd; AVFrameSideData *sd; - int need_reinit, ret; + int need_reinit = 0, ret; /* determine if the parameters for this input changed */ - need_reinit = ifp->format != frame->format; - switch (ifp->type) { case AVMEDIA_TYPE_AUDIO: - need_reinit |= ifp->sample_rate != frame->sample_rate || - av_channel_layout_compare(&ifp->ch_layout, &frame->ch_layout); + if (ifp->format != frame->format || + ifp->sample_rate != frame->sample_rate || + av_channel_layout_compare(&ifp->ch_layout, &frame->ch_layout)) + need_reinit |= AUDIO_CHANGED; break; case AVMEDIA_TYPE_VIDEO: - need_reinit |= ifp->width != frame->width || - ifp->height != frame->height; + if (ifp->format != frame->format || + ifp->width != frame->width || + ifp->height != frame->height) + need_reinit |= VIDEO_CHANGED; break; } if (sd = av_frame_get_side_data(frame, AV_FRAME_DATA_DISPLAYMATRIX)) { if (!ifp->displaymatrix_present || memcmp(sd->data, ifp->displaymatrix, sizeof(ifp->displaymatrix))) - need_reinit = 1; + need_reinit |= MATRIX_CHANGED; } else if (ifp->displaymatrix_present) - need_reinit = 1; + need_reinit |= MATRIX_CHANGED; if (!ifp->ist->reinit_filters && fgt->graph) need_reinit = 0; if (!!ifp->hw_frames_ctx != !!frame->hw_frames_ctx || (ifp->hw_frames_ctx && ifp->hw_frames_ctx->data != frame->hw_frames_ctx->data)) - need_reinit = 1; + need_reinit |= HWACCEL_CHANGED; if (need_reinit) { ret = ifilter_parameters_from_frame(ifilter, frame); @@ -2649,6 +2658,27 @@ static int send_frame(FilterGraph *fg, FilterGraphThread *fgt, if (ret < 0) return ret; + if (fgt->graph) { + AVBPrint reason; + av_bprint_init(&reason, 0, AV_BPRINT_SIZE_AUTOMATIC); + if (need_reinit & AUDIO_CHANGED) { + const char *fmtname = av_get_sample_fmt_name(frame->format); + av_bprintf(&reason, ", audio parameters changed to %d Hz, ", frame->sample_rate); + av_channel_layout_describe_bprint(&frame->ch_layout, &reason); + av_bprintf(&reason, ", %s", fmtname ? fmtname : "?"); + } + if (need_reinit & VIDEO_CHANGED) { + const char *fmtname = av_get_pix_fmt_name(frame->format); + av_bprintf(&reason, ", video parameters changed to %s, %dx%d", + fmtname ? fmtname : "?", frame->width, frame->height); + } + if (need_reinit & MATRIX_CHANGED) + av_bprintf(&reason, ", display matrix changed"); + if (need_reinit & HWACCEL_CHANGED) + av_bprintf(&reason, ", hwaccel changed"); + av_log(fg, AV_LOG_INFO, "Reconfiguring filter graph%s\n", reason.str); + } + ret = configure_filtergraph(fg, fgt); if (ret < 0) { av_log(fg, AV_LOG_ERROR, "Error reinitializing filters!\n");