From patchwork Sun Jan 17 00:26:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: emcodem X-Patchwork-Id: 24991 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 1F36B44B050 for ; Sun, 17 Jan 2021 02:26:18 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DDDF46807A6; Sun, 17 Jan 2021 02:26:17 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mxfilter2.cpanel.guru (mxfilter2.cpanel.guru [193.93.253.37]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DF36A6804B5 for ; Sun, 17 Jan 2021 02:26:10 +0200 (EET) Received: from cloud03.cpanel.guru (cloud03.cpanel.guru [193.93.253.53]) by mxfilter2.cpanel.guru (Halon) with ESMTPS id 97ffaf14-585a-11eb-a0ed-0050569e601f; Sun, 17 Jan 2021 01:26:08 +0100 (CET) Received: from [::1] (port=40114 helo=cloud03.cpanel.guru) by cloud03.cpanel.guru with esmtpa (Exim 4.93) (envelope-from ) id 1l0vtQ-00Et14-8K for ffmpeg-devel@ffmpeg.org; Sun, 17 Jan 2021 01:26:08 +0100 MIME-Version: 1.0 Date: Sun, 17 Jan 2021 01:26:08 +0100 From: emcodem@ffastrans.com To: ffmpeg-devel@ffmpeg.org User-Agent: Roundcube Webmail/1.4.10 Message-ID: <3af35fff5c1a757447a3bcf1cc994324@ffastrans.com> X-Sender: emcodem@ffastrans.com X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - cloud03.cpanel.guru X-AntiAbuse: Original Domain - ffmpeg.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - ffastrans.com X-Get-Message-Sender-Via: cloud03.cpanel.guru: authenticated_id: emcodem@ffastrans.com X-Authenticated-Sender: cloud03.cpanel.guru: emcodem@ffastrans.com X-Source: X-Source-Args: X-Source-Dir: Subject: [FFmpeg-devel] [PATCH] Populate field order returned by avs script, Trac Ticket 8757 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" The purpose of this is to tell ffmpeg which field order the returned clip of the avisynth .avs script decided to finally deliver, which is handy in an automated environment. Interlacing is generally a very hard topic in avisynth, the huge comment is neccessary to explain my reasons. Additionally to the comment in the patch, i can tell that i set unknown instead of progressive for backward compatibility. (i was struggeling with this, maybe i should have even left it unset in case it is not clearly tff or bff interlaced. /* Set interlacing type. http://avisynth.nl/index.php/Interlaced_fieldbased * The following typically only works when assumetff (-bff) and assumefieldbased is used in the avs. * This is because most avisynth source plugins do not set the parity info in the clip properties. * We could use GetParity() to be more accurate but it decodes a frame which is * expensive and can potentially lead to unforeseen behaviour when seeking later. * In case Parity is not known, we still cannot guarantee that */ Tests with different avisynth source plugins, e.g. directshowsource, ffms2, mpeg2source delivered the expected result. Make FATE passed. Subject: [PATCH] Populate field order returned by avs script, Trac Ticket 8757 --- libavformat/avisynth.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c index 2c08ace8db..67348a61d7 100644 --- a/libavformat/avisynth.c +++ b/libavformat/avisynth.c @@ -241,6 +241,26 @@ static int avisynth_create_stream_video(AVFormatContext *s, AVStream *st) st->nb_frames = avs->vi->num_frames; avpriv_set_pts_info(st, 32, avs->vi->fps_denominator, avs->vi->fps_numerator); + av_log(s, AV_LOG_TRACE, "avs_is_field_based: %d\n", avs_is_field_based(avs->vi)); + av_log(s, AV_LOG_TRACE, "avs_is_parity_known: %d\n", avs_is_parity_known(avs->vi)); + + st->codecpar->field_order = AV_FIELD_UNKNOWN; + if (avs_is_field_based(avs->vi)) { + /* Set interlacing type. http://avisynth.nl/index.php/Interlaced_fieldbased + * The following typically only works when assumetff (-bff) and assumefieldbased is used in the avs. + * This is because most avisynth source plugins do not set the parity info in the clip properties. + * We could use GetParity() to be more accurate but it decodes a frame which is + * expensive and can potentially lead to unforeseen behaviour when seeking later. + * In case Parity is not known, we still cannot guarantee that + */ + if (avs_is_tff(avs->vi)) { + st->codecpar->field_order = AV_FIELD_TT; + } + else if (avs_is_bff(avs->vi)) { + st->codecpar->field_order = AV_FIELD_BB; + } + } + switch (avs->vi->pixel_type) { /* 10~16-bit YUV pix_fmts (AviSynth+) */ case AVS_CS_YUV444P10: