From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 31EAB49087 for ; Thu, 1 Feb 2024 00:10:38 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9046A68D13B; Thu, 1 Feb 2024 02:10:36 +0200 (EET) Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C601768C8CA for ; Thu, 1 Feb 2024 02:10:29 +0200 (EET) Received: by mail.gandi.net (Postfix) with ESMTPSA id 185AB60002 for ; Thu, 1 Feb 2024 00:10:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1706746229; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=/r8bGvpjwsyXk8X7073JPTfwFPo/MRALralpghuuKEs=; b=Q3QrNOtv0rk2ef8JF5e5+GEdGgq2p+HOuTRAfCzXL3aOp9w5Iy8HyvCwwR56cb32ggTsna MaAoKnCF1YnujLXns2sonMOE2/oucPc/CM64jLhBfBtv2UFrd+cmAanh0LGrmArpVIlHJA UOuWx5Fh9pJMIC7XU4FLvAYNs3CFUd9Dkrk32NzBkVvkcnMqdIO+X70TrOEoUjVyNGZCzl HdH8P9jx1B/FZucH1CNhtjabspUxRC5/dk+lWH7hAu2Hk0bec93bepC3iMb4uaCky+sQTq z/o+fmh98Mb60Qdbmw5UsCGu0WlsB3IssmXvilqyClnTtEWXX5wDK08die3Zlg== Date: Thu, 1 Feb 2024 01:10:28 +0100 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20240201001028.GB6420@pb2> References: <20240128030136.5585-1-cus@passwd.hu> <20240128030136.5585-3-cus@passwd.hu> <20240131000541.GP6420@pb2> <32ff862c-93f6-7c61-7168-801868f2f41d@passwd.hu> MIME-Version: 1.0 In-Reply-To: <32ff862c-93f6-7c61-7168-801868f2f41d@passwd.hu> X-GND-Sasl: michael@niedermayer.cc Subject: Re: [FFmpeg-devel] [PATCH 3/3] avfilter/yadif_common: fix timestamps with very small timebases 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 Content-Type: multipart/mixed; boundary="===============4721487993035933994==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============4721487993035933994== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="O2xZn31OH/0R4iBq" Content-Disposition: inline --O2xZn31OH/0R4iBq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jan 31, 2024 at 03:42:46AM +0100, Marton Balint wrote: >=20 >=20 > On Wed, 31 Jan 2024, Michael Niedermayer wrote: >=20 > > On Sun, Jan 28, 2024 at 04:01:36AM +0100, Marton Balint wrote: > > > Yadif filter assumed that the output timebase is always half of the i= nput > > > timebase. This is not true if halving the input time base is not repr= esentable > > > as an AVRational causing the output timestamps to be invalidly scaled= in such a > > > case. > > >=20 > > > So let's use av_reduce instead of av_mul_q when calculating the outpu= t time > > > base and if the conversion is inexact then let's fall back to the ori= ginal > > > timebase which probably makes more parctical sense than using x/INT_M= AX. > > >=20 > > > Fixes invalidly scaled pts_time values in this command line: > > > ffmpeg -f lavfi -i testsrc -vf settb=3Dtb=3D1/2000000000,yadif,showin= fo -f null none > > >=20 > > > Signed-off-by: Marton Balint > > > --- > > > libavfilter/yadif.h | 2 ++ > > > libavfilter/yadif_common.c | 20 ++++++++++++++------ > > > 2 files changed, 16 insertions(+), 6 deletions(-) > > >=20 > > > diff --git a/libavfilter/yadif.h b/libavfilter/yadif.h > > > index 2c4fed62d2..c144568242 100644 > > > --- a/libavfilter/yadif.h > > > +++ b/libavfilter/yadif.h > > > @@ -86,6 +86,8 @@ typedef struct YADIFContext { > > > * the first field. > > > */ > > > int current_field; ///< YADIFCurrentField > > > + > > > + int pts_divisor; > > > } YADIFContext; > > >=20 > > > void ff_yadif_init_x86(YADIFContext *yadif); > > > diff --git a/libavfilter/yadif_common.c b/libavfilter/yadif_common.c > > > index 933372529e..90a5cffc2d 100644 > > > --- a/libavfilter/yadif_common.c > > > +++ b/libavfilter/yadif_common.c > > > @@ -61,7 +61,7 @@ FF_ENABLE_DEPRECATION_WARNINGS > > > int64_t next_pts =3D yadif->next->pts; > > >=20 > > > if (next_pts !=3D AV_NOPTS_VALUE && cur_pts !=3D AV_NOPTS_VA= LUE) { > > > - yadif->out->pts =3D cur_pts + next_pts; > > > + yadif->out->pts =3D (cur_pts + next_pts) / yadif->pts_di= visor; > > > } else { > > > yadif->out->pts =3D AV_NOPTS_VALUE; > > > } > > > @@ -150,8 +150,8 @@ int ff_yadif_filter_frame(AVFilterLink *link, AVF= rame *frame) > > > ff_ccfifo_inject(&yadif->cc_fifo, yadif->out); > > > av_frame_free(&yadif->prev); > > > if (yadif->out->pts !=3D AV_NOPTS_VALUE) > > > - yadif->out->pts *=3D 2; > > > - yadif->out->duration *=3D 2; > > > + yadif->out->pts *=3D 2 / yadif->pts_divisor; > > > + yadif->out->duration *=3D 2 / yadif->pts_divisor; > > > return ff_filter_frame(ctx->outputs[0], yadif->out); > > > } > > >=20 > > > @@ -168,9 +168,9 @@ FF_ENABLE_DEPRECATION_WARNINGS > > > yadif->out->flags &=3D ~AV_FRAME_FLAG_INTERLACED; > > >=20 > > > if (yadif->out->pts !=3D AV_NOPTS_VALUE) > > > - yadif->out->pts *=3D 2; > > > + yadif->out->pts *=3D 2 / yadif->pts_divisor; > > > if (!(yadif->mode & 1)) > > > - yadif->out->duration *=3D 2; > > > + yadif->out->duration *=3D 2 / yadif->pts_divisor; > >=20 > > you can use >> instead of division for all above >=20 > Even for the first case? Because the right shift would be implementation > defined for negative timestamps. we are only supporting twos-complement systems i thought that was somewhete in teh docs thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Concerning the gods, I have no means of knowing whether they exist or not or of what sort they may be, because of the obscurity of the subject, and the brevity of human life -- Protagoras --O2xZn31OH/0R4iBq Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCZbrhcAAKCRBhHseHBAsP q/sZAJ4npoIj9wfO5p5TsNFhreT4F2mG4wCghpfWbtCwSd7Mh1UHl6KzL4fubGc= =dOyJ -----END PGP SIGNATURE----- --O2xZn31OH/0R4iBq-- --===============4721487993035933994== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". --===============4721487993035933994==--