aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/videotoolboxenc.c
Commit message (Collapse)AuthorAgeFilesLines
* avcodec/videotoolboxenc: Fix variable type of AV_OPT_TYPE_BOOLZhao Zhili2024-07-261-1/+1
| | | | Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* avcodec/videotoolboxenc: Set default bitrate to zeroZhao Zhili2024-07-261-0/+1
| | | | | | | | | | | | Zero is auto mode. From the doc of videotoolbox: The default bit rate is zero, which indicates that the video encoder should determine the size of compressed data. Before the patch, the default bitrate is 200000 setting by avcodec/options_table, which doesn't work for most of cases. Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* avcodec/videotoolboxenc: Fix bitrate doesn't work as expectedZhao Zhili2024-07-261-0/+9
| | | | | | | | Commit 4ef5e7d4722 add qmin/qmax support to videotoolbox encoder. The default value of (qmin, qmax) is (2, 31), which makes bitrate control doesn't work as users' expectations. Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* avcodec/videotoolboxenc: Put ExtraSEI inside BufNode directlyZhao Zhili2024-07-161-39/+21
| | | | | | Reduce error path and simplify the code. Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* avcodec/videotoolboxenc: Fix concurrent access to CVPixelBufferRefZhao Zhili2024-07-161-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | For a frame comes from AV_HWDEVICE_TYPE_VIDEOTOOLBOX, it's CVPixelBufferRef is maintained by a pool. CVPixelBufferRef returned to the pool when frame buffer reference reached to zero. However, VTCompressionSessionEncodeFrame also hold a reference to the CVPixelBufferRef. So a new frame get from av_hwframe_get_buffer may access a CVPixelBufferRef which still used by the encoder. It's only after vtenc_output_callback that we can make sure CVPixelBufferRef has been released by the encoder. The issue can be tested with sample from trac #10884. ffmpeg -hwaccel videotoolbox \ -hwaccel_output_format videotoolbox_vld \ -i input.mp4 \ -c:v hevc_videotoolbox \ -profile:v main \ -b:v 3M \ -vf scale_vt=w=iw/2:h=ih/2:color_matrix=bt709:color_primaries=bt709:color_transfer=bt709 \ -c:a copy \ -tag:v hvc1 \ output.mp4 Withtout the patch, there are some out of order images in output.mp4. Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* avcodec/videotoolboxenc: Use BufNode as sourceFrameRefconZhao Zhili2024-07-161-26/+51
| | | | | | | | | | | ExtraSEI is used as the sourceFrameRefcon of VTCompressionSessionEncodeFrame. It cannot hold other information which is necessary to fix another issue in the following patch. This patch also fixed leak of ExtraSEI on the error path of vtenc_output_callback. Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* avcodec/videotoolboxenc: Remove unused variableZhao Zhili2024-07-161-1/+0
| | | | Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* avcodec/videotoolboxenc: Don't ignore ENOMEMZhao Zhili2024-07-161-13/+16
| | | | Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* avcodec/videotoolboxenc: fix vtctx reset conditionHao Guan2024-07-071-1/+8
| | | | | | | | | | | In vtenc_populate_extradata, the cleanup function vtenc_reset should not be used when no error occurs, otherwise some color information is lost (#11036). This patch checks the status code and conducts the correct cleanup. Signed-off-by: Hao Guan <hguandl@gmail.com> Signed-off-by: Zhao Zhili <zhilizhao@tencent.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>
* all: use designated initializers for AVOption.unitAnton Khirnov2024-02-141-36/+36
| | | | | | | | | | | | | | | | | | | | | | | | Makes it robust against adding fields before it, which will be useful in following commits. Majority of the patch generated by the following Coccinelle script: @@ typedef AVOption; identifier arr_name; initializer list il; initializer list[8] il1; expression tail; @@ AVOption arr_name[] = { il, { il1, - tail + .unit = tail }, ... }; with some manual changes, as the script: * has trouble with options defined inside macros * sometimes does not handle options under an #else branch * sometimes swallows whitespace
* Revert "all: Don't set AVClass.item_name to its default value"Anton Khirnov2024-01-201-0/+3
| | | | | | | Some callers assume that item_name is always set, so this may be considered an API break. This reverts commit 0c6203c97a99f69dbaa6e4011d48c331e1111f5e.
* avcodec/videotoolboxenc: fix setting avctx color_range doesn't workZhao Zhili2024-01-121-1/+1
| | | | Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* avcodec/proresenc: make transparency honored in mov/QTClément Bœsch2024-01-061-0/+2
| | | | | | | | | In the mov muxer (in mov_write_video_tag()), bits_per_coded_sample will be written under certain conditions and is required to be 32 for the transparency to be honored in QuickTime. prores_kostya already has this setting but prores_anatoliy and prores_videotoolbox didn't.
* all: Don't set AVClass.item_name to its default valueAndreas Rheinhardt2023-12-221-3/+0
| | | | | | | | Unnecessary since acf63d5350adeae551d412db699f8ca03f7e76b9; also avoids relocations. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/videotoolboxenc: refactor dump encoder nameZhao Zhili2023-11-271-27/+38
| | | | Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* avcodec/videotoolboxenc: Fix build failure due to PropertyKey_EncoderIDZhao Zhili2023-11-271-1/+3
| | | | Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* avcodec/videotoolboxenc: Check and set hevc profileZhao Zhili2023-10-181-0/+18
| | | | | | | | | | | 1. If user don't specify the profile, set it to main10 when pixel format is 10 bits. Before the patch, videotoolbox output main profile bitstream with 10 bit input, which can be confusing. 2. Warning when user set profile to main explicitly with 10 bit input. It works, but not the best choice. 3. Reject main 10 profile with 8 bit input, it doesn't work. Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* avcodec/videotoolboxenc: add hw_configsZhao Zhili2023-10-181-0/+9
| | | | | | | | | Will be used in the following patch. With hw_config we can get avctx->hw_frames_ctx, and with avctx->hw_frames_ctx we get sw_pix_fmt. Otherwise sw_pix_fmt is none. I need sw_pix_fmt before get the first frame to set hevc encoder profile. Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* lavc/videotoolboxenc: Get the encoder supported propertiesJun Zhao2023-09-151-23/+49
| | | | | | | Get the encoder supported properties list, it will be used for feature support checks. Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
* lavc/videotoolboxenc: Dump the encoderJun Zhao2023-09-151-0/+28
| | | | | | Dump the encoder, it's will help debug some case Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
* avcodec/defs: Add AV_PROFILE_* defines, deprecate FF_PROFILE_* definesAndreas Rheinhardt2023-09-071-39/+39
| | | | | | | | | 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>
* avcodec/videotoolboxenc: use color parameters conversion from avutilZhao Zhili2023-07-231-124/+13
| | | | Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* lavc/videotoolboxenc: fix enabling low-latency encodexufuji4562023-07-021-11/+7
| | | | | | | | | Use CFDictionarySetValue to enable low-latency encoding mode. Since the key is a type of "EncoderSpecification", instead of "CompressionProperty". Signed-off-by: xufuji456 <839789740@qq.com> Signed-off-by: Rick Kern <kernrj@gmail.com>
* avcodec/videotoolboxenc: inherit profile from AVCodecContextZhao Zhili2023-06-191-0/+3
| | | | | | | This can happen when user set the avctx->profile field directly instead of specify profile via option. Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* avcodec/videotoolboxenc: remove AUTO_PROFILE defineZhao Zhili2023-06-191-6/+5
| | | | | | Use FF_PROFILE_UNKNOWN as auto mode. Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* avcodec/videotoolboxenc: use int as the type of profileZhao Zhili2023-06-191-8/+8
| | | | | | | | | | | Other than save a few bytes, it also has the benefit to show the AV_OPT_TYPE_CONST value in help, e.g., -profile <int> E..V....... Profile (from 0 to INT_MAX) (default 0) baseline 66 E..V....... Baseline Profile ... Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* lavc/videotoolboxenc: support additional optionsRick Kern2023-06-031-1/+121
| | | | | | | | | | | Added support for more VideoToolbox encoder options: - qmin and qmax options are now used - max_slice_bytes: Max number of bytes per H.264 slice - max_ref_frames: Limit the number of reference frames - Disable open GOP when the cgop flag is set - power_efficient: Enable power-efficient mode Signed-off-by: Rick Kern <kernrj@gmail.com>
* avcodec/videotoolboxenc: add CBP/CHP profilexufuji4562023-06-031-4/+34
| | | | | | | The CBP/CHP profile has available with H264 in iOS 15.0. Official Doc: https://developer.apple.com/documentation/videotoolbox/kvtprofilelevel_h264_constrainedbaseline_autolevel Signed-off-by: Rick Kern <kernrj@gmail.com>
* lavc/videotoolboxenc: use ffmpeg profile constantsRick Kern2023-06-031-35/+22
| | | | Signed-off-by: Rick Kern <kernrj@gmail.com>
* lavc/videotoolboxenc: warn when alpha quality not setRick Kern2023-05-201-0/+7
| | | | | | Added a warn log when alpha quality cannot be set, but continue encoding. Signed-off-by: Rick Kern <kernrj@gmail.com>
* lavc/videotoolboxenc: better compat_keys docsRick Kern2023-05-201-3/+13
| | | | | | | Added more specific docs about when to use compat_keys, and how to add new constants. Signed-off-by: Rick Kern <kernrj@gmail.com>
* lavc/videotoolboxenc: better compat_keys documentationRick Kern2023-05-191-1/+5
| | | | | | | Added documentation that describes when compat_keys should be used, and why it exists. Signed-off-by: Rick Kern <kernrj@gmail.com>
* avcodec/videotoolboxenc: add low-latency encodingxufuji4562023-05-191-0/+14
| | | | | | | | When using low-latency mode, it eliminates frame reordering and follows a one-in-one-out encoding mode Signed-off-by: xufuji456 <839789740@qq.com> Signed-off-by: Rick Kern <kernrj@gmail.com>
* lavc/videotoolboxenc: fix warningsJun Zhao2023-04-091-3/+3
| | | | | | | fix mixing declarations and code and function declaration without a prototype warnings Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
* avcodec/videotoolboxenc: fix error codeZhao Zhili2023-01-111-2/+6
| | | | | | | 1. Fix return 0 on error. 2. Fix return OS error code passthrough. Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* avcodec/videotoolboxenc: pass error code throughZhao Zhili2023-01-111-2/+2
| | | | Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* avcodec/videotoolboxenc: log when get_cv_pixel_format failedZhao Zhili2023-01-111-12/+11
| | | | Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* lavc/videotoolboxenc: fix warningsRick Kern2022-12-031-2/+4
| | | | | | This handles an unhandled error, and removes an unnecessary variable. Signed-off-by: Rick Kern <kernrj@gmail.com>
* lavc/videotoolboxenc: Fix crash by uninitialized valueThilo Borgmann2022-09-211-3/+1
| | | | If create_cv_pixel_buffer() fails, pixel_buffer_info might get into CFRelease() containing an arbitrary value.
* avcodec/codec_internal: Add macro to set AVCodec.long_nameAndreas Rheinhardt2022-09-031-3/+3
| | | | | | | | It reduces typing: Before this patch, there were 105 codecs whose long_name-definition exceeded the 80 char line length limit. Now there are only nine of them. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/videotoolboxenc: Add CBR option to H264 and HEVC encoderSebastian Beckmann2022-08-291-3/+24
| | | | | | | | | Adds an option to use constant bitrate instead of average bitrate to the videotoolbox encoders. This is enabled via -constant_bit_rate true. macOS 13 is required for this option to work. Signed-off-by: Sebastian Beckmann <beckmann.sebastian@outlook.de> Signed-off-by: Rick Kern <kernrj@gmail.com>
* avcodec: Make init-threadsafety the defaultAndreas Rheinhardt2022-07-181-6/+3
| | | | | | | | | | | and remove FF_CODEC_CAP_INIT_THREADSAFE All our native codecs are already init-threadsafe (only wrappers for external libraries and hwaccels are typically not marked as init-threadsafe yet), so it is only natural for this to also be the default state. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* lavc/videotoolboxenc: Speed/Quality prioriry settingSimone Karin Lehmann2022-05-021-1/+16
| | | | | | | | Add options to h264, hevc and prores encoders to prioritize speed. Speeds up encoding by 50% - 70% Signed-off-by: Simone Karin Lehmann <simone@lisanet.de> Signed-off-by: Rick Kern <kernrj@gmail.com>
* avcodec/codec_internal: Use union for FFCodec decode/encode callbacksAndreas Rheinhardt2022-04-051-3/+3
| | | | | | | | | | | 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-211-26/+26
| | | | | | | | | | | | | | | | 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-211-0/+1
| | | | | | | | | | 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-221-3/+3
| | | | | | 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-221-8/+8
| | | | | 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-221-6/+114
|