74 {
"android/media/MediaCodecList",
"findDecoderForFormat",
"(Landroid/media/MediaFormat;)Ljava/lang/String;",
FF_JNI_METHOD, offsetof(
struct JNIAMediaCodecListFields, find_decoder_for_format_id), 0 },
81 {
"android/media/MediaCodecInfo",
"getCapabilitiesForType",
"(Ljava/lang/String;)Landroid/media/MediaCodecInfo$CodecCapabilities;",
FF_JNI_METHOD, offsetof(
struct JNIAMediaCodecListFields, get_codec_capabilities_id), 1 },
87 {
"android/media/MediaCodecInfo$CodecCapabilities",
"profileLevels",
"[Landroid/media/MediaCodecInfo$CodecProfileLevel;",
FF_JNI_FIELD, offsetof(
struct JNIAMediaCodecListFields, profile_levels_id), 1 },
142 {
"android/media/MediaFormat",
"getByteBuffer",
"(Ljava/lang/String;)Ljava/nio/ByteBuffer;",
FF_JNI_METHOD, offsetof(
struct JNIAMediaFormatFields, get_bytebuffer_id), 1 },
148 {
"android/media/MediaFormat",
"setByteBuffer",
"(Ljava/lang/String;Ljava/nio/ByteBuffer;)V",
FF_JNI_METHOD, offsetof(
struct JNIAMediaFormatFields, set_bytebuffer_id), 1 },
238 {
"android/media/MediaCodec",
"configure",
"(Landroid/media/MediaFormat;Landroid/view/Surface;Landroid/media/MediaCrypto;I)V",
FF_JNI_METHOD, offsetof(
struct JNIAMediaCodecFields, configure_id), 1 },
244 {
"android/media/MediaCodec",
"getOutputFormat",
"()Landroid/media/MediaFormat;",
FF_JNI_METHOD, offsetof(
struct JNIAMediaCodecFields, get_output_format_id), 1 },
251 {
"android/media/MediaCodec",
"dequeueOutputBuffer",
"(Landroid/media/MediaCodec$BufferInfo;J)I",
FF_JNI_METHOD, offsetof(
struct JNIAMediaCodecFields, dequeue_output_buffer_id), 1 },
299 #define JNI_GET_ENV_OR_RETURN(env, log_ctx, ret) do { \
300 (env) = ff_jni_get_env(log_ctx); \
306 #define JNI_GET_ENV_OR_RETURN_VOID(env, log_ctx) do { \
307 (env) = ff_jni_get_env(log_ctx); \
319 jfieldID field_id = 0;
389 char *supported_type =
NULL;
395 jobject codec_name =
NULL;
399 jobjectArray types =
NULL;
401 jobject capabilities =
NULL;
402 jobject profile_level =
NULL;
403 jobjectArray profile_levels =
NULL;
420 for(
i = 0;
i < codec_count;
i++) {
440 if (is_encoder != encoder) {
444 type_count = (*env)->GetArrayLength(env, types);
445 for (j = 0; j < type_count; j++) {
449 type = (*env)->GetObjectArrayElement(env, types, j);
455 if (!supported_type) {
471 (*env)->DeleteLocalRef(env, codec_name);
477 strstr(
name,
"OMX.google") ||
478 strstr(
name,
"OMX.ffmpeg") ||
479 (strstr(
name,
"OMX.SEC") && strstr(
name,
".sw.")) ||
480 !strcmp(
name,
"OMX.qcom.video.decoder.hevcswvdec")) {
490 profile_levels = (*env)->GetObjectField(env, capabilities, jfields.
profile_levels_id);
495 profile_count = (*env)->GetArrayLength(env, profile_levels);
496 if (!profile_count) {
499 for (k = 0; k < profile_count; k++) {
500 int supported_profile = 0;
507 profile_level = (*env)->GetObjectArrayElement(env, profile_levels, k);
512 supported_profile = (*env)->GetIntField(env, profile_level, jfields.
profile_id);
517 found_codec =
profile == supported_profile;
520 (*env)->DeleteLocalRef(env, profile_level);
521 profile_level =
NULL;
531 if (profile_levels) {
532 (*env)->DeleteLocalRef(env, profile_levels);
533 profile_levels =
NULL;
537 (*env)->DeleteLocalRef(env, capabilities);
542 (*env)->DeleteLocalRef(env,
type);
557 (*env)->DeleteLocalRef(env,
info);
562 (*env)->DeleteLocalRef(env, types);
573 (*env)->DeleteLocalRef(env, codec_name);
577 (*env)->DeleteLocalRef(env,
info);
581 (*env)->DeleteLocalRef(env,
type);
585 (*env)->DeleteLocalRef(env, types);
589 (*env)->DeleteLocalRef(env, capabilities);
593 (*env)->DeleteLocalRef(env, profile_level);
596 if (profile_levels) {
597 (*env)->DeleteLocalRef(env, profile_levels);
616 jobject
object =
NULL;
634 object = (*env)->NewObject(env,
format->jfields.mediaformat_class,
format->jfields.init_id);
639 format->object = (*env)->NewGlobalRef(env,
object);
646 (*env)->DeleteLocalRef(env,
object);
678 format->object = (*env)->NewGlobalRef(env,
object);
704 (*env)->DeleteGlobalRef(env,
format->object);
745 jboolean contains_key;
757 contains_key = (*env)->CallBooleanMethod(env,
format->object,
format->jfields.contains_key_id,
key);
763 *
out = (*env)->CallIntMethod(env,
format->object,
format->jfields.get_integer_id,
key);
772 (*env)->DeleteLocalRef(env,
key);
784 jboolean contains_key;
796 contains_key = (*env)->CallBooleanMethod(env,
format->object,
format->jfields.contains_key_id,
key);
811 (*env)->DeleteLocalRef(env,
key);
823 jboolean contains_key;
835 contains_key = (*env)->CallBooleanMethod(env,
format->object,
format->jfields.contains_key_id,
key);
841 *
out = (*env)->CallFloatMethod(env,
format->object,
format->jfields.get_float_id,
key);
850 (*env)->DeleteLocalRef(env,
key);
862 jboolean contains_key;
875 contains_key = (*env)->CallBooleanMethod(env,
format->object,
format->jfields.contains_key_id,
key);
887 *
data = (*env)->GetDirectBufferAddress(env,
result);
888 *
size = (*env)->GetDirectBufferCapacity(env,
result);
904 (*env)->DeleteLocalRef(env,
key);
908 (*env)->DeleteLocalRef(env,
result);
920 jboolean contains_key;
933 contains_key = (*env)->CallBooleanMethod(env,
format->object,
format->jfields.contains_key_id,
key);
954 (*env)->DeleteLocalRef(env,
key);
958 (*env)->DeleteLocalRef(env,
result);
985 (*env)->DeleteLocalRef(env,
key);
1010 (*env)->DeleteLocalRef(env,
key);
1035 (*env)->DeleteLocalRef(env,
key);
1043 jstring
string =
NULL;
1059 (*env)->CallVoidMethod(env,
format->object,
format->jfields.set_string_id,
key,
string);
1066 (*env)->DeleteLocalRef(env,
key);
1070 (*env)->DeleteLocalRef(env,
string);
1113 (*env)->DeleteLocalRef(env,
key);
1117 (*env)->DeleteLocalRef(env,
buffer);
1175 #define CREATE_CODEC_BY_NAME 0
1176 #define CREATE_DECODER_BY_TYPE 1
1177 #define CREATE_ENCODER_BY_TYPE 2
1184 jstring jarg =
NULL;
1185 jobject
object =
NULL;
1186 jobject buffer_info =
NULL;
1187 jmethodID create_id =
NULL;
1218 object = (*env)->CallStaticObjectMethod(env,
1226 codec->
object = (*env)->NewGlobalRef(env,
object);
1244 codec->
buffer_info = (*env)->NewGlobalRef(env, buffer_info);
1252 (*env)->DeleteLocalRef(env, jarg);
1256 (*env)->DeleteLocalRef(env,
object);
1260 (*env)->DeleteLocalRef(env, buffer_info);
1265 (*env)->DeleteGlobalRef(env, codec->
object);
1279 #define DECLARE_FF_AMEDIACODEC_CREATE_FUNC(name, method) \
1280 FFAMediaCodec *ff_AMediaCodec_##name(const char *arg) \
1282 return codec_create(method, arg); \
1301 (*env)->CallVoidMethod(env, codec->object, codec->jfields.release_id);
1306 (*env)->DeleteGlobalRef(env, codec->input_buffers);
1307 codec->input_buffers =
NULL;
1309 (*env)->DeleteGlobalRef(env, codec->output_buffers);
1310 codec->output_buffers =
NULL;
1312 (*env)->DeleteGlobalRef(env, codec->object);
1313 codec->object =
NULL;
1315 (*env)->DeleteGlobalRef(env, codec->buffer_info);
1316 codec->buffer_info =
NULL;
1342 (*env)->DeleteLocalRef(env,
name);
1525 jobject input_buffers =
NULL;
1541 codec->
input_buffers = (*env)->NewGlobalRef(env, input_buffers);
1553 ret = (*env)->GetDirectBufferAddress(env,
buffer);
1557 (*env)->DeleteLocalRef(env,
buffer);
1560 if (input_buffers) {
1561 (*env)->DeleteLocalRef(env, input_buffers);
1573 jobject output_buffers =
NULL;
1589 codec->
output_buffers = (*env)->NewGlobalRef(env, output_buffers);
1601 ret = (*env)->GetDirectBufferAddress(env,
buffer);
1605 (*env)->DeleteLocalRef(env,
buffer);
1608 if (output_buffers) {
1609 (*env)->DeleteLocalRef(env, output_buffers);
1620 jobject mediaformat =
NULL;
1632 (*env)->DeleteLocalRef(env, mediaformat);
1700 jclass versionClass;
1701 jfieldID sdkIntFieldID;
1704 versionClass = (*env)->FindClass(env,
"android/os/Build$VERSION");
1705 sdkIntFieldID = (*env)->GetStaticFieldID(env, versionClass,
"SDK_INT",
"I");
1706 ret = (*env)->GetStaticIntField(env, versionClass, sdkIntFieldID);
1707 (*env)->DeleteLocalRef(env, versionClass);