From patchwork Thu Feb 17 21:18:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vignesh Venkat X-Patchwork-Id: 34370 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:d078:0:0:0:0 with SMTP id x24csp341230nkx; Thu, 17 Feb 2022 13:18:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJypllsvT8EZXg/MmxhBulxP3R0ASLnvXouzzpvBeutQnMVcjmr2k0wAILYw0iNf1BQ9rSAe X-Received: by 2002:a17:906:154c:b0:6ce:21d7:2826 with SMTP id c12-20020a170906154c00b006ce21d72826mr3812816ejd.9.1645132738774; Thu, 17 Feb 2022 13:18:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645132738; cv=none; d=google.com; s=arc-20160816; b=QLfBgHNszFJcmE2fZn1pXI9Ilu8w2xF4feG11a/LJ7zh7DSaA32PiOd/1lfOVG6Qsx Gmqn+8WYcumdPdMn9R79jxNw/DLCxdRVfztbLbemHYVoc/Al1l3f8LdyWMG7MgiWZ5nC jvCaj6Qc9NBgn36Nd3VlSDvClVmWPBoODKuGsEYc9RNlZmvZTHQxfUmt0WR06urRoNIa VAYtMsNIft7qb3Scvls7/6rdrcyKm79lAfLG2NHtKTw65yQWHKXZo2BIKQyqDewFKOAr 28O+zdvF8RQU/KVmZjbZhngNrY1pGe4+mqrF2K72+QQWIXgTzgnjBhurJkwYoS/arrbA fKLA== 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=/RqRhjzGawjJ7uGAYtHWsr/ZXa07pPy0QLHyr3BtMy8=; b=Cq/C+y7U4T33GJ0KPoJHRgmRD4urXwk1PMN7H6IJuzi40SlTsKUa4xcvPEnNJxgVe6 uf++JtLGJwo7OnLK2viVCzWv5ULWRh45zs6huThrHJxOWYQa2gO1H9NGj4OStCnsOyeQ 0ZDXrSIbLIWW41TM0Q8kezmHDoyM1grhP+OXUVJEOlcVjdH+U4pcBPdWcumjrGXlekKR 3fq+YM+4Pa+w89dy/BDgdk+Y6qgcSVcKUbTVzCij5H3DoPVy3MsvsgoxgQPg/tenKI/P es2AHgNCasuy0aw9BJv1vSZD+NqOKo2elKaQ+lLgGsefs2CArISwWFApd0fTUpI+D4pf LwyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@google.com header.s=20210112 header.b=UaTb1jif; 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 q10si2501623eje.193.2022.02.17.13.18.58; Thu, 17 Feb 2022 13:18:58 -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=UaTb1jif; 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 582F668B369; Thu, 17 Feb 2022 23:18:54 +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 7D4A168AFDF for ; Thu, 17 Feb 2022 23:18:47 +0200 (EET) Received: by mail-yb1-f201.google.com with SMTP id i6-20020a255406000000b006241e97e420so3539748ybb.5 for ; Thu, 17 Feb 2022 13:18:47 -0800 (PST) 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=sciSRj6nGGz549fYDWh2uICzOlp80/aabSkZsB6uzQk=; b=UaTb1jifMHVqyMFHFXKlBIIt/Uz/UNusRyf93/+nnUOpjCl99oReNIe6zK9fGrqP2r S7WV56vgm3tALilS4U+XWxF3FvOfywDYZRkkE6EkCfrSrkRNNqAnLybEcLfjE7M6E124 pZ/vR/VB/Mgo3IM2zQEolr9g95iA8Dy4xeqrGCNRTNXz+O8BpNJC9YB+aXxUJ/v/kR6K hM6scgw+XHVstxZ6rl+q/4nSIPhQS7e1dadJZatxi2UChaXKJ/Sdo6p4Sd300vDpGX8y 7lxGhCXJFlpmlRhkpMCDSNMYEzYI9WlzU7hhE3R1ZGIZPN9nrNk8YTaILU2a9I/uAxS8 zqAA== 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=sciSRj6nGGz549fYDWh2uICzOlp80/aabSkZsB6uzQk=; b=q0SmHHQMd4fT2YWJJuB5ReeM44LIBl1Wlb9xVSW9AnjATlETPcpychbBPe4REGHpe4 pLAcDuKsGeTp9/mLRlkprbupg2sezKrfZx7oSB2HE2T56MHgGNLCH3DPc+gU5KboBvcA TJEYrJGioUXVUlinYZsbQJuSqSYyqsRqmZFOy2KQv/utC5cBYwc2vTF1Mi4m8HwXlWUC /UQe7gfSiTCnOP3bpUUFJCRNNoPOyX8gEOnqxaLXXSvY8VQLmMOLYqNzDFwHNgILboRD 7wgjEiFY4XVo3QH8CPvG+/9kVayLXaIdVtExAvwUt9jdYhKnZGOvLnkRFayBuTpiBhGS gZjw== X-Gm-Message-State: AOAM533m+6OOrbPl5Q5OSE5G5JQzRVwn9Njr6MWniqB+9r/tOJybP6U0 YqWt/3MJLoriUrBT0TrvQyO+fUw+dqpHJJmQR0gX61NSMyzWybzht5CKgpC3MpkMfvCzotwzsxN 9+JUogkGmC+zt4iDkOB2hi6VlEvYNehwbVcS1RntM0Yyrz5z5ROwyXrbpzFImHzeiXNeL X-Received: from vigneshv3.mtv.corp.google.com ([2620:0:1000:2511:7cc5:c12a:2cc2:684c]) (user=vigneshv job=sendgmr) by 2002:a81:b204:0:b0:2cf:aa3c:ab17 with SMTP id q4-20020a81b204000000b002cfaa3cab17mr4683147ywh.410.1645132725849; Thu, 17 Feb 2022 13:18:45 -0800 (PST) Date: Thu, 17 Feb 2022 13:18:38 -0800 In-Reply-To: <57c1a0f8-9704-5849-7465-1d33068c447b@gmail.com> Message-Id: <20220217211838.3404301-1-vigneshv@google.com> Mime-Version: 1.0 References: <57c1a0f8-9704-5849-7465-1d33068c447b@gmail.com> X-Mailer: git-send-email 2.35.1.265.g69c8d7142f-goog From: Vignesh Venkatasubramanian To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH] 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: 79r4m0X6WVw6 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..638c1deca6 100644 --- a/libavcodec/libaomenc.c +++ b/libavcodec/libaomenc.c @@ -99,6 +99,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; @@ -746,6 +747,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) { @@ -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 + { "still-picture", "Encode in single frame mode (typically used for still AVIF images).", OFFSET(still_picture), 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},