Skip to content

Commit 287e22f

Browse files
committed
avcodec/mediacodecenc: set quality in cq mode
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>
1 parent f5e3e9e commit 287e22f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

libavcodec/mediacodecenc.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,11 @@ static av_cold int mediacodec_init(AVCodecContext *avctx)
268268

269269
if (avctx->bit_rate)
270270
ff_AMediaFormat_setInt32(format, "bitrate", avctx->bit_rate);
271-
if (s->bitrate_mode >= 0)
271+
if (s->bitrate_mode >= 0) {
272272
ff_AMediaFormat_setInt32(format, "bitrate-mode", s->bitrate_mode);
273+
if (s->bitrate_mode == BITRATE_MODE_CQ && avctx->global_quality > 0)
274+
ff_AMediaFormat_setInt32(format, "quality", avctx->global_quality);
275+
}
273276
// frame-rate and i-frame-interval are required to configure codec
274277
if (avctx->framerate.num >= avctx->framerate.den && avctx->framerate.den > 0) {
275278
s->fps = avctx->framerate.num / avctx->framerate.den;

0 commit comments

Comments
 (0)