Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: "Xiang, Haihao" <haihao.xiang-at-intel.com@ffmpeg.org>
To: "ffmpeg-devel@ffmpeg.org" <ffmpeg-devel@ffmpeg.org>
Cc: "nowrep@gmail.com" <nowrep@gmail.com>
Subject: Re: [FFmpeg-devel] [PATCH] lavc/vaapi_encode: add "quality" option to all encoders
Date: Mon, 12 Jun 2023 06:08:43 +0000
Message-ID: <8bd254a02b4c22a223d4829dca2977c44ec211dc.camel@intel.com> (raw)
In-Reply-To: <20230521073141.54054-1-nowrep@gmail.com>


> 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".

      reply	other threads:[~2023-06-12  6:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-21  7:31 David Rosca
2023-06-12  6:08 ` Xiang, Haihao [this message]

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=8bd254a02b4c22a223d4829dca2977c44ec211dc.camel@intel.com \
    --to=haihao.xiang-at-intel.com@ffmpeg.org \
    --cc=ffmpeg-devel@ffmpeg.org \
    --cc=nowrep@gmail.com \
    /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