Commit b8b8f03e authored by Martin Storsjö's avatar Martin Storsjö

mediacodec: Don't return frames before the output format is set

The decoder on Sony Xperia Z1 seems to return one frame before
the output format is set (and calling getOutputFormat() at this
point throws an IllegalStateException). Therefore just drop any
frames that are returned before the output format has been set.
Signed-off-by: default avatarMartin Storsjö <martin@martin.st>
parent ca062887
...@@ -398,6 +398,11 @@ static void GetOutput(decoder_t *p_dec, JNIEnv *env, picture_t **pp_pic, int loo ...@@ -398,6 +398,11 @@ static void GetOutput(decoder_t *p_dec, JNIEnv *env, picture_t **pp_pic, int loo
int index = (*env)->CallIntMethod(env, p_sys->codec, p_sys->dequeue_output_buffer, int index = (*env)->CallIntMethod(env, p_sys->codec, p_sys->dequeue_output_buffer,
p_sys->buffer_info, (jlong) 0); p_sys->buffer_info, (jlong) 0);
if (index >= 0) { if (index >= 0) {
if (!p_sys->pixel_format) {
msg_Warn(p_dec, "Buffers returned before output format is set, dropping frame");
(*env)->CallVoidMethod(env, p_sys->codec, p_sys->release_output_buffer, index, false);
continue;
}
jobject buf = (*env)->GetObjectArrayElement(env, p_sys->output_buffers, index); jobject buf = (*env)->GetObjectArrayElement(env, p_sys->output_buffers, index);
jsize buf_size = (*env)->GetDirectBufferCapacity(env, buf); jsize buf_size = (*env)->GetDirectBufferCapacity(env, buf);
uint8_t *ptr = (*env)->GetDirectBufferAddress(env, buf); uint8_t *ptr = (*env)->GetDirectBufferAddress(env, buf);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment