From patchwork Mon May 2 21:37:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vignesh Venkat X-Patchwork-Id: 35547 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a885:b0:7f:4be2:bd17 with SMTP id ca5csp88566pzb; Mon, 2 May 2022 14:37:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFEqGIvzrm0+e3MIBnY2QiXrbK5CSh/ZAkZ519UqwzJSU/8y750TxdcjSFhEQlFSNQpIj7 X-Received: by 2002:a17:907:3f10:b0:6da:818d:4525 with SMTP id hq16-20020a1709073f1000b006da818d4525mr12421939ejc.47.1651527435224; Mon, 02 May 2022 14:37:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651527435; cv=none; d=google.com; s=arc-20160816; b=HdUZq3qYc5se3Vr6ANcB01WyByOUTbcLa+XtZensCQaEIVYJXGFJZm1cDRFOlsyGTX hnO1iyrqHYXxG0mGPCQN6V+nk6cqt7OBRiZm1q42uLhvsfnfSF1R/XpuvLxEw20ZwfoH PSo+7wwAFDr2jtBbadNf9yKRGnRuWGbw6qbCyEtDOLrX7pCUDA0Qx5SyBTvuBgNNOj65 x1FySPHmJ7Lol2zB8L/NSNsOl/jTnHVQRm2lUaj1+zuBociyv+b3uxYK3m02sHo8BbfV 1iQAwxR5Pgk5ONDFMgbBPrHTa0k45duizGcpOJyCYILsA8ycLkujgqqH4ML7jpSDsTWf /xsw== 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=drTv66Uka6IdT9rukKotDFub8CInrD53NmqXqxHhKsE=; b=l/g7J8e96rUqiq4IUV6dLmeAqh69UJg4iOGPVo7YeS6+xnBD3EtGzU91Xv6R8aeO6C uYkrWJahQocMK01MMhqcAm1GYW+kWLGrJcZzn+FQOC9vqs4IdSgqLGzLmiU95H2vXdIS PDrLG2Q0vYUUsGHdAnXR00cSlMWgJEwnxBXuv7HP5ZZnlcwumL3p7lY/aAb9ZZAAmEFR WaR3LqMtLqoQlWJSMMU/gD9Bwg4TIfF4jex40Ot/zDG9PbTKxGaZI/aZ59HLnInlu+yg K+i0eXZ6/E4xtQwrquWoAZXQw2BDxGPtKn5sgQ29LD4CbcMSDfkB/BHSpqh7XGDSgUS1 wJoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@google.com header.s=20210112 header.b=A8EUvsR6; 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 s14-20020a056402014e00b0041d716cac8esi11874310edu.557.2022.05.02.14.37.14; Mon, 02 May 2022 14:37:15 -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=A8EUvsR6; 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 934DC68B2F7; Tue, 3 May 2022 00:37:12 +0300 (EEST) 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 8DA9568B0A6 for ; Tue, 3 May 2022 00:37:05 +0300 (EEST) Received: by mail-yb1-f201.google.com with SMTP id b33-20020a25aea1000000b0064588c45fbaso8868890ybj.16 for ; Mon, 02 May 2022 14:37:05 -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=oXCmEuZhS0Dr2TgjhoFpNW8T2V4dSh5M5R9X7SQeokA=; b=A8EUvsR6KQUswVp106Dwp4wHWJMI+txQbF331TV/LlExWuBodj0r9MWOEsHGIO0Ky+ mQMoEPgdm88/CrrSeQSrdjcgU3itF4B86Zj9TeaaM06PLQyKxlES/zDPmLFu0rhxUTli n+llFv8aQbjNzylFJhL8g5UgIn13VBRHVSjjcCiS2Z3TYZqnJqGAD8yEZ7qRum/Bj4Vd ANjCsMvHllGXT6jy55Rj0iIBbmiruX+vwW994nuQOXaTyKnasrDyygFm7NGvN+z9CKt7 C9exkPT8wYKH3aAlAoaUtWopNVTWnNVrse43dvMDvbhrIG4UXrEdQ5CjgBmNBDpOZPbZ Ii4w== 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=oXCmEuZhS0Dr2TgjhoFpNW8T2V4dSh5M5R9X7SQeokA=; b=KTRZFmKRMO7DAPDxqdBZLk3jwbUxvawBn75kq8FovsA24J6J9BulOMYVL/FDmHJbqx PvcLAxBM0xtwi3kcywV6JDshJJKtit/QqJABNlIBC5nO8ZVIil/chJ9BHgZioFNK9FY3 wmgv4Ru9DJwhQLmo4MIolVftDCnOCcpMnuz3l97C1n1s09DGRQwMD94oYiyxENh29fJu sNEQ1Fypp9cuKFjPcV1RSxowOVIsai+cphp3PKU0ZkPdWuhAuSpe5vY3K+o4MA1lmeSR bOoW/le+kbJMkknqk0MpjzQsYx5TrFgcO6LdbAOiZqrV1OxXSw95GQmQRxx5wHL1ech3 8SCA== X-Gm-Message-State: AOAM5301yRuvAYMUmgDhAlqbZDcwF3NjH+SHC52fevcTuvwWBFR+uj0J s2Ixd/4gcPAZSRTg64aonsrSnbeIkRd5B8QN1YZG3hoA061T2M3Ee1PtVvW2OgWleQ/GnfGwvgJ mx3sYbpppK0vdBdXoWMC/oduhV2DiaWlHGhMZVfK1YXUEB60r9xSZOH36N4I9E3T9Ki/T X-Received: from vigneshv3.mtv.corp.google.com ([2620:0:1000:2511:f699:797:bdbd:2026]) (user=vigneshv job=sendgmr) by 2002:a25:950:0:b0:648:ba7a:b98d with SMTP id u16-20020a250950000000b00648ba7ab98dmr12214136ybm.42.1651527424331; Mon, 02 May 2022 14:37:04 -0700 (PDT) Date: Mon, 2 May 2022 14:37:01 -0700 In-Reply-To: <20220413203918.3695742-1-vigneshv@google.com> Message-Id: <20220502213701.2462428-1-vigneshv@google.com> Mime-Version: 1.0 References: <20220413203918.3695742-1-vigneshv@google.com> X-Mailer: git-send-email 2.36.0.464.gb9c8b46e94-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: PaUA127mHp4K 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},