summaryrefslogtreecommitdiff
path: root/libavcodec/vaapi_encode.c
Commit message (Collapse)AuthorAge
* avcodec: use the buffer_size_t typedef where requiredJames Almer2021-03-10
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* lavc: Mark hw_config pointer arrays as constMark Thompson2020-11-08
| | | | They are read-only just like the HWConfig structures they point to.
* vaapi_encode: Delete unused fieldMark Thompson2020-08-01
|
* Revert "lavc/vaapi_encode: add EQUAL_MULTI_ROWS support for slice structure"Mark Thompson2020-07-27
| | | | | | | | | | | 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-24
| | | | | | 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-20
| | | | | | | | | | | | | | | | | | 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-20
| | | | | | | | 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-19
| | | | | | | | | | | | | | | | | | 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-18
| | | | | | | | | | | | | | | | 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-04
| | | | | | | | | | | | | | | 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-26
| | | | These encoders all accept VAAPI surfaces in a hardware frames context.
* lavc/vaapi_encode: Fix leak in error caseMark Thompson2020-02-09
| | | | Fixes CID 1442564.
* lavc/vaapi_encode: grow packet if vaMapBuffer returns multiple buffersLinjie Fu2019-12-17
| | | | | | | | | | | | 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-30
| | | | | 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-26
| | | | | | | 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-28
|
* vaapi_encode: Refactor encode misc parameter buffer creationMark Thompson2019-06-03
| | | | | | 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-03
|
* vaapi_encode: Warn if input has cropping informationMark Thompson2019-06-02
| | | | Cropping is not supported by VAAPI encode.
* vaapi_encode: Support more RC modesMark Thompson2019-02-25
| | | | | 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-23
| | | | | 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-23
| | | | | | | | | | | | | 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-23
|
* vaapi_encode: Improve log message for unsupported profilesMark Thompson2018-11-18
|
* vaapi_encode: Add flag to mark encoders supporting only constant-qualityMark Thompson2018-10-27
| | | | And set it for MJPEG.
* vaapi_encode: Support configurable slicesMark Thompson2018-10-27
| | | | | | 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-23
| | | | | | 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-23
| | | | | | 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-23
| | | | | | 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-23
| | | | | | 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-23
| | | | | | | | 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-23
|
* vaapi_encode: Choose profiles dynamicallyMark Thompson2018-09-23
| | | | | | | | | | | 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-27
|
* vaapi_encode: Remove common priv_data and options fieldsMark Thompson2018-08-27
| | | | | The codec-specific context now contains both the common context and the codec-specific options directly.
* vaapi_encode: Add an assert in vaapi_encode_truncate_gop()Haihao Xiang2018-05-10
| | | | | | | | The flag of input_available must be set when pic_start is not NULL, so add an assert to ensure it is true. In addition, the assert on last_pic is unnecessary now, so remove this assert. Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* lavc/vaapi_encode: Don't return error if the underlying driver doesn't ↵Haihao Xiang2018-03-08
| | | | | | | | | | | | support B frames The underlying driver need not support B frames - since they are enabled by default for some codecs, it is better to disable them rather than returning an error in this case. This makes the default settings usable for low-power encoding on Intel platforms. Signed-off-by: Haihao Xiang <haihao.xiang@intel.com> Signed-off-by: Mark Thompson <sw@jkqxz.net>
* Merge commit '216c44dfc17252ec0681dcb0bbeeb45a9d14eca7'Mark Thompson2018-02-21
|\ | | | | | | | | | | | | * commit '216c44dfc17252ec0681dcb0bbeeb45a9d14eca7': vaapi_encode: Destroy output buffer pool before VA context Merged-by: Mark Thompson <sw@jkqxz.net>
| * vaapi_encode: Destroy output buffer pool before VA contextMark Thompson2018-02-20
| | | | | | | | | | The buffers are created associated with the context, so they should be destroyed before the context is. This is enforced by the iHD driver.
* | Merge commit 'c8e135ea9225137050a6315fd9ba9c0f242c90b6'Mark Thompson2018-02-21
|\| | | | | | | | | | | | | | | | | | | * commit 'c8e135ea9225137050a6315fd9ba9c0f242c90b6': vaapi_encode: Allocate slice structures and parameter buffers dynamically Already present as e4a6eb70f471eda36592078e8fa1bad87fc9df73, one minor fix for libav merged. Merged-by: Mark Thompson <sw@jkqxz.net>
| * vaapi_encode: Allocate slice structures and parameter buffers dynamicallyJun Zhao2018-02-20
| | | | | | | | | | | | | | | | | | This removes the arbitrary limit on the allowed number of slices and parameter buffers. From ffmpeg commit e4a6eb70f471eda36592078e8fa1bad87fc9df73. Signed-off-by: Mark Thompson <sw@jkqxz.net>
| * vaapi: Always free parameter buffers after vaEndPicture() with libva2Mark Thompson2017-10-25
| | | | | | | | | | | | This is an ABI change in libva2: previously the Intel driver had this behaviour and it was implemented as a driver quirk, but now it is part of the specification so all drivers must do it.
| * vaapi_encode: Move quality option to common codeMark Thompson2017-08-06
| | | | | | | | | | | | | | | | | | Use AVCodecContext.compression_level rather than a private option, replacing the H.264-specific quality option (which stays only for compatibility). This now works with the H.265 encoder in the i965 driver, as well as the existing cases with the H.264 encoder.
| * vaapi_encode: Use gop_size consistently in RC parametersMark Thompson2017-04-26
| | | | | | | | | | | | | | | | The non-H.26[45] codecs already use this form. Since we don't currently generate I frames for codecs which support them separately to IDR, the p_per_i variable is set to infinity by default so that it doesn't interfere with any other calculation. (All the code for I frames still exists, and it works for H.264 if set manually.)
| * vaapi_encode: Discard output buffer if picture submission failsMark Thompson2017-02-16
| | | | | | | | | | Previously this was leaking, though it actually hit an assert making sure that the buffer had already been cleared when freeing the picture.
* | lavc/vaapi_encode: give a debug message if attrs unsupported.Jun Zhao2017-12-19
| | | | | | | | | | | | | | | | Give a debug message when query attribute get VA_ATTRIB_NOT_SUPPORTED, it's will help to trace and debug some issue. Signed-off-by: Jun Zhao <jun.zhao@intel.com> Signed-off-by: Mark Thompson <sw@jkqxz.net>
* | vaapi: Always free parameter buffers after vaEndPicture() with libva2Mark Thompson2017-10-09
| | | | | | | | | | | | This is an ABI change in libva2: previously the Intel driver had this behaviour and it was implemented as a driver quirk, but now it is part of the specification so all drivers must do it.
* | Merge commit 'fd9212f2edfe9b107c3c08ba2df5fd2cba5ab9e3'James Almer2017-09-26
|\| | | | | | | | | | | | | * commit 'fd9212f2edfe9b107c3c08ba2df5fd2cba5ab9e3': Mark some arrays that never change as const. Merged-by: James Almer <jamrial@gmail.com>
| * Mark some arrays that never change as const.Anton Khirnov2017-02-01
| |
| * vaapi_encode: Pass framerate parameters to driverMark Thompson2017-01-30
| | | | | | | | | | | | | | Only do this when building for a recent VAAPI version - initial driver implementations were confused about the interpretation of the framerate field, but hopefully this will be consistent everywhere once 0.40.0 is released.