aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/videotoolbox.c
Commit message (Collapse)AuthorAgeFilesLines
* avutil/frame: Port AVFrame.private_ref to RefStruct APIAndreas Rheinhardt2025-03-281-1/+1
| | | | | | | | | This is possible without deprecation period, because said field is documented as only for our libav* libraries and not the general public. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: James Almer <jamrial@gmail.com>
* videotoolbox: Fix building with older SDKsMartin Storsjö2025-03-261-1/+2
| | | | | | | | | The kVTVideoDecoderReferenceMissingErr constant was only added in the macOS 12 and iOS 15 SDKs. Use a hardcoded value instead of the named constant, to fix building with older SDKs after c6214b0d691566c7cb0f2ff5be08a24c3534e5bb. Signed-off-by: Martin Storsjö <martin@martin.st>
* avcodec/vt: Don't restart decoder when confronted with ReferenceMissingErrZhao Zhili2025-03-241-4/+6
| | | | | | | Otherwise the decoder may enter an loop of repeated state resets. This can happen for streams with CRA but no IDR. Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* FFHWAccel: add buffer_ref argument to start_frameLynne2025-03-171-2/+6
| | | | | | | | This commit adds a reference to the buffer as an argument to start_frame, and adapts all existing code. This allows for asynchronous hardware accelerators to skip copying packet data by referencing it.
* avcodec/videotoolbox: choose AYUV pixel format when idealJames Almer2024-10-121-3/+2
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* videotoolbox: Fix indentation of old existing codeMartin Storsjö2024-10-021-2/+2
| | | | Signed-off-by: Martin Storsjö <martin@martin.st>
* avcodec/videotoolbox: add AV1 hardware accelerationJan Ekström2024-10-021-0/+34
| | | | | | | | | | | | | Use AV1DecContext's current_obu to access the original OBUs, and feed them to videotoolbox, rather than the bare slice data passed via decode_slice. This requires a small addition to AV1DecContext, for keeping track of the current range of OBUs that belong to the current frame. Co-authored-by: Ruslan Chernenko <ractyfree@gmail.com> Co-authored-by: Martin Storsjö <martin@martin.st> Signed-off-by: Martin Storsjö <martin@martin.st>
* lavc/videotoolbox: drop HEVC cropping from start_frame rather than end_frameAnton Khirnov2024-08-191-5/+8
| | | | | | HEVCContext.output_frame will be removed in following commits. Reported-By: Max Bykov
* avcodec/mpegpicture: Split MPVPicture into WorkPicture and ordinary PicAndreas Rheinhardt2024-06-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are two types of MPVPictures: Three (cur_pic, last_pic, next_pic) that are directly part of MpegEncContext and an array of MPVPictures that are separately allocated and are mostly accessed via pointers (cur|last|next)_pic_ptr; they are also used to store AVFrames in the encoder (necessary due to B-frames). As the name implies, each of the former is directly associated with one of the _ptr pointers: They actually share the same underlying buffers, but the ones that are part of the context can have their data pointers offset and their linesize doubled for field pictures. Up until now, each of these had their own references; in particular, there was an underlying av_frame_ref() to sync cur_pic and cur_pic_ptr etc. This is wasteful. This commit changes this relationship: cur_pic, last_pic and next_pic now become MPVWorkPictures; this structure does not have an AVFrame at all any more, but only the cached values of data and linesize. It also contains a pointer to the corresponding MPVPicture, establishing a more natural relationsship between the two. This already means that creating the context-pictures from the pointers can no longer fail. What has not been changed is the fact that the MPVPicture* pointers are not ownership pointers and that the MPVPictures are part of an array of MPVPictures that is owned by a single AVCodecContext. Doing so will be done in a latter commit. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo: Shorten variable namesAndreas Rheinhardt2024-06-121-1/+1
| | | | | | | | current_picture->cur_pic, last_picture->last_pic, similarly for new_picture and next_picture. Also rename the corresponding *_ptr fields. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* lavc/hevcdec: move active PPS from HEVCParamSets to HEVCContextAnton Khirnov2024-06-111-3/+3
| | | | | "Currently active PPS" is a property of the decoding process, not of the list of available parameter sets.
* lavc/hevc*: move to hevc/ subdirAnton Khirnov2024-06-041-1/+1
|
* lavc/hevcdec: rename HEVCFrame.frame to just fAnton Khirnov2024-06-041-1/+1
| | | | | This is shorter, loses no information, and is consistent with other similar structs.
* lavc/hevcdec: rename HEVCContext.ref to cur_frameAnton Khirnov2024-06-041-1/+1
| | | | Since it stores a pointer to the current frame.
* avcodec/videotoolbox: use the correct HEVCSPS field nameJames Almer2024-06-011-1/+1
| | | | | | Fixes compilation that was broken in 6fed1841a1f5dd3cdcf343f77925af0781ebe83a. Signed-off-by: James Almer <jamrial@gmail.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>
* avcodec: remove deprecated FF_API_VT_HWACCEL_CONTEXTJames Almer2024-03-071-31/+0
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/videotoolbox: specify color range for hw frame ctxZhao Zhili2024-01-041-0/+6
| | | | Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* avcodec/hevc_ps: Use RefStruct API for parameter setsAndreas Rheinhardt2023-10-071-2/+2
| | | | | | | | | | Avoids allocations and error checks for these allocations; e.g. syncing buffers across threads can't fail any more and needn't be checked. It also gets rid of casts and indirections. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/avcodec: Add FFHWAccel, hide internals of AVHWAccelAndreas Rheinhardt2023-08-071-35/+36
| | | | | | | | | This commit is the AVHWAccel analogue of commit 20f972701806be20a77f808db332d9489343bb78: It moves the private fields of AVHWAccel to a new struct FFHWAccel extending AVHWAccel in an internal header (namely hwaccel_internal.h). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* lavc/videotoolbox: fix warningsJun Zhao2023-04-091-6/+10
| | | | | | fix mixing declarations and code warnings Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
* avcodec/videotoolbox: don't use av_ prefix for local functionZhao Zhili2023-01-261-5/+5
| | | | Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* avcodec/videotoolbox: deprecate creating AVVideotoolboxContext by userZhao Zhili2023-01-261-15/+20
| | | | Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* avcodec/videotoolbox: prefer hw_frames_ctx/hw_device_ctx over hwaccel_contextZhao Zhili2023-01-261-1/+2
| | | | Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* avcodec/videotoolbox: fix NULL pointer dereferenceZhao Zhili2023-01-261-3/+2
| | | | | | | | | | | | In the code path of av_videotoolbox_default_init/init2(), avctx->internal->hwaccel_priv_data is NULL and passed to decoder_cb.decompressionOutputRefCon. Then it will be dereferenced inside videotoolbox_decoder_callback(). Delay videotoolbox_star() until ff_videotoolbox_common_init() to fix the bug. Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* lavc/videotoolbox: deprecate write-only output_callbackAnton Khirnov2022-09-191-2/+0
| | | | | This field has never been used for anything, so stop setting it and deprecate it.
* lavc/videotoolbox: do not pass AVCodecContext to decoder output callbackAnton Khirnov2022-09-191-4/+6
| | | | | | | | | | | | | | | | | | The opaque parameter for the callback is set in videotoolbox_start(), called when the hwaccel is initialized. When frame threading is used, avctx will be the context corresponding to the frame thread currently doing the decoding. Using this same codec context in all subsequent invocations of the decoder callback (even those triggered by a different frame thread) is unsafe, and broken after cc867f2c09d2b69cee8a0eccd62aff002cbbfe11, since each frame thread now cleans up its hwaccel state after decoding each frame. Fix this by passing hwaccel_priv_data as the opaque parameter, which exists in a single instance forwarded between all frame threads. The only other use of AVCodecContext in the decoder output callback is as a logging context. For this purpose, store a logging context in hwaccel_priv_data.
* lavc/videotoolboxdec: insert emu-prevention bytes for HEVC as wellrcombs2022-06-011-4/+4
| | | | | | Fixes decoding of files with sync-fooling sequences in their PSs. Signed-off-by: rcombs <rcombs@rcombs.me>
* lavc/videotoolboxdec: fix writing too many 1 bits for the reserved fieldsrcombs2022-06-011-2/+2
| | | | Signed-off-by: rcombs <rcombs@rcombs.me>
* lavc/videotoolboxdec: fix generating HEVC general_profile_compatibility_flagsrcombs2022-06-011-1/+10
| | | | | | We store this as an array of bools, not a bitfield. Signed-off-by: rcombs <rcombs@rcombs.me>
* lavc/videotoolboxdec: fix escaping sequential zero sequencesrcombs2022-06-011-4/+3
| | | | | | | This ensure that e.g. 0000000000 becomes 00000300 000300, rather than 00000300 0000. Signed-off-by: rcombs <rcombs@rcombs.me>
* lavc/videotoolboxdec: warn on nonzero status in the callbackrcombs2022-06-011-1/+1
| | | | Signed-off-by: rcombs <rcombs@rcombs.me>
* configure: Use a separate config_components.h header for $ALL_COMPONENTSMartin Storsjö2022-03-161-0/+1
| | | | | | | | 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>
* avcodec/videotoolbox: add internal.h for header depenedencyLimin Wang2022-02-141-0/+1
| | | | | | | Fixes build failures for videotoolbox Signed-off-by: Limin Wang <lance.lmwang@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/videotoolbox: Fix undefined symbol with minimal configurationLimin Wang2022-01-051-0/+2
| | | | | | | | | | | | | | | | | Please reproduced with the following minimal configure command: ./configure --enable-shared --disable-all --enable-avcodec --enable-decoder=h264 --enable-hwaccel=h264_videotoolbox You'll get below error: Undefined symbols for architecture x86_64: "_ff_videotoolbox_vpcc_extradata_create", referenced from: _videotoolbox_start in videotoolbox.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) Reported-by: Cameron Gutman <aicommander@gmail.com> Tested-by: Cameron Gutman <aicommander@gmail.com> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* lavc/videotoolbox: set attachments on decoded buffersrcombs2021-12-221-0/+4
| | | | | | VideoToolbox internally sets all the colorspace parameters to BT709, regardless of what the bitstream actually indicates, so we need to replace that with what we've parsed.
* avcodec/videotoolbox: fix use of unknown builtin '__builtin_available'Limin Wang2021-12-041-2/+2
| | | | | | | | | Old system is: OSX version: 10.11.6 Apple LLVM version 8.0.0 (clang-800.0.42.1) Target: x86_64-apple-darwin15.6.0 Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avcodec/videotoolbox: silence some -Wimplicit-fallthrough warningsJames Almer2021-11-281-0/+2
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* lavc/videotoolbox: fix build on pre-10.14 SDKsrcombs2021-11-281-19/+7
| | | | Also fixes handling of future codec tags (needed to bswap)
* lavc/proresdec: add videotoolbox hwaccelrcombs2021-11-281-1/+73
|
* videotoolbox: add alpha supportrcombs2021-11-281-0/+3
|
* lavc/videotoolbox: add VP9 hardware accelerationrcombs2021-11-281-2/+15
| | | | On M1 Max, this supports profiles 0 and 2, but not 1 and 3.
* lavc/videotoolbox: call VTRegisterSupplementalVideoDecoderIfAvailablercombs2021-11-281-0/+7
| | | | This is required for VP9 to work.
* lavc/videotoolbox: expose some functions as lavc-internalrcombs2021-11-281-78/+68
|
* lavc/videotoolbox: select 4:2:2 and 4:4:4 formats when applicablercombs2021-11-281-0/+26
|
* lavc/videotoolbox: fix format computationrcombs2021-11-281-1/+1
| | | | Use sw_pix_fmt instead of pix_fmt (consistent with other hwaccels)
* lavc/videotoolbox: escape 0x00000[0-3]s in avcC PSsrcombs2021-11-281-8/+45
|
* avcodec/videotoolbox: make FFmpeg-to-VT mapping error more informativeJan Ekström2021-01-021-1/+7
| | | | Now logs the actual failed-to-map pixel format as well as range.
* avcodec/videotoolbox: add logging context to logSteven Liu2019-10-081-1/+1
| | | | Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
* lavc/videotoolboxdec: fix crop handling when multithreadedRodger Combs2019-09-151-5/+5
| | | | | | | | This was partially fixed by 233cd89, but it made changes to AVFrame fields from within end_frame, which doesn't work consistently when multithreading is enabled. This is what the post_process function is for. Signed-off-by: Aman Gupta <aman@tmm1.net>