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
1795dccd
Commit
1795dccd
authored
May 10, 2017
by
Matthieu Bouron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavc/mediacodec_wrapper: fix local reference leaks
Reviewed-by:
Clément Bœsch
<
u@pkh.me
>
parent
2f43897f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
21 deletions
+42
-21
mediacodec_wrapper.c
libavcodec/mediacodec_wrapper.c
+42
-21
No files found.
libavcodec/mediacodec_wrapper.c
View file @
1795dccd
...
@@ -1129,9 +1129,11 @@ fail:
...
@@ -1129,9 +1129,11 @@ fail:
FFAMediaCodec
*
ff_AMediaCodec_createCodecByName
(
const
char
*
name
)
FFAMediaCodec
*
ff_AMediaCodec_createCodecByName
(
const
char
*
name
)
{
{
int
ret
=
-
1
;
JNIEnv
*
env
=
NULL
;
JNIEnv
*
env
=
NULL
;
FFAMediaCodec
*
codec
=
NULL
;
FFAMediaCodec
*
codec
=
NULL
;
jstring
codec_name
=
NULL
;
jstring
codec_name
=
NULL
;
jobject
object
=
NULL
;
codec
=
av_mallocz
(
sizeof
(
FFAMediaCodec
));
codec
=
av_mallocz
(
sizeof
(
FFAMediaCodec
));
if
(
!
codec
)
{
if
(
!
codec
)
{
...
@@ -1154,12 +1156,12 @@ FFAMediaCodec* ff_AMediaCodec_createCodecByName(const char *name)
...
@@ -1154,12 +1156,12 @@ FFAMediaCodec* ff_AMediaCodec_createCodecByName(const char *name)
goto
fail
;
goto
fail
;
}
}
codec
->
object
=
(
*
env
)
->
CallStaticObjectMethod
(
env
,
codec
->
jfields
.
mediacodec_class
,
codec
->
jfields
.
create_by_codec_name_id
,
codec_name
);
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
)
{
if
(
ff_jni_exception_check
(
env
,
1
,
codec
)
<
0
)
{
goto
fail
;
goto
fail
;
}
}
codec
->
object
=
(
*
env
)
->
NewGlobalRef
(
env
,
codec
->
object
);
codec
->
object
=
(
*
env
)
->
NewGlobalRef
(
env
,
object
);
if
(
!
codec
->
object
)
{
if
(
!
codec
->
object
)
{
goto
fail
;
goto
fail
;
}
}
...
@@ -1172,24 +1174,31 @@ FFAMediaCodec* ff_AMediaCodec_createCodecByName(const char *name)
...
@@ -1172,24 +1174,31 @@ FFAMediaCodec* ff_AMediaCodec_createCodecByName(const char *name)
codec
->
has_get_i_o_buffer
=
1
;
codec
->
has_get_i_o_buffer
=
1
;
}
}
ret
urn
codec
;
ret
=
0
;
fail:
fail:
ff_jni_reset_jfields
(
env
,
&
codec
->
jfields
,
jni_amediacodec_mapping
,
1
,
codec
);
if
(
codec_name
)
{
if
(
codec_name
)
{
(
*
env
)
->
DeleteLocalRef
(
env
,
codec_name
);
(
*
env
)
->
DeleteLocalRef
(
env
,
codec_name
);
}
}
av_freep
(
&
codec
);
if
(
object
)
{
(
*
env
)
->
DeleteLocalRef
(
env
,
object
);
}
return
NULL
;
if
(
ret
<
0
)
{
ff_jni_reset_jfields
(
env
,
&
codec
->
jfields
,
jni_amediacodec_mapping
,
1
,
codec
);
av_freep
(
&
codec
);
}
return
codec
;
}
}
FFAMediaCodec
*
ff_AMediaCodec_createDecoderByType
(
const
char
*
mime
)
FFAMediaCodec
*
ff_AMediaCodec_createDecoderByType
(
const
char
*
mime
)
{
{
int
ret
=
-
1
;
JNIEnv
*
env
=
NULL
;
JNIEnv
*
env
=
NULL
;
FFAMediaCodec
*
codec
=
NULL
;
FFAMediaCodec
*
codec
=
NULL
;
jstring
mime_type
=
NULL
;
jstring
mime_type
=
NULL
;
jobject
object
=
NULL
;
codec
=
av_mallocz
(
sizeof
(
FFAMediaCodec
));
codec
=
av_mallocz
(
sizeof
(
FFAMediaCodec
));
if
(
!
codec
)
{
if
(
!
codec
)
{
...
@@ -1212,12 +1221,12 @@ FFAMediaCodec* ff_AMediaCodec_createDecoderByType(const char *mime)
...
@@ -1212,12 +1221,12 @@ FFAMediaCodec* ff_AMediaCodec_createDecoderByType(const char *mime)
goto
fail
;
goto
fail
;
}
}
codec
->
object
=
(
*
env
)
->
CallStaticObjectMethod
(
env
,
codec
->
jfields
.
mediacodec_class
,
codec
->
jfields
.
create_decoder_by_type_id
,
mime_type
);
object
=
(
*
env
)
->
CallStaticObjectMethod
(
env
,
codec
->
jfields
.
mediacodec_class
,
codec
->
jfields
.
create_decoder_by_type_id
,
mime_type
);
if
(
ff_jni_exception_check
(
env
,
1
,
codec
)
<
0
)
{
if
(
ff_jni_exception_check
(
env
,
1
,
codec
)
<
0
)
{
goto
fail
;
goto
fail
;
}
}
codec
->
object
=
(
*
env
)
->
NewGlobalRef
(
env
,
codec
->
object
);
codec
->
object
=
(
*
env
)
->
NewGlobalRef
(
env
,
object
);
if
(
!
codec
->
object
)
{
if
(
!
codec
->
object
)
{
goto
fail
;
goto
fail
;
}
}
...
@@ -1230,24 +1239,31 @@ FFAMediaCodec* ff_AMediaCodec_createDecoderByType(const char *mime)
...
@@ -1230,24 +1239,31 @@ FFAMediaCodec* ff_AMediaCodec_createDecoderByType(const char *mime)
codec
->
has_get_i_o_buffer
=
1
;
codec
->
has_get_i_o_buffer
=
1
;
}
}
ret
urn
codec
;
ret
=
0
;
fail:
fail:
ff_jni_reset_jfields
(
env
,
&
codec
->
jfields
,
jni_amediacodec_mapping
,
1
,
codec
);
if
(
mime_type
)
{
if
(
mime_type
)
{
(
*
env
)
->
DeleteLocalRef
(
env
,
mime_type
);
(
*
env
)
->
DeleteLocalRef
(
env
,
mime_type
);
}
}
av_freep
(
&
codec
);
if
(
object
)
{
(
*
env
)
->
DeleteLocalRef
(
env
,
object
);
}
return
NULL
;
if
(
ret
<
0
)
{
ff_jni_reset_jfields
(
env
,
&
codec
->
jfields
,
jni_amediacodec_mapping
,
1
,
codec
);
av_freep
(
&
codec
);
}
return
codec
;
}
}
FFAMediaCodec
*
ff_AMediaCodec_createEncoderByType
(
const
char
*
mime
)
FFAMediaCodec
*
ff_AMediaCodec_createEncoderByType
(
const
char
*
mime
)
{
{
int
ret
=
-
1
;
JNIEnv
*
env
=
NULL
;
JNIEnv
*
env
=
NULL
;
FFAMediaCodec
*
codec
=
NULL
;
FFAMediaCodec
*
codec
=
NULL
;
jstring
mime_type
=
NULL
;
jstring
mime_type
=
NULL
;
jobject
object
=
NULL
;
codec
=
av_mallocz
(
sizeof
(
FFAMediaCodec
));
codec
=
av_mallocz
(
sizeof
(
FFAMediaCodec
));
if
(
!
codec
)
{
if
(
!
codec
)
{
...
@@ -1270,12 +1286,12 @@ FFAMediaCodec* ff_AMediaCodec_createEncoderByType(const char *mime)
...
@@ -1270,12 +1286,12 @@ FFAMediaCodec* ff_AMediaCodec_createEncoderByType(const char *mime)
goto
fail
;
goto
fail
;
}
}
codec
->
object
=
(
*
env
)
->
CallStaticObjectMethod
(
env
,
codec
->
jfields
.
mediacodec_class
,
codec
->
jfields
.
create_encoder_by_type_id
,
mime_type
);
object
=
(
*
env
)
->
CallStaticObjectMethod
(
env
,
codec
->
jfields
.
mediacodec_class
,
codec
->
jfields
.
create_encoder_by_type_id
,
mime_type
);
if
(
ff_jni_exception_check
(
env
,
1
,
codec
)
<
0
)
{
if
(
ff_jni_exception_check
(
env
,
1
,
codec
)
<
0
)
{
goto
fail
;
goto
fail
;
}
}
codec
->
object
=
(
*
env
)
->
NewGlobalRef
(
env
,
codec
->
object
);
codec
->
object
=
(
*
env
)
->
NewGlobalRef
(
env
,
object
);
if
(
!
codec
->
object
)
{
if
(
!
codec
->
object
)
{
goto
fail
;
goto
fail
;
}
}
...
@@ -1288,17 +1304,22 @@ FFAMediaCodec* ff_AMediaCodec_createEncoderByType(const char *mime)
...
@@ -1288,17 +1304,22 @@ FFAMediaCodec* ff_AMediaCodec_createEncoderByType(const char *mime)
codec
->
has_get_i_o_buffer
=
1
;
codec
->
has_get_i_o_buffer
=
1
;
}
}
ret
urn
codec
;
ret
=
0
;
fail:
fail:
ff_jni_reset_jfields
(
env
,
&
codec
->
jfields
,
jni_amediacodec_mapping
,
1
,
codec
);
if
(
mime_type
)
{
if
(
mime_type
)
{
(
*
env
)
->
DeleteLocalRef
(
env
,
mime_type
);
(
*
env
)
->
DeleteLocalRef
(
env
,
mime_type
);
}
}
av_freep
(
&
codec
);
if
(
object
)
{
(
*
env
)
->
DeleteLocalRef
(
env
,
object
);
}
return
NULL
;
if
(
ret
<
0
)
{
ff_jni_reset_jfields
(
env
,
&
codec
->
jfields
,
jni_amediacodec_mapping
,
1
,
codec
);
av_freep
(
&
codec
);
}
return
codec
;
}
}
int
ff_AMediaCodec_delete
(
FFAMediaCodec
*
codec
)
int
ff_AMediaCodec_delete
(
FFAMediaCodec
*
codec
)
...
...
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