Commit Graph

120 Commits

Author SHA1 Message Date
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
Andrey Turkin
0d021cc8b3 avcodec/nvenc: rework library load and GPU selection
Use explicit nvenc capability checks instead to determine usable devices
instead of SM versions.

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2016-05-31 16:04:53 +02:00
Andrey Turkin
f052ef30ef avcodec/nvenc: allow configuring number of surfaces
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2016-05-31 15:48:43 +02:00
Andrey Turkin
b69335304d avcodec/nvenc: use INIT_CLEANUP to deal with init failures
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2016-05-31 15:48:43 +02:00
Andrey Turkin
f84dfbc74a avcodec/nvenc: add rate control option
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2016-05-31 15:48:43 +02:00
Andrey Turkin
40df468ab1 avcodec/nvenc: convert tier to AVOptions
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2016-05-31 15:48:43 +02:00
Andrey Turkin
b0172873a8 avcodec/nvenc: convert levels to AVOptions
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2016-05-31 15:48:43 +02:00
Andrey Turkin
9824321b32 avcodec/nvenc: convert profile parsing to AVOptions
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2016-05-31 15:48:43 +02:00
Andrey Turkin
faffff88c2 avcodec/nvenc: use AVOptions to select presets
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2016-05-31 15:48:43 +02:00
Andrey Turkin
7aa16d59bf avcodec/nvenc: split H264/HEVC encoder definitions into separate files
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2016-05-31 11:15:19 +00:00
Timo Rothenpieler
24fcb23351 avcodec/nvenc: Require Maxwell for lossless 2016-05-25 12:16:54 +02:00
Andrey Turkin
a8cf25dd92 avcodec/nvenc: CUDA frames support
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2016-05-25 12:16:48 +02:00
Andrey Turkin
cfb49fc6f7 avcodec/nvenc: replace custom FIFOs with AVFifos
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2016-05-25 12:16:45 +02:00
Andrey Turkin
e1691c44f0 avcodec/nvenc: combine input and output surface structures
There is no point in separate structures as they have 1:1 relationship,
they are always used together and they have same lifetime.

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2016-05-25 12:16:40 +02:00
Andrey Turkin
82d705e245 avcodec/nvenc: split large functions into smaller ones
Functions names and scopes are from libav. This commit basically moves
code around without changing it; it shouldn't change any functionality
except some small leak fixes on error paths.

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2016-05-25 12:16:33 +02:00
Timo Rothenpieler
c921ca9b5d avcodec/nvenc: Write buffPeriod/picTime SEI in both CBR modes 2016-05-11 12:58:52 +02:00