aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/vaapi_encode.h
Commit message (Collapse)AuthorAgeFilesLines
* 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)
* vaapi_encode: Check packed header capabilitiesMark Thompson2016-11-211-0/+3
| | | | | | | This improves behaviour with drivers which do not support packed headers, such as AMD VCE on mesa/gallium. (cherry picked from commit 892bbbcdc171ff0d08d69636a240ffb95f54243c)
* vaapi_encode: Refactor initialisationMark Thompson2016-11-211-30/+66
| | | | | | | | | | This allows better checking of capabilities and will make it easier to add more functionality later. It also commonises some duplicated code around rate control setup and adds more comments explaining the internals. (cherry picked from commit 80a5d05108cb218e8cd2e25c6621a3bfef0a832e)
* Merge commit '8a62d2c28fbacd1ae20c35887a1eecba2be14371'Hendrik Leppkes2016-11-131-1/+3
|\ | | | | | | | | | | | | * commit '8a62d2c28fbacd1ae20c35887a1eecba2be14371': vaapi_encode: Maintain a pool of bitstream output buffers Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
| * vaapi_encode: Maintain a pool of bitstream output buffersMark Thompson2016-06-261-1/+3
| | | | | | | | | | | | | | | | | | Previously we would allocate a new one for every frame. This instead maintains an AVBufferPool of them to use as-needed. Also makes the maximum size of an output buffer adapt to the frame size - the fixed upper bound was a bit too easy to hit when encoding large pictures at high quality.
* | Merge commit '19d7667a81499d4357ec8e0851701e17c238e584'Clément Bœsch2016-06-291-0/+4
|\| | | | | | | | | | | | | * commit '19d7667a81499d4357ec8e0851701e17c238e584': vaapi_encode: Add support for writing arbitrary additional packed headers Merged-by: Clément Bœsch <clement@stupeflix.com>
| * vaapi_encode: Add support for writing arbitrary additional packed headersMark Thompson2016-06-091-0/+4
| |
* | Merge commit '92fdea37477b5a2d1329e5ef0773e24473fa8f12'Derek Buitenhuis2016-05-111-2/+13
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | These are all trivial to merge. * commit '92fdea37477b5a2d1329e5ef0773e24473fa8f12': vaapi_h265: Add -qp option, use it to replace use of -global_quality vaapi_h265: Add constant-bitrate encode support vaapi_h264: Add encode quality option (for quality-speed tradeoff) vaapi_h264: Add -qp option, use it to replace use of -global_quality vaapi_encode: Add support for codec-local options vaapi_h264: Add constant-bitrate encode support vaapi_encode: Refactor slightly to allow easier setting of global options Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
| * vaapi_encode: Add support for codec-local optionsMark Thompson2016-04-151-0/+5
| | | | | | | | Signed-off-by: Anton Khirnov <anton@khirnov.net>
| * vaapi_encode: Refactor slightly to allow easier setting of global optionsMark Thompson2016-04-151-2/+8
| | | | | | | | Signed-off-by: Anton Khirnov <anton@khirnov.net>
* | Merge commit '104c804bcaac24b52eb51ed17df2fb311e6ae73e'Derek Buitenhuis2016-05-081-4/+4
|/ | | | | | | * commit '104c804bcaac24b52eb51ed17df2fb311e6ae73e': lavc: VAAPI encode common infrastructure Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
* lavc: VAAPI encode common infrastructureMark Thompson2016-03-301-0/+217
Signed-off-by: Anton Khirnov <anton@khirnov.net>