1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-18 03:19:31 +02:00
Commit Graph

37 Commits

Author SHA1 Message Date
Timo Rothenpieler
ff3084606c avcodec/cuvid: make capability check optional 2017-06-01 12:39:06 +02:00
Timo Rothenpieler
fea4713472 avcodec/cuvid: use capability check instead of dummy decoder 2017-05-09 18:38:30 +02:00
wm4
c0f17a905f cuvid: support AVCodecContext.hw_device_ctx API
This is a newer API that is intended for decoders like the cuvid
wrapper. Until now, the wrapper required to set an awkward
"incomplete" hw_frames_ctx to set the device. Now the device
can be set directly, and the user can get AV_PIX_FMT_CUDA output
for a specific device simply by setting hw_device_ctx.

This still does a dummy ff_get_format() call at init time, and should
be fully backward compatible.
2017-05-05 00:17:41 +02:00
Muhammad Faiz
31f61b0d4f avcodec: do not use AVFrame accessor
Reviewed-by: wm4 <nfxjfg@googlemail.com>
Signed-off-by: Muhammad Faiz <mfcc64@gmail.com>
2017-04-23 14:27:47 +07:00
James Almer
bddb2343b6 Merge commit '061a0c14bb5767bca72e3a7227ca400de439ba09'
* commit '061a0c14bb5767bca72e3a7227ca400de439ba09':
  decode: restructure the core decoding code

CUVID decoder adapted by wm4.

Merged-by: James Almer <jamrial@gmail.com>
2017-04-22 20:08:42 -03:00
Timo Rothenpieler
5cd3cd5b68 avcodec/cuvid: add support for cropping/resizing
Overhauled version, original patch by Miroslav Slugeň <thunder.m@email.cz>.
2017-03-09 18:39:15 +01:00
Miroslav Slugeň
2a2f6b2887 avcodec/cuvid: add drop_second_field as input option
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2017-02-18 12:44:08 +01:00
Miroslav Slugeň
4cb8872eb7 avcodec/cuvid: don't overwrite deinterlace at progressive input
If there is progressive input it will disable deinterlacing in cuvid for
all future frames even those interlaced.

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2017-02-18 12:44:08 +01:00
Timo Rothenpieler
b6f4f0b14b avcodec/cuvid: add format mismatch debug logs 2017-02-14 11:48:38 +01:00
Timo Rothenpieler
ce79410bba avcodec/cuvid: set width and height before calling get_format
The external hw_frames_ctx is initialized in that callback, and needs
that information to be accurate.
2017-02-14 11:47:10 +01:00
Timo Rothenpieler
b7d480f431 avcodec/cuvid: update hw_frames_ctx reference after get_format call 2017-02-14 11:43:47 +01:00
Pavel Koshevoy
9ea2998586 avcodec/cuvid: fail early if GPU can't handle video resolution
CUVID on GeForce GT 730 and GeForce GTX 1060 does not report any error when
decoding 8K h264 packets. However, it does return an error during
cuvidCreateDecoder call if the indicated video resolution is not
supported.

Given that stream resolution is typically known as a result of probing
it is better to use this information during avcodec_open2 call to fail
immediately, rather than proceeding to decode and never receiving any
frames from the decoder nor receiving any indication of decode failure.

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2017-01-23 17:49:35 +01:00
Timo Rothenpieler
00223132e9 avcodec/cuvid: fix compilation with msvc11 2016-12-12 13:09:55 +01:00
Philip Langdale
dd10e7253a avcodec/cuvid: Restore initialization of pixel format in init()
I moved this into the handle_video_sequence callback because that's
the earliest time you can make an accurate decision as to what the
format should be.

However, transcoding requires that the decision between using
the accelerated PIX_FMT_CUDA vs a normal pix format happen at init()
time. There is enough information available to make that decision
and things work out with the underlying format only being discovered
in the sequence callback.
2016-11-23 13:23:34 -08:00
Philip Langdale
81147b5596 avcodec/cuvid: Add support for P010/P016 as an output surface format
The nvidia 375.xx driver introduces support for P016 output surfaces,
for 10bit and 12bit HEVC content (it's also the first driver to support
hardware decoding of 12bit content).

The cuvid api, as far as I can tell, only declares one output format
that they appear to refer to as P016 in the driver strings. Of course,
10bit content in P016 is identical to P010, and it is useful for
compatibility purposes to declare the format to be P010 to work with
other components that only know how to consume P010 (and to avoid
triggering swscale conversions that are lossy when they shouldn't be).

For simplicity, this change does not maintain the previous ability
to output dithered NV12 for 10/12 bit input video - the user will need
to update their driver to decode such videos.
2016-11-22 10:09:30 -08:00
Miroslav Slugen
10db40f374 avcodec/cuvid: allow setting number of used surfaces
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2016-11-22 10:34:27 +01:00
Timo Rothenpieler
d9ad18f3b4 avcodec/cuvid: use dynamically loaded CUDA/CUVID
And remove the now obsolete compat headers.
2016-11-22 10:34:27 +01:00
Philip Langdale
21b68cdbae avcodec/cuvid: Don't claim to decode h.263 (it doesn't)
Turns out cuvid doesn't support h.263.
2016-10-30 15:47:37 -07:00
Philip Langdale
ee7d6738ca avcodec/cuvid: Allow reinitialization of decoder
In practice, this works fine.
2016-10-22 14:57:00 -07:00
Hendrik Leppkes
3f9137c57d Merge commit '32c8359093d1ff4f45ed19518b449b3ac3769d27'
* commit '32c8359093d1ff4f45ed19518b449b3ac3769d27':
  lavc: export the timestamps when decoding in AVFrame.pts

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2016-10-07 13:03:36 +02:00
Timo Rothenpieler
5d4fea88d4 avcodec/cuvid: don't align frame size
hwcontext_cuda was changed to take care of proper alignment internally
2016-10-04 12:58:42 +02:00
Timo Rothenpieler
ba0e516533 avcodec/cuvid: make use of new av_hwdevice_ctx_create api 2016-09-29 22:58:34 +02:00
Timo Rothenpieler
49511501aa avcodec/cuvid: support a pre-initialized hw_frames_ctx 2016-09-29 22:58:34 +02:00
Timo Rothenpieler
f0ea96d8a2 avcodec/cuvid: use actual frame size for buffer allocation 2016-09-29 22:58:34 +02:00
Timo Rothenpieler
dcea618976 avcodec/cuvid: mark as avoid for probing 2016-09-23 11:17:49 +02:00
Philip Langdale
289a6bb8b1 cuvid: Pass bit depth information to decoder
Although cuvid can only output 8bit, it can consume HEVC Main10 if
the bit depth is set properly. In cases where >8bit is not supported,
this change is still beneficial as the decoder will fail to be
created instead of plowing throw and decoding as 8bit.
2016-09-22 18:39:46 -07:00
Philip Langdale
843aff3cf7 cuvid: Use bundled headers
We need to remove the dynlink fanciness and replace it with normal
function prototypes and update the include paths and configure logic.

We don't need to explicitly check for PICPARMS now - they're going
to be there.
2016-09-22 18:38:51 -07:00
Timo Rothenpieler
0b420886a4 avcodec/cuvid: add support for hardware deinterlacing
Currently does not work with the ffmpeg cli tool, due do it using the
old one in one out API.
Anything using the new API, like mpv, can make use of it, provided it is
prepared for a decoder modifying the framerate and outputing multiple
frames per input. FFmpeg itself is not.
2016-09-21 18:23:14 +02:00
Timo Rothenpieler
3b24020b54 avcodec/cuvid: implement new send_packet/receive_frame api 2016-09-21 18:22:27 +02:00
Philip Langdale
ee88dcb2b0 avcodec/cuvid: Check for non 420 chroma formats - they aren't supported
Despite the video parser seeming to correctly handle 422 and 444
chroma formats, the video decoder fails miserably to actually
decode frames - even though no errors are ever returned; you just
get frames showing unintialized garbage.

Signed-off-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2016-09-17 14:08:58 +02:00
Philip Langdale
8a06669702 avcodec/cuvid: Fully re-initialize the parser after a flush.
I'm not really sure how this worked at all before, but we do need to
reinitalize the parser with the stream extradata.

Signed-off-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2016-09-17 14:08:53 +02:00
Philip Langdale
4029f05c8b avcodec/cuvid: Always check for internal errors during parsing
The cuvid parser is basically undocumented, and although you'd
think that a failed callback would result in the overall parse
call returning an error, that is not true.

So, we end up silently trying to keep going as if nothing is wrong,
which doesn't achieve anything.

Solution: check the internal error flag every time.
Signed-off-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2016-09-10 22:27:24 +02:00
Timo Rothenpieler
b91e0e5987 avcodec/cuvid: check for and warn about invalid pkt_timebase 2016-09-09 17:56:07 +02:00
Timo Rothenpieler
132adf73af avcodec/cuvid: use pkt_timebase instead of time_base 2016-09-09 17:56:07 +02:00
Philip Langdale
86910b15c9 cuvid: Implement flush to support seeking in media players
Right now, if we attempt to use cuvid in a media player and then
try to seek, the decoder will happily pass out whatever frames were
already in flight before the seek.

There is both the output queue in our code and some number of frames
within the cuvid decoder that need to be accounted for.

cuvid doesn't support flush, so our only choice is to do a brute-force
re-creation of the decoder, which also implies re-creating the parser,
but this is fine.

The only subtlty is that there is sanity check code in decoder
initialisation that wants to make sure the HWContextFrame hasn't already
been initialised. This is a fair check to do at the beginning but not
after a flush, so it has to be made conditional.

Signed-off-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2016-09-06 21:52:05 +02:00
Philip Langdale
1891dfe013 cuvid: Add hwaccels and decoders for remaining supported formats
cuvid/nvdecode also supports mpeg1, mpeg2, h.263/mpeg4-asp and mjpeg.

It should, in theory, also support wmv3 via the vc1 support, given
that vdpau supports this. However, it failed to play wmv3 samples
which vdpau played correctly, so I'm not sure what to make of it.

Signed-off-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2016-09-06 21:35:42 +02:00
Timo Rothenpieler
88e8aef9e9 avcodec/cuvid: add cuvid decoder 2016-06-10 16:31:23 +02:00