From patchwork Tue Oct 27 18:30:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 23252 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 6AB2244A1D5 for ; Tue, 27 Oct 2020 20:31:07 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 331206898C1; Tue, 27 Oct 2020 20:31:07 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0B95E6880B2 for ; Tue, 27 Oct 2020 20:31:01 +0200 (EET) Received: by mail-lj1-f182.google.com with SMTP id a5so2892148ljj.11 for ; Tue, 27 Oct 2020 11:31:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=F3Xc1bdOF4dbzH5jtOMPLC9UrC08+yLB+4gNWFVDcks=; b=aaTs/7EuQH8ph3diK0Fq/EetyVZjVQ5MpT0blGiVlc6JN6BDFK1LyOVdjQ2eHSFKbK sBjraMRmzS8QzdtUD3Xxs4aSXH8TxbEyZt/Knh9YeMqIhba/gxih/Jz3E740Z7bzAzOo B6lcMwQpLlMtdJECbPvJ3RBEEOKxGVYUqLR2cANvLYqQbNLeapYqooW4G4nGD/nh7nrX oHt4dgvEFaYN12SLvNMHP9Jroh4ivxIBP3f/4y2o1u9L8IKewxF9X3io4snHyihNKMS5 JhyzoY/l8FPOCRE0b7uenRZt4xfJ57PTjH4pW5UNp/aDjN1YAvzEnw5yJpgU2CX0YneC bLLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=F3Xc1bdOF4dbzH5jtOMPLC9UrC08+yLB+4gNWFVDcks=; b=knl9iA5bLDm8BZDLiTKcEH5c5urYLMTrP4E86Fvo6pSs//8Mb5l36u19EEmuAVQlRW Waidxs2Aw1TvTBvjpr1Z3oGwXGgr7rWxy7Ra8RW37hE/XZm+vwlZQR2cYieFUZSwYXZT LcZhU8sfJBFmtvu+6+SZdNzMMib8ABrrTkUrki21PBdtOMwnX+z8w7wEGvss6Ummm3C8 w+mSdz/3VMZ+5f9RRwoKt6fEwLbwhIYwmf1kWf5UVw302pCQJQ51a9MaA7t6bhg5jod2 1w9Cy3mkWo8YccNnMTo+sgwFrqI/VRZNktyC1gclB4Lz5oTSJ8Rtdn+vFFwBMbFseZvE M3Ew== X-Gm-Message-State: AOAM530Oi7pzIQidT+KlsLBEDbO32XFYRGo47CN23hvaqIvO0tpyfHre qWPQ3P+w4MvRVnOsKHI0ZGSG5QUxBmk= X-Google-Smtp-Source: ABdhPJxPUfA0ouxaIO+8eaHTWWt7np0q9F4dGcMebB+y6epdcETUF6D/B/Nq5wfwpeukH0jv8ytLpg== X-Received: by 2002:a2e:b542:: with SMTP id a2mr1300108ljn.7.1603823459648; Tue, 27 Oct 2020 11:30:59 -0700 (PDT) Received: from localhost.localdomain (91-159-194-103.elisa-laajakaista.fi. [91.159.194.103]) by smtp.gmail.com with ESMTPSA id a1sm255101lfg.63.2020.10.27.11.30.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Oct 2020 11:30:58 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Tue, 27 Oct 2020 20:30:51 +0200 Message-Id: <20201027183056.17993-1-jeebjp@gmail.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 0/5] ffmpeg: late A/V encoder init, AVFrame metadata usage X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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" This patch set started with a very simple wish to not have to set color related values manually each time when utilizing ffmpeg.c. As of the fourth iteration, the following changes were done since the third: 1. The data size threshold patch was moved to be the first one, thus meaning that there is no case of it not being applied, and the encoder initialization being moved later. 2. As noted by Anton, as the encoder options are applied after the AVFrame-based configuration, that code can be simplified to just simple passing of values instead of first checking if the option is set in the dictionary. 3. Interlaced/progressive and field order decision making commit has been reworded to include an explanation of the FATE test changes. Unfortunately, audio still needs two locations where the encoder is initialized, due to how avfilter_graph_request_oldest peeks and already puts one AVFrame to be available from the filter graph (which is then utilized as-is as an early return inside both av_buffersink_get_frame_flags and av_buffersink_get_samples). If this would be improved in lavfi (or the call to avfilter_graph_request_oldest removed), we could at least remove one of these. Currently limited to using values for video and started with the basic values, more can be added later if needed. This probably fixes some trac issues, but with a quick look I couldn't find anything that explicitly was due to lack of video color metadata passthrough. Jan Example 1: I have an RGB 3-D render, which I would like to encode into BT.709 YCbCr. The video filter I'm generally using for this (zscale) does flag the matrix in the output AVFrame. Yet to have the video encoder have the correct metadata set, I have to set the value(s) manually. With this patch set, the value(s) from the first AVFrame fed to do_video_out will be utilized. Example 2: I have an input video that sets one or more of the following: matrix/primaries/transfer function/range/chroma location. I just want to re-encode it. All of this metadata gets stripped. With this patch set, the value(s) from the first AVFrame fed to do_video_out will be utilized. Example 3: I have a video which has incorrect metadata tagged. Before, I had to set the correct data data manually. With this patch set, since ffmpeg.c takes color related options as dictionary keys, the AVFrame values will only be utilized if the user has not set the option for a given stream. Thus, this use case still works. Jan Ekström (5): ffmpeg: add a data size threshold for muxing queue size ffmpeg: move AVFrame time base adjustment into a function ffmpeg: move A/V non-streamcopy initialization to a later point ffmpeg: pass decoded or filtered AVFrame to output stream initialization ffmpeg: move field order decision making to encoder initialization doc/ffmpeg.texi | 5 + fftools/ffmpeg.c | 237 ++++++++++++------ fftools/ffmpeg.h | 11 + fftools/ffmpeg_opt.c | 8 + .../fate/concat-demuxer-extended-lavf-mxf_d10 | 2 +- .../fate/concat-demuxer-simple1-lavf-mxf_d10 | 2 +- tests/ref/fate/rgb24-mkv | 4 +- tests/ref/lavf/mxf_d10 | 2 +- tests/ref/lavf/mxf_dv25 | 2 +- tests/ref/lavf/mxf_dvcpro50 | 2 +- tests/ref/lavf/mxf_opatom | 2 +- 11 files changed, 192 insertions(+), 85 deletions(-)