Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
fbc9359d
Commit
fbc9359d
authored
May 17, 2016
by
Matthieu Bouron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavc/mediacodec: factorize static fields initialization
parent
493db04c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
110 deletions
+57
-110
mediacodec_wrapper.c
libavcodec/mediacodec_wrapper.c
+57
-110
No files found.
libavcodec/mediacodec_wrapper.c
View file @
fbc9359d
...
...
@@ -958,83 +958,101 @@ struct FFAMediaCodec {
int
has_get_i_o_buffer
;
};
FFAMediaCodec
*
ff_AMediaCodec_createCodecByName
(
const
char
*
name
)
static
int
codec_init_static_fields
(
FFAMediaCodec
*
codec
)
{
int
ret
=
0
;
int
attached
=
0
;
JNIEnv
*
env
=
NULL
;
FFAMediaCodec
*
codec
=
NULL
;
jstring
codec_name
=
NULL
;
codec
=
av_mallocz
(
sizeof
(
FFAMediaCodec
));
if
(
!
codec
)
{
return
NULL
;
}
codec
->
class
=
&
amediacodec_class
;
JNI_ATTACH_ENV_OR_RETURN
(
env
,
&
attached
,
codec
,
AVERROR_EXTERNAL
);
env
=
ff_jni_attach_env
(
&
attached
,
codec
);
if
(
!
env
)
{
av_freep
(
&
codec
);
return
NULL
;
codec
->
INFO_TRY_AGAIN_LATER
=
(
*
env
)
->
GetStaticIntField
(
env
,
codec
->
jfields
.
mediacodec_class
,
codec
->
jfields
.
info_try_again_later_id
);
if
((
ret
=
ff_jni_exception_check
(
env
,
1
,
codec
))
<
0
)
{
goto
fail
;
}
if
(
ff_jni_init_jfields
(
env
,
&
codec
->
jfields
,
jni_amediacodec_mapping
,
1
,
codec
)
<
0
)
{
codec
->
BUFFER_FLAG_CODEC_CONFIG
=
(
*
env
)
->
GetStaticIntField
(
env
,
codec
->
jfields
.
mediacodec_class
,
codec
->
jfields
.
buffer_flag_codec_config_id
);
if
((
ret
=
ff_jni_exception_check
(
env
,
1
,
codec
))
<
0
)
{
goto
fail
;
}
codec
_name
=
ff_jni_utf_chars_to_jstring
(
env
,
name
,
codec
);
if
(
!
codec_name
)
{
codec
->
BUFFER_FLAG_END_OF_STREAM
=
(
*
env
)
->
GetStaticIntField
(
env
,
codec
->
jfields
.
mediacodec_class
,
codec
->
jfields
.
buffer_flag_end_of_stream_id
);
if
(
(
ret
=
ff_jni_exception_check
(
env
,
1
,
codec
))
<
0
)
{
goto
fail
;
}
codec
->
object
=
(
*
env
)
->
CallStaticObjectMethod
(
env
,
codec
->
jfields
.
mediacodec_class
,
codec
->
jfields
.
create_by_codec_name_id
,
codec_name
);
if
(
ff_jni_exception_check
(
env
,
1
,
codec
)
<
0
)
{
goto
fail
;
if
(
codec
->
jfields
.
buffer_flag_key_frame_id
)
{
codec
->
BUFFER_FLAG_KEY_FRAME
=
(
*
env
)
->
GetStaticIntField
(
env
,
codec
->
jfields
.
mediacodec_class
,
codec
->
jfields
.
buffer_flag_key_frame_id
);
if
((
ret
=
ff_jni_exception_check
(
env
,
1
,
codec
))
<
0
)
{
goto
fail
;
}
}
codec
->
object
=
(
*
env
)
->
NewGlobalRef
(
env
,
codec
->
object
);
if
(
!
codec
->
object
)
{
codec
->
CONFIGURE_FLAG_ENCODE
=
(
*
env
)
->
GetStaticIntField
(
env
,
codec
->
jfields
.
mediacodec_class
,
codec
->
jfields
.
configure_flag_encode_id
);
if
(
(
ret
=
ff_jni_exception_check
(
env
,
1
,
codec
))
<
0
)
{
goto
fail
;
}
codec
->
INFO_TRY_AGAIN_LATER
=
(
*
env
)
->
GetStaticIntField
(
env
,
codec
->
jfields
.
mediacodec_class
,
codec
->
jfields
.
info_try_again_later_id
);
if
(
ff_jni_exception_check
(
env
,
1
,
codec
)
<
0
)
{
if
(
(
ret
=
ff_jni_exception_check
(
env
,
1
,
codec
)
)
<
0
)
{
goto
fail
;
}
codec
->
BUFFER_FLAG_CODEC_CONFIG
=
(
*
env
)
->
GetStaticIntField
(
env
,
codec
->
jfields
.
mediacodec_class
,
codec
->
jfields
.
buffer_flag_codec_config
_id
);
if
(
ff_jni_exception_check
(
env
,
1
,
codec
)
<
0
)
{
codec
->
INFO_OUTPUT_BUFFERS_CHANGED
=
(
*
env
)
->
GetStaticIntField
(
env
,
codec
->
jfields
.
mediacodec_class
,
codec
->
jfields
.
info_output_buffers_changed
_id
);
if
(
(
ret
=
ff_jni_exception_check
(
env
,
1
,
codec
)
)
<
0
)
{
goto
fail
;
}
codec
->
BUFFER_FLAG_END_OF_STREAM
=
(
*
env
)
->
GetStaticIntField
(
env
,
codec
->
jfields
.
mediacodec_class
,
codec
->
jfields
.
buffer_flag_end_of_stream
_id
);
if
(
ff_jni_exception_check
(
env
,
1
,
codec
)
<
0
)
{
codec
->
INFO_OUTPUT_FORMAT_CHANGED
=
(
*
env
)
->
GetStaticIntField
(
env
,
codec
->
jfields
.
mediacodec_class
,
codec
->
jfields
.
info_output_format_changed
_id
);
if
(
(
ret
=
ff_jni_exception_check
(
env
,
1
,
codec
)
)
<
0
)
{
goto
fail
;
}
if
(
codec
->
jfields
.
buffer_flag_key_frame_id
)
{
codec
->
BUFFER_FLAG_KEY_FRAME
=
(
*
env
)
->
GetStaticIntField
(
env
,
codec
->
jfields
.
mediacodec_class
,
codec
->
jfields
.
buffer_flag_key_frame_id
);
if
(
ff_jni_exception_check
(
env
,
1
,
codec
)
<
0
)
{
goto
fail
;
}
fail:
JNI_DETACH_ENV
(
attached
,
NULL
);
return
ret
;
}
FFAMediaCodec
*
ff_AMediaCodec_createCodecByName
(
const
char
*
name
)
{
int
attached
=
0
;
JNIEnv
*
env
=
NULL
;
FFAMediaCodec
*
codec
=
NULL
;
jstring
codec_name
=
NULL
;
codec
=
av_mallocz
(
sizeof
(
FFAMediaCodec
));
if
(
!
codec
)
{
return
NULL
;
}
codec
->
class
=
&
amediacodec_class
;
codec
->
CONFIGURE_FLAG_ENCODE
=
(
*
env
)
->
GetStaticIntField
(
env
,
codec
->
jfields
.
mediacodec_class
,
codec
->
jfields
.
configure_flag_encode_id
);
if
(
ff_jni_exception_check
(
env
,
1
,
codec
)
<
0
)
{
env
=
ff_jni_attach_env
(
&
attached
,
codec
);
if
(
!
env
)
{
av_freep
(
&
codec
);
return
NULL
;
}
if
(
ff_jni_init_jfields
(
env
,
&
codec
->
jfields
,
jni_amediacodec_mapping
,
1
,
codec
)
<
0
)
{
goto
fail
;
}
codec
->
INFO_TRY_AGAIN_LATER
=
(
*
env
)
->
GetStaticIntField
(
env
,
codec
->
jfields
.
mediacodec_class
,
codec
->
jfields
.
info_try_again_later_id
);
if
(
ff_jni_exception_check
(
env
,
1
,
codec
)
<
0
)
{
codec
_name
=
ff_jni_utf_chars_to_jstring
(
env
,
name
,
codec
);
if
(
!
codec_name
)
{
goto
fail
;
}
codec
->
INFO_OUTPUT_BUFFERS_CHANGED
=
(
*
env
)
->
GetStaticIntField
(
env
,
codec
->
jfields
.
mediacodec_class
,
codec
->
jfields
.
info_output_buffers_changed_id
);
codec
->
object
=
(
*
env
)
->
CallStaticObjectMethod
(
env
,
codec
->
jfields
.
mediacodec_class
,
codec
->
jfields
.
create_by_codec_name_id
,
codec_name
);
if
(
ff_jni_exception_check
(
env
,
1
,
codec
)
<
0
)
{
goto
fail
;
}
codec
->
INFO_OUTPUT_FORMAT_CHANGED
=
(
*
env
)
->
GetStaticIntField
(
env
,
codec
->
jfields
.
mediacodec_class
,
codec
->
jfields
.
info_output_format_changed_id
);
if
(
ff_jni_exception_check
(
env
,
1
,
codec
)
<
0
)
{
codec
->
object
=
(
*
env
)
->
NewGlobalRef
(
env
,
codec
->
object
);
if
(
!
codec
->
object
)
{
goto
fail
;
}
if
(
codec_init_static_fields
(
codec
)
<
0
)
{
goto
fail
;
}
...
...
@@ -1093,40 +1111,7 @@ FFAMediaCodec* ff_AMediaCodec_createDecoderByType(const char *mime)
goto
fail
;
}
codec
->
BUFFER_FLAG_CODEC_CONFIG
=
(
*
env
)
->
GetStaticIntField
(
env
,
codec
->
jfields
.
mediacodec_class
,
codec
->
jfields
.
buffer_flag_codec_config_id
);
if
(
ff_jni_exception_check
(
env
,
1
,
codec
)
<
0
)
{
goto
fail
;
}
codec
->
BUFFER_FLAG_END_OF_STREAM
=
(
*
env
)
->
GetStaticIntField
(
env
,
codec
->
jfields
.
mediacodec_class
,
codec
->
jfields
.
buffer_flag_end_of_stream_id
);
if
(
ff_jni_exception_check
(
env
,
1
,
codec
)
<
0
)
{
goto
fail
;
}
if
(
codec
->
jfields
.
buffer_flag_key_frame_id
)
{
codec
->
BUFFER_FLAG_KEY_FRAME
=
(
*
env
)
->
GetStaticIntField
(
env
,
codec
->
jfields
.
mediacodec_class
,
codec
->
jfields
.
buffer_flag_key_frame_id
);
if
(
ff_jni_exception_check
(
env
,
1
,
codec
)
<
0
)
{
goto
fail
;
}
}
codec
->
CONFIGURE_FLAG_ENCODE
=
(
*
env
)
->
GetStaticIntField
(
env
,
codec
->
jfields
.
mediacodec_class
,
codec
->
jfields
.
configure_flag_encode_id
);
if
(
ff_jni_exception_check
(
env
,
1
,
codec
)
<
0
)
{
goto
fail
;
}
codec
->
INFO_TRY_AGAIN_LATER
=
(
*
env
)
->
GetStaticIntField
(
env
,
codec
->
jfields
.
mediacodec_class
,
codec
->
jfields
.
info_try_again_later_id
);
if
(
ff_jni_exception_check
(
env
,
1
,
codec
)
<
0
)
{
goto
fail
;
}
codec
->
INFO_OUTPUT_BUFFERS_CHANGED
=
(
*
env
)
->
GetStaticIntField
(
env
,
codec
->
jfields
.
mediacodec_class
,
codec
->
jfields
.
info_output_buffers_changed_id
);
if
(
ff_jni_exception_check
(
env
,
1
,
codec
)
<
0
)
{
goto
fail
;
}
codec
->
INFO_OUTPUT_FORMAT_CHANGED
=
(
*
env
)
->
GetStaticIntField
(
env
,
codec
->
jfields
.
mediacodec_class
,
codec
->
jfields
.
info_output_format_changed_id
);
if
(
ff_jni_exception_check
(
env
,
1
,
codec
)
<
0
)
{
if
(
codec_init_static_fields
(
codec
)
<
0
)
{
goto
fail
;
}
...
...
@@ -1189,45 +1174,7 @@ FFAMediaCodec* ff_AMediaCodec_createEncoderByType(const char *mime)
goto
fail
;
}
codec
->
INFO_TRY_AGAIN_LATER
=
(
*
env
)
->
GetStaticIntField
(
env
,
codec
->
jfields
.
mediacodec_class
,
codec
->
jfields
.
info_try_again_later_id
);
if
(
ff_jni_exception_check
(
env
,
1
,
codec
)
<
0
)
{
goto
fail
;
}
codec
->
BUFFER_FLAG_CODEC_CONFIG
=
(
*
env
)
->
GetStaticIntField
(
env
,
codec
->
jfields
.
mediacodec_class
,
codec
->
jfields
.
buffer_flag_codec_config_id
);
if
(
ff_jni_exception_check
(
env
,
1
,
codec
)
<
0
)
{
goto
fail
;
}
codec
->
BUFFER_FLAG_END_OF_STREAM
=
(
*
env
)
->
GetStaticIntField
(
env
,
codec
->
jfields
.
mediacodec_class
,
codec
->
jfields
.
buffer_flag_end_of_stream_id
);
if
(
ff_jni_exception_check
(
env
,
1
,
codec
)
<
0
)
{
goto
fail
;
}
if
(
codec
->
jfields
.
buffer_flag_key_frame_id
)
{
codec
->
BUFFER_FLAG_KEY_FRAME
=
(
*
env
)
->
GetStaticIntField
(
env
,
codec
->
jfields
.
mediacodec_class
,
codec
->
jfields
.
buffer_flag_key_frame_id
);
if
(
ff_jni_exception_check
(
env
,
1
,
codec
)
<
0
)
{
goto
fail
;
}
}
codec
->
CONFIGURE_FLAG_ENCODE
=
(
*
env
)
->
GetStaticIntField
(
env
,
codec
->
jfields
.
mediacodec_class
,
codec
->
jfields
.
configure_flag_encode_id
);
if
(
ff_jni_exception_check
(
env
,
1
,
codec
)
<
0
)
{
goto
fail
;
}
codec
->
INFO_TRY_AGAIN_LATER
=
(
*
env
)
->
GetStaticIntField
(
env
,
codec
->
jfields
.
mediacodec_class
,
codec
->
jfields
.
info_try_again_later_id
);
if
(
ff_jni_exception_check
(
env
,
1
,
codec
)
<
0
)
{
goto
fail
;
}
codec
->
INFO_OUTPUT_BUFFERS_CHANGED
=
(
*
env
)
->
GetStaticIntField
(
env
,
codec
->
jfields
.
mediacodec_class
,
codec
->
jfields
.
info_output_buffers_changed_id
);
if
(
ff_jni_exception_check
(
env
,
1
,
codec
)
<
0
)
{
goto
fail
;
}
codec
->
INFO_OUTPUT_FORMAT_CHANGED
=
(
*
env
)
->
GetStaticIntField
(
env
,
codec
->
jfields
.
mediacodec_class
,
codec
->
jfields
.
info_output_format_changed_id
);
if
(
ff_jni_exception_check
(
env
,
1
,
codec
)
<
0
)
{
if
(
codec_init_static_fields
(
codec
)
<
0
)
{
goto
fail
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment