Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Anton Khirnov <anton@khirnov.net>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH v3] libavcodec/qsvenc: Enable fixed QP configure in qsv CQP runtime
Date: Sat, 02 Jul 2022 11:39:09 +0200
Message-ID: <165675474959.31466.10582792568629584963@lain.khirnov.net> (raw)
In-Reply-To: <20220623053242.360909-1-wenbin.chen@intel.com>

Quoting Wenbin Chen (2022-06-23 07:32:42)
> From: Yue Heng <yue.heng@intel.com>
> 
> Enable dynamic QP configuration in runtime on qsv encoder. Through
> AVFrame->metadata, we can set key "qsv_config_qp" to change QP
> configuration when we encode video in CQP mode.
> 
> Signed-off-by: Yue Heng <yue.heng@intel.com>
> Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
> ---
>  doc/encoders.texi   | 10 +++++
>  libavcodec/qsvenc.c | 89 +++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 99 insertions(+)
> 
> diff --git a/doc/encoders.texi b/doc/encoders.texi
> index 1850c99fe9..02a91ffe96 100644
> --- a/doc/encoders.texi
> +++ b/doc/encoders.texi
> @@ -3333,6 +3333,16 @@ Forcing I frames as IDR frames.
>  For encoders set this flag to ON to reduce power consumption and GPU usage.
>  @end table
>  
> +@subsection Runtime Options
> +Following options can be used durning qsv encoding.
> +
> +@table @option
> +@item @var{qsv_config_qp}
> +Supported in h264_qsv and hevc_qsv.
> +This option can be set in per-frame metadata. QP parameter can be dynamically
> +changed when encoding in CQP mode.
> +@end table
> +
>  @subsection H264 options
>  These options are used by h264_qsv
>  
> diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
> index 902bada55b..2382c2f5f7 100644
> --- a/libavcodec/qsvenc.c
> +++ b/libavcodec/qsvenc.c
> @@ -146,6 +146,14 @@ static const struct {
>      { MFX_RATECONTROL_QVBR,    "QVBR" },
>  };
>  
> +#define UPDATE_PARAM(a, b)  \
> +do {                        \
> +    if ((a) != (b)) {       \
> +        a = b;              \
> +        updated = 1;        \
> +    }                       \
> +} while (0)                 \
> +
>  static const char *print_ratecontrol(mfxU16 rc_mode)
>  {
>      int i;
> @@ -1613,6 +1621,83 @@ static int set_roi_encode_ctrl(AVCodecContext *avctx, const AVFrame *frame,
>      return 0;
>  }
>  
> +static int update_qp(AVCodecContext *avctx, QSVEncContext *q,
> +                     const AVFrame *frame)
> +{
> +    int updated = 0, qp = 0, new_qp;
> +    char *tail;
> +    AVDictionaryEntry *entry = NULL;
> +
> +    if (avctx->codec_id != AV_CODEC_ID_H264 && avctx->codec_id != AV_CODEC_ID_HEVC)
> +        return 0;
> +
> +    entry = av_dict_get(frame->metadata, "qsv_config_qp", NULL, 0);

Why is this using frame metadata rather than the AVVideoEncParams side
data?

Frame metadata should not be used in encoders at all. Longer term it
should not be used at all by anything.

-- 
Anton Khirnov
_______________________________________________
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".

  parent reply	other threads:[~2022-07-02  9:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-23  5:32 Wenbin Chen
2022-06-25  2:47 ` Xiang, Haihao
2022-07-02  9:39 ` Anton Khirnov [this message]
2022-07-02 14:21   ` Paul B Mahol
2022-07-04  6:33   ` Chen, Wenbin
2022-07-04  6:45   ` Anton Khirnov
2022-07-04  8:40     ` Chen, Wenbin

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=165675474959.31466.10582792568629584963@lain.khirnov.net \
    --to=anton@khirnov.net \
    --cc=ffmpeg-devel@ffmpeg.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