diff mbox series

[FFmpeg-devel,1/4] avcodec/mediacodecdec: Add operating_rate option

Message ID tencent_DA8BB2E6155097E6DF27F26A9193025C5606@qq.com
State New
Headers show
Series [FFmpeg-devel,1/4] avcodec/mediacodecdec: Add operating_rate option | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished

Commit Message

Zhao Zhili Nov. 6, 2024, 12:33 p.m. UTC
From: Zhao Zhili <zhilizhao@tencent.com>

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.
---
 libavcodec/mediacodecdec.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Zhao Zhili Nov. 6, 2024, 12:38 p.m. UTC | #1
> On Nov 6, 2024, at 20:33, Zhao Zhili <quinkblack@foxmail.com> wrote:
> 
> From: Zhao Zhili <zhilizhao@tencent.com>
> 
> 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.
> —

Sorry for the resend, my patchset keep lost when sending in a group

Send this email? ([y]es|[n]o|[e]dit|[q]uit|[a]ll): a
250 OK
        ...propagated at /opt/homebrew/opt/git/libexec/git-core/git-send-email line 1657, <FIN> line 2.
diff mbox series

Patch

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 }
 };