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
3c53627a
Commit
3c53627a
authored
Feb 22, 2016
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
qsvdec: store the sync point in heap memory
The reasoning is the same as for the corresponding qsvenc patch.
parent
a1335149
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
6 deletions
+28
-6
qsvdec.c
libavcodec/qsvdec.c
+28
-6
No files found.
libavcodec/qsvdec.c
View file @
3c53627a
...
...
@@ -77,7 +77,7 @@ static int qsv_decode_init(AVCodecContext *avctx, QSVContext *q, mfxSession sess
if
(
!
q
->
async_fifo
)
{
q
->
async_fifo
=
av_fifo_alloc
((
1
+
q
->
async_depth
)
*
(
sizeof
(
mfxSyncPoint
)
+
sizeof
(
QSVFrame
*
)));
(
sizeof
(
mfxSyncPoint
*
)
+
sizeof
(
QSVFrame
*
)));
if
(
!
q
->
async_fifo
)
return
AVERROR
(
ENOMEM
);
}
...
...
@@ -218,7 +218,7 @@ static int qsv_decode(AVCodecContext *avctx, QSVContext *q,
QSVFrame
*
out_frame
;
mfxFrameSurface1
*
insurf
;
mfxFrameSurface1
*
outsurf
;
mfxSyncPoint
sync
;
mfxSyncPoint
*
sync
;
mfxBitstream
bs
=
{
{
{
0
}
}
};
int
ret
;
...
...
@@ -229,13 +229,19 @@ static int qsv_decode(AVCodecContext *avctx, QSVContext *q,
bs
.
TimeStamp
=
avpkt
->
pts
;
}
sync
=
av_mallocz
(
sizeof
(
*
sync
));
if
(
!
sync
)
{
av_freep
(
&
sync
);
return
AVERROR
(
ENOMEM
);
}
do
{
ret
=
get_surface
(
avctx
,
q
,
&
insurf
);
if
(
ret
<
0
)
return
ret
;
ret
=
MFXVideoDECODE_DecodeFrameAsync
(
q
->
session
,
avpkt
->
size
?
&
bs
:
NULL
,
insurf
,
&
outsurf
,
&
sync
);
insurf
,
&
outsurf
,
sync
);
if
(
ret
==
MFX_WRN_DEVICE_BUSY
)
av_usleep
(
1
);
...
...
@@ -246,28 +252,32 @@ static int qsv_decode(AVCodecContext *avctx, QSVContext *q,
ret
!=
MFX_WRN_VIDEO_PARAM_CHANGED
&&
ret
!=
MFX_ERR_MORE_SURFACE
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Error during QSV decoding.
\n
"
);
av_freep
(
&
sync
);
return
ff_qsv_error
(
ret
);
}
/* make sure we do not enter an infinite loop if the SDK
* did not consume any data and did not return anything */
if
(
!
sync
&&
!
bs
.
DataOffset
)
{
if
(
!
*
sync
&&
!
bs
.
DataOffset
)
{
av_log
(
avctx
,
AV_LOG_WARNING
,
"A decode call did not consume any data
\n
"
);
bs
.
DataOffset
=
avpkt
->
size
;
}
if
(
sync
)
{
if
(
*
sync
)
{
QSVFrame
*
out_frame
=
find_frame
(
q
,
outsurf
);
if
(
!
out_frame
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"The returned surface does not correspond to any frame
\n
"
);
av_freep
(
&
sync
);
return
AVERROR_BUG
;
}
out_frame
->
queued
=
1
;
av_fifo_generic_write
(
q
->
async_fifo
,
&
out_frame
,
sizeof
(
out_frame
),
NULL
);
av_fifo_generic_write
(
q
->
async_fifo
,
&
sync
,
sizeof
(
sync
),
NULL
);
}
else
{
av_freep
(
&
sync
);
}
if
(
!
av_fifo_space
(
q
->
async_fifo
)
||
...
...
@@ -279,9 +289,11 @@ static int qsv_decode(AVCodecContext *avctx, QSVContext *q,
out_frame
->
queued
=
0
;
do
{
ret
=
MFXVideoCORE_SyncOperation
(
q
->
session
,
sync
,
1000
);
ret
=
MFXVideoCORE_SyncOperation
(
q
->
session
,
*
sync
,
1000
);
}
while
(
ret
==
MFX_WRN_IN_EXECUTION
);
av_freep
(
&
sync
);
src_frame
=
out_frame
->
frame
;
ret
=
av_frame_ref
(
frame
,
src_frame
);
...
...
@@ -314,6 +326,16 @@ int ff_qsv_decode_close(QSVContext *q)
if
(
q
->
session
)
MFXVideoDECODE_Close
(
q
->
session
);
while
(
q
->
async_fifo
&&
av_fifo_size
(
q
->
async_fifo
))
{
QSVFrame
*
out_frame
;
mfxSyncPoint
*
sync
;
av_fifo_generic_read
(
q
->
async_fifo
,
&
out_frame
,
sizeof
(
out_frame
),
NULL
);
av_fifo_generic_read
(
q
->
async_fifo
,
&
sync
,
sizeof
(
sync
),
NULL
);
av_freep
(
&
sync
);
}
while
(
cur
)
{
q
->
work_frames
=
cur
->
next
;
av_frame_free
(
&
cur
->
frame
);
...
...
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