Message ID | 20240210082143.1654211-1-darekm@google.com |
---|---|
State | New |
Headers | show |
Series | [FFmpeg-devel,v4] lavc/libvpxenc: add screen-content-mode option | expand |
Context | Check | Description |
---|---|---|
yinshiyou/make_loongarch64 | success | Make finished |
yinshiyou/make_fate_loongarch64 | success | Make fate finished |
andriy/make_x86 | success | Make finished |
andriy/make_fate_x86 | success | Make fate finished |
On Sat, Feb 10, 2024 at 12:22 AM Dariusz Marcinkiewicz via ffmpeg-devel <ffmpeg-devel@ffmpeg.org> wrote: > > 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 | 3 +++ > libavcodec/libvpxenc.c | 11 +++++++++++ > libavcodec/version.h | 2 +- > 3 files changed, 15 insertions(+), 1 deletion(-) > > diff --git a/doc/encoders.texi b/doc/encoders.texi > index c9fe6d6143..0868aa66db 100644 > --- a/doc/encoders.texi > +++ b/doc/encoders.texi > @@ -2150,6 +2150,9 @@ of quality. > Set a change threshold on blocks below which they will be skipped by the > encoder. > > +@item screen-content-mode > +Screen content mode, one of: off (0), screen (1), screen with more aggressive rate control (2). > + Move this above 'VP9-specific options' and add a section for VP8. Also reword this to '...one of: 0 (off), 1 (screen), ...'. The parameter is an integer so should list that first, similar to aq-mode. > @item slices (@emph{token-parts}) > Note that FFmpeg's @option{slices} option gives the total number of partitions, > while @command{vpxenc}'s @option{token-parts} is given as > diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c > index 80988a2608..0d507beaae 100644 > --- a/libavcodec/libvpxenc.c > +++ b/libavcodec/libvpxenc.c > @@ -102,6 +102,7 @@ typedef struct VPxEncoderContext { > #define VP8F_AUTO_ALT_REF 0x00000002 ///< Enable automatic alternate reference frame generation > > int auto_alt_ref; > + int screen_content_mode; > Move this above '// VP9-only' and add '// VP8-only'. > [...] > @@ -1946,6 +1956,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, "screen_content_mode"}, Remove the last item, "screen_content_mode". This no longer describes a group of options.
Hello. On Tue, Feb 13, 2024 at 12:12 AM James Zern <jzern@google.com> wrote: > [...] > > +@item screen-content-mode > > +Screen content mode, one of: off (0), screen (1), screen with more aggressive rate control (2). > > + > > Move this above 'VP9-specific options' and add a section for VP8. Also > reword this to '...one of: 0 (off), 1 (screen), ...'. The parameter is > an integer so should list that first, similar to aq-mode. > This and below are addressed in v5. Thank you.
diff --git a/doc/encoders.texi b/doc/encoders.texi index c9fe6d6143..0868aa66db 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -2150,6 +2150,9 @@ of quality. Set a change threshold on blocks below which they will be skipped by the encoder. +@item screen-content-mode +Screen content mode, one of: off (0), screen (1), screen with more aggressive rate control (2). + @item slices (@emph{token-parts}) Note that FFmpeg's @option{slices} option gives the total number of partitions, while @command{vpxenc}'s @option{token-parts} is given as diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index 80988a2608..0d507beaae 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -102,6 +102,7 @@ typedef struct VPxEncoderContext { #define VP8F_AUTO_ALT_REF 0x00000002 ///< Enable automatic alternate reference frame generation int auto_alt_ref; + int screen_content_mode; int arnr_max_frames; int arnr_strength; @@ -164,6 +165,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 +1264,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 +1956,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, "screen_content_mode"}, 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, \
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 | 3 +++ libavcodec/libvpxenc.c | 11 +++++++++++ libavcodec/version.h | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-)