75 {
"android/media/MediaCodecList",
"findDecoderForFormat",
"(Landroid/media/MediaFormat;)Ljava/lang/String;",
FF_JNI_METHOD, offsetof(
struct JNIAMediaCodecListFields, find_decoder_for_format_id), 0 },
82 {
"android/media/MediaCodecInfo",
"getCapabilitiesForType",
"(Ljava/lang/String;)Landroid/media/MediaCodecInfo$CodecCapabilities;",
FF_JNI_METHOD, offsetof(
struct JNIAMediaCodecListFields, get_codec_capabilities_id), 1 },
89 {
"android/media/MediaCodecInfo$CodecCapabilities",
"profileLevels",
"[Landroid/media/MediaCodecInfo$CodecProfileLevel;",
FF_JNI_FIELD, offsetof(
struct JNIAMediaCodecListFields, profile_levels_id), 1 },
144 {
"android/media/MediaFormat",
"getByteBuffer",
"(Ljava/lang/String;)Ljava/nio/ByteBuffer;",
FF_JNI_METHOD, offsetof(
struct JNIAMediaFormatFields, get_bytebuffer_id), 1 },
150 {
"android/media/MediaFormat",
"setByteBuffer",
"(Ljava/lang/String;Ljava/nio/ByteBuffer;)V",
FF_JNI_METHOD, offsetof(
struct JNIAMediaFormatFields, set_bytebuffer_id), 1 },
240 {
"android/media/MediaCodec",
"configure",
"(Landroid/media/MediaFormat;Landroid/view/Surface;Landroid/media/MediaCrypto;I)V",
FF_JNI_METHOD, offsetof(
struct JNIAMediaCodecFields, configure_id), 1 },
246 {
"android/media/MediaCodec",
"getOutputFormat",
"()Landroid/media/MediaFormat;",
FF_JNI_METHOD, offsetof(
struct JNIAMediaCodecFields, get_output_format_id), 1 },
253 {
"android/media/MediaCodec",
"dequeueOutputBuffer",
"(Landroid/media/MediaCodec$BufferInfo;J)I",
FF_JNI_METHOD, offsetof(
struct JNIAMediaCodecFields, dequeue_output_buffer_id), 1 },
301 #define JNI_GET_ENV_OR_RETURN(env, log_ctx, ret) do { \
302 (env) = ff_jni_get_env(log_ctx); \
308 #define JNI_GET_ENV_OR_RETURN_VOID(env, log_ctx) do { \
309 (env) = ff_jni_get_env(log_ctx); \
321 jfieldID field_id = 0;
391 char *supported_type =
NULL;
397 jobject codec_name =
NULL;
401 jobjectArray types =
NULL;
403 jobject capabilities =
NULL;
404 jobject profile_level =
NULL;
405 jobjectArray profile_levels =
NULL;
422 for(
i = 0;
i < codec_count;
i++) {
442 if (is_encoder != encoder) {
452 if (is_software_only) {
468 (*env)->DeleteLocalRef(env, codec_name);
474 strstr(
name,
"OMX.google") ||
475 strstr(
name,
"OMX.ffmpeg") ||
476 (strstr(
name,
"OMX.SEC") && strstr(
name,
".sw.")) ||
477 !strcmp(
name,
"OMX.qcom.video.decoder.hevcswvdec")) {
481 type_count = (*env)->GetArrayLength(env, types);
482 for (j = 0; j < type_count; j++) {
486 type = (*env)->GetObjectArrayElement(env, types, j);
492 if (!supported_type) {
505 profile_levels = (*env)->GetObjectField(env, capabilities, jfields.
profile_levels_id);
510 profile_count = (*env)->GetArrayLength(env, profile_levels);
511 if (!profile_count) {
514 for (k = 0; k < profile_count; k++) {
515 int supported_profile = 0;
522 profile_level = (*env)->GetObjectArrayElement(env, profile_levels, k);
527 supported_profile = (*env)->GetIntField(env, profile_level, jfields.
profile_id);
532 found_codec =
profile == supported_profile;
535 (*env)->DeleteLocalRef(env, profile_level);
536 profile_level =
NULL;
545 if (profile_levels) {
546 (*env)->DeleteLocalRef(env, profile_levels);
547 profile_levels =
NULL;
551 (*env)->DeleteLocalRef(env, capabilities);
556 (*env)->DeleteLocalRef(env,
type);
569 (*env)->DeleteLocalRef(env,
info);
574 (*env)->DeleteLocalRef(env, types);
587 (*env)->DeleteLocalRef(env, codec_name);
591 (*env)->DeleteLocalRef(env,
info);
595 (*env)->DeleteLocalRef(env,
type);
599 (*env)->DeleteLocalRef(env, types);
603 (*env)->DeleteLocalRef(env, capabilities);
607 (*env)->DeleteLocalRef(env, profile_level);
610 if (profile_levels) {
611 (*env)->DeleteLocalRef(env, profile_levels);
630 jobject
object =
NULL;
648 object = (*env)->NewObject(env,
format->jfields.mediaformat_class,
format->jfields.init_id);
653 format->object = (*env)->NewGlobalRef(env,
object);
660 (*env)->DeleteLocalRef(env,
object);
692 format->object = (*env)->NewGlobalRef(env,
object);
718 (*env)->DeleteGlobalRef(env,
format->object);
759 jboolean contains_key;
771 contains_key = (*env)->CallBooleanMethod(env,
format->object,
format->jfields.contains_key_id,
key);
777 *
out = (*env)->CallIntMethod(env,
format->object,
format->jfields.get_integer_id,
key);
786 (*env)->DeleteLocalRef(env,
key);
798 jboolean contains_key;
810 contains_key = (*env)->CallBooleanMethod(env,
format->object,
format->jfields.contains_key_id,
key);
825 (*env)->DeleteLocalRef(env,
key);
837 jboolean contains_key;
849 contains_key = (*env)->CallBooleanMethod(env,
format->object,
format->jfields.contains_key_id,
key);
855 *
out = (*env)->CallFloatMethod(env,
format->object,
format->jfields.get_float_id,
key);
864 (*env)->DeleteLocalRef(env,
key);
876 jboolean contains_key;
889 contains_key = (*env)->CallBooleanMethod(env,
format->object,
format->jfields.contains_key_id,
key);
901 *
data = (*env)->GetDirectBufferAddress(env,
result);
902 *
size = (*env)->GetDirectBufferCapacity(env,
result);
918 (*env)->DeleteLocalRef(env,
key);
922 (*env)->DeleteLocalRef(env,
result);
934 jboolean contains_key;
947 contains_key = (*env)->CallBooleanMethod(env,
format->object,
format->jfields.contains_key_id,
key);
968 (*env)->DeleteLocalRef(env,
key);
972 (*env)->DeleteLocalRef(env,
result);
999 (*env)->DeleteLocalRef(env,
key);
1024 (*env)->DeleteLocalRef(env,
key);
1049 (*env)->DeleteLocalRef(env,
key);
1057 jstring
string =
NULL;
1073 (*env)->CallVoidMethod(env,
format->object,
format->jfields.set_string_id,
key,
string);
1080 (*env)->DeleteLocalRef(env,
key);
1084 (*env)->DeleteLocalRef(env,
string);
1127 (*env)->DeleteLocalRef(env,
key);
1131 (*env)->DeleteLocalRef(env,
buffer);
1189 #define CREATE_CODEC_BY_NAME 0
1190 #define CREATE_DECODER_BY_TYPE 1
1191 #define CREATE_ENCODER_BY_TYPE 2
1198 jstring jarg =
NULL;
1199 jobject
object =
NULL;
1200 jobject buffer_info =
NULL;
1201 jmethodID create_id =
NULL;
1232 object = (*env)->CallStaticObjectMethod(env,
1240 codec->
object = (*env)->NewGlobalRef(env,
object);
1258 codec->
buffer_info = (*env)->NewGlobalRef(env, buffer_info);
1266 (*env)->DeleteLocalRef(env, jarg);
1270 (*env)->DeleteLocalRef(env,
object);
1274 (*env)->DeleteLocalRef(env, buffer_info);
1279 (*env)->DeleteGlobalRef(env, codec->
object);
1293 #define DECLARE_FF_AMEDIACODEC_CREATE_FUNC(name, method) \
1294 FFAMediaCodec *ff_AMediaCodec_##name(const char *arg) \
1296 return codec_create(method, arg); \
1315 (*env)->CallVoidMethod(env, codec->object, codec->jfields.release_id);
1320 (*env)->DeleteGlobalRef(env, codec->input_buffers);
1321 codec->input_buffers =
NULL;
1323 (*env)->DeleteGlobalRef(env, codec->output_buffers);
1324 codec->output_buffers =
NULL;
1326 (*env)->DeleteGlobalRef(env, codec->object);
1327 codec->object =
NULL;
1329 (*env)->DeleteGlobalRef(env, codec->buffer_info);
1330 codec->buffer_info =
NULL;
1356 (*env)->DeleteLocalRef(env,
name);
1539 jobject input_buffers =
NULL;
1555 codec->
input_buffers = (*env)->NewGlobalRef(env, input_buffers);
1567 ret = (*env)->GetDirectBufferAddress(env,
buffer);
1571 (*env)->DeleteLocalRef(env,
buffer);
1574 if (input_buffers) {
1575 (*env)->DeleteLocalRef(env, input_buffers);
1587 jobject output_buffers =
NULL;
1603 codec->
output_buffers = (*env)->NewGlobalRef(env, output_buffers);
1615 ret = (*env)->GetDirectBufferAddress(env,
buffer);
1619 (*env)->DeleteLocalRef(env,
buffer);
1622 if (output_buffers) {
1623 (*env)->DeleteLocalRef(env, output_buffers);
1634 jobject mediaformat =
NULL;
1646 (*env)->DeleteLocalRef(env, mediaformat);
1714 jclass versionClass;
1715 jfieldID sdkIntFieldID;
1718 versionClass = (*env)->FindClass(env,
"android/os/Build$VERSION");
1719 sdkIntFieldID = (*env)->GetStaticFieldID(env, versionClass,
"SDK_INT",
"I");
1720 ret = (*env)->GetStaticIntField(env, versionClass, sdkIntFieldID);
1721 (*env)->DeleteLocalRef(env, versionClass);