From patchwork Sun Nov 27 17:03:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 39504 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp6960304pzb; Sun, 27 Nov 2022 09:07:53 -0800 (PST) X-Google-Smtp-Source: AA0mqf4zjitfnYUGtpUj5ab5lbdrC+7BSX0C26Ak3k2TUkCdi5owhzykJonqTup2GjfRpG42KTnY X-Received: by 2002:a05:6402:685:b0:46a:890d:b0d1 with SMTP id f5-20020a056402068500b0046a890db0d1mr16781342edy.292.1669568873334; Sun, 27 Nov 2022 09:07:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669568873; cv=none; d=google.com; s=arc-20160816; b=gPsH9PwQq3xb1yqUJcj74ZDnQx1ktfujAXdYZyHnMEf7OArgpXsq8cQe3R7bkGKsuO +Rc1P2CeLePWGqIXx7+JA/r+VvjMaz4zXQKDCmIzGXx2APf4JSjp7qrZSTq1c4cDxJoF 7wnl/sOlKmOanUrcWwJitRsrUmuEezTVnuTxzdSi26kzbfyseCtxhO0sBR52XwHr8uR1 2V7m5o8yW+rgbLCjqwDJHUBi/Rkxl709oswjUe8mQ2bRItfDfbM5zGndxer8zmsSkuky aynFL946woCMrp+jlyLKQ1P2ik50jaxInQdBcmYGxEoyJcg7gYeN9yc6vXXYyMWS+Vse d5hQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=ok2PZX/suwSDwANaPuBJc18JbPf3c50H/RUncMbvD88=; b=nFcKEz9cfJTxHsdqTR9THbk1caqfGDziHyZGOk8X69/kJWtg5bcDuFiUUYI/0jqU4N R6WmAoFEELkSYzX5idrn0C1S6GYMGpeuC/6Afo0wKUZmw1Qw5//fZR8bnicBq0vGQ5N3 KrbhRFpckrerQjTdscJaNOlgL5n3CYGHtAWKerQPf3daIniBWaY1yLGGZi/vuRRem9KL n4gDBI/5m1l5JMadAngCIjr7BmLfmyi+O6HGLkxd9pj88hVaTD0sndaHIziMiMyvazsR Y2sIWuhspkcC8mfCCV82JScE7kTj2T3/d9N+qa1KQElgkrvNyGHtOYGAe/D80YNPxT4/ FKYg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id hd34-20020a17090796a200b007833c7cf1dcsi10304057ejc.387.2022.11.27.09.07.52; Sun, 27 Nov 2022 09:07:53 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1BEE168BBCC; Sun, 27 Nov 2022 19:06:11 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 81D1A68B862 for ; Sun, 27 Nov 2022 19:06:00 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 7FCD92405EC for ; Sun, 27 Nov 2022 18:06:00 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id uEAb6sNu3iDO for ; Sun, 27 Nov 2022 18:06:00 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id DEB13240D1B for ; Sun, 27 Nov 2022 18:05:51 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 324603A2668 for ; Sun, 27 Nov 2022 18:05:47 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 27 Nov 2022 18:03:51 +0100 Message-Id: <20221127170351.11477-30-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221127170351.11477-1-anton@khirnov.net> References: <20221127170351.11477-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 30/30] lavc/libaomenc: pass through frame durations to encoded packets 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: oDx59cAExE3T --- libavcodec/libaomenc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c index bd576fdd3a..c117ca4ee6 100644 --- a/libavcodec/libaomenc.c +++ b/libavcodec/libaomenc.c @@ -1094,6 +1094,7 @@ static int storeframe(AVCodecContext *avctx, struct FrameListData *cx_frame, } memcpy(pkt->data, cx_frame->buf, pkt->size); pkt->pts = pkt->dts = cx_frame->pts; + pkt->duration = cx_frame->duration; if (!!(cx_frame->flags & AOM_FRAME_IS_KEY)) { pkt->flags |= AV_PKT_FLAG_KEY; @@ -1275,6 +1276,7 @@ static int aom_encode(AVCodecContext *avctx, AVPacket *pkt, AOMContext *ctx = avctx->priv_data; struct aom_image *rawimg = NULL; int64_t timestamp = 0; + unsigned long duration = 0; int res, coded_size; aom_enc_frame_flags_t flags = 0; @@ -1287,6 +1289,8 @@ static int aom_encode(AVCodecContext *avctx, AVPacket *pkt, rawimg->stride[AOM_PLANE_U] = frame->linesize[1]; rawimg->stride[AOM_PLANE_V] = frame->linesize[2]; timestamp = frame->pts; + duration = frame->duration ? frame->duration : + avctx->ticks_per_frame; switch (frame->color_range) { case AVCOL_RANGE_MPEG: rawimg->range = AOM_CR_STUDIO_RANGE; @@ -1300,8 +1304,7 @@ static int aom_encode(AVCodecContext *avctx, AVPacket *pkt, flags |= AOM_EFLAG_FORCE_KF; } - res = aom_codec_encode(&ctx->encoder, rawimg, timestamp, - avctx->ticks_per_frame, flags); + res = aom_codec_encode(&ctx->encoder, rawimg, timestamp, duration, flags); if (res != AOM_CODEC_OK) { log_encoder_error(avctx, "Error encoding frame"); return AVERROR_INVALIDDATA;