Commit Graph

17 Commits

Author SHA1 Message Date
Anton Khirnov
871d0930d4 nvenc: support CUDA frames as input 2016-02-14 22:31:47 +01:00
Anton Khirnov
c51b2c79a7 Allow linking to CUDA dynamically instead of dlopen()ing it at runtime 2016-02-14 22:08:13 +01:00
Anton Khirnov
d005ccc630 nvenc: rename a misnamed function
This function copies the encoded bistream into the caller's packet,
calling it 'get_frame' is misleading.
2016-02-12 10:20:11 +01:00
Anton Khirnov
118beda355 nvenc: merge input and output surface structs
An input frame always corresponds to exactly one output packet, so there
is no point in complicating the situation by managing them separately.
2016-02-12 10:19:40 +01:00
Anton Khirnov
28259c13db nvenc: factor out the pixel format list 2016-02-12 10:19:26 +01:00
Anton Khirnov
c59fec783d nvenc: generate dts properly
When there is a non-zero decoding delay due to reordering, the first dts
should be lower than the first pts (since the first packet fed to the
decoder does not produce any output).

Use the same scheme used in mpegvideo_enc (which comes from x264
originally) -- wait for first two timestamps and extrapolate linearly to
the past to produce the first dts value.
2016-01-12 09:23:38 +01:00
Anton Khirnov
9d36cab4c0 nvenc: fix encoding with B-frames
When B-frames are enabled and the encoder returns success, all currently
pending buffers immediately become valid and can be returned to the
caller. We can only return one packet at a time, so all the other
pending buffers should be transferred to a new 'ready' fifo, from where
they can be returned in subsequent calls (in which the encoder does not
produce any new output). This bug was hidden by the incorrect testing of
the encoder return value (the return value was overwritten before it was
tested).
2016-01-12 09:23:38 +01:00
Anton Khirnov
aac7d6b284 nvenc: flush the encoder before closing it, as required by the docs
Otherwise, closing the encoder can crash.
2016-01-12 09:23:38 +01:00
Anton Khirnov
39571e86cb nvenc: better error handling
Return proper error codes and print more descriptive error messages.
2016-01-12 09:12:40 +01:00
Anton Khirnov
1520c6ff05 nvenc: export CPB props side data 2015-12-06 10:25:43 +01:00
Luca Barbato
413d4e54a9 nvenc: Properly free the fifos
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2015-08-25 19:47:43 +02:00
Vittorio Giovara
059a934806 lavc: Consistently prefix input buffer defines
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-07-27 15:24:59 +01:00
Vittorio Giovara
7c6eb0a1b7 lavc: AV-prefix all codec flags
Convert doxygen to multiline and express bitfields more simply.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-07-27 15:24:58 +01:00
Vittorio Giovara
40cf1bbacc Deprecate avctx.coded_frame
The rationale is that coded_frame was only used to communicate key_frame,
pict_type and quality to the caller, as well as a few other random fields,
in a non predictable, let alone consistent way.

There was agreement that there was no use case for coded_frame, as it is
a full-sized AVFrame container used for just 2-3 int-sized properties,
which shouldn't even belong into the AVCodecContext in the first place.

The appropriate AVPacket flag can be used instead of key_frame, while
quality is exported with the new AVPacketSideData quality factor.
There is no replacement for the other fields as they were unreliable,
mishandled or just not used at all.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-07-20 15:06:50 +01:00
Vittorio Giovara
d6604b29ef Gather all coded_frame allocations and free functions to a single place
Allocating coded_frame is what most encoders do anyway, so it makes
sense to always allocate and free it in a single place. Moreover a lot
of encoders freed the frame with av_freep() instead of the correct API
av_frame_free().

This bring uniformity to encoder behaviour and prevents applications
from erroneusly accessing this field when not allocated. Additionally
this helps isolating encoders that export information with coded_frame,
and heavily simplifies its deprecation.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-07-20 14:16:15 +01:00
Luca Barbato
92fdc80cab nvenc: Fix NV12 input 2015-06-26 22:18:24 +02:00
Luca Barbato
b08caa87c3 nvenc: H264 and HEVC encoders
Partially based on the work of Timo Rothenpieler <timo@rothenpieler.org>

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2015-05-31 15:17:22 +02:00