* [FFmpeg-devel] [PATCH] lavc/vaapi_encode: add "quality" option to all encoders
@ 2023-05-21 7:31 David Rosca
2023-06-12 6:08 ` Xiang, Haihao
0 siblings, 1 reply; 2+ messages in thread
From: David Rosca @ 2023-05-21 7:31 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: David Rosca
Move "quality" option from h264_vaapi to common options.
---
libavcodec/vaapi_encode.c | 3 +++
libavcodec/vaapi_encode.h | 8 +++++++-
libavcodec/vaapi_encode_h264.c | 5 -----
3 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index bfca315a7a..974b805df1 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -2635,6 +2635,9 @@ av_cold int ff_vaapi_encode_init(AVCodecContext *avctx)
if (err < 0)
goto fail;
+ if (avctx->compression_level == FF_COMPRESSION_DEFAULT)
+ avctx->compression_level = ctx->quality;
+
if (avctx->compression_level >= 0) {
err = vaapi_encode_init_quality(avctx);
if (err < 0)
diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h
index a1e639f56b..3e4a8c24d3 100644
--- a/libavcodec/vaapi_encode.h
+++ b/libavcodec/vaapi_encode.h
@@ -364,6 +364,8 @@ typedef struct VAAPIEncodeContext {
AVFifo *encode_fifo;
// Max number of frame buffered in encoder.
int async_depth;
+ // Encode quality (trades off against speed, higher is faster)
+ int quality;
} VAAPIEncodeContext;
enum {
@@ -490,7 +492,11 @@ int ff_vaapi_encode_close(AVCodecContext *avctx);
{ "max_frame_size", \
"Maximum frame size (in bytes)",\
OFFSET(common.max_frame_size), AV_OPT_TYPE_INT, \
- { .i64 = 0 }, 0, INT_MAX, FLAGS }
+ { .i64 = 0 }, 0, INT_MAX, FLAGS }, \
+ { "quality", \
+ "Set encode quality (trades off against speed, higher is faster)", \
+ OFFSET(common.quality), AV_OPT_TYPE_INT, \
+ { .i64 = -1 }, -1, INT_MAX, FLAGS }
#define VAAPI_ENCODE_RC_MODE(name, desc) \
{ #name, desc, 0, AV_OPT_TYPE_CONST, { .i64 = RC_MODE_ ## name }, \
diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
index 9ad017d540..c9629c1fea 100644
--- a/libavcodec/vaapi_encode_h264.c
+++ b/libavcodec/vaapi_encode_h264.c
@@ -71,7 +71,6 @@ typedef struct VAAPIEncodeH264Context {
// User options.
int qp;
- int quality;
int coder;
int aud;
int sei;
@@ -1211,8 +1210,6 @@ static av_cold int vaapi_encode_h264_init(AVCodecContext *avctx)
avctx->profile = priv->profile;
if (avctx->level == FF_LEVEL_UNKNOWN)
avctx->level = priv->level;
- if (avctx->compression_level == FF_COMPRESSION_DEFAULT)
- avctx->compression_level = priv->quality;
// Reject unsupported profiles.
switch (avctx->profile) {
@@ -1282,8 +1279,6 @@ static const AVOption vaapi_encode_h264_options[] = {
{ "qp", "Constant QP (for P-frames; scaled by qfactor/qoffset for I/B)",
OFFSET(qp), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 52, FLAGS },
- { "quality", "Set encode quality (trades off against speed, higher is faster)",
- OFFSET(quality), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, FLAGS },
{ "coder", "Entropy coder type",
OFFSET(coder), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, FLAGS, "coder" },
{ "cavlc", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, FLAGS, "coder" },
--
2.40.1
_______________________________________________
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".
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [FFmpeg-devel] [PATCH] lavc/vaapi_encode: add "quality" option to all encoders
2023-05-21 7:31 [FFmpeg-devel] [PATCH] lavc/vaapi_encode: add "quality" option to all encoders David Rosca
@ 2023-06-12 6:08 ` Xiang, Haihao
0 siblings, 0 replies; 2+ messages in thread
From: Xiang, Haihao @ 2023-06-12 6:08 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: nowrep
> Move "quality" option from h264_vaapi to common options.
User may directly use compression_level option in vaapi path, the h.264 specific
quality option stays for compatibility only. (If I remember correctly, there
was a proposal to deprecate the h.264 specific option).
Thanks
Haihao
> ---
> libavcodec/vaapi_encode.c | 3 +++
> libavcodec/vaapi_encode.h | 8 +++++++-
> libavcodec/vaapi_encode_h264.c | 5 -----
> 3 files changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
> index bfca315a7a..974b805df1 100644
> --- a/libavcodec/vaapi_encode.c
> +++ b/libavcodec/vaapi_encode.c
> @@ -2635,6 +2635,9 @@ av_cold int ff_vaapi_encode_init(AVCodecContext *avctx)
> if (err < 0)
> goto fail;
>
> + if (avctx->compression_level == FF_COMPRESSION_DEFAULT)
> + avctx->compression_level = ctx->quality;
> +
> if (avctx->compression_level >= 0) {
> err = vaapi_encode_init_quality(avctx);
> if (err < 0)
> diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h
> index a1e639f56b..3e4a8c24d3 100644
> --- a/libavcodec/vaapi_encode.h
> +++ b/libavcodec/vaapi_encode.h
> @@ -364,6 +364,8 @@ typedef struct VAAPIEncodeContext {
> AVFifo *encode_fifo;
> // Max number of frame buffered in encoder.
> int async_depth;
> + // Encode quality (trades off against speed, higher is faster)
> + int quality;
> } VAAPIEncodeContext;
>
> enum {
> @@ -490,7 +492,11 @@ int ff_vaapi_encode_close(AVCodecContext *avctx);
> { "max_frame_size", \
> "Maximum frame size (in bytes)",\
> OFFSET(common.max_frame_size), AV_OPT_TYPE_INT, \
> - { .i64 = 0 }, 0, INT_MAX, FLAGS }
> + { .i64 = 0 }, 0, INT_MAX, FLAGS }, \
> + { "quality", \
> + "Set encode quality (trades off against speed, higher is faster)", \
> + OFFSET(common.quality), AV_OPT_TYPE_INT, \
> + { .i64 = -1 }, -1, INT_MAX, FLAGS }
>
> #define VAAPI_ENCODE_RC_MODE(name, desc) \
> { #name, desc, 0, AV_OPT_TYPE_CONST, { .i64 = RC_MODE_ ## name }, \
> diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
> index 9ad017d540..c9629c1fea 100644
> --- a/libavcodec/vaapi_encode_h264.c
> +++ b/libavcodec/vaapi_encode_h264.c
> @@ -71,7 +71,6 @@ typedef struct VAAPIEncodeH264Context {
>
> // User options.
> int qp;
> - int quality;
> int coder;
> int aud;
> int sei;
> @@ -1211,8 +1210,6 @@ static av_cold int vaapi_encode_h264_init(AVCodecContext
> *avctx)
> avctx->profile = priv->profile;
> if (avctx->level == FF_LEVEL_UNKNOWN)
> avctx->level = priv->level;
> - if (avctx->compression_level == FF_COMPRESSION_DEFAULT)
> - avctx->compression_level = priv->quality;
>
> // Reject unsupported profiles.
> switch (avctx->profile) {
> @@ -1282,8 +1279,6 @@ static const AVOption vaapi_encode_h264_options[] = {
>
> { "qp", "Constant QP (for P-frames; scaled by qfactor/qoffset for I/B)",
> OFFSET(qp), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 52, FLAGS },
> - { "quality", "Set encode quality (trades off against speed, higher is
> faster)",
> - OFFSET(quality), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, FLAGS },
> { "coder", "Entropy coder type",
> OFFSET(coder), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, FLAGS, "coder" },
> { "cavlc", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN,
> INT_MAX, FLAGS, "coder" },
_______________________________________________
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".
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-06-12 6:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-21 7:31 [FFmpeg-devel] [PATCH] lavc/vaapi_encode: add "quality" option to all encoders David Rosca
2023-06-12 6:08 ` Xiang, Haihao
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