From patchwork Fri Apr 3 21:00:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Cao X-Patchwork-Id: 18617 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 3096C44A9B4 for ; Sat, 4 Apr 2020 00:07:18 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0B09E68AEE8; Sat, 4 Apr 2020 00:07:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2C4A9689AA9 for ; Sat, 4 Apr 2020 00:07:12 +0300 (EEST) Received: by mail-pg1-f196.google.com with SMTP id d17so4153692pgo.0 for ; Fri, 03 Apr 2020 14:07:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oNHq9NR9DS1mQujlc5Yx7PtqnILtQXQEt0noeJM2Gcc=; b=Stji273JotVjgGo4dEv/kyOhgiegS5jqEJt7ihrKhlcOxglpqfgnbuNYbLYkBwvXxt XQ2/2lYwlwwi0mawY5eGkK0PfBCPLLSvI+6rrbdoCCUQ+MivZbOZh4S6HVlx9aia5ule r+IdS2lvIoBt7FkguaX1r3L1G6WUzP7k+pLuSsX16ALJvDK9fHJlWCssiLJjmiXxIznS vbqBDB6Gncc7MLmYYu9MfRGJ/sUrK3hrjFiJStWpqocVm9tfPbvzhwsn8cBx3BvkfYpx erEUmP9dXszhOQsZBU54P9hYcggPCUDSswpznr+YVFXseT4gQlG3dkyYyw8FfJGv5h9c QQGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oNHq9NR9DS1mQujlc5Yx7PtqnILtQXQEt0noeJM2Gcc=; b=BtDuDPOfOE1FjG3bVktpE69Lkm6ezY6pwZftelms30IS8pT6mjUGKxVSA/P4DLXz4U CuS6SG0lRxBKO3tHtnSkhfuwzWb27B62p/6pYMWVipc0qs7aXHxqYQ6+cz+BB3wLtRTS T2pIaLWUVxdEMcy4MPykuEAkBBWN34Zst3ofcHm/m6XurLOepQPjhXcfclQGMS2LXnye V1xBouZ6g46YZvGyRCn2vaUP70jiZ0on4LnGpsvy+gxA5HHx3Tek9hemsXQ5GxLVfpjN IIaIz6+tBUBpIscrizm6QXiytjpjPL2KZlrn8iwPGEU1QOoWU1Cd4AsRYOFoTBnx03eW ssmg== X-Gm-Message-State: AGi0PuYbHb4Q1aB5n9XhulpvXSP+LFdJvhCN6jKFDvmOefiKw/aTgOvP y8LIBiAJ5Zo3pzdu48ET8D6QMVv21vA= X-Google-Smtp-Source: APiQypK16lIWQPvic9SjSr7DdpHFHcJGDciUrV8SqP08dV5GQTwWfnUneSlbDfRUQ4Nt7H8/XDEbxA== X-Received: by 2002:a63:e841:: with SMTP id a1mr10433244pgk.64.1585947639200; Fri, 03 Apr 2020 14:00:39 -0700 (PDT) Received: from wangcao.bej.corp.google.com ([2401:fa00:45:201:7885:4f90:fa40:35]) by smtp.gmail.com with ESMTPSA id lj14sm6394859pjb.25.2020.04.03.14.00.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Apr 2020 14:00:38 -0700 (PDT) From: Wang Cao X-Google-Original-From: Wang Cao To: ffmpeg-devel@ffmpeg.org Date: Sat, 4 Apr 2020 05:00:26 +0800 Message-Id: <20200403210026.133606-1-wangcao@google.com> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: References: MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 1/2] avcodec/libaomenc.c: Add a libaom command-line option 'tune' X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: Wang Cao Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Wang Cao --- doc/encoders.texi | 9 +++++++++ libavcodec/libaomenc.c | 7 +++++++ libavcodec/version.h | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/doc/encoders.texi b/doc/encoders.texi index e23b6b32fe..18bfe8f2eb 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -1508,6 +1508,15 @@ Complexity-based. Cyclic refresh. @end table +@item tune (@emph{tune}) +Set the distortion metric the encoder is tuned with. Default is @code{psnr}. + +@table @samp +@item psnr (@emph{0}) + +@item ssim (@emph{1}) +@end table + @item lag-in-frames Set the maximum number of frames which the encoder may keep in flight at any one time for lookahead purposes. Defaults to the internal diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c index 096aadbe1c..20b0e5c8e9 100644 --- a/libavcodec/libaomenc.c +++ b/libavcodec/libaomenc.c @@ -94,6 +94,7 @@ typedef struct AOMEncoderContext { int enable_intrabc; int enable_restoration; int usage; + int tune; } AOMContext; static const char *const ctlidstr[] = { @@ -132,6 +133,7 @@ static const char *const ctlidstr[] = { [AV1E_SET_ENABLE_INTRABC] = "AV1E_SET_ENABLE_INTRABC", #endif [AV1E_SET_ENABLE_CDEF] = "AV1E_SET_ENABLE_CDEF", + [AOME_SET_TUNING] = "AOME_SET_TUNING", }; static av_cold void log_encoder_error(AVCodecContext *avctx, const char *desc) @@ -699,6 +701,8 @@ static av_cold int aom_init(AVCodecContext *avctx, codecctl_int(avctx, AOME_SET_STATIC_THRESHOLD, ctx->static_thresh); if (ctx->crf >= 0) codecctl_int(avctx, AOME_SET_CQ_LEVEL, ctx->crf); + if (ctx->tune >= 0) + codecctl_int(avctx, AOME_SET_TUNING, ctx->tune); codecctl_int(avctx, AV1E_SET_COLOR_PRIMARIES, avctx->color_primaries); codecctl_int(avctx, AV1E_SET_MATRIX_COEFFICIENTS, avctx->colorspace); @@ -1096,6 +1100,9 @@ static const AVOption options[] = { { "usage", "Quality and compression efficiency vs speed tradeof", OFFSET(usage), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, VE, "usage"}, { "good", "Good quality", 0, AV_OPT_TYPE_CONST, {.i64 = 0 /* AOM_USAGE_GOOD_QUALITY */}, 0, 0, VE, "usage"}, { "realtime", "Realtime encoding", 0, AV_OPT_TYPE_CONST, {.i64 = 1 /* AOM_USAGE_REALTIME */}, 0, 0, VE, "usage"}, + { "tune", "The metric that encoder tunes. Automatically choosen by the encoder by default", OFFSET(tune), AV_OPT_TYPE_INT, {.i64 = -1}, -1, AOM_TUNE_SSIM, VE, "tune"}, + { "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"}, { NULL }, }; diff --git a/libavcodec/version.h b/libavcodec/version.h index f4d1d4de21..dadca75430 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #define LIBAVCODEC_VERSION_MAJOR 58 #define LIBAVCODEC_VERSION_MINOR 77 -#define LIBAVCODEC_VERSION_MICRO 101 +#define LIBAVCODEC_VERSION_MICRO 102 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \