[vlc-commits] mediacodec: add releaseOutputBufferAtTime
Thomas Guillem
git at videolan.org
Wed Oct 25 19:15:58 CEST 2017
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Oct 25 19:03:32 2017 +0200| [399b049176cdf535b1ad7bf5cd3e26b1ad416136] | committer: Thomas Guillem
mediacodec: add releaseOutputBufferAtTime
Only implemented by mediaocodec_ndk. Used to render a picture at a specific
time.
See
https://developer.android.com/reference/android/media/MediaCodec.html#releaseOutputBuffer%28int,%20long%29
Refs #18912
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=399b049176cdf535b1ad7bf5cd3e26b1ad416136
---
modules/codec/omxil/mediacodec.c | 10 ++++++++++
modules/codec/omxil/mediacodec.h | 3 +++
modules/codec/omxil/mediacodec_jni.c | 1 +
modules/codec/omxil/mediacodec_ndk.c | 21 +++++++++++++++++++++
4 files changed, 35 insertions(+)
diff --git a/modules/codec/omxil/mediacodec.c b/modules/codec/omxil/mediacodec.c
index c50bec2853..80c8392dd6 100644
--- a/modules/codec/omxil/mediacodec.c
+++ b/modules/codec/omxil/mediacodec.c
@@ -813,6 +813,14 @@ static void ReleasePicture(decoder_t *p_dec, unsigned i_index, bool b_render)
p_sys->api.release_out(&p_sys->api, i_index, b_render);
}
+static void ReleasePictureTs(decoder_t *p_dec, unsigned i_index, mtime_t i_ts)
+{
+ decoder_sys_t *p_sys = p_dec->p_sys;
+ assert(p_sys->api.release_out_ts);
+
+ p_sys->api.release_out_ts(&p_sys->api, i_index, i_ts * INT64_C(1000));
+}
+
static void InvalidateAllPictures(decoder_t *p_dec)
{
decoder_sys_t *p_sys = p_dec->p_sys;
@@ -830,6 +838,8 @@ static int InsertInflightPicture(decoder_t *p_dec, picture_sys_t *p_picsys)
{
p_picsys->hw.p_dec = p_dec;
p_picsys->hw.pf_release = ReleasePicture;
+ if (p_sys->api.release_out_ts)
+ p_picsys->hw.pf_release_ts = ReleasePictureTs;
TAB_APPEND_CAST((picture_sys_t **),
p_sys->video.i_inflight_pictures,
p_sys->video.pp_inflight_pictures,
diff --git a/modules/codec/omxil/mediacodec.h b/modules/codec/omxil/mediacodec.h
index ca58c49109..3c2ff397e6 100644
--- a/modules/codec/omxil/mediacodec.h
+++ b/modules/codec/omxil/mediacodec.h
@@ -152,6 +152,9 @@ struct mc_api
/* i_index is the index returned by dequeue_out and should be >= 0 */
int (*release_out)(mc_api *, int i_index, bool b_render);
+ /* render a buffer at a specified ts */
+ int (*release_out_ts)(mc_api *, int i_index, int64_t i_ts_ns);
+
/* Dynamically sets the output surface
* Returns 0 on success, or MC_API_ERROR */
int (*set_output_surface)(mc_api*, void *p_surface, void *p_jsurface);
diff --git a/modules/codec/omxil/mediacodec_jni.c b/modules/codec/omxil/mediacodec_jni.c
index b69cb1aab8..2fb341a9ea 100644
--- a/modules/codec/omxil/mediacodec_jni.c
+++ b/modules/codec/omxil/mediacodec_jni.c
@@ -1006,6 +1006,7 @@ int MediaCodecJni_Init(mc_api *api)
api->dequeue_out = DequeueOutput;
api->get_out = GetOutput;
api->release_out = ReleaseOutput;
+ api->release_out_ts = NULL;
api->set_output_surface = SetOutputSurface;
/* Allow rotation only after API 21 */
diff --git a/modules/codec/omxil/mediacodec_ndk.c b/modules/codec/omxil/mediacodec_ndk.c
index a07ec20289..254a9a41fe 100644
--- a/modules/codec/omxil/mediacodec_ndk.c
+++ b/modules/codec/omxil/mediacodec_ndk.c
@@ -143,6 +143,9 @@ typedef uint8_t* (*pf_AMediaCodec_getOutputBuffer)(AMediaCodec*,
typedef media_status_t (*pf_AMediaCodec_releaseOutputBuffer)(AMediaCodec*,
size_t idx, bool render);
+typedef media_status_t (*pf_AMediaCodec_releaseOutputBufferAtTime)(AMediaCodec*,
+ size_t idx, int64_t timestampNs);
+
typedef media_status_t (*pf_AMediaCodec_setOutputSurface)(AMediaCodec*,
ANativeWindow *surface);
@@ -174,6 +177,7 @@ struct syms
pf_AMediaCodec_dequeueOutputBuffer dequeueOutputBuffer;
pf_AMediaCodec_getOutputBuffer getOutputBuffer;
pf_AMediaCodec_releaseOutputBuffer releaseOutputBuffer;
+ pf_AMediaCodec_releaseOutputBufferAtTime releaseOutputBufferAtTime;
pf_AMediaCodec_setOutputSurface setOutputSurface;
} AMediaCodec;
struct {
@@ -208,6 +212,7 @@ static struct members members[] =
{ "AMediaCodec_dequeueOutputBuffer", OFF(dequeueOutputBuffer), true },
{ "AMediaCodec_getOutputBuffer", OFF(getOutputBuffer), true },
{ "AMediaCodec_releaseOutputBuffer", OFF(releaseOutputBuffer), true },
+ { "AMediaCodec_releaseOutputBufferAtTime", OFF(releaseOutputBufferAtTime), true },
{ "AMediaCodec_setOutputSurface", OFF(setOutputSurface), false },
#undef OFF
#define OFF(x) offsetof(struct syms, AMediaFormat.x)
@@ -558,6 +563,21 @@ static int ReleaseOutput(mc_api *api, int i_index, bool b_render)
}
/*****************************************************************************
+ * ReleaseOutputAtTime
+ *****************************************************************************/
+static int ReleaseOutputAtTime(mc_api *api, int i_index, int64_t i_ts_ns)
+{
+ mc_api_sys *p_sys = api->p_sys;
+
+ assert(i_index >= 0);
+ if (syms.AMediaCodec.releaseOutputBufferAtTime(p_sys->p_codec, i_index, i_ts_ns)
+ == AMEDIA_OK)
+ return 0;
+ else
+ return MC_API_ERROR;
+}
+
+/*****************************************************************************
* SetOutputSurface
*****************************************************************************/
static int SetOutputSurface(mc_api *api, void *p_surface, void *p_jsurface)
@@ -622,6 +642,7 @@ int MediaCodecNdk_Init(mc_api *api)
api->dequeue_out = DequeueOutput;
api->get_out = GetOutput;
api->release_out = ReleaseOutput;
+ api->release_out_ts = ReleaseOutputAtTime;
api->set_output_surface = SetOutputSurface;
api->b_support_rotation = true;
More information about the vlc-commits
mailing list