1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-07 11:13:41 +02:00
Commit Graph

135 Commits

Author SHA1 Message Date
Ben Chang
8de3458a07 avcodec/nvenc: surface allocation reduction
This patch aims to reduce the number of input/output surfaces
NVENC allocates per session. Previous default sets allocated surfaces to 32
(unless there is user specified param or lookahead involved). Having large
number of surfaces consumes extra video memory (esp for higher resolution
encoding). The patch changes the surfaces calculation for default, B-frames,
lookahead scenario respectively.

The other change involves surface selection. Previously, if a session
allocates x surfaces, only x-1 surfaces are used (due to combination
of output delay and lock toggle logic). To prevent unused surfaces,
changing surface rotation to using predefined fifo.

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2017-04-26 21:57:54 +02:00
Timo Rothenpieler
d84c2298e2 avcodec/nvenc: apply quantization factors to cqp 2017-03-23 17:10:52 +01:00
Timo Rothenpieler
7fb2a7afa1 avcodec/nvenc: Deprecate usage of global_quality, introducing qp 2017-03-23 17:10:52 +01:00
Clément Bœsch
b7cc4eb303 lavc/nvenc: misc cosmetics to reduce diff with Libav 2017-03-20 23:04:28 +01:00
Konda Raju
2db5ab73d4 avcodec/nvenc: allow different const-qps for I, P and B frames
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2017-03-17 10:42:55 +01:00
Konda Raju
5f44a4a0a9 avcodec/nvenc: add initial QP value options
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2017-03-01 13:15:34 +01:00
Ganapathy Raman Kasi
a549243b89 avcodec/nvenc: remove qmin and qmax constraints for vbr
qmin and qmax are not necessary for nvenc vbr.
Enforcing this constraint, doesn't allow user to use vbr 2 pass mode without explicity setting the qmin and qmax options

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2017-03-01 12:20:54 +01:00
Timo Rothenpieler
be74ba648c avcodec/nvenc: push cuda context before encoding a frame
Thanks to Miroslav Slugeň for figuring out what was going on here.
2017-02-14 11:24:13 +01:00
Timo Rothenpieler
8a3fea14ae avcodec/nvenc: set frame buffer format for mapped frames 2017-02-13 11:30:52 +01:00
Timo Rothenpieler
6b0a3ee6f8 avcodec/nvenc: add logging for more error cases 2017-01-20 10:29:36 +01:00
Timo Rothenpieler
5403d90f32 avcodec/nvenc: make gpu indices independend of supported capabilities 2017-01-20 10:29:36 +01:00
Miroslav Slugen
9b425bd24c avcodec/nvenc: Add bluray_compat basic implementation
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2017-01-01 14:47:25 +01:00
Miroslav Slugen
1841eda679 avcodec/nvenc: Make AUD optional for h264_nvenc and hevc_nvenc
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2017-01-01 14:37:09 +01:00
Miroslav Slugeň
f8c503d927 avcodec/nvenc: round qpIntra and qpInter calculation
Round qpIntra and qpInter calculation instead of old floor behavior.

Adopted from vaapi_encode_h264.c

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2017-01-01 14:34:42 +01:00
Ruta Gadkari
67db4ff3b6 NVENC: Update check for Lookahead
Reviewed-by: Timo Rothenpieler <timo@rothenpieler.org>
2016-12-26 12:13:39 -03:00
Timo Rothenpieler
c2f3af57a5 avcodec/nvenc: mark intentional fall through 2016-11-30 12:36:23 +01:00
Miroslav Slugeň
f2dd6aee80 avcodec/nvenc: always reduce DAR width and height
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2016-11-30 12:36:23 +01:00
Philip Langdale
27038693bb avcodec/nvenc: Delay identification of underlying format of cuda frames
When input surfaces are cuda frames, we will not know what the actual
underlying format (nv12, p010, etc) is at surface allocation time.

On the other hand, we will know when the input frames are actually
registered and associated with a surface.

So, let's delay format discovery until registration time, which is
actually how we handle other frame properties, such as dimensions.

By itself, this change doesn't allow for transcoding of 10bit
content from cuvid, but it reduces the problem to the hardcoding of
the sw format in ffmpeg_cuvid.c

Signed-off-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2016-11-30 12:36:23 +01:00
Philip Langdale
829db8effd avcodec/nvenc: Remove aspect-ratio decompensation logic
This dubious behaviour in nvenc was finally removed by nvidia, and
as we refuse to run on anything older than 7.0, we don't need to
keep it around for old versions.
2016-11-25 10:13:58 -08:00
Miroslav Slugeň
de2faec2fa avcodec/nvenc: better surface allocation alghoritm, fix rc_lookahead
User selectable surfaces are not working correctly, if you set number of
surfaces on cmdline, it will always use minimum 32 or 48 depends on
selected resolution, but in nvenc it is not necessary to use so many
surfaces.

So from now you can define as low as 1 surface and nvenc will still
work, it will ofcourse lower GPU memory usage by 95% and async_delay to zero

That was the easy part, now littlebit more...

Next part of this patch is to always prefer rc_lookahead to be more
important for number of surfaces, than user defined surfaces value.
Maximum rc_lookahead from nvidia documentation is 32, but could increase
in future generations so there is no limit for this yet. Value
async_depth is still accepted and prefered over rc_lookahead.

There were also bug when you request more than rc_lookahead > 31, it
will always set maximum 31, because surface numbers recalculation was
after setting lookahead, which is now fixed.

Results:
If you set -rc_lookahead 32 and -bf 3 it will now use only 40 surfaces
and lower GPU memory usage by 20%, also it will now increase PSNR by 0.012dB

Two more comments:

1. from my internal test, i don't understand addition of 4 more surfaces
when lookahead is calculated, i didn't used this and everything works as
with those 4 more extra surfaces, does anybody know what is going on
there? I looks like it was used for B frames which are calculated
separately, because B frames maximum is 4.

2. rc_lookahead is defined default to -1, but in test condition if
(ctx->rc_lookahead) which sets lookahead it will be always true, i don't
know if this is intended behavior, so in default behavior is lookahead
always on!

This is default condition when rc_lokkahead is -1 (not defined on
cmdline), whis is maybe something that is not intended:
ctx->encode_config.rcParams.enableLookahead = 1;
ctx->encode_config.rcParams.lookaheadDepth  = 0;
ctx->encode_config.rcParams.disableIadapt   = 0;
ctx->encode_config.rcParams.disableBadapt   = 0;

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2016-11-22 10:34:27 +01:00
Timo Rothenpieler
a66835bcb1 avcodec/nvenc: use dynamically loaded CUDA 2016-11-22 10:34:27 +01:00
Matt Oliver
6ead033bca avcodec/nvenc.c: Use new safe dlopen code.
Signed-off-by: Matt Oliver <protogonoi@gmail.com>
2016-11-05 18:09:03 +11:00
Sven C. Dack
da4d0fa86b avcodec/nvenc: add test for Temporal AQ support
Adds a check to see if the hardware supports temporal aq.

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2016-10-19 12:41:41 +02:00
Timo Rothenpieler
30c5587503 avcodec/nvenc: add support for forcing intra/idr frames 2016-10-12 20:51:43 +02:00
Yogender Gupta
facc19ef06 avcodec/nvenc: Extended rate-control support as provided by SDK 7
Merged from libav commit by Yogender Gupta:
https://git.libav.org/?p=libav.git;a=commitdiff;h=70de2ea4261f860457a04e3d0c58c5543f403325
2016-09-28 16:48:43 +02:00
Timo Rothenpieler
033f98c902 avcodec/nvenc: add HEVC REXT profile 2016-09-28 16:48:43 +02:00
Timo Rothenpieler
a81b000a39 avcodec/nvenc: Make sure that enum and array index match
Based on libav commits by Luca Barbato and Yogender Gupta:
https://git.libav.org/?p=libav.git;a=commit;h=352741b5ead1543d775ccf6040f33023e4491186
https://git.libav.org/?p=libav.git;a=commit;h=e02e2515b24bfc37ede6ca1744696230be55e50b
2016-09-28 16:48:43 +02:00
James Almer
dc48248ea8 avcodec/nvenc: use AVERROR_BUFFER_TOO_SMALL instead of ENOBUFS
Should fix compilation with mingw32

Reviewed-by: Timo Rothenpieler <timo@rothenpieler.org>
Signed-off-by: James Almer <jamrial@gmail.com>
2016-09-24 15:48:30 -03:00
Timo Rothenpieler
8ebe1dddfb avcodec/nvenc: use frame size instead of surface size 2016-09-08 19:08:31 +02:00
Sven C. Dack
4aeb7a88ec avcodec/nvenc: support RGB input
nvenc still encodes as yuv, but does the conversion internally which
brings some performance gains.

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2016-09-07 18:44:10 +02:00
Timo Rothenpieler
fa3ecad071 avcodec/nvenc: correctly set inputPitch 2016-09-07 18:44:10 +02:00
Timo Rothenpieler
96cba1c552 avcodec/nvenc: use av_image_copy for copying frame data 2016-09-07 18:44:10 +02:00
Timo Rothenpieler
cac2df230e avcodec/nvenc: update license header 2016-08-28 19:51:22 +02:00
Timo Rothenpieler
26a5cbd781 avcodec/nvenc: use proper soname for cuda/nvenc libraries 2016-08-28 19:49:56 +02:00
Timo Rothenpieler
df615efcf2 avcodec/nvenc: check maximum driver API version 2016-08-28 19:46:44 +02:00
Timo Rothenpieler
a19989cae5 avcodec/nvenc: fix potantially uninitialized free 2016-08-28 18:58:05 +02:00
Timo Rothenpieler
19e75fd883 avcodec/nvenc: fix library names on cygwin 2016-08-28 18:58:05 +02:00
Oliver Collyer
a81b398e86 avcodec/nvenc: added support for rate control lookahead
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2016-08-28 16:47:54 +02:00
Oliver Collyer
d1bf8a3aa8 avcodec/nvenc: added support for 10 bit HEVC encoding
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2016-08-28 16:47:54 +02:00
Clément Bœsch
8ef57a0d61 Merge commit '41ed7ab45fc693f7d7fc35664c0233f4c32d69bb'
* commit '41ed7ab45fc693f7d7fc35664c0233f4c32d69bb':
  cosmetics: Fix spelling mistakes

Merged-by: Clément Bœsch <u@pkh.me>
2016-06-21 21:55:34 +02:00
Timo Rothenpieler
808356c61c avcodec/nvenc: Check capabilities for interlaced encoding 2016-06-06 23:52:55 +02:00
Timo Rothenpieler
7c55f5d782 avcodec/nvenc: Don't set packet duration
It's not expected to be set on video packets and causes issues in
ffmpeg.c.
2016-06-04 12:20:59 +02:00
Timo Rothenpieler
e5babccfbc avcodec/nvenc: Refactor timestamp generation logic
Directly adapted from libav
2016-05-31 18:59:37 +02:00
Timo Rothenpieler
69c25c0ad7 avcodec/nvenc: forward frame duration 2016-05-31 18:39:28 +02:00
Timo Rothenpieler
971351b664 avcodec/nvenc: Handle minqp-only case in set_vbr 2016-05-31 17:00:07 +02:00
Timo Rothenpieler
eae4eba9cb avcodec/nvenc: twopass mode works in all modes 2016-05-31 16:55:24 +02:00
Timo Rothenpieler
1330a0f31f avcodec/nvenc: Fix forcing constqp rc mode
The CONSTQP enum value is 0, so this check failed for it.
2016-05-31 16:53:38 +02:00
Andrey Turkin
58c6dcb4b7 avcodec/nvenc: don't enqueue timestamps until a frame was accepted
Otherwise timestamps/pending FIFOs would go out of sync if nvEncodePicture ever fails.

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2016-05-31 16:50:45 +02:00
Andrey Turkin
2f53b5b74b avcodec/nvenc: refactor encode_frame a bit
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2016-05-31 16:47:07 +02:00
Andrey Turkin
d3463912c1 avcodec/nvenc: extract timestamp calculations into separate function
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2016-05-31 16:32:03 +02:00