Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Dariusz Marcinkiewicz via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: "Dariusz Marcinkiewicz" <darekm@google.com>,
	"Erik Språng" <sprang@webrtc.org>
Subject: [FFmpeg-devel] [PATCH v5] lavc/libvpxenc: add screen-content-mode option
Date: Tue, 13 Feb 2024 06:34:08 +0000
Message-ID: <20240213063409.2167597-1-darekm@google.com> (raw)
In-Reply-To: <CABWgkXJnpkdT8Lc-Zwk1tj5v+dpZfN0gwCo_xTFsUXEp+-vSKw@mail.gmail.com>

This exposes VP8E_SET_SCREEN_CONTENT_MODE option from libvpx.

Co-authored-by: Erik Språng <sprang@webrtc.org>
Signed-off-by: Dariusz Marcinkiewicz <darekm@google.com>
---
 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, \
-- 
2.43.0.687.g38aa6559b0-goog

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  reply	other threads:[~2024-02-13  6:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-31 16:23 [FFmpeg-devel] [PATCH v2] libavcodec: add tune_content option also for VP8 Dariusz Marcinkiewicz via ffmpeg-devel
2024-02-07 16:03 ` Dariusz Marcinkiewicz via ffmpeg-devel
2024-02-08  6:13   ` James Zern via ffmpeg-devel
2024-02-08 21:56     ` [FFmpeg-devel] [PATCH v3] lavc/libvpxenc: add screen-content-mode option Dariusz Marcinkiewicz via ffmpeg-devel
2024-02-09 18:28       ` James Zern via ffmpeg-devel
2024-02-10  8:21         ` [FFmpeg-devel] [PATCH v4] " Dariusz Marcinkiewicz via ffmpeg-devel
2024-02-12 23:12           ` James Zern via ffmpeg-devel
2024-02-13  6:34             ` Dariusz Marcinkiewicz via ffmpeg-devel [this message]
2024-02-14  3:26               ` [FFmpeg-devel] [PATCH v5] " James Zern via ffmpeg-devel
2024-02-16  3:12                 ` James Zern via ffmpeg-devel
2024-02-14  2:24             ` [FFmpeg-devel] [PATCH v4] " Dariusz Marcinkiewicz via ffmpeg-devel
2024-02-10  8:28         ` [FFmpeg-devel] [PATCH v3] " Dariusz Marcinkiewicz via ffmpeg-devel
2024-02-08 22:00     ` [FFmpeg-devel] [PATCH v2] libavcodec: add tune_content option also for VP8 Dariusz Marcinkiewicz via ffmpeg-devel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240213063409.2167597-1-darekm@google.com \
    --to=ffmpeg-devel@ffmpeg.org \
    --cc=darekm@google.com \
    --cc=sprang@webrtc.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git