From patchwork Thu Feb 17 05:51:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vignesh Venkat X-Patchwork-Id: 34349 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:d078:0:0:0:0 with SMTP id x24csp352471nkx; Wed, 16 Feb 2022 21:51:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJwvh24MymvcIn8S9G40GKL/KHnxnD7VRBD9EmOS9t7EaAmEp7lSP9fNxVcgbBtfTwN5tWZc X-Received: by 2002:a05:6402:d6e:b0:410:8169:46de with SMTP id ec46-20020a0564020d6e00b00410816946demr1020252edb.328.1645077096638; Wed, 16 Feb 2022 21:51:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645077096; cv=none; d=google.com; s=arc-20160816; b=CDDWh3QPX1QRXlrnS/VWsgIAM60lnUOg7+UcI0hg9QPecK8Ic/s7/8RN31vG4GRiF9 wXXZJ5RaswGcg1JSz0MRtSLBhPTwxRG+riH6tVIMt3+k7EzKcZ9pKH7xoUv4+6fECr1w wT+ATGt+F/1qTMC5NHWEEpl2guwPH+xPxIthSLd01hoPIdJzA9NE/24mOEQX3uiMSSbs nFlguHTKVZMRyG2yFesr1nu98VedaoaT6HMBSdNKqmmVQAOH16tv9XObZsDRMAMh4hda FZRW767Le9nvz+CIf08p2HKB97pHYo+xDcFgJM9WM8X9pCtf4TkrA8KeKsZNJ0aD+YDN +njQ== 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:mime-version:message-id:date :dkim-signature:delivered-to; bh=pi4x5EGmtt8a1ibniT14whIg6iFv4HMNTU5lKPE0OGM=; b=h0c9qFMODYl8CjykWRAjW6LPd6ECXxXIqj9mC31BJVY3aUEyJLoHopWDdepX4M9o7z zw7mkXnzT6xGaTYLaB8yB8swH40CTY2DmIIUukzu+W5Mumx0xo2FGILyMiBR73ID2AIN xEvbF14MT56RXKIsEzfSMACLJ0bZx5scuzOcPgmW6Ide2roUacz7O7cL+TBC4DRDocVz KH6uVyvSOM1CPwr+T3ILbSzDHip7izsxhQoryNFA04D8UrzQxChOVWCOn1UougHK71n7 qdVJefDjLOfGYOzyMt474marwLt+iRkXPtHzmoBOsRYgAYS3WcaJlqz3/THgnx+jQk2s reXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@google.com header.s=20210112 header.b=osvzdGt5; 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 nd3si1567903ejc.49.2022.02.16.21.51.35; Wed, 16 Feb 2022 21:51:36 -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; dkim=neutral (body hash did not verify) header.i=@google.com header.s=20210112 header.b=osvzdGt5; 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 6828068B1E0; Thu, 17 Feb 2022 07:51:31 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 36B8E68AEB1 for ; Thu, 17 Feb 2022 07:51:24 +0200 (EET) Received: by mail-yb1-f201.google.com with SMTP id i4-20020a25a0c4000000b00623ab738437so6326696ybm.0 for ; Wed, 16 Feb 2022 21:51:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=jY8aC5fIgBpYhbh86WoX7XQz/lswekl54M4wR7waLfk=; b=osvzdGt5OyX+hXxpKuF9M3ej3yxIvDZGHX22pbW7mGVtYFZleCBjUktTgPTvrXOzIe Ywe+IUfoOc46+Vg7zGI3TYFSdjp1ffA21AZ2KPn7gZuEe6MAd3zIUJaEX9TutqM9zHnF 1CH2MiGjrpYBXbw4969vWKb2gEldhf9eEVRUj9l/N8g7t7653QlZP3kdjLQpi8j1Y+wA NyyXU/wb/U5bAMSXUhBOVzm0QKdZ04N+PiNV+uLFEryieSOQTIMXgVfxW0tphF8qwPWj UutiwPjGRvNv90tBFSwQLP5QOml/XyLjDsAjHH1SPhx/xUTAXQ8agJAUzOihPSW5Fc7z w/1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=jY8aC5fIgBpYhbh86WoX7XQz/lswekl54M4wR7waLfk=; b=KQk4axMJuDVICgY/5AGtgK/Esd/Jg83gT/xS5PxVcPof2+zaQLIimJBe8EmK62/bET AMX46D0VJgV9TsVrZGaEDJSU/If+mm+Y6a7y/hLzbBi7sTbZdlwkVPAVpeYDdToF9e/G /e8TJQ33RUq29czpnRI/6sXjBtnnnNUEgqTRhLRwwUVrYFy6YZ1/XlYrvUt7YvIx5gTI I9axBRdd4aVLeJG6oduRgdA2vUEiUfSBDQpcPbHfh0KGpa+xxtD+O2xUhE7GVzXOhs3n yPtpnXYAoeUyB6o9ZdJ/TJVu1jzqEqcBNqtPc3RvUUwJT2Gid72LuGlAbG3dF+91/2qc lmFw== X-Gm-Message-State: AOAM532yYWK8fZA6iZvv/qODksUKuVOnKcb/HAQMeuuY+ZeLUYo+gjyt WBJ2pu08mkmvYV7S7+sqN4yoK1wdfAqM7WKVtoKx8luHC422YgM2qVrXGgLzZEW7voI1/AVF1Ve BC+M6f8Rett9ApyvUXgMgBUEBkYcZoFk7vVYU3qzhwN9PWyWiUCPivT35r4qwIzP7elhc X-Received: from vigneshv3.mtv.corp.google.com ([2620:0:1000:2511:4804:9763:5ad6:9d1f]) (user=vigneshv job=sendgmr) by 2002:a81:644:0:b0:2d0:d34c:9170 with SMTP id 65-20020a810644000000b002d0d34c9170mr1178351ywg.204.1645077082250; Wed, 16 Feb 2022 21:51:22 -0800 (PST) Date: Wed, 16 Feb 2022 21:51:15 -0800 Message-Id: <20220217055117.3233501-1-vigneshv@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.35.1.265.g69c8d7142f-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: 6jsrGFH2oTGs 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; + // 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 }, { "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},