Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Matthieu Bouron <matthieu.bouron@gmail.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Cc: Zhao Zhili <zhilizhao@tencent.com>
Subject: Re: [FFmpeg-devel] [PATCH] avcodec/mediacodecenc: set quality in cq mode
Date: Tue, 19 Dec 2023 11:42:12 +0100
Message-ID: <CAOmVQXGpSkWAvhS2jJDWyPnOFcUaOg4rdyZa6H02sUV+CuZw3g@mail.gmail.com> (raw)
In-Reply-To: <tencent_2D9ADA40509A7D9F72ABFC4ED370242DBD08@qq.com>

On Sun, Dec 17, 2023 at 1:51 PM Zhao Zhili <quinkblack@foxmail.com> wrote:
>
> From: Zhao Zhili <zhilizhao@tencent.com>
>
> From AOSP doc, these values are device and codec specific, but lower
> values generally result in more efficient (smaller-sized) encoding.
>
> For example, global_quality 50 on Pixel 6 results a 1080P 30 FPS
> HEVC with 3744 kb/s, while global_quality 80 results 28178 kb/s.
>
> Fix #10689
>
> Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
> ---
>  libavcodec/mediacodecenc.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/mediacodecenc.c b/libavcodec/mediacodecenc.c
> index a1ae5d5ec5..7eae542248 100644
> --- a/libavcodec/mediacodecenc.c
> +++ b/libavcodec/mediacodecenc.c
> @@ -268,8 +268,11 @@ static av_cold int mediacodec_init(AVCodecContext *avctx)
>
>      if (avctx->bit_rate)
>          ff_AMediaFormat_setInt32(format, "bitrate", avctx->bit_rate);
> -    if (s->bitrate_mode >= 0)
> +    if (s->bitrate_mode >= 0) {
>          ff_AMediaFormat_setInt32(format, "bitrate-mode", s->bitrate_mode);
> +        if (s->bitrate_mode == BITRATE_MODE_CQ && avctx->global_quality > 0)
> +            ff_AMediaFormat_setInt32(format, "quality", avctx->global_quality);
> +    }
>      // frame-rate and i-frame-interval are required to configure codec
>      if (avctx->framerate.num >= avctx->framerate.den && avctx->framerate.den > 0) {
>          s->fps = avctx->framerate.num / avctx->framerate.den;
> --
> 2.34.1
>

Does the `global_quality` value need to be checked/clamped against
`MediaCodecInfo.EncoderCapabilities.getQualityRange()` before use ?
Otherwise, LGTM.
_______________________________________________
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-12-19 10:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-17 12:50 Zhao Zhili
2023-12-19 10:42 ` Matthieu Bouron [this message]
2023-12-19 14:16   ` Zhao Zhili

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=CAOmVQXGpSkWAvhS2jJDWyPnOFcUaOg4rdyZa6H02sUV+CuZw3g@mail.gmail.com \
    --to=matthieu.bouron@gmail.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    --cc=zhilizhao@tencent.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