aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/vaapi_encode.c
Commit message (Collapse)AuthorAgeFilesLines
* lavc/vaapi_encode: Query surface alignmentDavid Rosca2024-12-171-0/+66
| | | | | | 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-12/+12
| | | | It is highly versatile and generally useful.
* lavc/vaapi_encode: Fix potential use of uninitialized valueFei Wang2024-09-191-1/+1
| | | | Signed-off-by: Fei Wang <fei.w.wang@intel.com>
* hw_base_encode: allocate DPB image upfrontLynne2024-09-091-5/+0
| | | | Vulkan requires this, as it needs to initialize state upfront.
* hw_base_encode: refactor picture allocation/freeingLynne2024-09-091-50/+39
| | | | | | | | | | | | 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/vaapi_encode: Check hwctxMichael Niedermayer2024-07-231-2/+4
| | | | | | | | Fixes: null pointer dereference Fixes: 70376/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_VAAPI_fuzzer-4733551250046976 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/hw_base_encode: avoid getting FFHWBaseEncodeContext from avctxTong Wu2024-07-021-5/+11
| | | | | | | | | | 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 free funtion to base layerTong Wu2024-07-021-5/+1
| | | | Signed-off-by: Tong Wu <tong1.wu@intel.com>
* avcodec/vaapi_encode: extract a get_recon_format function to base layerTong Wu2024-07-021-62/+19
| | | | | | 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 set_output_property to base layerTong Wu2024-07-021-42/+2
| | | | Signed-off-by: Tong Wu <tong1.wu@intel.com>
* avcodec/vaapi_encode: extract gop configuration and two options to base layerTong Wu2024-07-021-48/+4
| | | | | | 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-61/+29
| | | | | | | 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-667/+126
| | | | | | | | | | 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: move pic->input_surface initialization to encode_allocTong Wu2024-07-021-4/+4
| | | | | | | | When allocating the VAAPIEncodePicture, pic->input_surface can be initialized right in the place. This movement simplifies the send_frame logic and is the preparation for moving vaapi_encode_send_frame to the base layer. Signed-off-by: Tong Wu <tong1.wu@intel.com>
* avcodec/vaapi_encode: add picture type name to baseTong Wu2024-07-021-3/+1
| | | | Signed-off-by: Tong Wu <tong1.wu@intel.com>
* avcodec/vaapi_encode: add async_depth to common optionsTong Wu2024-07-021-5/+8
| | | | Signed-off-by: Tong Wu <tong1.wu@intel.com>
* avcodec/hw_base_encode: add FF_HW_ prefix for two enumsTong Wu2024-07-021-25/+25
| | | | | | | PICTURE_TYPE_* and FLAG_* are added FF_HW_ prefix after being moved to base layer. Signed-off-by: Tong Wu <tong1.wu@intel.com>
* lavc/vaapi_encode: convert from lambda to qpHaihao Xiang2024-04-031-1/+4
| | | | | | | When AV_CODEC_FLAG_QSCALE is set, the value of avctx->global_quality is lambda. Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* lavc/vaapi_encode: Add VAAPI version check for BLBRCFei Wang2024-04-031-3/+17
| | | | | | Fix build fail when VAAPI version less than 0.39.2. Signed-off-by: Fei Wang <fei.w.wang@intel.com>
* avutil/common: Don't auto-include mem.hAndreas Rheinhardt2024-03-311-0/+1
| | | | | | | | | | | There are lots of files that don't need it: The number of object files that actually need it went down from 2011 to 884 here. Keep it for external users in order to not cause breakages. Also improve the other headers a bit while just at it. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* lavc/vaapi_encode: Enable block level bitrate controlFei Wang2024-03-181-1/+12
| | | | Signed-off-by: Fei Wang <fei.w.wang@intel.com>
* avcodec/vaapi_encode: remove a duplicate av_freepTong Wu2024-02-261-1/+0
| | | | Signed-off-by: Tong Wu <tong1.wu@intel.com>
* avcodec/vaapi_encode: Avoid double AVERRORSMichael Niedermayer2023-12-291-1/+1
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/vaapi_encode: Use RefStruct pool API, stop abusing AVBuffer APIAndreas Rheinhardt2023-11-011-40/+28
| | | | | | | | | | | | | | 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-32/+166
| | | | | 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-25/+87
| | | | | | | 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>
* lavc/vaapi_encode: Extract set output pkt property functionFei Wang2023-09-221-27/+38
| | | | | Signed-off-by: Fei Wang <fei.w.wang@intel.com> Reviewed-by: Neal Gompa <ngompa13@gmail.com>
* lavc/vaapi_encode: Init pic at the beginning of APIFei Wang2023-09-221-4/+1
| | | | | 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-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>