From: Zhao Zhili <quinkblack@foxmail.com> To: ffmpeg-devel@ffmpeg.org Cc: Zhao Zhili <zhilizhao@tencent.com> Subject: [FFmpeg-devel] [PATCH 1/7] avcodec/mediacodecenc: add bitrate_mode option Date: Mon, 5 Dec 2022 01:12:22 +0800 Message-ID: <tencent_9194CFE0D52F2763B8AF9624CD5D2007CD07@qq.com> (raw) From: Zhao Zhili <zhilizhao@tencent.com> --- libavcodec/mediacodecenc.c | 25 +++++++++++++++++++++++++ libavcodec/version.h | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/libavcodec/mediacodecenc.c b/libavcodec/mediacodecenc.c index 69246ad693..c8d8f84e46 100644 --- a/libavcodec/mediacodecenc.c +++ b/libavcodec/mediacodecenc.c @@ -39,6 +39,17 @@ #define INPUT_DEQUEUE_TIMEOUT_US 8000 #define OUTPUT_DEQUEUE_TIMEOUT_US 8000 +enum BitrateMode { + /* Constant quality mode */ + BITRATE_MODE_CQ = 0, + /* Variable bitrate mode */ + BITRATE_MODE_VBR = 1, + /* Constant bitrate mode */ + BITRATE_MODE_CBR = 2, + /* Constant bitrate mode with frame drops */ + BITRATE_MODE_CBR_FD = 3, +}; + typedef struct MediaCodecEncContext { AVClass *avclass; FFAMediaCodec *codec; @@ -67,6 +78,8 @@ typedef struct MediaCodecEncContext { int eof_sent; AVFrame *frame; + + int bitrate_mode; } MediaCodecEncContext; enum { @@ -193,6 +206,8 @@ 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) + ff_AMediaFormat_setInt32(format, "bitrate-mode", s->bitrate_mode); // 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; @@ -485,6 +500,16 @@ static const AVOption common_options[] = { OFFSET(use_ndk_codec), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE }, { "codec_name", "Select codec by name", OFFSET(name), AV_OPT_TYPE_STRING, {0}, 0, 0, VE }, + { "bitrate_mode", "Bitrate control method", + OFFSET(bitrate_mode), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE, "bitrate_mode" }, + { "cq", "Constant quality mode", + 0, AV_OPT_TYPE_CONST, {.i64 = BITRATE_MODE_CQ}, 0, 0, VE, "bitrate_mode" }, + { "vbr", "Variable bitrate mode", + 0, AV_OPT_TYPE_CONST, {.i64 = BITRATE_MODE_VBR}, 0, 0, VE, "bitrate_mode" }, + { "cbr", "Constant bitrate mode", + 0, AV_OPT_TYPE_CONST, {.i64 = BITRATE_MODE_CBR}, 0, 0, VE, "bitrate_mode" }, + { "cbr_fd", "Constant bitrate mode with frame drops", + 0, AV_OPT_TYPE_CONST, {.i64 = BITRATE_MODE_CBR_FD}, 0, 0, VE, "bitrate_mode" }, { NULL }, }; diff --git a/libavcodec/version.h b/libavcodec/version.h index 9e66920593..527b4dbd0b 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -30,7 +30,7 @@ #include "version_major.h" #define LIBAVCODEC_VERSION_MINOR 54 -#define LIBAVCODEC_VERSION_MICRO 101 +#define LIBAVCODEC_VERSION_MICRO 102 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ -- 2.25.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".
reply other threads:[~2022-12-04 17:13 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=tencent_9194CFE0D52F2763B8AF9624CD5D2007CD07@qq.com \ --to=quinkblack@foxmail.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