1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00
Commit Graph

122 Commits

Author SHA1 Message Date
Andreas Rheinhardt
790f793844 avutil/common: Don't auto-include mem.h
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>
2024-03-31 00:08:43 +01:00
Anton Khirnov
1e7d2007c3 all: use designated initializers for AVOption.unit
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
2024-02-14 14:53:41 +01:00
Anton Khirnov
08bebeb1be Revert "all: Don't set AVClass.item_name to its default value"
Some callers assume that item_name is always set, so this may be
considered an API break.

This reverts commit 0c6203c97a.
2024-01-20 10:34:48 +01:00
Zhao Zhili
13c1fea92f avcodec/videotoolboxenc: fix setting avctx color_range doesn't work
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2024-01-12 10:49:18 +08:00
Clément Bœsch
2142141a16 avcodec/proresenc: make transparency honored in mov/QT
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.
2024-01-06 17:29:59 +01:00
Andreas Rheinhardt
0c6203c97a all: Don't set AVClass.item_name to its default value
Unnecessary since acf63d5350adeae551d412db699f8ca03f7e76b9;
also avoids relocations.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-12-22 15:12:33 +01:00
Zhao Zhili
d526a34c20 avcodec/videotoolboxenc: refactor dump encoder name
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-11-27 23:49:01 +08:00
Zhao Zhili
cb049d377f avcodec/videotoolboxenc: Fix build failure due to PropertyKey_EncoderID
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-11-27 23:48:55 +08:00
Zhao Zhili
2361970880 avcodec/videotoolboxenc: Check and set hevc profile
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>
2023-10-18 23:05:14 +08:00
Zhao Zhili
cbb6199ff8 avcodec/videotoolboxenc: add hw_configs
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>
2023-10-18 23:02:12 +08:00
Jun Zhao
5c635b7d8c lavc/videotoolboxenc: Get the encoder supported properties
Get the encoder supported properties list, it will be used for
feature support checks.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2023-09-15 21:08:21 +08:00
Jun Zhao
213cba9696 lavc/videotoolboxenc: Dump the encoder
Dump the encoder, it's will help debug some case

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2023-09-15 21:07:46 +08:00
Andreas Rheinhardt
8238bc0b5e avcodec/defs: Add AV_PROFILE_* defines, deprecate FF_PROFILE_* defines
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>
2023-09-07 00:39:02 +02:00
Zhao Zhili
6c90fcd9e6 avcodec/videotoolboxenc: use color parameters conversion from avutil
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-07-23 11:51:42 +08:00
xufuji456
5930d397ef lavc/videotoolboxenc: fix enabling low-latency encode
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>
2023-07-02 12:02:51 -04:00
Zhao Zhili
f66e1862e3 avcodec/videotoolboxenc: inherit profile from AVCodecContext
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>
2023-06-19 12:19:37 +08:00
Zhao Zhili
3fafc842f1 avcodec/videotoolboxenc: remove AUTO_PROFILE define
Use FF_PROFILE_UNKNOWN as auto mode.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-06-19 12:19:37 +08:00
Zhao Zhili
315c66af0f avcodec/videotoolboxenc: use int as the type of profile
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>
2023-06-19 12:19:37 +08:00
Rick Kern
4ef5e7d472 lavc/videotoolboxenc: support additional options
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>
2023-06-03 17:29:07 -04:00
xufuji456
decc776f88 avcodec/videotoolboxenc: add CBP/CHP profile
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>
2023-06-03 17:29:07 -04:00
Rick Kern
cab6d7bd71 lavc/videotoolboxenc: use ffmpeg profile constants
Signed-off-by: Rick Kern <kernrj@gmail.com>
2023-06-03 17:29:06 -04:00
Rick Kern
247e977953 lavc/videotoolboxenc: warn when alpha quality not set
Added a warn log when alpha quality cannot be set, but continue encoding.

Signed-off-by: Rick Kern <kernrj@gmail.com>
2023-05-20 11:42:12 -04:00
Rick Kern
902c949d30 lavc/videotoolboxenc: better compat_keys docs
Added more specific docs about when to use compat_keys, and how to
add new constants.

Signed-off-by: Rick Kern <kernrj@gmail.com>
2023-05-20 11:42:12 -04:00
Rick Kern
c789a2324a lavc/videotoolboxenc: better compat_keys documentation
Added documentation that describes when compat_keys should be used,
and why it exists.

Signed-off-by: Rick Kern <kernrj@gmail.com>
2023-05-19 09:48:26 -04:00
xufuji456
5cd304298e avcodec/videotoolboxenc: add low-latency encoding
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>
2023-05-19 09:40:28 -04:00
Jun Zhao
aa8ff2240c lavc/videotoolboxenc: fix warnings
fix mixing declarations and code and function
declaration without a prototype warnings

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2023-04-09 18:11:58 +08:00
Zhao Zhili
8f35ee8240 avcodec/videotoolboxenc: fix error code
1. Fix return 0 on error.
2. Fix return OS error code passthrough.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-01-11 18:57:44 +08:00
Zhao Zhili
0ef85a5471 avcodec/videotoolboxenc: pass error code through
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-01-11 18:57:20 +08:00
Zhao Zhili
5ab429d8df avcodec/videotoolboxenc: log when get_cv_pixel_format failed
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-01-11 18:57:20 +08:00
Rick Kern
33e70dc0b8 lavc/videotoolboxenc: fix warnings
This handles an unhandled error, and removes an unnecessary variable.

Signed-off-by: Rick Kern <kernrj@gmail.com>
2022-12-03 11:19:56 -05:00
Thilo Borgmann
2ca2d46f0b lavc/videotoolboxenc: Fix crash by uninitialized value
If create_cv_pixel_buffer() fails, pixel_buffer_info might get into CFRelease() containing an arbitrary value.
2022-09-21 13:39:55 +02:00
Andreas Rheinhardt
48286d4d98 avcodec/codec_internal: Add macro to set AVCodec.long_name
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>
2022-09-03 15:42:57 +02:00
Sebastian Beckmann
47b85c5a76 avcodec/videotoolboxenc: Add CBR option to H264 and HEVC encoder
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>
2022-08-29 09:34:20 -04:00
Andreas Rheinhardt
21b23ceab3 avcodec: Make init-threadsafety the default
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>
2022-07-18 20:04:59 +02:00
Simone Karin Lehmann
b67572c7c7 lavc/videotoolboxenc: Speed/Quality prioriry setting
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>
2022-05-02 08:10:22 -07:00
Andreas Rheinhardt
4243da4ff4 avcodec/codec_internal: Use union for FFCodec decode/encode callbacks
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>
2022-04-05 20:02:37 +02:00
Andreas Rheinhardt
20f9727018 avcodec/codec_internal: Add FFCodec, hide internal part of AVCodec
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>
2022-03-21 01:33:09 +01:00
Andreas Rheinhardt
a688f3c13c avcodec/internal: Move FF_CODEC_CAP_* to a new header codec_internal.h
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>
2022-03-21 01:33:09 +01:00
rcombs
4778ab2b1f lavc/videotoolboxenc: explicitly set realtime=false
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.
2021-12-22 18:43:34 -06:00
rcombs
802c051506 libavcodec/videotoolboxenc: use the correct types for options
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.
2021-12-22 18:43:34 -06:00
rcombs
18192166e7 lavc/videotoolboxenc: add ProRes support 2021-12-22 18:38:40 -06:00
rcombs
2bb5edc38c lavc/videotoolboxenc: add handling for non-NAL-based codecs 2021-12-22 18:38:40 -06:00
rcombs
30539394bb lavc/videotoolboxenc: vastly simplify get_cv_pixel_info
No longer requires per-format switch cases.

The frame==0 path was unused (and would've crashed anyway).
2021-12-22 18:38:40 -06:00
rcombs
c8323350f4 lavc/videotoolboxenc: config-gate ATSC CC support 2021-12-22 18:38:40 -06:00
rcombs
7644c6224f lavc/videotoolboxenc: fix RGB support 2021-12-22 18:38:40 -06:00
rcombs
e55db79612 lavc/videotoolboxenc: detect alpha more generically
Fixes support for alpha in hardware input frames
2021-12-22 18:38:40 -06:00
rcombs
2acb13cb93 lavc/videotoolboxenc: don't access int64_t member as int 2021-12-22 18:38:40 -06:00
rcombs
028a6ed1a1 lavc/videotoolboxenc: use common routine for pixfmt conversion 2021-12-22 18:38:40 -06:00
songyutong
8a969e1280 avcodec/videotoolboxenc: fix pixel buffer memory leak
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>
2021-11-09 07:14:39 -05:00
Limin Wang
871fee82e1 avcodec/videotoolboxenc: use goto end for memory cleanup
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-10-13 20:12:30 +08:00