Skip to content
Snippets Groups Projects
Commit 4e76bcfd authored by Thomas Guillem's avatar Thomas Guillem
Browse files

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.
parent 669505d1
No related branches found
No related tags found
No related merge requests found
Pipeline #10628 failed with stage
in 22 minutes and 57 seconds
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment