From patchwork Tue Feb 13 06:34:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dariusz Marcinkiewicz X-Patchwork-Id: 46231 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:9002:b0:19e:cdac:8cce with SMTP id d2csp1122703pzc; Mon, 12 Feb 2024 22:34:32 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUi35jvSZEXh9hyuBdfrak1XH6GfwcmH4lzYbYQektXvnTzrOzQE6LYGGeF4rf5w4bAcjDbhNvuueCyrWQ2/lJNhtb3NvwpG9VkOQ== X-Google-Smtp-Source: AGHT+IHfb9AJo2MRpa1yP05PdpvjqxFvyzPNfmcOX1VXTnW+2Y2NPpMfK8+8umfz66cQQrcAJzKt X-Received: by 2002:a17:907:c207:b0:a3b:b390:2257 with SMTP id ti7-20020a170907c20700b00a3bb3902257mr7416793ejc.2.1707806072292; Mon, 12 Feb 2024 22:34:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707806072; cv=none; d=google.com; s=arc-20160816; b=sCfT8W8mbzBWZ7HRfvQcXLKcYGgd28UVun74IAOwot06FrjZkEKcRwy0x2a/JONY0f vMB0VaOAWQ9aXVhiivZMe5vjCPxtPHEpBl0WBn21BUfFLIw3oOzE8TOIB/u4KW8o6EOg eVx23GLdrdvxlkzQnUQURNm3TjaUUHYZc0EV6K7pcgbBTM7k0jXjKPmqZVSZ2OqORRkl gV7Ry2vARFXljI7sLvPbhseM7D3Ygle3XCMgOaczfoinbM/OHwO5I9xeTaxtiseni95P xlO/OhZFEUW4ujNgw7n/jISrhVi++e99PT62gYm2s+5Aak8styXHd21/0cWmPolsrkaR D9Lg== 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:from :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:to:message-id:references:mime-version :in-reply-to:date:delivered-to; bh=Tvo2UxFu6MLk2687Z8W/Omsqs06GWf0e6QFr1auJMNY=; fh=VsC4Nua/U/CoHkqSYQW/LhLMIUJ2ucGjG+CeUwXQrBc=; b=xEFLWBEFE8b0gmFTPY4IYNiIX4mvEcHXidZuzRM8TQNoMIpiVEK2fdKAMhbMZIM42s PfMwudnYwdtvhc5IkudvptadlTnYtzc1vCZ59shV+JANdZh2FGX8mrimLApBCscoP9QF TuEuB1KmaP2nTKV0RONFlw0VG9PnLhoIqUCsT3/fd5uSPjXji4Le/kW/VYc3vOmk5QuC OwsnahXCMJGcr2hAxAqBFuJYzWDfAxrBzRKXgkdGUxhIBcFLt5p80RsiEQmRCKQ2Ob6z pwKy5hW1dQZQoLCtlvq67Xb4bVQ4hs33zHj8SPCY8cGUkVInB/7fX7SP8NNrzhm84olE VkTA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; 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 X-Forwarded-Encrypted: i=1; AJvYcCVw/2uOVfVXUgFEPapBgFmIr8R/3ZoM3h7wlnNblMoJM4AafN66VgdpVZkyVUdghG1uk2E1uc/wEU9mT11ree9jF0EfVjxbhghPF/4ir/xG30Ia4YEi9FzPKH4QrDwk1pUsyyTGj7y9alxq8i47nX/jbYXrMPaRhfDsuaOLspkcDxKSmZISdkVGC8bQ6VMMfOG25J9fJfHQQA7wyPHSZqJsuuFDMsgZGsNJBz4Hn77UNoUGI6oA4sBsx39CRC7XK6eSju2Gwod/aqSDdzMPNOTQ3NrpsfwJY5hnET6QNysoUR/n1KWzBLy5Z53PtXQ6qYXgH0mmQQrQvh1FomtCZWj6iRnJl9nBz+Dv0j9tndVjFubpSoSnRyPYrouGEEgYQxv0Xv+cfFCg0tQOGCAcq18nCK/CNO4dmy3wf2XKFH5duTqr4ACPjlToxevx63WQrcO02IQ6gnmf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ukvvk7PRdZOkP4+HgoUV2jXTBm5J4TyJiozLC/aCAE= Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id x16-20020a170906299000b00a3bf48a4708si955185eje.104.2024.02.12.22.34.31; Mon, 12 Feb 2024 22:34:32 -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; 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 52FBE68D109; Tue, 13 Feb 2024 08:34:28 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f73.google.com (mail-wr1-f73.google.com [209.85.221.73]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0A8C568CDD1 for ; Tue, 13 Feb 2024 08:34:21 +0200 (EET) Received: by mail-wr1-f73.google.com with SMTP id ffacd0b85a97d-33cdeee3f0dso26123f8f.2 for ; Mon, 12 Feb 2024 22:34:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707806061; x=1708410861; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=xLWk782mdelRKAnib6ArO6Fxe2jR5ZDFegWIghxG9kA=; b=MvinAxyz93ShL3MuYTNvmww4bJArKbZPWrnWx6DiBzY9LMD6PfYc/r+f8EV4E7vtq9 zzSaIAfHGw+XzkTgDq8vs5NwuJ4vKOpYx74GGXddyYHYCHHeQszCdpM6iKZiAOUcLa1v PHbU0wCjYh4ZLYgB3EU/sCJr0/tdmxNIHoMDJqn1RuMgvGl37QWFeLd2mRIobyjZrwvw E8mUWGv8uGA4SD+ba3dVJDoB9cFn0D7Pc8fM44LfbtJxFp5GraMahQvLLJQpN21UaUpA bzHSNrcoUCyD1sBw0TYlgKUx2O8I4d2pQlBgEle4/zwwimLEWQIt8ogi8FOawQYY97C8 SwwA== X-Gm-Message-State: AOJu0Yz68FQjrHCjZigAqiTUKDMgGfyF0wt6gbIyHQd87Ti3oqoq3p76 HJaT3Wd7Lwl2svFmynKA9ugl8bvAtZQJ/bnjvHYGlsDKo9JCIbQZkHLv1bct0KVVfgokmwJnJLi dOvmfjxDbo8HDt4P7uEmSdImsPvcdbe1dqa204yH3DehHvW6gC6+sPiXkrqiVB5uiUcQV/whFEf pO9ZiWo9oNAPqLqfCS/3JVYX3lY+XqEf8VVg== X-Received: from reksio.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1be8]) (user=darekm job=sendgmr) by 2002:a05:6000:1f81:b0:33b:3c03:b684 with SMTP id bw1-20020a0560001f8100b0033b3c03b684mr15854wrb.11.1707806061021; Mon, 12 Feb 2024 22:34:21 -0800 (PST) Date: Tue, 13 Feb 2024 06:34:08 +0000 In-Reply-To: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog Message-ID: <20240213063409.2167597-1-darekm@google.com> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH v5] lavc/libvpxenc: add screen-content-mode option 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: , X-Patchwork-Original-From: Dariusz Marcinkiewicz via ffmpeg-devel From: Dariusz Marcinkiewicz Reply-To: FFmpeg development discussions and patches Cc: Dariusz Marcinkiewicz , =?utf-8?q?Erik_Spr=C3=A5ng?= Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: BK3Wk/4Tlq91 This exposes VP8E_SET_SCREEN_CONTENT_MODE option from libvpx. Co-authored-by: Erik Språng Signed-off-by: Dariusz Marcinkiewicz --- doc/encoders.texi | 6 ++++++ libavcodec/libvpxenc.c | 13 +++++++++++++ libavcodec/version.h | 2 +- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/doc/encoders.texi b/doc/encoders.texi index c9fe6d6143..13a7084512 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -2237,6 +2237,12 @@ the two temporal layer 2 frames within the temporal period. @end table @end table +@item VP8-specific options +@table @option +@item screen-content-mode +Screen content mode, one of: (0) off, (1) screen, (2) screen with more aggressive rate control. +@end table + @item VP9-specific options @table @option @item lossless diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index 80988a2608..8f765f2dc4 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -121,6 +121,9 @@ typedef struct VPxEncoderContext { int *ts_layer_flags; int current_temporal_idx; + // VP8-only + int screen_content_mode; + // VP9-only int lossless; int tile_columns; @@ -164,6 +167,7 @@ static const char *const ctlidstr[] = { [VP8E_SET_MAX_INTRA_BITRATE_PCT] = "VP8E_SET_MAX_INTRA_BITRATE_PCT", [VP8E_SET_SHARPNESS] = "VP8E_SET_SHARPNESS", [VP8E_SET_TEMPORAL_LAYER_ID] = "VP8E_SET_TEMPORAL_LAYER_ID", + [VP8E_SET_SCREEN_CONTENT_MODE] = "VP8E_SET_SCREEN_CONTENT_MODE", #if CONFIG_LIBVPX_VP9_ENCODER [VP9E_SET_LOSSLESS] = "VP9E_SET_LOSSLESS", [VP9E_SET_TILE_COLUMNS] = "VP9E_SET_TILE_COLUMNS", @@ -1262,6 +1266,14 @@ static av_cold int vpx_init(AVCodecContext *avctx, #endif } #endif + if (avctx->codec_id == AV_CODEC_ID_VP8 && ctx->screen_content_mode >= 0) { + if (ctx->screen_content_mode == 2 && ctx->is_alpha) { + av_log(avctx, AV_LOG_ERROR, + "Transparency encoding with screen mode with aggressive rate control not supported\n"); + return AVERROR(EINVAL); + } + codecctl_int(avctx, VP8E_SET_SCREEN_CONTENT_MODE, ctx->screen_content_mode); + } av_log(avctx, AV_LOG_DEBUG, "Using deadline: %d\n", ctx->deadline); @@ -1946,6 +1958,7 @@ static const AVOption vp8_options[] = { { "auto-alt-ref", "Enable use of alternate reference " "frames (2-pass only)", OFFSET(auto_alt_ref), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 2, VE}, { "cpu-used", "Quality/Speed ratio modifier", OFFSET(cpu_used), AV_OPT_TYPE_INT, {.i64 = 1}, -16, 16, VE}, + { "screen-content-mode", "Encoder screen content mode", OFFSET(screen_content_mode), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 2, VE}, LEGACY_OPTIONS { NULL } }; diff --git a/libavcodec/version.h b/libavcodec/version.h index f2f14eaed1..ecdbc51c74 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -30,7 +30,7 @@ #include "version_major.h" #define LIBAVCODEC_VERSION_MINOR 39 -#define LIBAVCODEC_VERSION_MICRO 100 +#define LIBAVCODEC_VERSION_MICRO 101 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \