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 309BB41D37 for ; Thu, 17 Feb 2022 21:21:18 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CC71368B363; Thu, 17 Feb 2022 23:21:16 +0200 (EET) Received: from mail-yw1-f173.google.com (mail-yw1-f173.google.com [209.85.128.173]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5C2AA68B29E for ; Thu, 17 Feb 2022 23:21:10 +0200 (EET) Received: by mail-yw1-f173.google.com with SMTP id 00721157ae682-2d646fffcc2so46461867b3.4 for ; Thu, 17 Feb 2022 13:21:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=PhtYNaQlCgtQspvl8ECkf3/MlNkU2rj3qs2mVYE6N1M=; b=IlZTXDPOLOk/2EzOsFtOl+HwuPYraD5DjAlghtSOrzQkiADKf3Uzh5AvIUg8fhSFAR QNjA4ha39WJknTQowR5sWyAAlUnc9a1m32Gkk7EIv8oPzriDdtUYRpJEWZb9gMfUHlIg DRjQyy4oPU/KD+kEUhBpyqLni46yLAlcz2npt01RYVWq74euN+dqS9CF/oFAuWsBFc7X MX5NGC33W8m3UXMQQj//JHN2yUCcd1xQMjPn7iUdxpFQDHF8Uw08b/5/zgiywAshupGp 6Jy1OoBcNZouFG9beibKN+Ho9RRa1gFrplzRtt7RR/X0xXjVeCvHuxqRzEUs6w9x9CDV TwDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=PhtYNaQlCgtQspvl8ECkf3/MlNkU2rj3qs2mVYE6N1M=; b=64XTZTN/pF4ypeG9Z0+7GWfmDnIqlrB3W59DX6Zoh3njJR1eykjst3fTWwgHR9PkJ+ RxU7/vyxeIxvtoQ7ItJjyQHs4Llh76zx6E5zhUnfUVB90rN6Byl4u1zflybBFm7Ah057 vhyEN4/DX8hqbywUvRNS1vI7GIexAUXxNnpEI+w/J8etihDdE2iP90dE2brzsGclOZIv /uvdKDZFEqHp4iljbx0QBTIbkLC0DRdQYYbYqdorLOM6LQHAGjVLi6euhM8OdaRz/Cht k3iqfSq+ohUCQTSlvLn64eJ2OhTMmGCeBMTVTgF4ONIMKSbrwFf2Xuau/sEMmv4Xm4Cq qYYA== X-Gm-Message-State: AOAM533BojicH9IXANv3ue4FZQEGMkBdFe1ox9XGlr4v38ymoolSXThO TcScNES1rNqh8eoqRq+AcUoD7P/sKNdmCzVSAcNZjPSejCM= X-Google-Smtp-Source: ABdhPJzZm5XYkvkDsjDDU8CLEG6HvT3xKizijVl6UzA6olue/QbYgVkRrsndoBliMGnJZcCPAIFjtkXa8CI4sNKA64w= X-Received: by 2002:a81:f0c:0:b0:2d6:83ab:7605 with SMTP id 12-20020a810f0c000000b002d683ab7605mr4626038ywp.150.1645132867551; Thu, 17 Feb 2022 13:21:07 -0800 (PST) MIME-Version: 1.0 References: <20220217055117.3233501-1-vigneshv@google.com> <57c1a0f8-9704-5849-7465-1d33068c447b@gmail.com> In-Reply-To: <57c1a0f8-9704-5849-7465-1d33068c447b@gmail.com> From: Vignesh Venkatasubramanian Date: Thu, 17 Feb 2022 13:20:56 -0800 Message-ID: To: FFmpeg development discussions and patches Subject: Re: [FFmpeg-devel] [PATCH 1/3] avcodec/libaomenc: Add parameter for avif single image encoding 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: 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: On Thu, Feb 17, 2022 at 1:00 PM James Almer wrote: > > > > On 2/17/2022 2:51 AM, Vignesh Venkatasubramanian wrote: > > Add a parameter to libaom-av1 encoder to enforce some of the single > > image constraints in the AV1 encoder. Setting this flag will limit > > the encoder to producing exactly one frame and the sequence header > > that is produced by the encoder will be conformant to the AVIF > > specification [1]. > > > > Part of Fixing Trac ticket #7621 > > > > [1] https://aomediacodec.github.io/av1-avif > > > > Signed-off-by:: Vignesh Venkatasubramanian > > --- > > libavcodec/libaomenc.c | 14 ++++++++++++++ > > 1 file changed, 14 insertions(+) > > > > diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c > > index 963cc1bcbc..0398060a2f 100644 > > --- a/libavcodec/libaomenc.c > > +++ b/libavcodec/libaomenc.c > > @@ -99,6 +99,7 @@ typedef struct AOMEncoderContext { > > int enable_restoration; > > int usage; > > int tune; > > + int is_avif; > > int enable_rect_partitions; > > int enable_1to4_partitions; > > int enable_ab_partitions; > > @@ -746,6 +747,18 @@ static av_cold int aom_init(AVCodecContext *avctx, > > if (res < 0) > > return res; > > > > + if (ctx->is_avif) { > > + // Set the maximum number of frames to 1. This will let libaom set > > + // still_picture and reduced_still_picture_header to 1 in the Sequence > > + // Header as required by AVIF still images. > > + enccfg.g_limit = 1; > > How will libaom react if you feed it more than 1 frame? Will it reject > the input and return an error? > Yes, trying to encode a second frame after setting g_limit to 1 will result in aom_codec_encode() returning an error. > > + // Reduce memory usage for still images. > > + enccfg.g_lag_in_frames = 0; > > + // All frames will be key frames. > > + enccfg.kf_max_dist = 0; > > + enccfg.kf_mode = AOM_KF_DISABLED; > > + } > > + > > /* Construct Encoder Context */ > > res = aom_codec_enc_init(&ctx->encoder, iface, &enccfg, flags); > > if (res != AOM_CODEC_OK) { > > @@ -1290,6 +1303,7 @@ static const AVOption options[] = { > > { "psnr", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AOM_TUNE_PSNR}, 0, 0, VE, "tune"}, > > { "ssim", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AOM_TUNE_SSIM}, 0, 0, VE, "tune"}, > > FF_AV1_PROFILE_OPTS > > + { "avif-image", "Encode in single frame mode for still AVIF images.", OFFSET(is_avif), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE }, > > Judging by the above settings, this option should be called > "still_picture". The description can mention it's required for AVIF output. > Renamed the variable and the option name to "still_picture". > An alternative is to add new AVProfiles, giving them values outside the > range that would be written into the sequence header. Like > FF_PROFILE_AV1_MAIN_STILL_PICTURE with a value of 0x80, > FF_PROFILE_AV1_HIGH_STILL_PICTURE with a value of 0x81, etc. > Then you just look for avctx->profile & 0x80 to know it's a still picture. > > Of course considerations would need to be done to avoid problems, like > the line "enccfg.g_profile = avctx->profile;" being changed to > "enccfg.g_profile = avctx->profile & 0x3;" (We can define a constant for > that 0x3 mask called profile_bits or whatever). > > > { "enable-rect-partitions", "Enable rectangular partitions", OFFSET(enable_rect_partitions), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE}, > > { "enable-1to4-partitions", "Enable 1:4/4:1 partitions", OFFSET(enable_1to4_partitions), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE}, > > { "enable-ab-partitions", "Enable ab shape partitions", OFFSET(enable_ab_partitions), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE}, > _______________________________________________ > 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". -- Vignesh _______________________________________________ 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".