diff options
author | Zhao Zhili <zhilizhao@tencent.com> | 2024-11-06 20:31:00 +0800 |
---|---|---|
committer | Zhao Zhili <zhilizhao@tencent.com> | 2024-11-20 19:20:59 +0800 |
commit | 46ad1abd361f2486bfd9ee28ab80aea28e890f2f (patch) | |
tree | a340a85c0670edefffdcc7f28939be366ee089cc /libavcodec | |
parent | a8375346eb1a542081d8067c0f0d682fad1ca697 (diff) | |
download | ffmpeg-46ad1abd361f2486bfd9ee28ab80aea28e890f2f.tar.gz |
avcodec/mediacodecdec: Add operating_rate option
The codec wants to know whether the usecase is realtime playback
or full-speed transcoding, or playback at a higher speed. The codec
runs faster when operating_rate higher than framerate.
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/mediacodecdec.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c index cc55b306bd..4937828f21 100644 --- a/libavcodec/mediacodecdec.c +++ b/libavcodec/mediacodecdec.c @@ -57,6 +57,8 @@ typedef struct MediaCodecH264DecContext { int amlogic_mpeg2_api23_workaround; int use_ndk_codec; + // Ref. MediaFormat KEY_OPERATING_RATE + int operating_rate; } MediaCodecH264DecContext; static av_cold int mediacodec_decode_close(AVCodecContext *avctx) @@ -441,6 +443,8 @@ static av_cold int mediacodec_decode_init(AVCodecContext *avctx) ff_AMediaFormat_setInt32(format, "channel-count", avctx->ch_layout.nb_channels); ff_AMediaFormat_setInt32(format, "sample-rate", avctx->sample_rate); } + if (s->operating_rate > 0) + ff_AMediaFormat_setInt32(format, "operating-rate", s->operating_rate); s->ctx = av_mallocz(sizeof(*s->ctx)); if (!s->ctx) { @@ -599,6 +603,8 @@ static const AVOption ff_mediacodec_vdec_options[] = { OFFSET(delay_flush), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, VD }, { "ndk_codec", "Use MediaCodec from NDK", OFFSET(use_ndk_codec), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VD }, + { "operating_rate", "The desired operating rate that the codec will need to operate at, zero for unspecified", + OFFSET(operating_rate), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, VD }, { NULL } }; @@ -662,6 +668,8 @@ DECLARE_MEDIACODEC_VDEC(av1, "AV1", AV_CODEC_ID_AV1, NULL) static const AVOption ff_mediacodec_adec_options[] = { { "ndk_codec", "Use MediaCodec from NDK", OFFSET(use_ndk_codec), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, AD }, + { "operating_rate", "The desired operating rate that the codec will need to operate at, zero for unspecified", + OFFSET(operating_rate), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AD }, { NULL } }; |