From patchwork Mon Mar 28 20:47:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vignesh Venkat X-Patchwork-Id: 35025 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c05:b0:7a:e998:b410 with SMTP id bw5csp526979pzb; Mon, 28 Mar 2022 13:48:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyK8hdYpHUZwIUSVuWdKs5JMyBg/0gwpssbFIKLQG+8h14/wbVZyR3e8oBIsfpan9H14c2s X-Received: by 2002:a17:906:d789:b0:6e0:bdd5:a884 with SMTP id pj9-20020a170906d78900b006e0bdd5a884mr18171942ejb.201.1648500487323; Mon, 28 Mar 2022 13:48:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648500487; cv=none; d=google.com; s=arc-20160816; b=kbxLQ534VLFEA3Oe19ImgYO0ZSNsM9m7ZYrOS356q8NMQ9fpannznw0AJvjzcPXo33 /orDCEo00RI8Gv3HjwW1Y/PhO8A1/W0huh5kG8XsX7wZpzyYjcbiI9hoQa7WiWxwq7mS +lB0mYgai2OyTUm5ZiiaAfd/EiL6My29XJNCZs7EB9p4osV0tVIkkcyfxw7kd27VZoPV BiJ58I/e7j/LQ6/YOK3fz6M/0U5/fH2rO3mrUOgzX0oIr5cpYQWzpMwxcZGPIJof5Nax pTo28SGYszxGkQoqgj1pduitX8T1L8fg1GLZk8AufnCuGO2Sieuvx2/2QRxEvwMzUbZE prtQ== 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=QT3O26n+gSlQUG9b3xR3qxK3/GH3KFjrJZfclq1s36Q=; b=j9EEM2ulC0g5AkOcGclnE7O7kxYA6SYmPm6kYZRI07K622NOqUU9+IrPhaowTLXFje C8oGqTb1tbgZH89QcENdFlutBYdO2UiN9T/7pl3OeNiQ3Ov9EUsDnoUmYP8vo1+zo8mC kWgfyslf1ouySkEjOEhwSX7fXZ5fxypSZNfkgn3BdinCPfwZhzJh/idJzqzf3qZhcpN3 SPK7bfHihIkfmsp3bzK3SRxqBQvw5liUlfg3gKY6/m7x+fsvYktyl+JeZG2DCpXVR+Lh kpS6OUwq/Qp4OxR8Ykfi453u+stlEBN5q9qzgsnrvS6SWbJ+z8mkM7gIck8xAJVxmNdL 6b/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@google.com header.s=20210112 header.b=Qoak2vGd; 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 a27-20020a17090640db00b006df7cded054si14703842ejk.698.2022.03.28.13.48.06; Mon, 28 Mar 2022 13:48:07 -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=Qoak2vGd; 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 C6C0A68B2B0; Mon, 28 Mar 2022 23:48:04 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org 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 DC43668B12C for ; Mon, 28 Mar 2022 23:47:57 +0300 (EEST) Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-2e6aaf57a0eso121438327b3.11 for ; Mon, 28 Mar 2022 13:47:57 -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=1vAAlgZlX8s8PPkF4mAcINGxifXRwtxAmQA7oyOh9bU=; b=Qoak2vGdF2D0pG77J7FS6WtrHrXJHxUjsFSiJXR6ERRB6lWGsXuwaImSRiGykdgyiN fT/zuLO5h9hOv4KarYwmibIpqELWSgrt4MyZXFykjWA/vIPyJ6YRA3nNW6XSwSZaj/yf mBqUmEFgeaIIjGYpe/7tyGGuI7S1yaDpTBNLCnSPXHemf8DD0/02UwDW/jFFvgcLXsLs LfPED6izkYSoobfS0Vbc4eBnqjI4buoKNUi8y1f+EXB7fJFgymJ9s7Wn5lCdn4MVulj9 joZaeqT2zRVcbaK945FpbnkleslTuNF1VjOs0q5o2ht5aHKCpUW9zW0jaxsM+3DkxbZ8 M6/Q== 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=1vAAlgZlX8s8PPkF4mAcINGxifXRwtxAmQA7oyOh9bU=; b=SowZMiJORchuz3hKTCcg+xybjVb6xVbly9En36f+Lz/U7UlwJvFpYlWNAvGqWDpi/T IaiSXp34bE1fgojcfw7dIR7o3LBPYBSNXW/UvCXRbvS2LxM8RuAassrwTIg2ChmKGV7S 0d4Rjz6VTqiqj+EMRHiHi69wtVCMJ4SBbGcVkPbw6PLRBcNYONjnXOpv5kgJ7qW4h0KL KSjB3KTp9zL5Z1mlsW+1iJb2wlDfxnBgrpNoxHanierODZJGqQPKiLyCI87Qe1jynvr0 qvoXt7SPttOgC2ouDFvZbunPjMzbtKwhtPNa6QhcscprDkB2KVyw/WjPL9ssIw3rVnQW ET8Q== X-Gm-Message-State: AOAM532auL3hL22JQZw6bAZnecXXT8Y+mytw+RlsL65TQ1ML8DfJ6jXC UT3/UinF1FpbuXUA9oERkvvzDm8VBe5gCixqEwCulTATG6dCVoXNfRtG4EnW73bQAcV8I09Hm+X H0pmW4xODV953aIi3tQPIclccV9g0zCG255ZRYK8BobwLylvlzrCfFJRF/bf0x1kPvuzJ X-Received: from vigneshv3.mtv.corp.google.com ([2620:0:1000:2511:228a:277d:bb24:94ea]) (user=vigneshv job=sendgmr) by 2002:a25:b9cb:0:b0:61d:a7a5:6005 with SMTP id y11-20020a25b9cb000000b0061da7a56005mr24058197ybj.360.1648500476557; Mon, 28 Mar 2022 13:47:56 -0700 (PDT) Date: Mon, 28 Mar 2022 13:47:52 -0700 In-Reply-To: <20220222213655.3049471-1-vigneshv@google.com> Message-Id: <20220328204752.3339971-1-vigneshv@google.com> Mime-Version: 1.0 References: <20220222213655.3049471-1-vigneshv@google.com> X-Mailer: git-send-email 2.35.1.1021.g381101b075-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: Qj0maOAq8XQK 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 7dbb6f6f39..ccd0823b97 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},