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
48e52e4e
Commit
48e52e4e
authored
Jan 28, 2018
by
Timo Rothenpieler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec/nvenc: add some more error case checks
Signed-off-by:
Timo Rothenpieler
<
timo@rothenpieler.org
>
parent
32bc4e77
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
6 deletions
+18
-6
nvenc.c
libavcodec/nvenc.c
+18
-6
No files found.
libavcodec/nvenc.c
View file @
48e52e4e
...
...
@@ -1529,6 +1529,7 @@ static int nvenc_find_free_reg_resource(AVCodecContext *avctx)
NvencContext
*
ctx
=
avctx
->
priv_data
;
NvencDynLoadFunctions
*
dl_fn
=
&
ctx
->
nvenc_dload_funcs
;
NV_ENCODE_API_FUNCTION_LIST
*
p_nvenc
=
&
dl_fn
->
nvenc_funcs
;
NVENCSTATUS
nv_status
;
int
i
;
...
...
@@ -1536,8 +1537,9 @@ static int nvenc_find_free_reg_resource(AVCodecContext *avctx)
for
(
i
=
0
;
i
<
ctx
->
nb_registered_frames
;
i
++
)
{
if
(
!
ctx
->
registered_frames
[
i
].
mapped
)
{
if
(
ctx
->
registered_frames
[
i
].
regptr
)
{
p_nvenc
->
nvEncUnregisterResource
(
ctx
->
nvencoder
,
ctx
->
registered_frames
[
i
].
regptr
);
nv_status
=
p_nvenc
->
nvEncUnregisterResource
(
ctx
->
nvencoder
,
ctx
->
registered_frames
[
i
].
regptr
);
if
(
nv_status
!=
NV_ENC_SUCCESS
)
return
nvenc_print_error
(
avctx
,
nv_status
,
"Failed unregistering unused input resource"
);
ctx
->
registered_frames
[
i
].
regptr
=
NULL
;
}
return
i
;
...
...
@@ -1789,15 +1791,25 @@ static int process_output_surface(AVCodecContext *avctx, AVPacket *pkt, NvencSur
memcpy
(
pkt
->
data
,
lock_params
.
bitstreamBufferPtr
,
lock_params
.
bitstreamSizeInBytes
);
nv_status
=
p_nvenc
->
nvEncUnlockBitstream
(
ctx
->
nvencoder
,
tmpoutsurf
->
output_surface
);
if
(
nv_status
!=
NV_ENC_SUCCESS
)
nvenc_print_error
(
avctx
,
nv_status
,
"Failed unlocking bitstream buffer, expect the gates of mordor to open"
);
if
(
nv_status
!=
NV_ENC_SUCCESS
)
{
res
=
nvenc_print_error
(
avctx
,
nv_status
,
"Failed unlocking bitstream buffer, expect the gates of mordor to open"
);
goto
error
;
}
if
(
avctx
->
pix_fmt
==
AV_PIX_FMT_CUDA
||
avctx
->
pix_fmt
==
AV_PIX_FMT_D3D11
)
{
ctx
->
registered_frames
[
tmpoutsurf
->
reg_idx
].
mapped
-=
1
;
if
(
ctx
->
registered_frames
[
tmpoutsurf
->
reg_idx
].
mapped
==
0
)
{
p_nvenc
->
nvEncUnmapInputResource
(
ctx
->
nvencoder
,
ctx
->
registered_frames
[
tmpoutsurf
->
reg_idx
].
in_map
.
mappedResource
);
p_nvenc
->
nvEncUnregisterResource
(
ctx
->
nvencoder
,
ctx
->
registered_frames
[
tmpoutsurf
->
reg_idx
].
regptr
);
nv_status
=
p_nvenc
->
nvEncUnmapInputResource
(
ctx
->
nvencoder
,
ctx
->
registered_frames
[
tmpoutsurf
->
reg_idx
].
in_map
.
mappedResource
);
if
(
nv_status
!=
NV_ENC_SUCCESS
)
{
res
=
nvenc_print_error
(
avctx
,
nv_status
,
"Failed unmapping input resource"
);
goto
error
;
}
nv_status
=
p_nvenc
->
nvEncUnregisterResource
(
ctx
->
nvencoder
,
ctx
->
registered_frames
[
tmpoutsurf
->
reg_idx
].
regptr
);
if
(
nv_status
!=
NV_ENC_SUCCESS
)
{
res
=
nvenc_print_error
(
avctx
,
nv_status
,
"Failed unregistering input resource"
);
goto
error
;
}
ctx
->
registered_frames
[
tmpoutsurf
->
reg_idx
].
regptr
=
NULL
;
}
else
if
(
ctx
->
registered_frames
[
tmpoutsurf
->
reg_idx
].
mapped
<
0
)
{
res
=
AVERROR_BUG
;
...
...
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