summaryrefslogtreecommitdiff
path: root/libavcodec/nvenc.c
Commit message (Collapse)AuthorAge
* nvenc: allow setting the number of slicesAnton Khirnov2016-05-19
| | | | Based on a patch by Agatha Hu <ahu@nvidia.com>
* nvenc: De-compensate aspect ratio compensation of DVD-like content.Philip Langdale2016-05-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For reasons we are not privy to, nvidia decided that the nvenc encoder should apply aspect ratio compensation to 'DVD like' content, assuming that the content is not BT.601 compliant, but needs to be BT.601 compliant. In this context, that means that they make the following, questionable, assumptions: 1) If the input dimensions are 720x480 or 720x576, assume the content has an active area of 704x480 or 704x576. 2) Assume that whatever the input sample aspect ratio is, it does not account for the difference between 'physical' and 'active' dimensions. From these assumptions, they then conclude that they can 'help', by adjusting the sample aspect ratio by a factor of 45/44. And indeed, if you wanted to display only the 704 wide active area with the same aspect ratio as the full 720 wide image - this would be the correct adjustment factor, but what if you don't? And more importantly, what if you're used to lavc not making this kind of adjustment at encode time - because none of the other encoders do this! And, what if you had already accounted for BT.601 and your input had the correct attributes? Well, it's going to apply the compensation anyway! So, if you take some content, and feed it through nvenc repeatedly, it will keep scaling the aspect ratio every time, stretching your video out more and more and more. So, clearly, regardless of whether you want to apply bt.601 aspect ratio adjustments or not, this is not the way to do it. With any other lavc encoder, you would do it as part of defining your input parameters or do the adjustment at playback time, and there's no reason by nvenc should be any different. This change adds some logic to undo the compensation that nvenc would otherwise do. nvidia engineers have told us that they will work to make this compensation mechanism optional in a future release of the nvenc SDK. At that point, we can adapt accordingly. Signed-off-by: Philip Langdale <philipl@overt.org> Reviewed-by: Timo Rothenpieler <timo@rothenpieler.org> Signed-off-by: Anton Khirnov <anton@khirnov.net>
* nvenc: list the major contributors in the copyright headerAnton Khirnov2016-05-19
|
* nvenc: drop the hard dependency on CUDAAnton Khirnov2016-05-19
| | | | | | | | The code needs only a few definitions from cuda.h, so define them directly when CUDA is not enabled. CUDA is still required for accepting HW frames as input. Based on the code by Timo Rothenpieler <timo@rothenpieler.org>.
* nvenc: only support HW frames when CUDA is enabledAnton Khirnov2016-05-19
| | | | | hwcontext_cuda.h includes cuda.h, so this will allow building nvenc without depending on cuda.h
* nvenc: write the VUI signal properties for HEVCAnton Khirnov2016-05-19
| | | | | | Bump the API version requirement to 6. Based on a patch by Agatha Hu <ahu@nvidia.com>.
* nvenc: only write the VUI signal type fields if they are setAnton Khirnov2016-05-19
| | | | Based on a patch by Agatha Hu <ahu@nvidia.com>.
* nvenc: Generate bufferingPeriod/pictureTiming SEITimo Rothenpieler2016-05-19
| | | | | | | For some unknown reason enabling these causes proper CBR padding, so as there are no known downsides just always enable them in CBR mode. Signed-off-by: Anton Khirnov <anton@khirnov.net>
* nvenc: Delay frame output to increase encoding speedTimo Rothenpieler2016-05-19
| | | | Signed-off-by: Anton Khirnov <anton@khirnov.net>
* nvenc: add support for lossless encodingAnton Khirnov2016-05-19
| | | | Based on a patch by Philip Langdale <philipl@overt.org>
* nvenc: Generate AUD NAL units for better compatiblityTimo Rothenpieler2016-05-19
| | | | Signed-off-by: Anton Khirnov <anton@khirnov.net>
* cosmetics: Fix spelling mistakesVittorio Giovara2016-05-04
| | | | Signed-off-by: Diego Biurrun <diego@biurrun.de>
* nvenc: support CUDA frames as inputAnton Khirnov2016-02-14
|
* Allow linking to CUDA dynamically instead of dlopen()ing it at runtimeAnton Khirnov2016-02-14
|
* nvenc: rename a misnamed functionAnton Khirnov2016-02-12
| | | | | This function copies the encoded bistream into the caller's packet, calling it 'get_frame' is misleading.
* nvenc: merge input and output surface structsAnton Khirnov2016-02-12
| | | | | An input frame always corresponds to exactly one output packet, so there is no point in complicating the situation by managing them separately.
* nvenc: factor out the pixel format listAnton Khirnov2016-02-12
|
* nvenc: generate dts properlyAnton Khirnov2016-01-12
| | | | | | | | | | 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.
* nvenc: fix encoding with B-framesAnton Khirnov2016-01-12
| | | | | | | | | | | 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).
* nvenc: flush the encoder before closing it, as required by the docsAnton Khirnov2016-01-12
| | | | Otherwise, closing the encoder can crash.
* nvenc: better error handlingAnton Khirnov2016-01-12
| | | | Return proper error codes and print more descriptive error messages.
* nvenc: export CPB props side dataAnton Khirnov2015-12-06
|
* nvenc: Properly free the fifosLuca Barbato2015-08-25
| | | | Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
* lavc: Consistently prefix input buffer definesVittorio Giovara2015-07-27
| | | | Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
* lavc: AV-prefix all codec flagsVittorio Giovara2015-07-27
| | | | | | Convert doxygen to multiline and express bitfields more simply. Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
* Deprecate avctx.coded_frameVittorio Giovara2015-07-20
| | | | | | | | | | | | | | | | | 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>
* Gather all coded_frame allocations and free functions to a single placeVittorio Giovara2015-07-20
| | | | | | | | | | | | | | 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>
* nvenc: Fix NV12 inputLuca Barbato2015-06-26
|
* nvenc: H264 and HEVC encodersLuca Barbato2015-05-31
Partially based on the work of Timo Rothenpieler <timo@rothenpieler.org> Signed-off-by: Luca Barbato <lu_zero@gentoo.org>