[vlc-commits] mediacodec/omxil: use same blacklist

Thomas Guillem git at videolan.org
Tue Apr 7 13:40:33 CEST 2015


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Apr  3 14:17:40 2015 +0000| [604ef756395a884036fd81a41ae098261fc55df4] | committer: Jean-Baptiste Kempf

mediacodec/omxil: use same blacklist

A crashing decoder via MediaCodec has a lot of chances to crash via omxil.

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

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

 modules/codec/omxil/android_mediacodec.c |   24 +----------
 modules/codec/omxil/omxil.c              |   35 +---------------
 modules/codec/omxil/omxil_utils.h        |    5 +++
 modules/codec/omxil/utils.c              |   66 ++++++++++++++++++++++++++++++
 4 files changed, 73 insertions(+), 57 deletions(-)

diff --git a/modules/codec/omxil/android_mediacodec.c b/modules/codec/omxil/android_mediacodec.c
index adf88e2..94c0113 100644
--- a/modules/codec/omxil/android_mediacodec.c
+++ b/modules/codec/omxil/android_mediacodec.c
@@ -390,28 +390,6 @@ end:
     return ret;
 }
 
-static bool codec_is_blacklisted( const char *p_name, unsigned int i_name_len )
-{
-     static const char *blacklisted_codecs[] = {
-        /* software decoders */
-        "OMX.google.",
-        /* crashes mediaserver */
-        "OMX.MTK.VIDEO.DECODER.MPEG4",
-        /* Not working or crashing (Samsung) */
-        "OMX.SEC.vp8.dec",
-        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
  *****************************************************************************/
@@ -499,7 +477,7 @@ static int OpenDecoder(vlc_object_t *p_this)
         name_ptr = (*env)->GetStringUTFChars(env, name, NULL);
         found = false;
 
-        if (codec_is_blacklisted( name_ptr, name_len))
+        if (OMXCodec_IsBlacklisted( name_ptr, name_len))
             goto loopclean;
         for (int j = 0; j < num_types && !found; j++) {
             jobject type = (*env)->GetObjectArrayElement(env, types, j);
diff --git a/modules/codec/omxil/omxil.c b/modules/codec/omxil/omxil.c
index 16eb50e..1f6ebf4 100644
--- a/modules/codec/omxil/omxil.c
+++ b/modules/codec/omxil/omxil.c
@@ -1109,40 +1109,7 @@ static int OpenGeneric( vlc_object_t *p_this, bool b_encode )
     for(i = 0; i < p_sys->components; i++)
     {
 #ifdef __ANDROID__
-        /* ignore OpenCore software codecs */
-        if (!strncmp(p_sys->ppsz_components[i], "OMX.PV.", 7))
-            continue;
-        /* The same sw codecs, renamed in ICS (perhaps also in honeycomb) */
-        if (!strncmp(p_sys->ppsz_components[i], "OMX.google.", 11))
-            continue;
-        /* This one has been seen on HTC One V - it behaves like it works,
-         * but FillBufferDone returns buffers filled with 0 bytes. The One V
-         * has got a working OMX.qcom.video.decoder.avc instead though. */
-        if (!strncmp(p_sys->ppsz_components[i], "OMX.ARICENT.", 12))
-            continue;
-        /* Codecs with DRM, that don't output plain YUV data but only
-         * support direct rendering where the output can't be intercepted. */
-        if (strstr(p_sys->ppsz_components[i], ".secure"))
-            continue;
-        /* Use VC1 decoder for WMV3 for now */
-        if (!strcmp(p_sys->ppsz_components[i], "OMX.SEC.WMV.Decoder"))
-            continue;
-        /* This decoder does work, but has an insane latency (leading to errors
-         * about "main audio output playback way too late" and dropped frames).
-         * At least Samsung Galaxy S III (where this decoder is present) has
-         * got another one, OMX.SEC.mp3.dec, that works well and has a
-         * sensible latency. (Also, even if that one isn't found, in general,
-         * using SW codecs is usually more than fast enough for MP3.) */
-        if (!strcmp(p_sys->ppsz_components[i], "OMX.SEC.MP3.Decoder"))
-            continue;
-        /* This codec should be able to handle both VC1 and WMV3, but
-         * for VC1 it doesn't output any buffers at all (in the way we use
-         * it) and for WMV3 it outputs plain black buffers. Thus ignore
-         * it until we can make it work properly. */
-        if (!strcmp(p_sys->ppsz_components[i], "OMX.Nvidia.vc1.decode"))
-            continue;
-        /* This codec doesn't work or crashes */
-        if (!strcmp(p_sys->ppsz_components[i], "OMX.SEC.vp8.dec"))
+        if (OMXCodec_IsBlacklisted(p_sys->ppsz_components[i], strlen(p_sys->ppsz_components[i])))
             continue;
 #endif
         omx_error = InitialiseComponent(p_dec, p_sys->ppsz_components[i],
diff --git a/modules/codec/omxil/omxil_utils.h b/modules/codec/omxil/omxil_utils.h
index a1d564b..04a56bd 100644
--- a/modules/codec/omxil/omxil_utils.h
+++ b/modules/codec/omxil/omxil_utils.h
@@ -222,6 +222,11 @@ const char *ErrorToString(OMX_ERRORTYPE error);
 void PrintOmx(decoder_t *p_dec, OMX_HANDLETYPE omx_handle, OMX_U32 i_port);
 
 /*****************************************************************************
+ * Utility functions
+ *****************************************************************************/
+bool OMXCodec_IsBlacklisted( const char *p_name, unsigned int i_name_len );
+
+/*****************************************************************************
  * fourcc -> omx id mapping
  *****************************************************************************/
 int GetOmxVideoFormat( vlc_fourcc_t i_fourcc,
diff --git a/modules/codec/omxil/utils.c b/modules/codec/omxil/utils.c
index 3f9501d..6ec82cc 100644
--- a/modules/codec/omxil/utils.c
+++ b/modules/codec/omxil/utils.c
@@ -307,6 +307,72 @@ int IgnoreOmxDecoderPadding(const char *name)
 }
 
 /*****************************************************************************
+ * Utility functions
+ *****************************************************************************/
+bool OMXCodec_IsBlacklisted( const char *p_name, unsigned int i_name_len )
+{
+    static const char *blacklisted_prefix[] = {
+        /* ignore OpenCore software codecs */
+        "OMX.PV.",
+        /* The same sw codecs, renamed in ICS (perhaps also in honeycomb) */
+        "OMX.google.",
+        /* This one has been seen on HTC One V - it behaves like it works,
+         * but FillBufferDone returns buffers filled with 0 bytes. The One V
+         * has got a working OMX.qcom.video.decoder.avc instead though. */
+        "OMX.ARICENT.",
+        /* Use VC1 decoder for WMV3 for now */
+        "OMX.SEC.WMV.Decoder",
+        /* This decoder does work, but has an insane latency (leading to errors
+         * about "main audio output playback way too late" and dropped frames).
+         * At least Samsung Galaxy S III (where this decoder is present) has
+         * got another one, OMX.SEC.mp3.dec, that works well and has a
+         * sensible latency. (Also, even if that one isn't found, in general,
+         * using SW codecs is usually more than fast enough for MP3.) */
+        "OMX.SEC.MP3.Decoder",
+        /* This codec should be able to handle both VC1 and WMV3, but
+         * for VC1 it doesn't output any buffers at all (in the way we use
+         * it) and for WMV3 it outputs plain black buffers. Thus ignore
+         * it until we can make it work properly. */
+        "OMX.Nvidia.vc1.decode",
+        /* crashes mediaserver */
+        "OMX.MTK.VIDEO.DECODER.MPEG4",
+        /* Not working or crashing (Samsung) */
+        "OMX.SEC.vp8.dec",
+        NULL
+    };
+
+    static const char *blacklisted_suffix[] = {
+        /* Codecs with DRM, that don't output plain YUV data but only
+         * support direct rendering where the output can't be intercepted. */
+        ".secure",
+        NULL
+    };
+
+    /* p_name is not '\0' terminated */
+
+    for( const char **pp_bl_prefix = blacklisted_prefix; *pp_bl_prefix != NULL;
+          pp_bl_prefix++ )
+    {
+        if( !strncmp( p_name, *pp_bl_prefix,
+           __MIN( strlen(*pp_bl_prefix), i_name_len ) ) )
+           return true;
+    }
+
+    for( const char **pp_bl_suffix = blacklisted_suffix; *pp_bl_suffix != NULL;
+         pp_bl_suffix++ )
+    {
+       size_t i_suffix_len = strlen( *pp_bl_suffix );
+
+       if( i_name_len > i_suffix_len
+        && !strncmp( p_name + i_name_len - i_suffix_len, *pp_bl_suffix,
+                     i_suffix_len ) )
+           return true;
+    }
+
+    return false;
+}
+
+/*****************************************************************************
  * Logging utility functions
  *****************************************************************************/
 const char *StateToString(OMX_STATETYPE state)



More information about the vlc-commits mailing list