From patchwork Wed Apr 13 20:39:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vignesh Venkat X-Patchwork-Id: 35309 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:671c:b0:7c:62c8:b2d1 with SMTP id q28csp404466pzh; Wed, 13 Apr 2022 13:39:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBVmAynX7BW4k4W7CXSijvAVRZMhb4ZNYF/pLznUqAcxmC8WoioweeLIPgVwEfuozLDaVA X-Received: by 2002:a17:907:6e04:b0:6e0:736b:d786 with SMTP id sd4-20020a1709076e0400b006e0736bd786mr40182327ejc.667.1649882380458; Wed, 13 Apr 2022 13:39:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649882380; cv=none; d=google.com; s=arc-20160816; b=OXDcgSIwbEU/VLOHqRkAS/JvtUQeH7Aiy8xdAcF4IRJpYxtt9ZoZOgSOGhJyOLtFQT +wtW/V/HaXVANWzUnA8VWqM5I8ckoSSJ7Mm0KepG0zw3fUu0HeIBbUDfGNl212vkpOWc bK9vqS2KcEKWsOzbjAzYSqqkpOn5nqcbfEy6C5Y84zuwcHlSNivFTKRvdficVwqXzUu+ T7K5N4Rzye2t35f76240W4VQ0osxnfzIkpFweh4GO3QF7QaSxp10XUJIDm9lFH/FtNCJ x/RxyF63qCskE1SBt3YyxNQgE4jHpKjJdCx3XQoGX7xNWOkgyX6yyFGqRS+7+QKuHthO iK/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:to:from:references:mime-version :message-id:in-reply-to:date:dkim-signature:delivered-to; bh=T+PPCcSLuWhctvasOW6bpuhuWPQvLZXt0dnatXDCNHs=; b=E5VnZtFaTCuL3Sz0mayNecpHqQuU1LSGpsuheFmajUeL23mM8FbTshawIleTL+b6AA VUqGcCBGEoxOHdeCtT8OjX8YaI/xmosfYjt6ywTwr5iO+GxDDDf0hPPbymd+gyIqln20 iDBthmiTP+cPGC0cnokBTWr5JqEORolHVxi6vpOX/tQCU6/3jgmvqKHiv3NTGyBJH67U R2jYeh6Uw6lx0jSpvTZdu8lhKiyfjmkUh4gINk1aekHnScRZl/R1krFgWnxJnXhp4rGL 8W+V3RUHJ+1/arjiiG2Mm35qDHxb95AkbRhX92behtHjpV7s5t02HnhtlhcwkNsjsbHp Hcqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@google.com header.s=20210112 header.b=TNxSVTrV; 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 s16-20020a056402037000b0041d664093e1si2248694edw.482.2022.04.13.13.39.39; Wed, 13 Apr 2022 13:39:40 -0700 (PDT) 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; dkim=neutral (body hash did not verify) header.i=@google.com header.s=20210112 header.b=TNxSVTrV; 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 2C5CB68B43E; Wed, 13 Apr 2022 23:39:36 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CA43368B360 for ; Wed, 13 Apr 2022 23:39:29 +0300 (EEST) Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-2e61c5a0eb7so25748657b3.22 for ; Wed, 13 Apr 2022 13:39:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=rDn2haR5vqJ4UydnzvgLnIpleYuPmJrdn8GZOUHJG74=; b=TNxSVTrVWEqEv15nN3kTzd3yDylazayxDzwGD2SCvp8N4N58l5c9EhKE8x7W3BmgFt H6cSgBRZ0QbSi94juR4r1qEeFTrbJ4+TQt1mosHQJKvkPTaIU9lJ3wk4HqfZPNIwyIQC SQ2oWYAhVQh97lE7HoWPCwOyjD766UtpgyBmlj4ptpt15oz45Bk+jowYpC+JT6WeUr0A GcrUttEpvJn9ypNvfm1vsIQhjdK4mLL9mrwHRIgvN0csu16eabJcfmI7y93r65M+kIXA VbV+tYPy1Bq/TovikeT8UIc+g0Om90V+azKMzohm6LbOc+N1Ijw+6Cz+Sr3AIw/E4gpk uWsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=rDn2haR5vqJ4UydnzvgLnIpleYuPmJrdn8GZOUHJG74=; b=2JCeYyewr+kTxuIRofqZsEkvb0Qh4AIUmwE/d/e3RQMy/DanYpelKndvvMzKyFWIwM Gjrp8zdSqbLCUu9LtO8NqI7DT/eyTHip7umc8QlXhwcdqg3ZbTMlpTBgxOAWslkHEg2I kbnJngeIr0yvUG3GTVcZReVdYZI+kx5RDZJ1p0fIuW5p4bS8gb9ICF6PDXOZvCws56Qu rM/U6/ILJuvEeq+JQge3CWnRek3P21OSVErCaCIkpTXacRYmxIqXAEcs8SPcAnn0Y6a7 AMhgYWBO+w65bTIdpMy2ZaKCGpikfg1PmEbukK34jGcJ3+KG278r77BjfPnq5T5I3idX mesg== X-Gm-Message-State: AOAM533HNlR6YMtnZl9akA+yA5ii7RIm91LU4EDH/xJCo19FZ4kqZWvx p++pFrcSsjxbvpq7Fx9ajLA0koO9IfXjzcquLMmPyyt6kxiw4bQ8iS/Bv+ymUmlDJVBkbXbGfaK ftsxkb05+VTFzyc+G+lmD7JNiUdZaDdmCrHnPIKuVBxMD6K+Lyk6wpYvbLm3cK59zrM9/ X-Received: from vigneshv3.mtv.corp.google.com ([2620:0:1000:2511:a185:f162:f2de:5a9]) (user=vigneshv job=sendgmr) by 2002:a05:6902:150d:b0:63d:f457:9384 with SMTP id q13-20020a056902150d00b0063df4579384mr589635ybu.601.1649882367601; Wed, 13 Apr 2022 13:39:27 -0700 (PDT) Date: Wed, 13 Apr 2022 13:39:18 -0700 In-Reply-To: <20220328204752.3339971-1-vigneshv@google.com> Message-Id: <20220413203918.3695742-1-vigneshv@google.com> Mime-Version: 1.0 References: <20220328204752.3339971-1-vigneshv@google.com> X-Mailer: git-send-email 2.35.1.1178.g4f1659d476-goog From: Vignesh Venkatasubramanian To: ffmpeg-devel@ffmpeg.org Subject: [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 Cc: Vignesh Venkatasubramanian Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: D/iCfwAft8RD 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 054903e6e2..0411773bbf 100644 --- a/libavcodec/libaomenc.c +++ b/libavcodec/libaomenc.c @@ -100,6 +100,7 @@ typedef struct AOMEncoderContext { int enable_restoration; int usage; int tune; + int still_picture; int enable_rect_partitions; int enable_1to4_partitions; int enable_ab_partitions; @@ -747,6 +748,18 @@ static av_cold int aom_init(AVCodecContext *avctx, if (res < 0) return res; + if (ctx->still_picture) { + // 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; + // 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) { @@ -1291,6 +1304,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 + { "still-picture", "Encode in single frame mode (typically used for still AVIF images).", OFFSET(still_picture), AV_OPT_TYPE_BOOL, {.i64 = 0}, -1, 1, VE }, { "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},