[vlc-devel] [PATCH] mediacodec: Work around slice height handling on some Samsung codecs

Martin Storsjö martin at martin.st
Mon Sep 24 16:09:53 CEST 2012


This is similar to what we do in the omxil decoder already.
---
This can be squashed into 2/2 - I got this finished after sending
the first patches.

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

diff --git a/modules/codec/omxil/android_mediacodec.c b/modules/codec/omxil/android_mediacodec.c
index bf2c156..784b399 100644
--- a/modules/codec/omxil/android_mediacodec.c
+++ b/modules/codec/omxil/android_mediacodec.c
@@ -60,6 +60,7 @@ struct decoder_sys_t
     int pixel_format;
     int stride, slice_height;
     int crop_top, crop_left;
+    char *name;
 
     int started;
     int decoded;
@@ -208,6 +209,9 @@ static int OpenDecoder(vlc_object_t *p_this)
             jsize name_len = (*env)->GetStringUTFLength(env, name);
             const char *name_ptr = (*env)->GetStringUTFChars(env, name, NULL);
             msg_Dbg(p_dec, "using %.*s", name_len, name_ptr);
+            p_sys->name = malloc(name_len + 1);
+            memcpy(p_sys->name, name_ptr, name_len);
+            p_sys->name[name_len] = '\0';
             (*env)->ReleaseStringUTFChars(env, name, name_ptr);
             codec_info = info;
             codec_name = name;
@@ -308,6 +312,7 @@ static void CloseDecoder(vlc_object_t *p_this)
         (*env)->DeleteGlobalRef(env, p_sys->buffer_info);
     (*myVm)->DetachCurrentThread(myVm);
 
+    free(p_sys->name);
     free(p_sys);
 }
 
@@ -384,6 +389,16 @@ static void GetOutput(decoder_t *p_dec, JNIEnv *env, picture_t **pp_pic, int loo
                 p_sys->crop_top = 0;
                 p_sys->crop_left = 0;
             }
+            /* Workaround for some Samsung decoders, the ones named e.g.
+             * OMX.SEC.avc.dec don't have any padding between planes (while
+             * the slice height signals that they would have). The ones
+             * named OMX.SEC.AVC.Decoder have proper slice height as the
+             * parameter indicates. */
+            if (!strncmp(p_sys->name, "OMX.SEC.", strlen("OMX.SEC.")) &&
+                !strstr(p_sys->name, ".Decoder")) {
+                p_sys->slice_height = 0;
+            }
+
             continue;
         } else {
             break;
-- 
1.7.10




More information about the vlc-devel mailing list