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
e3dfef8e
Commit
e3dfef8e
authored
Mar 20, 2016
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
qsvdec_h2645: switch to the new BSF API
parent
a638e918
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
32 deletions
+52
-32
qsvdec_h2645.c
libavcodec/qsvdec_h2645.c
+52
-32
No files found.
libavcodec/qsvdec_h2645.c
View file @
e3dfef8e
...
@@ -49,13 +49,11 @@ typedef struct QSVH2645Context {
...
@@ -49,13 +49,11 @@ typedef struct QSVH2645Context {
int
load_plugin
;
int
load_plugin
;
// the filter for converting to Annex B
// the filter for converting to Annex B
AVB
itStreamFilter
Context
*
bsf
;
AVB
SF
Context
*
bsf
;
AVFifoBuffer
*
packet_fifo
;
AVFifoBuffer
*
packet_fifo
;
AVPacket
input_ref
;
AVPacket
pkt_filtered
;
AVPacket
pkt_filtered
;
uint8_t
*
filtered_data
;
}
QSVH2645Context
;
}
QSVH2645Context
;
static
void
qsv_clear_buffers
(
QSVH2645Context
*
s
)
static
void
qsv_clear_buffers
(
QSVH2645Context
*
s
)
...
@@ -66,10 +64,9 @@ static void qsv_clear_buffers(QSVH2645Context *s)
...
@@ -66,10 +64,9 @@ static void qsv_clear_buffers(QSVH2645Context *s)
av_packet_unref
(
&
pkt
);
av_packet_unref
(
&
pkt
);
}
}
if
(
s
->
filtered_data
!=
s
->
input_ref
.
data
)
av_bsf_free
(
&
s
->
bsf
);
av_freep
(
&
s
->
filtered_data
);
s
->
filtered_data
=
NULL
;
av_packet_unref
(
&
s
->
pkt_filtered
);
av_packet_unref
(
&
s
->
input_ref
);
}
}
static
av_cold
int
qsv_decode_close
(
AVCodecContext
*
avctx
)
static
av_cold
int
qsv_decode_close
(
AVCodecContext
*
avctx
)
...
@@ -82,8 +79,6 @@ static av_cold int qsv_decode_close(AVCodecContext *avctx)
...
@@ -82,8 +79,6 @@ static av_cold int qsv_decode_close(AVCodecContext *avctx)
av_fifo_free
(
s
->
packet_fifo
);
av_fifo_free
(
s
->
packet_fifo
);
av_bitstream_filter_close
(
s
->
bsf
);
return
0
;
return
0
;
}
}
...
@@ -113,15 +108,6 @@ static av_cold int qsv_decode_init(AVCodecContext *avctx)
...
@@ -113,15 +108,6 @@ static av_cold int qsv_decode_init(AVCodecContext *avctx)
goto
fail
;
goto
fail
;
}
}
if
(
avctx
->
codec_id
==
AV_CODEC_ID_H264
)
s
->
bsf
=
av_bitstream_filter_init
(
"h264_mp4toannexb"
);
else
s
->
bsf
=
av_bitstream_filter_init
(
"hevc_mp4toannexb"
);
if
(
!
s
->
bsf
)
{
ret
=
AVERROR
(
ENOMEM
);
goto
fail
;
}
s
->
qsv
.
iopattern
=
MFX_IOPATTERN_OUT_SYSTEM_MEMORY
;
s
->
qsv
.
iopattern
=
MFX_IOPATTERN_OUT_SYSTEM_MEMORY
;
return
0
;
return
0
;
...
@@ -130,6 +116,37 @@ fail:
...
@@ -130,6 +116,37 @@ fail:
return
ret
;
return
ret
;
}
}
static
int
qsv_init_bsf
(
AVCodecContext
*
avctx
,
QSVH2645Context
*
s
)
{
const
char
*
filter_name
=
avctx
->
codec_id
==
AV_CODEC_ID_HEVC
?
"hevc_mp4toannexb"
:
"h264_mp4toannexb"
;
const
AVBitStreamFilter
*
filter
;
int
ret
;
if
(
s
->
bsf
)
return
0
;
filter
=
av_bsf_get_by_name
(
filter_name
);
if
(
!
filter
)
return
AVERROR_BUG
;
ret
=
av_bsf_alloc
(
filter
,
&
s
->
bsf
);
if
(
ret
<
0
)
return
ret
;
ret
=
avcodec_parameters_from_context
(
s
->
bsf
->
par_in
,
avctx
);
if
(
ret
<
0
)
return
ret
;
s
->
bsf
->
time_base_in
=
avctx
->
time_base
;
ret
=
av_bsf_init
(
s
->
bsf
);
if
(
ret
<
0
)
return
ret
;
return
ret
;
}
static
int
qsv_decode_frame
(
AVCodecContext
*
avctx
,
void
*
data
,
static
int
qsv_decode_frame
(
AVCodecContext
*
avctx
,
void
*
data
,
int
*
got_frame
,
AVPacket
*
avpkt
)
int
*
got_frame
,
AVPacket
*
avpkt
)
{
{
...
@@ -137,6 +154,11 @@ static int qsv_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -137,6 +154,11 @@ static int qsv_decode_frame(AVCodecContext *avctx, void *data,
AVFrame
*
frame
=
data
;
AVFrame
*
frame
=
data
;
int
ret
;
int
ret
;
/* make sure the bitstream filter is initialized */
ret
=
qsv_init_bsf
(
avctx
,
s
);
if
(
ret
<
0
)
return
ret
;
/* buffer the input packet */
/* buffer the input packet */
if
(
avpkt
->
size
)
{
if
(
avpkt
->
size
)
{
AVPacket
input_ref
=
{
0
};
AVPacket
input_ref
=
{
0
};
...
@@ -158,28 +180,26 @@ static int qsv_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -158,28 +180,26 @@ static int qsv_decode_frame(AVCodecContext *avctx, void *data,
while
(
!*
got_frame
)
{
while
(
!*
got_frame
)
{
/* prepare the input data -- convert to Annex B if needed */
/* prepare the input data -- convert to Annex B if needed */
if
(
s
->
pkt_filtered
.
size
<=
0
)
{
if
(
s
->
pkt_filtered
.
size
<=
0
)
{
int
size
;
AVPacket
input_ref
;
/* no more data */
/* no more data */
if
(
av_fifo_size
(
s
->
packet_fifo
)
<
sizeof
(
AVPacket
))
if
(
av_fifo_size
(
s
->
packet_fifo
)
<
sizeof
(
AVPacket
))
return
avpkt
->
size
?
avpkt
->
size
:
ff_qsv_process_data
(
avctx
,
&
s
->
qsv
,
frame
,
got_frame
,
avpkt
);
return
avpkt
->
size
?
avpkt
->
size
:
ff_qsv_process_data
(
avctx
,
&
s
->
qsv
,
frame
,
got_frame
,
avpkt
);
if
(
s
->
filtered_data
!=
s
->
input_ref
.
data
)
av_packet_unref
(
&
s
->
pkt_filtered
);
av_freep
(
&
s
->
filtered_data
);
s
->
filtered_data
=
NULL
;
av_packet_unref
(
&
s
->
input_ref
);
av_fifo_generic_read
(
s
->
packet_fifo
,
&
s
->
input_ref
,
sizeof
(
s
->
input_ref
),
NULL
);
av_fifo_generic_read
(
s
->
packet_fifo
,
&
input_ref
,
sizeof
(
input_ref
),
NULL
);
ret
=
av_bitstream_filter_filter
(
s
->
bsf
,
avctx
,
NULL
,
ret
=
av_bsf_send_packet
(
s
->
bsf
,
&
input_ref
);
&
s
->
filtered_data
,
&
size
,
s
->
input_ref
.
data
,
s
->
input_ref
.
size
,
0
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
s
->
filtered_data
=
s
->
input_ref
.
data
;
av_packet_unref
(
&
input_ref
)
;
size
=
s
->
input_ref
.
size
;
return
ret
;
}
}
s
->
pkt_filtered
=
s
->
input_ref
;
s
->
pkt_filtered
.
data
=
s
->
filtered_data
;
ret
=
av_bsf_receive_packet
(
s
->
bsf
,
&
s
->
pkt_filtered
);
s
->
pkt_filtered
.
size
=
size
;
if
(
ret
<
0
)
av_packet_move_ref
(
&
s
->
pkt_filtered
,
&
input_ref
);
else
av_packet_unref
(
&
input_ref
);
}
}
ret
=
ff_qsv_process_data
(
avctx
,
&
s
->
qsv
,
frame
,
got_frame
,
&
s
->
pkt_filtered
);
ret
=
ff_qsv_process_data
(
avctx
,
&
s
->
qsv
,
frame
,
got_frame
,
&
s
->
pkt_filtered
);
...
...
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