[vlc-commits] mediacodec: fix video aspect ratio on Amazon devices

Thomas Guillem git at videolan.org
Tue Oct 29 11:23:53 CET 2019


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Oct 29 11:14:56 2019 +0100| [4e76bcfd5001db152167c6dec598d25b0e337f94] | committer: Thomas Guillem

mediacodec: fix video aspect ratio on Amazon devices

The AVC MediaCodec implementation of Amazon Fire TV devices report the surface
output size instead of the input video size.

These are the only know devices that need this HACK.

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

 modules/codec/omxil/mediacodec_jni.c | 46 ++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/modules/codec/omxil/mediacodec_jni.c b/modules/codec/omxil/mediacodec_jni.c
index ba2e92f21e..63e2a93464 100644
--- a/modules/codec/omxil/mediacodec_jni.c
+++ b/modules/codec/omxil/mediacodec_jni.c
@@ -314,6 +314,36 @@ struct mc_api_sys
     jobject input_buffers, output_buffers;
 };
 
+static char *GetManufacturer(JNIEnv *env)
+{
+    char *manufacturer = NULL;
+
+    jclass clazz = (*env)->FindClass(env, "android/os/Build");
+    if (CHECK_EXCEPTION())
+        return NULL;
+
+    jfieldID id = (*env)->GetStaticFieldID(env, clazz, "MANUFACTURER",
+                                           "Ljava/lang/String;");
+    if (CHECK_EXCEPTION())
+        goto end;
+
+    jstring jstr = (*env)->GetStaticObjectField(env, clazz, id);
+
+    if (CHECK_EXCEPTION())
+        goto end;
+
+    const char *str = (*env)->GetStringUTFChars(env, jstr, 0);
+    if (str)
+    {
+        manufacturer = strdup(str);
+        (*env)->ReleaseStringUTFChars(env, jstr, str);
+    }
+
+end:
+    (*env)->DeleteLocalRef(env, clazz);
+    return manufacturer;
+}
+
 /*****************************************************************************
  * MediaCodec_GetName
  *****************************************************************************/
@@ -456,6 +486,22 @@ char* MediaCodec_GetName(vlc_object_t *p_obj, const char *psz_mime,
 
                 bool ignore_size = false;
 
+                /* The AVC MediaCodec implementation on Amazon fire TV seems to
+                 * report the Output surface size instead of the AVC size. This
+                 * bug is specific to Amazon devices since other MTK
+                 * implementations report the correct size. The manufacturer is
+                 * checked only if the codec matches the MKT AVC one in order
+                 * to avoid extra manufacturer check for other every devices.
+                 * */
+                static const char mtk_avc[] = "OMX.MTK.VIDEO.DECODER.AVC";
+                if (strncmp(psz_name, mtk_avc, sizeof(mtk_avc) - 1) == 0)
+                {
+                    char *manufacturer = GetManufacturer(env);
+                    if (manufacturer && strcmp(manufacturer, "Amazon") == 0)
+                        ignore_size = true;
+                    free(manufacturer);
+                }
+
                 if (ignore_size)
                 {
                     *p_quirks |= MC_API_VIDEO_QUIRKS_IGNORE_SIZE;



More information about the vlc-commits mailing list