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
cfbebe9d
Commit
cfbebe9d
authored
May 09, 2017
by
Timo Rothenpieler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec/nvenc: deprecated old rc modes, add new ones
parent
ef390e34
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
31 deletions
+49
-31
nvenc.c
libavcodec/nvenc.c
+21
-11
nvenc.h
libavcodec/nvenc.h
+2
-0
nvenc_h264.c
libavcodec/nvenc_h264.c
+13
-10
nvenc_hevc.c
libavcodec/nvenc_hevc.c
+13
-10
No files found.
libavcodec/nvenc.c
View file @
cfbebe9d
...
...
@@ -32,9 +32,9 @@
#include "internal.h"
#define NVENC_CAP 0x30
#define IS_CBR(rc) (rc == NV_ENC_PARAMS_RC_CBR ||
\
rc == NV_ENC_PARAMS_RC_
2_PASS_QUALITY ||
\
rc == NV_ENC_PARAMS_RC_
2_PASS_FRAMESIZE_CAP
)
#define IS_CBR(rc) (rc == NV_ENC_PARAMS_RC_CBR || \
rc == NV_ENC_PARAMS_RC_
CBR_LOWDELAY_HQ ||
\
rc == NV_ENC_PARAMS_RC_
CBR_HQ
)
const
enum
AVPixelFormat
ff_nvenc_pix_fmts
[]
=
{
AV_PIX_FMT_YUV420P
,
...
...
@@ -633,13 +633,13 @@ static void nvenc_override_rate_control(AVCodecContext *avctx)
return
;
}
/* fall through */
case
NV_ENC_PARAMS_RC_
2_PASS_VBR
:
case
NV_ENC_PARAMS_RC_
VBR_HQ
:
case
NV_ENC_PARAMS_RC_VBR
:
set_vbr
(
avctx
);
break
;
case
NV_ENC_PARAMS_RC_CBR
:
case
NV_ENC_PARAMS_RC_
2_PASS_QUALITY
:
case
NV_ENC_PARAMS_RC_
2_PASS_FRAMESIZE_CAP
:
case
NV_ENC_PARAMS_RC_
CBR_HQ
:
case
NV_ENC_PARAMS_RC_
CBR_LOWDELAY_HQ
:
break
;
}
...
...
@@ -715,19 +715,29 @@ static av_cold void nvenc_setup_rate_control(AVCodecContext *avctx)
if
(
ctx
->
cbr
)
{
if
(
ctx
->
twopass
)
{
ctx
->
rc
=
NV_ENC_PARAMS_RC_
2_PASS_QUALITY
;
ctx
->
rc
=
NV_ENC_PARAMS_RC_
CBR_LOWDELAY_HQ
;
}
else
{
ctx
->
rc
=
NV_ENC_PARAMS_RC_CBR
;
}
}
else
if
(
ctx
->
cqp
>=
0
)
{
ctx
->
rc
=
NV_ENC_PARAMS_RC_CONSTQP
;
}
else
if
(
ctx
->
twopass
)
{
ctx
->
rc
=
NV_ENC_PARAMS_RC_
2_PASS_VBR
;
ctx
->
rc
=
NV_ENC_PARAMS_RC_
VBR_HQ
;
}
else
if
(
avctx
->
qmin
>=
0
&&
avctx
->
qmax
>=
0
)
{
ctx
->
rc
=
NV_ENC_PARAMS_RC_VBR_MINQP
;
}
}
if
(
ctx
->
rc
>=
0
&&
ctx
->
rc
&
RC_MODE_DEPRECATED
)
{
av_log
(
avctx
,
AV_LOG_WARNING
,
"Specified rc mode is deprecated.
\n
"
);
av_log
(
avctx
,
AV_LOG_WARNING
,
"
\t
ll_2pass_quality -> cbr_ld_hq
\n
"
);
av_log
(
avctx
,
AV_LOG_WARNING
,
"
\t
ll_2pass_size -> cbr_hq
\n
"
);
av_log
(
avctx
,
AV_LOG_WARNING
,
"
\t
vbr_2pass -> vbr_hq
\n
"
);
av_log
(
avctx
,
AV_LOG_WARNING
,
"
\t
vbr_minqp -> (no replacement)
\n
"
);
ctx
->
rc
&=
~
RC_MODE_DEPRECATED
;
}
if
(
ctx
->
flags
&
NVENC_LOSSLESS
)
{
set_lossless
(
avctx
);
}
else
if
(
ctx
->
rc
>=
0
)
{
...
...
@@ -830,9 +840,9 @@ static av_cold int nvenc_setup_h264_config(AVCodecContext *avctx)
h264
->
outputPictureTimingSEI
=
1
;
}
if
(
cc
->
rcParams
.
rateControlMode
==
NV_ENC_PARAMS_RC_
2_PASS_QUALITY
||
cc
->
rcParams
.
rateControlMode
==
NV_ENC_PARAMS_RC_
2_PASS_FRAMESIZE_CAP
||
cc
->
rcParams
.
rateControlMode
==
NV_ENC_PARAMS_RC_
2_PASS_VBR
)
{
if
(
cc
->
rcParams
.
rateControlMode
==
NV_ENC_PARAMS_RC_
CBR_LOWDELAY_HQ
||
cc
->
rcParams
.
rateControlMode
==
NV_ENC_PARAMS_RC_
CBR_HQ
||
cc
->
rcParams
.
rateControlMode
==
NV_ENC_PARAMS_RC_
VBR_HQ
)
{
h264
->
adaptiveTransformMode
=
NV_ENC_H264_ADAPTIVE_TRANSFORM_ENABLE
;
h264
->
fmoMode
=
NV_ENC_H264_FMO_DISABLE
;
}
...
...
libavcodec/nvenc.h
View file @
cfbebe9d
...
...
@@ -30,6 +30,8 @@
#include "avcodec.h"
#define MAX_REGISTERED_FRAMES 64
#define RC_MODE_DEPRECATED 0x800000
#define RCD(rc_mode) ((rc_mode) | RC_MODE_DEPRECATED)
typedef
struct
NvencSurface
{
...
...
libavcodec/nvenc_h264.c
View file @
cfbebe9d
...
...
@@ -68,16 +68,19 @@ static const AVOption options[] = {
{
"5"
,
""
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
NV_ENC_LEVEL_H264_5
},
0
,
0
,
VE
,
"level"
},
{
"5.0"
,
""
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
NV_ENC_LEVEL_H264_5
},
0
,
0
,
VE
,
"level"
},
{
"5.1"
,
""
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
NV_ENC_LEVEL_H264_51
},
0
,
0
,
VE
,
"level"
},
{
"rc"
,
"Override the preset rate-control"
,
OFFSET
(
rc
),
AV_OPT_TYPE_INT
,
{
.
i64
=
-
1
},
-
1
,
INT_MAX
,
VE
,
"rc"
},
{
"constqp"
,
"Constant QP mode"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
NV_ENC_PARAMS_RC_CONSTQP
},
0
,
0
,
VE
,
"rc"
},
{
"vbr"
,
"Variable bitrate mode"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
NV_ENC_PARAMS_RC_VBR
},
0
,
0
,
VE
,
"rc"
},
{
"cbr"
,
"Constant bitrate mode"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
NV_ENC_PARAMS_RC_CBR
},
0
,
0
,
VE
,
"rc"
},
{
"vbr_minqp"
,
"Variable bitrate mode with MinQP"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
NV_ENC_PARAMS_RC_VBR_MINQP
},
0
,
0
,
VE
,
"rc"
},
{
"ll_2pass_quality"
,
"Multi-pass optimized for image quality (only for low-latency presets)"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
NV_ENC_PARAMS_RC_2_PASS_QUALITY
},
0
,
0
,
VE
,
"rc"
},
{
"ll_2pass_size"
,
"Multi-pass optimized for constant frame size (only for low-latency presets)"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
NV_ENC_PARAMS_RC_2_PASS_FRAMESIZE_CAP
},
0
,
0
,
VE
,
"rc"
},
{
"vbr_2pass"
,
"Multi-pass variable bitrate mode"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
NV_ENC_PARAMS_RC_2_PASS_VBR
},
0
,
0
,
VE
,
"rc"
},
{
"rc"
,
"Override the preset rate-control"
,
OFFSET
(
rc
),
AV_OPT_TYPE_INT
,
{
.
i64
=
-
1
},
-
1
,
INT_MAX
,
VE
,
"rc"
},
{
"constqp"
,
"Constant QP mode"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
NV_ENC_PARAMS_RC_CONSTQP
},
0
,
0
,
VE
,
"rc"
},
{
"vbr"
,
"Variable bitrate mode"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
NV_ENC_PARAMS_RC_VBR
},
0
,
0
,
VE
,
"rc"
},
{
"cbr"
,
"Constant bitrate mode"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
NV_ENC_PARAMS_RC_CBR
},
0
,
0
,
VE
,
"rc"
},
{
"vbr_minqp"
,
"Variable bitrate mode with MinQP (deprecated)"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
RCD
(
NV_ENC_PARAMS_RC_VBR_MINQP
)
},
0
,
0
,
VE
,
"rc"
},
{
"ll_2pass_quality"
,
"Multi-pass optimized for image quality (deprecated)"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
RCD
(
NV_ENC_PARAMS_RC_2_PASS_QUALITY
)
},
0
,
0
,
VE
,
"rc"
},
{
"ll_2pass_size"
,
"Multi-pass optimized for constant frame size (deprecated)"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
RCD
(
NV_ENC_PARAMS_RC_2_PASS_FRAMESIZE_CAP
)
},
0
,
0
,
VE
,
"rc"
},
{
"vbr_2pass"
,
"Multi-pass variable bitrate mode (deprecated)"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
RCD
(
NV_ENC_PARAMS_RC_2_PASS_VBR
)
},
0
,
0
,
VE
,
"rc"
},
{
"cbr_ld_hq"
,
"Constant bitrate low delay high quality mode"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ
},
0
,
0
,
VE
,
"rc"
},
{
"cbr_hq"
,
"Constant bitrate high quality mode"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
NV_ENC_PARAMS_RC_CBR_HQ
},
0
,
0
,
VE
,
"rc"
},
{
"vbr_hq"
,
"Variable bitrate high quality mode"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
NV_ENC_PARAMS_RC_VBR_HQ
},
0
,
0
,
VE
,
"rc"
},
{
"rc-lookahead"
,
"Number of frames to look ahead for rate-control"
,
OFFSET
(
rc_lookahead
),
AV_OPT_TYPE_INT
,
{
.
i64
=
0
},
0
,
INT_MAX
,
VE
},
{
"surfaces"
,
"Number of concurrent surfaces"
,
OFFSET
(
nb_surfaces
),
AV_OPT_TYPE_INT
,
{
.
i64
=
0
},
0
,
MAX_REGISTERED_FRAMES
,
VE
},
...
...
libavcodec/nvenc_hevc.c
View file @
cfbebe9d
...
...
@@ -67,16 +67,19 @@ static const AVOption options[] = {
{
"tier"
,
"Set the encoding tier"
,
OFFSET
(
tier
),
AV_OPT_TYPE_INT
,
{
.
i64
=
NV_ENC_TIER_HEVC_MAIN
},
NV_ENC_TIER_HEVC_MAIN
,
NV_ENC_TIER_HEVC_HIGH
,
VE
,
"tier"
},
{
"main"
,
""
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
NV_ENC_TIER_HEVC_MAIN
},
0
,
0
,
VE
,
"tier"
},
{
"high"
,
""
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
NV_ENC_TIER_HEVC_HIGH
},
0
,
0
,
VE
,
"tier"
},
{
"rc"
,
"Override the preset rate-control"
,
OFFSET
(
rc
),
AV_OPT_TYPE_INT
,
{
.
i64
=
-
1
},
-
1
,
INT_MAX
,
VE
,
"rc"
},
{
"constqp"
,
"Constant QP mode"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
NV_ENC_PARAMS_RC_CONSTQP
},
0
,
0
,
VE
,
"rc"
},
{
"vbr"
,
"Variable bitrate mode"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
NV_ENC_PARAMS_RC_VBR
},
0
,
0
,
VE
,
"rc"
},
{
"cbr"
,
"Constant bitrate mode"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
NV_ENC_PARAMS_RC_CBR
},
0
,
0
,
VE
,
"rc"
},
{
"vbr_minqp"
,
"Variable bitrate mode with MinQP"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
NV_ENC_PARAMS_RC_VBR_MINQP
},
0
,
0
,
VE
,
"rc"
},
{
"ll_2pass_quality"
,
"Multi-pass optimized for image quality (only for low-latency presets)"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
NV_ENC_PARAMS_RC_2_PASS_QUALITY
},
0
,
0
,
VE
,
"rc"
},
{
"ll_2pass_size"
,
"Multi-pass optimized for constant frame size (only for low-latency presets)"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
NV_ENC_PARAMS_RC_2_PASS_FRAMESIZE_CAP
},
0
,
0
,
VE
,
"rc"
},
{
"vbr_2pass"
,
"Multi-pass variable bitrate mode"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
NV_ENC_PARAMS_RC_2_PASS_VBR
},
0
,
0
,
VE
,
"rc"
},
{
"rc"
,
"Override the preset rate-control"
,
OFFSET
(
rc
),
AV_OPT_TYPE_INT
,
{
.
i64
=
-
1
},
-
1
,
INT_MAX
,
VE
,
"rc"
},
{
"constqp"
,
"Constant QP mode"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
NV_ENC_PARAMS_RC_CONSTQP
},
0
,
0
,
VE
,
"rc"
},
{
"vbr"
,
"Variable bitrate mode"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
NV_ENC_PARAMS_RC_VBR
},
0
,
0
,
VE
,
"rc"
},
{
"cbr"
,
"Constant bitrate mode"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
NV_ENC_PARAMS_RC_CBR
},
0
,
0
,
VE
,
"rc"
},
{
"vbr_minqp"
,
"Variable bitrate mode with MinQP (deprecated)"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
RCD
(
NV_ENC_PARAMS_RC_VBR_MINQP
)
},
0
,
0
,
VE
,
"rc"
},
{
"ll_2pass_quality"
,
"Multi-pass optimized for image quality (deprecated)"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
RCD
(
NV_ENC_PARAMS_RC_2_PASS_QUALITY
)
},
0
,
0
,
VE
,
"rc"
},
{
"ll_2pass_size"
,
"Multi-pass optimized for constant frame size (deprecated)"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
RCD
(
NV_ENC_PARAMS_RC_2_PASS_FRAMESIZE_CAP
)
},
0
,
0
,
VE
,
"rc"
},
{
"vbr_2pass"
,
"Multi-pass variable bitrate mode (deprecated)"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
RCD
(
NV_ENC_PARAMS_RC_2_PASS_VBR
)
},
0
,
0
,
VE
,
"rc"
},
{
"cbr_ld_hq"
,
"Constant bitrate low delay high quality mode"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ
},
0
,
0
,
VE
,
"rc"
},
{
"cbr_hq"
,
"Constant bitrate high quality mode"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
NV_ENC_PARAMS_RC_CBR_HQ
},
0
,
0
,
VE
,
"rc"
},
{
"vbr_hq"
,
"Variable bitrate high quality mode"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
NV_ENC_PARAMS_RC_VBR_HQ
},
0
,
0
,
VE
,
"rc"
},
{
"rc-lookahead"
,
"Number of frames to look ahead for rate-control"
,
OFFSET
(
rc_lookahead
),
AV_OPT_TYPE_INT
,
{
.
i64
=
0
},
0
,
INT_MAX
,
VE
},
{
"surfaces"
,
"Number of concurrent surfaces"
,
OFFSET
(
nb_surfaces
),
AV_OPT_TYPE_INT
,
{
.
i64
=
0
},
0
,
MAX_REGISTERED_FRAMES
,
VE
},
...
...
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