[vlc-commits] mediacodec: add a function that checks if codec is blacklisted

Thomas Guillem git at videolan.org
Mon Mar 16 10:33:31 CET 2015


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Mon Mar 16 08:29:54 2015 +0000| [42cc2df680d9987137b5725243a118da4253b184] | committer: Jean-Baptiste Kempf

mediacodec: add a function that checks if codec is blacklisted

This also fixes a crash because of a missing __MIN(strlen()) for MTK MPEG4.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/codec/omxil/android_mediacodec.c |   24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/modules/codec/omxil/android_mediacodec.c b/modules/codec/omxil/android_mediacodec.c
index 2840494..7ccffb2 100644
--- a/modules/codec/omxil/android_mediacodec.c
+++ b/modules/codec/omxil/android_mediacodec.c
@@ -308,6 +308,26 @@ static inline bool check_exception( JNIEnv *env )
 }
 #define CHECK_EXCEPTION() check_exception( env )
 
+static bool codec_is_blacklisted( const char *p_name, int i_name_len )
+{
+     static const char *blacklisted_codecs[] = {
+        /* software decoders */
+        "OMX.google.",
+        /* crashes mediaserver */
+        "OMX.MTK.VIDEO.DECODER.MPEG4",
+        NULL,
+     };
+
+     for( const char **pp_bl_codecs = blacklisted_codecs; *pp_bl_codecs != NULL;
+          pp_bl_codecs++ )
+     {
+        if( !strncmp( p_name, *pp_bl_codecs,
+            __MIN( strlen(*pp_bl_codecs), i_name_len ) ) )
+            return true;
+     }
+     return false;
+}
+
 /*****************************************************************************
  * OpenDecoder: Create the decoder instance
  *****************************************************************************/
@@ -442,9 +462,7 @@ static int OpenDecoder(vlc_object_t *p_this)
         name_ptr = (*env)->GetStringUTFChars(env, name, NULL);
         found = false;
 
-        if (!strncmp(name_ptr, "OMX.google.", __MIN(11, name_len)))
-            goto loopclean;
-        if (!strncmp(name_ptr, "OMX.MTK.VIDEO.DECODER.MPEG4", name_len))
+        if (codec_is_blacklisted( name_ptr, name_len))
             goto loopclean;
         for (int j = 0; j < num_types && !found; j++) {
             jobject type = (*env)->GetObjectArrayElement(env, types, j);



More information about the vlc-commits mailing list