aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/vaapi_encode.h
Commit message (Collapse)AuthorAgeFilesLines
* lavc/vaapi_encode: Query surface alignmentDavid Rosca2024-12-171-0/+4
| | | | | | It needs to create temporary config to query surface attribute. Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
* lavc/refstruct: move to lavu and make publicAnton Khirnov2024-12-151-1/+1
| | | | It is highly versatile and generally useful.
* hw_base_encode: refactor picture allocation/freeingLynne2024-09-091-7/+5
| | | | | | | | | | | | This commit cleans up and refactors the mess of private state upon private state that used to be. Now, FFHWBaseEncodePicture is fully initialized upon call-time, and, most importantly, this lets APIs which require initialization data for frames (VkImageViews) to initialize this for both the input image, and the reconstruction (DPB) image. Signed-off-by: Tong Wu <wutong1208@outlook.com>
* avcodec/hw_base_encode: avoid getting FFHWBaseEncodeContext from avctxTong Wu2024-07-021-0/+2
| | | | | | | | | | This patch is to make FFHWBaseEncodeContext a standalone component and avoid getting FFHWBaseEncodeContext from avctx->priv_data. This patch also removes some unnecessary AVCodecContext arguments. For receive_packet call, a small wrapper is introduced. Signed-off-by: Tong Wu <tong1.wu@intel.com>
* avcodec/vaapi_encode: extract a get_recon_format function to base layerTong Wu2024-07-021-10/+0
| | | | | | Surface size and block size parameters are also moved to base layer. Signed-off-by: Tong Wu <tong1.wu@intel.com>
* avcodec/vaapi_encode: extract gop configuration and two options to base layerTong Wu2024-07-021-16/+0
| | | | | | idr_interval and desired_b_depth are moved to HW_BASE_ENCODE_COMMON_OPTIONS. Signed-off-by: Tong Wu <tong1.wu@intel.com>
* avcodec/vaapi_encode: extract the init and close function to base layerTong Wu2024-07-021-10/+0
| | | | | | | Related parameters such as device context, frame context are also moved to base layer. Signed-off-by: Tong Wu <tong1.wu@intel.com>
* avcodec/vaapi_encode: move the dpb logic from VAAPI to base layerTong Wu2024-07-021-101/+1
| | | | | | | | | | Move receive_packet function to base. This requires adding *alloc, *issue, *output, *free as hardware callbacks. HWBaseEncodePicture is introduced as the base layer structure. The related parameters in VAAPIEncodeContext are also extracted to HWBaseEncodeContext. Then DPB management logic can be fully extracted to base layer as-is. Signed-off-by: Tong Wu <tong1.wu@intel.com>
* avcodec/vaapi_encode: add async_depth to common optionsTong Wu2024-07-021-7/+0
| | | | Signed-off-by: Tong Wu <tong1.wu@intel.com>
* avcodec/vaapi_encode: introduce a base layer for vaapi encodeTong Wu2024-07-021-32/+7
| | | | | | | Since VAAPI and future D3D12VA implementation may share some common parameters, a base layer encode context is introduced as vaapi context's base. Signed-off-by: Tong Wu <tong1.wu@intel.com>
* lavc/vaapi_encode: Enable block level bitrate controlFei Wang2024-03-181-1/+8
| | | | Signed-off-by: Fei Wang <fei.w.wang@intel.com>
* all: use designated initializers for AVOption.unitAnton Khirnov2024-02-141-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | Makes it robust against adding fields before it, which will be useful in following commits. Majority of the patch generated by the following Coccinelle script: @@ typedef AVOption; identifier arr_name; initializer list il; initializer list[8] il1; expression tail; @@ AVOption arr_name[] = { il, { il1, - tail + .unit = tail }, ... }; with some manual changes, as the script: * has trouble with options defined inside macros * sometimes does not handle options under an #else branch * sometimes swallows whitespace
* avcodec/vaapi_encode: Use RefStruct pool API, stop abusing AVBuffer APIAndreas Rheinhardt2023-11-011-4/+8
| | | | | | | | | | | | | | Up until now, the VAAPI encoder uses fake data with the AVBuffer-API: The data pointer does not point to real memory, but is instead just a VABufferID converted to a pointer. This has probably been copied from the VAAPI-hwcontext-API (which presumably does it to avoid allocations). This commit changes this without causing additional allocations by switching to the RefStruct-pool API. This also fixes an unchecked av_buffer_ref(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* lavc/vaapi_encode: Add VAAPI AV1 encoderFei Wang2023-09-221-0/+24
| | | | | Signed-off-by: Fei Wang <fei.w.wang@intel.com> Acked-by: Neal Gompa <ngompa13@gmail.com>
* lavc/vaapi_encode: Separate reference frame into previous/future listFei Wang2023-09-221-6/+9
| | | | | | | To support more reference frames from different directions. Signed-off-by: Fei Wang <fei.w.wang@intel.com> Reviewed-by: Neal Gompa <ngompa13@gmail.com>
* avcodec/defs: Add AV_PROFILE_* defines, deprecate FF_PROFILE_* definesAndreas Rheinhardt2023-09-071-2/+2
| | | | | | | | | These defines are also used in other contexts than just AVCodecContext ones, e.g. in libavformat. Furthermore, given that these defines are public, the AV-prefix is the right one, so deprecate (and not just move) the FF-macros. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* lavc/vaapi_encode: fix propagating durations and opaquesAnton Khirnov2023-02-021-0/+4
| | | | | input_image is freed by the time the output packet is constructed, so we need to store copies in VAAPIEncodePicture.
* lavc/vaapi_encode: add support for maxframesizeLinjie Fu2022-06-061-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | 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/+7
| | | | | | | | 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-0/+1
| | | | | | | | | | | | | 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>
* libavcodec/vaapi_encode: Add async_depth to vaapi_encoder to increase ↵Wenbin Chen2022-02-281-2/+14
| | | | | | | | | | | | | | | | 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-0/+3
| | | | | | | | | | 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>
* 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-1/+0
|
* vaapi_encode_h265: Fix ordering of tile dimensionsMark Thompson2020-08-011-1/+1
| | | | | | | Dimensions are normally specified as width x height, and this will match the same option to libaom-av1. Remove the indirection through the private context at the same time.
* lavc/vaapi_encode: add tile slice encoding supportLinjie Fu2020-07-201-0/+16
| | | | | | | | | | | | | | | | | | 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>
* avcodec/encode: restructure the core encoding codeJames Almer2020-06-181-1/+2
| | | | | | | | | | | | | | | | 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 hardware config metadataMark Thompson2020-04-261-0/+3
| | | | These encoders all accept VAAPI surfaces in a hardware frames context.
* vaapi_encode: Add ROI supportMark Thompson2019-07-281-0/+18
|
* vaapi_encode: Refactor encode misc parameter buffer creationMark Thompson2019-06-031-17/+6
| | | | | | 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-3/+0
|
* vaapi_encode: Warn if input has cropping informationMark Thompson2019-06-021-0/+4
| | | | Cropping is not supported by VAAPI encode.
* vaapi_encode: Support more RC modesMark Thompson2019-02-251-0/+65
| | | | | Allow setting the mode explicitly, and try to make a sensible choice given the available parameters if not.
* vaapi_encode: Convert to send/receive APIMark Thompson2019-01-231-15/+59
| | | | | | | | | | | | | 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-0/+4
|
* vaapi_encode: Add flag to mark encoders supporting only constant-qualityMark Thompson2018-10-271-0/+2
| | | | And set it for MJPEG.
* vaapi_encode: Support configurable slicesMark Thompson2018-10-271-0/+22
| | | | | | 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-3/+4
| | | | | | 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-0/+1
| | | | | | 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: Clean up rate control configurationMark Thompson2018-09-231-2/+4
| | | | | | 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: Add common options between all encodersMark Thompson2018-09-231-0/+9
| | | | | The only common option here is low_power - it was previously supported for H.264 only, that specific option is removed.
* vaapi_encode: Choose profiles dynamicallyMark Thompson2018-09-231-7/+36
| | | | | | | | | | | 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: Remove common priv_data and options fieldsMark Thompson2018-08-271-11/+0
| | | | | The codec-specific context now contains both the common context and the codec-specific options directly.
* lavc/vaapi_encode: Change the slice/parameter buffers to dynamic alloc.Jun Zhao2017-08-281-4/+2
| | | | | | | | Change the slice/parameter buffers to be allocated dynamically. Signed-off-by: Wang, Yi A <yi.a.wang@intel.com> Signed-off-by: Jun Zhao <jun.zhao@intel.com> Signed-off-by: Mark Thompson <sw@jkqxz.net>
* vaapi_encode: Move quality option to common codeMark Thompson2017-08-201-0/+6
| | | | | | | | | | | 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. (cherry picked from commit 19388a7200e5d99c703271f05dba1c806720e808)
* vaapi_encode: Pass framerate parameters to driverMark Thompson2017-02-081-0/+4
| | | | | | | | | 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. (cherry picked from commit ff35aa8ca4069bf1543adeec4c28e51e4a012eee)
* vaapi_encode: Add MPEG-2 supportMark Thompson2017-02-081-2/+3
| | | | (cherry picked from commit ca6ae3b77a7e6600e517723b90e57527a47809de)
* vaapi_encode: Support forcing IDR frames via AVFrame.pict_typeMark Thompson2017-02-081-0/+1
| | | | (cherry picked from commit a3c3a5eac20a51d402c332cdf5220fff40a7943f)
* vaapi_encode: Fix GOP sizingMark Thompson2017-02-081-3/+1
| | | | | | | | This change makes the configured GOP size be respected exactly - previously the value could be exceeded slightly due to flaws in the frame type selection logic. (cherry picked from commit 37fab0661a760b2a9d727939d72e629acee1a6ef)
* vaapi_encode: Write sequence header as extradataMark Thompson2016-12-051-0/+2
| | | | | | | Only works if packed headers are supported, where we can know the output before generating the first frame. (cherry picked from commit 0cf86fabfa5820596cca2cfead63c6f8df76c3f2)