From patchwork Fri Dec 21 00:51:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rene Claus X-Patchwork-Id: 11508 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 0FE9044C9BC for ; Fri, 21 Dec 2018 02:51:46 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 33F3268AE70; Fri, 21 Dec 2018 02:51:46 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-vs1-f73.google.com (mail-vs1-f73.google.com [209.85.217.73]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7AAFD68AE6F for ; Fri, 21 Dec 2018 02:51:40 +0200 (EET) Received: by mail-vs1-f73.google.com with SMTP id c9so1600723vsd.4 for ; Thu, 20 Dec 2018 16:51:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=jLmXZcBd+4f2aFrAsoEdNCDQ7+07EOR7nORwjUC/OHs=; b=O+W7ECNFxxyKxj/PfZQ5ZLmw3NjFNZ9Gyp7xIYAUoumA1sAoUkvcfQHobnn8Yv0a8w zvpa2u+5zhY5/cQiePpshCW3CQq5ZzaL43G9a4c8YtWCJM/WDY0sBqSg3Jn9bKbd0pgI nDpgONXIWRhPb2+QuF0hpjlFOls0HhsCfyDFdcLCQ47/wVIzgCI1URweZreGLERD6tOl uU+YSKOLlXYHVpyKJiuiKUJ5HDXB90GQJPHGKexZPb3yV+l47aoNb4sIKuou1iBE4MoJ kUhz7/j3H959P/2ng5Ffdfwo7ICx74T1cUmm5ZIgqDG/xh8crLk5+BU+QFdRTuRiMcZS Dr0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=jLmXZcBd+4f2aFrAsoEdNCDQ7+07EOR7nORwjUC/OHs=; b=W/gwezRpfOJvleXpGFX0VExzxFlalTyRRbu2IpOtESi+TK6ZTNwgZIG5AjxA4ZWnOt +PxMsOqdwljszlfnmvWLFrBG1dCEWl80CAL7qk3KXPS1UJ+43k8bLJWzm17Hvu9KiQ8D Y5exy+cHPTjzkv1MRDbTbOTjcTJv8BVqTw4a5nZuwoD1Q+0ZcCPBK9RHoQzMewzHgE5f mzJZu8yKq/cQb+jgy2mGu1VBH72BxNt3v5Oc1W8o8iyBPpW7DUSkP58OQF5J7OYBE4eg 3gWNQCg8iODDd8fqAZHp1H2dhd3OyDOumTh5Vq1kJf1kaEGBssGY9MYXRQLIjakQXRDM TlJA== X-Gm-Message-State: AJcUukcFH/O/2ZgNB9bOL7OAW/dOvfHjboCBJTP/CSLTBHJwnAYWFiH4 69lc9D65X+/JSDwdDjP1uTWpAWQBwTTzaWk3G/NPhBYhyje98XkHThONKCaBoBvFEERJRlt/NcP C6bXuiXKOQVU2leiY3LTr6LkQYRBiyckmi3i/0hw953OrOFSseLaL/36auHf1yfo= X-Google-Smtp-Source: ALg8bN6ad0HWa0/su3juG+TndQ8YiBvJ/zqtnOLlyxB0bdUorCynzGsw5sPZ/w9/jZyk6eFHZwi5zm9hRkg= X-Received: by 2002:a1f:178e:: with SMTP id 136mr306622vkx.11.1545353501887; Thu, 20 Dec 2018 16:51:41 -0800 (PST) Date: Thu, 20 Dec 2018 16:51:35 -0800 In-Reply-To: <20181219182429.247347-1-rclaus@google.com> Message-Id: <20181221005135.126908-1-rclaus@google.com> Mime-Version: 1.0 References: <20181219182429.247347-1-rclaus@google.com> X-Mailer: git-send-email 2.20.1.415.g653613c723-goog From: Rene Claus To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH] avcodec/libvpxenc: add VP8/9 sharpness config option 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: Rene Claus Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This commit adds configuration options to libvpxenc.c that can be used to tune the sharpness parameter for VP8 and VP9. Signed-off-by: Rene Claus --- doc/encoders.texi | 4 ++++ libavcodec/libvpxenc.c | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/doc/encoders.texi b/doc/encoders.texi index 3d5b9fc2d2..7f9478fa9d 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -1767,6 +1767,10 @@ Set number of frames to look ahead for frametype and ratecontrol. @item error-resilient Enable error resiliency features. +@item sharpness @var{integer} +Codec control function to set higher sharpness at the expense of a lower PSNR. +The valid range is [0, 7]. Default is 0. + @item VP8-specific options @table @option @item ts-parameters diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index 39af586790..34d2624103 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -76,6 +76,7 @@ typedef struct VPxEncoderContext { struct FrameListData *coded_frame_list; int cpu_used; + int sharpness; /** * VP8 specific flags, see VP8F_* below. */ @@ -130,6 +131,7 @@ static const char *const ctlidstr[] = { [VP8E_SET_TUNING] = "VP8E_SET_TUNING", [VP8E_SET_CQ_LEVEL] = "VP8E_SET_CQ_LEVEL", [VP8E_SET_MAX_INTRA_BITRATE_PCT] = "VP8E_SET_MAX_INTRA_BITRATE_PCT", + [VP8E_SET_SHARPNESS] = "VP8E_SET_SHARPNESS", #if CONFIG_LIBVPX_VP9_ENCODER [VP9E_SET_LOSSLESS] = "VP9E_SET_LOSSLESS", [VP9E_SET_TILE_COLUMNS] = "VP9E_SET_TILE_COLUMNS", @@ -751,6 +753,9 @@ FF_ENABLE_DEPRECATION_WARNINGS return AVERROR(EINVAL); } + if (ctx->sharpness >= 0) + codecctl_int(avctx, VP8E_SET_SHARPNESS, ctx->sharpness); + if (CONFIG_LIBVPX_VP8_ENCODER && avctx->codec_id == AV_CODEC_ID_VP8) { #if FF_API_PRIVATE_OPT FF_DISABLE_DEPRECATION_WARNINGS @@ -1193,6 +1198,7 @@ static int vpx_encode(AVCodecContext *avctx, AVPacket *pkt, {"arnr_strength", "altref noise reduction filter strength", offsetof(VPxContext, arnr_strength), AV_OPT_TYPE_INT, {.i64 = 3}, 0, 6, VE}, \ {"arnr_type", "altref noise reduction filter type", offsetof(VPxContext, arnr_type), AV_OPT_TYPE_INT, {.i64 = 3}, 1, 3, VE}, \ {"rc_lookahead", "Number of frames to look ahead for alternate reference frame selection", offsetof(VPxContext, lag_in_frames), AV_OPT_TYPE_INT, {.i64 = 25}, 0, 25, VE}, \ + { "sharpness", "Sharpness", offsetof(VPxContext, sharpness), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 7, VE}, #if CONFIG_LIBVPX_VP8_ENCODER static const AVOption vp8_options[] = {