[vlc-commits] mediacodec: Simplify the GetOutput function

Martin Storsjö git at videolan.org
Mon Nov 4 21:26:26 CET 2013


vlc | branch: master | Martin Storsjö <martin at martin.st> | Mon Nov  4 22:20:50 2013 +0200| [74bb926bdbe8a457d4ffc9d42d3f1ddacfb422f8] | committer: Martin Storsjö

mediacodec: Simplify the GetOutput function

The loop parameter is always 0 nowadays.

Always call the dequeueOutputBuffer method again if it returned
changed output buffers or changed output format.

Signed-off-by: Martin Storsjö <martin at martin.st>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=74bb926bdbe8a457d4ffc9d42d3f1ddacfb422f8
---

 modules/codec/omxil/android_mediacodec.c |   15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/modules/codec/omxil/android_mediacodec.c b/modules/codec/omxil/android_mediacodec.c
index c078b2b..ef1f90c 100644
--- a/modules/codec/omxil/android_mediacodec.c
+++ b/modules/codec/omxil/android_mediacodec.c
@@ -395,10 +395,10 @@ static void CloseDecoder(vlc_object_t *p_this)
     free(p_sys);
 }
 
-static void GetOutput(decoder_t *p_dec, JNIEnv *env, picture_t **pp_pic, int loop)
+static void GetOutput(decoder_t *p_dec, JNIEnv *env, picture_t **pp_pic)
 {
     decoder_sys_t *p_sys = p_dec->p_sys;
-    do {
+    while (1) {
         int index = (*env)->CallIntMethod(env, p_sys->codec, p_sys->dequeue_output_buffer,
                                           p_sys->buffer_info, (jlong) 0);
         if (index >= 0) {
@@ -438,13 +438,13 @@ static void GetOutput(decoder_t *p_dec, JNIEnv *env, picture_t **pp_pic, int loo
                 }
             }
             (*env)->DeleteLocalRef(env, buf);
+            return;
         } else if (index == INFO_OUTPUT_BUFFERS_CHANGED) {
             msg_Dbg(p_dec, "output buffers changed");
             (*env)->DeleteGlobalRef(env, p_sys->output_buffers);
             p_sys->output_buffers = (*env)->CallObjectMethod(env, p_sys->codec,
                                                              p_sys->get_output_buffers);
             p_sys->output_buffers = (*env)->NewGlobalRef(env, p_sys->output_buffers);
-            continue;
         } else if (index == INFO_OUTPUT_FORMAT_CHANGED) {
 
             jobject format = (*env)->CallObjectMethod(env, p_sys->codec, p_sys->get_output_format);
@@ -497,11 +497,10 @@ static void GetOutput(decoder_t *p_dec, JNIEnv *env, picture_t **pp_pic, int loo
                 p_sys->stride = p_dec->fmt_out.video.i_width;
             }
 
-            continue;
         } else {
-            break;
+            return;
         }
-    } while (loop);
+    }
 }
 
 static picture_t *DecodeVideo(decoder_t *p_dec, block_t **pp_block)
@@ -536,7 +535,7 @@ static picture_t *DecodeVideo(decoder_t *p_dec, block_t **pp_block)
     while (true) {
         int index = (*env)->CallIntMethod(env, p_sys->codec, p_sys->dequeue_input_buffer, timeout);
         if (index < 0) {
-            GetOutput(p_dec, env, &p_pic, 0);
+            GetOutput(p_dec, env, &p_pic);
             if (p_pic) {
                 /* If we couldn't get an available input buffer but a
                  * decoded frame is available, we return the frame
@@ -567,7 +566,7 @@ static picture_t *DecodeVideo(decoder_t *p_dec, block_t **pp_block)
         break;
     }
     if (!p_pic)
-        GetOutput(p_dec, env, &p_pic, 0);
+        GetOutput(p_dec, env, &p_pic);
     (*myVm)->DetachCurrentThread(myVm);
 
     block_Release(p_block);



More information about the vlc-commits mailing list