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 1BE07471A8 for ; Wed, 27 Sep 2023 22:14:18 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A47A068CAE3; Thu, 28 Sep 2023 01:14:15 +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 3EC0D68CA54 for ; Thu, 28 Sep 2023 01:14:09 +0300 (EEST) Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-59f8134eb83so148214637b3.2 for ; Wed, 27 Sep 2023 15:14:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695852847; x=1696457647; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=7ho5OAp3eCmPTuilLJPPg7I9zz+imSffva7tHOMyf5Q=; b=Kdd5T7nLR2dafjE3CEuf6d1mQ32O0jK5Mg+2sYMWn5QQ1wuAfY9YRNzxrCHr7p9z7l boluyhA7iY16BahX+z1HKhRjof5EWByiIh9PmV9x60k4OkIPl720MSrFFE0ejtjMOu2d HWj+cuWMfbhsW1/85GsFRMy86gE+spl4OtENIZT6K/XzW/tKWkZ3KMTbIo8Mkc9eUSIf tD278+US/pyN1oiOHgOrYLBqS1SMu2pYIKCxvVFXZYqC7nctkMhvP+Dt6BcWu6ra00VC FmsIYf6E0I4QW9hCcuk9P8hZhdjv6nH/q0x0dsc4U3KxbvHUD8bWEzKbijUHQ6bDHDyb UG9w== X-Gm-Message-State: AOJu0YyQNGc8CzPpjOau894M2pue7HTHKsKlacDafNLUXs4ZmPxJJZ/U RSeBlXMbg4vQvFVdovHnMmEHfHKrq2DQc4wmlAO91dRh5D/LIalWqgqmtGe3p9ngHxEsZvMWewg 1AA2+MXBwMUHhC6Ha+F7gxp8xPuLsCFLD7igUBxZwST8YrhXk4Oxyr85yQf3FgozH3+CB X-Google-Smtp-Source: AGHT+IGxWodaG5MqnVMymKAYxU3szEpYoGHMnmStxoQg84CM2Ty8SW9NXqBD1Gl6oaHhDK2nTby/Wi1nF90cAw== X-Received: from vigneshv3.mtv.corp.google.com ([2620:0:1000:2511:a068:cf4f:7b0:f4a7]) (user=vigneshv job=sendgmr) by 2002:a25:c058:0:b0:d80:19e5:76c8 with SMTP id c85-20020a25c058000000b00d8019e576c8mr42852ybf.12.1695852847331; Wed, 27 Sep 2023 15:14:07 -0700 (PDT) Date: Wed, 27 Sep 2023 15:13:58 -0700 Mime-Version: 1.0 X-Mailer: git-send-email 2.42.0.515.g380fc7ccd1-goog Message-ID: <20230927221403.3277953-1-vigneshv@google.com> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH] avcodec/svt-av1: Set pic_type only when 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: , From: Vignesh Venkatasubramanian via ffmpeg-devel 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: SVT-AV1 does not support requesting keyframes at arbitrary points by setting pic_type to EB_AV1_KEY_PICTURE. This patch changes the following: * Set pic_type to EB_AV1_KEY_PICTURE only when gop_size == 1. This only has an effect in this case (combined with force_key_frames). In all other cases, setting this has no effect. * Set force_key_frames to 1 only when gop_size == 1, this is needed for pic_type request above to work. Please see the comments in https://gitlab.com/AOMediaCodec/SVT-AV1/-/issues/2076 for a bit more details. Signed-off-by: Vignesh Venkatasubramanian --- libavcodec/libsvtav1.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c index 5015169244..3247c30f60 100644 --- a/libavcodec/libsvtav1.c +++ b/libavcodec/libsvtav1.c @@ -253,8 +253,11 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param, // 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; + // keyframe with pic_type is set to EB_AV1_KEY_PICTURE). As of now, SVT-AV1 + // does not support arbitrary keyframe requests by setting pic_type to + // EB_AV1_KEY_PICTURE, so it is done only when gop_size == 1. + if (avctx->gop_size == 1) + param->force_key_frames = 1; if (avctx->framerate.num > 0 && avctx->framerate.den > 0) { param->frame_rate_numerator = avctx->framerate.num; @@ -462,19 +465,8 @@ static int eb_send_frame(AVCodecContext *avctx, const AVFrame *frame) headerPtr->flags = 0; headerPtr->p_app_private = NULL; headerPtr->pts = frame->pts; - - switch (frame->pict_type) { - case AV_PICTURE_TYPE_I: - headerPtr->pic_type = EB_AV1_KEY_PICTURE; - break; - default: - // Actually means auto, or default. - headerPtr->pic_type = EB_AV1_INVALID_PICTURE; - break; - } - - if (avctx->gop_size == 1) - headerPtr->pic_type = EB_AV1_KEY_PICTURE; + // EB_AV1_INVALID_PICTURE means auto, or default. + headerPtr->pic_type = (avctx->gop_size == 1) ? EB_AV1_KEY_PICTURE : EB_AV1_INVALID_PICTURE; svt_av1_enc_send_picture(svt_enc->svt_handle, headerPtr); -- 2.42.0.515.g380fc7ccd1-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".