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;
396 jobject codec =
NULL;
397 jobject codec_name =
NULL;
401 jobjectArray types =
NULL;
403 jobject capabilities =
NULL;
404 jobject profile_level =
NULL;
405 jobjectArray profile_levels =
NULL;
409 if ((ret =
ff_jni_init_jfields(env, &jfields, jni_amediacodeclist_mapping, 0, log_ctx)) < 0) {
413 if ((ret =
ff_jni_init_jfields(env, &mediaformat_jfields, jni_amediaformat_mapping, 0, log_ctx)) < 0) {
422 for(i = 0; i < codec_count; i++) {
437 is_encoder = (*env)->CallBooleanMethod(env, info, jfields.
is_encoder_id);
442 if (is_encoder != encoder) {
446 type_count = (*env)->GetArrayLength(env, types);
447 for (j = 0; j < type_count; j++) {
451 type = (*env)->GetObjectArrayElement(env, types, j);
457 if (!supported_type) {
462 codec_name = (*env)->CallObjectMethod(env, info, jfields.
get_name_id);
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")) {
487 profile_levels = (*env)->GetObjectField(env, capabilities, jfields.
profile_levels_id);
492 profile_count = (*env)->GetArrayLength(env, profile_levels);
493 if (!profile_count) {
496 for (k = 0; k < profile_count; k++) {
497 int supported_profile = 0;
504 profile_level = (*env)->GetObjectArrayElement(env, profile_levels, k);
509 supported_profile = (*env)->GetIntField(env, profile_level, jfields.
profile_id);
514 found_codec = profile == supported_profile;
517 (*env)->DeleteLocalRef(env, profile_level);
518 profile_level =
NULL;
528 if (profile_levels) {
529 (*env)->DeleteLocalRef(env, profile_levels);
530 profile_levels =
NULL;
534 (*env)->DeleteLocalRef(env, capabilities);
539 (*env)->DeleteLocalRef(env, type);
554 (*env)->DeleteLocalRef(env, info);
559 (*env)->DeleteLocalRef(env, types);
570 (*env)->DeleteLocalRef(env, format);
574 (*env)->DeleteLocalRef(env, codec);
578 (*env)->DeleteLocalRef(env, codec_name);
582 (*env)->DeleteLocalRef(env, info);
586 (*env)->DeleteLocalRef(env, type);
590 (*env)->DeleteLocalRef(env, types);
594 (*env)->DeleteLocalRef(env, capabilities);
598 (*env)->DeleteLocalRef(env, profile_level);
601 if (profile_levels) {
602 (*env)->DeleteLocalRef(env, profile_levels);
621 jobject
object =
NULL;
644 format->
object = (*env)->NewGlobalRef(env,
object);
651 (*env)->DeleteLocalRef(env,
object);
683 format->
object = (*env)->NewGlobalRef(env,
object);
709 (*env)->DeleteGlobalRef(env, format->
object);
724 jstring description =
NULL;
738 (*env)->DeleteLocalRef(env, description);
750 jboolean contains_key;
777 (*env)->DeleteLocalRef(env, key);
789 jboolean contains_key;
816 (*env)->DeleteLocalRef(env, key);
828 jboolean contains_key;
855 (*env)->DeleteLocalRef(env, key);
867 jboolean contains_key;
868 jobject result =
NULL;
892 *data = (*env)->GetDirectBufferAddress(env, result);
893 *size = (*env)->GetDirectBufferCapacity(env, result);
895 if (*data && *size) {
903 memcpy(*data, src, *size);
909 (*env)->DeleteLocalRef(env, key);
913 (*env)->DeleteLocalRef(env, result);
925 jboolean contains_key;
926 jstring result =
NULL;
959 (*env)->DeleteLocalRef(env, key);
963 (*env)->DeleteLocalRef(env, result);
990 (*env)->DeleteLocalRef(env, key);
1015 (*env)->DeleteLocalRef(env, key);
1040 (*env)->DeleteLocalRef(env, key);
1048 jstring
string =
NULL;
1071 (*env)->DeleteLocalRef(env, key);
1075 (*env)->DeleteLocalRef(env,
string);
1095 if (!data || !size) {
1104 memcpy(buffer_data, data, size);
1106 buffer = (*env)->NewDirectByteBuffer(env, buffer_data, size);
1118 (*env)->DeleteLocalRef(env, key);
1122 (*env)->DeleteLocalRef(env, buffer);
1180 #define CREATE_CODEC_BY_NAME 0 1181 #define CREATE_DECODER_BY_TYPE 1 1182 #define CREATE_ENCODER_BY_TYPE 2 1189 jstring jarg =
NULL;
1190 jobject
object =
NULL;
1191 jobject buffer_info =
NULL;
1192 jmethodID create_id =
NULL;
1223 object = (*env)->CallStaticObjectMethod(env,
1231 codec->
object = (*env)->NewGlobalRef(env,
object);
1249 codec->
buffer_info = (*env)->NewGlobalRef(env, buffer_info);
1257 (*env)->DeleteLocalRef(env, jarg);
1261 (*env)->DeleteLocalRef(env,
object);
1265 (*env)->DeleteLocalRef(env, buffer_info);
1270 (*env)->DeleteGlobalRef(env, codec->
object);
1284 #define DECLARE_FF_AMEDIACODEC_CREATE_FUNC(name, method) \ 1285 FFAMediaCodec *ff_AMediaCodec_##name(const char *arg) \ 1287 return codec_create(method, arg); \ 1306 (*env)->CallVoidMethod(env, codec->object, codec->jfields.release_id);
1311 (*env)->DeleteGlobalRef(env, codec->object);
1312 codec->object =
NULL;
1314 (*env)->DeleteGlobalRef(env, codec->buffer_info);
1315 codec->buffer_info =
NULL;
1520 jobject input_buffers =
NULL;
1536 codec->
input_buffers = (*env)->NewGlobalRef(env, input_buffers);
1542 buffer = (*env)->GetObjectArrayElement(env, codec->
input_buffers, idx);
1548 ret = (*env)->GetDirectBufferAddress(env, buffer);
1549 *out_size = (*env)->GetDirectBufferCapacity(env, buffer);
1552 (*env)->DeleteLocalRef(env, buffer);
1555 if (input_buffers) {
1556 (*env)->DeleteLocalRef(env, input_buffers);
1568 jobject output_buffers =
NULL;
1584 codec->
output_buffers = (*env)->NewGlobalRef(env, output_buffers);
1590 buffer = (*env)->GetObjectArrayElement(env, codec->
output_buffers, idx);
1596 ret = (*env)->GetDirectBufferAddress(env, buffer);
1597 *out_size = (*env)->GetDirectBufferCapacity(env, buffer);
1600 (*env)->DeleteLocalRef(env, buffer);
1603 if (output_buffers) {
1604 (*env)->DeleteLocalRef(env, output_buffers);
1615 jobject mediaformat =
NULL;
1627 (*env)->DeleteLocalRef(env, mediaformat);
#define FF_PROFILE_H264_MAIN
static const char * format[]
int ff_jni_reset_jfields(JNIEnv *env, void *jfields, const struct FFJniField *jfields_mapping, int global, void *log_ctx)
#define LIBAVUTIL_VERSION_INT
Memory handling functions.
const char * av_default_item_name(void *ptr)
Return the context name.
jstring ff_jni_utf_chars_to_jstring(JNIEnv *env, const char *utf_chars, void *log_ctx)
#define FF_PROFILE_H264_HIGH_444_PREDICTIVE
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define FF_PROFILE_H264_BASELINE
#define FF_PROFILE_HEVC_MAIN
#define FF_PROFILE_H264_EXTENDED
#define FF_PROFILE_HEVC_MAIN_10
Libavcodec version macros.
#define FF_PROFILE_H264_HIGH_422
#define FF_PROFILE_H264_HIGH
simple assert() macros that are a bit more flexible than ISO C assert().
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
static const uint8_t offset[127][2]
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
char * ff_jni_jstring_to_utf_chars(JNIEnv *env, jstring string, void *log_ctx)
#define FF_PROFILE_HEVC_MAIN_STILL_PICTURE
int ff_jni_init_jfields(JNIEnv *env, void *jfields, const struct FFJniField *jfields_mapping, int global, void *log_ctx)
int ff_jni_exception_check(JNIEnv *env, int log, void *log_ctx)
Libavcodec external API header.
#define FF_PROFILE_H264_HIGH_422_INTRA
main external API structure.
#define FF_PROFILE_H264_HIGH_10_INTRA
Describe the class of an AVClass context structure.
#define FF_PROFILE_H264_HIGH_444
JNIEnv * ff_jni_get_env(void *log_ctx)
#define FF_PROFILE_H264_HIGH_444_INTRA
#define FF_PROFILE_H264_CONSTRAINED_BASELINE
#define FF_PROFILE_H264_HIGH_10
#define AVERROR_EXTERNAL
Generic error in an external library.