[vlc-devel] [PATCH] mediacodec: abort if there is no SPS/PPS (for h264/hevc)
Thomas Guillem
thomas at gllm.fr
Wed Mar 4 11:53:00 CET 2015
Because ACodec can assert on some devices when you don't set sps/pps.
---
modules/codec/omxil/android_mediacodec.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/modules/codec/omxil/android_mediacodec.c b/modules/codec/omxil/android_mediacodec.c
index 8a6ce90..2ccf6f6 100644
--- a/modules/codec/omxil/android_mediacodec.c
+++ b/modules/codec/omxil/android_mediacodec.c
@@ -511,6 +511,7 @@ loopclean:
p_sys->create_video_format, (*env)->NewStringUTF(env, mime),
p_dec->fmt_in.video.i_width, p_dec->fmt_in.video.i_height);
+ bool b_has_sps_pps = false;
if (p_dec->fmt_in.i_extra) {
// Allocate a byte buffer via allocateDirect in java instead of NewDirectByteBuffer,
// since the latter doesn't allocate storage of its own, and we don't know how long
@@ -521,13 +522,14 @@ loopclean:
uint32_t size = p_dec->fmt_in.i_extra;
uint8_t *ptr = (*env)->GetDirectBufferAddress(env, bytebuf);
if (p_dec->fmt_in.i_codec == VLC_CODEC_H264 && ((uint8_t*)p_dec->fmt_in.p_extra)[0] == 1) {
- convert_sps_pps(p_dec, p_dec->fmt_in.p_extra, p_dec->fmt_in.i_extra,
- ptr, buf_size,
- &size, &p_sys->nal_size);
+ b_has_sps_pps = convert_sps_pps(p_dec, p_dec->fmt_in.p_extra,
+ p_dec->fmt_in.i_extra, ptr,
+ buf_size, &size,
+ &p_sys->nal_size) == VLC_SUCCESS;
} else if (p_dec->fmt_in.i_codec == VLC_CODEC_HEVC) {
- convert_hevc_nal_units(p_dec, p_dec->fmt_in.p_extra,
- p_dec->fmt_in.i_extra, ptr, buf_size,
- &size, &p_sys->nal_size);
+ b_has_sps_pps = convert_hevc_nal_units(p_dec, p_dec->fmt_in.p_extra,
+ p_dec->fmt_in.i_extra, ptr, buf_size,
+ &size, &p_sys->nal_size) == VLC_SUCCESS;
} else {
memcpy(ptr, p_dec->fmt_in.p_extra, size);
}
@@ -536,6 +538,13 @@ loopclean:
(*env)->NewStringUTF(env, "csd-0"), bytebuf);
(*env)->DeleteLocalRef(env, bytebuf);
}
+ if ((p_dec->fmt_in.i_codec == VLC_CODEC_H264
+ || p_dec->fmt_in.i_codec == VLC_CODEC_HEVC) && !b_has_sps_pps)
+ {
+ /* ACodec can assert on some devices when you don't set sps/pps */
+ msg_Err(p_dec, "h264/hevc: No nal units found, abort mediacodec");
+ goto error;
+ }
/* If the VideoPlayerActivity is not started, MediaCodec opaque
direct rendering should be disabled since no surface will be
--
2.1.3
More information about the vlc-devel
mailing list