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
3839580b
Commit
3839580b
authored
Jun 09, 2017
by
Matthieu Bouron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavc/mediacodecdec: switch to the new generic filtering mechanism
parent
4f9e958b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
61 deletions
+13
-61
mediacodecdec.c
libavcodec/mediacodecdec.c
+13
-61
No files found.
libavcodec/mediacodecdec.c
View file @
3839580b
...
...
@@ -41,11 +41,9 @@ typedef struct MediaCodecH264DecContext {
MediaCodecDecContext
*
ctx
;
AVBSFContext
*
bsf
;
AVFifoBuffer
*
fifo
;
AVPacket
filt
ered_pkt
;
AVPacket
buff
ered_pkt
;
}
MediaCodecH264DecContext
;
...
...
@@ -58,8 +56,7 @@ static av_cold int mediacodec_decode_close(AVCodecContext *avctx)
av_fifo_free
(
s
->
fifo
);
av_bsf_free
(
&
s
->
bsf
);
av_packet_unref
(
&
s
->
filtered_pkt
);
av_packet_unref
(
&
s
->
buffered_pkt
);
return
0
;
}
...
...
@@ -312,9 +309,6 @@ static av_cold int mediacodec_decode_init(AVCodecContext *avctx)
const
char
*
codec_mime
=
NULL
;
const
char
*
bsf_name
=
NULL
;
const
AVBitStreamFilter
*
bsf
=
NULL
;
FFAMediaFormat
*
format
=
NULL
;
MediaCodecH264DecContext
*
s
=
avctx
->
priv_data
;
...
...
@@ -329,7 +323,6 @@ static av_cold int mediacodec_decode_init(AVCodecContext *avctx)
#if CONFIG_H264_MEDIACODEC_DECODER
case
AV_CODEC_ID_H264
:
codec_mime
=
"video/avc"
;
bsf_name
=
"h264_mp4toannexb"
;
ret
=
h264_set_extradata
(
avctx
,
format
);
if
(
ret
<
0
)
...
...
@@ -339,7 +332,6 @@ static av_cold int mediacodec_decode_init(AVCodecContext *avctx)
#if CONFIG_HEVC_MEDIACODEC_DECODER
case
AV_CODEC_ID_HEVC
:
codec_mime
=
"video/hevc"
;
bsf_name
=
"hevc_mp4toannexb"
;
ret
=
hevc_set_extradata
(
avctx
,
format
);
if
(
ret
<
0
)
...
...
@@ -410,25 +402,6 @@ static av_cold int mediacodec_decode_init(AVCodecContext *avctx)
goto
done
;
}
if
(
bsf_name
)
{
bsf
=
av_bsf_get_by_name
(
bsf_name
);
if
(
!
bsf
)
{
ret
=
AVERROR_BSF_NOT_FOUND
;
goto
done
;
}
if
((
ret
=
av_bsf_alloc
(
bsf
,
&
s
->
bsf
)))
{
goto
done
;
}
if
(((
ret
=
avcodec_parameters_from_context
(
s
->
bsf
->
par_in
,
avctx
))
<
0
)
||
((
ret
=
av_bsf_init
(
s
->
bsf
))
<
0
))
{
goto
done
;
}
}
av_init_packet
(
&
s
->
filtered_pkt
);
done:
if
(
format
)
{
ff_AMediaFormat_delete
(
format
);
...
...
@@ -502,11 +475,9 @@ static int mediacodec_decode_frame(AVCodecContext *avctx, void *data,
/* process buffered data */
while
(
!*
got_frame
)
{
/* prepare the input data -- convert to Annex B if needed */
if
(
s
->
filtered_pkt
.
size
<=
0
)
{
AVPacket
input_pkt
=
{
0
};
av_packet_unref
(
&
s
->
filtered_pkt
);
/* prepare the input data */
if
(
s
->
buffered_pkt
.
size
<=
0
)
{
av_packet_unref
(
&
s
->
buffered_pkt
);
/* no more data */
if
(
av_fifo_size
(
s
->
fifo
)
<
sizeof
(
AVPacket
))
{
...
...
@@ -514,38 +485,17 @@ static int mediacodec_decode_frame(AVCodecContext *avctx, void *data,
ff_mediacodec_dec_decode
(
avctx
,
s
->
ctx
,
frame
,
got_frame
,
avpkt
);
}
av_fifo_generic_read
(
s
->
fifo
,
&
input_pkt
,
sizeof
(
input_pkt
),
NULL
);
if
(
s
->
bsf
)
{
ret
=
av_bsf_send_packet
(
s
->
bsf
,
&
input_pkt
);
if
(
ret
<
0
)
{
return
ret
;
}
ret
=
av_bsf_receive_packet
(
s
->
bsf
,
&
s
->
filtered_pkt
);
if
(
ret
==
AVERROR
(
EAGAIN
))
{
goto
done
;
}
}
else
{
av_packet_move_ref
(
&
s
->
filtered_pkt
,
&
input_pkt
);
}
/* {h264,hevc}_mp4toannexb are used here and do not require flushing */
av_assert0
(
ret
!=
AVERROR_EOF
);
if
(
ret
<
0
)
{
return
ret
;
}
av_fifo_generic_read
(
s
->
fifo
,
&
s
->
buffered_pkt
,
sizeof
(
s
->
buffered_pkt
),
NULL
);
}
ret
=
mediacodec_process_data
(
avctx
,
frame
,
got_frame
,
&
s
->
filt
ered_pkt
);
ret
=
mediacodec_process_data
(
avctx
,
frame
,
got_frame
,
&
s
->
buff
ered_pkt
);
if
(
ret
<
0
)
return
ret
;
s
->
filt
ered_pkt
.
size
-=
ret
;
s
->
filt
ered_pkt
.
data
+=
ret
;
s
->
buff
ered_pkt
.
size
-=
ret
;
s
->
buff
ered_pkt
.
data
+=
ret
;
}
done:
return
avpkt
->
size
;
}
...
...
@@ -560,7 +510,7 @@ static void mediacodec_decode_flush(AVCodecContext *avctx)
}
av_fifo_reset
(
s
->
fifo
);
av_packet_unref
(
&
s
->
filt
ered_pkt
);
av_packet_unref
(
&
s
->
buff
ered_pkt
);
ff_mediacodec_dec_flush
(
avctx
,
s
->
ctx
);
}
...
...
@@ -578,6 +528,7 @@ AVCodec ff_h264_mediacodec_decoder = {
.
close
=
mediacodec_decode_close
,
.
capabilities
=
AV_CODEC_CAP_DELAY
|
AV_CODEC_CAP_AVOID_PROBING
,
.
caps_internal
=
FF_CODEC_CAP_SETS_PKT_DTS
,
.
bsfs
=
"h264_mp4toannexb"
,
};
#endif
...
...
@@ -594,6 +545,7 @@ AVCodec ff_hevc_mediacodec_decoder = {
.
close
=
mediacodec_decode_close
,
.
capabilities
=
AV_CODEC_CAP_DELAY
|
AV_CODEC_CAP_AVOID_PROBING
,
.
caps_internal
=
FF_CODEC_CAP_SETS_PKT_DTS
,
.
bsfs
=
"hevc_mp4toannexb"
,
};
#endif
...
...
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