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

Thomas Guillem git at videolan.org
Wed Oct 30 08:15:54 CET 2019


vlc/vlc-3.0 | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Oct 29 11:14:56 2019 +0100| [71fd3326ea4390d4e62434670baf69388f51ab04] | 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.

(cherry picked from commit 4e76bcfd5001db152167c6dec598d25b0e337f94)
Signed-off-by: Thomas Guillem <thomas at gllm.fr>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=71fd3326ea4390d4e62434670baf69388f51ab04
---

 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 8ef9ff3ace..1dc206515e 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