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 DF8E1458B2 for ; Mon, 26 Jun 2023 17:47:34 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A171068C317; Mon, 26 Jun 2023 20:47:31 +0300 (EEST) Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4A1DD68C094 for ; Mon, 26 Jun 2023 20:47:25 +0300 (EEST) Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-573d70da2afso47110987b3.2 for ; Mon, 26 Jun 2023 10:47:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1687801643; x=1690393643; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=DWyshsv2BFQbfxyRwN6ZBtK/w2w5pv6F2QWJBHkTVxM=; b=fgULLFfR19PLfBZoleCF6/lOTcLtXtgag75H2YMAWg8yUIjw/aUVgi97E5SeF1CUKE 9zXkluRYiTrukxCGBCHhzVKOUxsAie3RtVgPPo39wwDwH5sGNsni67IRaE1LoXgtHCr9 85Dd2ICysO3nhFyarcEFts8nO29mf47PaczOdpyfRLzp2S73YUrjzwit+VFDNaYDTz3i NdDSa3vJbJ8izC+x3+PiRVAlhBBRwag5Fo4f+4KlffjuQ1EM8p+Ao8fDRqafnuBTm0x7 1r8y1RKKJK5Kh2V5WKo/5Kg+UNY9eSM0crOArz+aV4uw9cNRE+jRsEHZs4vRJBrH3Kig 8WeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687801643; x=1690393643; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=DWyshsv2BFQbfxyRwN6ZBtK/w2w5pv6F2QWJBHkTVxM=; b=cDTQuwj7yGdgqMyG+dJwtWUKA+7jRdrbEkWa21oDVhe4GSu2TXqbRGCK0EDJbhJUf7 3WANND/zi22C3h+HVSAC/jyn6rwmV9FbnVtht48GrOBUpZoPSo4dOdvenZp2OIEEymtT KGxGZS0Yp3MSdEz8zuLdZKg0wS8awulspr9762NOuF4cJKqj4a/qtWhsy1zmW3qw8F2v v/CfoNTp4og48jXIvuYWdQzdIhb1Ga7YgkUWxLKztP1w1wYvTwWeZAR4K6YE505tnKFS 7XvPPCS/oqOk440BvKhR+/VvvMtZJIunMsUmoBMxEXlxyJ4WbKBXj36kQi9aPj4DXGOc Wg6A== X-Gm-Message-State: AC+VfDznaRl8eQsHq2DgUV75a+M1A3tNzJeQt5hDL4I5Cmi71p/EXLpg uvKJJgkorHwn0Utvi7nqT2zNP7UkhL8lb5iJ7GVA8VYwXMLYO691Ww5wuYuA3ZcW4v9jVervYu8 gCTDE667tpm0GdiNOh2IzYPzEc3Rc4j73Q+tOKu8mi3ein8QShksTmLS+loVnKxX8ZLce X-Google-Smtp-Source: ACHHUZ6TYjRe2cqoJpBNIMjihRTG1eVBOb5J1M8nV8wC7sysbDvP7eokjrkI5K4cgEq9qaBOkQUiW1p+bVH8kA== X-Received: from vigneshv3.mtv.corp.google.com ([2620:0:1000:2511:63ba:95e9:b17:2db3]) (user=vigneshv job=sendgmr) by 2002:a25:7408:0:b0:ba8:929a:2073 with SMTP id p8-20020a257408000000b00ba8929a2073mr13311867ybc.1.1687801643382; Mon, 26 Jun 2023 10:47:23 -0700 (PDT) Date: Mon, 26 Jun 2023 10:47:09 -0700 Mime-Version: 1.0 X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog Message-ID: <20230626174715.2213497-1-vigneshv@google.com> From: Vignesh Venkatasubramanian To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH] libsvtav1: Add workaround for gop_size == 1 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 Cc: Vignesh Venkatasubramanian Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: In some versions of libsvtav1, setting intra_period_length to 0 does not produce the intended result (i.e.) all frames produced are not keyframes. Instead handle the gop_size == 1 as a special case by setting the pic_type to EB_AV1_KEY_PICTURE when encoding each frame so that all the output frames are keyframes. SVT-AV1 Bug: https://gitlab.com/AOMediaCodec/SVT-AV1/-/issues/2076 Example command: ffmpeg -f lavfi -i testsrc=duration=1:size=64x64:rate=30 -c:v libsvtav1 -g 1 -y test.webm Before: Only first frame is keyframe. After: All frames are keyframes. Signed-off-by: Vignesh Venkatasubramanian --- libavcodec/libsvtav1.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c index 718a04d221..f2b73361d8 100644 --- a/libavcodec/libsvtav1.c +++ b/libavcodec/libsvtav1.c @@ -242,9 +242,20 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param, if (avctx->level != FF_LEVEL_UNKNOWN) param->level = avctx->level; - if (avctx->gop_size > 0) + // gop_size == 1 case is handled when encoding each frame by setting + // pic_type to EB_AV1_KEY_PICTURE. For gop_size > 1, set the + // intra_period_length. Even though setting intra_period_length to 0 should + // work in this case, it does not. + // See: https://gitlab.com/AOMediaCodec/SVT-AV1/-/issues/2076 + if (avctx->gop_size > 1) param->intra_period_length = avctx->gop_size - 1; + // In order for SVT-AV1 to force keyframes by setting pic_type to + // EB_AV1_KEY_PICTURE on any frame, force_key_frames has to be set. Note + // that this does not force all frames to be keyframes (it only forces a + // keyframe with pic_type is set to EB_AV1_KEY_PICTURE). + param->force_key_frames = 1; + if (avctx->framerate.num > 0 && avctx->framerate.den > 0) { param->frame_rate_numerator = avctx->framerate.num; param->frame_rate_denominator = avctx->framerate.den; @@ -462,6 +473,9 @@ static int eb_send_frame(AVCodecContext *avctx, const AVFrame *frame) break; } + if (avctx->gop_size == 1) + headerPtr->pic_type = EB_AV1_KEY_PICTURE; + svt_av1_enc_send_picture(svt_enc->svt_handle, headerPtr); return 0; -- 2.41.0.162.gfafddb0af9-goog _______________________________________________ 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".