summaryrefslogtreecommitdiff
path: root/libavcodec/vaapi_encode.c
Commit message (Collapse)AuthorAgeFilesLines
* lavc/vaapi_encode: fix propagating durations and opaquesAnton Khirnov2023-02-021-5/+17
| | | | | input_image is freed by the time the output packet is constructed, so we need to store copies in VAAPIEncodePicture.
* lavc/vaapi_encode*: handle frame durations and ↵Anton Khirnov2023-01-291-0/+8
| | | | | | | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE Except for the mjpeg_vaapi encoder, which is already handled generically.
* lavc/vaapi: Add support for remaining 10/12bit profilesPhilip Langdale2022-09-031-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | With the necessary pixel formats defined, we can now expose support for the remaining 10/12bit combinations that VAAPI can handle. Specifically, we are adding support for: * HEVC ** 12bit 420 ** 10bit 422 ** 12bit 422 ** 10bit 444 ** 12bit 444 * VP9 ** 10bit 444 ** 12bit 444 These obviously require actual hardware support to be usable, but where that exists, it is now enabled. Note that unlike YUVA/YUVX, the Intel driver does not formally expose support for the alphaless formats XV30 and XV360, and so we are implicitly discarding the alpha from the decoder and passing undefined values for the alpha to the encoder. If a future encoder iteration was to actually do something with the alpha bits, we would need to use a formal alpha capable format or the encoder would need to explicitly accept the alphaless format.
* lavc/vaapi: Switch preferred 8bit 444 format to VUYXPhilip Langdale2022-08-251-1/+1
| | | | | | | | | As vaapi doesn't actually do anything useful with the alpha channel, and we have an alphaless format available, let's use that instead. The changes here are mostly 1:1 switching, but do note the explicit change in the number of declared channels from 4 to 3 to reflect that the alpha is being ignored.
* lavc/vaapi_encode: enable 8bit 4:4:4 encoding for HEVC and VP9Philip Langdale2022-08-091-0/+1
| | | | | | | | | | Sufficiently recent Intel hardware is able to do encoding of 8bit 4:4:4 content in HEVC and VP9. The main requirement here is that the frames must be provided in the AYUV format. Enabling support is done by adding the appropriate encoding profiles and noting that AYUV is officially a four channel format with alpha so we must state that we expect all four channels.
* lavc/vaapi_encode: add support for maxframesizeLinjie Fu2022-06-061-0/+74
| | | | | | | | | | | | | | | | | | | | | | | | | | Add support for max frame size: - max_frame_size (bytes) to indicate the max allowed size for frame. Control each encoded frame size into target limitation size by adjusting whole frame's average QP value. The driver will use multi passes to adjust average QP setp by step to achieve the target, and the result may not strictly guaranteed. Frame size may exceed target alone with using the maximum average QP value. The failure always happens on the intra(especially the first intra frame of a new GOP) frames or set max_frame_size with a very small number. example cmdline: ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -f rawvideo \ -v verbose -s:v 352x288 -i ./input.yuv -vf format=nv12,hwupload \ -c:v h264_vaapi -profile:v main -g 30 -rc_mode VBR -b:v 500k \ -bf 3 -max_frame_size 40000 -vframes 100 -y ./max_frame_size.h264 Max frame size was enabled since VA-API version (0, 33, 0), but query is available since (1, 5, 0). It will be passed as a parameter in picParam and should be set for each frame. Signed-off-by: Linjie Fu <linjie.fu@intel.com> Signed-off-by: Fei Wang <fei.w.wang@intel.com>
* vaapi_encode: Move block size calculation after entrypoint selectionMark Thompson2022-04-111-0/+16
| | | | | | | | The block size can be dependent on the profile and entrypoint selected. It defaults to 16x16, with codecs able to override this choice with their own function. Signed-off-by: Fei Wang <fei.w.wang@intel.com>
* lavc/vaapi_encode_h265: Add GPB frame support for hevc_vaapiLinjie Fu2022-04-111-5/+62
| | | | | | | | | | | | | Use GPB frames to replace regular P/B frames if backend driver does not support it. - GPB: Generalized P and B picture. Regular P/B frames replaced by B frames with previous-predict only, L0 == L1. Normal B frames still have 2 different ref_lists and allow bi-prediction Signed-off-by: Linjie Fu <linjie.fu@intel.com> Signed-off-by: Fei Wang <fei.w.wang@intel.com>
* configure: Use a separate config_components.h header for $ALL_COMPONENTSMartin Storsjö2022-03-161-0/+2
| | | | | | | | This avoids unnecessary rebuilds of most source files if only the list of enabled components has changed, but not the other properties of the build, set in config.h. Signed-off-by: Martin Storsjö <martin@martin.st>
* libavcodec/vaapi_encode: Add async_depth to vaapi_encoder to increase ↵Wenbin Chen2022-02-281-13/+51
| | | | | | | | | | | | | | | | performance Fix: #7706. After commit 5fdcf85bbffe7451c2, vaapi encoder's performance decrease. The reason is that vaRenderPicture() and vaSyncBuffer() are called at the same time (vaRenderPicture() always followed by a vaSyncBuffer()). Now I changed them to be called in a asynchronous way, which will make better use of hardware. Async_depth is added to increase encoder's performance. The frames that are sent to hardware are stored in a fifo. Encoder will sync output after async fifo is full. Signed-off-by: Wenbin Chen <wenbin.chen@intel.com> Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* libavcodec/vaapi_encode: Add new API adaption to vaapi_encodeWenbin Chen2022-02-281-5/+27
| | | | | | | | | | Add vaSyncBuffer to VAAPI encoder. Old version API vaSyncSurface wait surface to complete. When surface is used for multiple operation, it waits all operations to finish. vaSyncBuffer only wait one channel to finish. Signed-off-by: Wenbin Chen <wenbin.chen@intel.com> Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* avcodec/vaapi_encode: Fix segfault upon closing uninitialized encoderAndreas Rheinhardt2021-12-011-3/+10
| | | | | | | Fixes ticket #9537. Probably a regression since 2b3206891649f317c20993411efef4bee39ae784. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* Replace all occurences of av_mallocz_array() by av_calloc()Andreas Rheinhardt2021-09-201-2/+2
| | | | | | | They do the same. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avutil/buffer: Switch AVBuffer API to size_tAndreas Rheinhardt2021-04-271-1/+1
| | | | | | | Announced in 14040a1d913794d9a3fd6406a6d8c2f0e37e0062. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/vaapi_encode: use AVCodecContext.get_encode_buffer()James Almer2021-03-171-1/+1
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec: use the buffer_size_t typedef where requiredJames Almer2021-03-101-1/+2
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* lavc: Mark hw_config pointer arrays as constMark Thompson2020-11-081-1/+1
| | | | They are read-only just like the HWConfig structures they point to.
* vaapi_encode: Delete unused fieldMark Thompson2020-08-011-8/+4
|
* Revert "lavc/vaapi_encode: add EQUAL_MULTI_ROWS support for slice structure"Mark Thompson2020-07-271-3/+0
| | | | | | | | | | | This reverts commit 489c5db0791f39518775b12eef6d48276c17f96f. Treating EQUAL_MULTI_ROWS in the same way as the arbitrary-size cases is just wrong. Consider 9 rows, 4 slices - we pick 4 slices with sizes { 3, 2, 2, 2 }, which EQUAL_MULTI_ROWS does not allow. It isn't possible to split the frame into 4 slices at all with the EQUAL_MULTI_ROWS structure - the closest options are 3 slices with sizes { 3, 3, 3 } or 5 slices with sizes { 2, 2, 2, 2, 1 }.
* lavc/vaapi_encode: Add render target support for 422 10-bitLinjie Fu2020-07-241-0/+3
| | | | | | This enables VAAPI encoding support for 422 10-bit(Y210). Signed-off-by: Linjie Fu <linjie.justin.fu@gmail.com>
* lavc/vaapi_encode: add tile slice encoding supportLinjie Fu2020-07-201-8/+120
| | | | | | | | | | | | | | | | | | Add functions to initialize tile slice structure and make tile slice: - vaapi_encode_init_tile_slice_structure - vaapi_encode_make_tile_slice Tile slice is not allowed to cross the boundary of a tile due to the constraints of media-driver. Currently adding support for one slice per tile. N x N tile encoding is supposed to be supported with the the capability of ARBITRARY_MACROBLOCKS slice structures. N X 1 tile encoding should also work in ARBITRARY_ROWS slice structure. Signed-off-by: Linjie Fu <linjie.justin.fu@gmail.com>
* lavc/vaapi_encode: wrap slice codes into row slice functionsLinjie Fu2020-07-201-81/+109
| | | | | | | | Wrap current whole-row slice codes into following functions: - vaapi_encode_make_row_slice() - vaapi_encode_init_row_slice_structure() Signed-off-by: Linjie Fu <linjie.justin.fu@gmail.com>
* lavc/vaapi_encode: add EQUAL_MULTI_ROWS support for slice structureLinjie Fu2020-07-191-0/+3
| | | | | | | | | | | | | | | | | | VA_ENC_SLICE_STRUCTURE_EQUAL_MULTI_ROWS is added to in the latest libva (1.8.0) which matches the hardware behaviour: /** \brief Driver supports any number of rows per slice but they must * be the same for all slices except for the last one, which must be * equal or smaller to the previous slices. */ And VA_ENC_SLICE_STRUCTURE_EQUAL_ROWS is kind of deprecated for iHD since it's somehow introduced in [1] which is misleading from what we actually handles. [1]<https://github.com/intel/libva/commit/0e6d5441f19bdc674b4da3169d614d10fd644778> Signed-off-by: Linjie Fu <linjie.justin.fu@gmail.com>
* avcodec/encode: restructure the core encoding codeJames Almer2020-06-181-4/+23
| | | | | | | | | | | | | | | | This commit follows the same logic as 061a0c14bb, but for the encode API: The new public encoding API will no longer be a wrapper around the old deprecated one, and the internal API used by the encoders now consists of a single receive_packet() callback that pulls frames as required. amf encoders adapted by James Almer librav1e encoder adapted by James Almer nvidia encoders adapted by James Almer MediaFoundation encoders adapted by James Almer vaapi encoders adapted by Linjie Fu v4l2_m2m encoders adapted by Andriy Gelman Signed-off-by: James Almer <jamrial@gmail.com>
* lavc/vaapi_encode: add FF_CODEC_CAP_INIT_CLEANUP caps for encodersLinjie Fu2020-05-041-1/+0
| | | | | | | | | | | | | | | ff_vaapi_encode_close() is not enough to free the resources like cbs if initialization failure happens after codec->configure (except for vp8/vp9). We need to call avctx->codec->close() to deallocate, otherwise memory leak happens. Add FF_CODEC_CAP_INIT_CLEANUP for vaapi encoders and deallocate the resources at free_and_end inside avcodec_open2(). Reviewed-by: Timo Rothenpieler <timo@rothenpieler.org> Signed-off-by: Linjie Fu <linjie.fu@intel.com>
* lavc/vaapi_encode: Add hardware config metadataMark Thompson2020-04-261-0/+5
| | | | These encoders all accept VAAPI surfaces in a hardware frames context.
* lavc/vaapi_encode: Fix leak in error caseMark Thompson2020-02-091-0/+1
| | | | Fixes CID 1442564.
* lavc/vaapi_encode: grow packet if vaMapBuffer returns multiple buffersLinjie Fu2019-12-171-5/+13
| | | | | | | | | | | | Currently, assigning new buffer for pkt when multiple buffers were returned from vaMapBuffer will overwrite the previous encoded pkt data and lead to encode issues. Iterate through the buf_list first to find out the total buffer size needed for the pkt, allocate the whole pkt to avoid repeated reallocation and memcpy, then copy data from each buf to pkt. Signed-off-by: Linjie Fu <linjie.fu@intel.com>
* avcodec/vaapi_encode: Simplify code with av_clip_int8()Michael Niedermayer2019-08-301-1/+1
| | | | | Reviewed-by: "Li, Zhong" <zhong.li@intel.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/vaapi_encode: respect -force_key_frames settingAman Gupta2019-08-261-1/+1
| | | | | | | This was a regression in 5fdcf85bbffe7451c227478fda62da5c0938f27d Signed-off-by: Aman Gupta <aman@tmm1.net> Signed-off-by: Mark Thompson <sw@jkqxz.net>
* vaapi_encode: Add ROI supportMark Thompson2019-07-281-0/+116
|
* vaapi_encode: Refactor encode misc parameter buffer creationMark Thompson2019-06-031-21/+51
| | | | | | This removes the use of the nonstandard combined structures, which generated some warnings with clang and will cause alignment problems with some parameter buffer types.
* vaapi_encode: Remove unused functionMark Thompson2019-06-031-6/+0
|
* vaapi_encode: Warn if input has cropping informationMark Thompson2019-06-021-0/+19
| | | | Cropping is not supported by VAAPI encode.
* vaapi_encode: Support more RC modesMark Thompson2019-02-251-113/+269
| | | | | Allow setting the mode explicitly, and try to make a sensible choice given the available parameters if not.
* vaapi_encode: Let the reconstructed frame pool be sized dynamicallyMark Thompson2019-01-231-3/+0
| | | | | No supported encode driver requires the pool to be fixed-size, so just remove this constraint.
* vaapi_encode: Convert to send/receive APIMark Thompson2019-01-231-301/+334
| | | | | | | | | | | | | This attaches the logic of picking the mode of for the next picture to the output, which simplifies some choices by removing the concept of the picture for which input is not yet available. At the same time, we allow more complex reference structures and track more reference metadata (particularly the contents of the DPB) for use in the codec-specific code. It also adds flags to explicitly track the available features of the different codecs. The new structure also allows open-GOP support, so that is now available for codecs which can do it.
* vaapi_encode: Allocate picture-private data in generic codeMark Thompson2019-01-231-3/+12
|
* vaapi_encode: Improve log message for unsupported profilesMark Thompson2018-11-181-2/+3
|
* vaapi_encode: Add flag to mark encoders supporting only constant-qualityMark Thompson2018-10-271-1/+2
| | | | And set it for MJPEG.
* vaapi_encode: Support configurable slicesMark Thompson2018-10-271-0/+148
| | | | | | This adds common code to query driver support and set appropriate address/size information for each slice. It only supports rectangular slices for now, since that is the most common use-case.
* vaapi_encode: Clean up the packed header configurationMark Thompson2018-09-231-56/+63
| | | | | | Add a larger warning more clearly explaining the consequences of missing packed header support in the driver. Also only write the extradata if the user actually requests it via the GLOBAL_HEADER flag.
* vaapi_encode: Clean up the GOP structure configurationMark Thompson2018-09-231-27/+56
| | | | | | Choose what types of reference frames will be used based on what types are available, and make the intra-only mode explicit (GOP size one, which must be used for MJPEG).
* vaapi_encode: Add support for max QP in rate controlMark Thompson2018-09-231-0/+3
| | | | | | This was added in libva 2.1.0 (VAAPI 1.1.0). Use AVCodecContext.qmax, matching the existing behaviour for qmin, and clean up the defaults so that we only pass min/max when explicitly set.
* vaapi_encode: Clean up rate control configurationMark Thompson2018-09-231-51/+130
| | | | | | Query which modes are supported and select between VBR and CBR based on that - this removes all of the codec-specific rate control mode selection code.
* vaapi_encode: Always reapply global parameters after the sequence headerMark Thompson2018-09-231-11/+9
| | | | | | | | The codec sequence headers may contain fields which can overwrite the fine parameters given in the specific settings (e.g. a crude bitrate value vs. the max-rate / target-percentage / etc. values in VAEncMiscParameterRateControl). Always reapply all global parameters after a sequence header to avoid this causing problems.
* vaapi_encode: Clean up the encode quality configurationMark Thompson2018-09-231-33/+51
|
* vaapi_encode: Choose profiles dynamicallyMark Thompson2018-09-231-55/+221
| | | | | | | | | | | Previously there was one fixed choice for each codec (e.g. H.265 -> Main profile), and using anything else then required an explicit option from the user. This changes to selecting the profile based on the input format and the set of profiles actually supported by the driver (e.g. P010 input will choose Main 10 profile for H.265 if the driver supports it). The entrypoint and render target format are also chosen dynamically in the same way, removing those explicit selections from the per-codec code.
* vaapi_encode: Factorise out adding global parametersMark Thompson2018-08-271-16/+22
|
* vaapi_encode: Remove common priv_data and options fieldsMark Thompson2018-08-271-10/+0
| | | | | The codec-specific context now contains both the common context and the codec-specific options directly.