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 C423D45CB6 for ; Sun, 2 Apr 2023 22:25:37 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A202168BEC9; Mon, 3 Apr 2023 01:25:35 +0300 (EEST) Received: from btbn.de (btbn.de [136.243.74.85]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0185D68BE21 for ; Mon, 3 Apr 2023 01:25:28 +0300 (EEST) Received: from [authenticated] by btbn.de (Postfix) with ESMTPSA id 2942B2B1E8E for ; Mon, 3 Apr 2023 00:25:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rothenpieler.org; s=mail; t=1680474328; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TiI6wUX8grp0LPcjussGs1Axy06pV1/pAAATZTfAjus=; b=Mbd/e0dLezkwBoVu+yra7STel57bWMNs5dWgP6j4cW2qJLSdl7Ile+tolOGE6z1cML8YVO 41SR/g9Q/vTyrPQ08jq7HYdF4IiuGDkv3asUKZ8DtKL4xi+aZ/VyrENdGhXocsVlBTomVm 7HSV/FgF1v0gleOz5V0c7DSnPQpYtMYYgPJ2JdrphfVikdEIAJPDG3KUZVsegti9yZXJYk ec3FkqDzPCOAuEtUaLNlrVNtZliprQBFLqVobMhj5AaAYKlzQD/NS0lHZ41BlCo88q6kxN CJ20+9EAXhcDhufO/q1ZD17iz6zH4cav3oj53rJhe30hp3MZOpEE8lLkuWEkdQ== Message-ID: <5c9678e4-5251-3167-f432-2a7d4fb9bf29@rothenpieler.org> Date: Mon, 3 Apr 2023 00:25:27 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: <20230402220225.342600-1-tt2468@irltoolkit.com> From: Timo Rothenpieler In-Reply-To: <20230402220225.342600-1-tt2468@irltoolkit.com> Subject: Re: [FFmpeg-devel] [PATCH] avcodec/nvenc: fix b-frame DTS behavior with fractional framerates 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 03.04.2023 00:02, tt2468 wrote: > When using fractional framerates (or any fraction with a numerator != 1), > DTS values for packets would be calculated incorrectly. > > Signed-off-by: tt2468 If you want to sign your commits off, please use a proper name. A real name is not strictly required, but without it, a Sign-off becomes a bit pointless. > --- > libavcodec/nvenc.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c > index 9acf3e8697..8b02856507 100644 > --- a/libavcodec/nvenc.c > +++ b/libavcodec/nvenc.c > @@ -2266,7 +2266,8 @@ static int nvenc_set_timestamp(AVCodecContext *avctx, > dts = reorder_queue_dequeue(ctx->reorder_queue, avctx, pkt); > > if (avctx->codec_descriptor->props & AV_CODEC_PROP_REORDER) { > - pkt->dts = dts - FFMAX(ctx->encode_config.frameIntervalP - 1, 0) * FFMAX(avctx->ticks_per_frame, 1); > + pkt->dts = dts - > + FFMAX(ctx->encode_config.frameIntervalP - 1, 0) * FFMAX(avctx->time_base.num * avctx->ticks_per_frame, avctx->time_base.num); What if the time_base is unset? It's not really used anywhere else, so it might potentially never be set by some users. The whole right-side term has to at least stay 1. So probably something clunky like the following is needed: > FFMAX(avctx->time_base.num * avctx->ticks_per_frame, FFMAX(avctx->time_base.num, 1)) I'm also not sure if this is the right way to calculate this value still. What if someone sets a super weird timebase, like the mpeg-ts one? Not like it'd work correctly as it is right now, so I'm more wondering on how to make this more robust in general. Definitely looks like an improvement though, given that timebases like 1001/30000 exist, where just subtracting 1 or 2 would do barely anything. _______________________________________________ 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".