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 94D5348FD8 for ; Wed, 31 Jan 2024 00:05:53 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5159D68CAC6; Wed, 31 Jan 2024 02:05:50 +0200 (EET) Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 44D7168C353 for ; Wed, 31 Jan 2024 02:05:43 +0200 (EET) Received: by mail.gandi.net (Postfix) with ESMTPSA id 64260C0002 for ; Wed, 31 Jan 2024 00:05:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1706659542; 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=SQxPdAY5wum2Dm2d56PeOjmAN21D0nZPUtD7UR1rjJM=; b=b2u2tOy+0JXYNDc2fIszTH0uTAqiv1KOf/8G180+1jnRSU8TVWORrLQHRmra+zwgLPGQ9I Txh8nCZvbPpQ32R2tfWTWP03WXWy4WkZBhuCmuXwiNE7hXQ5Om6vfKLUwLMTVIHwQIvDvx gTmCu3p3JN5qFyLvLylTHE3Vkw2i3buBVImMxZONBFStD5CHy592kAGPR1MsRq7fFE+Qyi LFtF/89jDa+AXKWJ7cgh+Y5Z4BxTYACkC9moJW4fli5nMZXWFF5eDINioJ1Nt6wzP+JrCR Rod/erbZ9ZMV5VljNVIJrzBIf6QTrnDi9OzvJWLCcj6apojdcq+w4MLNmYKSwA== Date: Wed, 31 Jan 2024 01:05:41 +0100 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20240131000541.GP6420@pb2> References: <20240128030136.5585-1-cus@passwd.hu> <20240128030136.5585-3-cus@passwd.hu> MIME-Version: 1.0 In-Reply-To: <20240128030136.5585-3-cus@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="===============4687307561567947163==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============4687307561567947163== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="4anKvtMGVIMjoL5F" Content-Disposition: inline --4anKvtMGVIMjoL5F Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 input > timebase. This is not true if halving the input time base is not represen= table > 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 output ti= me > base and if the conversion is inexact then let's fall back to the original > timebase which probably makes more parctical sense than using x/INT_MAX. >=20 > Fixes invalidly scaled pts_time values in this command line: > ffmpeg -f lavfi -i testsrc -vf settb=3Dtb=3D1/2000000000,yadif,showinfo -= 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_VALUE)= { > - yadif->out->pts =3D cur_pts + next_pts; > + yadif->out->pts =3D (cur_pts + next_pts) / yadif->pts_diviso= r; > } else { > yadif->out->pts =3D AV_NOPTS_VALUE; > } > @@ -150,8 +150,8 @@ int ff_yadif_filter_frame(AVFilterLink *link, AVFrame= *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; you can use >> instead of division for all above otherwise should be ok thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Avoid a single point of failure, be that a person or equipment. --4anKvtMGVIMjoL5F Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCZbmO1QAKCRBhHseHBAsP q7IWAJwL99R1V15gNOZAJ1JdRXRbRqbuEwCfXB6x8mvsyGGLFCzQ7jqJCAF/wr4= =pdvB -----END PGP SIGNATURE----- --4anKvtMGVIMjoL5F-- --===============4687307561567947163== 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". --===============4687307561567947163==--