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
a1e215ea
Commit
a1e215ea
authored
Jul 25, 2015
by
Timo Rothenpieler
Committed by
Anton Khirnov
May 19, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nvenc: Delay frame output to increase encoding speed
Signed-off-by:
Anton Khirnov
<
anton@khirnov.net
>
parent
9427d92f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
1 deletion
+14
-1
nvenc.c
libavcodec/nvenc.c
+9
-1
nvenc.h
libavcodec/nvenc.h
+1
-0
nvenc_h264.c
libavcodec/nvenc_h264.c
+2
-0
nvenc_hevc.c
libavcodec/nvenc_hevc.c
+2
-0
No files found.
libavcodec/nvenc.c
View file @
a1e215ea
...
...
@@ -840,6 +840,8 @@ static int nvenc_setup_surfaces(AVCodecContext *avctx)
ctx
->
nb_surfaces
=
FFMAX
(
4
+
avctx
->
max_b_frames
,
ctx
->
nb_surfaces
);
ctx
->
async_depth
=
FFMIN
(
ctx
->
async_depth
,
ctx
->
nb_surfaces
-
1
);
ctx
->
frames
=
av_mallocz_array
(
ctx
->
nb_surfaces
,
sizeof
(
*
ctx
->
frames
));
if
(
!
ctx
->
frames
)
...
...
@@ -1301,13 +1303,19 @@ FF_ENABLE_DEPRECATION_WARNINGS
static
int
output_ready
(
AVCodecContext
*
avctx
,
int
flush
)
{
NVENCContext
*
ctx
=
avctx
->
priv_data
;
int
nb_ready
,
nb_pending
;
/* when B-frames are enabled, we wait for two initial timestamps to
* calculate the first dts */
if
(
!
flush
&&
avctx
->
max_b_frames
>
0
&&
(
ctx
->
initial_pts
[
0
]
==
AV_NOPTS_VALUE
||
ctx
->
initial_pts
[
1
]
==
AV_NOPTS_VALUE
))
return
0
;
return
av_fifo_size
(
ctx
->
ready
)
>
0
;
nb_ready
=
av_fifo_size
(
ctx
->
ready
)
/
sizeof
(
NVENCFrame
*
);
nb_pending
=
av_fifo_size
(
ctx
->
pending
)
/
sizeof
(
NVENCFrame
*
);
if
(
flush
)
return
nb_ready
>
0
;
return
(
nb_ready
>
0
)
&&
(
nb_ready
+
nb_pending
>=
ctx
->
async_depth
);
}
int
ff_nvenc_encode_frame
(
AVCodecContext
*
avctx
,
AVPacket
*
pkt
,
...
...
libavcodec/nvenc.h
View file @
a1e215ea
...
...
@@ -142,6 +142,7 @@ typedef struct NVENCContext {
int
rc
;
int
device
;
int
flags
;
int
async_depth
;
}
NVENCContext
;
int
ff_nvenc_encode_init
(
AVCodecContext
*
avctx
);
...
...
libavcodec/nvenc_h264.c
View file @
a1e215ea
...
...
@@ -72,6 +72,8 @@ static const AVOption options[] = {
{
"device"
,
"Select a specific NVENC device"
,
OFFSET
(
device
),
AV_OPT_TYPE_INT
,
{
.
i64
=
-
1
},
-
2
,
INT_MAX
,
VE
,
"device"
},
{
"any"
,
"Pick the first device available"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
ANY_DEVICE
},
0
,
0
,
VE
,
"device"
},
{
"list"
,
"List the available devices"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
LIST_DEVICES
},
0
,
0
,
VE
,
"device"
},
{
"async_depth"
,
"Delay frame output by the given amount of frames"
,
OFFSET
(
async_depth
),
AV_OPT_TYPE_INT
,
{
.
i64
=
INT_MAX
},
0
,
INT_MAX
,
VE
},
{
"delay"
,
"Delay frame output by the given amount of frames"
,
OFFSET
(
async_depth
),
AV_OPT_TYPE_INT
,
{
.
i64
=
INT_MAX
},
0
,
INT_MAX
,
VE
},
{
NULL
}
};
...
...
libavcodec/nvenc_hevc.c
View file @
a1e215ea
...
...
@@ -68,6 +68,8 @@ static const AVOption options[] = {
{
"device"
,
"Select a specific NVENC device"
,
OFFSET
(
device
),
AV_OPT_TYPE_INT
,
{
.
i64
=
-
1
},
-
2
,
INT_MAX
,
VE
,
"device"
},
{
"any"
,
"Pick the first device available"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
ANY_DEVICE
},
0
,
0
,
VE
,
"device"
},
{
"list"
,
"List the available devices"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
LIST_DEVICES
},
0
,
0
,
VE
,
"device"
},
{
"async_depth"
,
"Delay frame output by the given amount of frames"
,
OFFSET
(
async_depth
),
AV_OPT_TYPE_INT
,
{
.
i64
=
INT_MAX
},
0
,
INT_MAX
,
VE
},
{
"delay"
,
"Delay frame output by the given amount of frames"
,
OFFSET
(
async_depth
),
AV_OPT_TYPE_INT
,
{
.
i64
=
INT_MAX
},
0
,
INT_MAX
,
VE
},
{
NULL
}
};
...
...
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