summaryrefslogtreecommitdiff
path: root/libavcodec/videotoolbox.c
Commit message (Collapse)AuthorAge
* avcodec/videotoolbox: Fix undefined symbol with minimal configurationLimin Wang2022-01-05
| | | | | | | | | | | | | | | | | 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-22
| | | | | | 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-04
| | | | | | | | | 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-28
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* lavc/videotoolbox: fix build on pre-10.14 SDKsrcombs2021-11-28
| | | | Also fixes handling of future codec tags (needed to bswap)
* lavc/proresdec: add videotoolbox hwaccelrcombs2021-11-28
|
* videotoolbox: add alpha supportrcombs2021-11-28
|
* lavc/videotoolbox: add VP9 hardware accelerationrcombs2021-11-28
| | | | On M1 Max, this supports profiles 0 and 2, but not 1 and 3.
* lavc/videotoolbox: call VTRegisterSupplementalVideoDecoderIfAvailablercombs2021-11-28
| | | | This is required for VP9 to work.
* lavc/videotoolbox: expose some functions as lavc-internalrcombs2021-11-28
|
* lavc/videotoolbox: select 4:2:2 and 4:4:4 formats when applicablercombs2021-11-28
|
* lavc/videotoolbox: fix format computationrcombs2021-11-28
| | | | Use sw_pix_fmt instead of pix_fmt (consistent with other hwaccels)
* lavc/videotoolbox: escape 0x00000[0-3]s in avcC PSsrcombs2021-11-28
|
* avcodec/videotoolbox: make FFmpeg-to-VT mapping error more informativeJan Ekström2021-01-02
| | | | Now logs the actual failed-to-map pixel format as well as range.
* avcodec/videotoolbox: add logging context to logSteven Liu2019-10-08
| | | | Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
* lavc/videotoolboxdec: fix crop handling when multithreadedRodger Combs2019-09-15
| | | | | | | | 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>
* avcodec/videotoolbox: add support for full range pixel formatsAkemi2019-09-04
| | | | Signed-off-by: Aman Gupta <aman@tmm1.net>
* avcodec/videotoolbox_hevc: avoid leaking cached_hw_frames_ctxPavel Koshevoy2019-08-23
| | | | | | | | vtctx->cached_hw_frames_ctx is unref'd in videotoolbox_uninit, but videotoolbox_hevc used ff_videotoolbox_uninit which doesn't unref cache_hw_frames_ctx. Signed-off-by: Pavel Koshevoy <pkoshevoy@gmail.com>
* avcodec/videotoolbox: add support for 10bit pixel formatfumoboy0072019-04-16
| | | | | this patch was originally posted on issue #7704 and was slightly adjusted to check for the availability of the pixel format.
* avcodec/vt_hevc: fix crash if vps_list[0] or sps_list[0] are nullRodger Combs2019-03-19
| | | | | | | Instead of assuming id 0 is used, use the same logic as used for PPS, where all available entries in the list are emitted. Signed-off-by: Aman Gupta <aman@tmm1.net>
* lavc/videotoolbox: Fix cropping with HEVC and H264 videosAkemi2018-11-12
| | | | | | | | | | | videotoolbox returns an already cropped stream which led to double cropping. this issue was introduced with the refactor of the cropping mechanism in commit 07596e4 for h264 and 000fb61 for HEVC. to fix this we set the cropping of the frame and the output frame to 0. Tested-by: ponpon Fixes ticket #7544.
* avcodec/videotoolbox: fix decoding of some HEVC videosAman Gupta2018-05-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In a normal hwaccel, the AVHWFramesContext sets AVFrame.hw_frames_ctx when it initializes a new AVFrame in av_hwframe_get_buffer(). But the VT hwaccel doesn't know what hw_frames_ctx to assign when the AVFrame is first created, because it depends on the format of the pixbuf that the decoder eventually decides to return. Thus newly created AVFrames always have a NULL hw_frames_ctx, and the hwaccel would only assign the ctx once a frame was done decoding. This worked fine with the H264 decoder, but with the HEVC decoder the frame's data may be moved to another empty AVFrame. Since the empty AVFrame never had hw_frames_ctx set, a frame with a NULL ctx could be returned to the API user. This patch works around the issue by moving the derived hw_frames_ctx from the AVFrame to a new VTHWFrame which now holds both the CVPixelBufferRef and the AVBuffer. The hw_frames_ctx is only copied to the AVFrame right before it is about to be returned to the user in videotoolbox_postproc_frame() (since in the case of VT, the hw_frames_ctx is only there for the API user anyway). Fixes playback on macOS and iOS of some hevc videos like https://s3.amazonaws.com/tmm1/videotoolbox/germany-hevc-zdf.ts Signed-off-by: Aman Gupta <aman@tmm1.net>
* avcodec/videotoolbox: split h264/hevc callbacksAman Gupta2018-05-09
| | | | | | | Previously the shared callbacks were trying to interpret avctx->priv_data as H264Context* Signed-off-by: Aman Gupta <aman@tmm1.net>
* avcodec/videotoolbox: cleanupsAman Gupta2018-05-09
| | | | | | No functional changes. Signed-off-by: Aman Gupta <aman@tmm1.net>
* avcodec/videotoolbox: fix kVTCouldNotFindVideoDecoderErr trying to decode ↵Aman Gupta2018-05-04
| | | | | | | | | | HEVC on iOS Older iOS devices don't have a hardware HEVC decoder, but the software decoder offered by VideoToolbox is well-optimized and performs much better than the ffmpeg decoder. Signed-off-by: Aman Gupta <aman@tmm1.net>
* avcodec/videotoolbox: improve logging of decoder errorsAman Gupta2018-05-04
| | | | Signed-off-by: Aman Gupta <aman@tmm1.net>
* lavc/videotoolbox: fix failure to decode PAFFRodger Combs2018-04-10
| | | | Signed-off-by: Aman Gupta <aman@tmm1.net>
* lavc/videotoolbox: fix threaded decodingRodger Combs2018-03-08
| | | | | | | | | | | | | | | | | | AVHWAccel.end_frame can run on a worker thread. The assumption of the frame threading code is that the worker thread will change the AVFrame image data, not the AVFrame fields. So the AVFrame fields are not synced back to the main thread. But this breaks videotoolbox due to its special requirements (everything else is fine). It actually wants to update AVFrame fields. The actual videotoolbox frame is now stored in the dummy AVBufferRef, so it mimics what happens in non-videotoolbox cases. (Changing the AVBufferRef contents is a bit like changing the image data.) The post_process callback copies that reference to the proper AVFrame field. Based on a patch by wm4. Signed-off-by: Aman Gupta <aman@tmm1.net>
* avcodec/videotoolbox: fix SEGV when hwaccel decoding h264 with ffmpeg.cAman Gupta2017-11-28
| | | | Signed-off-by: Aman Gupta <aman@tmm1.net>
* lavc: Mark all AVHWAccel structures as constMark Thompson2017-11-26
|
* libavcodec/videotoolbox: fix decoding of h264 streams with minor SPS changesAman Gupta2017-11-20
| | | | | | | | | | | | | | | | | | | | | | | | | | Previously the codec kept an entire copy of the SPS, and restarted the VT decoder session whenever it changed. This fixed decoding errors in [1], as described in 9519983c. On further inspection, that sample features an SPS change from High/4.0 to High/3.2 while moving from one scene to another. Yesterday I received [2], which contains minor SPS changes where the profile and level do not change. These occur frequently and are not associated with scene changes. After 9519983c, the VT decoder session is recreated unnecessarily when these are encountered causing visual glitches. This commit simplifies the state kept in the VTContext to include just the first three bytes of the SPS, containing the profile and level details. This is populated initially when the VT decoder session is created, and used to detect changes and force a restart. This means minor SPS changes are fed directly into the existing decoder, whereas profile/level changes force the decoder session to be recreated with the new parameters. After this commit, both samples [1] and [2] playback as expected. [1] https://s3.amazonaws.com/tmm1/videotoolbox/spschange.ts [2] https://s3.amazonaws.com/tmm1/videotoolbox/spschange2.ts Signed-off-by: Aman Gupta <aman@tmm1.net>
* avcodec/videotoolbox: fix opaque_ref handlingwm42017-11-13
| | | | | | | | | | | | This is a partial fix - to fix videotoolbox fully (with multithreaded hwaccel decoding), much more work would be required. Before this change, an assertion failure would trigger: $ ffmpeg -hwaccel videotoolbox -hwaccel_output_format videotoolbox_vld -i h264.ts -f null -y /dev/null Assertion (frame->private_ref && frame->private_ref->size == sizeof(FrameDecodeData)) || !(avctx->codec->capabilities & (1 << 1)) failed at libavcodec/decode.c:620 Signed-off-by: Aman Gupta <aman@tmm1.net>
* avcodec/videotoolbox: reorder functions to avoid forward declarationsAman Gupta2017-11-13
| | | | | | Cosmetic change only. Signed-off-by: Aman Gupta <aman@tmm1.net>
* avcodec/videotoolbox: fix whitespaceAman Gupta2017-11-13
| | | | Signed-off-by: Aman Gupta <aman@tmm1.net>
* avcodec/videotoolbox: pass through hevc param changes to the decoderAman Gupta2017-11-13
| | | | | | | | | | This includes the SEI_PREFIX/SEI_SUFFIX NALUs, which can contain updates like HEVC_SEI_TYPE_ACTIVE_PARAMETER_SETS. Previously, hevc samples with this SEI present would not playback correctly. See for example https://github.com/lhc70000/iina/issues/1123 Signed-off-by: Aman Gupta <aman@tmm1.net>
* avcodec/videotoolbox: remove unnecessary if statementAman Gupta2017-11-13
| | | | | | Cosmetic change only. Signed-off-by: Aman Gupta <aman@tmm1.net>
* avcodec/videotoolbox: create avcC even when h264 extradata is missingAman Gupta2017-11-13
| | | | | | | | | | Removes the avctx->extradata_size requirement when creating avcC/hvcC, since avctx->extradata is only used in the esds code path. This fixes an issue where the VideoToolbox decoder would not work unless avformat_find_stream_info() was called. Signed-off-by: Aman Gupta <aman@tmm1.net>
* avcodec/videotoolbox: use decode_params to propagate H264 PPS changes and ↵Aman Gupta2017-11-13
| | | | | | | | | | | | | | | | | | | | | restart on SPS changes This fixes decoding of H264 video samples with SPS and PPS changes. See for example https://s3.amazonaws.com/tmm1/videotoolbox/spschange.ts, which previously stalled the decoder and failed to produce any new frames after the SPS change. Also see https://s3.amazonaws.com/tmm1/videotoolbox/ppschange.ts, which uses multiple PPS and would previously cause VT decode failures. If the VideoToolbox session needs to be restarted, and videotoolbox_start() fails for some reason (for instance, if the video is interlaced and the decoder is running on iOS), avcodec will return AVERROR_EXTERNAL. This can be used by the API user to switch to another decoder. Signed-off-by: Aman Gupta <aman@tmm1.net>
* avcodec/videotoolbox: print descriptive errors on decode failuresAman Gupta2017-11-13
| | | | Signed-off-by: Aman Gupta <aman@tmm1.net>
* avcodec/videotoolbox: reset bitstream_size in end_frameAman Gupta2017-11-13
| | | | | | | | | | | This allows decode_slice to be invoked multiple times before end_frame, causing slices to accumulate before being fed into the VT decoder. An upcoming commit will re-use decode_slice for parameter NALUs, so they can be propagated into the VT decoder session along with slice data. Signed-off-by: Aman Gupta <aman@tmm1.net>
* avcodec/videotoolbox: extract videotoolbox_{start,stop} helpersAman Gupta2017-11-13
| | | | | | | These helpers will be used in later commits to automatically restart the decoder session when SPS changes are encountered. Signed-off-by: Aman Gupta <aman@tmm1.net>
* avcodec/videotoolbox: use early return in videotoolbox_default_freeAman Gupta2017-11-13
| | | | | | Cosmetic change only. Signed-off-by: Aman Gupta <aman@tmm1.net>
* videotoolbox: add frame_params supportwm42017-11-12
| | | | | | Allows decoding with API users which require this API. Reviewed-by: Aman Gupta <ffmpeg@tmm1.net>
* lavc/videotoolbox: fix out-of-bounds memory access during hvcc creationAman Gupta2017-10-31
| | | | Signed-off-by: Aman Gupta <aman@tmm1.net>
* lavc: drop VDAClément Bœsch2017-10-23
| | | | | Deprecated (aka removed) in OSX 10.11, and we have a replacement for it (VideoToolbox).
* avcodec/videotoolbox: add hevc supportAman Gupta2017-09-28
| | | | Signed-off-by: Aman Gupta <aman@tmm1.net>
* videotoolbox: fix crash when decoding interlaced video with new APIwm42017-07-11
|
* videotoolbox: log errorswm42017-05-31
| | | | | | | With the new decode API, you can't handle errors directly in the API user - you only know that the hwaccel did not initialize at all. Add some approximate logging.
* videotoolbox: add hwcontext supportwm42017-05-15
| | | | | | | | | | | | | | | | | | This adds tons of code for no other benefit than making VideoToolbox support conform with the new hwaccel API (using hw_device_ctx and hw_frames_ctx). Since VideoToolbox decoding does not actually require the user to allocate frames, the new code does mostly nothing. One benefit is that ffmpeg_videotoolbox.c can be dropped once generic hwaccel support for ffmpeg.c is merged from Libav. Does not consider VDA or VideoToolbox encoding. Fun fact: the frame transfer functions are copied from vaapi, as the mapping makes copying generic boilerplate. Mapping itself is not exported by the VT code, because I don't know how to test.
* avcodec/h264, videotoolbox: fix crash after VT decoder failsAman Gupta2017-03-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The way videotoolbox hooks in as a hwaccel is pretty hacky. The VT decode API is not invoked until end_frame(), so alloc_frame() returns a dummy frame with a 1-byte buffer. When end_frame() is eventually called, the dummy buffer is replaced with the actual decoded data from VTDecompressionSessionDecodeFrame(). When the VT decoder fails, the frame returned to the h264 decoder from alloc_frame() remains invalid and should not be used. Before 9747219958060d8c4f697df62e7f172c2a77e6c7, it was accidentally being returned all the way up to the API user. After that commit, the dummy frame was unref'd so the user received an error. However, since that commit, VT hwaccel failures started causing random segfaults in the h264 decoder. This happened more often on iOS where the VT implementation is more likely to throw errors on bitstream anomolies. A recent report of this issue can be see in http://ffmpeg.org/pipermail/libav-user/2016-November/009831.html The issue here is that the dummy frame is still referenced internally by the h264 decoder, as part of the reflist and cur_pic_ptr. Deallocating the frame causes assertions like this one to trip later on during decoding: Assertion h->cur_pic_ptr->f->buf[0] failed at src/libavcodec/h264_slice.c:1340 With this commit, we leave the dummy 1-byte frame intact, but avoid returning it to the user. This reverts commit 9747219958060d8c4f697df62e7f172c2a77e6c7. Signed-off-by: wm4 <nfxjfg@googlemail.com>