1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00
Commit Graph

188 Commits

Author SHA1 Message Date
Zachariah Brown
b18fd2b95b avcodec/nvenc: use framerate if available
The h264_nvenc and hevc_nvenc encoders aren't respecting the framerate in the codec context.
Instead it was using the timebase which in our use-case was 1/1000 so the encoder was behaving
as if we wanted 1000fps. This resulted in poor encoding results due to an extremely low bitrate.

Both the amf and qsv encoders already contain similar logic to first check the framerate before
falling back to the timebase.

Signed-off-by: Zachariah Brown <zachariah@renewedvision.com>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2020-05-15 00:44:31 +02:00
Timo Rothenpieler
9ce7de9038 avcodec/nvenc: refactor dts calculation logic
The old approach used some highly complex delta computation math and
output-delaying.
I do not remember what the initial reasoning behind that was, but given
that we can just offset the dts by the amount of bframes, it seems wholy
unnecessary.

This leaves open an issue with VFR content, for which some more complex
logic might be needed.

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2020-05-02 01:33:49 +02:00
Timo Rothenpieler
aaadf0dce8 avcodec/nvenc: offset dts to account for b-frame reordering
Fixes ticket #7303

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2020-05-01 20:52:36 +02:00
Mark Thompson
1dff97b7bc avcodec/nvenc: add hardware config metadata
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2020-04-27 23:06:06 +02:00
Philip Langdale
3ea7057677 nvenc: implement flush to help allow an encoder to be re-used
It can be useful to re-use an encoder instance when doing segmented
encodings, and this requires flushing the encoder at the start of
each segment.
2020-01-08 19:20:36 -08:00
Timo Rothenpieler
4fb6ce27f0 avcodec/nvenc: make sure newly allocated packets are refcounted
Fixes ticket 8383

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2019-11-17 01:37:34 +01:00
hydra3333
ba6b20df3f avcodec/nvenc: turn feature check failures into warnings
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2019-10-29 13:38:24 +01:00
Timo Rothenpieler
ab0ef1abdf avcodec/nvenc: make use of new GetLastErrorString function
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2019-09-27 20:00:59 +02:00
Timo Rothenpieler
51a23343d9 avcodec/nvenc: pass CUstream to nvenc when available
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2019-09-27 20:00:59 +02:00
Roman Arzumanyan
567b5e33d9 avcodec/nvenc: add multiple reference frames support
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2019-09-27 20:00:59 +02:00
Timo Rothenpieler
e929b2f248 avcodec/nvenc: switch to dedicated dpb_size option
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2019-09-27 20:00:59 +02:00
Timo Rothenpieler
89cbbe9f70 avcodec/nvenc: fix typo in new Windows driver version
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2019-09-24 12:00:00 +02:00
Timo Rothenpieler
648f5c9382 avcodec/nvenc: add driver version info for SDK 9.1
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2019-09-23 15:47:27 +02:00
Timo Rothenpieler
2e254bb897 avcodec/nvenc: fix indentation 2019-04-27 12:33:08 +02:00
Timo Rothenpieler
23ed147e8f avcodec/nvenc: only unregister input resources when absolutely needed
This reverts nvenc to old behaviour, which in some super rare edge cases
performs better.
The implication of this is that any potential API user who relies on
nvenc cleaning up every frames device resources after it's done using
them will have to change their usage pattern.

That should not be a problem, since pretty much every normal usage
pattern automatically implies that surfaces are reused from a common
pool, since constant re-allocation is also very expensive.
2019-04-27 12:33:08 +02:00
Timo Rothenpieler
1144d5c96d avcodec/nvenc: add minimum driver version for SDK 8.2 and 9.0
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2019-03-10 00:25:31 +01:00
Roman Arzumanyan
f1f66df6a2 avcodec/nvenc: add b_as_ref support for HEVC
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2019-02-14 13:22:09 +01:00
Philip Langdale
19d3d0c057 avutil/hwcontext_cuda: Define and use common CHECK_CU()
We have a pattern of wrapping CUDA calls to print errors and
normalise return values that is used in a couple of places. To
avoid duplication and increase consistency, let's put the wrapper
implementation in a shared place and use it everywhere.

Affects:

* avcodec/cuviddec
* avcodec/nvdec
* avcodec/nvenc
* avfilter/vf_scale_cuda
* avfilter/vf_scale_npp
* avfilter/vf_thumbnail_cuda
* avfilter/vf_transpose_npp
* avfilter/vf_yadif_cuda
2018-11-14 17:39:42 -08:00
Timo Rothenpieler
dc2d56a66b avcodec/nvenc: add option to turn off a53 closed caption embedding 2018-08-21 15:14:56 +02:00
Pavel Koshevoy
f7d117b484 avcodec/nvenc: enable nvenc encoder instance reuse
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2018-06-15 11:18:47 +02:00
Timo Rothenpieler
2e700b082c Revert "avcodec/nvenc: make hw_frames_ctx fully optional"
This reverts commit 7d4e1f7cfb.

Accidentially pushed this with a batch of other patches, and it didn't
seem to break anything, so I went with it.
Except it does, so reverting it it is.
2018-05-10 00:34:21 +02:00
Timo Rothenpieler
fdbb4b9a78 avcodec/nvenc: move reconfig_encoder call inside of push/pop ctx
Also make it void, it must not fail the encode anyway.
2018-05-04 23:35:38 +02:00
Roman Arzumanyan
5a88e8c365 avcodec/nvenc: add A53CC support
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2018-05-04 23:35:38 +02:00
pkviet
155375123c avcodec/nvenc: support dynamic bitrate changes
The patch enables dynamic bitrate through ReconfigureEncoder method
from nvenc API.
This is useful for live streaming in case of network congestion.

Signed-off-by: pkviet <pkv.stream@gmail.com>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2018-05-04 23:35:38 +02:00
Miroslav Slugeň
952421cd20 avcodec/nvenc: support dynamic aspect ratio change
If there is input like DVB-T streams it can change aspect ratio
on-the-fly, so nvenc should respect this change and change aspect ratio
in encoder.

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2018-05-04 23:35:38 +02:00
Timo Rothenpieler
7d4e1f7cfb avcodec/nvenc: make hw_frames_ctx fully optional 2018-05-04 23:35:38 +02:00
Timo Rothenpieler
9f3902f107 avcodec/nv{enc,dec}: use sane version checking macro
For some odd reason, the Nvidia version macros puts the minor version in
the msb, so comparing against it is impossible.
2018-04-13 11:19:43 +02:00
Timo Rothenpieler
2108a6736f avcodec/nvenc: update required driver versions for nvenc 2018-04-11 14:55:28 +02:00
Timo Rothenpieler
86e9dba8fa avcodec/nvenc: add support for B frames as ref 2018-04-11 14:55:28 +02:00
Philip Langdale
6a89cdc474 avcodec/nvenc: Declare support for P016
nvenc doesn't support P016, but we have two problems today:

1) We declare support for YUV444P16 which nvenc also doesn't support.
   We do this because it's the only pix_fmt we have that can
   approximate nvenc's internal format that is YUV444P10 with data in
   MSBs instead of LSBs. Because the declared format is a 16bit one,
   it will be preferrentially chosen when encoding >10bit content,
   but that content will normally be YUV420P12 or P016 which should
   get mapped to P010 and not YUV444P10.

2) Transcoding P016 content with nvenc should be possible in a pure
   hardware pipeline, and that can't be done if nvenc doesn't say it
   accepts P016. By mapping it to P010, we can use it, albeit with
   truncation. I have established that swscale doesn't know how to
   dither to 10bits so we'd get truncation anyway, even if we tried
   to do this 'properly'.
2018-03-02 14:52:48 -08:00
Timo Rothenpieler
932037c6bb avcodec/nvenc: also clear data pointer after unregistering a resource
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2018-01-28 13:05:09 +01:00
Timo Rothenpieler
48e52e4edd avcodec/nvenc: add some more error case checks
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2018-01-28 12:56:31 +01:00
Timo Rothenpieler
32bc4e77f6 avcodec/nvenc: unregister input resource when unmapping
Currently the resource is only ever unregistered when the
registered_frames array is fully in use and an unmapped entry is re-used
and cleaned up.
I'm pretty sure the frame will have been cleaned up before that happens,
so I'm kinda surprised this never blew up.

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2018-01-28 12:39:06 +01:00
Timo Rothenpieler
bbe1b21022 avcodec/nvenc: refcount input frame mappings
If some logic like vsync in ffmpeg.c duplicates frames, it might pass
the same frame twice, which will result in a crash due it being
effectively mapped and unmapped twice.

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2018-01-28 12:29:24 +01:00
Pan Bian
eb69e7bed8 avcodec/nvenc: set correct error code
In function process_output_surface(), the return value is 0 on the path
that av_mallocz() returns a NULL pointer. 0 indicates success, which
deviates from the fact. Return "AVERROR(ENOMEM)" instead of "0".

Signed-off-by: Pan Bian <bianpan2016@163.com>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2017-11-29 10:42:58 +01:00
Mark Thompson
1dc483a6f2 compat/cuda: Pass a logging context to load functions
Reviewed-by: Timo Rothenpieler <timo@rothenpieler.org>
2017-11-20 15:47:05 +00:00
Timo Rothenpieler
4e93f00b06 avcodec/nvenc: check pop_context return value 2017-11-17 23:34:18 +01:00
Hendrik Leppkes
bff6d98ba3 nvenc: support d3d11 surface input 2017-11-15 10:35:44 +01:00
Hendrik Leppkes
6fcbf39f9e nvenc: factor context push/pop into functions
This reduces code repetition, and will allow adding further push/pop
refinement for D3D11 devices in future commits.
2017-11-15 10:35:39 +01:00
Timo Rothenpieler
d0961d3069 avcodec/nvenc: sanitize variable names 2017-09-07 12:08:32 +02:00
Timo Rothenpieler
a56d0497cb avcodec/nvenc: migrate to new encode API
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2017-09-07 12:08:32 +02:00
Timo Rothenpieler
4e6638abb4 avcodec/nvenc: always output picture timing SEI
Interlaced encoding profits from it, or might even need it in some
players.
No harm in enabling it unconditionally.

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2017-09-02 16:01:57 +02:00
Timo Rothenpieler
0e995eac20 avcodec/nvenc: only push cuda context on encoder close if encoder exists
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2017-09-01 10:52:15 +02:00
Timo Rothenpieler
a0b69e2b0a avcodec/nvenc: add support for specifying entropy coding mode
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2017-09-01 10:52:15 +02:00
Ganapathy Kasi
43c417ac1a avcodec/nvenc: fix hw accelerated transcode with bframes
hw accelerated transcode (h264_cuvid -> h264_nvenc with -hwaccel cuvid) was
broken after the filtergraph initialization was changed to intialize decoder
first followed by encoder (commit af1761f7b5).
During initialzing encoder with bframes, local buffers are allocated
internally in encoder which fails since no cuda context is available. Now
pushing the correct cuda context before encoder initialization fixes the issue.
Also adding push/pop cuda ctx during create/destroy/map/unmap resources and
destroy encoder session.

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2017-06-02 21:32:35 +02:00
Timo Rothenpieler
cb3358b68f avcodec/nvenc: print minimum driver version on error 2017-06-01 11:55:25 +02:00
Timo Rothenpieler
a1652aca7e avcodec/nvenc: remove unnecessary alignment
Fixes #6260
2017-05-23 11:24:43 +02:00
Sumit Agarwal
01775730fd avcodec/nvenc: add weighted prediction support
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2017-05-10 10:22:41 +02:00
Ben Chang
18a659d1b6 avcodec/nvenc: add fractional CQ support
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2017-05-10 10:21:25 +02:00
Timo Rothenpieler
cfbebe9dda avcodec/nvenc: deprecated old rc modes, add new ones 2017-05-09 18:38:30 +02:00