[FFmpeg-cvslog] lavc/libvpxenc: add screen-content-mode option

Dariusz Marcinkiewicz git at videolan.org
Fri Feb 16 05:11:26 EET 2024


ffmpeg | branch: master | Dariusz Marcinkiewicz <darekm at google.com> | Tue Feb 13 06:34:08 2024 +0000| [86367be5ef313887a0d93390e668fe13dc675394] | committer: James Zern

lavc/libvpxenc: add screen-content-mode option

This exposes VP8E_SET_SCREEN_CONTENT_MODE option from libvpx.

Co-authored-by: Erik Språng <sprang at webrtc.org>
Signed-off-by: Dariusz Marcinkiewicz <darekm at google.com>
Signed-off-by: James Zern <jzern at google.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=86367be5ef313887a0d93390e668fe13dc675394
---

 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..9f477d7c53 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
 
+ at item VP8-specific options
+ at table @option
+ at item screen-content-mode
+Screen content mode, one of: 0 (off), 1 (screen), 2 (screen with more aggressive rate control).
+ at end table
+
 @item VP9-specific options
 @table @option
 @item lossless
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index a36cfcf09e..dbf1bd679f 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, \



More information about the ffmpeg-cvslog mailing list