summaryrefslogtreecommitdiff
path: root/libavcodec/videotoolboxenc.c
Commit message (Collapse)AuthorAge
* avcodec/codec_internal: Use union for FFCodec decode/encode callbacksAndreas Rheinhardt2022-04-05
| | | | | | | | | | | This is possible, because every given FFCodec has to implement exactly one of these. Doing so decreases sizeof(FFCodec) and therefore decreases the size of the binary. Notice that in case of position-independent code the decrease is in .data.rel.ro, so that this translates to decreased memory consumption. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/codec_internal: Add FFCodec, hide internal part of AVCodecAndreas Rheinhardt2022-03-21
| | | | | | | | | | | | | | | | Up until now, codec.h contains both public and private parts of AVCodec. This exposes the internals of AVCodec to users and leads them into the temptation of actually using them and forces us to forward-declare structures and types that users can't use at all. This commit changes this by adding a new structure FFCodec to codec_internal.h that extends AVCodec, i.e. contains the public AVCodec as first member; the private fields of AVCodec are moved to this structure, leaving codec.h clean. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/internal: Move FF_CODEC_CAP_* to a new header codec_internal.hAndreas Rheinhardt2022-03-21
| | | | | | | | | | Also move FF_CODEC_TAGS_END as well as struct AVCodecDefault. This reduces the amount of files that have to include internal.h (which comes with quite a lot of indirect inclusions), as e.g. most encoders don't need it. It is furthemore in preparation for moving the private part of AVCodec out of the public codec.h. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* lavc/videotoolboxenc: explicitly set realtime=falsercombs2021-12-22
| | | | | | On some encoders, this defaults to true, which can result in encode speed being _limited_ to only slightly above realtime (as a power-saving measure), so we need a way to disable it.
* libavcodec/videotoolboxenc: use the correct types for optionsrcombs2021-12-22
| | | | | These are all set by AV_OPT_TYPE_INT or AV_OPT_TYPE_BOOL; the only reason they worked before was that this is only used on little-endian.
* lavc/videotoolboxenc: add ProRes supportrcombs2021-12-22
|
* lavc/videotoolboxenc: add handling for non-NAL-based codecsrcombs2021-12-22
|
* lavc/videotoolboxenc: vastly simplify get_cv_pixel_inforcombs2021-12-22
| | | | | | No longer requires per-format switch cases. The frame==0 path was unused (and would've crashed anyway).
* lavc/videotoolboxenc: config-gate ATSC CC supportrcombs2021-12-22
|
* lavc/videotoolboxenc: fix RGB supportrcombs2021-12-22
|
* lavc/videotoolboxenc: detect alpha more genericallyrcombs2021-12-22
| | | | Fixes support for alpha in hardware input frames
* lavc/videotoolboxenc: don't access int64_t member as intrcombs2021-12-22
|
* lavc/videotoolboxenc: use common routine for pixfmt conversionrcombs2021-12-22
|
* avcodec/videotoolboxenc: fix pixel buffer memory leaksongyutong2021-11-09
| | | | | | | | In function vtenc_populate_extradata(), there is a manually created pixel buffer that has not been released. So we should use CVPixelBufferRelease to release this pixel buffer at the end, otherwise will cause a memory leak. Signed-off-by: Rick Kern <kernrj@gmail.com>
* avcodec/videotoolboxenc: use goto end for memory cleanupLimin Wang2021-10-13
| | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avcodec/videotoolboxenc: Fixes non-B-Frame encodingNoHalfBits2021-09-27
| | | | | | | | | | | | Sets vtctx->has_b_frames to 0 if the VideoToolbox compression session will not emit B-frames (and, in consequence, no valid DTSs). Required for the handling of invalid DTSs in 'vtenc_cm_to_avpacket' (line 2018ff) to work correctly and not abort encoding with "DTS is invalid." when no B-frames are generated. Signed-off-by: NoHalfBits <ffmpeg-devel@fluthaus.com> Signed-off-by: Rick Kern <kernrj@gmail.com>
* Fix for bug #9231: B-frames parameter is ignored in videotoolboxencAnselm Busse2021-08-13
| | | | | | | | | This commit fixes the bug as report in https://trac.ffmpeg.org/ticket/9231 by removing the line that overwrites the user settings for max_b_frames. Signed-off-by: Anselm Busse <anselm.busse@outlook.com> Signed-off-by: Rick Kern <kernrj@gmail.com>
* lavc/videotoolboxenc.c: Fix preprocessor macro for OSX 10.10.5 and probably ↵Thilo Borgmann2021-06-14
| | | | older versions
* avcodec/videotoolboxenc: #define TARGET_CPU_ARM64 to 0 if not provided by ↵Zane van Iperen2021-05-19
| | | | | | | | | | the SDK Fixes build failure on older SDKs without it. Fixes #9242 Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
* avcodec/videotoolboxenc: Avoid copying data, allow user-supplied buffersAndreas Rheinhardt2021-05-06
| | | | | | | | | | | Here the packet size is known before allocating the packet because the encoder provides said information (and works with internal buffers itself), so one use this information to avoid the implicit use of another intermediate buffer for the packet data; and by switching to ff_get_encode_buffer() one can also allow user-supplied buffers. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: Rick Kern <kernrj@gmail.com>
* lavc/videotoolboxenc: set DataRateLimits for hevcZhao Zhili2021-05-06
| | | | | | | | From the comment it's not available on old version. It works now by testing on macOS 11.2.1. There is no document about since when. So trying to set the configuration and ignore the error for hevc. Signed-off-by: Rick Kern <kernrj@gmail.com>
* avcodec: Constify AVCodecsAndreas Rheinhardt2021-04-27
| | | | | | | | | | Given that the AVCodec.next pointer has now been removed, most of the AVCodecs are not modified at all any more and can therefore be made const (as this patch does); the only exceptions are the very few codecs for external libraries that have a init_static_data callback. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* lavc/videotoolboxenc: Add support for HEVC with Alpha.Hironori Bono2021-03-19
| | | | | | | | | | | | | | | This change supports the "HEVC Video with Alpha" profile introduced in WWDC 2019 <https://developer.apple.com/videos/play/wwdc2019/506/>. (This change is a partial fix for Ticket #7965.) For example, the following command converts an animation PNG file to an HEVC with Alpha video: ./ffmpeg -i fate-suite/apng/clock.png -c:v hevc_videotoolbox -allow_sw 1 -alpha_quality 0.75 -vtag hvc1 clock.mov (This change uses the "HEVC Video with Alpha" profile only when the '-alpha_quality' value is not 0 for backward compatibility.) Signed-off-by: Hironori Bono <bouno@rouge.plala.or.jp>
* videotoolboxenc: enable constant quality with -q:v on Apple Silicon Macs and ↵Simone Karin Lehmann2021-03-19
| | | | | | | use b-frames für HEVC and H264 and b-pyramid for HEVC. Signed-off-by: Simone Karin Lehmann <simone@lisanet.de> Signed-off-by: Rick Kern <kernrj@gmail.com>
* avcodec/videotoolboxenc: Fix SEI enum identifiersAndreas Rheinhardt2021-01-22
| | | | | | | Broken in 64b3aac8d07a8744656737619b70977359d9a6a5. Tested-by: Mark Himsley <mark.himsley@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* h264: Use common SEI typesMark Thompson2021-01-21
|
* libavcodec/videotoolboxenc: Fix crash when frame received after errorRick Kern2020-09-28
| | | | Signed-off-by: Rick Kern <kernrj@gmail.com>
* avcodec/videotoolboxenc: move pthread_cond_signal after add buffer to the queueTian Qi2020-09-28
| | | | | | | | | | | | | In the VT encoding insertion by FFmpeg, and vtenc_q_push is callback to add the encoded data to the singly linked list group in VTEncContext, and consumers are notified to fetch it. However, because it first informs consumers of pthread_cond_signal, and then inserts the data into the tail, there is a multi-thread safety hazard. Signed-off-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Rick Kern <kernrj@gmail.com>
* avcodec/videotoolboxenc: don't wait when flushing dataTian Qi2020-09-28
| | | | | | | | | | because there is run in thread mode, few times will block the workflow at the wait, so check the status is flushing data, don't wait when flushing data. Signed-off-by: Tian Qi <tianqi@kuaishou.com> Signed-off-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Rick Kern <kernrj@gmail.com>
* avcodec/videotoolboxenc: fix use after destroyZhao Zhili2020-09-28
| | | | | | The lock is used in clear_frame_queue(). Signed-off-by: Rick Kern <kernrj@gmail.com>
* avcodec/videotoolboxenc: fix align issueZhao Zhili2020-09-28
| | | | | | | | bool a53_cc is accessed as int: src/libavutil/opt.c:129:9: runtime error: store to misaligned address 0x7fbf454121a3 for type 'int', which requires 4 byte alignment Signed-off-by: Rick Kern <kernrj@gmail.com>
* avcodec/videotoolboxenc: Allow full range 10bit pixel format inputHarry Mallon2020-09-28
| | | | | Signed-off-by: Harry Mallon <harry.mallon@codex.online> Signed-off-by: Rick Kern <kernrj@gmail.com>
* avcodec/videotoolboxenc: Set profile (main/main10) on HEVC encodeHarry Mallon2020-09-28
| | | | | Signed-off-by: Harry Mallon <harry.mallon@codex.online> Signed-off-by: Rick Kern <kernrj@gmail.com>
* avcodec: move ff_alloc_a53_sei() to atsc_53James Almer2020-08-15
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec: Add more kCVImageBufferColorPrimaries to videotoolboxencNomis1012019-11-17
| | | | Signed-off-by: Rick Kern <kernrj@gmail.com>
* avcodec/videotoolboxenc: warn user when output will use a different ↵Rick Kern2019-09-16
| | | | | | profile/level than requested. Signed-off-by: Rick Kern <kernrj@gmail.com>
* avcodec/videotoolboxenc: add H264 Extended profile and levelLimin Wang2019-09-16
| | | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com> Signed-off-by: Rick Kern <kernrj@gmail.com>
* avcodec/videotoolboxenc: fix encoding frame crash on iOS 11sharpbai2019-09-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | On iOS 11, encoding a frame may return error with log "Error encoding frame 0", which means vtenc_output_callback is called with status=0 and sample_buffer=NULL. Then the encoding session will be crashed on next callback wether or not closing the codec context. Let us look through the link below introducing VTCompressionOutputCallback, https://developer.apple.com/documentation/videotoolbox/vtcompressionoutputcallback?language=objc "status=0" (noErr) means compression was successful. "sampleBuffer=NULL" means the frame was dropped when compression was successful (status=0) or compression was not successful (status!=0). So we should not set AVERROR_EXTERNAL on "status=0" and "sample_buffer=NULL" as it is not a error. The fix is that we only set AVERROR_EXTERNAL with status value non zero. When sample_buffer is NULL and status value is zero, we simply return with no other operation. This crash often occurs on iOS 11 for example encoding 720p@25fps. Signed-off-by: sharpbai <sharpbai@gmail.com> Signed-off-by: Rick Kern <kernrj@gmail.com>
* lavc/videotoolboxenc: make transfer_fnc initialized for unsupport functionLimin Wang2019-08-11
| | | | | | | | The current function will report one error message, but the caller func haven't check it, so change the default to process as AVCOL_TRC_UNSPECIFIED. Signed-off-by: Limin Wang <lance.lmwang@gmail.com> Signed-off-by: Rick Kern <kernrj@gmail.com>
* lavc/videotoolboxenc: add hdr10, linear, hlg color transfer function for ↵Limin Wang2019-08-11
| | | | | | | | | | | | videotoolboxenc Below is the testing ffmpeg command for the setting: ./ffmpeg -i input.ts -c:v hevc_videotoolbox -color_primaries bt2020 -colorspace bt2020_ncl -color_trc smpte2084 smpte2048.ts ./ffmpeg -i input.ts -c:v hevc_videotoolbox -color_primaries bt2020 -colorspace bt2020_ncl -color_trc linear linear.ts ./ffmpeg -i input.ts -c:v hevc_videotoolbox -color_primaries bt2020 -colorspace bt2020_ncl -color_trc arib-std-b67 hlg.ts Signed-off-by: Limin Wang <lance.lmwang@gmail.com> Signed-off-by: Rick Kern <kernrj@gmail.com>
* avcodec/videotoolboxenc: remove unused variableSteven Liu2019-07-11
| | | | Signed-off-by: Steven Liu <lq@onvideo.cn>
* libavcodec/videotoolboxenc: Fix compilation broken on macOS 10.12Limin Wang2019-06-17
| | | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com> Signed-off-by: Rick Kern <kernrj@gmail.com>
* lavc/videotoolboxenc: Add support for 10-bit HEVC encoding.Rick Kern2019-05-12
| | | | | | | | | Hardware-accelerated encoding may not support 10-bit encoding. Use '-require_sw 1' in this case. Fixes: #7581 Signed-off-by: Rick Kern <kernrj@gmail.com>
* lavc/videotoolboxenc: simplify frame creation logic between OS X and iOS.Rick Kern2019-05-12
| | | | Signed-off-by: Rick Kern <kernrj@gmail.com>
* lavc/videotoolboxenc: add require_sw option to force software encoding.Rick Kern2019-05-12
| | | | Signed-off-by: Rick Kern <kernrj@gmail.com>
* lavc/videotoolboxenc: Fix compilation on osx 10.10.5 YosemiteThilo Borgmann2018-08-14
| | | | Signed-off-by: Aman Gupta <aman@tmm1.net>
* avcodec/videotoolboxenc: fix undefined behavior with rc_max_rate=0Thomas Guillem2018-07-19
| | | | | | | | | | | On macOS, a zero rc_max_rate cause an error from VTSessionSetProperty(kVTCompressionPropertyKey_DataRateLimits). on iOS (depending on device/version), a zero rc_max_rate cause invalid arguments from the vtenc_output_callback after few frames and then a crash within the VideoToolbox library. Signed-off-by: Aman Gupta <aman@tmm1.net>
* avcodec/videotoolboxenc: fix invalid session on iOSThomas Guillem2018-06-18
| | | | | | | Cf. comment. Restart the VT session when the APP goes from foreground to background and vice versa. Signed-off-by: Aman Gupta <aman@tmm1.net>
* avcodec/videotoolboxenc: split initializationThomas Guillem2018-06-18
| | | | | | | | | Split vtenc_init() into vtenc_init() (VTEncContext initialization) and vtenc_configure_encoder() (creates the vt session). This commit will allow to restart the vt session while encoding. Signed-off-by: Aman Gupta <aman@tmm1.net>
* avcodec/videotoolboxenc: fix mutex/cond leak in error pathThomas Guillem2018-06-18
| | | | | | The leak could happen when the vtenc_create_encoder() function failed. Signed-off-by: Aman Gupta <aman@tmm1.net>