diff --git a/decrypter/0_latest.txt b/decrypter/0_latest.txt index f5f90552..4e57998e 100644 --- a/decrypter/0_latest.txt +++ b/decrypter/0_latest.txt @@ -1,26 +1,24 @@ -# 19417 -s 17 +# 19660 +s 67 c 1 -R -s 65 +s 31 > -r -800848978 -R -e 330905968 -r -1801395041 -r -45203544 -r 969944705 -s -1266939812 -s 1071587255 -r 2070384319 -t hwadna7 Aa0-_ -s 61910453 -R -t UDjUn 0aA-_ -r -1700764381 -R -R -r 859083917 -r -2140614363 -r -307172264 +t split Aa0-_ +e 349754986 +s 1399367760 +e 1563194841 +r 1680918897 +s -1227273718 +r 945509789 +s -386866156 +r -2141966360 +r -505298648 +e 349713772 +r 1006958380 +e 191776033 +r 1956089104 +t finally Aa0-_ +s -1467723118 +s -703780294 +s 1903244263 R diff --git a/decrypter/README.md b/decrypter/README.md new file mode 100644 index 00000000..0c17c2b8 --- /dev/null +++ b/decrypter/README.md @@ -0,0 +1,55 @@ +## YouTube "decrypter" file +YouTube employs some measures for anti-third-party client. Something called "signature cipher" or "n parameter" is one of them. +We can fetch stream URLs from `ytInitialPlayerResponse` in the video page or `/player` endpoint, but the URLs are unusable or rate-limited without some parameter conversion. +The conversion is done in `base.js` on the official web client, and the process seems to be always a combination of a certain simple operations. +We could download `base.js` and execute the conversion code on ThirdTube, but `base.js` is a large(1~2 MB) file and it slows down video loading, +so we make a text file(2-300 B) describing the operations in the conversion process and let the app load it. +This document describes the format of the file. + +## How ThirdTube loads the file +1. embedded in romfs of the app file (updated with the ThirdTube releases) +2. local cache (updated along with 3.) +3. `decrypter/0_latest.txt` in this repository (latest) + +On startup, the app loads the decrypter in the following order, and uses the last one that is succeeded to load. + +## How to find conversion function in base.js + +### sig +1. Search for `a=a.split("")`. It should be at the start of a function, followed by \[VAR\].\[FUNC\](a,[x]). The function is the conversion function. +2. Search for `var [VAR]=` to see the content of `FUNC`s. + +### n +1. Search for `("n")`. The unique match should be followed by `&&(b=[ARR][0](b))`. +2. Go for the defintion of `[ARR]` by searching `var [ARR]` and get the conversion function name + +## Format +``` +# [STS] +[one or more lines for "sig" conversion] +> +[one or more lines for "n" conversion] +``` +`STS` is like a version of the decrypter and seems to be the day count from unix epoch to the deployment of the decrypter. +A line for "sig"/"n" conversion is one of the following: +`s [x]` : **s**wap `a[0]` and `a[x mod a.size()]` +`e [x]` : **e**rase `a[x mod a.size()]` from `a` +`c [x]` : (**c**ut) erase the first `x` items of `a` +`r [x]` : **r**otate `a` right for `x mod a.size()` items +`R` : reverse `a` +`t [key] [charset]` : **t**ransform `a` with the following procedure: + + 1. Replace `A` in `charset` with `ABC...Z` (string containing all latin uppercase letters in order) + 2. Replace `a` in `charset` with `abc...z` (string containing all latin lowercase letters in order) + 3. Replace `0` in `charset` with `012...9` (string containing all digit letters in order) + (These three steps are done in order to be able to compress the "decrypter" file) + 4. Let f(c) be the index in `charset` at which the character `c` appears + 5. For $i = 0, 1, 2, ..., \mathrm{a.size()-1}$ do the following : + 1. Assign `charset[(f(a[i]) - f(key[i])) mod 64]` to `a[i]` (64 is always equal to `charset.size()`) + 2. Push `a[i]` to the back of `key` + +Here, `a` denotes the original string of "sig"/"n" parameter and `x mod y` denotes an integer between $0$ and $y - 1$ that is congruent to $x$ mod $y$. +When the url of the streams are fetched, ThirdTube converts the `sig` parameter by executing the lines for `sig` conversion in order and `n` in the same way. +While YouTube updates the decrypter regularly (around every three days?), we can use old decrypter by requesting the stream with old `STS`. +However, they seem to invalidate decrypters older than 2-3 weeks, so we have to update the decrypter regularly. + diff --git a/decrypter/archive/0/19660.txt b/decrypter/archive/0/19660.txt new file mode 100644 index 00000000..4e57998e --- /dev/null +++ b/decrypter/archive/0/19660.txt @@ -0,0 +1,24 @@ +# 19660 +s 67 +c 1 +s 31 +> +t split Aa0-_ +e 349754986 +s 1399367760 +e 1563194841 +r 1680918897 +s -1227273718 +r 945509789 +s -386866156 +r -2141966360 +r -505298648 +e 349713772 +r 1006958380 +e 191776033 +r 1956089104 +t finally Aa0-_ +s -1467723118 +s -703780294 +s 1903244263 +R diff --git a/library/FFmpeg/FFmpeg b/library/FFmpeg/FFmpeg index a594675f..125da06c 160000 --- a/library/FFmpeg/FFmpeg +++ b/library/FFmpeg/FFmpeg @@ -1 +1 @@ -Subproject commit a594675f73228163895737b4e7db857d5dba0566 +Subproject commit 125da06c6a2cbc35945782b76097f45d0472cfaf diff --git a/library/FFmpeg/include/libavcodec/avcodec.h b/library/FFmpeg/include/libavcodec/avcodec.h index 8b97895a..7fb44e28 100644 --- a/library/FFmpeg/include/libavcodec/avcodec.h +++ b/library/FFmpeg/include/libavcodec/avcodec.h @@ -27,29 +27,34 @@ * Libavcodec external API header */ -#include #include "libavutil/samplefmt.h" #include "libavutil/attributes.h" #include "libavutil/avutil.h" #include "libavutil/buffer.h" -#include "libavutil/cpu.h" #include "libavutil/channel_layout.h" #include "libavutil/dict.h" #include "libavutil/frame.h" -#include "libavutil/hwcontext.h" #include "libavutil/log.h" #include "libavutil/pixfmt.h" #include "libavutil/rational.h" -#include "bsf.h" #include "codec.h" -#include "codec_desc.h" -#include "codec_par.h" #include "codec_id.h" #include "defs.h" #include "packet.h" +#include "version_major.h" +#ifndef HAVE_AV_CONFIG_H +/* When included as part of the ffmpeg build, only include the major version + * to avoid unnecessary rebuilds. When included externally, keep including + * the full version information. */ #include "version.h" +#include "codec_desc.h" +#include "codec_par.h" +#endif + +struct AVCodecParameters; + /** * @defgroup libavc libavcodec * Encoding/Decoding Library @@ -225,11 +230,76 @@ typedef struct RcOverride{ * Use qpel MC. */ #define AV_CODEC_FLAG_QPEL (1 << 4) +#if FF_API_DROPCHANGED /** * Don't output frames whose parameters differ from first * decoded frame in stream. + * + * @deprecated callers should implement this functionality in their own code */ #define AV_CODEC_FLAG_DROPCHANGED (1 << 5) +#endif +/** + * Request the encoder to output reconstructed frames, i.e.\ frames that would + * be produced by decoding the encoded bistream. These frames may be retrieved + * by calling avcodec_receive_frame() immediately after a successful call to + * avcodec_receive_packet(). + * + * Should only be used with encoders flagged with the + * @ref AV_CODEC_CAP_ENCODER_RECON_FRAME capability. + * + * @note + * Each reconstructed frame returned by the encoder corresponds to the last + * encoded packet, i.e. the frames are returned in coded order rather than + * presentation order. + * + * @note + * Frame parameters (like pixel format or dimensions) do not have to match the + * AVCodecContext values. Make sure to use the values from the returned frame. + */ +#define AV_CODEC_FLAG_RECON_FRAME (1 << 6) +/** + * @par decoding + * Request the decoder to propagate each packet's AVPacket.opaque and + * AVPacket.opaque_ref to its corresponding output AVFrame. + * + * @par encoding: + * Request the encoder to propagate each frame's AVFrame.opaque and + * AVFrame.opaque_ref values to its corresponding output AVPacket. + * + * @par + * May only be set on encoders that have the + * @ref AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE capability flag. + * + * @note + * While in typical cases one input frame produces exactly one output packet + * (perhaps after a delay), in general the mapping of frames to packets is + * M-to-N, so + * - Any number of input frames may be associated with any given output packet. + * This includes zero - e.g. some encoders may output packets that carry only + * metadata about the whole stream. + * - A given input frame may be associated with any number of output packets. + * Again this includes zero - e.g. some encoders may drop frames under certain + * conditions. + * . + * This implies that when using this flag, the caller must NOT assume that + * - a given input frame's opaques will necessarily appear on some output packet; + * - every output packet will have some non-NULL opaque value. + * . + * When an output packet contains multiple frames, the opaque values will be + * taken from the first of those. + * + * @note + * The converse holds for decoders, with frames and packets switched. + */ +#define AV_CODEC_FLAG_COPY_OPAQUE (1 << 7) +/** + * Signal to the encoder that the values of AVFrame.duration are valid and + * should be used (typically for transferring them to output packets). + * + * If this flag is not set, frame durations are ignored. + */ +#define AV_CODEC_FLAG_FRAME_DURATION (1 << 8) /** * Use internal 2pass ratecontrol in first pass mode. */ @@ -250,11 +320,6 @@ typedef struct RcOverride{ * error[?] variables will be set during encoding. */ #define AV_CODEC_FLAG_PSNR (1 << 15) -/** - * Input bitstream might be truncated at a random location - * instead of only at frame boundaries. - */ -#define AV_CODEC_FLAG_TRUNCATED (1 << 16) /** * Use interlaced DCT. */ @@ -295,11 +360,6 @@ typedef struct RcOverride{ */ #define AV_CODEC_FLAG2_LOCAL_HEADER (1 << 3) -/** - * timecode is in drop frame format. DEPRECATED!!!! - */ -#define AV_CODEC_FLAG2_DROP_FRAME_TIMECODE (1 << 13) - /** * Input bitstream might be truncated at a packet boundaries * instead of only at frame boundaries. @@ -326,13 +386,12 @@ typedef struct RcOverride{ * Do not reset ASS ReadOrder field on flush (subtitles decoding) */ #define AV_CODEC_FLAG2_RO_FLUSH_NOOP (1 << 30) - -/* Unsupported options : - * Syntax Arithmetic coding (SAC) - * Reference Picture Selection - * Independent Segment Decoding */ -/* /Fx */ -/* codec capabilities */ +/** + * Generate/parse ICC profiles on encode/decode, as appropriate for the type of + * file. No effect on codecs which cannot contain embedded ICC profiles, or + * when compiled without support for lcms2. + */ +#define AV_CODEC_FLAG2_ICC_PROFILES (1U << 31) /* Exported side data. These flags can be passed in AVCodecContext.export_side_data before initialization. @@ -366,8 +425,6 @@ typedef struct RcOverride{ */ #define AV_GET_ENCODE_BUFFER_FLAG_REF (1 << 0) -struct AVCodecInternal; - /** * main external API structure. * New fields can be added to the end with minor version bumps. @@ -501,19 +558,26 @@ typedef struct AVCodecContext { * (fixed_vop_rate == 0 implies that it is different from the framerate) * * - encoding: MUST be set by user. - * - decoding: the use of this field for decoding is deprecated. - * Use framerate instead. + * - decoding: unused. */ AVRational time_base; +#if FF_API_TICKS_PER_FRAME /** * For some codecs, the time base is closer to the field rate than the frame rate. * Most notably, H.264 and MPEG-2 specify time_base as half of frame duration * if no telecine is used ... * * Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2. + * + * @deprecated + * - decoding: Use AVCodecDescriptor.props & AV_CODEC_PROP_FIELDS + * - encoding: Set AVCodecContext.framerate instead + * */ + attribute_deprecated int ticks_per_frame; +#endif /** * Codec delay. @@ -730,11 +794,13 @@ typedef struct AVCodecContext { */ float dark_masking; +#if FF_API_SLICE_OFFSET /** * slice count * - encoding: Set by libavcodec. * - decoding: Set by user (or 0). */ + attribute_deprecated int slice_count; /** @@ -742,7 +808,9 @@ typedef struct AVCodecContext { * - encoding: Set/allocated by libavcodec. * - decoding: Set/allocated by user (or NULL). */ + attribute_deprecated int *slice_offset; +#endif /** * sample aspect ratio (0 if unknown) @@ -962,8 +1030,11 @@ typedef struct AVCodecContext { /** * MPEG vs JPEG YUV range. - * - encoding: Set by user - * - decoding: Set by libavcodec + * - encoding: Set by user to override the default output color range value, + * If not specified, libavcodec sets the color range depending on the + * output format. + * - decoding: Set by libavcodec, can be set by the user to propagate the + * color range to components reading from the decoder context. */ enum AVColorRange color_range; @@ -991,7 +1062,15 @@ typedef struct AVCodecContext { /* audio only */ int sample_rate; ///< samples per second - int channels; ///< number of audio channels + +#if FF_API_OLD_CHANNEL_LAYOUT + /** + * number of audio channels + * @deprecated use ch_layout.nb_channels + */ + attribute_deprecated + int channels; +#endif /** * audio sample format @@ -1012,6 +1091,7 @@ typedef struct AVCodecContext { */ int frame_size; +#if FF_API_AVCTX_FRAME_NUMBER /** * Frame counter, set by libavcodec. * @@ -1020,8 +1100,11 @@ typedef struct AVCodecContext { * * @note the counter is not incremented if encoding/decoding resulted in * an error. + * @deprecated use frame_num instead */ + attribute_deprecated int frame_number; +#endif /** * number of bytes per packet if constant and known or 0 @@ -1036,19 +1119,25 @@ typedef struct AVCodecContext { */ int cutoff; +#if FF_API_OLD_CHANNEL_LAYOUT /** * Audio channel layout. * - encoding: set by user. * - decoding: set by user, may be overwritten by libavcodec. + * @deprecated use ch_layout */ + attribute_deprecated uint64_t channel_layout; /** * Request decoder to use this channel layout if it can (0 for default) * - encoding: unused * - decoding: Set by user. + * @deprecated use "downmix" codec private option */ + attribute_deprecated uint64_t request_channel_layout; +#endif /** * Type of service that the audio stream conveys. @@ -1175,7 +1264,7 @@ typedef struct AVCodecContext { /** * decoder bitstream buffer size * - encoding: Set by user. - * - decoding: unused + * - decoding: May be set by libavcodec. */ int rc_buffer_size; @@ -1277,13 +1366,9 @@ typedef struct AVCodecContext { * unofficial and experimental (that is, they always try to decode things * when they can) unless they are explicitly asked to behave stupidly * (=strictly conform to the specs) + * This may only be set to one of the FF_COMPLIANCE_* values in defs.h. */ int strict_std_compliance; -#define FF_COMPLIANCE_VERY_STRICT 2 ///< Strictly conform to an older more strict version of the spec or reference software. -#define FF_COMPLIANCE_STRICT 1 ///< Strictly conform to all the things in the spec no matter what consequences. -#define FF_COMPLIANCE_NORMAL 0 -#define FF_COMPLIANCE_UNOFFICIAL -1 ///< Allow unofficial extensions -#define FF_COMPLIANCE_EXPERIMENTAL -2 ///< Allow nonstandardized experimental things. /** * error concealment flags @@ -1319,28 +1404,14 @@ typedef struct AVCodecContext { /** * Error recognition; may misdetect some more or less valid parts as errors. + * This is a bitfield of the AV_EF_* values defined in defs.h. + * * - encoding: Set by user. * - decoding: Set by user. */ int err_recognition; -/** - * Verify checksums embedded in the bitstream (could be of either encoded or - * decoded data, depending on the codec) and print an error message on mismatch. - * If AV_EF_EXPLODE is also set, a mismatching checksum will result in the - * decoder returning an error. - */ -#define AV_EF_CRCCHECK (1<<0) -#define AV_EF_BITSTREAM (1<<1) ///< detect bitstream specification deviations -#define AV_EF_BUFFER (1<<2) ///< detect improper bitstream length -#define AV_EF_EXPLODE (1<<3) ///< abort decoding on minor error detection - -#define AV_EF_IGNORE_ERR (1<<15) ///< ignore errors and continue -#define AV_EF_CAREFUL (1<<16) ///< consider things that violate the spec, are fast to calculate and have not been seen in the wild as errors -#define AV_EF_COMPLIANT (1<<17) ///< consider all spec non compliances as errors -#define AV_EF_AGGRESSIVE (1<<18) ///< consider things that a sane encoder should not do as an error - - +#if FF_API_REORDERED_OPAQUE /** * opaque 64-bit number (generally a PTS) that will be reordered and * output in AVFrame.reordered_opaque @@ -1349,8 +1420,12 @@ typedef struct AVCodecContext { * supported by encoders with the * AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE capability. * - decoding: Set by user. + * + * @deprecated Use AV_CODEC_FLAG_COPY_OPAQUE instead */ + attribute_deprecated int64_t reordered_opaque; +#endif /** * Hardware accelerator in use @@ -1360,13 +1435,26 @@ typedef struct AVCodecContext { const struct AVHWAccel *hwaccel; /** - * Hardware accelerator context. - * For some hardware accelerators, a global context needs to be - * provided by the user. In that case, this holds display-dependent - * data FFmpeg cannot instantiate itself. Please refer to the - * FFmpeg HW accelerator documentation to know how to fill this. - * - encoding: unused - * - decoding: Set by user + * Legacy hardware accelerator context. + * + * For some hardware acceleration methods, the caller may use this field to + * signal hwaccel-specific data to the codec. The struct pointed to by this + * pointer is hwaccel-dependent and defined in the respective header. Please + * refer to the FFmpeg HW accelerator documentation to know how to fill + * this. + * + * In most cases this field is optional - the necessary information may also + * be provided to libavcodec through @ref hw_frames_ctx or @ref + * hw_device_ctx (see avcodec_get_hw_config()). However, in some cases it + * may be the only method of signalling some (optional) information. + * + * The struct and its contents are owned by the caller. + * + * - encoding: May be set by the caller before avcodec_open2(). Must remain + * valid until avcodec_free_context(). + * - decoding: May be set by the caller in the get_format() callback. + * Must remain valid until the next get_format() call, + * or avcodec_free_context() (whichever comes first). */ void *hwaccel_context; @@ -1408,7 +1496,10 @@ typedef struct AVCodecContext { #define FF_IDCT_SIMPLEARMV6 17 #define FF_IDCT_FAAN 20 #define FF_IDCT_SIMPLENEON 22 -#define FF_IDCT_NONE 24 /* Used by XvMC to extract IDCT coefficients with FF_IDCT_PERM_NONE */ +#if FF_API_IDCT_NONE +// formerly used by xvmc +#define FF_IDCT_NONE 24 +#endif #define FF_IDCT_SIMPLEAUTO 128 /** @@ -1459,27 +1550,6 @@ typedef struct AVCodecContext { */ int active_thread_type; -#if FF_API_THREAD_SAFE_CALLBACKS - /** - * Set by the client if its custom get_buffer() callback can be called - * synchronously from another thread, which allows faster multithreaded decoding. - * draw_horiz_band() will be called from other threads regardless of this setting. - * Ignored if the default get_buffer() is used. - * - encoding: Set by user. - * - decoding: Set by user. - * - * @deprecated the custom get_buffer2() callback should always be - * thread-safe. Thread-unsafe get_buffer2() implementations will be - * invalid starting with LIBAVCODEC_VERSION_MAJOR=60; in other words, - * libavcodec will behave as if this field was always set to 1. - * Callers that want to be forward compatible with future libavcodec - * versions should wrap access to this field in - * #if LIBAVCODEC_VERSION_MAJOR < 60 - */ - attribute_deprecated - int thread_safe_callbacks; -#endif - /** * The codec may call this to execute several independent things. * It will return only after finishing all tasks. @@ -1496,7 +1566,6 @@ typedef struct AVCodecContext { * It will return only after finishing all tasks. * The user may replace this with some multithreaded implementation, * the default implementation will execute the parts serially. - * Also see avcodec_thread_init and e.g. the --enable-pthread configure option. * @param c context passed also to func * @param count the number of things to execute * @param arg2 argument passed unchanged to func @@ -1522,8 +1591,12 @@ typedef struct AVCodecContext { * profile * - encoding: Set by user. * - decoding: Set by libavcodec. + * See the AV_PROFILE_* defines in defs.h. */ int profile; +#if FF_API_FF_PROFILE_LEVEL + /** @deprecated The following defines are deprecated; use AV_PROFILE_* + * in defs.h instead. */ #define FF_PROFILE_UNKNOWN -99 #define FF_PROFILE_RESERVED -100 @@ -1545,12 +1618,19 @@ typedef struct AVCodecContext { #define FF_PROFILE_DNXHR_HQX 4 #define FF_PROFILE_DNXHR_444 5 -#define FF_PROFILE_DTS 20 -#define FF_PROFILE_DTS_ES 30 -#define FF_PROFILE_DTS_96_24 40 -#define FF_PROFILE_DTS_HD_HRA 50 -#define FF_PROFILE_DTS_HD_MA 60 -#define FF_PROFILE_DTS_EXPRESS 70 +#define FF_PROFILE_DTS 20 +#define FF_PROFILE_DTS_ES 30 +#define FF_PROFILE_DTS_96_24 40 +#define FF_PROFILE_DTS_HD_HRA 50 +#define FF_PROFILE_DTS_HD_MA 60 +#define FF_PROFILE_DTS_EXPRESS 70 +#define FF_PROFILE_DTS_HD_MA_X 61 +#define FF_PROFILE_DTS_HD_MA_X_IMAX 62 + + +#define FF_PROFILE_EAC3_DDP_ATMOS 30 + +#define FF_PROFILE_TRUEHD_ATMOS 30 #define FF_PROFILE_MPEG2_422 0 #define FF_PROFILE_MPEG2_HIGH 1 @@ -1615,6 +1695,7 @@ typedef struct AVCodecContext { #define FF_PROFILE_HEVC_MAIN_10 2 #define FF_PROFILE_HEVC_MAIN_STILL_PICTURE 3 #define FF_PROFILE_HEVC_REXT 4 +#define FF_PROFILE_HEVC_SCC 9 #define FF_PROFILE_VVC_MAIN_10 1 #define FF_PROFILE_VVC_MAIN_10_444 33 @@ -1644,13 +1725,24 @@ typedef struct AVCodecContext { #define FF_PROFILE_KLVA_SYNC 0 #define FF_PROFILE_KLVA_ASYNC 1 +#define FF_PROFILE_EVC_BASELINE 0 +#define FF_PROFILE_EVC_MAIN 1 +#endif + /** - * level - * - encoding: Set by user. + * Encoding level descriptor. + * - encoding: Set by user, corresponds to a specific level defined by the + * codec, usually corresponding to the profile level, if not specified it + * is set to FF_LEVEL_UNKNOWN. * - decoding: Set by libavcodec. + * See AV_LEVEL_* in defs.h. */ int level; +#if FF_API_FF_PROFILE_LEVEL + /** @deprecated The following define is deprecated; use AV_LEVEL_UNKOWN + * in defs.h instead. */ #define FF_LEVEL_UNKNOWN -99 +#endif /** * Skip loop filtering for selected frames. @@ -1718,9 +1810,9 @@ typedef struct AVCodecContext { enum AVPixelFormat sw_pix_fmt; /** - * Timebase in which pkt_dts/pts and AVPacket.dts/pts are. - * - encoding unused. - * - decoding set by user. + * Timebase in which pkt_dts/pts and AVPacket.dts/pts are expressed. + * - encoding: unused. + * - decoding: set by user. */ AVRational pkt_timebase; @@ -1729,7 +1821,7 @@ typedef struct AVCodecContext { * - encoding: unused. * - decoding: set by libavcodec. */ - const AVCodecDescriptor *codec_descriptor; + const struct AVCodecDescriptor *codec_descriptor; /** * Current statistics for PTS correction. @@ -1781,17 +1873,6 @@ typedef struct AVCodecContext { */ int seek_preroll; -#if FF_API_DEBUG_MV - /** - * @deprecated unused - */ - attribute_deprecated - int debug_mv; -#define FF_DEBUG_VIS_MV_P_FOR 0x00000001 //visualize forward predicted MVs of P frames -#define FF_DEBUG_VIS_MV_B_FOR 0x00000002 //visualize forward predicted MVs of B frames -#define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames -#endif - /** * custom intra quantization matrix * - encoding: Set by user, can be NULL. @@ -1823,11 +1904,12 @@ typedef struct AVCodecContext { unsigned properties; #define FF_CODEC_PROPERTY_LOSSLESS 0x00000001 #define FF_CODEC_PROPERTY_CLOSED_CAPTIONS 0x00000002 +#define FF_CODEC_PROPERTY_FILM_GRAIN 0x00000004 /** * Additional data associated with the entire coded stream. * - * - decoding: unused + * - decoding: may be set by user before calling avcodec_open2(). * - encoding: may be set by libavcodec after avcodec_open2(). */ AVPacketSideData *coded_side_data; @@ -1857,14 +1939,6 @@ typedef struct AVCodecContext { */ AVBufferRef *hw_frames_ctx; - /** - * Control the form of AVSubtitle.rects[N]->ass - * - decoding: set by user - * - encoding: unused - */ - int sub_text_format; -#define FF_SUB_TEXT_FMT_ASS 0 - /** * Audio only. The amount of padding (in samples) appended by the encoder to * the end of the audio. I.e. this number of decoded samples must be @@ -2023,9 +2097,26 @@ typedef struct AVCodecContext { * - decoding: unused */ int (*get_encode_buffer)(struct AVCodecContext *s, AVPacket *pkt, int flags); -} AVCodecContext; -struct MpegEncContext; + /** + * Audio channel layout. + * - encoding: must be set by the caller, to one of AVCodec.ch_layouts. + * - decoding: may be set by the caller if known e.g. from the container. + * The decoder can then override during decoding as needed. + */ + AVChannelLayout ch_layout; + + /** + * Frame counter, set by libavcodec. + * + * - decoding: total number of frames returned from the decoder so far. + * - encoding: total number of frames passed to the encoder so far. + * + * @note the counter is not incremented if encoding/decoding resulted in + * an error. + */ + int64_t frame_num; +} AVCodecContext; /** * @defgroup lavc_hwaccel AVHWAccel @@ -2069,132 +2160,6 @@ typedef struct AVHWAccel { * see AV_HWACCEL_CODEC_CAP_* */ int capabilities; - - /***************************************************************** - * No fields below this line are part of the public API. They - * may not be used outside of libavcodec and can be changed and - * removed at will. - * New public fields should be added right above. - ***************************************************************** - */ - - /** - * Allocate a custom buffer - */ - int (*alloc_frame)(AVCodecContext *avctx, AVFrame *frame); - - /** - * Called at the beginning of each frame or field picture. - * - * Meaningful frame information (codec specific) is guaranteed to - * be parsed at this point. This function is mandatory. - * - * Note that buf can be NULL along with buf_size set to 0. - * Otherwise, this means the whole frame is available at this point. - * - * @param avctx the codec context - * @param buf the frame data buffer base - * @param buf_size the size of the frame in bytes - * @return zero if successful, a negative value otherwise - */ - int (*start_frame)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size); - - /** - * Callback for parameter data (SPS/PPS/VPS etc). - * - * Useful for hardware decoders which keep persistent state about the - * video parameters, and need to receive any changes to update that state. - * - * @param avctx the codec context - * @param type the nal unit type - * @param buf the nal unit data buffer - * @param buf_size the size of the nal unit in bytes - * @return zero if successful, a negative value otherwise - */ - int (*decode_params)(AVCodecContext *avctx, int type, const uint8_t *buf, uint32_t buf_size); - - /** - * Callback for each slice. - * - * Meaningful slice information (codec specific) is guaranteed to - * be parsed at this point. This function is mandatory. - * The only exception is XvMC, that works on MB level. - * - * @param avctx the codec context - * @param buf the slice data buffer base - * @param buf_size the size of the slice in bytes - * @return zero if successful, a negative value otherwise - */ - int (*decode_slice)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size); - - /** - * Called at the end of each frame or field picture. - * - * The whole picture is parsed at this point and can now be sent - * to the hardware accelerator. This function is mandatory. - * - * @param avctx the codec context - * @return zero if successful, a negative value otherwise - */ - int (*end_frame)(AVCodecContext *avctx); - - /** - * Size of per-frame hardware accelerator private data. - * - * Private data is allocated with av_mallocz() before - * AVCodecContext.get_buffer() and deallocated after - * AVCodecContext.release_buffer(). - */ - int frame_priv_data_size; - - /** - * Called for every Macroblock in a slice. - * - * XvMC uses it to replace the ff_mpv_reconstruct_mb(). - * Instead of decoding to raw picture, MB parameters are - * stored in an array provided by the video driver. - * - * @param s the mpeg context - */ - void (*decode_mb)(struct MpegEncContext *s); - - /** - * Initialize the hwaccel private data. - * - * This will be called from ff_get_format(), after hwaccel and - * hwaccel_context are set and the hwaccel private data in AVCodecInternal - * is allocated. - */ - int (*init)(AVCodecContext *avctx); - - /** - * Uninitialize the hwaccel private data. - * - * This will be called from get_format() or avcodec_close(), after hwaccel - * and hwaccel_context are already uninitialized. - */ - int (*uninit)(AVCodecContext *avctx); - - /** - * Size of the private data to allocate in - * AVCodecInternal.hwaccel_priv_data. - */ - int priv_data_size; - - /** - * Internal hwaccel capabilities. - */ - int caps_internal; - - /** - * Fill the given hw_frames context with current codec parameters. Called - * from get_format. Refer to avcodec_get_hw_frames_parameters() for - * details. - * - * This CAN be called before AVHWAccel.init is called, and you must assume - * that avctx->hwaccel_priv_data is invalid. - */ - int (*frame_params)(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx); } AVHWAccel; /** @@ -2233,6 +2198,22 @@ typedef struct AVHWAccel { */ #define AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH (1 << 2) +/** + * Some hardware decoders (namely nvdec) can either output direct decoder + * surfaces, or make an on-device copy and return said copy. + * There is a hard limit on how many decoder surfaces there can be, and it + * cannot be accurately guessed ahead of time. + * For some processing chains, this can be okay, but others will run into the + * limit and in turn produce very confusing errors that require fine tuning of + * more or less obscure options by the user, or in extreme cases cannot be + * resolved at all without inserting an avfilter that forces a copy. + * + * Thus, the hwaccel will by default make a copy for safety and resilience. + * If a users really wants to minimize the amount of copies, they can set this + * flag and ensure their processing chain does not exhaust the surface pool. + */ +#define AV_HWACCEL_FLAG_UNSAFE_OUTPUT (1 << 3) + /** * @} */ @@ -2338,14 +2319,6 @@ void avcodec_free_context(AVCodecContext **avctx); */ const AVClass *avcodec_get_class(void); -#if FF_API_GET_FRAME_CLASS -/** - * @deprecated This function should not be used. - */ -attribute_deprecated -const AVClass *avcodec_get_frame_class(void); -#endif - /** * Get the AVClass for AVSubtitleRect. It can be used in combination with * AV_OPT_SEARCH_FAKE_OBJ for examining options. @@ -2361,7 +2334,7 @@ const AVClass *avcodec_get_subtitle_rect_class(void); * * @return >= 0 on success, a negative AVERROR code on failure */ -int avcodec_parameters_from_context(AVCodecParameters *par, +int avcodec_parameters_from_context(struct AVCodecParameters *par, const AVCodecContext *codec); /** @@ -2373,7 +2346,7 @@ int avcodec_parameters_from_context(AVCodecParameters *par, * @return >= 0 on success, a negative AVERROR code on failure. */ int avcodec_parameters_to_context(AVCodecContext *codec, - const AVCodecParameters *par); + const struct AVCodecParameters *par); /** * Initialize the AVCodecContext to use the given AVCodec. Prior to using this @@ -2383,11 +2356,16 @@ int avcodec_parameters_to_context(AVCodecContext *codec, * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for * retrieving a codec. * - * @warning This function is not thread safe! + * Depending on the codec, you might need to set options in the codec context + * also for decoding (e.g. width, height, or the pixel or audio sample format in + * the case the information is not available in the bitstream, as when decoding + * raw audio or video). * - * @note Always call this function before using decoding routines (such as - * @ref avcodec_receive_frame()). + * Options in the codec context can be set either by setting them in the options + * AVDictionary, or by setting the values in the context itself, directly or by + * using the av_opt_set() API before calling this function. * + * Example: * @code * av_dict_set(&opts, "b", "2.5M", 0); * codec = avcodec_find_decoder(AV_CODEC_ID_H264); @@ -2400,17 +2378,36 @@ int avcodec_parameters_to_context(AVCodecContext *codec, * exit(1); * @endcode * + * In the case AVCodecParameters are available (e.g. when demuxing a stream + * using libavformat, and accessing the AVStream contained in the demuxer), the + * codec parameters can be copied to the codec context using + * avcodec_parameters_to_context(), as in the following example: + * + * @code + * AVStream *stream = ...; + * context = avcodec_alloc_context3(codec); + * if (avcodec_parameters_to_context(context, stream->codecpar) < 0) + * exit(1); + * if (avcodec_open2(context, codec, NULL) < 0) + * exit(1); + * @endcode + * + * @note Always call this function before using decoding routines (such as + * @ref avcodec_receive_frame()). + * * @param avctx The context to initialize. * @param codec The codec to open this context for. If a non-NULL codec has been * previously passed to avcodec_alloc_context3() or * for this context, then this parameter MUST be either NULL or * equal to the previously passed codec. - * @param options A dictionary filled with AVCodecContext and codec-private options. - * On return this object will be filled with options that were not found. + * @param options A dictionary filled with AVCodecContext and codec-private + * options, which are set on top of the options already set in + * avctx, can be NULL. On return this object will be filled with + * options that were not found in the avctx codec context. * * @return zero on success, a negative value on error * @see avcodec_alloc_context3(), avcodec_find_decoder(), avcodec_find_encoder(), - * av_dict_set(), av_opt_find(). + * av_dict_set(), av_opt_set(), av_opt_find(), avcodec_parameters_to_context() */ int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options); @@ -2478,6 +2475,7 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height); void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, int linesize_align[AV_NUM_DATA_POINTERS]); +#ifdef FF_API_AVCODEC_CHROMA_POS /** * Converts AVChromaLocation to swscale x/y chroma position. * @@ -2486,7 +2484,9 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, * * @param xpos horizontal chroma sample position * @param ypos vertical chroma sample position + * @deprecated Use av_chroma_location_enum_to_pos() instead. */ + attribute_deprecated int avcodec_enum_to_chroma_pos(int *xpos, int *ypos, enum AVChromaLocation pos); /** @@ -2497,8 +2497,11 @@ int avcodec_enum_to_chroma_pos(int *xpos, int *ypos, enum AVChromaLocation pos); * * @param xpos horizontal chroma sample position * @param ypos vertical chroma sample position + * @deprecated Use av_chroma_location_pos_to_enum() instead. */ + attribute_deprecated enum AVChromaLocation avcodec_chroma_pos_to_enum(int xpos, int ypos); +#endif /** * Decode a subtitle message. @@ -2528,8 +2531,7 @@ enum AVChromaLocation avcodec_chroma_pos_to_enum(int xpos, int ypos); * @param[in] avpkt The input AVPacket containing the input buffer. */ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, - int *got_sub_ptr, - AVPacket *avpkt); + int *got_sub_ptr, const AVPacket *avpkt); /** * Supply raw packet data as input to a decoder. @@ -2565,40 +2567,38 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, * still has frames buffered, it will return them after sending * a flush packet. * - * @return 0 on success, otherwise negative error code: - * AVERROR(EAGAIN): input is not accepted in the current state - user - * must read output with avcodec_receive_frame() (once - * all output is read, the packet should be resent, and - * the call will not fail with EAGAIN). - * AVERROR_EOF: the decoder has been flushed, and no new packets can - * be sent to it (also returned if more than 1 flush - * packet is sent) - * AVERROR(EINVAL): codec not opened, it is an encoder, or requires flush - * AVERROR(ENOMEM): failed to add packet to internal queue, or similar - * other errors: legitimate decoding errors + * @retval 0 success + * @retval AVERROR(EAGAIN) input is not accepted in the current state - user + * must read output with avcodec_receive_frame() (once + * all output is read, the packet should be resent, + * and the call will not fail with EAGAIN). + * @retval AVERROR_EOF the decoder has been flushed, and no new packets can be + * sent to it (also returned if more than 1 flush + * packet is sent) + * @retval AVERROR(EINVAL) codec not opened, it is an encoder, or requires flush + * @retval AVERROR(ENOMEM) failed to add packet to internal queue, or similar + * @retval "another negative error code" legitimate decoding errors */ int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt); /** - * Return decoded output data from a decoder. + * Return decoded output data from a decoder or encoder (when the + * @ref AV_CODEC_FLAG_RECON_FRAME flag is used). * * @param avctx codec context * @param frame This will be set to a reference-counted video or audio * frame (depending on the decoder type) allocated by the - * decoder. Note that the function will always call + * codec. Note that the function will always call * av_frame_unref(frame) before doing anything else. * - * @return - * 0: success, a frame was returned - * AVERROR(EAGAIN): output is not available in this state - user must try - * to send new input - * AVERROR_EOF: the decoder has been fully flushed, and there will be - * no more output frames - * AVERROR(EINVAL): codec not opened, or it is an encoder - * AVERROR_INPUT_CHANGED: current decoded frame has changed parameters - * with respect to first decoded frame. Applicable - * when flag AV_CODEC_FLAG_DROPCHANGED is set. - * other negative values: legitimate decoding errors + * @retval 0 success, a frame was returned + * @retval AVERROR(EAGAIN) output is not available in this state - user must + * try to send new input + * @retval AVERROR_EOF the codec has been fully flushed, and there will be + * no more output frames + * @retval AVERROR(EINVAL) codec not opened, or it is an encoder without the + * @ref AV_CODEC_FLAG_RECON_FRAME flag enabled + * @retval "other negative error code" legitimate decoding errors */ int avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame); @@ -2625,16 +2625,16 @@ int avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame); * If it is not set, frame->nb_samples must be equal to * avctx->frame_size for all frames except the last. * The final frame may be smaller than avctx->frame_size. - * @return 0 on success, otherwise negative error code: - * AVERROR(EAGAIN): input is not accepted in the current state - user - * must read output with avcodec_receive_packet() (once - * all output is read, the packet should be resent, and - * the call will not fail with EAGAIN). - * AVERROR_EOF: the encoder has been flushed, and no new frames can - * be sent to it - * AVERROR(EINVAL): codec not opened, it is a decoder, or requires flush - * AVERROR(ENOMEM): failed to add packet to internal queue, or similar - * other errors: legitimate encoding errors + * @retval 0 success + * @retval AVERROR(EAGAIN) input is not accepted in the current state - user must + * read output with avcodec_receive_packet() (once all + * output is read, the packet should be resent, and the + * call will not fail with EAGAIN). + * @retval AVERROR_EOF the encoder has been flushed, and no new frames can + * be sent to it + * @retval AVERROR(EINVAL) codec not opened, it is a decoder, or requires flush + * @retval AVERROR(ENOMEM) failed to add packet to internal queue, or similar + * @retval "another negative error code" legitimate encoding errors */ int avcodec_send_frame(AVCodecContext *avctx, const AVFrame *frame); @@ -2645,13 +2645,13 @@ int avcodec_send_frame(AVCodecContext *avctx, const AVFrame *frame); * @param avpkt This will be set to a reference-counted packet allocated by the * encoder. Note that the function will always call * av_packet_unref(avpkt) before doing anything else. - * @return 0 on success, otherwise negative error code: - * AVERROR(EAGAIN): output is not available in the current state - user - * must try to send input - * AVERROR_EOF: the encoder has been fully flushed, and there will be - * no more output packets - * AVERROR(EINVAL): codec not opened, or it is a decoder - * other errors: legitimate encoding errors + * @retval 0 success + * @retval AVERROR(EAGAIN) output is not available in the current state - user must + * try to send input + * @retval AVERROR_EOF the encoder has been fully flushed, and there will be no + * more output packets + * @retval AVERROR(EINVAL) codec not opened, or it is a decoder + * @retval "another negative error code" legitimate encoding errors */ int avcodec_receive_packet(AVCodecContext *avctx, AVPacket *avpkt); @@ -2765,10 +2765,10 @@ int avcodec_get_hw_frames_parameters(AVCodecContext *avctx, */ enum AVPictureStructure { - AV_PICTURE_STRUCTURE_UNKNOWN, //< unknown - AV_PICTURE_STRUCTURE_TOP_FIELD, //< coded as top field - AV_PICTURE_STRUCTURE_BOTTOM_FIELD, //< coded as bottom field - AV_PICTURE_STRUCTURE_FRAME, //< coded as frame + AV_PICTURE_STRUCTURE_UNKNOWN, ///< unknown + AV_PICTURE_STRUCTURE_TOP_FIELD, ///< coded as top field + AV_PICTURE_STRUCTURE_BOTTOM_FIELD, ///< coded as bottom field + AV_PICTURE_STRUCTURE_FRAME, ///< coded as frame }; typedef struct AVCodecParserContext { @@ -2931,7 +2931,7 @@ typedef struct AVCodecParserContext { } AVCodecParserContext; typedef struct AVCodecParser { - int codec_ids[5]; /* several codec IDs are permitted */ + int codec_ids[7]; /* several codec IDs are permitted */ int priv_data_size; int (*parser_init)(AVCodecParserContext *s); /* This callback never returns an error, a negative value means that diff --git a/library/FFmpeg/include/libavcodec/avfft.h b/library/FFmpeg/include/libavcodec/avfft.h index 0c0f9b8d..e3a0da1e 100644 --- a/library/FFmpeg/include/libavcodec/avfft.h +++ b/library/FFmpeg/include/libavcodec/avfft.h @@ -19,6 +19,10 @@ #ifndef AVCODEC_AVFFT_H #define AVCODEC_AVFFT_H +#include "libavutil/attributes.h" +#include "version_major.h" +#if FF_API_AVFFT + /** * @file * @ingroup lavc_fft @@ -44,26 +48,42 @@ typedef struct FFTContext FFTContext; * Set up a complex FFT. * @param nbits log2 of the length of the input array * @param inverse if 0 perform the forward transform, if 1 perform the inverse + * @deprecated use av_tx_init from libavutil/tx.h with a type of AV_TX_FLOAT_FFT */ +attribute_deprecated FFTContext *av_fft_init(int nbits, int inverse); /** * Do the permutation needed BEFORE calling ff_fft_calc(). + * @deprecated without replacement */ +attribute_deprecated void av_fft_permute(FFTContext *s, FFTComplex *z); /** * Do a complex FFT with the parameters defined in av_fft_init(). The * input data must be permuted before. No 1.0/sqrt(n) normalization is done. + * @deprecated use the av_tx_fn value returned by av_tx_init, which also does permutation */ +attribute_deprecated void av_fft_calc(FFTContext *s, FFTComplex *z); +attribute_deprecated void av_fft_end(FFTContext *s); +/** + * @deprecated use av_tx_init from libavutil/tx.h with a type of AV_TX_FLOAT_MDCT, + * with a flag of AV_TX_FULL_IMDCT for a replacement to av_imdct_calc. + */ +attribute_deprecated FFTContext *av_mdct_init(int nbits, int inverse, double scale); +attribute_deprecated void av_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input); +attribute_deprecated void av_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input); +attribute_deprecated void av_mdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input); +attribute_deprecated void av_mdct_end(FFTContext *s); /* Real Discrete Fourier Transform */ @@ -81,9 +101,14 @@ typedef struct RDFTContext RDFTContext; * Set up a real FFT. * @param nbits log2 of the length of the input array * @param trans the type of transform + * + * @deprecated use av_tx_init from libavutil/tx.h with a type of AV_TX_FLOAT_RDFT */ +attribute_deprecated RDFTContext *av_rdft_init(int nbits, enum RDFTransformType trans); +attribute_deprecated void av_rdft_calc(RDFTContext *s, FFTSample *data); +attribute_deprecated void av_rdft_end(RDFTContext *s); /* Discrete Cosine Transform */ @@ -106,13 +131,19 @@ enum DCTTransformType { * @param type the type of transform * * @note the first element of the input of DST-I is ignored + * + * @deprecated use av_tx_init from libavutil/tx.h with an appropriate type of AV_TX_FLOAT_DCT */ +attribute_deprecated DCTContext *av_dct_init(int nbits, enum DCTTransformType type); +attribute_deprecated void av_dct_calc(DCTContext *s, FFTSample *data); +attribute_deprecated void av_dct_end (DCTContext *s); /** * @} */ +#endif /* FF_API_AVFFT */ #endif /* AVCODEC_AVFFT_H */ diff --git a/library/FFmpeg/include/libavcodec/bsf.h b/library/FFmpeg/include/libavcodec/bsf.h index 3b5faa85..a09c69f2 100644 --- a/library/FFmpeg/include/libavcodec/bsf.h +++ b/library/FFmpeg/include/libavcodec/bsf.h @@ -30,12 +30,31 @@ #include "packet.h" /** - * @addtogroup lavc_core + * @defgroup lavc_bsf Bitstream filters + * @ingroup libavc + * + * Bitstream filters transform encoded media data without decoding it. This + * allows e.g. manipulating various header values. Bitstream filters operate on + * @ref AVPacket "AVPackets". + * + * The bitstream filtering API is centered around two structures: + * AVBitStreamFilter and AVBSFContext. The former represents a bitstream filter + * in abstract, the latter a specific filtering process. Obtain an + * AVBitStreamFilter using av_bsf_get_by_name() or av_bsf_iterate(), then pass + * it to av_bsf_alloc() to create an AVBSFContext. Fill in the user-settable + * AVBSFContext fields, as described in its documentation, then call + * av_bsf_init() to prepare the filter context for use. + * + * Submit packets for filtering using av_bsf_send_packet(), obtain filtered + * results with av_bsf_receive_packet(). When no more input packets will be + * sent, submit a NULL AVPacket to signal the end of the stream to the filter. + * av_bsf_receive_packet() will then return trailing packets, if any are + * produced by the filter. + * + * Finally, free the filter context with av_bsf_free(). * @{ */ -typedef struct AVBSFInternal AVBSFInternal; - /** * The bitstream filter state. * @@ -57,12 +76,6 @@ typedef struct AVBSFContext { */ const struct AVBitStreamFilter *filter; - /** - * Opaque libavcodec internal data. Must not be touched by the caller in any - * way. - */ - AVBSFInternal *internal; - /** * Opaque filter-specific private data. If filter->priv_class is non-NULL, * this is an AVOptions-enabled struct. @@ -115,20 +128,6 @@ typedef struct AVBitStreamFilter { * code to this class. */ const AVClass *priv_class; - - /***************************************************************** - * No fields below this line are part of the public API. They - * may not be used outside of libavcodec and can be changed and - * removed at will. - * New public fields should be added right above. - ***************************************************************** - */ - - int priv_data_size; - int (*init)(AVBSFContext *ctx); - int (*filter)(AVBSFContext *ctx, AVPacket *pkt); - void (*close)(AVBSFContext *ctx); - void (*flush)(AVBSFContext *ctx); } AVBitStreamFilter; /** @@ -154,9 +153,9 @@ const AVBitStreamFilter *av_bsf_iterate(void **opaque); * av_bsf_init() before sending any data to the filter. * * @param filter the filter for which to allocate an instance. - * @param ctx a pointer into which the pointer to the newly-allocated context - * will be written. It must be freed with av_bsf_free() after the - * filtering is done. + * @param[out] ctx a pointer into which the pointer to the newly-allocated context + * will be written. It must be freed with av_bsf_free() after the + * filtering is done. * * @return 0 on success, a negative AVERROR code on failure */ @@ -165,6 +164,8 @@ int av_bsf_alloc(const AVBitStreamFilter *filter, AVBSFContext **ctx); /** * Prepare the filter for use, after all the parameters and options have been * set. + * + * @param ctx a AVBSFContext previously allocated with av_bsf_alloc() */ int av_bsf_init(AVBSFContext *ctx); @@ -175,6 +176,7 @@ int av_bsf_init(AVBSFContext *ctx); * av_bsf_receive_packet() repeatedly until it returns AVERROR(EAGAIN) or * AVERROR_EOF. * + * @param ctx an initialized AVBSFContext * @param pkt the packet to filter. The bitstream filter will take ownership of * the packet and reset the contents of pkt. pkt is not touched if an error occurs. * If pkt is empty (i.e. NULL, or pkt->data is NULL and pkt->side_data_elems zero), @@ -182,15 +184,18 @@ int av_bsf_init(AVBSFContext *ctx); * sending more empty packets does nothing) and will cause the filter to output * any packets it may have buffered internally. * - * @return 0 on success. AVERROR(EAGAIN) if packets need to be retrieved from the - * filter (using av_bsf_receive_packet()) before new input can be consumed. Another - * negative AVERROR value if an error occurs. + * @return + * - 0 on success. + * - AVERROR(EAGAIN) if packets need to be retrieved from the filter (using + * av_bsf_receive_packet()) before new input can be consumed. + * - Another negative AVERROR value if an error occurs. */ int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt); /** * Retrieve a filtered packet. * + * @param ctx an initialized AVBSFContext * @param[out] pkt this struct will be filled with the contents of the filtered * packet. It is owned by the caller and must be freed using * av_packet_unref() when it is no longer needed. @@ -201,10 +206,12 @@ int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt); * overwritten by the returned data. On failure, pkt is not * touched. * - * @return 0 on success. AVERROR(EAGAIN) if more packets need to be sent to the - * filter (using av_bsf_send_packet()) to get more output. AVERROR_EOF if there - * will be no further output from the filter. Another negative AVERROR value if - * an error occurs. + * @return + * - 0 on success. + * - AVERROR(EAGAIN) if more packets need to be sent to the filter (using + * av_bsf_send_packet()) to get more output. + * - AVERROR_EOF if there will be no further output from the filter. + * - Another negative AVERROR value if an error occurs. * * @note one input packet may result in several output packets, so after sending * a packet with av_bsf_send_packet(), this function needs to be called diff --git a/library/FFmpeg/include/libavcodec/codec.h b/library/FFmpeg/include/libavcodec/codec.h index cedd1069..8034f1a5 100644 --- a/library/FFmpeg/include/libavcodec/codec.h +++ b/library/FFmpeg/include/libavcodec/codec.h @@ -31,7 +31,7 @@ #include "libavutil/samplefmt.h" #include "libavcodec/codec_id.h" -#include "libavcodec/version.h" +#include "libavcodec/version_major.h" /** * @addtogroup lavc_core @@ -50,7 +50,6 @@ * avcodec_default_get_buffer2 or avcodec_default_get_encode_buffer. */ #define AV_CODEC_CAP_DR1 (1 << 1) -#define AV_CODEC_CAP_TRUNCATED (1 << 3) /** * Encoder or decoder requires flushing with NULL input at the end in order to * give the complete and correct output. @@ -81,6 +80,7 @@ */ #define AV_CODEC_CAP_SMALL_LAST_FRAME (1 << 6) +#if FF_API_SUBFRAMES /** * Codec can output multiple frames per AVPacket * Normally demuxers return one frame at a time, demuxers which do not do @@ -93,6 +93,8 @@ * as a last resort. */ #define AV_CODEC_CAP_SUBFRAMES (1 << 8) +#endif + /** * Codec is experimental and is thus avoided in favor of non experimental * encoders @@ -120,9 +122,6 @@ * multithreading-capable external libraries. */ #define AV_CODEC_CAP_OTHER_THREADS (1 << 15) -#if FF_API_AUTO_THREADS -#define AV_CODEC_CAP_AUTO_THREADS AV_CODEC_CAP_OTHER_THREADS -#endif /** * Audio encoder supports receiving a different number of samples in each call. */ @@ -138,17 +137,6 @@ */ #define AV_CODEC_CAP_AVOID_PROBING (1 << 17) -#if FF_API_UNUSED_CODEC_CAPS -/** - * Deprecated and unused. Use AVCodecDescriptor.props instead - */ -#define AV_CODEC_CAP_INTRA_ONLY 0x40000000 -/** - * Deprecated and unused. Use AVCodecDescriptor.props instead - */ -#define AV_CODEC_CAP_LOSSLESS 0x80000000 -#endif - /** * Codec is backed by a hardware implementation. Typically used to * identify a non-hwaccel hardware decoder. For information about hwaccels, use @@ -164,9 +152,9 @@ #define AV_CODEC_CAP_HYBRID (1 << 19) /** - * This codec takes the reordered_opaque field from input AVFrames - * and returns it in the corresponding field in AVCodecContext after - * encoding. + * This encoder can reorder user opaque values from input AVFrames and return + * them with corresponding output packets. + * @see AV_CODEC_FLAG_COPY_OPAQUE */ #define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE (1 << 20) @@ -177,6 +165,14 @@ */ #define AV_CODEC_CAP_ENCODER_FLUSH (1 << 21) +/** + * The encoder is able to output reconstructed frame data, i.e. raw frames that + * would be produced by decoding the encoded bitstream. + * + * Reconstructed frame output is enabled by the AV_CODEC_FLAG_RECON_FRAME flag. + */ +#define AV_CODEC_CAP_ENCODER_RECON_FRAME (1 << 22) + /** * AVProfile. */ @@ -185,12 +181,6 @@ typedef struct AVProfile { const char *name; ///< short name for the profile } AVProfile; -typedef struct AVCodecDefault AVCodecDefault; - -struct AVCodecContext; -struct AVSubtitle; -struct AVPacket; - /** * AVCodec. */ @@ -214,14 +204,20 @@ typedef struct AVCodec { * see AV_CODEC_CAP_* */ int capabilities; + uint8_t max_lowres; ///< maximum value for lowres supported by the decoder const AVRational *supported_framerates; ///< array of supported framerates, or NULL if any, array is terminated by {0,0} const enum AVPixelFormat *pix_fmts; ///< array of supported pixel formats, or NULL if unknown, array is terminated by -1 const int *supported_samplerates; ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0 const enum AVSampleFormat *sample_fmts; ///< array of supported sample formats, or NULL if unknown, array is terminated by -1 +#if FF_API_OLD_CHANNEL_LAYOUT + /** + * @deprecated use ch_layouts instead + */ + attribute_deprecated const uint64_t *channel_layouts; ///< array of support channel layouts, or NULL if unknown. array is terminated by 0 - uint8_t max_lowres; ///< maximum value for lowres supported by the decoder +#endif const AVClass *priv_class; ///< AVClass for the private context - const AVProfile *profiles; ///< array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN} + const AVProfile *profiles; ///< array of recognized profiles, or NULL if unknown, array is terminated by {AV_PROFILE_UNKNOWN} /** * Group name of the codec implementation. @@ -235,119 +231,10 @@ typedef struct AVCodec { */ const char *wrapper_name; - /***************************************************************** - * No fields below this line are part of the public API. They - * may not be used outside of libavcodec and can be changed and - * removed at will. - * New public fields should be added right above. - ***************************************************************** - */ - int priv_data_size; - /** - * @name Frame-level threading support functions - * @{ - */ - /** - * Copy necessary context variables from a previous thread context to the current one. - * If not defined, the next thread will start automatically; otherwise, the codec - * must call ff_thread_finish_setup(). - * - * dst and src will (rarely) point to the same context, in which case memcpy should be skipped. - */ - int (*update_thread_context)(struct AVCodecContext *dst, const struct AVCodecContext *src); - - /** - * Copy variables back to the user-facing context - */ - int (*update_thread_context_for_user)(struct AVCodecContext *dst, const struct AVCodecContext *src); - /** @} */ - - /** - * Private codec-specific defaults. - */ - const AVCodecDefault *defaults; - - /** - * Initialize codec static data, called from av_codec_iterate(). - * - * This is not intended for time consuming operations as it is - * run for every codec regardless of that codec being used. - */ - void (*init_static_data)(struct AVCodec *codec); - - int (*init)(struct AVCodecContext *); - int (*encode_sub)(struct AVCodecContext *, uint8_t *buf, int buf_size, - const struct AVSubtitle *sub); - /** - * Encode data to an AVPacket. - * - * @param avctx codec context - * @param avpkt output AVPacket - * @param[in] frame AVFrame containing the raw data to be encoded - * @param[out] got_packet_ptr encoder sets to 0 or 1 to indicate that a - * non-empty packet was returned in avpkt. - * @return 0 on success, negative error code on failure - */ - int (*encode2)(struct AVCodecContext *avctx, struct AVPacket *avpkt, - const struct AVFrame *frame, int *got_packet_ptr); - /** - * Decode picture or subtitle data. - * - * @param avctx codec context - * @param outdata codec type dependent output struct - * @param[out] got_frame_ptr decoder sets to 0 or 1 to indicate that a - * non-empty frame or subtitle was returned in - * outdata. - * @param[in] avpkt AVPacket containing the data to be decoded - * @return amount of bytes read from the packet on success, negative error - * code on failure - */ - int (*decode)(struct AVCodecContext *avctx, void *outdata, - int *got_frame_ptr, struct AVPacket *avpkt); - int (*close)(struct AVCodecContext *); - /** - * Encode API with decoupled frame/packet dataflow. This function is called - * to get one output packet. It should call ff_encode_get_frame() to obtain - * input data. - */ - int (*receive_packet)(struct AVCodecContext *avctx, struct AVPacket *avpkt); - - /** - * Decode API with decoupled packet/frame dataflow. This function is called - * to get one output frame. It should call ff_decode_get_packet() to obtain - * input data. - */ - int (*receive_frame)(struct AVCodecContext *avctx, struct AVFrame *frame); - /** - * Flush buffers. - * Will be called when seeking - */ - void (*flush)(struct AVCodecContext *); - /** - * Internal codec capabilities. - * See FF_CODEC_CAP_* in internal.h - */ - int caps_internal; - - /** - * Decoding only, a comma-separated list of bitstream filters to apply to - * packets before decoding. - */ - const char *bsfs; - - /** - * Array of pointers to hardware configurations supported by the codec, - * or NULL if no hardware supported. The array is terminated by a NULL - * pointer. - * - * The user can only access this field via avcodec_get_hw_config(). - */ - const struct AVCodecHWConfigInternal *const *hw_configs; - /** - * List of supported codec_tags, terminated by FF_CODEC_TAGS_END. + * Array of supported channel layouts, terminated with a zeroed layout. */ - const uint32_t *codec_tags; + const AVChannelLayout *ch_layouts; } AVCodec; /** diff --git a/library/FFmpeg/include/libavcodec/codec_desc.h b/library/FFmpeg/include/libavcodec/codec_desc.h index 126b52df..96afd202 100644 --- a/library/FFmpeg/include/libavcodec/codec_desc.h +++ b/library/FFmpeg/include/libavcodec/codec_desc.h @@ -60,7 +60,7 @@ typedef struct AVCodecDescriptor { const char *const *mime_types; /** * If non-NULL, an array of profiles recognized for this codec. - * Terminated with FF_PROFILE_UNKNOWN. + * Terminated with AV_PROFILE_UNKNOWN. */ const struct AVProfile *profiles; } AVCodecDescriptor; @@ -90,6 +90,12 @@ typedef struct AVCodecDescriptor { * equal. */ #define AV_CODEC_PROP_REORDER (1 << 3) + +/** + * Video codec supports separate coding of fields in interlaced frames. + */ +#define AV_CODEC_PROP_FIELDS (1 << 4) + /** * Subtitle codec is bitmap based * Decoded AVSubtitle data can be read from the AVSubtitleRect->pict field. diff --git a/library/FFmpeg/include/libavcodec/codec_id.h b/library/FFmpeg/include/libavcodec/codec_id.h index d49f9af3..29b410b8 100644 --- a/library/FFmpeg/include/libavcodec/codec_id.h +++ b/library/FFmpeg/include/libavcodec/codec_id.h @@ -24,6 +24,8 @@ #include "libavutil/avutil.h" #include "libavutil/samplefmt.h" +#include "version_major.h" + /** * @addtogroup lavc_core * @{ @@ -251,7 +253,9 @@ enum AVCodecID { AV_CODEC_ID_AVRP, AV_CODEC_ID_012V, AV_CODEC_ID_AVUI, +#if FF_API_AYUV_CODECID AV_CODEC_ID_AYUV, +#endif AV_CODEC_ID_TARGA_Y216, AV_CODEC_ID_V308, AV_CODEC_ID_V408, @@ -307,6 +311,19 @@ enum AVCodecID { AV_CODEC_ID_CRI, AV_CODEC_ID_SIMBIOSIS_IMX, AV_CODEC_ID_SGA_VIDEO, + AV_CODEC_ID_GEM, + AV_CODEC_ID_VBN, + AV_CODEC_ID_JPEGXL, + AV_CODEC_ID_QOI, + AV_CODEC_ID_PHM, + AV_CODEC_ID_RADIANCE_HDR, + AV_CODEC_ID_WBMP, + AV_CODEC_ID_MEDIA100, + AV_CODEC_ID_VQC, + AV_CODEC_ID_PDV, + AV_CODEC_ID_EVC, + AV_CODEC_ID_RTV1, + AV_CODEC_ID_VMIX, /* various PCM "codecs" */ AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs @@ -400,6 +417,7 @@ enum AVCodecID { AV_CODEC_ID_ADPCM_IMA_CUNNING, AV_CODEC_ID_ADPCM_IMA_MOFLEX, AV_CODEC_ID_ADPCM_IMA_ACORN, + AV_CODEC_ID_ADPCM_XMD, /* AMR */ AV_CODEC_ID_AMR_NB = 0x12000, @@ -417,6 +435,8 @@ enum AVCodecID { AV_CODEC_ID_SDX2_DPCM, AV_CODEC_ID_GREMLIN_DPCM, AV_CODEC_ID_DERF_DPCM, + AV_CODEC_ID_WADY_DPCM, + AV_CODEC_ID_CBD2_DPCM, /* audio codecs */ AV_CODEC_ID_MP2 = 0x15000, @@ -514,6 +534,16 @@ enum AVCodecID { AV_CODEC_ID_SIREN, AV_CODEC_ID_HCA, AV_CODEC_ID_FASTAUDIO, + AV_CODEC_ID_MSNSIREN, + AV_CODEC_ID_DFPWM, + AV_CODEC_ID_BONK, + AV_CODEC_ID_MISC4, + AV_CODEC_ID_APAC, + AV_CODEC_ID_FTR, + AV_CODEC_ID_WAVARC, + AV_CODEC_ID_RKA, + AV_CODEC_ID_AC4, + AV_CODEC_ID_OSQ, /* subtitle codecs */ AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs. @@ -558,6 +588,7 @@ enum AVCodecID { AV_CODEC_ID_DVD_NAV, AV_CODEC_ID_TIMED_ID3, AV_CODEC_ID_BIN_DATA, + AV_CODEC_ID_SMPTE_2038, AV_CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify it @@ -568,6 +599,16 @@ enum AVCodecID { * stream (only used by libavformat) */ AV_CODEC_ID_FFMETADATA = 0x21000, ///< Dummy codec for streams containing only metadata information. AV_CODEC_ID_WRAPPED_AVFRAME = 0x21001, ///< Passthrough codec, AVFrames wrapped in AVPacket + /** + * Dummy null video codec, useful mainly for development and debugging. + * Null encoder/decoder discard all input and never return any output. + */ + AV_CODEC_ID_VNULL, + /** + * Dummy null audio codec, useful mainly for development and debugging. + * Null encoder/decoder discard all input and never return any output. + */ + AV_CODEC_ID_ANULL, }; /** diff --git a/library/FFmpeg/include/libavcodec/codec_par.h b/library/FFmpeg/include/libavcodec/codec_par.h index 10cf79df..64882a97 100644 --- a/library/FFmpeg/include/libavcodec/codec_par.h +++ b/library/FFmpeg/include/libavcodec/codec_par.h @@ -24,24 +24,19 @@ #include #include "libavutil/avutil.h" +#include "libavutil/channel_layout.h" #include "libavutil/rational.h" #include "libavutil/pixfmt.h" #include "codec_id.h" +#include "defs.h" +#include "packet.h" /** * @addtogroup lavc_core + * @{ */ -enum AVFieldOrder { - AV_FIELD_UNKNOWN, - AV_FIELD_PROGRESSIVE, - AV_FIELD_TT, //< Top coded_first, top displayed first - AV_FIELD_BB, //< Bottom coded first, bottom displayed first - AV_FIELD_TB, //< Top coded first, bottom displayed first - AV_FIELD_BT, //< Bottom coded first, top displayed first -}; - /** * This struct describes the properties of an encoded stream. * @@ -154,16 +149,22 @@ typedef struct AVCodecParameters { */ int video_delay; +#if FF_API_OLD_CHANNEL_LAYOUT /** * Audio only. The channel layout bitmask. May be 0 if the channel layout is * unknown or unspecified, otherwise the number of bits set must be equal to * the channels field. + * @deprecated use ch_layout */ + attribute_deprecated uint64_t channel_layout; /** * Audio only. The number of audio channels. + * @deprecated use ch_layout.nb_channels */ + attribute_deprecated int channels; +#endif /** * Audio only. The number of audio samples per second. */ @@ -198,6 +199,33 @@ typedef struct AVCodecParameters { * Audio only. Number of samples to skip after a discontinuity. */ int seek_preroll; + + /** + * Audio only. The channel layout and number of channels. + */ + AVChannelLayout ch_layout; + + /** + * Video only. Number of frames per second, for streams with constant frame + * durations. Should be set to { 0, 1 } when some frames have differing + * durations or if the value is not known. + * + * @note This field correponds to values that are stored in codec-level + * headers and is typically overridden by container/transport-layer + * timestamps, when available. It should thus be used only as a last resort, + * when no higher-level timing information is available. + */ + AVRational framerate; + + /** + * Additional data associated with the entire stream. + */ + AVPacketSideData *coded_side_data; + + /** + * Amount of entries in @ref coded_side_data. + */ + int nb_coded_side_data; } AVCodecParameters; /** diff --git a/library/FFmpeg/include/libavcodec/defs.h b/library/FFmpeg/include/libavcodec/defs.h index 420a042b..00d840ec 100644 --- a/library/FFmpeg/include/libavcodec/defs.h +++ b/library/FFmpeg/include/libavcodec/defs.h @@ -39,6 +39,171 @@ */ #define AV_INPUT_BUFFER_PADDING_SIZE 64 +/** + * Verify checksums embedded in the bitstream (could be of either encoded or + * decoded data, depending on the format) and print an error message on mismatch. + * If AV_EF_EXPLODE is also set, a mismatching checksum will result in the + * decoder/demuxer returning an error. + */ +#define AV_EF_CRCCHECK (1<<0) +#define AV_EF_BITSTREAM (1<<1) ///< detect bitstream specification deviations +#define AV_EF_BUFFER (1<<2) ///< detect improper bitstream length +#define AV_EF_EXPLODE (1<<3) ///< abort decoding on minor error detection + +#define AV_EF_IGNORE_ERR (1<<15) ///< ignore errors and continue +#define AV_EF_CAREFUL (1<<16) ///< consider things that violate the spec, are fast to calculate and have not been seen in the wild as errors +#define AV_EF_COMPLIANT (1<<17) ///< consider all spec non compliances as errors +#define AV_EF_AGGRESSIVE (1<<18) ///< consider things that a sane encoder/muxer should not do as an error + +#define FF_COMPLIANCE_VERY_STRICT 2 ///< Strictly conform to an older more strict version of the spec or reference software. +#define FF_COMPLIANCE_STRICT 1 ///< Strictly conform to all the things in the spec no matter what consequences. +#define FF_COMPLIANCE_NORMAL 0 +#define FF_COMPLIANCE_UNOFFICIAL -1 ///< Allow unofficial extensions +#define FF_COMPLIANCE_EXPERIMENTAL -2 ///< Allow nonstandardized experimental things. + + +#define AV_PROFILE_UNKNOWN -99 +#define AV_PROFILE_RESERVED -100 + +#define AV_PROFILE_AAC_MAIN 0 +#define AV_PROFILE_AAC_LOW 1 +#define AV_PROFILE_AAC_SSR 2 +#define AV_PROFILE_AAC_LTP 3 +#define AV_PROFILE_AAC_HE 4 +#define AV_PROFILE_AAC_HE_V2 28 +#define AV_PROFILE_AAC_LD 22 +#define AV_PROFILE_AAC_ELD 38 +#define AV_PROFILE_MPEG2_AAC_LOW 128 +#define AV_PROFILE_MPEG2_AAC_HE 131 + +#define AV_PROFILE_DNXHD 0 +#define AV_PROFILE_DNXHR_LB 1 +#define AV_PROFILE_DNXHR_SQ 2 +#define AV_PROFILE_DNXHR_HQ 3 +#define AV_PROFILE_DNXHR_HQX 4 +#define AV_PROFILE_DNXHR_444 5 + +#define AV_PROFILE_DTS 20 +#define AV_PROFILE_DTS_ES 30 +#define AV_PROFILE_DTS_96_24 40 +#define AV_PROFILE_DTS_HD_HRA 50 +#define AV_PROFILE_DTS_HD_MA 60 +#define AV_PROFILE_DTS_EXPRESS 70 +#define AV_PROFILE_DTS_HD_MA_X 61 +#define AV_PROFILE_DTS_HD_MA_X_IMAX 62 + +#define AV_PROFILE_EAC3_DDP_ATMOS 30 + +#define AV_PROFILE_TRUEHD_ATMOS 30 + +#define AV_PROFILE_MPEG2_422 0 +#define AV_PROFILE_MPEG2_HIGH 1 +#define AV_PROFILE_MPEG2_SS 2 +#define AV_PROFILE_MPEG2_SNR_SCALABLE 3 +#define AV_PROFILE_MPEG2_MAIN 4 +#define AV_PROFILE_MPEG2_SIMPLE 5 + +#define AV_PROFILE_H264_CONSTRAINED (1<<9) // 8+1; constraint_set1_flag +#define AV_PROFILE_H264_INTRA (1<<11) // 8+3; constraint_set3_flag + +#define AV_PROFILE_H264_BASELINE 66 +#define AV_PROFILE_H264_CONSTRAINED_BASELINE (66|AV_PROFILE_H264_CONSTRAINED) +#define AV_PROFILE_H264_MAIN 77 +#define AV_PROFILE_H264_EXTENDED 88 +#define AV_PROFILE_H264_HIGH 100 +#define AV_PROFILE_H264_HIGH_10 110 +#define AV_PROFILE_H264_HIGH_10_INTRA (110|AV_PROFILE_H264_INTRA) +#define AV_PROFILE_H264_MULTIVIEW_HIGH 118 +#define AV_PROFILE_H264_HIGH_422 122 +#define AV_PROFILE_H264_HIGH_422_INTRA (122|AV_PROFILE_H264_INTRA) +#define AV_PROFILE_H264_STEREO_HIGH 128 +#define AV_PROFILE_H264_HIGH_444 144 +#define AV_PROFILE_H264_HIGH_444_PREDICTIVE 244 +#define AV_PROFILE_H264_HIGH_444_INTRA (244|AV_PROFILE_H264_INTRA) +#define AV_PROFILE_H264_CAVLC_444 44 + +#define AV_PROFILE_VC1_SIMPLE 0 +#define AV_PROFILE_VC1_MAIN 1 +#define AV_PROFILE_VC1_COMPLEX 2 +#define AV_PROFILE_VC1_ADVANCED 3 + +#define AV_PROFILE_MPEG4_SIMPLE 0 +#define AV_PROFILE_MPEG4_SIMPLE_SCALABLE 1 +#define AV_PROFILE_MPEG4_CORE 2 +#define AV_PROFILE_MPEG4_MAIN 3 +#define AV_PROFILE_MPEG4_N_BIT 4 +#define AV_PROFILE_MPEG4_SCALABLE_TEXTURE 5 +#define AV_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION 6 +#define AV_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE 7 +#define AV_PROFILE_MPEG4_HYBRID 8 +#define AV_PROFILE_MPEG4_ADVANCED_REAL_TIME 9 +#define AV_PROFILE_MPEG4_CORE_SCALABLE 10 +#define AV_PROFILE_MPEG4_ADVANCED_CODING 11 +#define AV_PROFILE_MPEG4_ADVANCED_CORE 12 +#define AV_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE 13 +#define AV_PROFILE_MPEG4_SIMPLE_STUDIO 14 +#define AV_PROFILE_MPEG4_ADVANCED_SIMPLE 15 + +#define AV_PROFILE_JPEG2000_CSTREAM_RESTRICTION_0 1 +#define AV_PROFILE_JPEG2000_CSTREAM_RESTRICTION_1 2 +#define AV_PROFILE_JPEG2000_CSTREAM_NO_RESTRICTION 32768 +#define AV_PROFILE_JPEG2000_DCINEMA_2K 3 +#define AV_PROFILE_JPEG2000_DCINEMA_4K 4 + +#define AV_PROFILE_VP9_0 0 +#define AV_PROFILE_VP9_1 1 +#define AV_PROFILE_VP9_2 2 +#define AV_PROFILE_VP9_3 3 + +#define AV_PROFILE_HEVC_MAIN 1 +#define AV_PROFILE_HEVC_MAIN_10 2 +#define AV_PROFILE_HEVC_MAIN_STILL_PICTURE 3 +#define AV_PROFILE_HEVC_REXT 4 +#define AV_PROFILE_HEVC_SCC 9 + +#define AV_PROFILE_VVC_MAIN_10 1 +#define AV_PROFILE_VVC_MAIN_10_444 33 + +#define AV_PROFILE_AV1_MAIN 0 +#define AV_PROFILE_AV1_HIGH 1 +#define AV_PROFILE_AV1_PROFESSIONAL 2 + +#define AV_PROFILE_MJPEG_HUFFMAN_BASELINE_DCT 0xc0 +#define AV_PROFILE_MJPEG_HUFFMAN_EXTENDED_SEQUENTIAL_DCT 0xc1 +#define AV_PROFILE_MJPEG_HUFFMAN_PROGRESSIVE_DCT 0xc2 +#define AV_PROFILE_MJPEG_HUFFMAN_LOSSLESS 0xc3 +#define AV_PROFILE_MJPEG_JPEG_LS 0xf7 + +#define AV_PROFILE_SBC_MSBC 1 + +#define AV_PROFILE_PRORES_PROXY 0 +#define AV_PROFILE_PRORES_LT 1 +#define AV_PROFILE_PRORES_STANDARD 2 +#define AV_PROFILE_PRORES_HQ 3 +#define AV_PROFILE_PRORES_4444 4 +#define AV_PROFILE_PRORES_XQ 5 + +#define AV_PROFILE_ARIB_PROFILE_A 0 +#define AV_PROFILE_ARIB_PROFILE_C 1 + +#define AV_PROFILE_KLVA_SYNC 0 +#define AV_PROFILE_KLVA_ASYNC 1 + +#define AV_PROFILE_EVC_BASELINE 0 +#define AV_PROFILE_EVC_MAIN 1 + + +#define AV_LEVEL_UNKNOWN -99 + +enum AVFieldOrder { + AV_FIELD_UNKNOWN, + AV_FIELD_PROGRESSIVE, + AV_FIELD_TT, ///< Top coded_first, top displayed first + AV_FIELD_BB, ///< Bottom coded first, bottom displayed first + AV_FIELD_TB, ///< Top coded first, bottom displayed first + AV_FIELD_BT, ///< Bottom coded first, top displayed first +}; + /** * @ingroup lavc_decoding */ diff --git a/library/FFmpeg/include/libavcodec/dirac.h b/library/FFmpeg/include/libavcodec/dirac.h index e6d9d346..8c348cdc 100644 --- a/library/FFmpeg/include/libavcodec/dirac.h +++ b/library/FFmpeg/include/libavcodec/dirac.h @@ -31,7 +31,11 @@ * @author Jordi Ortiz */ -#include "avcodec.h" +#include +#include + +#include "libavutil/pixfmt.h" +#include "libavutil/rational.h" /** * The spec limits the number of wavelet decompositions to 4 for both diff --git a/library/FFmpeg/include/libavcodec/dv_profile.h b/library/FFmpeg/include/libavcodec/dv_profile.h index 9380a66f..4365f1b4 100644 --- a/library/FFmpeg/include/libavcodec/dv_profile.h +++ b/library/FFmpeg/include/libavcodec/dv_profile.h @@ -23,7 +23,6 @@ #include "libavutil/pixfmt.h" #include "libavutil/rational.h" -#include "avcodec.h" /* minimum number of bytes to read from a DV stream in order to * determine the profile */ diff --git a/library/FFmpeg/include/libavcodec/mediacodec.h b/library/FFmpeg/include/libavcodec/mediacodec.h index 4c8545df..4e9b56a6 100644 --- a/library/FFmpeg/include/libavcodec/mediacodec.h +++ b/library/FFmpeg/include/libavcodec/mediacodec.h @@ -88,13 +88,15 @@ int av_mediacodec_release_buffer(AVMediaCodecBuffer *buffer, int render); /** * Release a MediaCodec buffer and render it at the given time to the surface * that is associated with the decoder. The timestamp must be within one second - * of the current java/lang/System#nanoTime() (which is implemented using - * CLOCK_MONOTONIC on Android). See the Android MediaCodec documentation - * of android/media/MediaCodec#releaseOutputBuffer(int,long) for more details. + * of the current `java/lang/System#nanoTime()` (which is implemented using + * `CLOCK_MONOTONIC` on Android). See the Android MediaCodec documentation + * of [`android/media/MediaCodec#releaseOutputBuffer(int,long)`][0] for more details. * * @param buffer the buffer to render * @param time timestamp in nanoseconds of when to render the buffer * @return 0 on success, < 0 otherwise + * + * [0]: https://developer.android.com/reference/android/media/MediaCodec#releaseOutputBuffer(int,%20long) */ int av_mediacodec_render_buffer_at_time(AVMediaCodecBuffer *buffer, int64_t time); diff --git a/library/FFmpeg/include/libavcodec/packet.h b/library/FFmpeg/include/libavcodec/packet.h index a9d3a9b5..b19409b7 100644 --- a/library/FFmpeg/include/libavcodec/packet.h +++ b/library/FFmpeg/include/libavcodec/packet.h @@ -28,13 +28,14 @@ #include "libavutil/buffer.h" #include "libavutil/dict.h" #include "libavutil/rational.h" +#include "libavutil/version.h" -#include "libavcodec/version.h" +#include "libavcodec/version_major.h" /** - * @defgroup lavc_packet AVPacket + * @defgroup lavc_packet_side_data AVPacketSideData * - * Types and functions for working with AVPacket. + * Types and functions for working with AVPacketSideData. * @{ */ enum AVPacketSideDataType { @@ -160,7 +161,7 @@ enum AVPacketSideDataType { * the packet may contain "dual mono" audio specific to Japanese DTV * and if it is true, recommends only the selected channel to be used. * @code - * u8 selected channels (0=mail/left, 1=sub/right, 2=both) + * u8 selected channels (0=main/left, 1=sub/right, 2=both) * @endcode */ AV_PKT_DATA_JP_DUALMONO, @@ -311,12 +312,129 @@ enum AVPacketSideDataType { #define AV_PKT_DATA_QUALITY_FACTOR AV_PKT_DATA_QUALITY_STATS //DEPRECATED +/** + * This structure stores auxiliary information for decoding, presenting, or + * otherwise processing the coded stream. It is typically exported by demuxers + * and encoders and can be fed to decoders and muxers either in a per packet + * basis, or as global side data (applying to the entire coded stream). + * + * Global side data is handled as follows: + * - During demuxing, it may be exported through + * @ref AVStream.codecpar.side_data "AVStream's codec parameters", which can + * then be passed as input to decoders through the + * @ref AVCodecContext.coded_side_data "decoder context's side data", for + * initialization. + * - For muxing, it can be fed through @ref AVStream.codecpar.side_data + * "AVStream's codec parameters", typically the output of encoders through + * the @ref AVCodecContext.coded_side_data "encoder context's side data", for + * initialization. + * + * Packet specific side data is handled as follows: + * - During demuxing, it may be exported through @ref AVPacket.side_data + * "AVPacket's side data", which can then be passed as input to decoders. + * - For muxing, it can be fed through @ref AVPacket.side_data "AVPacket's + * side data", typically the output of encoders. + * + * Different modules may accept or export different types of side data + * depending on media type and codec. Refer to @ref AVPacketSideDataType for a + * list of defined types and where they may be found or used. + */ typedef struct AVPacketSideData { uint8_t *data; size_t size; enum AVPacketSideDataType type; } AVPacketSideData; +/** + * Allocate a new packet side data. + * + * @param sd pointer to an array of side data to which the side data should + * be added. *sd may be NULL, in which case the array will be + * initialized. + * @param nb_sd pointer to an integer containing the number of entries in + * the array. The integer value will be increased by 1 on success. + * @param type side data type + * @param size desired side data size + * @param flags currently unused. Must be zero + * + * @return pointer to freshly allocated side data on success, or NULL otherwise. + */ +AVPacketSideData *av_packet_side_data_new(AVPacketSideData **psd, int *pnb_sd, + enum AVPacketSideDataType type, + size_t size, int flags); + +/** + * Wrap existing data as packet side data. + * + * @param sd pointer to an array of side data to which the side data should + * be added. *sd may be NULL, in which case the array will be + * initialized + * @param nb_sd pointer to an integer containing the number of entries in + * the array. The integer value will be increased by 1 on success. + * @param type side data type + * @param data a data array. It must be allocated with the av_malloc() family + * of functions. The ownership of the data is transferred to the + * side data array on success + * @param size size of the data array + * @param flags currently unused. Must be zero + * + * @return pointer to freshly allocated side data on success, or NULL otherwise + * On failure, the side data array is unchanged and the data remains + * owned by the caller. + */ +AVPacketSideData *av_packet_side_data_add(AVPacketSideData **sd, int *nb_sd, + enum AVPacketSideDataType type, + void *data, size_t size, int flags); + +/** + * Get side information from a side data array. + * + * @param sd the array from which the side data should be fetched + * @param nb_sd value containing the number of entries in the array. + * @param type desired side information type + * + * @return pointer to side data if present or NULL otherwise + */ +const AVPacketSideData *av_packet_side_data_get(const AVPacketSideData *sd, + int nb_sd, + enum AVPacketSideDataType type); + +/** + * Remove side data of the given type from a side data array. + * + * @param sd the array from which the side data should be removed + * @param nb_sd pointer to an integer containing the number of entries in + * the array. Will be reduced by the amount of entries removed + * upon return + * @param type side information type + */ +void av_packet_side_data_remove(AVPacketSideData *sd, int *nb_sd, + enum AVPacketSideDataType type); + +/** + * Convenience function to free all the side data stored in an array, and + * the array itself. + * + * @param sd pointer to array of side data to free. Will be set to NULL + * upon return. + * @param nb_sd pointer to an integer containing the number of entries in + * the array. Will be set to 0 upon return. + */ +void av_packet_side_data_free(AVPacketSideData **sd, int *nb_sd); + +const char *av_packet_side_data_name(enum AVPacketSideDataType type); + +/** + * @} + */ + +/** + * @defgroup lavc_packet AVPacket + * + * Types and functions for working with AVPacket. + * @{ + */ + /** * This structure stores compressed data. It is typically exported by demuxers * and then passed as input to decoders, or received as output from encoders and @@ -391,6 +509,30 @@ typedef struct AVPacket { int64_t duration; int64_t pos; ///< byte position in stream, -1 if unknown + + /** + * for some private data of the user + */ + void *opaque; + + /** + * AVBufferRef for free use by the API user. FFmpeg will never check the + * contents of the buffer ref. FFmpeg calls av_buffer_unref() on it when + * the packet is unreferenced. av_packet_copy_props() calls create a new + * reference with av_buffer_ref() for the target packet's opaque_ref field. + * + * This is unrelated to the opaque field, although it serves a similar + * purpose. + */ + AVBufferRef *opaque_ref; + + /** + * Time base of the packet's timestamps. + * In the future, this field may be set on packets output by encoders or + * demuxers, but its value will be by default ignored on input to decoders + * or muxers. + */ + AVRational time_base; } AVPacket; #if FF_API_INIT_PACKET @@ -423,8 +565,13 @@ typedef struct AVPacketList { #define AV_PKT_FLAG_DISPOSABLE 0x0010 enum AVSideDataParamChangeFlags { +#if FF_API_OLD_CHANNEL_LAYOUT + /** + * @deprecated those are not used by any decoder + */ AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT = 0x0001, AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT = 0x0002, +#endif AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE = 0x0004, AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS = 0x0008, }; @@ -573,8 +720,6 @@ int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type, uint8_t* av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, size_t *size); -const char *av_packet_side_data_name(enum AVPacketSideDataType type); - /** * Pack a dictionary for use in side_data. * diff --git a/library/FFmpeg/include/libavcodec/qsv.h b/library/FFmpeg/include/libavcodec/qsv.h index b77158ec..c156b08d 100644 --- a/library/FFmpeg/include/libavcodec/qsv.h +++ b/library/FFmpeg/include/libavcodec/qsv.h @@ -21,7 +21,7 @@ #ifndef AVCODEC_QSV_H #define AVCODEC_QSV_H -#include +#include #include "libavutil/buffer.h" @@ -61,6 +61,8 @@ typedef struct AVQSVContext { * required by the encoder and the user-provided value nb_opaque_surfaces. * The array of the opaque surfaces will be exported to the caller through * the opaque_surfaces field. + * + * The caller must set this field to zero for oneVPL (MFX_VERSION >= 2.0) */ int opaque_alloc; diff --git a/library/FFmpeg/include/libavcodec/vdpau.h b/library/FFmpeg/include/libavcodec/vdpau.h index 3010094d..35c4b109 100644 --- a/library/FFmpeg/include/libavcodec/vdpau.h +++ b/library/FFmpeg/include/libavcodec/vdpau.h @@ -152,6 +152,6 @@ int av_vdpau_get_surface_parameters(AVCodecContext *avctx, VdpChromaType *type, */ AVVDPAUContext *av_vdpau_alloc_context(void); -/* @}*/ +/** @} */ #endif /* AVCODEC_VDPAU_H */ diff --git a/library/FFmpeg/include/libavcodec/version.h b/library/FFmpeg/include/libavcodec/version.h index 91325ce4..d6f1440d 100644 --- a/library/FFmpeg/include/libavcodec/version.h +++ b/library/FFmpeg/include/libavcodec/version.h @@ -27,8 +27,9 @@ #include "libavutil/version.h" -#define LIBAVCODEC_VERSION_MAJOR 59 -#define LIBAVCODEC_VERSION_MINOR 3 +#include "version_major.h" + +#define LIBAVCODEC_VERSION_MINOR 32 #define LIBAVCODEC_VERSION_MICRO 102 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ @@ -41,45 +42,4 @@ #define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION) -/** - * FF_API_* defines may be placed below to indicate public API that will be - * dropped at a future version bump. The defines themselves are not part of - * the public API and may change, break or disappear at any time. - * - * @note, when bumping the major version it is recommended to manually - * disable each FF_API_* in its own commit instead of disabling them all - * at once through the bump. This improves the git bisect-ability of the change. - */ - -#ifndef FF_API_OPENH264_SLICE_MODE -#define FF_API_OPENH264_SLICE_MODE (LIBAVCODEC_VERSION_MAJOR < 60) -#endif -#ifndef FF_API_OPENH264_CABAC -#define FF_API_OPENH264_CABAC (LIBAVCODEC_VERSION_MAJOR < 60) -#endif -#ifndef FF_API_UNUSED_CODEC_CAPS -#define FF_API_UNUSED_CODEC_CAPS (LIBAVCODEC_VERSION_MAJOR < 60) -#endif -#ifndef FF_API_THREAD_SAFE_CALLBACKS -#define FF_API_THREAD_SAFE_CALLBACKS (LIBAVCODEC_VERSION_MAJOR < 60) -#endif -#ifndef FF_API_DEBUG_MV -#define FF_API_DEBUG_MV (LIBAVCODEC_VERSION_MAJOR < 60) -#endif -#ifndef FF_API_GET_FRAME_CLASS -#define FF_API_GET_FRAME_CLASS (LIBAVCODEC_VERSION_MAJOR < 60) -#endif -#ifndef FF_API_AUTO_THREADS -#define FF_API_AUTO_THREADS (LIBAVCODEC_VERSION_MAJOR < 60) -#endif -#ifndef FF_API_INIT_PACKET -#define FF_API_INIT_PACKET (LIBAVCODEC_VERSION_MAJOR < 60) -#endif -#ifndef FF_API_AVCTX_TIMEBASE -#define FF_API_AVCTX_TIMEBASE (LIBAVCODEC_VERSION_MAJOR < 60) -#endif -#ifndef FF_API_MPEGVIDEO_OPTS -#define FF_API_MPEGVIDEO_OPTS (LIBAVCODEC_VERSION_MAJOR < 60) -#endif - #endif /* AVCODEC_VERSION_H */ diff --git a/library/FFmpeg/include/libavcodec/version_major.h b/library/FFmpeg/include/libavcodec/version_major.h new file mode 100644 index 00000000..b9164fe5 --- /dev/null +++ b/library/FFmpeg/include/libavcodec/version_major.h @@ -0,0 +1,59 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_VERSION_MAJOR_H +#define AVCODEC_VERSION_MAJOR_H + +/** + * @file + * @ingroup libavc + * Libavcodec version macros. + */ + +#define LIBAVCODEC_VERSION_MAJOR 60 + +/** + * FF_API_* defines may be placed below to indicate public API that will be + * dropped at a future version bump. The defines themselves are not part of + * the public API and may change, break or disappear at any time. + * + * @note, when bumping the major version it is recommended to manually + * disable each FF_API_* in its own commit instead of disabling them all + * at once through the bump. This improves the git bisect-ability of the change. + */ + +#define FF_API_INIT_PACKET (LIBAVCODEC_VERSION_MAJOR < 61) +#define FF_API_IDCT_NONE (LIBAVCODEC_VERSION_MAJOR < 61) +#define FF_API_SVTAV1_OPTS (LIBAVCODEC_VERSION_MAJOR < 61) +#define FF_API_AYUV_CODECID (LIBAVCODEC_VERSION_MAJOR < 61) +#define FF_API_VT_OUTPUT_CALLBACK (LIBAVCODEC_VERSION_MAJOR < 61) +#define FF_API_AVCODEC_CHROMA_POS (LIBAVCODEC_VERSION_MAJOR < 61) +#define FF_API_VT_HWACCEL_CONTEXT (LIBAVCODEC_VERSION_MAJOR < 61) +#define FF_API_AVCTX_FRAME_NUMBER (LIBAVCODEC_VERSION_MAJOR < 61) +#define FF_API_SLICE_OFFSET (LIBAVCODEC_VERSION_MAJOR < 61) +#define FF_API_SUBFRAMES (LIBAVCODEC_VERSION_MAJOR < 61) +#define FF_API_TICKS_PER_FRAME (LIBAVCODEC_VERSION_MAJOR < 61) +#define FF_API_DROPCHANGED (LIBAVCODEC_VERSION_MAJOR < 61) + +#define FF_API_AVFFT (LIBAVCODEC_VERSION_MAJOR < 62) +#define FF_API_FF_PROFILE_LEVEL (LIBAVCODEC_VERSION_MAJOR < 62) + +// reminder to remove CrystalHD decoders on next major bump +#define FF_CODEC_CRYSTAL_HD (LIBAVCODEC_VERSION_MAJOR < 61) + +#endif /* AVCODEC_VERSION_MAJOR_H */ diff --git a/library/FFmpeg/include/libavcodec/videotoolbox.h b/library/FFmpeg/include/libavcodec/videotoolbox.h index af2db0d5..ba5eddbf 100644 --- a/library/FFmpeg/include/libavcodec/videotoolbox.h +++ b/library/FFmpeg/include/libavcodec/videotoolbox.h @@ -29,6 +29,15 @@ * Public libavcodec Videotoolbox header. */ +/** + * @defgroup lavc_codec_hwaccel_videotoolbox VideoToolbox Decoder + * @ingroup lavc_codec_hwaccel + * + * Hardware accelerated decoding using VideoToolbox on Apple Platforms + * + * @{ + */ + #include #define Picture QuickdrawPicture @@ -37,6 +46,8 @@ #include "libavcodec/avcodec.h" +#include "libavutil/attributes.h" + /** * This struct holds all the information that needs to be passed * between the caller and libavcodec for initializing Videotoolbox decoding. @@ -46,15 +57,17 @@ typedef struct AVVideotoolboxContext { /** * Videotoolbox decompression session object. - * Created and freed the caller. */ VTDecompressionSessionRef session; +#if FF_API_VT_OUTPUT_CALLBACK /** * The output callback that must be passed to the session. * Set by av_videottoolbox_default_init() */ + attribute_deprecated VTDecompressionOutputCallback output_callback; +#endif /** * CVPixelBuffer Format Type that Videotoolbox will use for decoded frames. @@ -65,17 +78,17 @@ typedef struct AVVideotoolboxContext { /** * CoreMedia Format Description that Videotoolbox will use to create the decompression session. - * Set by the caller. */ CMVideoFormatDescriptionRef cm_fmt_desc; /** * CoreMedia codec type that Videotoolbox will use to create the decompression session. - * Set by the caller. */ int cm_codec_type; } AVVideotoolboxContext; +#if FF_API_VT_HWACCEL_CONTEXT + /** * Allocate and initialize a Videotoolbox context. * @@ -88,7 +101,9 @@ typedef struct AVVideotoolboxContext { * object and free the Videotoolbox context using av_free(). * * @return the newly allocated context or NULL on failure + * @deprecated Use AVCodecContext.hw_frames_ctx or hw_device_ctx instead. */ +attribute_deprecated AVVideotoolboxContext *av_videotoolbox_alloc_context(void); /** @@ -98,7 +113,9 @@ AVVideotoolboxContext *av_videotoolbox_alloc_context(void); * @param avctx the corresponding codec context * * @return >= 0 on success, a negative AVERROR code on failure + * @deprecated Use AVCodecContext.hw_frames_ctx or hw_device_ctx instead. */ +attribute_deprecated int av_videotoolbox_default_init(AVCodecContext *avctx); /** @@ -109,7 +126,9 @@ int av_videotoolbox_default_init(AVCodecContext *avctx); * @param vtctx the Videotoolbox context to use * * @return >= 0 on success, a negative AVERROR code on failure + * @deprecated Use AVCodecContext.hw_frames_ctx or hw_device_ctx instead. */ +attribute_deprecated int av_videotoolbox_default_init2(AVCodecContext *avctx, AVVideotoolboxContext *vtctx); /** @@ -117,9 +136,13 @@ int av_videotoolbox_default_init2(AVCodecContext *avctx, AVVideotoolboxContext * * av_videotoolbox_default_init(). * * @param avctx the corresponding codec context + * @deprecated Use AVCodecContext.hw_frames_ctx or hw_device_ctx instead. */ +attribute_deprecated void av_videotoolbox_default_free(AVCodecContext *avctx); +#endif /* FF_API_VT_HWACCEL_CONTEXT */ + /** * @} */ diff --git a/library/FFmpeg/include/libavcodec/xvmc.h b/library/FFmpeg/include/libavcodec/xvmc.h index 465ee78d..52e70c0d 100644 --- a/library/FFmpeg/include/libavcodec/xvmc.h +++ b/library/FFmpeg/include/libavcodec/xvmc.h @@ -27,10 +27,11 @@ * Public libavcodec XvMC header. */ +#pragma message("XvMC is no longer supported; this header is deprecated and will be removed") + #include #include "libavutil/attributes.h" -#include "version.h" #include "avcodec.h" /** diff --git a/library/FFmpeg/include/libavfilter/avfilter.h b/library/FFmpeg/include/libavfilter/avfilter.h index b82f72d0..d69381ae 100644 --- a/library/FFmpeg/include/libavfilter/avfilter.h +++ b/library/FFmpeg/include/libavfilter/avfilter.h @@ -47,7 +47,13 @@ #include "libavutil/pixfmt.h" #include "libavutil/rational.h" +#include "libavfilter/version_major.h" +#ifndef HAVE_AV_CONFIG_H +/* When included as part of the ffmpeg build, only include the major version + * to avoid unnecessary rebuilds. When included externally, keep including + * the full version information. */ #include "libavfilter/version.h" +#endif /** * Return the LIBAVFILTER_VERSION_INT constant. @@ -70,12 +76,6 @@ typedef struct AVFilterPad AVFilterPad; typedef struct AVFilterFormats AVFilterFormats; typedef struct AVFilterChannelLayouts AVFilterChannelLayouts; -/** - * Get the number of elements in a NULL-terminated array of AVFilterPads (e.g. - * AVFilter.inputs/outputs). - */ -int avfilter_pad_count(const AVFilterPad *pads); - /** * Get the name of an AVFilterPad. * @@ -115,6 +115,27 @@ enum AVMediaType avfilter_pad_get_type(const AVFilterPad *pads, int pad_idx); * and processing them concurrently. */ #define AVFILTER_FLAG_SLICE_THREADS (1 << 2) +/** + * The filter is a "metadata" filter - it does not modify the frame data in any + * way. It may only affect the metadata (i.e. those fields copied by + * av_frame_copy_props()). + * + * More precisely, this means: + * - video: the data of any frame output by the filter must be exactly equal to + * some frame that is received on one of its inputs. Furthermore, all frames + * produced on a given output must correspond to frames received on the same + * input and their order must be unchanged. Note that the filter may still + * drop or duplicate the frames. + * - audio: the data produced by the filter on any of its outputs (viewed e.g. + * as an array of interleaved samples) must be exactly equal to the data + * received by the filter on one of its inputs. + */ +#define AVFILTER_FLAG_METADATA_ONLY (1 << 3) + +/** + * The filter can create hardware frames using AVFilterContext.hw_device_ctx. + */ +#define AVFILTER_FLAG_HWDEVICE (1 << 4) /** * Some filters support a generic "enable" expression option that can be used * to enable or disable a filter in the timeline. Filters supporting this @@ -156,15 +177,16 @@ typedef struct AVFilter { const char *description; /** - * List of inputs, terminated by a zeroed element. + * List of static inputs. * * NULL if there are no (static) inputs. Instances of filters with * AVFILTER_FLAG_DYNAMIC_INPUTS set may have more inputs than present in * this list. */ const AVFilterPad *inputs; + /** - * List of outputs, terminated by a zeroed element. + * List of static outputs. * * NULL if there are no (static) outputs. Instances of filters with * AVFILTER_FLAG_DYNAMIC_OUTPUTS set may have more outputs than present in @@ -195,6 +217,22 @@ typedef struct AVFilter { ***************************************************************** */ + /** + * The number of entries in the list of inputs. + */ + uint8_t nb_inputs; + + /** + * The number of entries in the list of outputs. + */ + uint8_t nb_outputs; + + /** + * This field determines the state of the formats union. + * It is an enum FilterFormatsState value. + */ + uint8_t formats_state; + /** * Filter pre-initialization function * @@ -233,19 +271,6 @@ typedef struct AVFilter { */ int (*init)(AVFilterContext *ctx); - /** - * Should be set instead of @ref AVFilter.init "init" by the filters that - * want to pass a dictionary of AVOptions to nested contexts that are - * allocated during init. - * - * On return, the options dict should be freed and replaced with one that - * contains all the options which could not be processed by this filter (or - * with NULL if all the options were processed). - * - * Otherwise the semantics is the same as for @ref AVFilter.init "init". - */ - int (*init_dict)(AVFilterContext *ctx, AVDictionary **options); - /** * Filter uninitialization function. * @@ -259,28 +284,69 @@ typedef struct AVFilter { void (*uninit)(AVFilterContext *ctx); /** - * Query formats supported by the filter on its inputs and outputs. - * - * This callback is called after the filter is initialized (so the inputs - * and outputs are fixed), shortly before the format negotiation. This - * callback may be called more than once. - * - * This callback must set AVFilterLink.outcfg.formats on every input link and - * AVFilterLink.incfg.formats on every output link to a list of pixel/sample - * formats that the filter supports on that link. For audio links, this - * filter must also set @ref AVFilterLink.incfg.samplerates "in_samplerates" / - * @ref AVFilterLink.outcfg.samplerates "out_samplerates" and - * @ref AVFilterLink.incfg.channel_layouts "in_channel_layouts" / - * @ref AVFilterLink.outcfg.channel_layouts "out_channel_layouts" analogously. - * - * This callback may be NULL for filters with one input, in which case - * libavfilter assumes that it supports all input formats and preserves - * them on output. - * - * @return zero on success, a negative value corresponding to an - * AVERROR code otherwise + * The state of the following union is determined by formats_state. + * See the documentation of enum FilterFormatsState in internal.h. */ - int (*query_formats)(AVFilterContext *); + union { + /** + * Query formats supported by the filter on its inputs and outputs. + * + * This callback is called after the filter is initialized (so the inputs + * and outputs are fixed), shortly before the format negotiation. This + * callback may be called more than once. + * + * This callback must set ::AVFilterLink's + * @ref AVFilterFormatsConfig.formats "outcfg.formats" + * on every input link and + * @ref AVFilterFormatsConfig.formats "incfg.formats" + * on every output link to a list of pixel/sample formats that the filter + * supports on that link. + * For audio links, this filter must also set + * @ref AVFilterFormatsConfig.samplerates "incfg.samplerates" + * / + * @ref AVFilterFormatsConfig.samplerates "outcfg.samplerates" + * and @ref AVFilterFormatsConfig.channel_layouts "incfg.channel_layouts" + * / + * @ref AVFilterFormatsConfig.channel_layouts "outcfg.channel_layouts" + * analogously. + * + * This callback must never be NULL if the union is in this state. + * + * @return zero on success, a negative value corresponding to an + * AVERROR code otherwise + */ + int (*query_func)(AVFilterContext *); + /** + * A pointer to an array of admissible pixel formats delimited + * by AV_PIX_FMT_NONE. The generic code will use this list + * to indicate that this filter supports each of these pixel formats, + * provided that all inputs and outputs use the same pixel format. + * + * This list must never be NULL if the union is in this state. + * The type of all inputs and outputs of filters using this must + * be AVMEDIA_TYPE_VIDEO. + */ + const enum AVPixelFormat *pixels_list; + /** + * Analogous to pixels, but delimited by AV_SAMPLE_FMT_NONE + * and restricted to filters that only have AVMEDIA_TYPE_AUDIO + * inputs and outputs. + * + * In addition to that the generic code will mark all inputs + * and all outputs as supporting all sample rates and every + * channel count and channel layout, as long as all inputs + * and outputs use the same sample rate and channel count/layout. + */ + const enum AVSampleFormat *samples_list; + /** + * Equivalent to { pix_fmt, AV_PIX_FMT_NONE } as pixels_list. + */ + enum AVPixelFormat pix_fmt; + /** + * Equivalent to { sample_fmt, AV_SAMPLE_FMT_NONE } as samples_list. + */ + enum AVSampleFormat sample_fmt; + } formats; int priv_size; ///< size of private data to allocate for the filter @@ -300,13 +366,6 @@ typedef struct AVFilter { */ int (*process_command)(AVFilterContext *, const char *cmd, const char *arg, char *res, int res_len, int flags); - /** - * Filter initialization function, alternative to the init() - * callback. Args contains the user-supplied parameters, opaque is - * used for providing binary data. - */ - int (*init_opaque)(AVFilterContext *ctx, void *opaque); - /** * Filter activation function. * @@ -322,6 +381,11 @@ typedef struct AVFilter { int (*activate)(AVFilterContext *ctx); } AVFilter; +/** + * Get the number of elements in an AVFilter's inputs or outputs array. + */ +unsigned avfilter_filter_pad_count(const AVFilter *filter, int is_output); + /** * Process multiple parts of the frame concurrently. */ @@ -385,6 +449,10 @@ struct AVFilterContext { * in particular, a filter which consumes or processes hardware frames will * instead use the hw_frames_ctx field in AVFilterLink to carry the * hardware context information. + * + * May be set by the caller on filters flagged with AVFILTER_FLAG_HWDEVICE + * before initializing the filter with avfilter_init_str() or + * avfilter_init_dict(). */ AVBufferRef *hw_device_ctx; @@ -474,7 +542,14 @@ struct AVFilterLink { int h; ///< agreed upon image height AVRational sample_aspect_ratio; ///< agreed upon sample aspect ratio /* These parameters apply only to audio */ - uint64_t channel_layout; ///< channel layout of current buffer (see libavutil/channel_layout.h) +#if FF_API_OLD_CHANNEL_LAYOUT + /** + * channel layout of current buffer (see libavutil/channel_layout.h) + * @deprecated use ch_layout + */ + attribute_deprecated + uint64_t channel_layout; +#endif int sample_rate; ///< samples per second int format; ///< agreed upon media format @@ -488,6 +563,8 @@ struct AVFilterLink { */ AVRational time_base; + AVChannelLayout ch_layout; ///< channel layout of current buffer (see libavutil/channel_layout.h) + /***************************************************************** * All fields below this line are not part of the public API. They * may not be used outside of libavfilter and can be changed and @@ -548,20 +625,9 @@ struct AVFilterLink { */ AVRational frame_rate; - /** - * Buffer partially filled with samples to achieve a fixed/minimum size. - */ - AVFrame *partial_buf; - - /** - * Size of the partial buffer to allocate. - * Must be between min_samples and max_samples. - */ - int partial_buf_size; - /** * Minimum number of samples to filter at once. If filter_frame() is - * called with fewer samples, it will accumulate them in partial_buf. + * called with fewer samples, it will accumulate them in fifo. * This field and the related ones must not be changed after filtering * has started. * If 0, all related fields are ignored. @@ -575,14 +641,14 @@ struct AVFilterLink { int max_samples; /** - * Number of channels. + * Number of past frames sent through the link. */ - int channels; + int64_t frame_count_in, frame_count_out; /** - * Number of past frames sent through the link. + * Number of past samples sent through the link. */ - int64_t frame_count_in, frame_count_out; + int64_t sample_count_in, sample_count_out; /** * A pointer to a FFFramePool struct. @@ -1051,6 +1117,317 @@ int avfilter_graph_parse2(AVFilterGraph *graph, const char *filters, AVFilterInOut **inputs, AVFilterInOut **outputs); +/** + * Parameters of a filter's input or output pad. + * + * Created as a child of AVFilterParams by avfilter_graph_segment_parse(). + * Freed in avfilter_graph_segment_free(). + */ +typedef struct AVFilterPadParams { + /** + * An av_malloc()'ed string containing the pad label. + * + * May be av_free()'d and set to NULL by the caller, in which case this pad + * will be treated as unlabeled for linking. + * May also be replaced by another av_malloc()'ed string. + */ + char *label; +} AVFilterPadParams; + +/** + * Parameters describing a filter to be created in a filtergraph. + * + * Created as a child of AVFilterGraphSegment by avfilter_graph_segment_parse(). + * Freed in avfilter_graph_segment_free(). + */ +typedef struct AVFilterParams { + /** + * The filter context. + * + * Created by avfilter_graph_segment_create_filters() based on + * AVFilterParams.filter_name and instance_name. + * + * Callers may also create the filter context manually, then they should + * av_free() filter_name and set it to NULL. Such AVFilterParams instances + * are then skipped by avfilter_graph_segment_create_filters(). + */ + AVFilterContext *filter; + + /** + * Name of the AVFilter to be used. + * + * An av_malloc()'ed string, set by avfilter_graph_segment_parse(). Will be + * passed to avfilter_get_by_name() by + * avfilter_graph_segment_create_filters(). + * + * Callers may av_free() this string and replace it with another one or + * NULL. If the caller creates the filter instance manually, this string + * MUST be set to NULL. + * + * When both AVFilterParams.filter an AVFilterParams.filter_name are NULL, + * this AVFilterParams instance is skipped by avfilter_graph_segment_*() + * functions. + */ + char *filter_name; + /** + * Name to be used for this filter instance. + * + * An av_malloc()'ed string, may be set by avfilter_graph_segment_parse() or + * left NULL. The caller may av_free() this string and replace with another + * one or NULL. + * + * Will be used by avfilter_graph_segment_create_filters() - passed as the + * third argument to avfilter_graph_alloc_filter(), then freed and set to + * NULL. + */ + char *instance_name; + + /** + * Options to be apllied to the filter. + * + * Filled by avfilter_graph_segment_parse(). Afterwards may be freely + * modified by the caller. + * + * Will be applied to the filter by avfilter_graph_segment_apply_opts() + * with an equivalent of av_opt_set_dict2(filter, &opts, AV_OPT_SEARCH_CHILDREN), + * i.e. any unapplied options will be left in this dictionary. + */ + AVDictionary *opts; + + AVFilterPadParams **inputs; + unsigned nb_inputs; + + AVFilterPadParams **outputs; + unsigned nb_outputs; +} AVFilterParams; + +/** + * A filterchain is a list of filter specifications. + * + * Created as a child of AVFilterGraphSegment by avfilter_graph_segment_parse(). + * Freed in avfilter_graph_segment_free(). + */ +typedef struct AVFilterChain { + AVFilterParams **filters; + size_t nb_filters; +} AVFilterChain; + +/** + * A parsed representation of a filtergraph segment. + * + * A filtergraph segment is conceptually a list of filterchains, with some + * supplementary information (e.g. format conversion flags). + * + * Created by avfilter_graph_segment_parse(). Must be freed with + * avfilter_graph_segment_free(). + */ +typedef struct AVFilterGraphSegment { + /** + * The filtergraph this segment is associated with. + * Set by avfilter_graph_segment_parse(). + */ + AVFilterGraph *graph; + + /** + * A list of filter chain contained in this segment. + * Set in avfilter_graph_segment_parse(). + */ + AVFilterChain **chains; + size_t nb_chains; + + /** + * A string containing a colon-separated list of key=value options applied + * to all scale filters in this segment. + * + * May be set by avfilter_graph_segment_parse(). + * The caller may free this string with av_free() and replace it with a + * different av_malloc()'ed string. + */ + char *scale_sws_opts; +} AVFilterGraphSegment; + +/** + * Parse a textual filtergraph description into an intermediate form. + * + * This intermediate representation is intended to be modified by the caller as + * described in the documentation of AVFilterGraphSegment and its children, and + * then applied to the graph either manually or with other + * avfilter_graph_segment_*() functions. See the documentation for + * avfilter_graph_segment_apply() for the canonical way to apply + * AVFilterGraphSegment. + * + * @param graph Filter graph the parsed segment is associated with. Will only be + * used for logging and similar auxiliary purposes. The graph will + * not be actually modified by this function - the parsing results + * are instead stored in seg for further processing. + * @param graph_str a string describing the filtergraph segment + * @param flags reserved for future use, caller must set to 0 for now + * @param seg A pointer to the newly-created AVFilterGraphSegment is written + * here on success. The graph segment is owned by the caller and must + * be freed with avfilter_graph_segment_free() before graph itself is + * freed. + * + * @retval "non-negative number" success + * @retval "negative error code" failure + */ +int avfilter_graph_segment_parse(AVFilterGraph *graph, const char *graph_str, + int flags, AVFilterGraphSegment **seg); + +/** + * Create filters specified in a graph segment. + * + * Walk through the creation-pending AVFilterParams in the segment and create + * new filter instances for them. + * Creation-pending params are those where AVFilterParams.filter_name is + * non-NULL (and hence AVFilterParams.filter is NULL). All other AVFilterParams + * instances are ignored. + * + * For any filter created by this function, the corresponding + * AVFilterParams.filter is set to the newly-created filter context, + * AVFilterParams.filter_name and AVFilterParams.instance_name are freed and set + * to NULL. + * + * @param seg the filtergraph segment to process + * @param flags reserved for future use, caller must set to 0 for now + * + * @retval "non-negative number" Success, all creation-pending filters were + * successfully created + * @retval AVERROR_FILTER_NOT_FOUND some filter's name did not correspond to a + * known filter + * @retval "another negative error code" other failures + * + * @note Calling this function multiple times is safe, as it is idempotent. + */ +int avfilter_graph_segment_create_filters(AVFilterGraphSegment *seg, int flags); + +/** + * Apply parsed options to filter instances in a graph segment. + * + * Walk through all filter instances in the graph segment that have option + * dictionaries associated with them and apply those options with + * av_opt_set_dict2(..., AV_OPT_SEARCH_CHILDREN). AVFilterParams.opts is + * replaced by the dictionary output by av_opt_set_dict2(), which should be + * empty (NULL) if all options were successfully applied. + * + * If any options could not be found, this function will continue processing all + * other filters and finally return AVERROR_OPTION_NOT_FOUND (unless another + * error happens). The calling program may then deal with unapplied options as + * it wishes. + * + * Any creation-pending filters (see avfilter_graph_segment_create_filters()) + * present in the segment will cause this function to fail. AVFilterParams with + * no associated filter context are simply skipped. + * + * @param seg the filtergraph segment to process + * @param flags reserved for future use, caller must set to 0 for now + * + * @retval "non-negative number" Success, all options were successfully applied. + * @retval AVERROR_OPTION_NOT_FOUND some options were not found in a filter + * @retval "another negative error code" other failures + * + * @note Calling this function multiple times is safe, as it is idempotent. + */ +int avfilter_graph_segment_apply_opts(AVFilterGraphSegment *seg, int flags); + +/** + * Initialize all filter instances in a graph segment. + * + * Walk through all filter instances in the graph segment and call + * avfilter_init_dict(..., NULL) on those that have not been initialized yet. + * + * Any creation-pending filters (see avfilter_graph_segment_create_filters()) + * present in the segment will cause this function to fail. AVFilterParams with + * no associated filter context or whose filter context is already initialized, + * are simply skipped. + * + * @param seg the filtergraph segment to process + * @param flags reserved for future use, caller must set to 0 for now + * + * @retval "non-negative number" Success, all filter instances were successfully + * initialized + * @retval "negative error code" failure + * + * @note Calling this function multiple times is safe, as it is idempotent. + */ +int avfilter_graph_segment_init(AVFilterGraphSegment *seg, int flags); + +/** + * Link filters in a graph segment. + * + * Walk through all filter instances in the graph segment and try to link all + * unlinked input and output pads. Any creation-pending filters (see + * avfilter_graph_segment_create_filters()) present in the segment will cause + * this function to fail. Disabled filters and already linked pads are skipped. + * + * Every filter output pad that has a corresponding AVFilterPadParams with a + * non-NULL label is + * - linked to the input with the matching label, if one exists; + * - exported in the outputs linked list otherwise, with the label preserved. + * Unlabeled outputs are + * - linked to the first unlinked unlabeled input in the next non-disabled + * filter in the chain, if one exists + * - exported in the ouputs linked list otherwise, with NULL label + * + * Similarly, unlinked input pads are exported in the inputs linked list. + * + * @param seg the filtergraph segment to process + * @param flags reserved for future use, caller must set to 0 for now + * @param[out] inputs a linked list of all free (unlinked) inputs of the + * filters in this graph segment will be returned here. It + * is to be freed by the caller using avfilter_inout_free(). + * @param[out] outputs a linked list of all free (unlinked) outputs of the + * filters in this graph segment will be returned here. It + * is to be freed by the caller using avfilter_inout_free(). + * + * @retval "non-negative number" success + * @retval "negative error code" failure + * + * @note Calling this function multiple times is safe, as it is idempotent. + */ +int avfilter_graph_segment_link(AVFilterGraphSegment *seg, int flags, + AVFilterInOut **inputs, + AVFilterInOut **outputs); + +/** + * Apply all filter/link descriptions from a graph segment to the associated filtergraph. + * + * This functions is currently equivalent to calling the following in sequence: + * - avfilter_graph_segment_create_filters(); + * - avfilter_graph_segment_apply_opts(); + * - avfilter_graph_segment_init(); + * - avfilter_graph_segment_link(); + * failing if any of them fails. This list may be extended in the future. + * + * Since the above functions are idempotent, the caller may call some of them + * manually, then do some custom processing on the filtergraph, then call this + * function to do the rest. + * + * @param seg the filtergraph segment to process + * @param flags reserved for future use, caller must set to 0 for now + * @param[out] inputs passed to avfilter_graph_segment_link() + * @param[out] outputs passed to avfilter_graph_segment_link() + * + * @retval "non-negative number" success + * @retval "negative error code" failure + * + * @note Calling this function multiple times is safe, as it is idempotent. + */ +int avfilter_graph_segment_apply(AVFilterGraphSegment *seg, int flags, + AVFilterInOut **inputs, + AVFilterInOut **outputs); + +/** + * Free the provided AVFilterGraphSegment and everything associated with it. + * + * @param seg double pointer to the AVFilterGraphSegment to be freed. NULL will + * be written to this pointer on exit from this function. + * + * @note + * The filter contexts (AVFilterParams.filter) are owned by AVFilterGraph rather + * than AVFilterGraphSegment, so they are not freed. + */ +void avfilter_graph_segment_free(AVFilterGraphSegment **seg); + /** * Send a command to one or more filter instances. * diff --git a/library/FFmpeg/include/libavfilter/buffersink.h b/library/FFmpeg/include/libavfilter/buffersink.h index 69ed0f29..64e08de5 100644 --- a/library/FFmpeg/include/libavfilter/buffersink.h +++ b/library/FFmpeg/include/libavfilter/buffersink.h @@ -46,27 +46,26 @@ * - av_buffersink_get_h(), * - av_buffersink_get_sample_aspect_ratio(), * - av_buffersink_get_channels(), - * - av_buffersink_get_channel_layout(), + * - av_buffersink_get_ch_layout(), * - av_buffersink_get_sample_rate(). * + * The layout returned by av_buffersink_get_ch_layout() must de uninitialized + * by the caller. + * * The format can be constrained by setting options, using av_opt_set() and * related functions with the AV_OPT_SEARCH_CHILDREN flag. * - pix_fmts (int list), * - sample_fmts (int list), * - sample_rates (int list), - * - channel_layouts (int64_t), + * - ch_layouts (string), * - channel_counts (int list), * - all_channel_counts (bool). * Most of these options are of type binary, and should be set using * av_opt_set_int_list() or av_opt_set_bin(). If they are not set, all * corresponding formats are accepted. * - * As a special case, if neither channel_layouts nor channel_counts is set, - * all valid channel layouts are accepted, but channel counts without a - * layout are not, unless all_channel_counts is set. - * Also, channel_layouts must not contain a channel layout already accepted - * by a value in channel_counts; for example, if channel_counts contains 2, - * then channel_layouts must not contain stereo. + * As a special case, if ch_layouts is not set, all valid channel layouts are + * accepted except for UNSPEC layouts, unless all_channel_counts is set. */ /** @@ -95,42 +94,6 @@ int av_buffersink_get_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flag */ #define AV_BUFFERSINK_FLAG_NO_REQUEST 2 -#if FF_API_BUFFERSINK_ALLOC -/** - * Deprecated and unused struct to use for initializing a buffersink context. - */ -typedef struct AVBufferSinkParams { - const enum AVPixelFormat *pixel_fmts; ///< list of allowed pixel formats, terminated by AV_PIX_FMT_NONE -} AVBufferSinkParams; - -/** - * Create an AVBufferSinkParams structure. - * - * Must be freed with av_free(). - */ -attribute_deprecated -AVBufferSinkParams *av_buffersink_params_alloc(void); - -/** - * Deprecated and unused struct to use for initializing an abuffersink context. - */ -typedef struct AVABufferSinkParams { - const enum AVSampleFormat *sample_fmts; ///< list of allowed sample formats, terminated by AV_SAMPLE_FMT_NONE - const int64_t *channel_layouts; ///< list of allowed channel layouts, terminated by -1 - const int *channel_counts; ///< list of allowed channel counts, terminated by -1 - int all_channel_counts; ///< if not 0, accept any channel count or layout - int *sample_rates; ///< list of allowed sample rates, terminated by -1 -} AVABufferSinkParams; - -/** - * Create an AVABufferSinkParams structure. - * - * Must be freed with av_free(). - */ -attribute_deprecated -AVABufferSinkParams *av_abuffersink_params_alloc(void); -#endif - /** * Set the frame size for an audio buffer sink. * @@ -156,7 +119,12 @@ int av_buffersink_get_h (const AVFilterContext *c AVRational av_buffersink_get_sample_aspect_ratio (const AVFilterContext *ctx); int av_buffersink_get_channels (const AVFilterContext *ctx); +#if FF_API_OLD_CHANNEL_LAYOUT +attribute_deprecated uint64_t av_buffersink_get_channel_layout (const AVFilterContext *ctx); +#endif +int av_buffersink_get_ch_layout (const AVFilterContext *ctx, + AVChannelLayout *ch_layout); int av_buffersink_get_sample_rate (const AVFilterContext *ctx); AVBufferRef * av_buffersink_get_hw_frames_ctx (const AVFilterContext *ctx); diff --git a/library/FFmpeg/include/libavfilter/buffersrc.h b/library/FFmpeg/include/libavfilter/buffersrc.h index 08fbd18a..3b248b37 100644 --- a/library/FFmpeg/include/libavfilter/buffersrc.h +++ b/library/FFmpeg/include/libavfilter/buffersrc.h @@ -110,10 +110,19 @@ typedef struct AVBufferSrcParameters { */ int sample_rate; +#if FF_API_OLD_CHANNEL_LAYOUT /** * Audio only, the audio channel layout + * @deprecated use ch_layout */ + attribute_deprecated uint64_t channel_layout; +#endif + + /** + * Audio only, the audio channel layout + */ + AVChannelLayout ch_layout; } AVBufferSrcParameters; /** diff --git a/library/FFmpeg/include/libavfilter/version.h b/library/FFmpeg/include/libavfilter/version.h index fbb81ef3..537df129 100644 --- a/library/FFmpeg/include/libavfilter/version.h +++ b/library/FFmpeg/include/libavfilter/version.h @@ -29,9 +29,10 @@ #include "libavutil/version.h" -#define LIBAVFILTER_VERSION_MAJOR 8 -#define LIBAVFILTER_VERSION_MINOR 0 -#define LIBAVFILTER_VERSION_MICRO 103 +#include "version_major.h" + +#define LIBAVFILTER_VERSION_MINOR 13 +#define LIBAVFILTER_VERSION_MICRO 100 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ @@ -44,17 +45,4 @@ #define LIBAVFILTER_IDENT "Lavfi" AV_STRINGIFY(LIBAVFILTER_VERSION) -/** - * FF_API_* defines may be placed below to indicate public API that will be - * dropped at a future version bump. The defines themselves are not part of - * the public API and may change, break or disappear at any time. - */ - -#ifndef FF_API_SWS_PARAM_OPTION -#define FF_API_SWS_PARAM_OPTION (LIBAVFILTER_VERSION_MAJOR < 9) -#endif -#ifndef FF_API_BUFFERSINK_ALLOC -#define FF_API_BUFFERSINK_ALLOC (LIBAVFILTER_VERSION_MAJOR < 9) -#endif - #endif /* AVFILTER_VERSION_H */ diff --git a/library/FFmpeg/include/libavfilter/version_major.h b/library/FFmpeg/include/libavfilter/version_major.h new file mode 100644 index 00000000..1decc401 --- /dev/null +++ b/library/FFmpeg/include/libavfilter/version_major.h @@ -0,0 +1,40 @@ +/* + * Version macros. + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVFILTER_VERSION_MAJOR_H +#define AVFILTER_VERSION_MAJOR_H + +/** + * @file + * @ingroup lavfi + * Libavfilter version macros + */ + +#define LIBAVFILTER_VERSION_MAJOR 9 + +/** + * FF_API_* defines may be placed below to indicate public API that will be + * dropped at a future version bump. The defines themselves are not part of + * the public API and may change, break or disappear at any time. + */ + +#define FF_API_LIBPLACEBO_OPTS (LIBAVFILTER_VERSION_MAJOR < 10) + +#endif /* AVFILTER_VERSION_MAJOR_H */ diff --git a/library/FFmpeg/include/libavformat/avformat.h b/library/FFmpeg/include/libavformat/avformat.h index 81d2ac38..9e7eca00 100644 --- a/library/FFmpeg/include/libavformat/avformat.h +++ b/library/FFmpeg/include/libavformat/avformat.h @@ -307,10 +307,8 @@ * @} */ -#include #include /* FILE */ -#include "libavcodec/codec.h" #include "libavcodec/codec_par.h" #include "libavcodec/defs.h" #include "libavcodec/packet.h" @@ -319,12 +317,20 @@ #include "libavutil/log.h" #include "avio.h" +#include "libavformat/version_major.h" +#ifndef HAVE_AV_CONFIG_H +/* When included as part of the ffmpeg build, only include the major version + * to avoid unnecessary rebuilds. When included externally, keep including + * the full version information. */ #include "libavformat/version.h" -struct AVFormatContext; +#include "libavutil/frame.h" +#include "libavcodec/codec.h" +#endif +struct AVFormatContext; +struct AVFrame; struct AVDeviceInfoList; -struct AVDeviceCapabilitiesQuery; /** * @defgroup metadata_api Public Metadata API @@ -462,6 +468,13 @@ typedef struct AVProbeData { /// Demuxer will use avio_open, no opened file should be provided by the caller. #define AVFMT_NOFILE 0x0001 #define AVFMT_NEEDNUMBER 0x0002 /**< Needs '%d' in filename. */ +/** + * The muxer/demuxer is experimental and should be used with caution. + * + * - demuxers: will not be selected automatically by probing, must be specified + * explicitly. + */ +#define AVFMT_EXPERIMENTAL 0x0004 #define AVFMT_SHOW_IDS 0x0008 /**< Show format stream IDs numbers. */ #define AVFMT_GLOBALHEADER 0x0040 /**< Format wants global header. */ #define AVFMT_NOTIMESTAMPS 0x0080 /**< Format does not need / have any timestamps. */ @@ -473,7 +486,9 @@ typedef struct AVProbeData { #define AVFMT_NOBINSEARCH 0x2000 /**< Format does not allow to fall back on binary search via read_timestamp */ #define AVFMT_NOGENSEARCH 0x4000 /**< Format does not allow to fall back on generic search */ #define AVFMT_NO_BYTE_SEEK 0x8000 /**< Format does not allow seeking by bytes */ -#define AVFMT_ALLOW_FLUSH 0x10000 /**< Format allows flushing. If not set, the muxer will not receive a NULL packet in the write_packet function. */ +#if FF_API_ALLOW_FLUSH +#define AVFMT_ALLOW_FLUSH 0x10000 /**< @deprecated: Just send a NULL packet if you want to flush a muxer. */ +#endif #define AVFMT_TS_NONSTRICT 0x20000 /**< Format does not require strictly increasing timestamps, but they must still be monotonic */ @@ -509,7 +524,7 @@ typedef struct AVOutputFormat { /** * can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, * AVFMT_GLOBALHEADER, AVFMT_NOTIMESTAMPS, AVFMT_VARIABLE_FPS, - * AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS, AVFMT_ALLOW_FLUSH, + * AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS, * AVFMT_TS_NONSTRICT, AVFMT_TS_NEGATIVE */ int flags; @@ -522,98 +537,6 @@ typedef struct AVOutputFormat { const AVClass *priv_class; ///< AVClass for the private context - - /***************************************************************** - * No fields below this line are part of the public API. They - * may not be used outside of libavformat and can be changed and - * removed at will. - * New public fields should be added right above. - ***************************************************************** - */ - /** - * size of private data so that it can be allocated in the wrapper - */ - int priv_data_size; - - /** - * Internal flags. See FF_FMT_FLAG_* in internal.h. - */ - int flags_internal; - - int (*write_header)(struct AVFormatContext *); - /** - * Write a packet. If AVFMT_ALLOW_FLUSH is set in flags, - * pkt can be NULL in order to flush data buffered in the muxer. - * When flushing, return 0 if there still is more data to flush, - * or 1 if everything was flushed and there is no more buffered - * data. - */ - int (*write_packet)(struct AVFormatContext *, AVPacket *pkt); - int (*write_trailer)(struct AVFormatContext *); - /** - * A format-specific function for interleavement. - * If unset, packets will be interleaved by dts. - */ - int (*interleave_packet)(struct AVFormatContext *, AVPacket *out, - AVPacket *in, int flush); - /** - * Test if the given codec can be stored in this container. - * - * @return 1 if the codec is supported, 0 if it is not. - * A negative number if unknown. - * MKTAG('A', 'P', 'I', 'C') if the codec is only supported as AV_DISPOSITION_ATTACHED_PIC - */ - int (*query_codec)(enum AVCodecID id, int std_compliance); - - void (*get_output_timestamp)(struct AVFormatContext *s, int stream, - int64_t *dts, int64_t *wall); - /** - * Allows sending messages from application to device. - */ - int (*control_message)(struct AVFormatContext *s, int type, - void *data, size_t data_size); - - /** - * Write an uncoded AVFrame. - * - * See av_write_uncoded_frame() for details. - * - * The library will free *frame afterwards, but the muxer can prevent it - * by setting the pointer to NULL. - */ - int (*write_uncoded_frame)(struct AVFormatContext *, int stream_index, - AVFrame **frame, unsigned flags); - /** - * Returns device list with it properties. - * @see avdevice_list_devices() for more details. - */ - int (*get_device_list)(struct AVFormatContext *s, struct AVDeviceInfoList *device_list); - enum AVCodecID data_codec; /**< default data codec */ - /** - * Initialize format. May allocate data here, and set any AVFormatContext or - * AVStream parameters that need to be set before packets are sent. - * This method must not write output. - * - * Return 0 if streams were fully configured, 1 if not, negative AVERROR on failure - * - * Any allocations made here must be freed in deinit(). - */ - int (*init)(struct AVFormatContext *); - /** - * Deinitialize format. If present, this is called whenever the muxer is being - * destroyed, regardless of whether or not the header has been written. - * - * If a trailer is being written, this is called after write_trailer(). - * - * This is called if init() fails as well. - */ - void (*deinit)(struct AVFormatContext *); - /** - * Set up any necessary bitstream filtering and extract any extra data needed - * for the global header. - * Return 0 if more packets from this stream must be checked; 1 if not. - */ - int (*check_bitstream)(struct AVFormatContext *, const AVPacket *pkt); } AVOutputFormat; /** * @} @@ -791,22 +714,56 @@ typedef struct AVIndexEntry { int min_distance; /**< Minimum distance between this and the previous keyframe, used to avoid unneeded searching. */ } AVIndexEntry; -#define AV_DISPOSITION_DEFAULT 0x0001 -#define AV_DISPOSITION_DUB 0x0002 -#define AV_DISPOSITION_ORIGINAL 0x0004 -#define AV_DISPOSITION_COMMENT 0x0008 -#define AV_DISPOSITION_LYRICS 0x0010 -#define AV_DISPOSITION_KARAOKE 0x0020 +/** + * The stream should be chosen by default among other streams of the same type, + * unless the user has explicitly specified otherwise. + */ +#define AV_DISPOSITION_DEFAULT (1 << 0) +/** + * The stream is not in original language. + * + * @note AV_DISPOSITION_ORIGINAL is the inverse of this disposition. At most + * one of them should be set in properly tagged streams. + * @note This disposition may apply to any stream type, not just audio. + */ +#define AV_DISPOSITION_DUB (1 << 1) +/** + * The stream is in original language. + * + * @see the notes for AV_DISPOSITION_DUB + */ +#define AV_DISPOSITION_ORIGINAL (1 << 2) +/** + * The stream is a commentary track. + */ +#define AV_DISPOSITION_COMMENT (1 << 3) +/** + * The stream contains song lyrics. + */ +#define AV_DISPOSITION_LYRICS (1 << 4) +/** + * The stream contains karaoke audio. + */ +#define AV_DISPOSITION_KARAOKE (1 << 5) /** * Track should be used during playback by default. * Useful for subtitle track that should be displayed * even when user did not explicitly ask for subtitles. */ -#define AV_DISPOSITION_FORCED 0x0040 -#define AV_DISPOSITION_HEARING_IMPAIRED 0x0080 /**< stream for hearing impaired audiences */ -#define AV_DISPOSITION_VISUAL_IMPAIRED 0x0100 /**< stream for visual impaired audiences */ -#define AV_DISPOSITION_CLEAN_EFFECTS 0x0200 /**< stream without voice */ +#define AV_DISPOSITION_FORCED (1 << 6) +/** + * The stream is intended for hearing impaired audiences. + */ +#define AV_DISPOSITION_HEARING_IMPAIRED (1 << 7) +/** + * The stream is intended for visually impaired audiences. + */ +#define AV_DISPOSITION_VISUAL_IMPAIRED (1 << 8) +/** + * The audio stream contains music and sound effects without voice. + */ +#define AV_DISPOSITION_CLEAN_EFFECTS (1 << 9) /** * The stream is stored in the file as an attached picture/"cover art" (e.g. * APIC frame in ID3v2). The first (usually only) packet associated with it @@ -814,23 +771,60 @@ typedef struct AVIndexEntry { * seeking takes place. It can also be accessed at any time in * AVStream.attached_pic. */ -#define AV_DISPOSITION_ATTACHED_PIC 0x0400 +#define AV_DISPOSITION_ATTACHED_PIC (1 << 10) /** * The stream is sparse, and contains thumbnail images, often corresponding * to chapter markers. Only ever used with AV_DISPOSITION_ATTACHED_PIC. */ -#define AV_DISPOSITION_TIMED_THUMBNAILS 0x0800 +#define AV_DISPOSITION_TIMED_THUMBNAILS (1 << 11) + +/** + * The stream is intended to be mixed with a spatial audio track. For example, + * it could be used for narration or stereo music, and may remain unchanged by + * listener head rotation. + */ +#define AV_DISPOSITION_NON_DIEGETIC (1 << 12) + +/** + * The subtitle stream contains captions, providing a transcription and possibly + * a translation of audio. Typically intended for hearing-impaired audiences. + */ +#define AV_DISPOSITION_CAPTIONS (1 << 16) +/** + * The subtitle stream contains a textual description of the video content. + * Typically intended for visually-impaired audiences or for the cases where the + * video cannot be seen. + */ +#define AV_DISPOSITION_DESCRIPTIONS (1 << 17) +/** + * The subtitle stream contains time-aligned metadata that is not intended to be + * directly presented to the user. + */ +#define AV_DISPOSITION_METADATA (1 << 18) +/** + * The audio stream is intended to be mixed with another stream before + * presentation. + * Corresponds to mix_type=0 in mpegts. + */ +#define AV_DISPOSITION_DEPENDENT (1 << 19) +/** + * The video stream contains still images. + */ +#define AV_DISPOSITION_STILL_IMAGE (1 << 20) -typedef struct AVStreamInternal AVStreamInternal; +/** + * @return The AV_DISPOSITION_* flag corresponding to disp or a negative error + * code if disp does not correspond to a known stream disposition. + */ +int av_disposition_from_string(const char *disp); /** - * To specify text track kind (different from subtitles default). + * @param disposition a combination of AV_DISPOSITION_* values + * @return The string description corresponding to the lowest set bit in + * disposition. NULL when the lowest set bit does not correspond + * to a known disposition or when disposition is 0. */ -#define AV_DISPOSITION_CAPTIONS 0x10000 -#define AV_DISPOSITION_DESCRIPTIONS 0x20000 -#define AV_DISPOSITION_METADATA 0x40000 -#define AV_DISPOSITION_DEPENDENT 0x80000 ///< dependent audio stream (mix_type=0 in mpegts) -#define AV_DISPOSITION_STILL_IMAGE 0x100000 ///< still images in video stream (still_picture_flag=1 in mpegts) +const char *av_disposition_to_string(int disposition); /** * Options for behavior on timestamp wrap detection. @@ -847,6 +841,11 @@ typedef struct AVStreamInternal AVStreamInternal; * sizeof(AVStream) must not be used outside libav*. */ typedef struct AVStream { + /** + * A class for @ref avoptions. Set on stream creation. + */ + const AVClass *av_class; + int index; /**< stream index in AVFormatContext */ /** * Format-specific stream ID. @@ -855,6 +854,17 @@ typedef struct AVStream { */ int id; + /** + * Codec parameters associated with this stream. Allocated and freed by + * libavformat in avformat_new_stream() and avformat_free_context() + * respectively. + * + * - demuxing: filled by libavformat on stream creation or in + * avformat_find_stream_info() + * - muxing: filled by the caller before avformat_write_header() + */ + AVCodecParameters *codecpar; + void *priv_data; /** @@ -893,7 +903,13 @@ typedef struct AVStream { int64_t nb_frames; ///< number of frames in this stream if known or 0 - int disposition; /**< AV_DISPOSITION_* bit field */ + /** + * Stream disposition - a combination of AV_DISPOSITION_* flags. + * - demuxing: set by libavformat when creating the stream or in + * avformat_find_stream_info(). + * - muxing: may be set by the caller before avformat_write_header(). + */ + int disposition; enum AVDiscard discard; ///< Selects which packets can be discarded at will and do not need to be demuxed. @@ -924,6 +940,7 @@ typedef struct AVStream { */ AVPacket attached_pic; +#if FF_API_AVSTREAM_SIDE_DATA /** * An array of side data that applies to the whole stream (i.e. the * container does not allow it to change between packets). @@ -940,13 +957,20 @@ typedef struct AVStream { * * Freed by libavformat in avformat_free_context(). * - * @see av_format_inject_global_side_data() + * @deprecated use AVStream's @ref AVCodecParameters.coded_side_data + * "codecpar side data". */ + attribute_deprecated AVPacketSideData *side_data; /** * The number of elements in the AVStream.side_data array. + * + * @deprecated use AVStream's @ref AVCodecParameters.nb_coded_side_data + * "codecpar side data". */ + attribute_deprecated int nb_side_data; +#endif /** * Flags indicating events happening on the stream, a combination of @@ -984,17 +1008,6 @@ typedef struct AVStream { */ AVRational r_frame_rate; - /** - * Codec parameters associated with this stream. Allocated and freed by - * libavformat in avformat_new_stream() and avformat_free_context() - * respectively. - * - * - demuxing: filled by libavformat on stream creation or in - * avformat_find_stream_info() - * - muxing: filled by the caller before avformat_write_header() - */ - AVCodecParameters *codecpar; - /** * Number of bits in timestamps. Used for wrapping control. * @@ -1003,22 +1016,19 @@ typedef struct AVStream { * */ int pts_wrap_bits; - - /** - * An opaque field for libavformat internal usage. - * Must not be accessed in any way by callers. - */ - AVStreamInternal *internal; } AVStream; struct AVCodecParserContext *av_stream_get_parser(const AVStream *s); +#if FF_API_GET_END_PTS /** * Returns the pts of the last muxed packet + its duration * * the retuned value is undefined when used with a demuxer. */ +attribute_deprecated int64_t av_stream_get_end_pts(const AVStream *st); +#endif #define AV_PROGRAM_RUNNING 1 @@ -1090,8 +1100,6 @@ enum AVDurationEstimationMethod { AVFMT_DURATION_FROM_BITRATE ///< Duration estimated from bitrate (less accurate) }; -typedef struct AVFormatInternal AVFormatInternal; - /** * Format I/O context. * New fields can be added to the end with minor version bumps. @@ -1243,11 +1251,10 @@ typedef struct AVFormatContext { */ #define AVFMT_FLAG_BITEXACT 0x0400 #define AVFMT_FLAG_SORT_DTS 0x10000 ///< try to interleave outputted packets by dts (using this flag can slow demuxing down) -#if FF_API_LAVF_PRIV_OPT -#define AVFMT_FLAG_PRIV_OPT 0x20000 ///< Enable use of private options by delaying codec open (deprecated, does nothing) -#endif #define AVFMT_FLAG_FAST_SEEK 0x80000 ///< Enable fast, but inaccurate seeks for some formats +#if FF_API_LAVF_SHORTEST #define AVFMT_FLAG_SHORTEST 0x100000 ///< Stop muxing when the shortest stream stops. +#endif #define AVFMT_FLAG_AUTO_BSF 0x200000 ///< Add bitstream filters as requested by the muxer /** @@ -1434,12 +1441,13 @@ typedef struct AVFormatContext { /** * Avoid negative timestamps during muxing. * Any value of the AVFMT_AVOID_NEG_TS_* constants. - * Note, this only works when using av_interleaved_write_frame. (interleave_packet_per_dts is in use) + * Note, this works better when using av_interleaved_write_frame(). * - muxing: Set by user * - demuxing: unused */ int avoid_negative_ts; #define AVFMT_AVOID_NEG_TS_AUTO -1 ///< Enabled when required by target format +#define AVFMT_AVOID_NEG_TS_DISABLED 0 ///< Do not shift timestamps even when they are negative. #define AVFMT_AVOID_NEG_TS_MAKE_NON_NEGATIVE 1 ///< Shift timestamps so they are non negative #define AVFMT_AVOID_NEG_TS_MAKE_ZERO 2 ///< Shift timestamps so that they start at 0 @@ -1560,12 +1568,6 @@ typedef struct AVFormatContext { */ char *format_whitelist; - /** - * An opaque field for libavformat internal usage. - * Must not be accessed in any way by callers. - */ - AVFormatInternal *internal; - /** * IO repositioned flag. * This is set by avformat when the underlaying IO context read pointer @@ -1580,7 +1582,7 @@ typedef struct AVFormatContext { * the same codec_id. * Demuxing: Set by user */ - const AVCodec *video_codec; + const struct AVCodec *video_codec; /** * Forced audio codec. @@ -1588,7 +1590,7 @@ typedef struct AVFormatContext { * the same codec_id. * Demuxing: Set by user */ - const AVCodec *audio_codec; + const struct AVCodec *audio_codec; /** * Forced subtitle codec. @@ -1596,7 +1598,7 @@ typedef struct AVFormatContext { * the same codec_id. * Demuxing: Set by user */ - const AVCodec *subtitle_codec; + const struct AVCodec *subtitle_codec; /** * Forced data codec. @@ -1604,7 +1606,7 @@ typedef struct AVFormatContext { * the same codec_id. * Demuxing: Set by user */ - const AVCodec *data_codec; + const struct AVCodec *data_codec; /** * Number of bytes to be written as padding in a metadata header. @@ -1674,10 +1676,15 @@ typedef struct AVFormatContext { int (*io_open)(struct AVFormatContext *s, AVIOContext **pb, const char *url, int flags, AVDictionary **options); +#if FF_API_AVFORMAT_IO_CLOSE /** * A callback for closing the streams opened with AVFormatContext.io_open(). + * + * @deprecated use io_close2 */ + attribute_deprecated void (*io_close)(struct AVFormatContext *s, AVIOContext *pb); +#endif /** * ',' separated list of disallowed protocols. @@ -1706,11 +1713,30 @@ typedef struct AVFormatContext { * - decoding: set by user */ int max_probe_packets; + + /** + * A callback for closing the streams opened with AVFormatContext.io_open(). + * + * Using this is preferred over io_close, because this can return an error. + * Therefore this callback is used instead of io_close by the generic + * libavformat code if io_close is NULL or the default. + * + * @param s the format context + * @param pb IO context to be closed and freed + * @return 0 on success, a negative AVERROR code on failure + */ + int (*io_close2)(struct AVFormatContext *s, AVIOContext *pb); } AVFormatContext; /** * This function will cause global side data to be injected in the next packet * of each stream as well as after any subsequent seek. + * + * @note global side data is always available in every AVStream's + * @ref AVCodecParameters.coded_side_data "codecpar side data" array, and + * in a @ref AVCodecContext.coded_side_data "decoder's side data" array if + * initialized with said stream's codecpar. + * @see av_packet_side_data_get() */ void av_format_inject_global_side_data(AVFormatContext *s); @@ -1781,8 +1807,8 @@ const AVOutputFormat *av_muxer_iterate(void **opaque); /** * Iterate over all registered demuxers. * - * @param opaque a pointer where libavformat will store the iteration state. Must - * point to NULL to start the iteration. + * @param opaque a pointer where libavformat will store the iteration state. + * Must point to NULL to start the iteration. * * @return the next registered demuxer or NULL when the iteration is * finished @@ -1810,6 +1836,14 @@ void avformat_free_context(AVFormatContext *s); */ const AVClass *avformat_get_class(void); +/** + * Get the AVClass for AVStream. It can be used in combination with + * AV_OPT_SEARCH_FAKE_OBJ for examining options. + * + * @see av_opt_find(). + */ +const AVClass *av_stream_get_class(void); + /** * Add a new stream to a media file. * @@ -1827,20 +1861,25 @@ const AVClass *avformat_get_class(void); * * @return newly created stream or NULL on error. */ -AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c); +AVStream *avformat_new_stream(AVFormatContext *s, const struct AVCodec *c); +#if FF_API_AVSTREAM_SIDE_DATA /** * Wrap an existing array as stream side data. * - * @param st stream + * @param st stream * @param type side information type * @param data the side data array. It must be allocated with the av_malloc() * family of functions. The ownership of the data is transferred to * st. * @param size side information size + * * @return zero on success, a negative AVERROR code on failure. On failure, * the stream is unchanged and the data remains owned by the caller. + * @deprecated use av_packet_side_data_add() with the stream's + * @ref AVCodecParameters.coded_side_data "codecpar side data" */ +attribute_deprecated int av_stream_add_side_data(AVStream *st, enum AVPacketSideDataType type, uint8_t *data, size_t size); @@ -1848,23 +1887,32 @@ int av_stream_add_side_data(AVStream *st, enum AVPacketSideDataType type, * Allocate new information from stream. * * @param stream stream - * @param type desired side information type - * @param size side information size + * @param type desired side information type + * @param size side information size + * * @return pointer to fresh allocated data or NULL otherwise + * @deprecated use av_packet_side_data_new() with the stream's + * @ref AVCodecParameters.coded_side_data "codecpar side data" */ +attribute_deprecated uint8_t *av_stream_new_side_data(AVStream *stream, enum AVPacketSideDataType type, size_t size); /** * Get side information from stream. * * @param stream stream - * @param type desired side information type - * @param size If supplied, *size will be set to the size of the side data - * or to zero if the desired side data is not present. + * @param type desired side information type + * @param size If supplied, *size will be set to the size of the side data + * or to zero if the desired side data is not present. + * * @return pointer to data if present or NULL otherwise + * @deprecated use av_packet_side_data_get() with the stream's + * @ref AVCodecParameters.coded_side_data "codecpar side data" */ +attribute_deprecated uint8_t *av_stream_get_side_data(const AVStream *stream, enum AVPacketSideDataType type, size_t *size); +#endif AVProgram *av_new_program(AVFormatContext *s, int id); @@ -1878,16 +1926,17 @@ AVProgram *av_new_program(AVFormatContext *s, int id); * avformat_free_context() can be used to free the context and * everything allocated by the framework within it. * - * @param *ctx is set to the created format context, or to NULL in - * case of failure - * @param oformat format to use for allocating the context, if NULL - * format_name and filename are used instead - * @param format_name the name of output format to use for allocating the - * context, if NULL filename is used instead - * @param filename the name of the filename to use for allocating the - * context, may be NULL - * @return >= 0 in case of success, a negative AVERROR code in case of - * failure + * @param ctx pointee is set to the created format context, + * or to NULL in case of failure + * @param oformat format to use for allocating the context, if NULL + * format_name and filename are used instead + * @param format_name the name of output format to use for allocating the + * context, if NULL filename is used instead + * @param filename the name of the filename to use for allocating the + * context, may be NULL + * + * @return >= 0 in case of success, a negative AVERROR code in case of + * failure */ int avformat_alloc_output_context2(AVFormatContext **ctx, const AVOutputFormat *oformat, const char *format_name, const char *filename); @@ -1942,15 +1991,16 @@ const AVInputFormat *av_probe_input_format3(const AVProbeData *pd, * attempt is made. When the maximum probe size is reached, the input format * with the highest score is returned. * - * @param pb the bytestream to probe - * @param fmt the input format is put here - * @param url the url of the stream - * @param logctx the log context - * @param offset the offset within the bytestream to probe from + * @param pb the bytestream to probe + * @param fmt the input format is put here + * @param url the url of the stream + * @param logctx the log context + * @param offset the offset within the bytestream to probe from * @param max_probe_size the maximum probe buffer size (zero for default) + * * @return the score in case of success, a negative value corresponding to an * the maximal score is AVPROBE_SCORE_MAX - * AVERROR code otherwise + * AVERROR code otherwise */ int av_probe_input_buffer2(AVIOContext *pb, const AVInputFormat **fmt, const char *url, void *logctx, @@ -1967,16 +2017,19 @@ int av_probe_input_buffer(AVIOContext *pb, const AVInputFormat **fmt, * Open an input stream and read the header. The codecs are not opened. * The stream must be closed with avformat_close_input(). * - * @param ps Pointer to user-supplied AVFormatContext (allocated by avformat_alloc_context). - * May be a pointer to NULL, in which case an AVFormatContext is allocated by this - * function and written into ps. - * Note that a user-supplied AVFormatContext will be freed on failure. - * @param url URL of the stream to open. - * @param fmt If non-NULL, this parameter forces a specific input format. - * Otherwise the format is autodetected. - * @param options A dictionary filled with AVFormatContext and demuxer-private options. - * On return this parameter will be destroyed and replaced with a dict containing - * options that were not found. May be NULL. + * @param ps Pointer to user-supplied AVFormatContext (allocated by + * avformat_alloc_context). May be a pointer to NULL, in + * which case an AVFormatContext is allocated by this + * function and written into ps. + * Note that a user-supplied AVFormatContext will be freed + * on failure. + * @param url URL of the stream to open. + * @param fmt If non-NULL, this parameter forces a specific input format. + * Otherwise the format is autodetected. + * @param options A dictionary filled with AVFormatContext and demuxer-private + * options. + * On return this parameter will be destroyed and replaced with + * a dict containing options that were not found. May be NULL. * * @return 0 on success, a negative AVERROR on failure. * @@ -2015,6 +2068,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options); * @param last the last found program, the search will start after this * program, or from the beginning if it is NULL * @param s stream index + * * @return the next program which belongs to s, NULL if no program is found or * the last program is not among the programs of ic. */ @@ -2039,10 +2093,12 @@ void av_program_add_stream_index(AVFormatContext *ac, int progid, unsigned int i * @param decoder_ret if non-NULL, returns the decoder for the * selected stream * @param flags flags; none are currently defined + * * @return the non-negative stream number in case of success, * AVERROR_STREAM_NOT_FOUND if no stream with the requested type * could be found, * AVERROR_DECODER_NOT_FOUND if streams were found but no decoder + * * @note If av_find_best_stream returns successfully and decoder_ret is not * NULL, then *decoder_ret is guaranteed to be set to a valid AVCodec. */ @@ -2050,7 +2106,7 @@ int av_find_best_stream(AVFormatContext *ic, enum AVMediaType type, int wanted_stream_nb, int related_stream, - const AVCodec **decoder_ret, + const struct AVCodec **decoder_ret, int flags); /** @@ -2086,13 +2142,14 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt); * Seek to the keyframe at timestamp. * 'timestamp' in 'stream_index'. * - * @param s media file handle - * @param stream_index If stream_index is (-1), a default - * stream is selected, and timestamp is automatically converted - * from AV_TIME_BASE units to the stream specific time_base. - * @param timestamp Timestamp in AVStream.time_base units - * or, if no stream is specified, in AV_TIME_BASE units. - * @param flags flags which select direction and seeking mode + * @param s media file handle + * @param stream_index If stream_index is (-1), a default stream is selected, + * and timestamp is automatically converted from + * AV_TIME_BASE units to the stream specific time_base. + * @param timestamp Timestamp in AVStream.time_base units or, if no stream + * is specified, in AV_TIME_BASE units. + * @param flags flags which select direction and seeking mode + * * @return >= 0 on success */ int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, @@ -2114,12 +2171,12 @@ int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, * keyframes (this may not be supported by all demuxers). * If flags contain AVSEEK_FLAG_BACKWARD, it is ignored. * - * @param s media file handle + * @param s media file handle * @param stream_index index of the stream which is used as time base reference - * @param min_ts smallest acceptable timestamp - * @param ts target timestamp - * @param max_ts largest acceptable timestamp - * @param flags flags + * @param min_ts smallest acceptable timestamp + * @param ts target timestamp + * @param max_ts largest acceptable timestamp + * @param flags flags * @return >=0 on success, error code otherwise * * @note This is part of the new seek API which is still under construction. @@ -2183,16 +2240,22 @@ void avformat_close_input(AVFormatContext **s); * Allocate the stream private data and write the stream header to * an output media file. * - * @param s Media file handle, must be allocated with avformat_alloc_context(). - * Its oformat field must be set to the desired output format; - * Its pb field must be set to an already opened AVIOContext. - * @param options An AVDictionary filled with AVFormatContext and muxer-private options. - * On return this parameter will be destroyed and replaced with a dict containing - * options that were not found. May be NULL. - * - * @return AVSTREAM_INIT_IN_WRITE_HEADER on success if the codec had not already been fully initialized in avformat_init, - * AVSTREAM_INIT_IN_INIT_OUTPUT on success if the codec had already been fully initialized in avformat_init, - * negative AVERROR on failure. + * @param s Media file handle, must be allocated with + * avformat_alloc_context(). + * Its \ref AVFormatContext.oformat "oformat" field must be set + * to the desired output format; + * Its \ref AVFormatContext.pb "pb" field must be set to an + * already opened ::AVIOContext. + * @param options An ::AVDictionary filled with AVFormatContext and + * muxer-private options. + * On return this parameter will be destroyed and replaced with + * a dict containing options that were not found. May be NULL. + * + * @retval AVSTREAM_INIT_IN_WRITE_HEADER On success, if the codec had not already been + * fully initialized in avformat_init_output(). + * @retval AVSTREAM_INIT_IN_INIT_OUTPUT On success, if the codec had already been fully + * initialized in avformat_init_output(). + * @retval AVERROR A negative AVERROR on failure. * * @see av_opt_find, av_dict_set, avio_open, av_oformat_next, avformat_init_output. */ @@ -2201,20 +2264,26 @@ int avformat_write_header(AVFormatContext *s, AVDictionary **options); /** * Allocate the stream private data and initialize the codec, but do not write the header. - * May optionally be used before avformat_write_header to initialize stream parameters + * May optionally be used before avformat_write_header() to initialize stream parameters * before actually writing the header. - * If using this function, do not pass the same options to avformat_write_header. - * - * @param s Media file handle, must be allocated with avformat_alloc_context(). - * Its oformat field must be set to the desired output format; - * Its pb field must be set to an already opened AVIOContext. - * @param options An AVDictionary filled with AVFormatContext and muxer-private options. - * On return this parameter will be destroyed and replaced with a dict containing - * options that were not found. May be NULL. - * - * @return AVSTREAM_INIT_IN_WRITE_HEADER on success if the codec requires avformat_write_header to fully initialize, - * AVSTREAM_INIT_IN_INIT_OUTPUT on success if the codec has been fully initialized, - * negative AVERROR on failure. + * If using this function, do not pass the same options to avformat_write_header(). + * + * @param s Media file handle, must be allocated with + * avformat_alloc_context(). + * Its \ref AVFormatContext.oformat "oformat" field must be set + * to the desired output format; + * Its \ref AVFormatContext.pb "pb" field must be set to an + * already opened ::AVIOContext. + * @param options An ::AVDictionary filled with AVFormatContext and + * muxer-private options. + * On return this parameter will be destroyed and replaced with + * a dict containing options that were not found. May be NULL. + * + * @retval AVSTREAM_INIT_IN_WRITE_HEADER On success, if the codec requires + * avformat_write_header to fully initialize. + * @retval AVSTREAM_INIT_IN_INIT_OUTPUT On success, if the codec has been fully + * initialized. + * @retval AVERROR Anegative AVERROR on failure. * * @see av_opt_find, av_dict_set, avio_open, av_oformat_next, avformat_write_header. */ @@ -2264,7 +2333,7 @@ int av_write_frame(AVFormatContext *s, AVPacket *pkt); * Write a packet to an output media file ensuring correct interleaving. * * This function will buffer the packets internally as needed to make sure the - * packets in the output file are properly interleaved in the order of + * packets in the output file are properly interleaved, usually ordered by * increasing dts. Callers doing their own interleaving should call * av_write_frame() instead of this function. * @@ -2277,10 +2346,10 @@ int av_write_frame(AVFormatContext *s, AVPacket *pkt); *
* If the packet is reference-counted, this function will take * ownership of this reference and unreference it later when it sees - * fit. - * The caller must not access the data through this reference after - * this function returns. If the packet is not reference-counted, - * libavformat will make a copy. + * fit. If the packet is not reference-counted, libavformat will + * make a copy. + * The returned packet will be blank (as if returned from + * av_packet_alloc()), even on error. *
* This parameter can be NULL (at any time, not just at the end), to * flush the interleaving queues. @@ -2296,10 +2365,9 @@ int av_write_frame(AVFormatContext *s, AVPacket *pkt); * The dts for subsequent packets in one stream must be strictly * increasing (unless the output format is flagged with the * AVFMT_TS_NONSTRICT, then they merely have to be nondecreasing). - * @ref AVPacket.duration "duration") should also be set if known. + * @ref AVPacket.duration "duration" should also be set if known. * - * @return 0 on success, a negative AVERROR on error. Libavformat will always - * take care of freeing the packet, even if this function fails. + * @return 0 on success, a negative AVERROR on error. * * @see av_write_frame(), AVFormatContext.max_interleave_delta */ @@ -2314,7 +2382,7 @@ int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt); * See av_interleaved_write_uncoded_frame() for details. */ int av_write_uncoded_frame(AVFormatContext *s, int stream_index, - AVFrame *frame); + struct AVFrame *frame); /** * Write an uncoded frame to an output media file. @@ -2333,7 +2401,7 @@ int av_write_uncoded_frame(AVFormatContext *s, int stream_index, * @return >=0 for success, a negative code on error */ int av_interleaved_write_uncoded_frame(AVFormatContext *s, int stream_index, - AVFrame *frame); + struct AVFrame *frame); /** * Test whether a muxer supports uncoded frame. @@ -2360,11 +2428,11 @@ int av_write_trailer(AVFormatContext *s); * there is no match. * * @param short_name if non-NULL checks if short_name matches with the - * names of the registered formats - * @param filename if non-NULL checks if filename terminates with the - * extensions of the registered formats - * @param mime_type if non-NULL checks if mime_type matches with the - * MIME type of the registered formats + * names of the registered formats + * @param filename if non-NULL checks if filename terminates with the + * extensions of the registered formats + * @param mime_type if non-NULL checks if mime_type matches with the + * MIME type of the registered formats */ const AVOutputFormat *av_guess_format(const char *short_name, const char *filename, @@ -2388,9 +2456,11 @@ enum AVCodecID av_guess_codec(const AVOutputFormat *fmt, const char *short_name, * time_base units * @param[out] wall absolute time when that packet whas output, * in microsecond - * @return 0 if OK, AVERROR(ENOSYS) if the format does not support it - * Note: some formats or devices may not allow to measure dts and wall - * atomically. + * @retval 0 Success + * @retval AVERROR(ENOSYS) The format does not support it + * + * @note Some formats or devices may not allow to measure dts and wall + * atomically. */ int av_get_output_timestamp(struct AVFormatContext *s, int stream, int64_t *dts, int64_t *wall); @@ -2532,7 +2602,7 @@ const AVIndexEntry *avformat_index_get_entry(AVStream *st, int idx); * Get the AVIndexEntry corresponding to the given timestamp. * * @param st Stream containing the requested AVIndexEntry. - * @param timestamp Timestamp to retrieve the index entry for. + * @param wanted_timestamp Timestamp to retrieve the index entry for. * @param flags If AVSEEK_FLAG_BACKWARD then the returned entry will correspond * to the timestamp which is <= the requested one, if backward * is 0, then it will be >= @@ -2719,7 +2789,8 @@ const struct AVCodecTag *avformat_get_mov_audio_tags(void); * @param frame the frame with the aspect ratio to be determined * @return the guessed (valid) sample_aspect_ratio, 0/1 if no idea */ -AVRational av_guess_sample_aspect_ratio(AVFormatContext *format, AVStream *stream, AVFrame *frame); +AVRational av_guess_sample_aspect_ratio(AVFormatContext *format, AVStream *stream, + struct AVFrame *frame); /** * Guess the frame rate, based on both the container and codec information. @@ -2729,7 +2800,8 @@ AVRational av_guess_sample_aspect_ratio(AVFormatContext *format, AVStream *strea * @param frame the frame for which the frame rate should be determined, may be NULL * @return the guessed (valid) frame rate, 0/1 if no idea */ -AVRational av_guess_frame_rate(AVFormatContext *ctx, AVStream *stream, AVFrame *frame); +AVRational av_guess_frame_rate(AVFormatContext *ctx, AVStream *stream, + struct AVFrame *frame); /** * Check if the stream st contained in s is matched by the stream specifier diff --git a/library/FFmpeg/include/libavformat/avio.h b/library/FFmpeg/include/libavformat/avio.h index 0b354097..887a397c 100644 --- a/library/FFmpeg/include/libavformat/avio.h +++ b/library/FFmpeg/include/libavformat/avio.h @@ -27,12 +27,13 @@ */ #include +#include -#include "libavutil/common.h" +#include "libavutil/attributes.h" #include "libavutil/dict.h" #include "libavutil/log.h" -#include "libavformat/version.h" +#include "libavformat/version_major.h" /** * Seeking works like for a local file. @@ -100,9 +101,13 @@ typedef struct AVIODirEntry { int64_t filemode; /**< Unix file mode, -1 if unknown. */ } AVIODirEntry; +#if FF_API_AVIODIRCONTEXT typedef struct AVIODirContext { struct URLContext *url_context; } AVIODirContext; +#else +typedef struct AVIODirContext AVIODirContext; +#endif /** * Different data types that can be returned via the AVIO @@ -148,9 +153,9 @@ enum AVIODataMarkerType { /** * Bytestream IO Context. - * New fields can be added to the end with minor version bumps. - * Removal, reordering and changes to existing fields require a major - * version bump. + * New public fields can be added with minor version bumps. + * Removal, reordering and changes to existing public fields require + * a major version bump. * sizeof(AVIOContext) must not be used outside libav*. * * @note None of the function pointers in AVIOContext should be called @@ -233,16 +238,22 @@ typedef struct AVIOContext { void *opaque; /**< A private pointer, passed to the read/write/seek/... functions. */ int (*read_packet)(void *opaque, uint8_t *buf, int buf_size); +#if FF_API_AVIO_WRITE_NONCONST int (*write_packet)(void *opaque, uint8_t *buf, int buf_size); +#else + int (*write_packet)(void *opaque, const uint8_t *buf, int buf_size); +#endif int64_t (*seek)(void *opaque, int64_t offset, int whence); int64_t pos; /**< position in the file of the current buffer */ int eof_reached; /**< true if was unable to read due to error or eof */ + int error; /**< contains the error code or 0 if no error happened */ int write_flag; /**< true if open for writing */ int max_packet_size; + int min_packet_size; /**< Try to buffer at least this amount of data + before flushing it. */ unsigned long checksum; unsigned char *checksum_ptr; unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size); - int error; /**< contains the error code or 0 if no error happened */ /** * Pause or resume playback for network streaming protocols - e.g. MMS. */ @@ -259,12 +270,6 @@ typedef struct AVIOContext { */ int seekable; - /** - * max filesize, used to limit allocations - * This field is internal to libavformat and access from outside is not allowed. - */ - int64_t maxsize; - /** * avio_read and avio_write should if possible be satisfied directly * instead of going through a buffer, and avio_seek will always @@ -272,37 +277,6 @@ typedef struct AVIOContext { */ int direct; - /** - * Bytes read statistic - * This field is internal to libavformat and access from outside is not allowed. - */ - int64_t bytes_read; - - /** - * seek statistic - * This field is internal to libavformat and access from outside is not allowed. - */ - int seek_count; - - /** - * writeout statistic - * This field is internal to libavformat and access from outside is not allowed. - */ - int writeout_count; - - /** - * Original buffer size - * used internally after probing and ensure seekback to reset the buffer size - * This field is internal to libavformat and access from outside is not allowed. - */ - int orig_buffer_size; - - /** - * Threshold to favor readahead over seek. - * This is current internal only, do not use from outside. - */ - int short_seek_threshold; - /** * ',' separated list of allowed protocols. */ @@ -316,8 +290,13 @@ typedef struct AVIOContext { /** * A callback that is used instead of write_packet. */ +#if FF_API_AVIO_WRITE_NONCONST int (*write_data_type)(void *opaque, uint8_t *buf, int buf_size, enum AVIODataMarkerType type, int64_t time); +#else + int (*write_data_type)(void *opaque, const uint8_t *buf, int buf_size, + enum AVIODataMarkerType type, int64_t time); +#endif /** * If set, don't call write_data_type separately for AVIO_DATA_MARKER_BOUNDARY_POINT, * but ignore them and treat them as AVIO_DATA_MARKER_UNKNOWN (to avoid needlessly @@ -325,20 +304,6 @@ typedef struct AVIOContext { */ int ignore_boundary_point; - /** - * Internal, not meant to be used from outside of AVIOContext. - */ - enum AVIODataMarkerType current_type; - int64_t last_time; - - /** - * A callback that is used instead of short_seek_threshold. - * This is current internal only, do not use from outside. - */ - int (*short_seek_get)(void *opaque); - - int64_t written; - /** * Maximum reached position before a backward seek in the write buffer, * used keeping track of already written data for a later flush. @@ -346,9 +311,14 @@ typedef struct AVIOContext { unsigned char *buf_ptr_max; /** - * Try to buffer at least this amount of data before flushing it + * Read-only statistic of bytes read for this AVIOContext. + */ + int64_t bytes_read; + + /** + * Read-only statistic of bytes written for this AVIOContext. */ - int min_packet_size; + int64_t bytes_written; } AVIOContext; /** @@ -446,7 +416,11 @@ AVIOContext *avio_alloc_context( int write_flag, void *opaque, int (*read_packet)(void *opaque, uint8_t *buf, int buf_size), +#if FF_API_AVIO_WRITE_NONCONST int (*write_packet)(void *opaque, uint8_t *buf, int buf_size), +#else + int (*write_packet)(void *opaque, const uint8_t *buf, int buf_size), +#endif int64_t (*seek)(void *opaque, int64_t offset, int whence)); /** @@ -497,6 +471,7 @@ int avio_put_str16be(AVIOContext *s, const char *str); * * Zero-length ranges are omitted from the output. * + * @param s the AVIOContext * @param time the stream time the current bytestream pos corresponds to * (in AV_TIME_BASE units), or AV_NOPTS_VALUE if unknown or not * applicable @@ -552,6 +527,12 @@ int64_t avio_size(AVIOContext *s); */ int avio_feof(AVIOContext *s); +/** + * Writes a formatted string to the context taking a va_list. + * @return number of bytes written, < 0 on error. + */ +int avio_vprintf(AVIOContext *s, const char *fmt, va_list ap); + /** * Writes a formatted string to the context. * @return number of bytes written, < 0 on error. diff --git a/library/FFmpeg/include/libavformat/version.h b/library/FFmpeg/include/libavformat/version.h index 03eb20ad..2a28a3bf 100644 --- a/library/FFmpeg/include/libavformat/version.h +++ b/library/FFmpeg/include/libavformat/version.h @@ -29,11 +29,10 @@ #include "libavutil/version.h" -// Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium) -// Also please add any ticket numbers that you believe might be affected here -#define LIBAVFORMAT_VERSION_MAJOR 59 -#define LIBAVFORMAT_VERSION_MINOR 4 -#define LIBAVFORMAT_VERSION_MICRO 101 +#include "version_major.h" + +#define LIBAVFORMAT_VERSION_MINOR 17 +#define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ @@ -45,25 +44,4 @@ #define LIBAVFORMAT_IDENT "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION) -/** - * FF_API_* defines may be placed below to indicate public API that will be - * dropped at a future version bump. The defines themselves are not part of - * the public API and may change, break or disappear at any time. - * - * @note, when bumping the major version it is recommended to manually - * disable each FF_API_* in its own commit instead of disabling them all - * at once through the bump. This improves the git bisect-ability of the change. - * - */ -#ifndef FF_API_LAVF_PRIV_OPT -#define FF_API_LAVF_PRIV_OPT (LIBAVFORMAT_VERSION_MAJOR < 60) -#endif -#ifndef FF_API_COMPUTE_PKT_FIELDS2 -#define FF_API_COMPUTE_PKT_FIELDS2 (LIBAVFORMAT_VERSION_MAJOR < 60) -#endif - - -#ifndef FF_API_R_FRAME_RATE -#define FF_API_R_FRAME_RATE 1 -#endif #endif /* AVFORMAT_VERSION_H */ diff --git a/library/FFmpeg/include/libavformat/version_major.h b/library/FFmpeg/include/libavformat/version_major.h new file mode 100644 index 00000000..224fdacf --- /dev/null +++ b/library/FFmpeg/include/libavformat/version_major.h @@ -0,0 +1,56 @@ +/* + * Version macros. + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVFORMAT_VERSION_MAJOR_H +#define AVFORMAT_VERSION_MAJOR_H + +/** + * @file + * @ingroup libavf + * Libavformat version macros + */ + +// Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium) +// Also please add any ticket numbers that you believe might be affected here +#define LIBAVFORMAT_VERSION_MAJOR 60 + +/** + * FF_API_* defines may be placed below to indicate public API that will be + * dropped at a future version bump. The defines themselves are not part of + * the public API and may change, break or disappear at any time. + * + * @note, when bumping the major version it is recommended to manually + * disable each FF_API_* in its own commit instead of disabling them all + * at once through the bump. This improves the git bisect-ability of the change. + * + */ +#define FF_API_COMPUTE_PKT_FIELDS2 (LIBAVFORMAT_VERSION_MAJOR < 61) +#define FF_API_GET_END_PTS (LIBAVFORMAT_VERSION_MAJOR < 61) +#define FF_API_AVIODIRCONTEXT (LIBAVFORMAT_VERSION_MAJOR < 61) +#define FF_API_AVFORMAT_IO_CLOSE (LIBAVFORMAT_VERSION_MAJOR < 61) +#define FF_API_AVIO_WRITE_NONCONST (LIBAVFORMAT_VERSION_MAJOR < 61) +#define FF_API_LAVF_SHORTEST (LIBAVFORMAT_VERSION_MAJOR < 61) +#define FF_API_ALLOW_FLUSH (LIBAVFORMAT_VERSION_MAJOR < 61) +#define FF_API_AVSTREAM_SIDE_DATA (LIBAVFORMAT_VERSION_MAJOR < 61) + + +#define FF_API_R_FRAME_RATE 1 + +#endif /* AVFORMAT_VERSION_MAJOR_H */ diff --git a/library/FFmpeg/include/libavutil/aes.h b/library/FFmpeg/include/libavutil/aes.h index 09efbda1..4e734736 100644 --- a/library/FFmpeg/include/libavutil/aes.h +++ b/library/FFmpeg/include/libavutil/aes.h @@ -24,7 +24,6 @@ #include #include "attributes.h" -#include "version.h" /** * @defgroup lavu_aes AES @@ -43,6 +42,9 @@ struct AVAES *av_aes_alloc(void); /** * Initialize an AVAES context. + * + * @param a The AVAES context + * @param key Pointer to the key * @param key_bits 128, 192 or 256 * @param decrypt 0 for encryption, 1 for decryption */ @@ -50,9 +52,11 @@ int av_aes_init(struct AVAES *a, const uint8_t *key, int key_bits, int decrypt); /** * Encrypt or decrypt a buffer using a previously initialized context. - * @param count number of 16 byte blocks + * + * @param a The AVAES context * @param dst destination array, can be equal to src * @param src source array, can be equal to dst + * @param count number of 16 byte blocks * @param iv initialization vector for CBC mode, if NULL then ECB will be used * @param decrypt 0 for encryption, 1 for decryption */ diff --git a/library/FFmpeg/include/libavutil/aes_ctr.h b/library/FFmpeg/include/libavutil/aes_ctr.h index e4aae126..d98c0712 100644 --- a/library/FFmpeg/include/libavutil/aes_ctr.h +++ b/library/FFmpeg/include/libavutil/aes_ctr.h @@ -22,10 +22,15 @@ #ifndef AVUTIL_AES_CTR_H #define AVUTIL_AES_CTR_H +/** + * @defgroup lavu_aes_ctr AES-CTR + * @ingroup lavu_crypto + * @{ + */ + #include #include "attributes.h" -#include "version.h" #define AES_CTR_KEY_SIZE (16) #define AES_CTR_IV_SIZE (8) @@ -39,17 +44,23 @@ struct AVAESCTR *av_aes_ctr_alloc(void); /** * Initialize an AVAESCTR context. + * + * @param a The AVAESCTR context to initialize * @param key encryption key, must have a length of AES_CTR_KEY_SIZE */ int av_aes_ctr_init(struct AVAESCTR *a, const uint8_t *key); /** * Release an AVAESCTR context. + * + * @param a The AVAESCTR context */ void av_aes_ctr_free(struct AVAESCTR *a); /** * Process a buffer using a previously initialized context. + * + * @param a The AVAESCTR context * @param dst destination array, can be equal to src * @param src source array, can be equal to dst * @param size the size of src and dst diff --git a/library/FFmpeg/include/libavutil/ambient_viewing_environment.h b/library/FFmpeg/include/libavutil/ambient_viewing_environment.h new file mode 100644 index 00000000..e5e4ac21 --- /dev/null +++ b/library/FFmpeg/include/libavutil/ambient_viewing_environment.h @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2023 Jan Ekström + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_AMBIENT_VIEWING_ENVIRONMENT_H +#define AVUTIL_AMBIENT_VIEWING_ENVIRONMENT_H + +#include +#include "frame.h" +#include "rational.h" + +/** + * Ambient viewing environment metadata as defined by H.274. The values are + * saved in AVRationals so that they keep their exactness, while allowing for + * easy access to a double value with f.ex. av_q2d. + * + * @note sizeof(AVAmbientViewingEnvironment) is not part of the public ABI, and + * it must be allocated using av_ambient_viewing_environment_alloc. + */ +typedef struct AVAmbientViewingEnvironment { + /** + * Environmental illuminance of the ambient viewing environment in lux. + */ + AVRational ambient_illuminance; + + /** + * Normalized x chromaticity coordinate of the environmental ambient light + * in the nominal viewing environment according to the CIE 1931 definition + * of x and y as specified in ISO/CIE 11664-1. + */ + AVRational ambient_light_x; + + /** + * Normalized y chromaticity coordinate of the environmental ambient light + * in the nominal viewing environment according to the CIE 1931 definition + * of x and y as specified in ISO/CIE 11664-1. + */ + AVRational ambient_light_y; +} AVAmbientViewingEnvironment; + +/** + * Allocate an AVAmbientViewingEnvironment structure. + * + * @return the newly allocated struct or NULL on failure + */ +AVAmbientViewingEnvironment *av_ambient_viewing_environment_alloc(size_t *size); + +/** + * Allocate and add an AVAmbientViewingEnvironment structure to an existing + * AVFrame as side data. + * + * @return the newly allocated struct, or NULL on failure + */ +AVAmbientViewingEnvironment *av_ambient_viewing_environment_create_side_data(AVFrame *frame); + +#endif /* AVUTIL_AMBIENT_VIEWING_ENVIRONMENT_H */ diff --git a/library/FFmpeg/include/libavutil/attributes.h b/library/FFmpeg/include/libavutil/attributes.h index 5cb9fe34..04c615c9 100644 --- a/library/FFmpeg/include/libavutil/attributes.h +++ b/library/FFmpeg/include/libavutil/attributes.h @@ -110,7 +110,7 @@ * scheduled for removal. */ #ifndef AV_NOWARN_DEPRECATED -#if AV_GCC_VERSION_AT_LEAST(4,6) +#if AV_GCC_VERSION_AT_LEAST(4,6) || defined(__clang__) # define AV_NOWARN_DEPRECATED(code) \ _Pragma("GCC diagnostic push") \ _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") \ diff --git a/library/FFmpeg/include/libavutil/audio_fifo.h b/library/FFmpeg/include/libavutil/audio_fifo.h index d8a9194a..fa5f59a2 100644 --- a/library/FFmpeg/include/libavutil/audio_fifo.h +++ b/library/FFmpeg/include/libavutil/audio_fifo.h @@ -27,8 +27,7 @@ #ifndef AVUTIL_AUDIO_FIFO_H #define AVUTIL_AUDIO_FIFO_H -#include "avutil.h" -#include "fifo.h" +#include "attributes.h" #include "samplefmt.h" /** @@ -92,7 +91,7 @@ int av_audio_fifo_realloc(AVAudioFifo *af, int nb_samples); * code on failure. If successful, the number of samples * actually written will always be nb_samples. */ -int av_audio_fifo_write(AVAudioFifo *af, void **data, int nb_samples); +int av_audio_fifo_write(AVAudioFifo *af, void * const *data, int nb_samples); /** * Peek data from an AVAudioFifo. @@ -108,7 +107,7 @@ int av_audio_fifo_write(AVAudioFifo *af, void **data, int nb_samples); * be greater than nb_samples, and will only be less than * nb_samples if av_audio_fifo_size is less than nb_samples. */ -int av_audio_fifo_peek(AVAudioFifo *af, void **data, int nb_samples); +int av_audio_fifo_peek(const AVAudioFifo *af, void * const *data, int nb_samples); /** * Peek data from an AVAudioFifo. @@ -125,7 +124,8 @@ int av_audio_fifo_peek(AVAudioFifo *af, void **data, int nb_samples); * be greater than nb_samples, and will only be less than * nb_samples if av_audio_fifo_size is less than nb_samples. */ -int av_audio_fifo_peek_at(AVAudioFifo *af, void **data, int nb_samples, int offset); +int av_audio_fifo_peek_at(const AVAudioFifo *af, void * const *data, + int nb_samples, int offset); /** * Read data from an AVAudioFifo. @@ -141,7 +141,7 @@ int av_audio_fifo_peek_at(AVAudioFifo *af, void **data, int nb_samples, int offs * be greater than nb_samples, and will only be less than * nb_samples if av_audio_fifo_size is less than nb_samples. */ -int av_audio_fifo_read(AVAudioFifo *af, void **data, int nb_samples); +int av_audio_fifo_read(AVAudioFifo *af, void * const *data, int nb_samples); /** * Drain data from an AVAudioFifo. diff --git a/library/FFmpeg/include/libavutil/avassert.h b/library/FFmpeg/include/libavutil/avassert.h index 0e04ff05..04c3e846 100644 --- a/library/FFmpeg/include/libavutil/avassert.h +++ b/library/FFmpeg/include/libavutil/avassert.h @@ -28,8 +28,11 @@ #define AVUTIL_AVASSERT_H #include -#include "avutil.h" +#ifdef HAVE_AV_CONFIG_H +# include "config.h" +#endif #include "log.h" +#include "macros.h" /** * assert() equivalent, that is always enabled. diff --git a/library/FFmpeg/include/libavutil/avstring.h b/library/FFmpeg/include/libavutil/avstring.h index fae446c3..fc095349 100644 --- a/library/FFmpeg/include/libavutil/avstring.h +++ b/library/FFmpeg/include/libavutil/avstring.h @@ -24,7 +24,6 @@ #include #include #include "attributes.h" -#include "version.h" /** * @addtogroup lavu_string @@ -135,6 +134,7 @@ size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...) av_printf_forma /** * Get the count of continuous non zero chars starting from the beginning. * + * @param s the string whose length to count * @param len maximum number of characters to check in the string, that * is the maximum value which is returned by the function */ @@ -156,15 +156,6 @@ static inline size_t av_strnlen(const char *s, size_t len) */ char *av_asprintf(const char *fmt, ...) av_printf_format(1, 2); -#if FF_API_D2STR -/** - * Convert a number to an av_malloced string. - * @deprecated use av_asprintf() with "%f" or a more specific format - */ -attribute_deprecated -char *av_d2str(double d); -#endif - /** * Unescape the given string until a non escaped terminating char, * and return the token corresponding to the unescaped string. @@ -273,7 +264,7 @@ int av_strncasecmp(const char *a, const char *b, size_t n); /** * Locale-independent strings replace. - * @note This means only ASCII-range characters are replace + * @note This means only ASCII-range characters are replaced. */ char *av_strireplace(const char *str, const char *from, const char *to); diff --git a/library/FFmpeg/include/libavutil/avutil.h b/library/FFmpeg/include/libavutil/avutil.h index 4d633156..a362c8ba 100644 --- a/library/FFmpeg/include/libavutil/avutil.h +++ b/library/FFmpeg/include/libavutil/avutil.h @@ -257,7 +257,12 @@ const char *av_get_media_type_string(enum AVMediaType media_type); * Internal time base represented as fractional value */ +#ifdef __cplusplus +/* ISO C++ forbids compound-literals. */ +#define AV_TIME_BASE_Q av_make_q(1, AV_TIME_BASE) +#else #define AV_TIME_BASE_Q (AVRational){1, AV_TIME_BASE} +#endif /** * @} @@ -294,7 +299,6 @@ char av_get_picture_type_char(enum AVPictureType pict_type); */ #include "common.h" -#include "error.h" #include "rational.h" #include "version.h" #include "macros.h" @@ -331,12 +335,18 @@ unsigned av_int_list_length_for_size(unsigned elsize, #define av_int_list_length(list, term) \ av_int_list_length_for_size(sizeof(*(list)), list, term) +#if FF_API_AV_FOPEN_UTF8 /** * Open a file using a UTF-8 filename. * The API of this function matches POSIX fopen(), errors are returned through * errno. + * @deprecated Avoid using it, as on Windows, the FILE* allocated by this + * function may be allocated with a different CRT than the caller + * who uses the FILE*. No replacement provided in public API. */ +attribute_deprecated FILE *av_fopen_utf8(const char *path, const char *mode); +#endif /** * Return the fractional representation of the internal time base. diff --git a/library/FFmpeg/include/libavutil/bprint.h b/library/FFmpeg/include/libavutil/bprint.h index c09b1ac1..85597454 100644 --- a/library/FFmpeg/include/libavutil/bprint.h +++ b/library/FFmpeg/include/libavutil/bprint.h @@ -18,6 +18,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +/** + * @file + * @ingroup lavu_avbprint + * AVBPrint public header + */ + #ifndef AVUTIL_BPRINT_H #define AVUTIL_BPRINT_H @@ -26,6 +32,14 @@ #include "attributes.h" #include "avstring.h" +/** + * @defgroup lavu_avbprint AVBPrint + * @ingroup lavu_data + * + * A buffer to print data progressively + * @{ + */ + /** * Define a structure with extra padding to a fixed size * This helps ensuring binary compatibility with future versions. @@ -48,14 +62,14 @@ typedef struct name { \ * Small buffers are kept in the structure itself, and thus require no * memory allocation at all (unless the contents of the buffer is needed * after the structure goes out of scope). This is almost as lightweight as - * declaring a local "char buf[512]". + * declaring a local `char buf[512]`. * * The length of the string can go beyond the allocated size: the buffer is * then truncated, but the functions still keep account of the actual total * length. * - * In other words, buf->len can be greater than buf->size and records the - * total length of what would have been to the buffer if there had been + * In other words, AVBPrint.len can be greater than AVBPrint.size and records + * the total length of what would have been to the buffer if there had been * enough memory. * * Append operations do not need to be tested for failure: if a memory @@ -63,20 +77,17 @@ typedef struct name { \ * is still updated. This situation can be tested with * av_bprint_is_complete(). * - * The size_max field determines several possible behaviours: - * - * size_max = -1 (= UINT_MAX) or any large value will let the buffer be - * reallocated as necessary, with an amortized linear cost. - * - * size_max = 0 prevents writing anything to the buffer: only the total - * length is computed. The write operations can then possibly be repeated in - * a buffer with exactly the necessary size - * (using size_init = size_max = len + 1). - * - * size_max = 1 is automatically replaced by the exact size available in the - * structure itself, thus ensuring no dynamic memory allocation. The - * internal buffer is large enough to hold a reasonable paragraph of text, - * such as the current paragraph. + * The AVBPrint.size_max field determines several possible behaviours: + * - `size_max = -1` (= `UINT_MAX`) or any large value will let the buffer be + * reallocated as necessary, with an amortized linear cost. + * - `size_max = 0` prevents writing anything to the buffer: only the total + * length is computed. The write operations can then possibly be repeated in + * a buffer with exactly the necessary size + * (using `size_init = size_max = len + 1`). + * - `size_max = 1` is automatically replaced by the exact size available in the + * structure itself, thus ensuring no dynamic memory allocation. The + * internal buffer is large enough to hold a reasonable paragraph of text, + * such as the current paragraph. */ FF_PAD_STRUCTURE(AVBPrint, 1024, @@ -88,12 +99,31 @@ FF_PAD_STRUCTURE(AVBPrint, 1024, ) /** + * @name Max size special values * Convenience macros for special values for av_bprint_init() size_max * parameter. + * @{ + */ + +/** + * Buffer will be reallocated as necessary, with an amortized linear cost. */ #define AV_BPRINT_SIZE_UNLIMITED ((unsigned)-1) +/** + * Use the exact size available in the AVBPrint structure itself. + * + * Thus ensuring no dynamic memory allocation. The internal buffer is large + * enough to hold a reasonable paragraph of text, such as the current paragraph. + */ #define AV_BPRINT_SIZE_AUTOMATIC 1 +/** + * Do not write anything to the buffer, only calculate the total length. + * + * The write operations can then possibly be repeated in a buffer with + * exactly the necessary size (using `size_init = size_max = AVBPrint.len + 1`). + */ #define AV_BPRINT_SIZE_COUNT_ONLY 0 +/** @} */ /** * Init a print buffer. @@ -101,12 +131,12 @@ FF_PAD_STRUCTURE(AVBPrint, 1024, * @param buf buffer to init * @param size_init initial size (including the final 0) * @param size_max maximum size; - * 0 means do not write anything, just count the length; - * 1 is replaced by the maximum value for automatic storage; - * any large value means that the internal buffer will be - * reallocated as needed up to that limit; -1 is converted to - * UINT_MAX, the largest limit possible. - * Check also AV_BPRINT_SIZE_* macros. + * - `0` means do not write anything, just count the length + * - `1` is replaced by the maximum value for automatic storage + * any large value means that the internal buffer will be + * reallocated as needed up to that limit + * - `-1` is converted to `UINT_MAX`, the largest limit possible. + * Check also `AV_BPRINT_SIZE_*` macros. */ void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max); @@ -114,6 +144,9 @@ void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max); * Init a print buffer using a pre-existing buffer. * * The buffer will not be reallocated. + * In case size equals zero, the AVBPrint will be initialized to use + * the internal buffer as if using AV_BPRINT_SIZE_COUNT_ONLY with + * av_bprint_init(). * * @param buf buffer structure to init * @param buffer byte buffer to use for the string data @@ -216,4 +249,6 @@ int av_bprint_finalize(AVBPrint *buf, char **ret_str); void av_bprint_escape(AVBPrint *dstbuf, const char *src, const char *special_chars, enum AVEscapeMode mode, int flags); +/** @} */ + #endif /* AVUTIL_BPRINT_H */ diff --git a/library/FFmpeg/include/libavutil/bswap.h b/library/FFmpeg/include/libavutil/bswap.h index 91cb7953..4840ab43 100644 --- a/library/FFmpeg/include/libavutil/bswap.h +++ b/library/FFmpeg/include/libavutil/bswap.h @@ -40,6 +40,8 @@ # include "arm/bswap.h" #elif ARCH_AVR32 # include "avr32/bswap.h" +#elif ARCH_RISCV +# include "riscv/bswap.h" #elif ARCH_SH4 # include "sh4/bswap.h" #elif ARCH_X86 diff --git a/library/FFmpeg/include/libavutil/buffer.h b/library/FFmpeg/include/libavutil/buffer.h index 63ab87eb..e1ef5b7f 100644 --- a/library/FFmpeg/include/libavutil/buffer.h +++ b/library/FFmpeg/include/libavutil/buffer.h @@ -28,8 +28,6 @@ #include #include -#include "version.h" - /** * @defgroup lavu_buffer AVBuffer * @ingroup lavu_data @@ -147,7 +145,7 @@ void av_buffer_default_free(void *opaque, uint8_t *data); * @return a new AVBufferRef referring to the same AVBuffer as buf or NULL on * failure. */ -AVBufferRef *av_buffer_ref(AVBufferRef *buf); +AVBufferRef *av_buffer_ref(const AVBufferRef *buf); /** * Free a given reference and automatically free the buffer if there are no more @@ -214,7 +212,7 @@ int av_buffer_realloc(AVBufferRef **buf, size_t size); * @return 0 on success * AVERROR(ENOMEM) on memory allocation failure. */ -int av_buffer_replace(AVBufferRef **dst, AVBufferRef *src); +int av_buffer_replace(AVBufferRef **dst, const AVBufferRef *src); /** * @} @@ -315,7 +313,7 @@ AVBufferRef *av_buffer_pool_get(AVBufferPool *pool); * therefore you have to use this function to access the original opaque * parameter of an allocated buffer. */ -void *av_buffer_pool_buffer_get_opaque(AVBufferRef *ref); +void *av_buffer_pool_buffer_get_opaque(const AVBufferRef *ref); /** * @} diff --git a/library/FFmpeg/include/libavutil/camellia.h b/library/FFmpeg/include/libavutil/camellia.h index e674c9b9..96787102 100644 --- a/library/FFmpeg/include/libavutil/camellia.h +++ b/library/FFmpeg/include/libavutil/camellia.h @@ -59,7 +59,7 @@ int av_camellia_init(struct AVCAMELLIA *ctx, const uint8_t *key, int key_bits); * @param dst destination array, can be equal to src * @param src source array, can be equal to dst * @param count number of 16 byte blocks - * @paran iv initialization vector for CBC mode, NULL for ECB mode + * @param iv initialization vector for CBC mode, NULL for ECB mode * @param decrypt 0 for encryption, 1 for decryption */ void av_camellia_crypt(struct AVCAMELLIA *ctx, uint8_t *dst, const uint8_t *src, int count, uint8_t* iv, int decrypt); diff --git a/library/FFmpeg/include/libavutil/channel_layout.h b/library/FFmpeg/include/libavutil/channel_layout.h index d39ae117..c9c404ef 100644 --- a/library/FFmpeg/include/libavutil/channel_layout.h +++ b/library/FFmpeg/include/libavutil/channel_layout.h @@ -23,17 +23,132 @@ #define AVUTIL_CHANNEL_LAYOUT_H #include +#include + +#include "version.h" +#include "attributes.h" /** * @file - * audio channel layout utility functions + * @ingroup lavu_audio_channels + * Public libavutil channel layout APIs header. */ + /** - * @addtogroup lavu_audio + * @defgroup lavu_audio_channels Audio channels + * @ingroup lavu_audio + * + * Audio channel layout utility functions + * * @{ */ +enum AVChannel { + ///< Invalid channel index + AV_CHAN_NONE = -1, + AV_CHAN_FRONT_LEFT, + AV_CHAN_FRONT_RIGHT, + AV_CHAN_FRONT_CENTER, + AV_CHAN_LOW_FREQUENCY, + AV_CHAN_BACK_LEFT, + AV_CHAN_BACK_RIGHT, + AV_CHAN_FRONT_LEFT_OF_CENTER, + AV_CHAN_FRONT_RIGHT_OF_CENTER, + AV_CHAN_BACK_CENTER, + AV_CHAN_SIDE_LEFT, + AV_CHAN_SIDE_RIGHT, + AV_CHAN_TOP_CENTER, + AV_CHAN_TOP_FRONT_LEFT, + AV_CHAN_TOP_FRONT_CENTER, + AV_CHAN_TOP_FRONT_RIGHT, + AV_CHAN_TOP_BACK_LEFT, + AV_CHAN_TOP_BACK_CENTER, + AV_CHAN_TOP_BACK_RIGHT, + /** Stereo downmix. */ + AV_CHAN_STEREO_LEFT = 29, + /** See above. */ + AV_CHAN_STEREO_RIGHT, + AV_CHAN_WIDE_LEFT, + AV_CHAN_WIDE_RIGHT, + AV_CHAN_SURROUND_DIRECT_LEFT, + AV_CHAN_SURROUND_DIRECT_RIGHT, + AV_CHAN_LOW_FREQUENCY_2, + AV_CHAN_TOP_SIDE_LEFT, + AV_CHAN_TOP_SIDE_RIGHT, + AV_CHAN_BOTTOM_FRONT_CENTER, + AV_CHAN_BOTTOM_FRONT_LEFT, + AV_CHAN_BOTTOM_FRONT_RIGHT, + + /** Channel is empty can be safely skipped. */ + AV_CHAN_UNUSED = 0x200, + + /** Channel contains data, but its position is unknown. */ + AV_CHAN_UNKNOWN = 0x300, + + /** + * Range of channels between AV_CHAN_AMBISONIC_BASE and + * AV_CHAN_AMBISONIC_END represent Ambisonic components using the ACN system. + * + * Given a channel id `` between AV_CHAN_AMBISONIC_BASE and + * AV_CHAN_AMBISONIC_END (inclusive), the ACN index of the channel `` is + * ` = - AV_CHAN_AMBISONIC_BASE`. + * + * @note these values are only used for AV_CHANNEL_ORDER_CUSTOM channel + * orderings, the AV_CHANNEL_ORDER_AMBISONIC ordering orders the channels + * implicitly by their position in the stream. + */ + AV_CHAN_AMBISONIC_BASE = 0x400, + // leave space for 1024 ids, which correspond to maximum order-32 harmonics, + // which should be enough for the foreseeable use cases + AV_CHAN_AMBISONIC_END = 0x7ff, +}; + +enum AVChannelOrder { + /** + * Only the channel count is specified, without any further information + * about the channel order. + */ + AV_CHANNEL_ORDER_UNSPEC, + /** + * The native channel order, i.e. the channels are in the same order in + * which they are defined in the AVChannel enum. This supports up to 63 + * different channels. + */ + AV_CHANNEL_ORDER_NATIVE, + /** + * The channel order does not correspond to any other predefined order and + * is stored as an explicit map. For example, this could be used to support + * layouts with 64 or more channels, or with empty/skipped (AV_CHAN_SILENCE) + * channels at arbitrary positions. + */ + AV_CHANNEL_ORDER_CUSTOM, + /** + * The audio is represented as the decomposition of the sound field into + * spherical harmonics. Each channel corresponds to a single expansion + * component. Channels are ordered according to ACN (Ambisonic Channel + * Number). + * + * The channel with the index n in the stream contains the spherical + * harmonic of degree l and order m given by + * @code{.unparsed} + * l = floor(sqrt(n)), + * m = n - l * (l + 1). + * @endcode + * + * Conversely given a spherical harmonic of degree l and order m, the + * corresponding channel index n is given by + * @code{.unparsed} + * n = l * (l + 1) + m. + * @endcode + * + * Normalization is assumed to be SN3D (Schmidt Semi-Normalization) + * as defined in AmbiX format $ 2.1. + */ + AV_CHANNEL_ORDER_AMBISONIC, +}; + + /** * @defgroup channel_masks Audio channel masks * @@ -46,41 +161,46 @@ * * @{ */ -#define AV_CH_FRONT_LEFT 0x00000001 -#define AV_CH_FRONT_RIGHT 0x00000002 -#define AV_CH_FRONT_CENTER 0x00000004 -#define AV_CH_LOW_FREQUENCY 0x00000008 -#define AV_CH_BACK_LEFT 0x00000010 -#define AV_CH_BACK_RIGHT 0x00000020 -#define AV_CH_FRONT_LEFT_OF_CENTER 0x00000040 -#define AV_CH_FRONT_RIGHT_OF_CENTER 0x00000080 -#define AV_CH_BACK_CENTER 0x00000100 -#define AV_CH_SIDE_LEFT 0x00000200 -#define AV_CH_SIDE_RIGHT 0x00000400 -#define AV_CH_TOP_CENTER 0x00000800 -#define AV_CH_TOP_FRONT_LEFT 0x00001000 -#define AV_CH_TOP_FRONT_CENTER 0x00002000 -#define AV_CH_TOP_FRONT_RIGHT 0x00004000 -#define AV_CH_TOP_BACK_LEFT 0x00008000 -#define AV_CH_TOP_BACK_CENTER 0x00010000 -#define AV_CH_TOP_BACK_RIGHT 0x00020000 -#define AV_CH_STEREO_LEFT 0x20000000 ///< Stereo downmix. -#define AV_CH_STEREO_RIGHT 0x40000000 ///< See AV_CH_STEREO_LEFT. -#define AV_CH_WIDE_LEFT 0x0000000080000000ULL -#define AV_CH_WIDE_RIGHT 0x0000000100000000ULL -#define AV_CH_SURROUND_DIRECT_LEFT 0x0000000200000000ULL -#define AV_CH_SURROUND_DIRECT_RIGHT 0x0000000400000000ULL -#define AV_CH_LOW_FREQUENCY_2 0x0000000800000000ULL -#define AV_CH_TOP_SIDE_LEFT 0x0000001000000000ULL -#define AV_CH_TOP_SIDE_RIGHT 0x0000002000000000ULL -#define AV_CH_BOTTOM_FRONT_CENTER 0x0000004000000000ULL -#define AV_CH_BOTTOM_FRONT_LEFT 0x0000008000000000ULL -#define AV_CH_BOTTOM_FRONT_RIGHT 0x0000010000000000ULL +#define AV_CH_FRONT_LEFT (1ULL << AV_CHAN_FRONT_LEFT ) +#define AV_CH_FRONT_RIGHT (1ULL << AV_CHAN_FRONT_RIGHT ) +#define AV_CH_FRONT_CENTER (1ULL << AV_CHAN_FRONT_CENTER ) +#define AV_CH_LOW_FREQUENCY (1ULL << AV_CHAN_LOW_FREQUENCY ) +#define AV_CH_BACK_LEFT (1ULL << AV_CHAN_BACK_LEFT ) +#define AV_CH_BACK_RIGHT (1ULL << AV_CHAN_BACK_RIGHT ) +#define AV_CH_FRONT_LEFT_OF_CENTER (1ULL << AV_CHAN_FRONT_LEFT_OF_CENTER ) +#define AV_CH_FRONT_RIGHT_OF_CENTER (1ULL << AV_CHAN_FRONT_RIGHT_OF_CENTER) +#define AV_CH_BACK_CENTER (1ULL << AV_CHAN_BACK_CENTER ) +#define AV_CH_SIDE_LEFT (1ULL << AV_CHAN_SIDE_LEFT ) +#define AV_CH_SIDE_RIGHT (1ULL << AV_CHAN_SIDE_RIGHT ) +#define AV_CH_TOP_CENTER (1ULL << AV_CHAN_TOP_CENTER ) +#define AV_CH_TOP_FRONT_LEFT (1ULL << AV_CHAN_TOP_FRONT_LEFT ) +#define AV_CH_TOP_FRONT_CENTER (1ULL << AV_CHAN_TOP_FRONT_CENTER ) +#define AV_CH_TOP_FRONT_RIGHT (1ULL << AV_CHAN_TOP_FRONT_RIGHT ) +#define AV_CH_TOP_BACK_LEFT (1ULL << AV_CHAN_TOP_BACK_LEFT ) +#define AV_CH_TOP_BACK_CENTER (1ULL << AV_CHAN_TOP_BACK_CENTER ) +#define AV_CH_TOP_BACK_RIGHT (1ULL << AV_CHAN_TOP_BACK_RIGHT ) +#define AV_CH_STEREO_LEFT (1ULL << AV_CHAN_STEREO_LEFT ) +#define AV_CH_STEREO_RIGHT (1ULL << AV_CHAN_STEREO_RIGHT ) +#define AV_CH_WIDE_LEFT (1ULL << AV_CHAN_WIDE_LEFT ) +#define AV_CH_WIDE_RIGHT (1ULL << AV_CHAN_WIDE_RIGHT ) +#define AV_CH_SURROUND_DIRECT_LEFT (1ULL << AV_CHAN_SURROUND_DIRECT_LEFT ) +#define AV_CH_SURROUND_DIRECT_RIGHT (1ULL << AV_CHAN_SURROUND_DIRECT_RIGHT) +#define AV_CH_LOW_FREQUENCY_2 (1ULL << AV_CHAN_LOW_FREQUENCY_2 ) +#define AV_CH_TOP_SIDE_LEFT (1ULL << AV_CHAN_TOP_SIDE_LEFT ) +#define AV_CH_TOP_SIDE_RIGHT (1ULL << AV_CHAN_TOP_SIDE_RIGHT ) +#define AV_CH_BOTTOM_FRONT_CENTER (1ULL << AV_CHAN_BOTTOM_FRONT_CENTER ) +#define AV_CH_BOTTOM_FRONT_LEFT (1ULL << AV_CHAN_BOTTOM_FRONT_LEFT ) +#define AV_CH_BOTTOM_FRONT_RIGHT (1ULL << AV_CHAN_BOTTOM_FRONT_RIGHT ) +#if FF_API_OLD_CHANNEL_LAYOUT /** Channel mask value used for AVCodecContext.request_channel_layout to indicate that the user requests the channel order of the decoder output - to be the native codec channel order. */ + to be the native codec channel order. + @deprecated channel order is now indicated in a special field in + AVChannelLayout + */ #define AV_CH_LAYOUT_NATIVE 0x8000000000000000ULL +#endif /** * @} @@ -104,6 +224,7 @@ #define AV_CH_LAYOUT_6POINT0 (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_CENTER) #define AV_CH_LAYOUT_6POINT0_FRONT (AV_CH_LAYOUT_2_2|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER) #define AV_CH_LAYOUT_HEXAGONAL (AV_CH_LAYOUT_5POINT0_BACK|AV_CH_BACK_CENTER) +#define AV_CH_LAYOUT_3POINT1POINT2 (AV_CH_LAYOUT_3POINT1|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT) #define AV_CH_LAYOUT_6POINT1 (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_CENTER) #define AV_CH_LAYOUT_6POINT1_BACK (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_BACK_CENTER) #define AV_CH_LAYOUT_6POINT1_FRONT (AV_CH_LAYOUT_6POINT0_FRONT|AV_CH_LOW_FREQUENCY) @@ -112,10 +233,17 @@ #define AV_CH_LAYOUT_7POINT1 (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT) #define AV_CH_LAYOUT_7POINT1_WIDE (AV_CH_LAYOUT_5POINT1|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER) #define AV_CH_LAYOUT_7POINT1_WIDE_BACK (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER) +#define AV_CH_LAYOUT_5POINT1POINT2_BACK (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT) #define AV_CH_LAYOUT_OCTAGONAL (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_CENTER|AV_CH_BACK_RIGHT) +#define AV_CH_LAYOUT_CUBE (AV_CH_LAYOUT_QUAD|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT|AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_RIGHT) +#define AV_CH_LAYOUT_5POINT1POINT4_BACK (AV_CH_LAYOUT_5POINT1POINT2_BACK|AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_RIGHT) +#define AV_CH_LAYOUT_7POINT1POINT2 (AV_CH_LAYOUT_7POINT1|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT) +#define AV_CH_LAYOUT_7POINT1POINT4_BACK (AV_CH_LAYOUT_7POINT1POINT2|AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_RIGHT) #define AV_CH_LAYOUT_HEXADECAGONAL (AV_CH_LAYOUT_OCTAGONAL|AV_CH_WIDE_LEFT|AV_CH_WIDE_RIGHT|AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_RIGHT|AV_CH_TOP_BACK_CENTER|AV_CH_TOP_FRONT_CENTER|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT) #define AV_CH_LAYOUT_STEREO_DOWNMIX (AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT) -#define AV_CH_LAYOUT_22POINT2 (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER|AV_CH_BACK_CENTER|AV_CH_LOW_FREQUENCY_2|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT|AV_CH_TOP_FRONT_CENTER|AV_CH_TOP_CENTER|AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_RIGHT|AV_CH_TOP_SIDE_LEFT|AV_CH_TOP_SIDE_RIGHT|AV_CH_TOP_BACK_CENTER|AV_CH_BOTTOM_FRONT_CENTER|AV_CH_BOTTOM_FRONT_LEFT|AV_CH_BOTTOM_FRONT_RIGHT) +#define AV_CH_LAYOUT_22POINT2 (AV_CH_LAYOUT_7POINT1POINT4_BACK|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER|AV_CH_BACK_CENTER|AV_CH_LOW_FREQUENCY_2|AV_CH_TOP_FRONT_CENTER|AV_CH_TOP_CENTER|AV_CH_TOP_SIDE_LEFT|AV_CH_TOP_SIDE_RIGHT|AV_CH_TOP_BACK_CENTER|AV_CH_BOTTOM_FRONT_CENTER|AV_CH_BOTTOM_FRONT_LEFT|AV_CH_BOTTOM_FRONT_RIGHT) + +#define AV_CH_LAYOUT_7POINT1_TOP_BACK AV_CH_LAYOUT_5POINT1POINT2_BACK enum AVMatrixEncoding { AV_MATRIX_ENCODING_NONE, @@ -128,6 +256,182 @@ enum AVMatrixEncoding { AV_MATRIX_ENCODING_NB }; +/** + * @} + */ + +/** + * An AVChannelCustom defines a single channel within a custom order layout + * + * Unlike most structures in FFmpeg, sizeof(AVChannelCustom) is a part of the + * public ABI. + * + * No new fields may be added to it without a major version bump. + */ +typedef struct AVChannelCustom { + enum AVChannel id; + char name[16]; + void *opaque; +} AVChannelCustom; + +/** + * An AVChannelLayout holds information about the channel layout of audio data. + * + * A channel layout here is defined as a set of channels ordered in a specific + * way (unless the channel order is AV_CHANNEL_ORDER_UNSPEC, in which case an + * AVChannelLayout carries only the channel count). + * All orders may be treated as if they were AV_CHANNEL_ORDER_UNSPEC by + * ignoring everything but the channel count, as long as av_channel_layout_check() + * considers they are valid. + * + * Unlike most structures in FFmpeg, sizeof(AVChannelLayout) is a part of the + * public ABI and may be used by the caller. E.g. it may be allocated on stack + * or embedded in caller-defined structs. + * + * AVChannelLayout can be initialized as follows: + * - default initialization with {0}, followed by setting all used fields + * correctly; + * - by assigning one of the predefined AV_CHANNEL_LAYOUT_* initializers; + * - with a constructor function, such as av_channel_layout_default(), + * av_channel_layout_from_mask() or av_channel_layout_from_string(). + * + * The channel layout must be unitialized with av_channel_layout_uninit() + * + * Copying an AVChannelLayout via assigning is forbidden, + * av_channel_layout_copy() must be used instead (and its return value should + * be checked) + * + * No new fields may be added to it without a major version bump, except for + * new elements of the union fitting in sizeof(uint64_t). + */ +typedef struct AVChannelLayout { + /** + * Channel order used in this layout. + * This is a mandatory field. + */ + enum AVChannelOrder order; + + /** + * Number of channels in this layout. Mandatory field. + */ + int nb_channels; + + /** + * Details about which channels are present in this layout. + * For AV_CHANNEL_ORDER_UNSPEC, this field is undefined and must not be + * used. + */ + union { + /** + * This member must be used for AV_CHANNEL_ORDER_NATIVE, and may be used + * for AV_CHANNEL_ORDER_AMBISONIC to signal non-diegetic channels. + * It is a bitmask, where the position of each set bit means that the + * AVChannel with the corresponding value is present. + * + * I.e. when (mask & (1 << AV_CHAN_FOO)) is non-zero, then AV_CHAN_FOO + * is present in the layout. Otherwise it is not present. + * + * @note when a channel layout using a bitmask is constructed or + * modified manually (i.e. not using any of the av_channel_layout_* + * functions), the code doing it must ensure that the number of set bits + * is equal to nb_channels. + */ + uint64_t mask; + /** + * This member must be used when the channel order is + * AV_CHANNEL_ORDER_CUSTOM. It is a nb_channels-sized array, with each + * element signalling the presence of the AVChannel with the + * corresponding value in map[i].id. + * + * I.e. when map[i].id is equal to AV_CHAN_FOO, then AV_CH_FOO is the + * i-th channel in the audio data. + * + * When map[i].id is in the range between AV_CHAN_AMBISONIC_BASE and + * AV_CHAN_AMBISONIC_END (inclusive), the channel contains an ambisonic + * component with ACN index (as defined above) + * n = map[i].id - AV_CHAN_AMBISONIC_BASE. + * + * map[i].name may be filled with a 0-terminated string, in which case + * it will be used for the purpose of identifying the channel with the + * convenience functions below. Otherise it must be zeroed. + */ + AVChannelCustom *map; + } u; + + /** + * For some private data of the user. + */ + void *opaque; +} AVChannelLayout; + +/** + * Macro to define native channel layouts + * + * @note This doesn't use designated initializers for compatibility with C++ 17 and older. + */ +#define AV_CHANNEL_LAYOUT_MASK(nb, m) \ + { /* .order */ AV_CHANNEL_ORDER_NATIVE, \ + /* .nb_channels */ (nb), \ + /* .u.mask */ { m }, \ + /* .opaque */ NULL } + +/** + * @name Common pre-defined channel layouts + * @{ + */ +#define AV_CHANNEL_LAYOUT_MONO AV_CHANNEL_LAYOUT_MASK(1, AV_CH_LAYOUT_MONO) +#define AV_CHANNEL_LAYOUT_STEREO AV_CHANNEL_LAYOUT_MASK(2, AV_CH_LAYOUT_STEREO) +#define AV_CHANNEL_LAYOUT_2POINT1 AV_CHANNEL_LAYOUT_MASK(3, AV_CH_LAYOUT_2POINT1) +#define AV_CHANNEL_LAYOUT_2_1 AV_CHANNEL_LAYOUT_MASK(3, AV_CH_LAYOUT_2_1) +#define AV_CHANNEL_LAYOUT_SURROUND AV_CHANNEL_LAYOUT_MASK(3, AV_CH_LAYOUT_SURROUND) +#define AV_CHANNEL_LAYOUT_3POINT1 AV_CHANNEL_LAYOUT_MASK(4, AV_CH_LAYOUT_3POINT1) +#define AV_CHANNEL_LAYOUT_4POINT0 AV_CHANNEL_LAYOUT_MASK(4, AV_CH_LAYOUT_4POINT0) +#define AV_CHANNEL_LAYOUT_4POINT1 AV_CHANNEL_LAYOUT_MASK(5, AV_CH_LAYOUT_4POINT1) +#define AV_CHANNEL_LAYOUT_2_2 AV_CHANNEL_LAYOUT_MASK(4, AV_CH_LAYOUT_2_2) +#define AV_CHANNEL_LAYOUT_QUAD AV_CHANNEL_LAYOUT_MASK(4, AV_CH_LAYOUT_QUAD) +#define AV_CHANNEL_LAYOUT_5POINT0 AV_CHANNEL_LAYOUT_MASK(5, AV_CH_LAYOUT_5POINT0) +#define AV_CHANNEL_LAYOUT_5POINT1 AV_CHANNEL_LAYOUT_MASK(6, AV_CH_LAYOUT_5POINT1) +#define AV_CHANNEL_LAYOUT_5POINT0_BACK AV_CHANNEL_LAYOUT_MASK(5, AV_CH_LAYOUT_5POINT0_BACK) +#define AV_CHANNEL_LAYOUT_5POINT1_BACK AV_CHANNEL_LAYOUT_MASK(6, AV_CH_LAYOUT_5POINT1_BACK) +#define AV_CHANNEL_LAYOUT_6POINT0 AV_CHANNEL_LAYOUT_MASK(6, AV_CH_LAYOUT_6POINT0) +#define AV_CHANNEL_LAYOUT_6POINT0_FRONT AV_CHANNEL_LAYOUT_MASK(6, AV_CH_LAYOUT_6POINT0_FRONT) +#define AV_CHANNEL_LAYOUT_3POINT1POINT2 AV_CHANNEL_LAYOUT_MASK(6, AV_CH_LAYOUT_3POINT1POINT2) +#define AV_CHANNEL_LAYOUT_HEXAGONAL AV_CHANNEL_LAYOUT_MASK(6, AV_CH_LAYOUT_HEXAGONAL) +#define AV_CHANNEL_LAYOUT_6POINT1 AV_CHANNEL_LAYOUT_MASK(7, AV_CH_LAYOUT_6POINT1) +#define AV_CHANNEL_LAYOUT_6POINT1_BACK AV_CHANNEL_LAYOUT_MASK(7, AV_CH_LAYOUT_6POINT1_BACK) +#define AV_CHANNEL_LAYOUT_6POINT1_FRONT AV_CHANNEL_LAYOUT_MASK(7, AV_CH_LAYOUT_6POINT1_FRONT) +#define AV_CHANNEL_LAYOUT_7POINT0 AV_CHANNEL_LAYOUT_MASK(7, AV_CH_LAYOUT_7POINT0) +#define AV_CHANNEL_LAYOUT_7POINT0_FRONT AV_CHANNEL_LAYOUT_MASK(7, AV_CH_LAYOUT_7POINT0_FRONT) +#define AV_CHANNEL_LAYOUT_7POINT1 AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_7POINT1) +#define AV_CHANNEL_LAYOUT_7POINT1_WIDE AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_7POINT1_WIDE) +#define AV_CHANNEL_LAYOUT_7POINT1_WIDE_BACK AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_7POINT1_WIDE_BACK) +#define AV_CHANNEL_LAYOUT_5POINT1POINT2_BACK AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_5POINT1POINT2_BACK) +#define AV_CHANNEL_LAYOUT_OCTAGONAL AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_OCTAGONAL) +#define AV_CHANNEL_LAYOUT_CUBE AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_CUBE) +#define AV_CHANNEL_LAYOUT_5POINT1POINT4_BACK AV_CHANNEL_LAYOUT_MASK(10, AV_CH_LAYOUT_5POINT1POINT4_BACK) +#define AV_CHANNEL_LAYOUT_7POINT1POINT2 AV_CHANNEL_LAYOUT_MASK(10, AV_CH_LAYOUT_7POINT1POINT2) +#define AV_CHANNEL_LAYOUT_7POINT1POINT4_BACK AV_CHANNEL_LAYOUT_MASK(12, AV_CH_LAYOUT_7POINT1POINT4_BACK) +#define AV_CHANNEL_LAYOUT_HEXADECAGONAL AV_CHANNEL_LAYOUT_MASK(16, AV_CH_LAYOUT_HEXADECAGONAL) +#define AV_CHANNEL_LAYOUT_STEREO_DOWNMIX AV_CHANNEL_LAYOUT_MASK(2, AV_CH_LAYOUT_STEREO_DOWNMIX) +#define AV_CHANNEL_LAYOUT_22POINT2 AV_CHANNEL_LAYOUT_MASK(24, AV_CH_LAYOUT_22POINT2) + +#define AV_CHANNEL_LAYOUT_7POINT1_TOP_BACK AV_CHANNEL_LAYOUT_5POINT1POINT2_BACK + +#define AV_CHANNEL_LAYOUT_AMBISONIC_FIRST_ORDER \ + { /* .order */ AV_CHANNEL_ORDER_AMBISONIC, \ + /* .nb_channels */ 4, \ + /* .u.mask */ { 0 }, \ + /* .opaque */ NULL } +/** @} */ + +struct AVBPrint; + +#if FF_API_OLD_CHANNEL_LAYOUT +/** + * @name Deprecated Functions + * @{ + */ + /** * Return a channel layout id that matches name, or 0 if no match is found. * @@ -144,7 +448,10 @@ enum AVMatrixEncoding { * AV_CH_* macros). * * Example: "stereo+FC" = "2c+FC" = "2c+1c" = "0x7" + * + * @deprecated use av_channel_layout_from_string() */ +attribute_deprecated uint64_t av_get_channel_layout(const char *name); /** @@ -158,7 +465,9 @@ uint64_t av_get_channel_layout(const char *name); * @param[out] nb_channels number of channels * * @return 0 on success, AVERROR(EINVAL) if the parsing fails. + * @deprecated use av_channel_layout_from_string() */ +attribute_deprecated int av_get_extended_channel_layout(const char *name, uint64_t* channel_layout, int* nb_channels); /** @@ -167,47 +476,66 @@ int av_get_extended_channel_layout(const char *name, uint64_t* channel_layout, i * * @param buf put here the string containing the channel layout * @param buf_size size in bytes of the buffer + * @param nb_channels number of channels + * @param channel_layout channel layout bitset + * @deprecated use av_channel_layout_describe() */ +attribute_deprecated void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, uint64_t channel_layout); -struct AVBPrint; /** * Append a description of a channel layout to a bprint buffer. + * @deprecated use av_channel_layout_describe() */ +attribute_deprecated void av_bprint_channel_layout(struct AVBPrint *bp, int nb_channels, uint64_t channel_layout); /** * Return the number of channels in the channel layout. + * @deprecated use AVChannelLayout.nb_channels */ +attribute_deprecated int av_get_channel_layout_nb_channels(uint64_t channel_layout); /** * Return default channel layout for a given number of channels. + * + * @deprecated use av_channel_layout_default() */ +attribute_deprecated int64_t av_get_default_channel_layout(int nb_channels); /** * Get the index of a channel in channel_layout. * + * @param channel_layout channel layout bitset * @param channel a channel layout describing exactly one channel which must be * present in channel_layout. * * @return index of channel in channel_layout on success, a negative AVERROR * on error. + * + * @deprecated use av_channel_layout_index_from_channel() */ +attribute_deprecated int av_get_channel_layout_channel_index(uint64_t channel_layout, uint64_t channel); /** * Get the channel with the given index in channel_layout. + * @deprecated use av_channel_layout_channel_from_index() */ +attribute_deprecated uint64_t av_channel_layout_extract_channel(uint64_t channel_layout, int index); /** * Get the name of a given channel. * * @return channel name on success, NULL on error. + * + * @deprecated use av_channel_name() */ +attribute_deprecated const char *av_get_channel_name(uint64_t channel); /** @@ -215,7 +543,9 @@ const char *av_get_channel_name(uint64_t channel); * * @param channel a channel layout with a single channel * @return channel description on success, NULL on error + * @deprecated use av_channel_description() */ +attribute_deprecated const char *av_get_channel_description(uint64_t channel); /** @@ -226,12 +556,251 @@ const char *av_get_channel_description(uint64_t channel); * @param[out] name name of the layout * @return 0 if the layout exists, * <0 if index is beyond the limits + * @deprecated use av_channel_layout_standard() */ +attribute_deprecated int av_get_standard_channel_layout(unsigned index, uint64_t *layout, const char **name); - /** * @} + */ +#endif + +/** + * Get a human readable string in an abbreviated form describing a given channel. + * This is the inverse function of @ref av_channel_from_string(). + * + * @param buf pre-allocated buffer where to put the generated string + * @param buf_size size in bytes of the buffer. + * @param channel the AVChannel whose name to get + * @return amount of bytes needed to hold the output string, or a negative AVERROR + * on failure. If the returned value is bigger than buf_size, then the + * string was truncated. + */ +int av_channel_name(char *buf, size_t buf_size, enum AVChannel channel); + +/** + * bprint variant of av_channel_name(). + * + * @note the string will be appended to the bprint buffer. + */ +void av_channel_name_bprint(struct AVBPrint *bp, enum AVChannel channel_id); + +/** + * Get a human readable string describing a given channel. + * + * @param buf pre-allocated buffer where to put the generated string + * @param buf_size size in bytes of the buffer. + * @param channel the AVChannel whose description to get + * @return amount of bytes needed to hold the output string, or a negative AVERROR + * on failure. If the returned value is bigger than buf_size, then the + * string was truncated. + */ +int av_channel_description(char *buf, size_t buf_size, enum AVChannel channel); + +/** + * bprint variant of av_channel_description(). + * + * @note the string will be appended to the bprint buffer. + */ +void av_channel_description_bprint(struct AVBPrint *bp, enum AVChannel channel_id); + +/** + * This is the inverse function of @ref av_channel_name(). + * + * @return the channel with the given name + * AV_CHAN_NONE when name does not identify a known channel + */ +enum AVChannel av_channel_from_string(const char *name); + +/** + * Initialize a native channel layout from a bitmask indicating which channels + * are present. + * + * @param channel_layout the layout structure to be initialized + * @param mask bitmask describing the channel layout + * + * @return 0 on success + * AVERROR(EINVAL) for invalid mask values + */ +int av_channel_layout_from_mask(AVChannelLayout *channel_layout, uint64_t mask); + +/** + * Initialize a channel layout from a given string description. + * The input string can be represented by: + * - the formal channel layout name (returned by av_channel_layout_describe()) + * - single or multiple channel names (returned by av_channel_name(), eg. "FL", + * or concatenated with "+", each optionally containing a custom name after + * a "@", eg. "FL@Left+FR@Right+LFE") + * - a decimal or hexadecimal value of a native channel layout (eg. "4" or "0x4") + * - the number of channels with default layout (eg. "4c") + * - the number of unordered channels (eg. "4C" or "4 channels") + * - the ambisonic order followed by optional non-diegetic channels (eg. + * "ambisonic 2+stereo") + * + * @param channel_layout input channel layout + * @param str string describing the channel layout + * @return 0 channel layout was detected, AVERROR_INVALIDATATA otherwise + */ +int av_channel_layout_from_string(AVChannelLayout *channel_layout, + const char *str); + +/** + * Get the default channel layout for a given number of channels. + * + * @param ch_layout the layout structure to be initialized + * @param nb_channels number of channels + */ +void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels); + +/** + * Iterate over all standard channel layouts. + * + * @param opaque a pointer where libavutil will store the iteration state. Must + * point to NULL to start the iteration. + * + * @return the standard channel layout or NULL when the iteration is + * finished + */ +const AVChannelLayout *av_channel_layout_standard(void **opaque); + +/** + * Free any allocated data in the channel layout and reset the channel + * count to 0. + * + * @param channel_layout the layout structure to be uninitialized + */ +void av_channel_layout_uninit(AVChannelLayout *channel_layout); + +/** + * Make a copy of a channel layout. This differs from just assigning src to dst + * in that it allocates and copies the map for AV_CHANNEL_ORDER_CUSTOM. + * + * @note the destination channel_layout will be always uninitialized before copy. + * + * @param dst destination channel layout + * @param src source channel layout + * @return 0 on success, a negative AVERROR on error. + */ +int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src); + +/** + * Get a human-readable string describing the channel layout properties. + * The string will be in the same format that is accepted by + * @ref av_channel_layout_from_string(), allowing to rebuild the same + * channel layout, except for opaque pointers. + * + * @param channel_layout channel layout to be described + * @param buf pre-allocated buffer where to put the generated string + * @param buf_size size in bytes of the buffer. + * @return amount of bytes needed to hold the output string, or a negative AVERROR + * on failure. If the returned value is bigger than buf_size, then the + * string was truncated. + */ +int av_channel_layout_describe(const AVChannelLayout *channel_layout, + char *buf, size_t buf_size); + +/** + * bprint variant of av_channel_layout_describe(). + * + * @note the string will be appended to the bprint buffer. + * @return 0 on success, or a negative AVERROR value on failure. + */ +int av_channel_layout_describe_bprint(const AVChannelLayout *channel_layout, + struct AVBPrint *bp); + +/** + * Get the channel with the given index in a channel layout. + * + * @param channel_layout input channel layout + * @param idx index of the channel + * @return channel with the index idx in channel_layout on success or + * AV_CHAN_NONE on failure (if idx is not valid or the channel order is + * unspecified) + */ +enum AVChannel +av_channel_layout_channel_from_index(const AVChannelLayout *channel_layout, unsigned int idx); + +/** + * Get the index of a given channel in a channel layout. In case multiple + * channels are found, only the first match will be returned. + * + * @param channel_layout input channel layout + * @param channel the channel whose index to obtain + * @return index of channel in channel_layout on success or a negative number if + * channel is not present in channel_layout. + */ +int av_channel_layout_index_from_channel(const AVChannelLayout *channel_layout, + enum AVChannel channel); + +/** + * Get the index in a channel layout of a channel described by the given string. + * In case multiple channels are found, only the first match will be returned. + * + * This function accepts channel names in the same format as + * @ref av_channel_from_string(). + * + * @param channel_layout input channel layout + * @param name string describing the channel whose index to obtain + * @return a channel index described by the given string, or a negative AVERROR + * value. + */ +int av_channel_layout_index_from_string(const AVChannelLayout *channel_layout, + const char *name); + +/** + * Get a channel described by the given string. + * + * This function accepts channel names in the same format as + * @ref av_channel_from_string(). + * + * @param channel_layout input channel layout + * @param name string describing the channel to obtain + * @return a channel described by the given string in channel_layout on success + * or AV_CHAN_NONE on failure (if the string is not valid or the channel + * order is unspecified) + */ +enum AVChannel +av_channel_layout_channel_from_string(const AVChannelLayout *channel_layout, + const char *name); + +/** + * Find out what channels from a given set are present in a channel layout, + * without regard for their positions. + * + * @param channel_layout input channel layout + * @param mask a combination of AV_CH_* representing a set of channels + * @return a bitfield representing all the channels from mask that are present + * in channel_layout + */ +uint64_t av_channel_layout_subset(const AVChannelLayout *channel_layout, + uint64_t mask); + +/** + * Check whether a channel layout is valid, i.e. can possibly describe audio + * data. + * + * @param channel_layout input channel layout + * @return 1 if channel_layout is valid, 0 otherwise. + */ +int av_channel_layout_check(const AVChannelLayout *channel_layout); + +/** + * Check whether two channel layouts are semantically the same, i.e. the same + * channels are present on the same positions in both. + * + * If one of the channel layouts is AV_CHANNEL_ORDER_UNSPEC, while the other is + * not, they are considered to be unequal. If both are AV_CHANNEL_ORDER_UNSPEC, + * they are considered equal iff the channel counts are the same in both. + * + * @param chl input channel layout + * @param chl1 input channel layout + * @return 0 if chl and chl1 are equal, 1 if they are not equal. A negative + * AVERROR code if one or both are invalid. + */ +int av_channel_layout_compare(const AVChannelLayout *chl, const AVChannelLayout *chl1); + +/** * @} */ diff --git a/library/FFmpeg/include/libavutil/common.h b/library/FFmpeg/include/libavutil/common.h index aee353d3..de2140a6 100644 --- a/library/FFmpeg/include/libavutil/common.h +++ b/library/FFmpeg/include/libavutil/common.h @@ -40,15 +40,8 @@ #include #include "attributes.h" +#include "error.h" #include "macros.h" -#include "version.h" -#include "libavutil/avconfig.h" - -#if AV_HAVE_BIGENDIAN -# define AV_NE(be, le) (be) -#else -# define AV_NE(be, le) (le) -#endif //rounded division & shift #define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b)) @@ -89,25 +82,6 @@ #define FFABSU(a) ((a) <= 0 ? -(unsigned)(a) : (unsigned)(a)) #define FFABS64U(a) ((a) <= 0 ? -(uint64_t)(a) : (uint64_t)(a)) -/** - * Comparator. - * For two numerical expressions x and y, gives 1 if x > y, -1 if x < y, and 0 - * if x == y. This is useful for instance in a qsort comparator callback. - * Furthermore, compilers are able to optimize this to branchless code, and - * there is no risk of overflow with signed types. - * As with many macros, this evaluates its argument multiple times, it thus - * must not have a side-effect. - */ -#define FFDIFFSIGN(x,y) (((x)>(y)) - ((x)<(y))) - -#define FFMAX(a,b) ((a) > (b) ? (a) : (b)) -#define FFMAX3(a,b,c) FFMAX(FFMAX(a,b),c) -#define FFMIN(a,b) ((a) > (b) ? (b) : (a)) -#define FFMIN3(a,b,c) FFMIN(FFMIN(a,b),c) - -#define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0) -#define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0])) - /* misc math functions */ #ifdef HAVE_AV_CONFIG_H @@ -405,6 +379,8 @@ static av_always_inline int64_t av_sat_sub64_c(int64_t a, int64_t b) { /** * Clip a float value into the amin-amax range. + * If a is nan or -inf amin will be returned. + * If a is +inf amax will be returned. * @param a value to clip * @param amin minimum value of the clip range * @param amax maximum value of the clip range @@ -415,13 +391,13 @@ static av_always_inline av_const float av_clipf_c(float a, float amin, float ama #if defined(HAVE_AV_CONFIG_H) && defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2 if (amin > amax) abort(); #endif - if (a < amin) return amin; - else if (a > amax) return amax; - else return a; + return FFMIN(FFMAX(a, amin), amax); } /** * Clip a double value into the amin-amax range. + * If a is nan or -inf amin will be returned. + * If a is +inf amax will be returned. * @param a value to clip * @param amin minimum value of the clip range * @param amax maximum value of the clip range @@ -432,9 +408,7 @@ static av_always_inline av_const double av_clipd_c(double a, double amin, double #if defined(HAVE_AV_CONFIG_H) && defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2 if (amin > amax) abort(); #endif - if (a < amin) return amin; - else if (a > amax) return amax; - else return a; + return FFMIN(FFMAX(a, amin), amax); } /** Compute ceil(log2(x)). @@ -475,9 +449,6 @@ static av_always_inline av_const int av_parity_c(uint32_t v) return av_popcount(v) & 1; } -#define MKTAG(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((unsigned)(d) << 24)) -#define MKBETAG(a,b,c,d) ((d) | ((c) << 8) | ((b) << 16) | ((unsigned)(a) << 24)) - /** * Convert a UTF-8 character (up to 4 bytes) to its 32-bit UCS-4 encoded form. * diff --git a/library/FFmpeg/include/libavutil/cpu.h b/library/FFmpeg/include/libavutil/cpu.h index afea0640..8dff3418 100644 --- a/library/FFmpeg/include/libavutil/cpu.h +++ b/library/FFmpeg/include/libavutil/cpu.h @@ -54,6 +54,8 @@ #define AV_CPU_FLAG_BMI1 0x20000 ///< Bit Manipulation Instruction Set 1 #define AV_CPU_FLAG_BMI2 0x40000 ///< Bit Manipulation Instruction Set 2 #define AV_CPU_FLAG_AVX512 0x100000 ///< AVX-512 functions: requires OS support even if YMM/ZMM registers aren't used +#define AV_CPU_FLAG_AVX512ICL 0x200000 ///< F/CD/BW/DQ/VL/VNNI/IFMA/VBMI/VBMI2/VPOPCNTDQ/BITALG/GFNI/VAES/VPCLMULQDQ +#define AV_CPU_FLAG_SLOW_GATHER 0x2000000 ///< CPU has slow gathers. #define AV_CPU_FLAG_ALTIVEC 0x0001 ///< standard #define AV_CPU_FLAG_VSX 0x0002 ///< ISA 2.06 @@ -67,11 +69,28 @@ #define AV_CPU_FLAG_NEON (1 << 5) #define AV_CPU_FLAG_ARMV8 (1 << 6) #define AV_CPU_FLAG_VFP_VM (1 << 7) ///< VFPv2 vector mode, deprecated in ARMv7-A and unavailable in various CPUs implementations +#define AV_CPU_FLAG_DOTPROD (1 << 8) +#define AV_CPU_FLAG_I8MM (1 << 9) #define AV_CPU_FLAG_SETEND (1 <<16) #define AV_CPU_FLAG_MMI (1 << 0) #define AV_CPU_FLAG_MSA (1 << 1) +//Loongarch SIMD extension. +#define AV_CPU_FLAG_LSX (1 << 0) +#define AV_CPU_FLAG_LASX (1 << 1) + +// RISC-V extensions +#define AV_CPU_FLAG_RVI (1 << 0) ///< I (full GPR bank) +#define AV_CPU_FLAG_RVF (1 << 1) ///< F (single precision FP) +#define AV_CPU_FLAG_RVD (1 << 2) ///< D (double precision FP) +#define AV_CPU_FLAG_RVV_I32 (1 << 3) ///< Vectors of 8/16/32-bit int's */ +#define AV_CPU_FLAG_RVV_F32 (1 << 4) ///< Vectors of float's */ +#define AV_CPU_FLAG_RVV_I64 (1 << 5) ///< Vectors of 64-bit int's */ +#define AV_CPU_FLAG_RVV_F64 (1 << 6) ///< Vectors of double's +#define AV_CPU_FLAG_RVB_BASIC (1 << 7) ///< Basic bit-manipulations +#define AV_CPU_FLAG_RVB_ADDR (1 << 8) ///< Address bit-manipulations + /** * Return the flags which specify extensions supported by the CPU. * The returned value is affected by av_force_cpu_flags() if that was used diff --git a/library/FFmpeg/include/libavutil/crc.h b/library/FFmpeg/include/libavutil/crc.h index 47e22b4c..7f59812a 100644 --- a/library/FFmpeg/include/libavutil/crc.h +++ b/library/FFmpeg/include/libavutil/crc.h @@ -30,7 +30,6 @@ #include #include #include "attributes.h" -#include "version.h" /** * @defgroup lavu_crc32 CRC @@ -85,7 +84,10 @@ const AVCRC *av_crc_get_table(AVCRCId crc_id); /** * Calculate the CRC of a block. + * @param ctx initialized AVCRC array (see av_crc_init()) * @param crc CRC of previous blocks if any or initial value for CRC + * @param buffer buffer whose CRC to calculate + * @param length length of the buffer * @return CRC updated with the data from the given block * * @see av_crc_init() "le" parameter diff --git a/library/FFmpeg/include/libavutil/csp.h b/library/FFmpeg/include/libavutil/csp.h new file mode 100644 index 00000000..73bce52b --- /dev/null +++ b/library/FFmpeg/include/libavutil/csp.h @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2015 Kevin Wheatley + * Copyright (c) 2016 Ronald S. Bultje + * Copyright (c) 2023 Leo Izen + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_CSP_H +#define AVUTIL_CSP_H + +#include "pixfmt.h" +#include "rational.h" + +/** + * @file + * Colorspace value utility functions for libavutil. + * @ingroup lavu_math_csp + * @author Ronald S. Bultje + * @author Leo Izen + * @author Kevin Wheatley + */ + +/** + * @defgroup lavu_math_csp Colorspace Utility + * @ingroup lavu_math + * @{ + */ + +/** + * Struct containing luma coefficients to be used for RGB to YUV/YCoCg, or similar + * calculations. + */ +typedef struct AVLumaCoefficients { + AVRational cr, cg, cb; +} AVLumaCoefficients; + +/** + * Struct containing chromaticity x and y values for the standard CIE 1931 + * chromaticity definition. + */ +typedef struct AVCIExy { + AVRational x, y; +} AVCIExy; + +/** + * Struct defining the red, green, and blue primary locations in terms of CIE + * 1931 chromaticity x and y. + */ +typedef struct AVPrimaryCoefficients { + AVCIExy r, g, b; +} AVPrimaryCoefficients; + +/** + * Struct defining white point location in terms of CIE 1931 chromaticity x + * and y. + */ +typedef AVCIExy AVWhitepointCoefficients; + +/** + * Struct that contains both white point location and primaries location, providing + * the complete description of a color gamut. + */ +typedef struct AVColorPrimariesDesc { + AVWhitepointCoefficients wp; + AVPrimaryCoefficients prim; +} AVColorPrimariesDesc; + +/** + * Function pointer representing a double -> double transfer function that performs + * an EOTF transfer inversion. This function outputs linear light. + */ +typedef double (*av_csp_trc_function)(double); + +/** + * Retrieves the Luma coefficients necessary to construct a conversion matrix + * from an enum constant describing the colorspace. + * @param csp An enum constant indicating YUV or similar colorspace. + * @return The Luma coefficients associated with that colorspace, or NULL + * if the constant is unknown to libavutil. + */ +const AVLumaCoefficients *av_csp_luma_coeffs_from_avcsp(enum AVColorSpace csp); + +/** + * Retrieves a complete gamut description from an enum constant describing the + * color primaries. + * @param prm An enum constant indicating primaries + * @return A description of the colorspace gamut associated with that enum + * constant, or NULL if the constant is unknown to libavutil. + */ +const AVColorPrimariesDesc *av_csp_primaries_desc_from_id(enum AVColorPrimaries prm); + +/** + * Detects which enum AVColorPrimaries constant corresponds to the given complete + * gamut description. + * @see enum AVColorPrimaries + * @param prm A description of the colorspace gamut + * @return The enum constant associated with this gamut, or + * AVCOL_PRI_UNSPECIFIED if no clear match can be idenitified. + */ +enum AVColorPrimaries av_csp_primaries_id_from_desc(const AVColorPrimariesDesc *prm); + +/** + * Determine a suitable 'gamma' value to match the supplied + * AVColorTransferCharacteristic. + * + * See Apple Technical Note TN2257 (https://developer.apple.com/library/mac/technotes/tn2257/_index.html) + * + * This function returns the gamma exponent for the OETF. For example, sRGB is approximated + * by gamma 2.2, not by gamma 0.45455. + * + * @return Will return an approximation to the simple gamma function matching + * the supplied Transfer Characteristic, Will return 0.0 for any + * we cannot reasonably match against. + */ +double av_csp_approximate_trc_gamma(enum AVColorTransferCharacteristic trc); + +/** + * Determine the function needed to apply the given + * AVColorTransferCharacteristic to linear input. + * + * The function returned should expect a nominal domain and range of [0.0-1.0] + * values outside of this range maybe valid depending on the chosen + * characteristic function. + * + * @return Will return pointer to the function matching the + * supplied Transfer Characteristic. If unspecified will + * return NULL: + */ +av_csp_trc_function av_csp_trc_func_from_id(enum AVColorTransferCharacteristic trc); + +/** + * @} + */ + +#endif /* AVUTIL_CSP_H */ diff --git a/library/FFmpeg/include/libavutil/des.h b/library/FFmpeg/include/libavutil/des.h index 4cf11f5b..3a3e6fa4 100644 --- a/library/FFmpeg/include/libavutil/des.h +++ b/library/FFmpeg/include/libavutil/des.h @@ -43,6 +43,8 @@ AVDES *av_des_alloc(void); /** * @brief Initializes an AVDES context. * + * @param d pointer to a AVDES structure to initialize + * @param key pointer to the key to use * @param key_bits must be 64 or 192 * @param decrypt 0 for encryption/CBC-MAC, 1 for decryption * @return zero on success, negative value otherwise @@ -52,9 +54,10 @@ int av_des_init(struct AVDES *d, const uint8_t *key, int key_bits, int decrypt); /** * @brief Encrypts / decrypts using the DES algorithm. * - * @param count number of 8 byte blocks + * @param d pointer to the AVDES structure * @param dst destination array, can be equal to src, must be 8-byte aligned * @param src source array, can be equal to dst, must be 8-byte aligned, may be NULL + * @param count number of 8 byte blocks * @param iv initialization vector for CBC mode, if NULL then ECB will be used, * must be 8-byte aligned * @param decrypt 0 for encryption, 1 for decryption @@ -64,9 +67,10 @@ void av_des_crypt(struct AVDES *d, uint8_t *dst, const uint8_t *src, int count, /** * @brief Calculates CBC-MAC using the DES algorithm. * - * @param count number of 8 byte blocks + * @param d pointer to the AVDES structure * @param dst destination array, can be equal to src, must be 8-byte aligned * @param src source array, can be equal to dst, must be 8-byte aligned, may be NULL + * @param count number of 8 byte blocks */ void av_des_mac(struct AVDES *d, uint8_t *dst, const uint8_t *src, int count); diff --git a/library/FFmpeg/include/libavutil/detection_bbox.h b/library/FFmpeg/include/libavutil/detection_bbox.h index c20c204a..01198805 100644 --- a/library/FFmpeg/include/libavutil/detection_bbox.h +++ b/library/FFmpeg/include/libavutil/detection_bbox.h @@ -93,6 +93,7 @@ av_get_detection_bbox(const AVDetectionBBoxHeader *header, unsigned int idx) * AVDetectionBBox, and initializes the variables. * Can be freed with a normal av_free() call. * + * @param nb_bboxes number of AVDetectionBBox structures to allocate * @param out_size if non-NULL, the size in bytes of the resulting data array is * written here. */ diff --git a/library/FFmpeg/include/libavutil/dict.h b/library/FFmpeg/include/libavutil/dict.h index 118f1f00..713c9e36 100644 --- a/library/FFmpeg/include/libavutil/dict.h +++ b/library/FFmpeg/include/libavutil/dict.h @@ -32,8 +32,6 @@ #include -#include "version.h" - /** * @addtogroup lavu_dict AVDictionary * @ingroup lavu_data @@ -41,13 +39,15 @@ * @brief Simple key:value store * * @{ - * Dictionaries are used for storing key:value pairs. To create - * an AVDictionary, simply pass an address of a NULL pointer to - * av_dict_set(). NULL can be used as an empty dictionary wherever - * a pointer to an AVDictionary is required. - * Use av_dict_get() to retrieve an entry or iterate over all - * entries and finally av_dict_free() to free the dictionary - * and all its contents. + * Dictionaries are used for storing key-value pairs. + * + * - To **create an AVDictionary**, simply pass an address of a NULL + * pointer to av_dict_set(). NULL can be used as an empty dictionary + * wherever a pointer to an AVDictionary is required. + * - To **insert an entry**, use av_dict_set(). + * - Use av_dict_get() to **retrieve an entry**. + * - To **iterate over all entries**, use av_dict_iterate(). + * - In order to **free the dictionary and all its contents**, use av_dict_free(). * @code AVDictionary *d = NULL; // "create" an empty dictionary @@ -59,13 +59,18 @@ char *v = av_strdup("value"); // you can avoid copying them like this av_dict_set(&d, k, v, AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL); - while (t = av_dict_get(d, "", t, AV_DICT_IGNORE_SUFFIX)) { - <....> // iterate over all entries in d + while ((t = av_dict_iterate(d, t))) { + <....> // iterate over all entries in d } av_dict_free(&d); @endcode */ +/** + * @name AVDictionary Flags + * Flags that influence behavior of the matching of keys or insertion to the dictionary. + * @{ + */ #define AV_DICT_MATCH_CASE 1 /**< Only get an entry with exact-case key match. Only relevant in av_dict_get(). */ #define AV_DICT_IGNORE_SUFFIX 2 /**< Return first entry in a dictionary whose first part corresponds to the search key, ignoring the suffix of the found key string. Only relevant in av_dict_get(). */ @@ -73,10 +78,13 @@ allocated with av_malloc() or another memory allocation function. */ #define AV_DICT_DONT_STRDUP_VAL 8 /**< Take ownership of a value that's been allocated with av_malloc() or another memory allocation function. */ -#define AV_DICT_DONT_OVERWRITE 16 ///< Don't overwrite existing entries. +#define AV_DICT_DONT_OVERWRITE 16 /**< Don't overwrite existing entries. */ #define AV_DICT_APPEND 32 /**< If the entry already exists, append to it. Note that no - delimiter is added, the strings are simply concatenated. */ + delimiter is added, the strings are simply concatenated. */ #define AV_DICT_MULTIKEY 64 /**< Allow to store several equal keys in the dictionary */ +/** + * @} + */ typedef struct AVDictionaryEntry { char *key; @@ -91,18 +99,44 @@ typedef struct AVDictionary AVDictionary; * The returned entry key or value must not be changed, or it will * cause undefined behavior. * - * To iterate through all the dictionary entries, you can set the matching key - * to the null string "" and set the AV_DICT_IGNORE_SUFFIX flag. + * @param prev Set to the previous matching element to find the next. + * If set to NULL the first matching element is returned. + * @param key Matching key + * @param flags A collection of AV_DICT_* flags controlling how the + * entry is retrieved * - * @param prev Set to the previous matching element to find the next. - * If set to NULL the first matching element is returned. - * @param key matching key - * @param flags a collection of AV_DICT_* flags controlling how the entry is retrieved - * @return found entry or NULL in case no matching entry was found in the dictionary + * @return Found entry or NULL in case no matching entry was found in the dictionary */ AVDictionaryEntry *av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags); +/** + * Iterate over a dictionary + * + * Iterates through all entries in the dictionary. + * + * @warning The returned AVDictionaryEntry key/value must not be changed. + * + * @warning As av_dict_set() invalidates all previous entries returned + * by this function, it must not be called while iterating over the dict. + * + * Typical usage: + * @code + * const AVDictionaryEntry *e = NULL; + * while ((e = av_dict_iterate(m, e))) { + * // ... + * } + * @endcode + * + * @param m The dictionary to iterate over + * @param prev Pointer to the previous AVDictionaryEntry, NULL initially + * + * @retval AVDictionaryEntry* The next element in the dictionary + * @retval NULL No more elements in the dictionary + */ +const AVDictionaryEntry *av_dict_iterate(const AVDictionary *m, + const AVDictionaryEntry *prev); + /** * Get number of entries in dictionary. * @@ -117,23 +151,24 @@ int av_dict_count(const AVDictionary *m); * Note: If AV_DICT_DONT_STRDUP_KEY or AV_DICT_DONT_STRDUP_VAL is set, * these arguments will be freed on error. * - * Warning: Adding a new entry to a dictionary invalidates all existing entries - * previously returned with av_dict_get. + * @warning Adding a new entry to a dictionary invalidates all existing entries + * previously returned with av_dict_get() or av_dict_iterate(). * - * @param pm pointer to a pointer to a dictionary struct. If *pm is NULL - * a dictionary struct is allocated and put in *pm. - * @param key entry key to add to *pm (will either be av_strduped or added as a new key depending on flags) - * @param value entry value to add to *pm (will be av_strduped or added as a new key depending on flags). - * Passing a NULL value will cause an existing entry to be deleted. - * @return >= 0 on success otherwise an error code <0 + * @param pm Pointer to a pointer to a dictionary struct. If *pm is NULL + * a dictionary struct is allocated and put in *pm. + * @param key Entry key to add to *pm (will either be av_strduped or added as a new key depending on flags) + * @param value Entry value to add to *pm (will be av_strduped or added as a new key depending on flags). + * Passing a NULL value will cause an existing entry to be deleted. + * + * @return >= 0 on success otherwise an error code <0 */ int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags); /** - * Convenience wrapper for av_dict_set that converts the value to a string + * Convenience wrapper for av_dict_set() that converts the value to a string * and stores it. * - * Note: If AV_DICT_DONT_STRDUP_KEY is set, key will be freed on error. + * Note: If ::AV_DICT_DONT_STRDUP_KEY is set, key will be freed on error. */ int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int flags); @@ -143,14 +178,15 @@ int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int flags * In case of failure, all the successfully set entries are stored in * *pm. You may need to manually free the created dictionary. * - * @param key_val_sep a 0-terminated list of characters used to separate + * @param key_val_sep A 0-terminated list of characters used to separate * key from value - * @param pairs_sep a 0-terminated list of characters used to separate + * @param pairs_sep A 0-terminated list of characters used to separate * two pairs from each other - * @param flags flags to use when adding to dictionary. - * AV_DICT_DONT_STRDUP_KEY and AV_DICT_DONT_STRDUP_VAL + * @param flags Flags to use when adding to the dictionary. + * ::AV_DICT_DONT_STRDUP_KEY and ::AV_DICT_DONT_STRDUP_VAL * are ignored since the key/value tokens will always * be duplicated. + * * @return 0 on success, negative AVERROR code on failure */ int av_dict_parse_string(AVDictionary **pm, const char *str, @@ -159,11 +195,14 @@ int av_dict_parse_string(AVDictionary **pm, const char *str, /** * Copy entries from one AVDictionary struct into another. - * @param dst pointer to a pointer to a AVDictionary struct. If *dst is NULL, - * this function will allocate a struct for you and put it in *dst - * @param src pointer to source AVDictionary struct - * @param flags flags to use when setting entries in *dst - * @note metadata is read using the AV_DICT_IGNORE_SUFFIX flag + * + * @note Metadata is read using the ::AV_DICT_IGNORE_SUFFIX flag + * + * @param dst Pointer to a pointer to a AVDictionary struct to copy into. If *dst is NULL, + * this function will allocate a struct for you and put it in *dst + * @param src Pointer to the source AVDictionary struct to copy items from. + * @param flags Flags to use when setting entries in *dst + * * @return 0 on success, negative AVERROR code on failure. If dst was allocated * by this function, callers should free the associated memory. */ @@ -182,13 +221,15 @@ void av_dict_free(AVDictionary **m); * Such string may be passed back to av_dict_parse_string(). * @note String is escaped with backslashes ('\'). * - * @param[in] m dictionary + * @warning Separators cannot be neither '\\' nor '\0'. They also cannot be the same. + * + * @param[in] m The dictionary * @param[out] buffer Pointer to buffer that will be allocated with string containg entries. * Buffer must be freed by the caller when is no longer needed. - * @param[in] key_val_sep character used to separate key from value - * @param[in] pairs_sep character used to separate two pairs from each other + * @param[in] key_val_sep Character used to separate key from value + * @param[in] pairs_sep Character used to separate two pairs from each other + * * @return >= 0 on success, negative on error - * @warning Separators cannot be neither '\\' nor '\0'. They also cannot be the same. */ int av_dict_get_string(const AVDictionary *m, char **buffer, const char key_val_sep, const char pairs_sep); diff --git a/library/FFmpeg/include/libavutil/display.h b/library/FFmpeg/include/libavutil/display.h index 515adad7..50f2b44c 100644 --- a/library/FFmpeg/include/libavutil/display.h +++ b/library/FFmpeg/include/libavutil/display.h @@ -20,6 +20,7 @@ /** * @file + * @ingroup lavu_video_display * Display matrix */ @@ -27,18 +28,11 @@ #define AVUTIL_DISPLAY_H #include -#include "common.h" /** - * @addtogroup lavu_video - * @{ - * * @defgroup lavu_video_display Display transformation matrix functions - * @{ - */ - -/** - * @addtogroup lavu_video_display + * @ingroup lavu_video + * * The display transformation matrix specifies an affine transformation that * should be applied to video frames for correct presentation. It is compatible * with the matrices stored in the ISO/IEC 14496-12 container format. @@ -72,6 +66,8 @@ * q' = (b * p + d * q + y) / z; * z = u * p + v * q + w * @endcode + * + * @{ */ /** @@ -88,11 +84,11 @@ double av_display_rotation_get(const int32_t matrix[9]); /** - * Initialize a transformation matrix describing a pure counterclockwise + * Initialize a transformation matrix describing a pure clockwise * rotation by the specified angle (in degrees). * - * @param matrix an allocated transformation matrix (will be fully overwritten - * by this function) + * @param[out] matrix a transformation matrix (will be fully overwritten + * by this function) * @param angle rotation angle in degrees. */ void av_display_rotation_set(int32_t matrix[9], double angle); @@ -100,14 +96,13 @@ void av_display_rotation_set(int32_t matrix[9], double angle); /** * Flip the input matrix horizontally and/or vertically. * - * @param matrix an allocated transformation matrix + * @param[in,out] matrix a transformation matrix * @param hflip whether the matrix should be flipped horizontally * @param vflip whether the matrix should be flipped vertically */ void av_display_matrix_flip(int32_t matrix[9], int hflip, int vflip); /** - * @} * @} */ diff --git a/library/FFmpeg/include/libavutil/dovi_meta.h b/library/FFmpeg/include/libavutil/dovi_meta.h index 299911d4..3d11e02b 100644 --- a/library/FFmpeg/include/libavutil/dovi_meta.h +++ b/library/FFmpeg/include/libavutil/dovi_meta.h @@ -29,6 +29,7 @@ #include #include +#include "rational.h" /* * DOVI configuration @@ -67,4 +68,169 @@ typedef struct AVDOVIDecoderConfigurationRecord { */ AVDOVIDecoderConfigurationRecord *av_dovi_alloc(size_t *size); +/** + * Dolby Vision RPU data header. + * + * @note sizeof(AVDOVIRpuDataHeader) is not part of the public ABI. + */ +typedef struct AVDOVIRpuDataHeader { + uint8_t rpu_type; + uint16_t rpu_format; + uint8_t vdr_rpu_profile; + uint8_t vdr_rpu_level; + uint8_t chroma_resampling_explicit_filter_flag; + uint8_t coef_data_type; /* informative, lavc always converts to fixed */ + uint8_t coef_log2_denom; + uint8_t vdr_rpu_normalized_idc; + uint8_t bl_video_full_range_flag; + uint8_t bl_bit_depth; /* [8, 16] */ + uint8_t el_bit_depth; /* [8, 16] */ + uint8_t vdr_bit_depth; /* [8, 16] */ + uint8_t spatial_resampling_filter_flag; + uint8_t el_spatial_resampling_filter_flag; + uint8_t disable_residual_flag; +} AVDOVIRpuDataHeader; + +enum AVDOVIMappingMethod { + AV_DOVI_MAPPING_POLYNOMIAL = 0, + AV_DOVI_MAPPING_MMR = 1, +}; + +/** + * Coefficients of a piece-wise function. The pieces of the function span the + * value ranges between two adjacent pivot values. + */ +#define AV_DOVI_MAX_PIECES 8 +typedef struct AVDOVIReshapingCurve { + uint8_t num_pivots; /* [2, 9] */ + uint16_t pivots[AV_DOVI_MAX_PIECES + 1]; /* sorted ascending */ + enum AVDOVIMappingMethod mapping_idc[AV_DOVI_MAX_PIECES]; + /* AV_DOVI_MAPPING_POLYNOMIAL */ + uint8_t poly_order[AV_DOVI_MAX_PIECES]; /* [1, 2] */ + int64_t poly_coef[AV_DOVI_MAX_PIECES][3]; /* x^0, x^1, x^2 */ + /* AV_DOVI_MAPPING_MMR */ + uint8_t mmr_order[AV_DOVI_MAX_PIECES]; /* [1, 3] */ + int64_t mmr_constant[AV_DOVI_MAX_PIECES]; + int64_t mmr_coef[AV_DOVI_MAX_PIECES][3/* order - 1 */][7]; +} AVDOVIReshapingCurve; + +enum AVDOVINLQMethod { + AV_DOVI_NLQ_NONE = -1, + AV_DOVI_NLQ_LINEAR_DZ = 0, +}; + +/** + * Coefficients of the non-linear inverse quantization. For the interpretation + * of these, see ETSI GS CCM 001. + */ +typedef struct AVDOVINLQParams { + uint16_t nlq_offset; + uint64_t vdr_in_max; + /* AV_DOVI_NLQ_LINEAR_DZ */ + uint64_t linear_deadzone_slope; + uint64_t linear_deadzone_threshold; +} AVDOVINLQParams; + +/** + * Dolby Vision RPU data mapping parameters. + * + * @note sizeof(AVDOVIDataMapping) is not part of the public ABI. + */ +typedef struct AVDOVIDataMapping { + uint8_t vdr_rpu_id; + uint8_t mapping_color_space; + uint8_t mapping_chroma_format_idc; + AVDOVIReshapingCurve curves[3]; /* per component */ + + /* Non-linear inverse quantization */ + enum AVDOVINLQMethod nlq_method_idc; + uint32_t num_x_partitions; + uint32_t num_y_partitions; + AVDOVINLQParams nlq[3]; /* per component */ +} AVDOVIDataMapping; + +/** + * Dolby Vision RPU colorspace metadata parameters. + * + * @note sizeof(AVDOVIColorMetadata) is not part of the public ABI. + */ +typedef struct AVDOVIColorMetadata { + uint8_t dm_metadata_id; + uint8_t scene_refresh_flag; + + /** + * Coefficients of the custom Dolby Vision IPT-PQ matrices. These are to be + * used instead of the matrices indicated by the frame's colorspace tags. + * The output of rgb_to_lms_matrix is to be fed into a BT.2020 LMS->RGB + * matrix based on a Hunt-Pointer-Estevez transform, but without any + * crosstalk. (See the definition of the ICtCp colorspace for more + * information.) + */ + AVRational ycc_to_rgb_matrix[9]; /* before PQ linearization */ + AVRational ycc_to_rgb_offset[3]; /* input offset of neutral value */ + AVRational rgb_to_lms_matrix[9]; /* after PQ linearization */ + + /** + * Extra signal metadata (see Dolby patents for more info). + */ + uint16_t signal_eotf; + uint16_t signal_eotf_param0; + uint16_t signal_eotf_param1; + uint32_t signal_eotf_param2; + uint8_t signal_bit_depth; + uint8_t signal_color_space; + uint8_t signal_chroma_format; + uint8_t signal_full_range_flag; /* [0, 3] */ + uint16_t source_min_pq; + uint16_t source_max_pq; + uint16_t source_diagonal; +} AVDOVIColorMetadata; + +/** + * Combined struct representing a combination of header, mapping and color + * metadata, for attaching to frames as side data. + * + * @note The struct must be allocated with av_dovi_metadata_alloc() and + * its size is not a part of the public ABI. + */ + +typedef struct AVDOVIMetadata { + /** + * Offset in bytes from the beginning of this structure at which the + * respective structs start. + */ + size_t header_offset; /* AVDOVIRpuDataHeader */ + size_t mapping_offset; /* AVDOVIDataMapping */ + size_t color_offset; /* AVDOVIColorMetadata */ +} AVDOVIMetadata; + +static av_always_inline AVDOVIRpuDataHeader * +av_dovi_get_header(const AVDOVIMetadata *data) +{ + return (AVDOVIRpuDataHeader *)((uint8_t *) data + data->header_offset); +} + +static av_always_inline AVDOVIDataMapping * +av_dovi_get_mapping(const AVDOVIMetadata *data) +{ + return (AVDOVIDataMapping *)((uint8_t *) data + data->mapping_offset); +} + +static av_always_inline AVDOVIColorMetadata * +av_dovi_get_color(const AVDOVIMetadata *data) +{ + return (AVDOVIColorMetadata *)((uint8_t *) data + data->color_offset); +} + +/** + * Allocate an AVDOVIMetadata structure and initialize its + * fields to default values. + * + * @param size If this parameter is non-NULL, the size in bytes of the + * allocated struct will be written here on success + * + * @return the newly allocated struct or NULL on failure + */ +AVDOVIMetadata *av_dovi_metadata_alloc(size_t *size); + #endif /* AVUTIL_DOVI_META_H */ diff --git a/library/FFmpeg/include/libavutil/error.h b/library/FFmpeg/include/libavutil/error.h index 71df4da3..0d3269aa 100644 --- a/library/FFmpeg/include/libavutil/error.h +++ b/library/FFmpeg/include/libavutil/error.h @@ -27,6 +27,8 @@ #include #include +#include "macros.h" + /** * @addtogroup lavu_error * diff --git a/library/FFmpeg/include/libavutil/eval.h b/library/FFmpeg/include/libavutil/eval.h index 068c62cd..ee8cffb0 100644 --- a/library/FFmpeg/include/libavutil/eval.h +++ b/library/FFmpeg/include/libavutil/eval.h @@ -26,8 +26,6 @@ #ifndef AVUTIL_EVAL_H #define AVUTIL_EVAL_H -#include "avutil.h" - typedef struct AVExpr AVExpr; /** @@ -44,6 +42,7 @@ typedef struct AVExpr AVExpr; * @param func2_names NULL terminated array of zero terminated strings of funcs2 identifiers * @param funcs2 NULL terminated array of function pointers for functions which take 2 arguments * @param opaque a pointer which will be passed to all functions from funcs1 and funcs2 + * @param log_offset log level offset, can be used to silence error messages * @param log_ctx parent logging context * @return >= 0 in case of success, a negative value corresponding to an * AVERROR code otherwise @@ -67,6 +66,7 @@ int av_expr_parse_and_eval(double *res, const char *s, * @param funcs1 NULL terminated array of function pointers for functions which take 1 argument * @param func2_names NULL terminated array of zero terminated strings of funcs2 identifiers * @param funcs2 NULL terminated array of function pointers for functions which take 2 arguments + * @param log_offset log level offset, can be used to silence error messages * @param log_ctx parent logging context * @return >= 0 in case of success, a negative value corresponding to an * AVERROR code otherwise @@ -80,6 +80,7 @@ int av_expr_parse(AVExpr **expr, const char *s, /** * Evaluate a previously parsed expression. * + * @param e the AVExpr to evaluate * @param const_values a zero terminated array of values for the identifiers from av_expr_parse() const_names * @param opaque a pointer which will be passed to all functions from funcs1 and funcs2 * @return the value of the expression @@ -89,6 +90,7 @@ double av_expr_eval(AVExpr *e, const double *const_values, void *opaque); /** * Track the presence of variables and their number of occurrences in a parsed expression * + * @param e the AVExpr to track variables in * @param counter a zero-initialized array where the count of each variable will be stored * @param size size of array * @return 0 on success, a negative value indicates that no expression or array was passed @@ -100,6 +102,7 @@ int av_expr_count_vars(AVExpr *e, unsigned *counter, int size); * Track the presence of user provided functions and their number of occurrences * in a parsed expression. * + * @param e the AVExpr to track user provided functions in * @param counter a zero-initialized array where the count of each function will be stored * if you passed 5 functions with 2 arguments to av_expr_parse() * then for arg=2 this will use upto 5 entries. diff --git a/library/FFmpeg/include/libavutil/executor.h b/library/FFmpeg/include/libavutil/executor.h new file mode 100644 index 00000000..c602bcb6 --- /dev/null +++ b/library/FFmpeg/include/libavutil/executor.h @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2023 Nuo Mi + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_EXECUTOR_H +#define AVUTIL_EXECUTOR_H + +typedef struct AVExecutor AVExecutor; +typedef struct AVTask AVTask; + +struct AVTask { + AVTask *next; +}; + +typedef struct AVTaskCallbacks { + void *user_data; + + int local_context_size; + + // return 1 if a's priority > b's priority + int (*priority_higher)(const AVTask *a, const AVTask *b); + + // task is ready for run + int (*ready)(const AVTask *t, void *user_data); + + // run the task + int (*run)(AVTask *t, void *local_context, void *user_data); +} AVTaskCallbacks; + +/** + * Alloc executor + * @param callbacks callback structure for executor + * @param thread_count worker thread number + * @return return the executor + */ +AVExecutor* av_executor_alloc(const AVTaskCallbacks *callbacks, int thread_count); + +/** + * Free executor + * @param e pointer to executor + */ +void av_executor_free(AVExecutor **e); + +/** + * Add task to executor + * @param e pointer to executor + * @param t pointer to task. If NULL, it will wakeup one work thread + */ +void av_executor_execute(AVExecutor *e, AVTask *t); + +#endif //AVUTIL_EXECUTOR_H diff --git a/library/FFmpeg/include/libavutil/ffversion.h b/library/FFmpeg/include/libavutil/ffversion.h index 273f80ef..77feb7fb 100644 --- a/library/FFmpeg/include/libavutil/ffversion.h +++ b/library/FFmpeg/include/libavutil/ffversion.h @@ -1,5 +1,5 @@ /* Automatically generated by version.sh, do not manually edit! */ #ifndef AVUTIL_FFVERSION_H #define AVUTIL_FFVERSION_H -#define FFMPEG_VERSION "N-103028-ga594675f73" +#define FFMPEG_VERSION "N-112661-g125da06c6a" #endif /* AVUTIL_FFVERSION_H */ diff --git a/library/FFmpeg/include/libavutil/fifo.h b/library/FFmpeg/include/libavutil/fifo.h index dc7bc6f0..ce3a2aed 100644 --- a/library/FFmpeg/include/libavutil/fifo.h +++ b/library/FFmpeg/include/libavutil/fifo.h @@ -18,16 +18,229 @@ /** * @file - * a very simple circular buffer FIFO implementation + * @ingroup lavu_fifo + * A generic FIFO API */ #ifndef AVUTIL_FIFO_H #define AVUTIL_FIFO_H +#include #include -#include "avutil.h" + #include "attributes.h" +#include "version.h" + +/** + * @defgroup lavu_fifo AVFifo + * @ingroup lavu_data + * + * @{ + * A generic FIFO API + */ + +typedef struct AVFifo AVFifo; + +/** + * Callback for writing or reading from a FIFO, passed to (and invoked from) the + * av_fifo_*_cb() functions. It may be invoked multiple times from a single + * av_fifo_*_cb() call and may process less data than the maximum size indicated + * by nb_elems. + * + * @param opaque the opaque pointer provided to the av_fifo_*_cb() function + * @param buf the buffer for reading or writing the data, depending on which + * av_fifo_*_cb function is called + * @param nb_elems On entry contains the maximum number of elements that can be + * read from / written into buf. On success, the callback should + * update it to contain the number of elements actually written. + * + * @return 0 on success, a negative error code on failure (will be returned from + * the invoking av_fifo_*_cb() function) + */ +typedef int AVFifoCB(void *opaque, void *buf, size_t *nb_elems); + +/** + * Automatically resize the FIFO on writes, so that the data fits. This + * automatic resizing happens up to a limit that can be modified with + * av_fifo_auto_grow_limit(). + */ +#define AV_FIFO_FLAG_AUTO_GROW (1 << 0) + +/** + * Allocate and initialize an AVFifo with a given element size. + * + * @param elems initial number of elements that can be stored in the FIFO + * @param elem_size Size in bytes of a single element. Further operations on + * the returned FIFO will implicitly use this element size. + * @param flags a combination of AV_FIFO_FLAG_* + * + * @return newly-allocated AVFifo on success, a negative error code on failure + */ +AVFifo *av_fifo_alloc2(size_t elems, size_t elem_size, + unsigned int flags); + +/** + * @return Element size for FIFO operations. This element size is set at + * FIFO allocation and remains constant during its lifetime + */ +size_t av_fifo_elem_size(const AVFifo *f); + +/** + * Set the maximum size (in elements) to which the FIFO can be resized + * automatically. Has no effect unless AV_FIFO_FLAG_AUTO_GROW is used. + */ +void av_fifo_auto_grow_limit(AVFifo *f, size_t max_elems); + +/** + * @return number of elements available for reading from the given FIFO. + */ +size_t av_fifo_can_read(const AVFifo *f); + +/** + * @return Number of elements that can be written into the given FIFO without + * growing it. + * + * In other words, this number of elements or less is guaranteed to fit + * into the FIFO. More data may be written when the + * AV_FIFO_FLAG_AUTO_GROW flag was specified at FIFO creation, but this + * may involve memory allocation, which can fail. + */ +size_t av_fifo_can_write(const AVFifo *f); + +/** + * Enlarge an AVFifo. + * + * On success, the FIFO will be large enough to hold exactly + * inc + av_fifo_can_read() + av_fifo_can_write() + * elements. In case of failure, the old FIFO is kept unchanged. + * + * @param f AVFifo to resize + * @param inc number of elements to allocate for, in addition to the current + * allocated size + * @return a non-negative number on success, a negative error code on failure + */ +int av_fifo_grow2(AVFifo *f, size_t inc); + +/** + * Write data into a FIFO. + * + * In case nb_elems > av_fifo_can_write(f) and the AV_FIFO_FLAG_AUTO_GROW flag + * was not specified at FIFO creation, nothing is written and an error + * is returned. + * + * Calling function is guaranteed to succeed if nb_elems <= av_fifo_can_write(f). + * + * @param f the FIFO buffer + * @param buf Data to be written. nb_elems * av_fifo_elem_size(f) bytes will be + * read from buf on success. + * @param nb_elems number of elements to write into FIFO + * + * @return a non-negative number on success, a negative error code on failure + */ +int av_fifo_write(AVFifo *f, const void *buf, size_t nb_elems); + +/** + * Write data from a user-provided callback into a FIFO. + * + * @param f the FIFO buffer + * @param read_cb Callback supplying the data to the FIFO. May be called + * multiple times. + * @param opaque opaque user data to be provided to read_cb + * @param nb_elems Should point to the maximum number of elements that can be + * written. Will be updated to contain the number of elements + * actually written. + * + * @return non-negative number on success, a negative error code on failure + */ +int av_fifo_write_from_cb(AVFifo *f, AVFifoCB read_cb, + void *opaque, size_t *nb_elems); + +/** + * Read data from a FIFO. + * + * In case nb_elems > av_fifo_can_read(f), nothing is read and an error + * is returned. + * + * @param f the FIFO buffer + * @param buf Buffer to store the data. nb_elems * av_fifo_elem_size(f) bytes + * will be written into buf on success. + * @param nb_elems number of elements to read from FIFO + * + * @return a non-negative number on success, a negative error code on failure + */ +int av_fifo_read(AVFifo *f, void *buf, size_t nb_elems); + +/** + * Feed data from a FIFO into a user-provided callback. + * + * @param f the FIFO buffer + * @param write_cb Callback the data will be supplied to. May be called + * multiple times. + * @param opaque opaque user data to be provided to write_cb + * @param nb_elems Should point to the maximum number of elements that can be + * read. Will be updated to contain the total number of elements + * actually sent to the callback. + * + * @return non-negative number on success, a negative error code on failure + */ +int av_fifo_read_to_cb(AVFifo *f, AVFifoCB write_cb, + void *opaque, size_t *nb_elems); + +/** + * Read data from a FIFO without modifying FIFO state. + * + * Returns an error if an attempt is made to peek to nonexistent elements + * (i.e. if offset + nb_elems is larger than av_fifo_can_read(f)). + * + * @param f the FIFO buffer + * @param buf Buffer to store the data. nb_elems * av_fifo_elem_size(f) bytes + * will be written into buf. + * @param nb_elems number of elements to read from FIFO + * @param offset number of initial elements to skip. + * + * @return a non-negative number on success, a negative error code on failure + */ +int av_fifo_peek(const AVFifo *f, void *buf, size_t nb_elems, size_t offset); + +/** + * Feed data from a FIFO into a user-provided callback. + * + * @param f the FIFO buffer + * @param write_cb Callback the data will be supplied to. May be called + * multiple times. + * @param opaque opaque user data to be provided to write_cb + * @param nb_elems Should point to the maximum number of elements that can be + * read. Will be updated to contain the total number of elements + * actually sent to the callback. + * @param offset number of initial elements to skip; offset + *nb_elems must not + * be larger than av_fifo_can_read(f). + * + * @return a non-negative number on success, a negative error code on failure + */ +int av_fifo_peek_to_cb(const AVFifo *f, AVFifoCB write_cb, void *opaque, + size_t *nb_elems, size_t offset); +/** + * Discard the specified amount of data from an AVFifo. + * @param size number of elements to discard, MUST NOT be larger than + * av_fifo_can_read(f) + */ +void av_fifo_drain2(AVFifo *f, size_t size); + +/* + * Empty the AVFifo. + * @param f AVFifo to reset + */ +void av_fifo_reset2(AVFifo *f); + +/** + * Free an AVFifo and reset pointer to NULL. + * @param f Pointer to an AVFifo to free. *f == NULL is allowed. + */ +void av_fifo_freep2(AVFifo **f); + + +#if FF_API_FIFO_OLD_API typedef struct AVFifoBuffer { uint8_t *buffer; uint8_t *rptr, *wptr, *end; @@ -38,7 +251,9 @@ typedef struct AVFifoBuffer { * Initialize an AVFifoBuffer. * @param size of FIFO * @return AVFifoBuffer or NULL in case of memory allocation failure + * @deprecated use av_fifo_alloc2() */ +attribute_deprecated AVFifoBuffer *av_fifo_alloc(unsigned int size); /** @@ -46,25 +261,33 @@ AVFifoBuffer *av_fifo_alloc(unsigned int size); * @param nmemb number of elements * @param size size of the single element * @return AVFifoBuffer or NULL in case of memory allocation failure + * @deprecated use av_fifo_alloc2() */ +attribute_deprecated AVFifoBuffer *av_fifo_alloc_array(size_t nmemb, size_t size); /** * Free an AVFifoBuffer. * @param f AVFifoBuffer to free + * @deprecated use the AVFifo API with av_fifo_freep2() */ +attribute_deprecated void av_fifo_free(AVFifoBuffer *f); /** * Free an AVFifoBuffer and reset pointer to NULL. * @param f AVFifoBuffer to free + * @deprecated use the AVFifo API with av_fifo_freep2() */ +attribute_deprecated void av_fifo_freep(AVFifoBuffer **f); /** * Reset the AVFifoBuffer to the state right after av_fifo_alloc, in particular it is emptied. * @param f AVFifoBuffer to reset + * @deprecated use av_fifo_reset2() with the new AVFifo-API */ +attribute_deprecated void av_fifo_reset(AVFifoBuffer *f); /** @@ -72,7 +295,9 @@ void av_fifo_reset(AVFifoBuffer *f); * amount of data you can read from it. * @param f AVFifoBuffer to read from * @return size + * @deprecated use av_fifo_can_read() with the new AVFifo-API */ +attribute_deprecated int av_fifo_size(const AVFifoBuffer *f); /** @@ -80,7 +305,9 @@ int av_fifo_size(const AVFifoBuffer *f); * amount of data you can write into it. * @param f AVFifoBuffer to write into * @return size + * @deprecated use av_fifo_can_write() with the new AVFifo-API */ +attribute_deprecated int av_fifo_space(const AVFifoBuffer *f); /** @@ -91,7 +318,13 @@ int av_fifo_space(const AVFifoBuffer *f); * @param buf_size number of bytes to read * @param func generic read function * @param dest data destination + * + * @return a non-negative number on success, a negative error code on failure + * + * @deprecated use the new AVFifo-API with av_fifo_peek() when func == NULL, + * av_fifo_peek_to_cb() otherwise */ +attribute_deprecated int av_fifo_generic_peek_at(AVFifoBuffer *f, void *dest, int offset, int buf_size, void (*func)(void*, void*, int)); /** @@ -101,7 +334,13 @@ int av_fifo_generic_peek_at(AVFifoBuffer *f, void *dest, int offset, int buf_siz * @param buf_size number of bytes to read * @param func generic read function * @param dest data destination + * + * @return a non-negative number on success, a negative error code on failure + * + * @deprecated use the new AVFifo-API with av_fifo_peek() when func == NULL, + * av_fifo_peek_to_cb() otherwise */ +attribute_deprecated int av_fifo_generic_peek(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void*, void*, int)); /** @@ -110,7 +349,13 @@ int av_fifo_generic_peek(AVFifoBuffer *f, void *dest, int buf_size, void (*func) * @param buf_size number of bytes to read * @param func generic read function * @param dest data destination + * + * @return a non-negative number on success, a negative error code on failure + * + * @deprecated use the new AVFifo-API with av_fifo_read() when func == NULL, + * av_fifo_read_to_cb() otherwise */ +attribute_deprecated int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void*, void*, int)); /** @@ -124,8 +369,12 @@ int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void (*func) * func must return the number of bytes written to dest_buf, or <= 0 to * indicate no more data available to write. * If func is NULL, src is interpreted as a simple byte array for source data. - * @return the number of bytes written to the FIFO + * @return the number of bytes written to the FIFO or a negative error code on failure + * + * @deprecated use the new AVFifo-API with av_fifo_write() when func == NULL, + * av_fifo_write_from_cb() otherwise */ +attribute_deprecated int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void*, void*, int)); /** @@ -135,7 +384,11 @@ int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void * @param f AVFifoBuffer to resize * @param size new AVFifoBuffer size in bytes * @return <0 for failure, >=0 otherwise + * + * @deprecated use the new AVFifo-API with av_fifo_grow2() to increase FIFO size, + * decreasing FIFO size is not supported */ +attribute_deprecated int av_fifo_realloc2(AVFifoBuffer *f, unsigned int size); /** @@ -146,16 +399,24 @@ int av_fifo_realloc2(AVFifoBuffer *f, unsigned int size); * @param f AVFifoBuffer to resize * @param additional_space the amount of space in bytes to allocate in addition to av_fifo_size() * @return <0 for failure, >=0 otherwise + * + * @deprecated use the new AVFifo-API with av_fifo_grow2(); note that unlike + * this function it adds to the allocated size, rather than to the used size */ +attribute_deprecated int av_fifo_grow(AVFifoBuffer *f, unsigned int additional_space); /** * Read and discard the specified amount of data from an AVFifoBuffer. * @param f AVFifoBuffer to read from * @param size amount of data to read in bytes + * + * @deprecated use the new AVFifo-API with av_fifo_drain2() */ +attribute_deprecated void av_fifo_drain(AVFifoBuffer *f, int size); +#if FF_API_FIFO_PEEK2 /** * Return a pointer to the data stored in a FIFO buffer at a certain offset. * The FIFO buffer is not modified. @@ -165,7 +426,9 @@ void av_fifo_drain(AVFifoBuffer *f, int size); * than the used buffer size or the returned pointer will * point outside to the buffer data. * The used buffer size can be checked with av_fifo_size(). + * @deprecated use the new AVFifo-API with av_fifo_peek() or av_fifo_peek_to_cb() */ +attribute_deprecated static inline uint8_t *av_fifo_peek2(const AVFifoBuffer *f, int offs) { uint8_t *ptr = f->rptr + offs; @@ -175,5 +438,11 @@ static inline uint8_t *av_fifo_peek2(const AVFifoBuffer *f, int offs) ptr = f->end - (f->buffer - ptr); return ptr; } +#endif +#endif + +/** + * @} + */ #endif /* AVUTIL_FIFO_H */ diff --git a/library/FFmpeg/include/libavutil/file.h b/library/FFmpeg/include/libavutil/file.h index 3ef4a602..fc87a9cd 100644 --- a/library/FFmpeg/include/libavutil/file.h +++ b/library/FFmpeg/include/libavutil/file.h @@ -19,9 +19,11 @@ #ifndef AVUTIL_FILE_H #define AVUTIL_FILE_H +#include #include -#include "avutil.h" +#include "version.h" +#include "attributes.h" /** * @file @@ -37,6 +39,9 @@ * case *bufptr will be set to NULL and *size will be set to 0. * The returned buffer must be released with av_file_unmap(). * + * @param filename path to the file + * @param[out] bufptr pointee is set to the mapped or allocated buffer + * @param[out] size pointee is set to the size in bytes of the buffer * @param log_offset loglevel offset used for logging * @param log_ctx context used for logging * @return a non negative number in case of success, a negative value @@ -49,11 +54,13 @@ int av_file_map(const char *filename, uint8_t **bufptr, size_t *size, /** * Unmap or free the buffer bufptr created by av_file_map(). * + * @param bufptr the buffer previously created with av_file_map() * @param size size in bytes of bufptr, must be the same as returned * by av_file_map() */ void av_file_unmap(uint8_t *bufptr, size_t size); +#if FF_API_AV_FOPEN_UTF8 /** * Wrapper to work around the lack of mkstemp() on mingw. * Also, tries to create file in /tmp first, if possible. @@ -66,6 +73,8 @@ void av_file_unmap(uint8_t *bufptr, size_t size); * libraries and could interfere with the calling application. * @deprecated as fd numbers cannot be passed saftely between libs on some platforms */ +attribute_deprecated int av_tempfile(const char *prefix, char **filename, int log_offset, void *log_ctx); +#endif #endif /* AVUTIL_FILE_H */ diff --git a/library/FFmpeg/include/libavutil/film_grain_params.h b/library/FFmpeg/include/libavutil/film_grain_params.h index 7629e3a0..f3bd0a4a 100644 --- a/library/FFmpeg/include/libavutil/film_grain_params.h +++ b/library/FFmpeg/include/libavutil/film_grain_params.h @@ -28,6 +28,11 @@ enum AVFilmGrainParamsType { * The union is valid when interpreted as AVFilmGrainAOMParams (codec.aom) */ AV_FILM_GRAIN_PARAMS_AV1, + + /** + * The union is valid when interpreted as AVFilmGrainH274Params (codec.h274) + */ + AV_FILM_GRAIN_PARAMS_H274, }; /** @@ -117,6 +122,89 @@ typedef struct AVFilmGrainAOMParams { int limit_output_range; } AVFilmGrainAOMParams; +/** + * This structure describes how to handle film grain synthesis for codecs using + * the ITU-T H.274 Versatile suplemental enhancement information message. + * + * @note The struct must be allocated as part of AVFilmGrainParams using + * av_film_grain_params_alloc(). Its size is not a part of the public ABI. + */ +typedef struct AVFilmGrainH274Params { + /** + * Specifies the film grain simulation mode. + * 0 = Frequency filtering, 1 = Auto-regression + */ + int model_id; + + /** + * Specifies the bit depth used for the luma component. + */ + int bit_depth_luma; + + /** + * Specifies the bit depth used for the chroma components. + */ + int bit_depth_chroma; + + enum AVColorRange color_range; + enum AVColorPrimaries color_primaries; + enum AVColorTransferCharacteristic color_trc; + enum AVColorSpace color_space; + + /** + * Specifies the blending mode used to blend the simulated film grain + * with the decoded images. + * + * 0 = Additive, 1 = Multiplicative + */ + int blending_mode_id; + + /** + * Specifies a scale factor used in the film grain characterization equations. + */ + int log2_scale_factor; + + /** + * Indicates if the modelling of film grain for a given component is present. + */ + int component_model_present[3 /* y, cb, cr */]; + + /** + * Specifies the number of intensity intervals for which a specific set of + * model values has been estimated, with a range of [1, 256]. + */ + uint16_t num_intensity_intervals[3 /* y, cb, cr */]; + + /** + * Specifies the number of model values present for each intensity interval + * in which the film grain has been modelled, with a range of [1, 6]. + */ + uint8_t num_model_values[3 /* y, cb, cr */]; + + /** + * Specifies the lower ounds of each intensity interval for whichthe set of + * model values applies for the component. + */ + uint8_t intensity_interval_lower_bound[3 /* y, cb, cr */][256 /* intensity interval */]; + + /** + * Specifies the upper bound of each intensity interval for which the set of + * model values applies for the component. + */ + uint8_t intensity_interval_upper_bound[3 /* y, cb, cr */][256 /* intensity interval */]; + + /** + * Specifies the model values for the component for each intensity interval. + * - When model_id == 0, the following applies: + * For comp_model_value[y], the range of values is [0, 2^bit_depth_luma - 1] + * For comp_model_value[cb..cr], the range of values is [0, 2^bit_depth_chroma - 1] + * - Otherwise, the following applies: + * For comp_model_value[y], the range of values is [-2^(bit_depth_luma - 1), 2^(bit_depth_luma - 1) - 1] + * For comp_model_value[cb..cr], the range of values is [-2^(bit_depth_chroma - 1), 2^(bit_depth_chroma - 1) - 1] + */ + int16_t comp_model_value[3 /* y, cb, cr */][256 /* intensity interval */][6 /* model value */]; +} AVFilmGrainH274Params; + /** * This structure describes how to handle film grain synthesis in video * for specific codecs. Must be present on every frame where film grain is @@ -133,6 +221,9 @@ typedef struct AVFilmGrainParams { /** * Seed to use for the synthesis process, if the codec allows for it. + * + * @note For H.264, this refers to `pic_offset` as defined in + * SMPTE RDD 5-2006. */ uint64_t seed; @@ -143,6 +234,7 @@ typedef struct AVFilmGrainParams { */ union { AVFilmGrainAOMParams aom; + AVFilmGrainH274Params h274; } codec; } AVFilmGrainParams; diff --git a/library/FFmpeg/include/libavutil/frame.h b/library/FFmpeg/include/libavutil/frame.h index ff2540a2..c0c1b23d 100644 --- a/library/FFmpeg/include/libavutil/frame.h +++ b/library/FFmpeg/include/libavutil/frame.h @@ -30,6 +30,7 @@ #include "avutil.h" #include "buffer.h" +#include "channel_layout.h" #include "dict.h" #include "rational.h" #include "samplefmt.h" @@ -187,6 +188,42 @@ enum AVFrameSideDataType { * as described by AVDetectionBBoxHeader. */ AV_FRAME_DATA_DETECTION_BBOXES, + + /** + * Dolby Vision RPU raw data, suitable for passing to x265 + * or other libraries. Array of uint8_t, with NAL emulation + * bytes intact. + */ + AV_FRAME_DATA_DOVI_RPU_BUFFER, + + /** + * Parsed Dolby Vision metadata, suitable for passing to a software + * implementation. The payload is the AVDOVIMetadata struct defined in + * libavutil/dovi_meta.h. + */ + AV_FRAME_DATA_DOVI_METADATA, + + /** + * HDR Vivid dynamic metadata associated with a video frame. The payload is + * an AVDynamicHDRVivid type and contains information for color + * volume transform - CUVA 005.1-2021. + */ + AV_FRAME_DATA_DYNAMIC_HDR_VIVID, + + /** + * Ambient viewing environment metadata, as defined by H.274. + */ + AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT, + + /** + * Provide encoder-specific hinting information about changed/unchanged + * portions of a frame. It can be used to pass information about which + * macroblocks can be skipped because they didn't change from the + * corresponding ones in the previous frame. This could be useful for + * applications which know this information in advance to speed up + * encoding. + */ + AV_FRAME_DATA_VIDEO_HINT, }; enum AVActiveFormatDescription { @@ -304,21 +341,32 @@ typedef struct AVFrame { #define AV_NUM_DATA_POINTERS 8 /** * pointer to the picture/channel planes. - * This might be different from the first allocated byte + * This might be different from the first allocated byte. For video, + * it could even point to the end of the image data. + * + * All pointers in data and extended_data must point into one of the + * AVBufferRef in buf or extended_buf. * * Some decoders access areas outside 0,0 - width,height, please * see avcodec_align_dimensions2(). Some filters and swscale can read * up to 16 bytes beyond the planes, if these filters are to be used, * then 16 extra bytes must be allocated. * - * NOTE: Except for hwaccel formats, pointers not needed by the format - * MUST be set to NULL. + * NOTE: Pointers not needed by the format MUST be set to NULL. + * + * @attention In case of video, the data[] pointers can point to the + * end of image data in order to reverse line order, when used in + * combination with negative values in the linesize[] array. */ uint8_t *data[AV_NUM_DATA_POINTERS]; /** - * For video, size in bytes of each picture line. - * For audio, size in bytes of each plane. + * For video, a positive or negative value, which is typically indicating + * the size in bytes of each picture line, but it can also be: + * - the negative byte size of lines for vertical flipping + * (with data[n] pointing to the end of the data + * - a positive or negative multiple of the byte size as for accessing + * even and odd fields of a frame (possibly flipped) * * For audio, only linesize[0] may be set. For planar audio, each channel * plane must be the same size. @@ -330,6 +378,9 @@ typedef struct AVFrame { * * @note The linesize may be larger than the size of usable data -- there * may be extra padding present for performance reasons. + * + * @attention In case of video, line size values can be negative to achieve + * a vertically inverted iteration over image lines. */ int linesize[AV_NUM_DATA_POINTERS]; @@ -375,10 +426,15 @@ typedef struct AVFrame { */ int format; +#if FF_API_FRAME_KEY /** * 1 -> keyframe, 0-> not + * + * @deprecated Use AV_FRAME_FLAG_KEY instead */ + attribute_deprecated int key_frame; +#endif /** * Picture type of the frame. @@ -402,14 +458,26 @@ typedef struct AVFrame { */ int64_t pkt_dts; + /** + * Time base for the timestamps in this frame. + * In the future, this field may be set on frames output by decoders or + * filters, but its value will be by default ignored on input to encoders + * or filters. + */ + AVRational time_base; + +#if FF_API_FRAME_PICTURE_NUMBER /** * picture number in bitstream order */ + attribute_deprecated int coded_picture_number; /** * picture number in display order */ + attribute_deprecated int display_picture_number; +#endif /** * quality (between 1 (good) and FF_LAMBDA_MAX (bad)) @@ -417,31 +485,68 @@ typedef struct AVFrame { int quality; /** - * for some private data of the user + * Frame owner's private data. + * + * This field may be set by the code that allocates/owns the frame data. + * It is then not touched by any library functions, except: + * - it is copied to other references by av_frame_copy_props() (and hence by + * av_frame_ref()); + * - it is set to NULL when the frame is cleared by av_frame_unref() + * - on the caller's explicit request. E.g. libavcodec encoders/decoders + * will copy this field to/from @ref AVPacket "AVPackets" if the caller sets + * @ref AV_CODEC_FLAG_COPY_OPAQUE. + * + * @see opaque_ref the reference-counted analogue */ void *opaque; /** - * When decoding, this signals how much the picture must be delayed. - * extra_delay = repeat_pict / (2*fps) + * Number of fields in this frame which should be repeated, i.e. the total + * duration of this frame should be repeat_pict + 2 normal field durations. + * + * For interlaced frames this field may be set to 1, which signals that this + * frame should be presented as 3 fields: beginning with the first field (as + * determined by AV_FRAME_FLAG_TOP_FIELD_FIRST being set or not), followed + * by the second field, and then the first field again. + * + * For progressive frames this field may be set to a multiple of 2, which + * signals that this frame's duration should be (repeat_pict + 2) / 2 + * normal frame durations. + * + * @note This field is computed from MPEG2 repeat_first_field flag and its + * associated flags, H.264 pic_struct from picture timing SEI, and + * their analogues in other codecs. Typically it should only be used when + * higher-layer timing information is not available. */ int repeat_pict; +#if FF_API_INTERLACED_FRAME /** * The content of the picture is interlaced. + * + * @deprecated Use AV_FRAME_FLAG_INTERLACED instead */ + attribute_deprecated int interlaced_frame; /** * If the content is interlaced, is top field displayed first. + * + * @deprecated Use AV_FRAME_FLAG_TOP_FIELD_FIRST instead */ + attribute_deprecated int top_field_first; +#endif +#if FF_API_PALETTE_HAS_CHANGED /** * Tell user application that palette has changed from previous frame. */ + attribute_deprecated int palette_has_changed; +#endif +#if FF_API_REORDERED_OPAQUE /** * reordered opaque 64 bits (generally an integer or a double precision float * PTS but can be anything). @@ -449,24 +554,32 @@ typedef struct AVFrame { * that time, * the decoder reorders values as needed and sets AVFrame.reordered_opaque * to exactly one of the values provided by the user through AVCodecContext.reordered_opaque + * + * @deprecated Use AV_CODEC_FLAG_COPY_OPAQUE instead */ + attribute_deprecated int64_t reordered_opaque; +#endif /** * Sample rate of the audio data. */ int sample_rate; +#if FF_API_OLD_CHANNEL_LAYOUT /** * Channel layout of the audio data. + * @deprecated use ch_layout instead */ + attribute_deprecated uint64_t channel_layout; +#endif /** - * AVBuffer references backing the data for this frame. If all elements of - * this array are NULL, then this frame is not reference counted. This array - * must be filled contiguously -- if buf[i] is non-NULL then buf[j] must - * also be non-NULL for all j < i. + * AVBuffer references backing the data for this frame. All the pointers in + * data and extended_data must point inside one of the buffers in buf or + * extended_buf. This array must be filled contiguously -- if buf[i] is + * non-NULL then buf[j] must also be non-NULL for all j < i. * * There may be at most one AVBuffer per data plane, so for video this array * always contains all the references. For planar audio with more than @@ -509,10 +622,23 @@ typedef struct AVFrame { * The frame data may be corrupted, e.g. due to decoding errors. */ #define AV_FRAME_FLAG_CORRUPT (1 << 0) +/** + * A flag to mark frames that are keyframes. + */ +#define AV_FRAME_FLAG_KEY (1 << 1) /** * A flag to mark the frames which need to be decoded, but shouldn't be output. */ #define AV_FRAME_FLAG_DISCARD (1 << 2) +/** + * A flag to mark frames whose content is interlaced. + */ +#define AV_FRAME_FLAG_INTERLACED (1 << 3) +/** + * A flag to mark frames where the top field is displayed first if the content + * is interlaced. + */ +#define AV_FRAME_FLAG_TOP_FIELD_FIRST (1 << 4) /** * @} */ @@ -549,20 +675,30 @@ typedef struct AVFrame { */ int64_t best_effort_timestamp; +#if FF_API_FRAME_PKT /** * reordered pos from the last AVPacket that has been input into the decoder * - encoding: unused * - decoding: Read by user. + * @deprecated use AV_CODEC_FLAG_COPY_OPAQUE to pass through arbitrary user + * data from packets to frames */ + attribute_deprecated int64_t pkt_pos; +#endif +#if FF_API_PKT_DURATION /** * duration of the corresponding packet, expressed in * AVStream->time_base units, 0 if unknown. * - encoding: unused * - decoding: Read by user. + * + * @deprecated use duration instead */ + attribute_deprecated int64_t pkt_duration; +#endif /** * metadata. @@ -584,21 +720,30 @@ typedef struct AVFrame { #define FF_DECODE_ERROR_CONCEALMENT_ACTIVE 4 #define FF_DECODE_ERROR_DECODE_SLICES 8 +#if FF_API_OLD_CHANNEL_LAYOUT /** * number of audio channels, only used for audio. * - encoding: unused * - decoding: Read by user. + * @deprecated use ch_layout instead */ + attribute_deprecated int channels; +#endif +#if FF_API_FRAME_PKT /** * size of the corresponding packet containing the compressed * frame. * It is set to a negative value if unknown. * - encoding: unused * - decoding: set by libavcodec, read by user. + * @deprecated use AV_CODEC_FLAG_COPY_OPAQUE to pass through arbitrary user + * data from packets to frames */ + attribute_deprecated int pkt_size; +#endif /** * For hwaccel-format frames, this should be a reference to the @@ -607,13 +752,18 @@ typedef struct AVFrame { AVBufferRef *hw_frames_ctx; /** - * AVBufferRef for free use by the API user. FFmpeg will never check the - * contents of the buffer ref. FFmpeg calls av_buffer_unref() on it when - * the frame is unreferenced. av_frame_copy_props() calls create a new - * reference with av_buffer_ref() for the target frame's opaque_ref field. + * Frame owner's private data. + * + * This field may be set by the code that allocates/owns the frame data. + * It is then not touched by any library functions, except: + * - a new reference to the underlying buffer is propagated by + * av_frame_copy_props() (and hence by av_frame_ref()); + * - it is unreferenced in av_frame_unref(); + * - on the caller's explicit request. E.g. libavcodec encoders/decoders + * will propagate a new reference to/from @ref AVPacket "AVPackets" if the + * caller sets @ref AV_CODEC_FLAG_COPY_OPAQUE. * - * This is unrelated to the opaque field, although it serves a similar - * purpose. + * @see opaque the plain pointer analogue */ AVBufferRef *opaque_ref; @@ -645,18 +795,19 @@ typedef struct AVFrame { * for the target frame's private_ref field. */ AVBufferRef *private_ref; + + /** + * Channel layout of the audio data. + */ + AVChannelLayout ch_layout; + + /** + * Duration of the frame, in the same units as pts. 0 if unknown. + */ + int64_t duration; } AVFrame; -#if FF_API_COLORSPACE_NAME -/** - * Get the name of a colorspace. - * @return a static string identifying the colorspace; can be NULL. - * @deprecated use av_color_space_name() - */ -attribute_deprecated -const char *av_get_colorspace_name(enum AVColorSpace val); -#endif /** * Allocate an AVFrame and set its fields to default values. The resulting * struct must be freed using av_frame_free(). @@ -695,6 +846,19 @@ void av_frame_free(AVFrame **frame); */ int av_frame_ref(AVFrame *dst, const AVFrame *src); +/** + * Ensure the destination frame refers to the same data described by the source + * frame, either by creating a new reference for each AVBufferRef from src if + * they differ from those in dst, by allocating new buffers and copying data if + * src is not reference counted, or by unrefencing it if src is empty. + * + * Frame properties on dst will be replaced by those from src. + * + * @return 0 on success, a negative AVERROR on error. On error, dst is + * unreferenced. + */ +int av_frame_replace(AVFrame *dst, const AVFrame *src); + /** * Create a new frame that references the same data as src. * @@ -724,7 +888,7 @@ void av_frame_move_ref(AVFrame *dst, AVFrame *src); * The following fields must be set on frame before calling this function: * - format (pixel format for video, sample format for audio) * - width and height for video - * - nb_samples and channel_layout for audio + * - nb_samples and ch_layout for audio * * This function will fill AVFrame.data and AVFrame.buf arrays and, if * necessary, allocate and fill AVFrame.extended_data and AVFrame.extended_buf. @@ -761,7 +925,8 @@ int av_frame_is_writable(AVFrame *frame); * Ensure that the frame data is writable, avoiding data copy if possible. * * Do nothing if the frame is writable, allocate new buffers and copy the data - * if it is not. + * if it is not. Non-refcounted frames behave as non-writable, i.e. a copy + * is always made. * * @return 0 on success, a negative AVERROR on error. * @@ -796,12 +961,13 @@ int av_frame_copy_props(AVFrame *dst, const AVFrame *src); /** * Get the buffer reference a given data plane is stored in. * + * @param frame the frame to get the plane's buffer from * @param plane index of the data plane of interest in frame->extended_data. * * @return the buffer reference that contains the plane or NULL if the input * frame is not valid. */ -AVBufferRef *av_frame_get_plane_buffer(AVFrame *frame, int plane); +AVBufferRef *av_frame_get_plane_buffer(const AVFrame *frame, int plane); /** * Add a new side data to a frame. diff --git a/library/FFmpeg/include/libavutil/hash.h b/library/FFmpeg/include/libavutil/hash.h index 930d2d6c..94151ded 100644 --- a/library/FFmpeg/include/libavutil/hash.h +++ b/library/FFmpeg/include/libavutil/hash.h @@ -30,8 +30,6 @@ #include #include -#include "version.h" - /** * @defgroup lavu_hash Hash Functions * @ingroup lavu_crypto diff --git a/library/FFmpeg/include/libavutil/hdr_dynamic_metadata.h b/library/FFmpeg/include/libavutil/hdr_dynamic_metadata.h index 2d72de56..09e9d8bb 100644 --- a/library/FFmpeg/include/libavutil/hdr_dynamic_metadata.h +++ b/library/FFmpeg/include/libavutil/hdr_dynamic_metadata.h @@ -340,4 +340,37 @@ AVDynamicHDRPlus *av_dynamic_hdr_plus_alloc(size_t *size); */ AVDynamicHDRPlus *av_dynamic_hdr_plus_create_side_data(AVFrame *frame); +/** + * Parse the user data registered ITU-T T.35 to AVbuffer (AVDynamicHDRPlus). + * The T.35 buffer must begin with the application mode, skipping the + * country code, terminal provider codes, and application identifier. + * @param s A pointer containing the decoded AVDynamicHDRPlus structure. + * @param data The byte array containing the raw ITU-T T.35 data. + * @param size Size of the data array in bytes. + * + * @return >= 0 on success. Otherwise, returns the appropriate AVERROR. + */ +int av_dynamic_hdr_plus_from_t35(AVDynamicHDRPlus *s, const uint8_t *data, + size_t size); + +#define AV_HDR_PLUS_MAX_PAYLOAD_SIZE 907 + +/** + * Serialize dynamic HDR10+ metadata to a user data registered ITU-T T.35 buffer, + * excluding the first 48 bytes of the header, and beginning with the application mode. + * @param s A pointer containing the decoded AVDynamicHDRPlus structure. + * @param data[in,out] A pointer to pointer to a byte buffer to be filled with the + * serialized metadata. + * If *data is NULL, a buffer be will be allocated and a pointer to + * it stored in its place. The caller assumes ownership of the buffer. + * May be NULL, in which case the function will only store the + * required buffer size in *size. + * @param size[in,out] A pointer to a size to be set to the returned buffer's size. + * If *data is not NULL, *size must contain the size of the input + * buffer. May be NULL only if *data is NULL. + * + * @return >= 0 on success. Otherwise, returns the appropriate AVERROR. + */ +int av_dynamic_hdr_plus_to_t35(const AVDynamicHDRPlus *s, uint8_t **data, size_t *size); + #endif /* AVUTIL_HDR_DYNAMIC_METADATA_H */ diff --git a/library/FFmpeg/include/libavutil/hdr_dynamic_vivid_metadata.h b/library/FFmpeg/include/libavutil/hdr_dynamic_vivid_metadata.h new file mode 100644 index 00000000..4524a815 --- /dev/null +++ b/library/FFmpeg/include/libavutil/hdr_dynamic_vivid_metadata.h @@ -0,0 +1,346 @@ +/* + * Copyright (c) 2021 Limin Wang + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_HDR_DYNAMIC_VIVID_METADATA_H +#define AVUTIL_HDR_DYNAMIC_VIVID_METADATA_H + +#include "frame.h" +#include "rational.h" + +/** + * HDR Vivid three spline params. + */ +typedef struct AVHDRVivid3SplineParams { + /** + * The mode of three Spline. the value shall be in the range + * of 0 to 3, inclusive. + */ + int th_mode; + + /** + * three_Spline_TH_enable_MB is in the range of 0.0 to 1.0, inclusive + * and in multiples of 1.0/255. + * + */ + AVRational th_enable_mb; + + /** + * 3Spline_TH_enable of three Spline. + * The value shall be in the range of 0.0 to 1.0, inclusive. + * and in multiples of 1.0/4095. + */ + AVRational th_enable; + + /** + * 3Spline_TH_Delta1 of three Spline. + * The value shall be in the range of 0.0 to 0.25, inclusive, + * and in multiples of 0.25/1023. + */ + AVRational th_delta1; + + /** + * 3Spline_TH_Delta2 of three Spline. + * The value shall be in the range of 0.0 to 0.25, inclusive, + * and in multiples of 0.25/1023. + */ + AVRational th_delta2; + + /** + * 3Spline_enable_Strength of three Spline. + * The value shall be in the range of 0.0 to 1.0, inclusive, + * and in multiples of 1.0/255. + */ + AVRational enable_strength; +} AVHDRVivid3SplineParams; + +/** + * Color tone mapping parameters at a processing window in a dynamic metadata for + * CUVA 005.1:2021. + */ +typedef struct AVHDRVividColorToneMappingParams { + /** + * The nominal maximum display luminance of the targeted system display, + * in multiples of 1.0/4095 candelas per square metre. The value shall be in + * the range of 0.0 to 1.0, inclusive. + */ + AVRational targeted_system_display_maximum_luminance; + + /** + * This flag indicates that transfer the base paramter(for value of 1) + */ + int base_enable_flag; + + /** + * base_param_m_p in the base parameter, + * in multiples of 1.0/16383. The value shall be in + * the range of 0.0 to 1.0, inclusive. + */ + AVRational base_param_m_p; + + /** + * base_param_m_m in the base parameter, + * in multiples of 1.0/10. The value shall be in + * the range of 0.0 to 6.3, inclusive. + */ + AVRational base_param_m_m; + + /** + * base_param_m_a in the base parameter, + * in multiples of 1.0/1023. The value shall be in + * the range of 0.0 to 1.0 inclusive. + */ + AVRational base_param_m_a; + + /** + * base_param_m_b in the base parameter, + * in multiples of 1/1023. The value shall be in + * the range of 0.0 to 1.0, inclusive. + */ + AVRational base_param_m_b; + + /** + * base_param_m_n in the base parameter, + * in multiples of 1.0/10. The value shall be in + * the range of 0.0 to 6.3, inclusive. + */ + AVRational base_param_m_n; + + /** + * indicates k1_0 in the base parameter, + * base_param_k1 <= 1: k1_0 = base_param_k1 + * base_param_k1 > 1: reserved + */ + int base_param_k1; + + /** + * indicates k2_0 in the base parameter, + * base_param_k2 <= 1: k2_0 = base_param_k2 + * base_param_k2 > 1: reserved + */ + int base_param_k2; + + /** + * indicates k3_0 in the base parameter, + * base_param_k3 == 1: k3_0 = base_param_k3 + * base_param_k3 == 2: k3_0 = maximum_maxrgb + * base_param_k3 > 2: reserved + */ + int base_param_k3; + + /** + * This flag indicates that delta mode of base paramter(for value of 1) + */ + int base_param_Delta_enable_mode; + + /** + * base_param_Delta in the base parameter, + * in multiples of 1.0/127. The value shall be in + * the range of 0.0 to 1.0, inclusive. + */ + AVRational base_param_Delta; + + /** + * indicates 3Spline_enable_flag in the base parameter, + * This flag indicates that transfer three Spline of base paramter(for value of 1) + */ + int three_Spline_enable_flag; + + /** + * The number of three Spline. The value shall be in the range + * of 1 to 2, inclusive. + */ + int three_Spline_num; + +#if FF_API_HDR_VIVID_THREE_SPLINE + /** + * The mode of three Spline. the value shall be in the range + * of 0 to 3, inclusive. + * @deprecated Use three_spline instead + */ + attribute_deprecated + int three_Spline_TH_mode; + + /** + * three_Spline_TH_enable_MB is in the range of 0.0 to 1.0, inclusive + * and in multiples of 1.0/255. + * @deprecated Use three_spline instead + */ + attribute_deprecated + AVRational three_Spline_TH_enable_MB; + + /** + * 3Spline_TH_enable of three Spline. + * The value shall be in the range of 0.0 to 1.0, inclusive. + * and in multiples of 1.0/4095. + * @deprecated Use three_spline instead + */ + attribute_deprecated + AVRational three_Spline_TH_enable; + + /** + * 3Spline_TH_Delta1 of three Spline. + * The value shall be in the range of 0.0 to 0.25, inclusive, + * and in multiples of 0.25/1023. + * @deprecated Use three_spline instead + */ + attribute_deprecated + AVRational three_Spline_TH_Delta1; + + /** + * 3Spline_TH_Delta2 of three Spline. + * The value shall be in the range of 0.0 to 0.25, inclusive, + * and in multiples of 0.25/1023. + * @deprecated Use three_spline instead + */ + attribute_deprecated + AVRational three_Spline_TH_Delta2; + + /** + * 3Spline_enable_Strength of three Spline. + * The value shall be in the range of 0.0 to 1.0, inclusive, + * and in multiples of 1.0/255. + * @deprecated Use three_spline instead + */ + attribute_deprecated + AVRational three_Spline_enable_Strength; +#endif + + AVHDRVivid3SplineParams three_spline[2]; +} AVHDRVividColorToneMappingParams; + + +/** + * Color transform parameters at a processing window in a dynamic metadata for + * CUVA 005.1:2021. + */ +typedef struct AVHDRVividColorTransformParams { + /** + * Indicates the minimum brightness of the displayed content. + * The values should be in the range of 0.0 to 1.0, + * inclusive and in multiples of 1/4095. + */ + AVRational minimum_maxrgb; + + /** + * Indicates the average brightness of the displayed content. + * The values should be in the range of 0.0 to 1.0, + * inclusive and in multiples of 1/4095. + */ + AVRational average_maxrgb; + + /** + * Indicates the variance brightness of the displayed content. + * The values should be in the range of 0.0 to 1.0, + * inclusive and in multiples of 1/4095. + */ + AVRational variance_maxrgb; + + /** + * Indicates the maximum brightness of the displayed content. + * The values should be in the range of 0.0 to 1.0, inclusive + * and in multiples of 1/4095. + */ + AVRational maximum_maxrgb; + + /** + * This flag indicates that the metadata for the tone mapping function in + * the processing window is present (for value of 1). + */ + int tone_mapping_mode_flag; + + /** + * The number of tone mapping param. The value shall be in the range + * of 1 to 2, inclusive. + */ + int tone_mapping_param_num; + + /** + * The color tone mapping parameters. + */ + AVHDRVividColorToneMappingParams tm_params[2]; + + /** + * This flag indicates that the metadata for the color saturation mapping in + * the processing window is present (for value of 1). + */ + int color_saturation_mapping_flag; + + /** + * The number of color saturation param. The value shall be in the range + * of 0 to 7, inclusive. + */ + int color_saturation_num; + + /** + * Indicates the color correction strength parameter. + * The values should be in the range of 0.0 to 2.0, inclusive + * and in multiples of 1/128. + */ + AVRational color_saturation_gain[8]; +} AVHDRVividColorTransformParams; + +/** + * This struct represents dynamic metadata for color volume transform - + * CUVA 005.1:2021 standard + * + * To be used as payload of a AVFrameSideData or AVPacketSideData with the + * appropriate type. + * + * @note The struct should be allocated with + * av_dynamic_hdr_vivid_alloc() and its size is not a part of + * the public ABI. + */ +typedef struct AVDynamicHDRVivid { + /** + * The system start code. The value shall be set to 0x01. + */ + uint8_t system_start_code; + + /** + * The number of processing windows. The value shall be set to 0x01 + * if the system_start_code is 0x01. + */ + uint8_t num_windows; + + /** + * The color transform parameters for every processing window. + */ + AVHDRVividColorTransformParams params[3]; +} AVDynamicHDRVivid; + +/** + * Allocate an AVDynamicHDRVivid structure and set its fields to + * default values. The resulting struct can be freed using av_freep(). + * + * @return An AVDynamicHDRVivid filled with default values or NULL + * on failure. + */ +AVDynamicHDRVivid *av_dynamic_hdr_vivid_alloc(size_t *size); + +/** + * Allocate a complete AVDynamicHDRVivid and add it to the frame. + * @param frame The frame which side data is added to. + * + * @return The AVDynamicHDRVivid structure to be filled by caller or NULL + * on failure. + */ +AVDynamicHDRVivid *av_dynamic_hdr_vivid_create_side_data(AVFrame *frame); + +#endif /* AVUTIL_HDR_DYNAMIC_VIVID_METADATA_H */ diff --git a/library/FFmpeg/include/libavutil/hmac.h b/library/FFmpeg/include/libavutil/hmac.h index 412e9507..ca4da6a6 100644 --- a/library/FFmpeg/include/libavutil/hmac.h +++ b/library/FFmpeg/include/libavutil/hmac.h @@ -23,7 +23,6 @@ #include -#include "version.h" /** * @defgroup lavu_hmac HMAC * @ingroup lavu_crypto diff --git a/library/FFmpeg/include/libavutil/hwcontext.h b/library/FFmpeg/include/libavutil/hwcontext.h index 04d19d89..7ff08c86 100644 --- a/library/FFmpeg/include/libavutil/hwcontext.h +++ b/library/FFmpeg/include/libavutil/hwcontext.h @@ -249,7 +249,7 @@ const char *av_hwdevice_get_type_name(enum AVHWDeviceType type); /** * Iterate over supported device types. * - * @param type AV_HWDEVICE_TYPE_NONE initially, then the previous type + * @param prev AV_HWDEVICE_TYPE_NONE initially, then the previous type * returned by this function in subsequent iterations. * @return The next usable device type from enum AVHWDeviceType, or * AV_HWDEVICE_TYPE_NONE if there are no more. @@ -571,6 +571,10 @@ enum { * possible with the given arguments and hwframe setup, while other return * values indicate that it failed somehow. * + * On failure, the destination frame will be left blank, except for the + * hw_frames_ctx/format fields thay may have been set by the caller - those will + * be preserved as they were. + * * @param dst Destination frame, to contain the mapping. * @param src Source frame, to be mapped. * @param flags Some combination of AV_HWFRAME_MAP_* flags. @@ -587,6 +591,7 @@ int av_hwframe_map(AVFrame *dst, const AVFrame *src, int flags); * * @param derived_frame_ctx On success, a reference to the newly created * AVHWFramesContext. + * @param format The AVPixelFormat for the derived context. * @param derived_device_ctx A reference to the device to create the new * AVHWFramesContext on. * @param source_frame_ctx A reference to an existing AVHWFramesContext diff --git a/library/FFmpeg/include/libavutil/hwcontext_cuda.h b/library/FFmpeg/include/libavutil/hwcontext_cuda.h index cefbe0ce..cbad434f 100644 --- a/library/FFmpeg/include/libavutil/hwcontext_cuda.h +++ b/library/FFmpeg/include/libavutil/hwcontext_cuda.h @@ -62,6 +62,11 @@ typedef struct AVCUDADeviceContext { */ #define AV_CUDA_USE_PRIMARY_CONTEXT (1 << 0) +/** + * Use current device context instead of creating a new one. + */ +#define AV_CUDA_USE_CURRENT_CONTEXT (1 << 1) + /** * @} */ diff --git a/library/FFmpeg/include/libavutil/hwcontext_d3d11va.h b/library/FFmpeg/include/libavutil/hwcontext_d3d11va.h index 9f91e9b1..77d2d72f 100644 --- a/library/FFmpeg/include/libavutil/hwcontext_d3d11va.h +++ b/library/FFmpeg/include/libavutil/hwcontext_d3d11va.h @@ -164,6 +164,15 @@ typedef struct AVD3D11VAFramesContext { * This field is ignored/invalid if a user-allocated texture is provided. */ UINT MiscFlags; + + /** + * In case if texture structure member above is not NULL contains the same texture + * pointer for all elements and different indexes into the array texture. + * In case if texture structure member above is NULL, all elements contains + * pointers to separate non-array textures and 0 indexes. + * This field is ignored/invalid if a user-allocated texture is provided. + */ + AVD3D11FrameDescriptor *texture_infos; } AVD3D11VAFramesContext; #endif /* AVUTIL_HWCONTEXT_D3D11VA_H */ diff --git a/library/FFmpeg/include/libavutil/hwcontext_mediacodec.h b/library/FFmpeg/include/libavutil/hwcontext_mediacodec.h index 101a9806..fc0263ca 100644 --- a/library/FFmpeg/include/libavutil/hwcontext_mediacodec.h +++ b/library/FFmpeg/include/libavutil/hwcontext_mediacodec.h @@ -31,6 +31,31 @@ typedef struct AVMediaCodecDeviceContext { * This is the default surface used by decoders on this device. */ void *surface; + + /** + * Pointer to ANativeWindow. + * + * It both surface and native_window is NULL, try to create it + * automatically if create_window is true and OS support + * createPersistentInputSurface. + * + * It can be used as output surface for decoder and input surface for + * encoder. + */ + void *native_window; + + /** + * Enable createPersistentInputSurface automatically. + * + * Disabled by default. + * + * It can be enabled by setting this flag directly, or by setting + * AVDictionary of av_hwdevice_ctx_create(), with "create_window" as key. + * The second method is useful for ffmpeg cmdline, e.g., we can enable it + * via: + * -init_hw_device mediacodec=mediacodec,create_window=1 + */ + int create_window; } AVMediaCodecDeviceContext; #endif /* AVUTIL_HWCONTEXT_MEDIACODEC_H */ diff --git a/library/FFmpeg/include/libavutil/hwcontext_qsv.h b/library/FFmpeg/include/libavutil/hwcontext_qsv.h index b98d611c..e2dba8ad 100644 --- a/library/FFmpeg/include/libavutil/hwcontext_qsv.h +++ b/library/FFmpeg/include/libavutil/hwcontext_qsv.h @@ -19,7 +19,7 @@ #ifndef AVUTIL_HWCONTEXT_QSV_H #define AVUTIL_HWCONTEXT_QSV_H -#include +#include /** * @file @@ -34,6 +34,17 @@ */ typedef struct AVQSVDeviceContext { mfxSession session; + /** + * The mfxLoader handle used for mfxSession creation + * + * This field is only available for oneVPL user. For non-oneVPL user, this + * field must be set to NULL. + * + * Filled by the user before calling av_hwdevice_ctx_init() and should be + * cast to mfxLoader handle. Deallocating the AVHWDeviceContext will always + * release this interface. + */ + void *loader; } AVQSVDeviceContext; /** diff --git a/library/FFmpeg/include/libavutil/hwcontext_videotoolbox.h b/library/FFmpeg/include/libavutil/hwcontext_videotoolbox.h index 62cde07c..25dde85d 100644 --- a/library/FFmpeg/include/libavutil/hwcontext_videotoolbox.h +++ b/library/FFmpeg/include/libavutil/hwcontext_videotoolbox.h @@ -23,6 +23,7 @@ #include +#include "frame.h" #include "pixfmt.h" /** @@ -60,4 +61,36 @@ uint32_t av_map_videotoolbox_format_from_pixfmt(enum AVPixelFormat pix_fmt); */ uint32_t av_map_videotoolbox_format_from_pixfmt2(enum AVPixelFormat pix_fmt, bool full_range); +/** + * Convert an AVChromaLocation to a VideoToolbox/CoreVideo chroma location string. + * Returns 0 if no known equivalent was found. + */ +CFStringRef av_map_videotoolbox_chroma_loc_from_av(enum AVChromaLocation loc); + +/** + * Convert an AVColorSpace to a VideoToolbox/CoreVideo color matrix string. + * Returns 0 if no known equivalent was found. + */ +CFStringRef av_map_videotoolbox_color_matrix_from_av(enum AVColorSpace space); + +/** + * Convert an AVColorPrimaries to a VideoToolbox/CoreVideo color primaries string. + * Returns 0 if no known equivalent was found. + */ +CFStringRef av_map_videotoolbox_color_primaries_from_av(enum AVColorPrimaries pri); + +/** + * Convert an AVColorTransferCharacteristic to a VideoToolbox/CoreVideo color transfer + * function string. + * Returns 0 if no known equivalent was found. + */ +CFStringRef av_map_videotoolbox_color_trc_from_av(enum AVColorTransferCharacteristic trc); + +/** + * Update a CVPixelBufferRef's metadata to based on an AVFrame. + * Returns 0 if no known equivalent was found. + */ +int av_vt_pixbuf_set_attachments(void *log_ctx, + CVPixelBufferRef pixbuf, const struct AVFrame *src); + #endif /* AVUTIL_HWCONTEXT_VIDEOTOOLBOX_H */ diff --git a/library/FFmpeg/include/libavutil/hwcontext_vulkan.h b/library/FFmpeg/include/libavutil/hwcontext_vulkan.h index e4645527..895794c8 100644 --- a/library/FFmpeg/include/libavutil/hwcontext_vulkan.h +++ b/library/FFmpeg/include/libavutil/hwcontext_vulkan.h @@ -19,11 +19,16 @@ #ifndef AVUTIL_HWCONTEXT_VULKAN_H #define AVUTIL_HWCONTEXT_VULKAN_H +#if defined(_WIN32) && !defined(VK_USE_PLATFORM_WIN32_KHR) +#define VK_USE_PLATFORM_WIN32_KHR +#endif #include #include "pixfmt.h" #include "frame.h" +typedef struct AVVkFrame AVVkFrame; + /** * @file * API-specific header for AV_HWDEVICE_TYPE_VULKAN. @@ -50,7 +55,7 @@ typedef struct AVVulkanDeviceContext { PFN_vkGetInstanceProcAddr get_proc_addr; /** - * Vulkan instance. Must be at least version 1.1. + * Vulkan instance. Must be at least version 1.3. */ VkInstance inst; @@ -94,51 +99,109 @@ typedef struct AVVulkanDeviceContext { int nb_enabled_dev_extensions; /** - * Queue family index for graphics - * @note av_hwdevice_create() will set all 3 queue indices if unset - * If there is no dedicated queue for compute or transfer operations, - * they will be set to the graphics queue index which can handle both. - * nb_graphics_queues indicates how many queues were enabled for the - * graphics queue (must be at least 1) + * Queue family index for graphics operations, and the number of queues + * enabled for it. If unavaiable, will be set to -1. Not required. + * av_hwdevice_create() will attempt to find a dedicated queue for each + * queue family, or pick the one with the least unrelated flags set. + * Queue indices here may overlap if a queue has to share capabilities. */ int queue_family_index; int nb_graphics_queues; /** - * Queue family index to use for transfer operations, and the amount of queues - * enabled. In case there is no dedicated transfer queue, nb_tx_queues - * must be 0 and queue_family_tx_index must be the same as either the graphics - * queue or the compute queue, if available. + * Queue family index for transfer operations and the number of queues + * enabled. Required. */ int queue_family_tx_index; int nb_tx_queues; /** - * Queue family index for compute ops, and the amount of queues enabled. - * In case there are no dedicated compute queues, nb_comp_queues must be - * 0 and its queue family index must be set to the graphics queue. + * Queue family index for compute operations and the number of queues + * enabled. Required. */ int queue_family_comp_index; int nb_comp_queues; + + /** + * Queue family index for video encode ops, and the amount of queues enabled. + * If the device doesn't support such, queue_family_encode_index will be -1. + * Not required. + */ + int queue_family_encode_index; + int nb_encode_queues; + + /** + * Queue family index for video decode ops, and the amount of queues enabled. + * If the device doesn't support such, queue_family_decode_index will be -1. + * Not required. + */ + int queue_family_decode_index; + int nb_decode_queues; + + /** + * Locks a queue, preventing other threads from submitting any command + * buffers to this queue. + * If set to NULL, will be set to lavu-internal functions that utilize a + * mutex. + */ + void (*lock_queue)(struct AVHWDeviceContext *ctx, uint32_t queue_family, uint32_t index); + + /** + * Similar to lock_queue(), unlocks a queue. Must only be called after locking. + */ + void (*unlock_queue)(struct AVHWDeviceContext *ctx, uint32_t queue_family, uint32_t index); } AVVulkanDeviceContext; +/** + * Defines the behaviour of frame allocation. + */ +typedef enum AVVkFrameFlags { + /* Unless this flag is set, autodetected flags will be OR'd based on the + * device and tiling during av_hwframe_ctx_init(). */ + AV_VK_FRAME_FLAG_NONE = (1ULL << 0), + +#if FF_API_VULKAN_CONTIGUOUS_MEMORY + /* DEPRECATED: does nothing. Replaced by multiplane images. */ + AV_VK_FRAME_FLAG_CONTIGUOUS_MEMORY = (1ULL << 1), +#endif + + /* Disables multiplane images. + * This is required to export/import images from CUDA. */ + AV_VK_FRAME_FLAG_DISABLE_MULTIPLANE = (1ULL << 2), +} AVVkFrameFlags; + /** * Allocated as AVHWFramesContext.hwctx, used to set pool-specific options */ typedef struct AVVulkanFramesContext { /** * Controls the tiling of allocated frames. + * If left as VK_IMAGE_TILING_OPTIMAL (0), will use optimal tiling. + * Can be set to VK_IMAGE_TILING_LINEAR to force linear images, + * or VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT to force DMABUF-backed + * images. + * @note Imported frames from other APIs ignore this. */ VkImageTiling tiling; /** - * Defines extra usage of output frames. If left as 0, the following bits - * are set: TRANSFER_SRC, TRANSFER_DST. SAMPLED and STORAGE. + * Defines extra usage of output frames. If non-zero, all flags MUST be + * supported by the VkFormat. Otherwise, will use supported flags amongst: + * - VK_IMAGE_USAGE_SAMPLED_BIT + * - VK_IMAGE_USAGE_STORAGE_BIT + * - VK_IMAGE_USAGE_TRANSFER_SRC_BIT + * - VK_IMAGE_USAGE_TRANSFER_DST_BIT */ VkImageUsageFlagBits usage; /** * Extension data for image creation. + * If DRM tiling is used, a VkImageDrmFormatModifierListCreateInfoEXT structure + * can be added to specify the exact modifier to use. + * + * Additional structures may be added at av_hwframe_ctx_init() time, + * which will be freed automatically on uninit(), so users must only free + * any structures they've allocated themselves. */ void *create_pnext; @@ -150,35 +213,72 @@ typedef struct AVVulkanFramesContext { * extensions are present in enabled_dev_extensions. */ void *alloc_pnext[AV_NUM_DATA_POINTERS]; + + /** + * A combination of AVVkFrameFlags. Unless AV_VK_FRAME_FLAG_NONE is set, + * autodetected flags will be OR'd based on the device and tiling during + * av_hwframe_ctx_init(). + */ + AVVkFrameFlags flags; + + /** + * Flags to set during image creation. If unset, defaults to + * VK_IMAGE_CREATE_ALIAS_BIT. + */ + VkImageCreateFlags img_flags; + + /** + * Vulkan format for each image. MUST be compatible with the pixel format. + * If unset, will be automatically set. + * There are at most two compatible formats for a frame - a multiplane + * format, and a single-plane multi-image format. + */ + VkFormat format[AV_NUM_DATA_POINTERS]; + + /** + * Number of layers each image will have. + */ + int nb_layers; + + /** + * Locks a frame, preventing other threads from changing frame properties. + * Users SHOULD only ever lock just before command submission in order + * to get accurate frame properties, and unlock immediately after command + * submission without waiting for it to finish. + * + * If unset, will be set to lavu-internal functions that utilize a mutex. + */ + void (*lock_frame)(struct AVHWFramesContext *fc, AVVkFrame *vkf); + + /** + * Similar to lock_frame(), unlocks a frame. Must only be called after locking. + */ + void (*unlock_frame)(struct AVHWFramesContext *fc, AVVkFrame *vkf); } AVVulkanFramesContext; /* - * Frame structure, the VkFormat of the image will always match - * the pool's sw_format. - * All frames, imported or allocated, will be created with the - * VK_IMAGE_CREATE_ALIAS_BIT flag set, so the memory may be aliased if needed. - * - * If all three queue family indices in the device context are the same, - * images will be created with the EXCLUSIVE sharing mode. Otherwise, all images - * will be created using the CONCURRENT sharing mode. + * Frame structure. * * @note the size of this structure is not part of the ABI, to allocate * you must use @av_vk_frame_alloc(). */ -typedef struct AVVkFrame { +struct AVVkFrame { /** * Vulkan images to which the memory is bound to. + * May be one for multiplane formats, or multiple. */ VkImage img[AV_NUM_DATA_POINTERS]; /** - * The same tiling must be used for all images in the frame. + * Tiling for the frame. */ VkImageTiling tiling; /** - * Memory backing the images. Could be less than the amount of images - * if importing from a DRM or VAAPI frame. + * Memory backing the images. Either one, or as many as there are planes + * in the sw_format. + * In case of having multiple VkImages, but one memory, the offset field + * will indicate the bound offset for each image. */ VkDeviceMemory mem[AV_NUM_DATA_POINTERS]; size_t size[AV_NUM_DATA_POINTERS]; @@ -189,24 +289,45 @@ typedef struct AVVkFrame { VkMemoryPropertyFlagBits flags; /** - * Updated after every barrier + * Updated after every barrier. One per VkImage. */ VkAccessFlagBits access[AV_NUM_DATA_POINTERS]; VkImageLayout layout[AV_NUM_DATA_POINTERS]; /** - * Synchronization semaphores. Must not be freed manually. Must be waited on - * and signalled at every queue submission. - * Could be less than the amount of images: either one per VkDeviceMemory - * or one for the entire frame. All others will be set to VK_NULL_HANDLE. + * Synchronization timeline semaphores, one for each VkImage. + * Must not be freed manually. Must be waited on at every submission using + * the value in sem_value, and must be signalled at every submission, + * using an incremented value. */ VkSemaphore sem[AV_NUM_DATA_POINTERS]; + /** + * Up to date semaphore value at which each image becomes accessible. + * One per VkImage. + * Clients must wait on this value when submitting a command queue, + * and increment it when signalling. + */ + uint64_t sem_value[AV_NUM_DATA_POINTERS]; + /** * Internal data. */ struct AVVkFrameInternal *internal; -} AVVkFrame; + + /** + * Describes the binding offset of each image to the VkDeviceMemory. + * One per VkImage. + */ + ptrdiff_t offset[AV_NUM_DATA_POINTERS]; + + /** + * Queue family of the images. Must be VK_QUEUE_FAMILY_IGNORED if + * the image was allocated with the CONCURRENT concurrency option. + * One per VkImage. + */ + uint32_t queue_family[AV_NUM_DATA_POINTERS]; +}; /** * Allocates a single AVVkFrame and initializes everything as 0. @@ -215,7 +336,8 @@ typedef struct AVVkFrame { AVVkFrame *av_vk_frame_alloc(void); /** - * Returns the format of each image up to the number of planes for a given sw_format. + * Returns the optimal per-plane Vulkan format for a given sw_format, + * one for each plane. * Returns NULL on unsupported formats. */ const VkFormat *av_vkfmt_from_pixfmt(enum AVPixelFormat p); diff --git a/library/FFmpeg/include/libavutil/imgutils.h b/library/FFmpeg/include/libavutil/imgutils.h index 5eccbf0b..fa3bb101 100644 --- a/library/FFmpeg/include/libavutil/imgutils.h +++ b/library/FFmpeg/include/libavutil/imgutils.h @@ -27,8 +27,10 @@ * @{ */ -#include "avutil.h" +#include +#include #include "pixdesc.h" +#include "pixfmt.h" #include "rational.h" /** @@ -46,6 +48,7 @@ * component in the plane with the max pixel step. * @param max_pixstep_comps an array which is filled with the component * for each plane which has the max pixel step. May be NULL. + * @param pixdesc the AVPixFmtDescriptor for the image, describing its format */ void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4], const AVPixFmtDescriptor *pixdesc); @@ -63,6 +66,8 @@ int av_image_get_linesize(enum AVPixelFormat pix_fmt, int width, int plane); * width width. * * @param linesizes array to be filled with the linesize for each plane + * @param pix_fmt the AVPixelFormat of the image + * @param width width of the image in pixels * @return >= 0 in case of success, a negative error code otherwise */ int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width); @@ -71,6 +76,8 @@ int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int wi * Fill plane sizes for an image with pixel format pix_fmt and height height. * * @param size the array to be filled with the size of each image plane + * @param pix_fmt the AVPixelFormat of the image + * @param height height of the image in pixels * @param linesizes the array containing the linesize for each * plane, should be filled by av_image_fill_linesizes() * @return >= 0 in case of success, a negative error code otherwise @@ -86,6 +93,8 @@ int av_image_fill_plane_sizes(size_t size[4], enum AVPixelFormat pix_fmt, * height height. * * @param data pointers array to be filled with the pointer for each image plane + * @param pix_fmt the AVPixelFormat of the image + * @param height height of the image in pixels * @param ptr the pointer to a buffer which will contain the image * @param linesizes the array containing the linesize for each * plane, should be filled by av_image_fill_linesizes() @@ -101,6 +110,11 @@ int av_image_fill_pointers(uint8_t *data[4], enum AVPixelFormat pix_fmt, int hei * The allocated image buffer has to be freed by using * av_freep(&pointers[0]). * + * @param pointers array to be filled with the pointer for each image plane + * @param linesizes the array filled with the linesize for each plane + * @param w width of the image in pixels + * @param h height of the image in pixels + * @param pix_fmt the AVPixelFormat of the image * @param align the value to use for buffer size alignment * @return the size in bytes required for the image buffer, a negative * error code in case of failure @@ -117,23 +131,65 @@ int av_image_alloc(uint8_t *pointers[4], int linesizes[4], * bytewidth must be contained by both absolute values of dst_linesize * and src_linesize, otherwise the function behavior is undefined. * + * @param dst destination plane to copy to * @param dst_linesize linesize for the image plane in dst + * @param src source plane to copy from * @param src_linesize linesize for the image plane in src + * @param height height (number of lines) of the plane */ void av_image_copy_plane(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int bytewidth, int height); +/** + * Copy image data located in uncacheable (e.g. GPU mapped) memory. Where + * available, this function will use special functionality for reading from such + * memory, which may result in greatly improved performance compared to plain + * av_image_copy_plane(). + * + * bytewidth must be contained by both absolute values of dst_linesize + * and src_linesize, otherwise the function behavior is undefined. + * + * @note The linesize parameters have the type ptrdiff_t here, while they are + * int for av_image_copy_plane(). + * @note On x86, the linesizes currently need to be aligned to the cacheline + * size (i.e. 64) to get improved performance. + */ +void av_image_copy_plane_uc_from(uint8_t *dst, ptrdiff_t dst_linesize, + const uint8_t *src, ptrdiff_t src_linesize, + ptrdiff_t bytewidth, int height); + /** * Copy image in src_data to dst_data. * + * @param dst_data destination image data buffer to copy to * @param dst_linesizes linesizes for the image in dst_data + * @param src_data source image data buffer to copy from * @param src_linesizes linesizes for the image in src_data + * @param pix_fmt the AVPixelFormat of the image + * @param width width of the image in pixels + * @param height height of the image in pixels */ -void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4], - const uint8_t *src_data[4], const int src_linesizes[4], +void av_image_copy(uint8_t * const dst_data[4], const int dst_linesizes[4], + const uint8_t * const src_data[4], const int src_linesizes[4], enum AVPixelFormat pix_fmt, int width, int height); +/** + * Wrapper around av_image_copy() to workaround the limitation + * that the conversion from uint8_t * const * to const uint8_t * const * + * is not performed automatically in C. + * @see av_image_copy() + */ +static inline +void av_image_copy2(uint8_t * const dst_data[4], const int dst_linesizes[4], + uint8_t * const src_data[4], const int src_linesizes[4], + enum AVPixelFormat pix_fmt, int width, int height) +{ + av_image_copy(dst_data, dst_linesizes, + (const uint8_t * const *)src_data, src_linesizes, + pix_fmt, width, height); +} + /** * Copy image data located in uncacheable (e.g. GPU mapped) memory. Where * available, this function will use special functionality for reading from such @@ -148,8 +204,8 @@ void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4], * @note On x86, the linesizes currently need to be aligned to the cacheline * size (i.e. 64) to get improved performance. */ -void av_image_copy_uc_from(uint8_t *dst_data[4], const ptrdiff_t dst_linesizes[4], - const uint8_t *src_data[4], const ptrdiff_t src_linesizes[4], +void av_image_copy_uc_from(uint8_t * const dst_data[4], const ptrdiff_t dst_linesizes[4], + const uint8_t * const src_data[4], const ptrdiff_t src_linesizes[4], enum AVPixelFormat pix_fmt, int width, int height); /** @@ -279,7 +335,7 @@ int av_image_check_sar(unsigned int w, unsigned int h, AVRational sar); * @param height the height of the image in pixels * @return 0 if the image data was cleared, a negative AVERROR code otherwise */ -int av_image_fill_black(uint8_t *dst_data[4], const ptrdiff_t dst_linesize[4], +int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesize[4], enum AVPixelFormat pix_fmt, enum AVColorRange range, int width, int height); diff --git a/library/FFmpeg/include/libavutil/intreadwrite.h b/library/FFmpeg/include/libavutil/intreadwrite.h index 4c8413a5..21df7887 100644 --- a/library/FFmpeg/include/libavutil/intreadwrite.h +++ b/library/FFmpeg/include/libavutil/intreadwrite.h @@ -72,8 +72,6 @@ typedef union { # include "mips/intreadwrite.h" #elif ARCH_PPC # include "ppc/intreadwrite.h" -#elif ARCH_TOMI -# include "tomi/intreadwrite.h" #elif ARCH_X86 # include "x86/intreadwrite.h" #endif @@ -215,7 +213,7 @@ typedef union { * by per-arch headers. */ -#if defined(__GNUC__) +#if defined(__GNUC__) || defined(__clang__) union unaligned_64 { uint64_t l; } __attribute__((packed)) av_alias; union unaligned_32 { uint32_t l; } __attribute__((packed)) av_alias; diff --git a/library/FFmpeg/include/libavutil/lfg.h b/library/FFmpeg/include/libavutil/lfg.h index 2b669205..e75a986f 100644 --- a/library/FFmpeg/include/libavutil/lfg.h +++ b/library/FFmpeg/include/libavutil/lfg.h @@ -27,7 +27,7 @@ /** * Context structure for the Lagged Fibonacci PRNG. * The exact layout, types and content of this struct may change and should - * not be accessed directly. Only its sizeof() is guranteed to stay the same + * not be accessed directly. Only its `sizeof()` is guaranteed to stay the same * to allow easy instanciation. */ typedef struct AVLFG { @@ -40,7 +40,7 @@ void av_lfg_init(AVLFG *c, unsigned int seed); /** * Seed the state of the ALFG using binary data. * - * Return value: 0 on success, negative value (AVERROR) on failure. + * @return 0 on success, negative value (AVERROR) on failure. */ int av_lfg_init_from_data(AVLFG *c, const uint8_t *data, unsigned int length); @@ -73,6 +73,7 @@ static inline unsigned int av_mlfg_get(AVLFG *c){ * Get the next two numbers generated by a Box-Muller Gaussian * generator using the random numbers issued by lfg. * + * @param lfg pointer to the contex structure * @param out array where the two generated numbers are placed */ void av_bmg_get(AVLFG *lfg, double out[2]); diff --git a/library/FFmpeg/include/libavutil/log.h b/library/FFmpeg/include/libavutil/log.h index c2f1232a..ab7ceabe 100644 --- a/library/FFmpeg/include/libavutil/log.h +++ b/library/FFmpeg/include/libavutil/log.h @@ -22,7 +22,6 @@ #define AVUTIL_LOG_H #include -#include "avutil.h" #include "attributes.h" #include "version.h" @@ -107,11 +106,6 @@ typedef struct AVClass { */ int parent_log_context_offset; - /** - * Return next AVOptions-enabled child or NULL - */ - void* (*child_next)(void *obj, void *prev); - /** * Category used for visualization (like color) * This is only set if the category is equal for all objects using this class. @@ -131,6 +125,11 @@ typedef struct AVClass { */ int (*query_ranges)(struct AVOptionRanges **, void *obj, const char *key, int flags); + /** + * Return next AVOptions-enabled child or NULL + */ + void* (*child_next)(void *obj, void *prev); + /** * Iterate over the AVClasses corresponding to potential AVOptions-enabled * children. diff --git a/library/FFmpeg/include/libavutil/lzo.h b/library/FFmpeg/include/libavutil/lzo.h new file mode 100644 index 00000000..c0340399 --- /dev/null +++ b/library/FFmpeg/include/libavutil/lzo.h @@ -0,0 +1,66 @@ +/* + * LZO 1x decompression + * copyright (c) 2006 Reimar Doeffinger + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_LZO_H +#define AVUTIL_LZO_H + +/** + * @defgroup lavu_lzo LZO + * @ingroup lavu_crypto + * + * @{ + */ + +#include + +/** @name Error flags returned by av_lzo1x_decode + * @{ */ +/// end of the input buffer reached before decoding finished +#define AV_LZO_INPUT_DEPLETED 1 +/// decoded data did not fit into output buffer +#define AV_LZO_OUTPUT_FULL 2 +/// a reference to previously decoded data was wrong +#define AV_LZO_INVALID_BACKPTR 4 +/// a non-specific error in the compressed bitstream +#define AV_LZO_ERROR 8 +/** @} */ + +#define AV_LZO_INPUT_PADDING 8 +#define AV_LZO_OUTPUT_PADDING 12 + +/** + * @brief Decodes LZO 1x compressed data. + * @param out output buffer + * @param outlen size of output buffer, number of bytes left are returned here + * @param in input buffer + * @param inlen size of input buffer, number of bytes left are returned here + * @return 0 on success, otherwise a combination of the error flags above + * + * Make sure all buffers are appropriately padded, in must provide + * AV_LZO_INPUT_PADDING, out must provide AV_LZO_OUTPUT_PADDING additional bytes. + */ +int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen); + +/** + * @} + */ + +#endif /* AVUTIL_LZO_H */ diff --git a/library/FFmpeg/include/libavutil/macros.h b/library/FFmpeg/include/libavutil/macros.h index 2007ee56..2a7567c3 100644 --- a/library/FFmpeg/include/libavutil/macros.h +++ b/library/FFmpeg/include/libavutil/macros.h @@ -25,6 +25,36 @@ #ifndef AVUTIL_MACROS_H #define AVUTIL_MACROS_H +#include "libavutil/avconfig.h" + +#if AV_HAVE_BIGENDIAN +# define AV_NE(be, le) (be) +#else +# define AV_NE(be, le) (le) +#endif + +/** + * Comparator. + * For two numerical expressions x and y, gives 1 if x > y, -1 if x < y, and 0 + * if x == y. This is useful for instance in a qsort comparator callback. + * Furthermore, compilers are able to optimize this to branchless code, and + * there is no risk of overflow with signed types. + * As with many macros, this evaluates its argument multiple times, it thus + * must not have a side-effect. + */ +#define FFDIFFSIGN(x,y) (((x)>(y)) - ((x)<(y))) + +#define FFMAX(a,b) ((a) > (b) ? (a) : (b)) +#define FFMAX3(a,b,c) FFMAX(FFMAX(a,b),c) +#define FFMIN(a,b) ((a) > (b) ? (b) : (a)) +#define FFMIN3(a,b,c) FFMIN(FFMIN(a,b),c) + +#define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0) +#define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0])) + +#define MKTAG(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((unsigned)(d) << 24)) +#define MKBETAG(a,b,c,d) ((d) | ((c) << 8) | ((b) << 16) | ((unsigned)(a) << 24)) + /** * @addtogroup preproc_misc Preprocessor String Macros * diff --git a/library/FFmpeg/include/libavutil/mathematics.h b/library/FFmpeg/include/libavutil/mathematics.h index 54901800..e213bab6 100644 --- a/library/FFmpeg/include/libavutil/mathematics.h +++ b/library/FFmpeg/include/libavutil/mathematics.h @@ -36,30 +36,81 @@ #ifndef M_E #define M_E 2.7182818284590452354 /* e */ #endif +#ifndef M_Ef +#define M_Ef 2.7182818284590452354f /* e */ +#endif #ifndef M_LN2 #define M_LN2 0.69314718055994530942 /* log_e 2 */ #endif +#ifndef M_LN2f +#define M_LN2f 0.69314718055994530942f /* log_e 2 */ +#endif #ifndef M_LN10 #define M_LN10 2.30258509299404568402 /* log_e 10 */ #endif +#ifndef M_LN10f +#define M_LN10f 2.30258509299404568402f /* log_e 10 */ +#endif #ifndef M_LOG2_10 #define M_LOG2_10 3.32192809488736234787 /* log_2 10 */ #endif +#ifndef M_LOG2_10f +#define M_LOG2_10f 3.32192809488736234787f /* log_2 10 */ +#endif #ifndef M_PHI #define M_PHI 1.61803398874989484820 /* phi / golden ratio */ #endif +#ifndef M_PHIf +#define M_PHIf 1.61803398874989484820f /* phi / golden ratio */ +#endif #ifndef M_PI #define M_PI 3.14159265358979323846 /* pi */ #endif +#ifndef M_PIf +#define M_PIf 3.14159265358979323846f /* pi */ +#endif #ifndef M_PI_2 #define M_PI_2 1.57079632679489661923 /* pi/2 */ #endif +#ifndef M_PI_2f +#define M_PI_2f 1.57079632679489661923f /* pi/2 */ +#endif +#ifndef M_PI_4 +#define M_PI_4 0.78539816339744830962 /* pi/4 */ +#endif +#ifndef M_PI_4f +#define M_PI_4f 0.78539816339744830962f /* pi/4 */ +#endif +#ifndef M_1_PI +#define M_1_PI 0.31830988618379067154 /* 1/pi */ +#endif +#ifndef M_1_PIf +#define M_1_PIf 0.31830988618379067154f /* 1/pi */ +#endif +#ifndef M_2_PI +#define M_2_PI 0.63661977236758134308 /* 2/pi */ +#endif +#ifndef M_2_PIf +#define M_2_PIf 0.63661977236758134308f /* 2/pi */ +#endif +#ifndef M_2_SQRTPI +#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */ +#endif +#ifndef M_2_SQRTPIf +#define M_2_SQRTPIf 1.12837916709551257390f /* 2/sqrt(pi) */ +#endif #ifndef M_SQRT1_2 #define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ #endif +#ifndef M_SQRT1_2f +#define M_SQRT1_2f 0.70710678118654752440f /* 1/sqrt(2) */ +#endif #ifndef M_SQRT2 #define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ #endif +#ifndef M_SQRT2f +#define M_SQRT2f 1.41421356237309504880f /* sqrt(2) */ +#endif #ifndef NAN #define NAN av_int2float(0x7fc00000) #endif @@ -111,7 +162,8 @@ enum AVRounding { /** * Compute the greatest common divisor of two integer operands. * - * @param a,b Operands + * @param a Operand + * @param b Operand * @return GCD of a and b up to sign; if a >= 0 and b >= 0, return value is >= 0; * if a == 0 and b == 0, returns 0. */ @@ -134,6 +186,7 @@ int64_t av_rescale(int64_t a, int64_t b, int64_t c) av_const; * * The operation is mathematically equivalent to `a * b / c`, but writing that * directly can overflow, and does not support different rounding methods. + * If the result is not representable then INT64_MIN is returned. * * @see av_rescale(), av_rescale_q(), av_rescale_q_rnd() */ @@ -185,7 +238,8 @@ int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b); * av_compare_mod(0x11, 0x02, 0x20) > 0 // since 0x11 % 0x20 (0x11) > 0x02 % 0x20 (0x02) * @endcode * - * @param a,b Operands + * @param a Operand + * @param b Operand * @param mod Divisor; must be a power of 2 * @return * - a negative value if `a % mod < b % mod` @@ -234,6 +288,10 @@ int64_t av_rescale_delta(AVRational in_tb, int64_t in_ts, AVRational fs_tb, int */ int64_t av_add_stable(AVRational ts_tb, int64_t ts, AVRational inc_tb, int64_t inc); +/** + * 0th order modified bessel function of the first kind. + */ +double av_bessel_i0(double x); /** * @} diff --git a/library/FFmpeg/include/libavutil/md5.h b/library/FFmpeg/include/libavutil/md5.h index eee6af44..fc2eabdb 100644 --- a/library/FFmpeg/include/libavutil/md5.h +++ b/library/FFmpeg/include/libavutil/md5.h @@ -31,7 +31,6 @@ #include #include "attributes.h" -#include "version.h" /** * @defgroup lavu_md5 MD5 diff --git a/library/FFmpeg/include/libavutil/mem.h b/library/FFmpeg/include/libavutil/mem.h index e9d343ea..ab7648ac 100644 --- a/library/FFmpeg/include/libavutil/mem.h +++ b/library/FFmpeg/include/libavutil/mem.h @@ -27,12 +27,10 @@ #ifndef AVUTIL_MEM_H #define AVUTIL_MEM_H -#include +#include #include #include "attributes.h" -#include "avutil.h" -#include "version.h" /** * @addtogroup lavu_mem @@ -51,86 +49,6 @@ * @{ */ -#if FF_API_DECLARE_ALIGNED -/** - * - * @defgroup lavu_mem_macros Alignment Macros - * Helper macros for declaring aligned variables. - * @{ - */ - -/** - * @def DECLARE_ALIGNED(n,t,v) - * Declare a variable that is aligned in memory. - * - * @code{.c} - * DECLARE_ALIGNED(16, uint16_t, aligned_int) = 42; - * DECLARE_ALIGNED(32, uint8_t, aligned_array)[128]; - * - * // The default-alignment equivalent would be - * uint16_t aligned_int = 42; - * uint8_t aligned_array[128]; - * @endcode - * - * @param n Minimum alignment in bytes - * @param t Type of the variable (or array element) - * @param v Name of the variable - */ - -/** - * @def DECLARE_ASM_ALIGNED(n,t,v) - * Declare an aligned variable appropriate for use in inline assembly code. - * - * @code{.c} - * DECLARE_ASM_ALIGNED(16, uint64_t, pw_08) = UINT64_C(0x0008000800080008); - * @endcode - * - * @param n Minimum alignment in bytes - * @param t Type of the variable (or array element) - * @param v Name of the variable - */ - -/** - * @def DECLARE_ASM_CONST(n,t,v) - * Declare a static constant aligned variable appropriate for use in inline - * assembly code. - * - * @code{.c} - * DECLARE_ASM_CONST(16, uint64_t, pw_08) = UINT64_C(0x0008000800080008); - * @endcode - * - * @param n Minimum alignment in bytes - * @param t Type of the variable (or array element) - * @param v Name of the variable - */ - -#if defined(__INTEL_COMPILER) && __INTEL_COMPILER < 1110 || defined(__SUNPRO_C) - #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v - #define DECLARE_ASM_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v - #define DECLARE_ASM_CONST(n,t,v) const t __attribute__ ((aligned (n))) v -#elif defined(__DJGPP__) - #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (FFMIN(n, 16)))) v - #define DECLARE_ASM_ALIGNED(n,t,v) t av_used __attribute__ ((aligned (FFMIN(n, 16)))) v - #define DECLARE_ASM_CONST(n,t,v) static const t av_used __attribute__ ((aligned (FFMIN(n, 16)))) v -#elif defined(__GNUC__) || defined(__clang__) - #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v - #define DECLARE_ASM_ALIGNED(n,t,v) t av_used __attribute__ ((aligned (n))) v - #define DECLARE_ASM_CONST(n,t,v) static const t av_used __attribute__ ((aligned (n))) v -#elif defined(_MSC_VER) - #define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v - #define DECLARE_ASM_ALIGNED(n,t,v) __declspec(align(n)) t v - #define DECLARE_ASM_CONST(n,t,v) __declspec(align(n)) static const t v -#else - #define DECLARE_ALIGNED(n,t,v) t v - #define DECLARE_ASM_ALIGNED(n,t,v) t v - #define DECLARE_ASM_CONST(n,t,v) static const t v -#endif - -/** - * @} - */ -#endif - /** * @defgroup lavu_mem_attrs Function Attributes * Function attributes applicable to memory handling functions. @@ -237,20 +155,12 @@ av_alloc_size(1, 2) void *av_malloc_array(size_t nmemb, size_t size); * @see av_mallocz() * @see av_malloc_array() */ -av_alloc_size(1, 2) void *av_mallocz_array(size_t nmemb, size_t size); - -/** - * Non-inlined equivalent of av_mallocz_array(). - * - * Created for symmetry with the calloc() C function. - */ -void *av_calloc(size_t nmemb, size_t size) av_malloc_attrib; +void *av_calloc(size_t nmemb, size_t size) av_malloc_attrib av_alloc_size(1, 2); /** * Allocate, reallocate, or free a block of memory. * - * If `ptr` is `NULL` and `size` > 0, allocate a new block. If `size` is - * zero, free the memory block pointed to by `ptr`. Otherwise, expand or + * If `ptr` is `NULL` and `size` > 0, allocate a new block. Otherwise, expand or * shrink that block of memory according to `size`. * * @param ptr Pointer to a memory block already allocated with @@ -259,10 +169,11 @@ void *av_calloc(size_t nmemb, size_t size) av_malloc_attrib; * reallocated * * @return Pointer to a newly-reallocated block or `NULL` if the block - * cannot be reallocated or the function is used to free the memory block + * cannot be reallocated * * @warning Unlike av_malloc(), the returned pointer is not guaranteed to be - * correctly aligned. + * correctly aligned. The returned pointer must be freed after even + * if size is zero. * @see av_fast_realloc() * @see av_reallocp() */ @@ -310,8 +221,7 @@ void *av_realloc_f(void *ptr, size_t nelem, size_t elsize); /** * Allocate, reallocate, or free an array. * - * If `ptr` is `NULL` and `nmemb` > 0, allocate a new block. If - * `nmemb` is zero, free the memory block pointed to by `ptr`. + * If `ptr` is `NULL` and `nmemb` > 0, allocate a new block. * * @param ptr Pointer to a memory block already allocated with * av_realloc() or `NULL` @@ -319,19 +229,19 @@ void *av_realloc_f(void *ptr, size_t nelem, size_t elsize); * @param size Size of the single element of the array * * @return Pointer to a newly-reallocated block or NULL if the block - * cannot be reallocated or the function is used to free the memory block + * cannot be reallocated * * @warning Unlike av_malloc(), the allocated memory is not guaranteed to be - * correctly aligned. + * correctly aligned. The returned pointer must be freed after even if + * nmemb is zero. * @see av_reallocp_array() */ av_alloc_size(2, 3) void *av_realloc_array(void *ptr, size_t nmemb, size_t size); /** - * Allocate, reallocate, or free an array through a pointer to a pointer. + * Allocate, reallocate an array through a pointer to a pointer. * - * If `*ptr` is `NULL` and `nmemb` > 0, allocate a new block. If `nmemb` is - * zero, free the memory block pointed to by `*ptr`. + * If `*ptr` is `NULL` and `nmemb` > 0, allocate a new block. * * @param[in,out] ptr Pointer to a pointer to a memory block already * allocated with av_realloc(), or a pointer to `NULL`. @@ -342,7 +252,7 @@ av_alloc_size(2, 3) void *av_realloc_array(void *ptr, size_t nmemb, size_t size) * @return Zero on success, an AVERROR error code on failure * * @warning Unlike av_malloc(), the allocated memory is not guaranteed to be - * correctly aligned. + * correctly aligned. *ptr must be freed after even if nmemb is zero. */ int av_reallocp_array(void *ptr, size_t nmemb, size_t size); @@ -667,7 +577,8 @@ void *av_dynarray2_add(void **tab_ptr, int *nb_ptr, size_t elem_size, /** * Multiply two `size_t` values checking for overflow. * - * @param[in] a,b Operands of multiplication + * @param[in] a Operand of multiplication + * @param[in] b Operand of multiplication * @param[out] r Pointer to the result of the operation * @return 0 on success, AVERROR(EINVAL) on overflow */ diff --git a/library/FFmpeg/include/libavutil/murmur3.h b/library/FFmpeg/include/libavutil/murmur3.h index c5cd7e49..d90bc2fc 100644 --- a/library/FFmpeg/include/libavutil/murmur3.h +++ b/library/FFmpeg/include/libavutil/murmur3.h @@ -30,8 +30,6 @@ #include #include -#include "version.h" - /** * @defgroup lavu_murmur3 Murmur3 * @ingroup lavu_hash diff --git a/library/FFmpeg/include/libavutil/opt.h b/library/FFmpeg/include/libavutil/opt.h index c2329e55..461b5d3b 100644 --- a/library/FFmpeg/include/libavutil/opt.h +++ b/library/FFmpeg/include/libavutil/opt.h @@ -29,11 +29,11 @@ #include "rational.h" #include "avutil.h" +#include "channel_layout.h" #include "dict.h" #include "log.h" #include "pixfmt.h" #include "samplefmt.h" -#include "version.h" /** * @defgroup avoptions AVOptions @@ -238,8 +238,11 @@ enum AVOptionType{ AV_OPT_TYPE_VIDEO_RATE, ///< offset must point to AVRational AV_OPT_TYPE_DURATION, AV_OPT_TYPE_COLOR, +#if FF_API_OLD_CHANNEL_LAYOUT AV_OPT_TYPE_CHANNEL_LAYOUT, +#endif AV_OPT_TYPE_BOOL, + AV_OPT_TYPE_CHLAYOUT, }; /** @@ -694,7 +697,11 @@ int av_opt_set_image_size(void *obj, const char *name, int w, int h, int search_ int av_opt_set_pixel_fmt (void *obj, const char *name, enum AVPixelFormat fmt, int search_flags); int av_opt_set_sample_fmt(void *obj, const char *name, enum AVSampleFormat fmt, int search_flags); int av_opt_set_video_rate(void *obj, const char *name, AVRational val, int search_flags); +#if FF_API_OLD_CHANNEL_LAYOUT +attribute_deprecated int av_opt_set_channel_layout(void *obj, const char *name, int64_t ch_layout, int search_flags); +#endif +int av_opt_set_chlayout(void *obj, const char *name, const AVChannelLayout *layout, int search_flags); /** * @note Any old dictionary present is discarded and replaced with a copy of the new one. The * caller still owns val is and responsible for freeing it. @@ -749,7 +756,11 @@ int av_opt_get_image_size(void *obj, const char *name, int search_flags, int *w_ int av_opt_get_pixel_fmt (void *obj, const char *name, int search_flags, enum AVPixelFormat *out_fmt); int av_opt_get_sample_fmt(void *obj, const char *name, int search_flags, enum AVSampleFormat *out_fmt); int av_opt_get_video_rate(void *obj, const char *name, int search_flags, AVRational *out_val); +#if FF_API_OLD_CHANNEL_LAYOUT +attribute_deprecated int av_opt_get_channel_layout(void *obj, const char *name, int search_flags, int64_t *ch_layout); +#endif +int av_opt_get_chlayout(void *obj, const char *name, int search_flags, AVChannelLayout *layout); /** * @param[out] out_val The returned dictionary is a copy of the actual value and must * be freed with av_dict_free() by the caller @@ -791,9 +802,16 @@ int av_opt_query_ranges(AVOptionRanges **, void *obj, const char *key, int flags /** * Copy options from src object into dest object. * + * The underlying AVClass of both src and dest must coincide. The guarantee + * below does not apply if this is not fulfilled. + * * Options that require memory allocation (e.g. string or binary) are malloc'ed in dest object. * Original memory allocated for such options is freed unless both src and dest options points to the same memory. * + * Even on error it is guaranteed that allocated options from src and dest + * no longer alias each other afterwards; in particular calling av_opt_free() + * on both src and dest is safe afterwards if dest has been memdup'ed from src. + * * @param dest Object to copy from * @param src Object to copy into * @return 0 on success, negative on error diff --git a/library/FFmpeg/include/libavutil/parseutils.h b/library/FFmpeg/include/libavutil/parseutils.h index e66d24b7..dad5c277 100644 --- a/library/FFmpeg/include/libavutil/parseutils.h +++ b/library/FFmpeg/include/libavutil/parseutils.h @@ -79,6 +79,8 @@ int av_parse_video_rate(AVRational *rate, const char *str); /** * Put the RGBA values that correspond to color_string in rgba_color. * + * @param rgba_color 4-elements array of uint8_t values, where the respective + * red, green, blue and alpha component values are written. * @param color_string a string specifying a color. It can be the name of * a color (case insensitive match) or a [0x|#]RRGGBB[AA] sequence, * possibly followed by "@" and a string representing the alpha @@ -92,6 +94,8 @@ int av_parse_video_rate(AVRational *rate, const char *str); * @param slen length of the initial part of color_string containing the * color. It can be set to -1 if color_string is a null terminated string * containing nothing else than the color. + * @param log_ctx a pointer to an arbitrary struct of which the first field + * is a pointer to an AVClass struct (used for av_log()). Can be NULL. * @return >= 0 in case of success, a negative value in case of * failure (for example if color_string cannot be parsed). */ @@ -106,7 +110,7 @@ int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen, * av_parse_color(). * * @param color_idx index of the requested color, starting from 0 - * @param rgbp if not NULL, will point to a 3-elements array with the color value in RGB + * @param rgb if not NULL, will point to a 3-elements array with the color value in RGB * @return the color name string or NULL if color_idx is not in the array */ const char *av_get_known_color_name(int color_idx, const uint8_t **rgb); @@ -162,19 +166,19 @@ int av_find_info_tag(char *arg, int arg_size, const char *tag1, const char *info * by the standard strptime(). * * The supported input field descriptors are listed below. - * - %H: the hour as a decimal number, using a 24-hour clock, in the + * - `%%H`: the hour as a decimal number, using a 24-hour clock, in the * range '00' through '23' - * - %J: hours as a decimal number, in the range '0' through INT_MAX - * - %M: the minute as a decimal number, using a 24-hour clock, in the + * - `%%J`: hours as a decimal number, in the range '0' through INT_MAX + * - `%%M`: the minute as a decimal number, using a 24-hour clock, in the * range '00' through '59' - * - %S: the second as a decimal number, using a 24-hour clock, in the + * - `%%S`: the second as a decimal number, using a 24-hour clock, in the * range '00' through '59' - * - %Y: the year as a decimal number, using the Gregorian calendar - * - %m: the month as a decimal number, in the range '1' through '12' - * - %d: the day of the month as a decimal number, in the range '1' + * - `%%Y`: the year as a decimal number, using the Gregorian calendar + * - `%%m`: the month as a decimal number, in the range '1' through '12' + * - `%%d`: the day of the month as a decimal number, in the range '1' * through '31' - * - %T: alias for '%H:%M:%S' - * - %%: a literal '%' + * - `%%T`: alias for `%%H:%%M:%%S` + * - `%%`: a literal `%` * * @return a pointer to the first character not processed in this function * call. In case the input string contains more characters than diff --git a/library/FFmpeg/include/libavutil/pixdesc.h b/library/FFmpeg/include/libavutil/pixdesc.h index 9e7cfad9..ba2f6328 100644 --- a/library/FFmpeg/include/libavutil/pixdesc.h +++ b/library/FFmpeg/include/libavutil/pixdesc.h @@ -26,7 +26,6 @@ #include "attributes.h" #include "pixfmt.h" -#include "version.h" typedef struct AVComponentDescriptor { /** @@ -158,6 +157,11 @@ typedef struct AVPixFmtDescriptor { */ #define AV_PIX_FMT_FLAG_FLOAT (1 << 9) +/** + * The pixel format contains XYZ-like data (as opposed to YUV/RGB/grayscale). + */ +#define AV_PIX_FMT_FLAG_XYZ (1 << 10) + /** * Return the number of bits per pixel used by the pixel format * described by pixdesc. Note that this is not the same as the number @@ -265,6 +269,28 @@ const char *av_chroma_location_name(enum AVChromaLocation location); */ int av_chroma_location_from_name(const char *name); +/** + * Converts AVChromaLocation to swscale x/y chroma position. + * + * The positions represent the chroma (0,0) position in a coordinates system + * with luma (0,0) representing the origin and luma(1,1) representing 256,256 + * + * @param xpos horizontal chroma sample position + * @param ypos vertical chroma sample position + */ +int av_chroma_location_enum_to_pos(int *xpos, int *ypos, enum AVChromaLocation pos); + +/** + * Converts swscale x/y chroma position to AVChromaLocation. + * + * The positions represent the chroma (0,0) position in a coordinates system + * with luma (0,0) representing the origin and luma(1,1) representing 256,256 + * + * @param xpos horizontal chroma sample position + * @param ypos vertical chroma sample position + */ +enum AVChromaLocation av_chroma_location_pos_to_enum(int xpos, int ypos); + /** * Return the pixel format corresponding to name. * @@ -358,12 +384,15 @@ void av_write_image_line(const uint16_t *src, uint8_t *data[4], */ enum AVPixelFormat av_pix_fmt_swap_endianness(enum AVPixelFormat pix_fmt); -#define FF_LOSS_RESOLUTION 0x0001 /**< loss due to resolution change */ -#define FF_LOSS_DEPTH 0x0002 /**< loss due to color depth change */ -#define FF_LOSS_COLORSPACE 0x0004 /**< loss due to color space conversion */ -#define FF_LOSS_ALPHA 0x0008 /**< loss of alpha bits */ -#define FF_LOSS_COLORQUANT 0x0010 /**< loss due to color quantization */ -#define FF_LOSS_CHROMA 0x0020 /**< loss of chroma (e.g. RGB to gray conversion) */ +#define FF_LOSS_RESOLUTION 0x0001 /**< loss due to resolution change */ +#define FF_LOSS_DEPTH 0x0002 /**< loss due to color depth change */ +#define FF_LOSS_COLORSPACE 0x0004 /**< loss due to color space conversion */ +#define FF_LOSS_ALPHA 0x0008 /**< loss of alpha bits */ +#define FF_LOSS_COLORQUANT 0x0010 /**< loss due to color quantization */ +#define FF_LOSS_CHROMA 0x0020 /**< loss of chroma (e.g. RGB to gray conversion) */ +#define FF_LOSS_EXCESS_RESOLUTION 0x0040 /**< loss due to unneeded extra resolution */ +#define FF_LOSS_EXCESS_DEPTH 0x0080 /**< loss due to unneeded extra color depth */ + /** * Compute what kind of losses will occur when converting from one specific diff --git a/library/FFmpeg/include/libavutil/pixelutils.h b/library/FFmpeg/include/libavutil/pixelutils.h index a8dbc157..7a997cde 100644 --- a/library/FFmpeg/include/libavutil/pixelutils.h +++ b/library/FFmpeg/include/libavutil/pixelutils.h @@ -21,7 +21,6 @@ #include #include -#include "common.h" /** * Sum of abs(src1[x] - src2[x]) diff --git a/library/FFmpeg/include/libavutil/pixfmt.h b/library/FFmpeg/include/libavutil/pixfmt.h index 5814f3f3..a26c72d5 100644 --- a/library/FFmpeg/include/libavutil/pixfmt.h +++ b/library/FFmpeg/include/libavutil/pixfmt.h @@ -206,8 +206,36 @@ enum AVPixelFormat { AV_PIX_FMT_GBRAP16BE, ///< planar GBRA 4:4:4:4 64bpp, big-endian AV_PIX_FMT_GBRAP16LE, ///< planar GBRA 4:4:4:4 64bpp, little-endian /** - * HW acceleration through QSV, data[3] contains a pointer to the - * mfxFrameSurface1 structure. + * HW acceleration through QSV, data[3] contains a pointer to the + * mfxFrameSurface1 structure. + * + * Before FFmpeg 5.0: + * mfxFrameSurface1.Data.MemId contains a pointer when importing + * the following frames as QSV frames: + * + * VAAPI: + * mfxFrameSurface1.Data.MemId contains a pointer to VASurfaceID + * + * DXVA2: + * mfxFrameSurface1.Data.MemId contains a pointer to IDirect3DSurface9 + * + * FFmpeg 5.0 and above: + * mfxFrameSurface1.Data.MemId contains a pointer to the mfxHDLPair + * structure when importing the following frames as QSV frames: + * + * VAAPI: + * mfxHDLPair.first contains a VASurfaceID pointer. + * mfxHDLPair.second is always MFX_INFINITE. + * + * DXVA2: + * mfxHDLPair.first contains IDirect3DSurface9 pointer. + * mfxHDLPair.second is always MFX_INFINITE. + * + * D3D11: + * mfxHDLPair.first contains a ID3D11Texture2D pointer. + * mfxHDLPair.second contains the texture array index of the frame if the + * ID3D11Texture2D is an array texture, or always MFX_INFINITE if it is a + * normal texture. */ AV_PIX_FMT_QSV, /** @@ -260,7 +288,9 @@ enum AVPixelFormat { AV_PIX_FMT_BAYER_GRBG16LE, ///< bayer, GRGR..(odd line), BGBG..(even line), 16-bit samples, little-endian AV_PIX_FMT_BAYER_GRBG16BE, ///< bayer, GRGR..(odd line), BGBG..(even line), 16-bit samples, big-endian +#if FF_API_XVMC AV_PIX_FMT_XVMC,///< XVideo Motion Acceleration via common packet passing +#endif AV_PIX_FMT_YUV440P10LE, ///< planar YUV 4:4:0,20bpp, (1 Cr & Cb sample per 1x2 Y samples), little-endian AV_PIX_FMT_YUV440P10BE, ///< planar YUV 4:4:0,20bpp, (1 Cr & Cb sample per 1x2 Y samples), big-endian @@ -350,6 +380,55 @@ enum AVPixelFormat { AV_PIX_FMT_X2RGB10LE, ///< packed RGB 10:10:10, 30bpp, (msb)2X 10R 10G 10B(lsb), little-endian, X=unused/undefined AV_PIX_FMT_X2RGB10BE, ///< packed RGB 10:10:10, 30bpp, (msb)2X 10R 10G 10B(lsb), big-endian, X=unused/undefined + AV_PIX_FMT_X2BGR10LE, ///< packed BGR 10:10:10, 30bpp, (msb)2X 10B 10G 10R(lsb), little-endian, X=unused/undefined + AV_PIX_FMT_X2BGR10BE, ///< packed BGR 10:10:10, 30bpp, (msb)2X 10B 10G 10R(lsb), big-endian, X=unused/undefined + + AV_PIX_FMT_P210BE, ///< interleaved chroma YUV 4:2:2, 20bpp, data in the high bits, big-endian + AV_PIX_FMT_P210LE, ///< interleaved chroma YUV 4:2:2, 20bpp, data in the high bits, little-endian + + AV_PIX_FMT_P410BE, ///< interleaved chroma YUV 4:4:4, 30bpp, data in the high bits, big-endian + AV_PIX_FMT_P410LE, ///< interleaved chroma YUV 4:4:4, 30bpp, data in the high bits, little-endian + + AV_PIX_FMT_P216BE, ///< interleaved chroma YUV 4:2:2, 32bpp, big-endian + AV_PIX_FMT_P216LE, ///< interleaved chroma YUV 4:2:2, 32bpp, little-endian + + AV_PIX_FMT_P416BE, ///< interleaved chroma YUV 4:4:4, 48bpp, big-endian + AV_PIX_FMT_P416LE, ///< interleaved chroma YUV 4:4:4, 48bpp, little-endian + + AV_PIX_FMT_VUYA, ///< packed VUYA 4:4:4, 32bpp, VUYAVUYA... + + AV_PIX_FMT_RGBAF16BE, ///< IEEE-754 half precision packed RGBA 16:16:16:16, 64bpp, RGBARGBA..., big-endian + AV_PIX_FMT_RGBAF16LE, ///< IEEE-754 half precision packed RGBA 16:16:16:16, 64bpp, RGBARGBA..., little-endian + + AV_PIX_FMT_VUYX, ///< packed VUYX 4:4:4, 32bpp, Variant of VUYA where alpha channel is left undefined + + AV_PIX_FMT_P012LE, ///< like NV12, with 12bpp per component, data in the high bits, zeros in the low bits, little-endian + AV_PIX_FMT_P012BE, ///< like NV12, with 12bpp per component, data in the high bits, zeros in the low bits, big-endian + + AV_PIX_FMT_Y212BE, ///< packed YUV 4:2:2 like YUYV422, 24bpp, data in the high bits, zeros in the low bits, big-endian + AV_PIX_FMT_Y212LE, ///< packed YUV 4:2:2 like YUYV422, 24bpp, data in the high bits, zeros in the low bits, little-endian + + AV_PIX_FMT_XV30BE, ///< packed XVYU 4:4:4, 32bpp, (msb)2X 10V 10Y 10U(lsb), big-endian, variant of Y410 where alpha channel is left undefined + AV_PIX_FMT_XV30LE, ///< packed XVYU 4:4:4, 32bpp, (msb)2X 10V 10Y 10U(lsb), little-endian, variant of Y410 where alpha channel is left undefined + + AV_PIX_FMT_XV36BE, ///< packed XVYU 4:4:4, 48bpp, data in the high bits, zeros in the low bits, big-endian, variant of Y412 where alpha channel is left undefined + AV_PIX_FMT_XV36LE, ///< packed XVYU 4:4:4, 48bpp, data in the high bits, zeros in the low bits, little-endian, variant of Y412 where alpha channel is left undefined + + AV_PIX_FMT_RGBF32BE, ///< IEEE-754 single precision packed RGB 32:32:32, 96bpp, RGBRGB..., big-endian + AV_PIX_FMT_RGBF32LE, ///< IEEE-754 single precision packed RGB 32:32:32, 96bpp, RGBRGB..., little-endian + + AV_PIX_FMT_RGBAF32BE, ///< IEEE-754 single precision packed RGBA 32:32:32:32, 128bpp, RGBARGBA..., big-endian + AV_PIX_FMT_RGBAF32LE, ///< IEEE-754 single precision packed RGBA 32:32:32:32, 128bpp, RGBARGBA..., little-endian + + AV_PIX_FMT_P212BE, ///< interleaved chroma YUV 4:2:2, 24bpp, data in the high bits, big-endian + AV_PIX_FMT_P212LE, ///< interleaved chroma YUV 4:2:2, 24bpp, data in the high bits, little-endian + + AV_PIX_FMT_P412BE, ///< interleaved chroma YUV 4:4:4, 36bpp, data in the high bits, big-endian + AV_PIX_FMT_P412LE, ///< interleaved chroma YUV 4:4:4, 36bpp, data in the high bits, little-endian + + AV_PIX_FMT_GBRAP14BE, ///< planar GBR 4:4:4:4 56bpp, big-endian + AV_PIX_FMT_GBRAP14LE, ///< planar GBR 4:4:4:4 56bpp, little-endian + AV_PIX_FMT_NB ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions }; @@ -408,6 +487,7 @@ enum AVPixelFormat { #define AV_PIX_FMT_GBRP16 AV_PIX_FMT_NE(GBRP16BE, GBRP16LE) #define AV_PIX_FMT_GBRAP10 AV_PIX_FMT_NE(GBRAP10BE, GBRAP10LE) #define AV_PIX_FMT_GBRAP12 AV_PIX_FMT_NE(GBRAP12BE, GBRAP12LE) +#define AV_PIX_FMT_GBRAP14 AV_PIX_FMT_NE(GBRAP14BE, GBRAP14LE) #define AV_PIX_FMT_GBRAP16 AV_PIX_FMT_NE(GBRAP16BE, GBRAP16LE) #define AV_PIX_FMT_BAYER_BGGR16 AV_PIX_FMT_NE(BAYER_BGGR16BE, BAYER_BGGR16LE) @@ -436,10 +516,27 @@ enum AVPixelFormat { #define AV_PIX_FMT_NV20 AV_PIX_FMT_NE(NV20BE, NV20LE) #define AV_PIX_FMT_AYUV64 AV_PIX_FMT_NE(AYUV64BE, AYUV64LE) #define AV_PIX_FMT_P010 AV_PIX_FMT_NE(P010BE, P010LE) +#define AV_PIX_FMT_P012 AV_PIX_FMT_NE(P012BE, P012LE) #define AV_PIX_FMT_P016 AV_PIX_FMT_NE(P016BE, P016LE) #define AV_PIX_FMT_Y210 AV_PIX_FMT_NE(Y210BE, Y210LE) +#define AV_PIX_FMT_Y212 AV_PIX_FMT_NE(Y212BE, Y212LE) +#define AV_PIX_FMT_XV30 AV_PIX_FMT_NE(XV30BE, XV30LE) +#define AV_PIX_FMT_XV36 AV_PIX_FMT_NE(XV36BE, XV36LE) #define AV_PIX_FMT_X2RGB10 AV_PIX_FMT_NE(X2RGB10BE, X2RGB10LE) +#define AV_PIX_FMT_X2BGR10 AV_PIX_FMT_NE(X2BGR10BE, X2BGR10LE) + +#define AV_PIX_FMT_P210 AV_PIX_FMT_NE(P210BE, P210LE) +#define AV_PIX_FMT_P410 AV_PIX_FMT_NE(P410BE, P410LE) +#define AV_PIX_FMT_P212 AV_PIX_FMT_NE(P212BE, P212LE) +#define AV_PIX_FMT_P412 AV_PIX_FMT_NE(P412BE, P412LE) +#define AV_PIX_FMT_P216 AV_PIX_FMT_NE(P216BE, P216LE) +#define AV_PIX_FMT_P416 AV_PIX_FMT_NE(P416BE, P416LE) + +#define AV_PIX_FMT_RGBAF16 AV_PIX_FMT_NE(RGBAF16BE, RGBAF16LE) + +#define AV_PIX_FMT_RGBF32 AV_PIX_FMT_NE(RGBF32BE, RGBF32LE) +#define AV_PIX_FMT_RGBAF32 AV_PIX_FMT_NE(RGBAF32BE, RGBAF32LE) /** * Chromaticity coordinates of the source primaries. diff --git a/library/FFmpeg/include/libavutil/random_seed.h b/library/FFmpeg/include/libavutil/random_seed.h index 0462a048..8a47be96 100644 --- a/library/FFmpeg/include/libavutil/random_seed.h +++ b/library/FFmpeg/include/libavutil/random_seed.h @@ -21,6 +21,7 @@ #ifndef AVUTIL_RANDOM_SEED_H #define AVUTIL_RANDOM_SEED_H +#include #include /** * @addtogroup lavu_crypto @@ -36,6 +37,19 @@ */ uint32_t av_get_random_seed(void); +/** + * Generate cryptographically secure random data, i.e. suitable for use as + * encryption keys and similar. + * + * @param buf buffer into which the random data will be written + * @param len size of buf in bytes + * + * @retval 0 success, len bytes of random data was written + * into buf + * @retval "a negative AVERROR code" random data could not be generated + */ +int av_random_bytes(uint8_t *buf, size_t len); + /** * @} */ diff --git a/library/FFmpeg/include/libavutil/rational.h b/library/FFmpeg/include/libavutil/rational.h index cbb08a0b..8cbfc8e0 100644 --- a/library/FFmpeg/include/libavutil/rational.h +++ b/library/FFmpeg/include/libavutil/rational.h @@ -179,7 +179,8 @@ AVRational av_d2q(double d, int max) av_const; * Find which of the two rationals is closer to another rational. * * @param q Rational to be compared against - * @param q1,q2 Rationals to be tested + * @param q1 Rational to be tested + * @param q2 Rational to be tested * @return One of the following values: * - 1 if `q1` is nearer to `q` than `q2` * - -1 if `q2` is nearer to `q` than `q1` diff --git a/library/FFmpeg/include/libavutil/rc4.h b/library/FFmpeg/include/libavutil/rc4.h index 029cd2ad..bf0ca6e9 100644 --- a/library/FFmpeg/include/libavutil/rc4.h +++ b/library/FFmpeg/include/libavutil/rc4.h @@ -42,6 +42,8 @@ AVRC4 *av_rc4_alloc(void); /** * @brief Initializes an AVRC4 context. * + * @param d pointer to the AVRC4 context + * @param key buffer containig the key * @param key_bits must be a multiple of 8 * @param decrypt 0 for encryption, 1 for decryption, currently has no effect * @return zero on success, negative value otherwise @@ -51,6 +53,7 @@ int av_rc4_init(struct AVRC4 *d, const uint8_t *key, int key_bits, int decrypt); /** * @brief Encrypts / decrypts using the RC4 algorithm. * + * @param d pointer to the AVRC4 context * @param count number of bytes * @param dst destination array, can be equal to src * @param src source array, can be equal to dst, may be NULL diff --git a/library/FFmpeg/include/libavutil/ripemd.h b/library/FFmpeg/include/libavutil/ripemd.h index 8c24b728..9df9f905 100644 --- a/library/FFmpeg/include/libavutil/ripemd.h +++ b/library/FFmpeg/include/libavutil/ripemd.h @@ -32,7 +32,6 @@ #include #include "attributes.h" -#include "version.h" /** * @defgroup lavu_ripemd RIPEMD diff --git a/library/FFmpeg/include/libavutil/samplefmt.h b/library/FFmpeg/include/libavutil/samplefmt.h index 79f33d06..28e724ba 100644 --- a/library/FFmpeg/include/libavutil/samplefmt.h +++ b/library/FFmpeg/include/libavutil/samplefmt.h @@ -21,9 +21,6 @@ #include -#include "avutil.h" -#include "attributes.h" - /** * @addtogroup lavu_audio * @{ @@ -217,6 +214,7 @@ int av_samples_fill_arrays(uint8_t **audio_data, int *linesize, * @param[out] linesize aligned size for audio buffer(s), may be NULL * @param nb_channels number of audio channels * @param nb_samples number of samples per channel + * @param sample_fmt the sample format * @param align buffer size alignment (0 = default, 1 = no alignment) * @return >=0 on success or a negative error code on failure * @todo return the size of the allocated buffer in case of success at the next bump @@ -249,7 +247,7 @@ int av_samples_alloc_array_and_samples(uint8_t ***audio_data, int *linesize, int * @param nb_channels number of audio channels * @param sample_fmt audio sample format */ -int av_samples_copy(uint8_t **dst, uint8_t * const *src, int dst_offset, +int av_samples_copy(uint8_t * const *dst, uint8_t * const *src, int dst_offset, int src_offset, int nb_samples, int nb_channels, enum AVSampleFormat sample_fmt); @@ -262,7 +260,7 @@ int av_samples_copy(uint8_t **dst, uint8_t * const *src, int dst_offset, * @param nb_channels number of audio channels * @param sample_fmt audio sample format */ -int av_samples_set_silence(uint8_t **audio_data, int offset, int nb_samples, +int av_samples_set_silence(uint8_t * const *audio_data, int offset, int nb_samples, int nb_channels, enum AVSampleFormat sample_fmt); /** diff --git a/library/FFmpeg/include/libavutil/sha.h b/library/FFmpeg/include/libavutil/sha.h index 85356218..2e1220ab 100644 --- a/library/FFmpeg/include/libavutil/sha.h +++ b/library/FFmpeg/include/libavutil/sha.h @@ -31,7 +31,6 @@ #include #include "attributes.h" -#include "version.h" /** * @defgroup lavu_sha SHA diff --git a/library/FFmpeg/include/libavutil/sha512.h b/library/FFmpeg/include/libavutil/sha512.h index 30dd8744..a4a3f23d 100644 --- a/library/FFmpeg/include/libavutil/sha512.h +++ b/library/FFmpeg/include/libavutil/sha512.h @@ -32,7 +32,6 @@ #include #include "attributes.h" -#include "version.h" /** * @defgroup lavu_sha512 SHA-512 diff --git a/library/FFmpeg/include/libavutil/spherical.h b/library/FFmpeg/include/libavutil/spherical.h index cef759cf..828ac836 100644 --- a/library/FFmpeg/include/libavutil/spherical.h +++ b/library/FFmpeg/include/libavutil/spherical.h @@ -20,6 +20,7 @@ /** * @file + * @ingroup lavu_video_spherical * Spherical video */ @@ -30,19 +31,14 @@ #include /** - * @addtogroup lavu_video - * @{ - * * @defgroup lavu_video_spherical Spherical video mapping - * @{ - */ - -/** - * @addtogroup lavu_video_spherical + * @ingroup lavu_video + * * A spherical video file contains surfaces that need to be mapped onto a * sphere. Depending on how the frame was converted, a different distortion * transformation or surface recomposition function needs to be applied before * the video should be mapped and displayed. + * @{ */ /** @@ -225,7 +221,6 @@ const char *av_spherical_projection_name(enum AVSphericalProjection projection); */ int av_spherical_from_name(const char *name); /** - * @} * @} */ diff --git a/library/FFmpeg/include/libavutil/stereo3d.h b/library/FFmpeg/include/libavutil/stereo3d.h index d421aac2..3aab959b 100644 --- a/library/FFmpeg/include/libavutil/stereo3d.h +++ b/library/FFmpeg/include/libavutil/stereo3d.h @@ -20,6 +20,7 @@ /** * @file + * @ingroup lavu_video_stereo3d * Stereoscopic video */ @@ -31,19 +32,15 @@ #include "frame.h" /** - * @addtogroup lavu_video - * @{ - * * @defgroup lavu_video_stereo3d Stereo3D types and functions - * @{ - */ - -/** - * @addtogroup lavu_video_stereo3d + * @ingroup lavu_video + * * A stereoscopic video file consists in multiple views embedded in a single * frame, usually describing two views of a scene. This file describes all * possible codec-independent view arrangements. - * */ + * + * @{ + */ /** * List of possible 3D Types @@ -226,7 +223,6 @@ const char *av_stereo3d_type_name(unsigned int type); int av_stereo3d_from_name(const char *name); /** - * @} * @} */ diff --git a/library/FFmpeg/include/libavutil/timestamp.h b/library/FFmpeg/include/libavutil/timestamp.h index e082f01b..9ae64da8 100644 --- a/library/FFmpeg/include/libavutil/timestamp.h +++ b/library/FFmpeg/include/libavutil/timestamp.h @@ -24,7 +24,7 @@ #ifndef AVUTIL_TIMESTAMP_H #define AVUTIL_TIMESTAMP_H -#include "common.h" +#include "avutil.h" #if defined(__cplusplus) && !defined(__STDC_FORMAT_MACROS) && !defined(PRId64) #error missing -D__STDC_FORMAT_MACROS / #define __STDC_FORMAT_MACROS diff --git a/library/FFmpeg/include/libavutil/tree.h b/library/FFmpeg/include/libavutil/tree.h index d5e0aebf..bbb8fbb1 100644 --- a/library/FFmpeg/include/libavutil/tree.h +++ b/library/FFmpeg/include/libavutil/tree.h @@ -28,7 +28,6 @@ #define AVUTIL_TREE_H #include "attributes.h" -#include "version.h" /** * @addtogroup lavu_tree AVTree diff --git a/library/FFmpeg/include/libavutil/twofish.h b/library/FFmpeg/include/libavutil/twofish.h index 813cfecd..67f359e8 100644 --- a/library/FFmpeg/include/libavutil/twofish.h +++ b/library/FFmpeg/include/libavutil/twofish.h @@ -59,7 +59,7 @@ int av_twofish_init(struct AVTWOFISH *ctx, const uint8_t *key, int key_bits); * @param dst destination array, can be equal to src * @param src source array, can be equal to dst * @param count number of 16 byte blocks - * @paran iv initialization vector for CBC mode, NULL for ECB mode + * @param iv initialization vector for CBC mode, NULL for ECB mode * @param decrypt 0 for encryption, 1 for decryption */ void av_twofish_crypt(struct AVTWOFISH *ctx, uint8_t *dst, const uint8_t *src, int count, uint8_t* iv, int decrypt); diff --git a/library/FFmpeg/include/libavutil/tx.h b/library/FFmpeg/include/libavutil/tx.h index 55173810..4696988c 100644 --- a/library/FFmpeg/include/libavutil/tx.h +++ b/library/FFmpeg/include/libavutil/tx.h @@ -38,50 +38,99 @@ typedef struct AVComplexInt32 { enum AVTXType { /** - * Standard complex to complex FFT with sample data type AVComplexFloat. + * Standard complex to complex FFT with sample data type of AVComplexFloat, + * AVComplexDouble or AVComplexInt32, for each respective variant. + * * Output is not 1/len normalized. Scaling currently unsupported. - * The stride parameter is ignored. + * The stride parameter must be set to the size of a single sample in bytes. */ - AV_TX_FLOAT_FFT = 0, + AV_TX_FLOAT_FFT = 0, + AV_TX_DOUBLE_FFT = 2, + AV_TX_INT32_FFT = 4, /** - * Standard MDCT with sample data type of float and a scale type of - * float. Length is the frame size, not the window size (which is 2x frame) + * Standard MDCT with a sample data type of float, double or int32_t, + * respecively. For the float and int32 variants, the scale type is + * 'float', while for the double variant, it's 'double'. + * If scale is NULL, 1.0 will be used as a default. + * + * Length is the frame size, not the window size (which is 2x frame). * For forward transforms, the stride specifies the spacing between each * sample in the output array in bytes. The input must be a flat array. * * For inverse transforms, the stride specifies the spacing between each - * sample in the input array in bytes. The output will be a flat array. - * Stride must be a non-zero multiple of sizeof(float). + * sample in the input array in bytes. The output must be a flat array. * * NOTE: the inverse transform is half-length, meaning the output will not * contain redundant data. This is what most codecs work with. To do a full * inverse transform, set the AV_TX_FULL_IMDCT flag on init. */ - AV_TX_FLOAT_MDCT = 1, + AV_TX_FLOAT_MDCT = 1, + AV_TX_DOUBLE_MDCT = 3, + AV_TX_INT32_MDCT = 5, /** - * Same as AV_TX_FLOAT_FFT with a data type of AVComplexDouble. + * Real to complex and complex to real DFTs. + * For the float and int32 variants, the scale type is 'float', while for + * the double variant, it's a 'double'. If scale is NULL, 1.0 will be used + * as a default. + * + * For forward transforms (R2C), stride must be the spacing between two + * samples in bytes. For inverse transforms, the stride must be set + * to the spacing between two complex values in bytes. + * + * The forward transform performs a real-to-complex DFT of N samples to + * N/2+1 complex values. + * + * The inverse transform performs a complex-to-real DFT of N/2+1 complex + * values to N real samples. The output is not normalized, but can be + * made so by setting the scale value to 1.0/len. + * NOTE: the inverse transform always overwrites the input. */ - AV_TX_DOUBLE_FFT = 2, + AV_TX_FLOAT_RDFT = 6, + AV_TX_DOUBLE_RDFT = 7, + AV_TX_INT32_RDFT = 8, /** - * Same as AV_TX_FLOAT_MDCT with data and scale type of double. - * Stride must be a non-zero multiple of sizeof(double). + * Real to real (DCT) transforms. + * + * The forward transform is a DCT-II. + * The inverse transform is a DCT-III. + * + * The input array is always overwritten. DCT-III requires that the + * input be padded with 2 extra samples. Stride must be set to the + * spacing between two samples in bytes. */ - AV_TX_DOUBLE_MDCT = 3, + AV_TX_FLOAT_DCT = 9, + AV_TX_DOUBLE_DCT = 10, + AV_TX_INT32_DCT = 11, /** - * Same as AV_TX_FLOAT_FFT with a data type of AVComplexInt32. + * Discrete Cosine Transform I + * + * The forward transform is a DCT-I. + * The inverse transform is a DCT-I multiplied by 2/(N + 1). + * + * The input array is always overwritten. */ - AV_TX_INT32_FFT = 4, + AV_TX_FLOAT_DCT_I = 12, + AV_TX_DOUBLE_DCT_I = 13, + AV_TX_INT32_DCT_I = 14, /** - * Same as AV_TX_FLOAT_MDCT with data type of int32_t and scale type of float. - * Only scale values less than or equal to 1.0 are supported. - * Stride must be a non-zero multiple of sizeof(int32_t). + * Discrete Sine Transform I + * + * The forward transform is a DST-I. + * The inverse transform is a DST-I multiplied by 2/(N + 1). + * + * The input array is always overwritten. */ - AV_TX_INT32_MDCT = 5, + AV_TX_FLOAT_DST_I = 15, + AV_TX_DOUBLE_DST_I = 16, + AV_TX_INT32_DST_I = 17, + + /* Not part of the API, do not use */ + AV_TX_NB, }; /** @@ -106,9 +155,8 @@ typedef void (*av_tx_fn)(AVTXContext *s, void *out, void *in, ptrdiff_t stride); */ enum AVTXFlags { /** - * Performs an in-place transformation on the input. The output argument - * of av_tn_fn() MUST match the input. May be unsupported or slower for some - * transform types. + * Allows for in-place transformations, where input == output. + * May be unsupported or slower for some transform types. */ AV_TX_INPLACE = 1ULL << 0, @@ -125,6 +173,16 @@ enum AVTXFlags { * Ignored for all transforms but inverse MDCTs. */ AV_TX_FULL_IMDCT = 1ULL << 2, + + /** + * Perform a real to half-complex RDFT. + * Only the real, or imaginary coefficients will + * be output, depending on the flag used. Only available for forward RDFTs. + * Output array must have enough space to hold N complex values + * (regular size for a real to complex transform). + */ + AV_TX_REAL_TO_REAL = 1ULL << 3, + AV_TX_REAL_TO_IMAGINARY = 1ULL << 4, }; /** @@ -145,7 +203,7 @@ int av_tx_init(AVTXContext **ctx, av_tx_fn *tx, enum AVTXType type, int inv, int len, const void *scale, uint64_t flags); /** - * Frees a context and sets ctx to NULL, does nothing when ctx == NULL + * Frees a context and sets *ctx to NULL, does nothing when *ctx == NULL. */ void av_tx_uninit(AVTXContext **ctx); diff --git a/library/FFmpeg/include/libavutil/uuid.h b/library/FFmpeg/include/libavutil/uuid.h new file mode 100644 index 00000000..748b7ed3 --- /dev/null +++ b/library/FFmpeg/include/libavutil/uuid.h @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2022 Pierre-Anthony Lemieux + * Zane van Iperen + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * UUID parsing and serialization utilities. + * The library treats the UUID as an opaque sequence of 16 unsigned bytes, + * i.e. ignoring the internal layout of the UUID, which depends on the type + * of the UUID. + * + * @author Pierre-Anthony Lemieux + * @author Zane van Iperen + */ + +#ifndef AVUTIL_UUID_H +#define AVUTIL_UUID_H + +#include +#include + +#define AV_PRI_UUID \ + "%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-" \ + "%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx" + +#define AV_PRI_URN_UUID \ + "urn:uuid:%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-" \ + "%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx" + +/* AV_UUID_ARG() is used together with AV_PRI_UUID() or AV_PRI_URN_UUID + * to print UUIDs, e.g. + * av_log(NULL, AV_LOG_DEBUG, "UUID: " AV_PRI_UUID, AV_UUID_ARG(uuid)); + */ +#define AV_UUID_ARG(x) \ + (x)[ 0], (x)[ 1], (x)[ 2], (x)[ 3], \ + (x)[ 4], (x)[ 5], (x)[ 6], (x)[ 7], \ + (x)[ 8], (x)[ 9], (x)[10], (x)[11], \ + (x)[12], (x)[13], (x)[14], (x)[15] + +#define AV_UUID_LEN 16 + +/* Binary representation of a UUID */ +typedef uint8_t AVUUID[AV_UUID_LEN]; + +/** + * Parses a string representation of a UUID formatted according to IETF RFC 4122 + * into an AVUUID. The parsing is case-insensitive. The string must be 37 + * characters long, including the terminating NUL character. + * + * Example string representation: "2fceebd0-7017-433d-bafb-d073a7116696" + * + * @param[in] in String representation of a UUID, + * e.g. 2fceebd0-7017-433d-bafb-d073a7116696 + * @param[out] uu AVUUID + * @return A non-zero value in case of an error. + */ +int av_uuid_parse(const char *in, AVUUID uu); + +/** + * Parses a URN representation of a UUID, as specified at IETF RFC 4122, + * into an AVUUID. The parsing is case-insensitive. The string must be 46 + * characters long, including the terminating NUL character. + * + * Example string representation: "urn:uuid:2fceebd0-7017-433d-bafb-d073a7116696" + * + * @param[in] in URN UUID + * @param[out] uu AVUUID + * @return A non-zero value in case of an error. + */ +int av_uuid_urn_parse(const char *in, AVUUID uu); + +/** + * Parses a string representation of a UUID formatted according to IETF RFC 4122 + * into an AVUUID. The parsing is case-insensitive. + * + * @param[in] in_start Pointer to the first character of the string representation + * @param[in] in_end Pointer to the character after the last character of the + * string representation. That memory location is never + * accessed. It is an error if `in_end - in_start != 36`. + * @param[out] uu AVUUID + * @return A non-zero value in case of an error. + */ +int av_uuid_parse_range(const char *in_start, const char *in_end, AVUUID uu); + +/** + * Serializes a AVUUID into a string representation according to IETF RFC 4122. + * The string is lowercase and always 37 characters long, including the + * terminating NUL character. + * + * @param[in] uu AVUUID + * @param[out] out Pointer to an array of no less than 37 characters. + */ +void av_uuid_unparse(const AVUUID uu, char *out); + +/** + * Compares two UUIDs for equality. + * + * @param[in] uu1 AVUUID + * @param[in] uu2 AVUUID + * @return Nonzero if uu1 and uu2 are identical, 0 otherwise + */ +static inline int av_uuid_equal(const AVUUID uu1, const AVUUID uu2) +{ + return memcmp(uu1, uu2, AV_UUID_LEN) == 0; +} + +/** + * Copies the bytes of src into dest. + * + * @param[out] dest AVUUID + * @param[in] src AVUUID + */ +static inline void av_uuid_copy(AVUUID dest, const AVUUID src) +{ + memcpy(dest, src, AV_UUID_LEN); +} + +/** + * Sets a UUID to the nil UUID, i.e. a UUID with have all + * its 128 bits set to zero. + * + * @param[in,out] uu UUID to be set to the nil UUID + */ +static inline void av_uuid_nil(AVUUID uu) +{ + memset(uu, 0, AV_UUID_LEN); +} + +#endif /* AVUTIL_UUID_H */ diff --git a/library/FFmpeg/include/libavutil/version.h b/library/FFmpeg/include/libavutil/version.h index 34b83112..589a42b0 100644 --- a/library/FFmpeg/include/libavutil/version.h +++ b/library/FFmpeg/include/libavutil/version.h @@ -78,8 +78,8 @@ * @{ */ -#define LIBAVUTIL_VERSION_MAJOR 57 -#define LIBAVUTIL_VERSION_MINOR 1 +#define LIBAVUTIL_VERSION_MAJOR 58 +#define LIBAVUTIL_VERSION_MINOR 31 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ @@ -105,15 +105,20 @@ * @{ */ -#ifndef FF_API_D2STR -#define FF_API_D2STR (LIBAVUTIL_VERSION_MAJOR < 58) -#endif -#ifndef FF_API_DECLARE_ALIGNED -#define FF_API_DECLARE_ALIGNED (LIBAVUTIL_VERSION_MAJOR < 58) -#endif -#ifndef FF_API_COLORSPACE_NAME -#define FF_API_COLORSPACE_NAME (LIBAVUTIL_VERSION_MAJOR < 58) -#endif +#define FF_API_FIFO_PEEK2 (LIBAVUTIL_VERSION_MAJOR < 59) +#define FF_API_FIFO_OLD_API (LIBAVUTIL_VERSION_MAJOR < 59) +#define FF_API_XVMC (LIBAVUTIL_VERSION_MAJOR < 59) +#define FF_API_OLD_CHANNEL_LAYOUT (LIBAVUTIL_VERSION_MAJOR < 59) +#define FF_API_AV_FOPEN_UTF8 (LIBAVUTIL_VERSION_MAJOR < 59) +#define FF_API_PKT_DURATION (LIBAVUTIL_VERSION_MAJOR < 59) +#define FF_API_REORDERED_OPAQUE (LIBAVUTIL_VERSION_MAJOR < 59) +#define FF_API_FRAME_PICTURE_NUMBER (LIBAVUTIL_VERSION_MAJOR < 59) +#define FF_API_HDR_VIVID_THREE_SPLINE (LIBAVUTIL_VERSION_MAJOR < 59) +#define FF_API_FRAME_PKT (LIBAVUTIL_VERSION_MAJOR < 59) +#define FF_API_INTERLACED_FRAME (LIBAVUTIL_VERSION_MAJOR < 59) +#define FF_API_FRAME_KEY (LIBAVUTIL_VERSION_MAJOR < 59) +#define FF_API_PALETTE_HAS_CHANGED (LIBAVUTIL_VERSION_MAJOR < 59) +#define FF_API_VULKAN_CONTIGUOUS_MEMORY (LIBAVUTIL_VERSION_MAJOR < 59) /** * @} diff --git a/library/FFmpeg/include/libavutil/video_enc_params.h b/library/FFmpeg/include/libavutil/video_enc_params.h index fc0c3bc1..62265a5c 100644 --- a/library/FFmpeg/include/libavutil/video_enc_params.h +++ b/library/FFmpeg/include/libavutil/video_enc_params.h @@ -136,8 +136,8 @@ typedef struct AVVideoBlockParams { int32_t delta_qp; } AVVideoBlockParams; -/* - * Get the block at the specified {@code idx}. Must be between 0 and nb_blocks. +/** + * Get the block at the specified {@code idx}. Must be between 0 and nb_blocks - 1. */ static av_always_inline AVVideoBlockParams* av_video_enc_params_block(AVVideoEncParams *par, unsigned int idx) diff --git a/library/FFmpeg/include/libavutil/video_hint.h b/library/FFmpeg/include/libavutil/video_hint.h new file mode 100644 index 00000000..1b219609 --- /dev/null +++ b/library/FFmpeg/include/libavutil/video_hint.h @@ -0,0 +1,107 @@ +/** + * Copyright 2023 Elias Carotti + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_VIDEO_HINT_H +#define AVUTIL_VIDEO_HINT_H + +#include +#include +#include "libavutil/avassert.h" +#include "libavutil/frame.h" + +typedef struct AVVideoRect { + uint32_t x, y; + uint32_t width, height; +} AVVideoRect; + +typedef enum AVVideoHintType { + /* rectangled delimit the constant areas (unchanged), default is changed */ + AV_VIDEO_HINT_TYPE_CONSTANT, + + /* rectangled delimit the constant areas (changed), default is not changed */ + AV_VIDEO_HINT_TYPE_CHANGED, +} AVVideoHintType; + +typedef struct AVVideoHint { + /** + * Number of AVVideoRect present. + * + * May be 0, in which case no per-rectangle information is present. In this + * case the values of rect_offset / rect_size are unspecified and should + * not be accessed. + */ + size_t nb_rects; + + /** + * Offset in bytes from the beginning of this structure at which the array + * of AVVideoRect starts. + */ + size_t rect_offset; + + /** + * Size in bytes of AVVideoRect. + */ + size_t rect_size; + + AVVideoHintType type; +} AVVideoHint; + +static av_always_inline AVVideoRect * +av_video_hint_rects(const AVVideoHint *hints) { + return (AVVideoRect *)((uint8_t *)hints + hints->rect_offset); +} + +static av_always_inline AVVideoRect * +av_video_hint_get_rect(const AVVideoHint *hints, size_t idx) { + return (AVVideoRect *)((uint8_t *)hints + hints->rect_offset + idx * hints->rect_size); +} + +/** + * Allocate memory for the AVVideoHint struct along with an nb_rects-sized + * arrays of AVVideoRect. + * + * The side data contains a list of rectangles for the portions of the frame + * which changed from the last encoded one (and the remainder are assumed to be + * changed), or, alternately (depending on the type parameter) the unchanged + * ones (and the remanining ones are those which changed). + * Macroblocks will thus be hinted either to be P_SKIP-ped or go through the + * regular encoding procedure. + * + * It's responsibility of the caller to fill the AVRects accordingly, and to set + * the proper AVVideoHintType field. + * + * @param out_size if non-NULL, the size in bytes of the resulting data array is + * written here + * + * @return newly allocated AVVideoHint struct (must be freed by the caller using + * av_free()) on success, NULL on memory allocation failure + */ +AVVideoHint *av_video_hint_alloc(size_t nb_rects, + size_t *out_size); + +/** + * Same as av_video_hint_alloc(), except newly-allocated AVVideoHint is attached + * as side data of type AV_FRAME_DATA_VIDEO_HINT_INFO to frame. + */ +AVVideoHint *av_video_hint_create_side_data(AVFrame *frame, + size_t nb_rects); + + +#endif /* AVUTIL_VIDEO_HINT_H */ diff --git a/library/FFmpeg/include/libswresample/swresample.h b/library/FFmpeg/include/libswresample/swresample.h index c7b84fbc..d4dcaebd 100644 --- a/library/FFmpeg/include/libswresample/swresample.h +++ b/library/FFmpeg/include/libswresample/swresample.h @@ -34,11 +34,11 @@ * Audio resampling, sample format conversion and mixing library. * * Interaction with lswr is done through SwrContext, which is - * allocated with swr_alloc() or swr_alloc_set_opts(). It is opaque, so all parameters + * allocated with swr_alloc() or swr_alloc_set_opts2(). It is opaque, so all parameters * must be set with the @ref avoptions API. * * The first thing you will need to do in order to use lswr is to allocate - * SwrContext. This can be done with swr_alloc() or swr_alloc_set_opts(). If you + * SwrContext. This can be done with swr_alloc() or swr_alloc_set_opts2(). If you * are using the former, you must set options through the @ref avoptions API. * The latter function provides the same feature, but it allows you to set some * common options in the same statement. @@ -57,13 +57,14 @@ * av_opt_set_sample_fmt(swr, "out_sample_fmt", AV_SAMPLE_FMT_S16, 0); * @endcode * - * The same job can be done using swr_alloc_set_opts() as well: + * The same job can be done using swr_alloc_set_opts2() as well: * @code - * SwrContext *swr = swr_alloc_set_opts(NULL, // we're allocating a new context - * AV_CH_LAYOUT_STEREO, // out_ch_layout + * SwrContext *swr = NULL; + * int ret = swr_alloc_set_opts2(&swr, // we're allocating a new context + * &(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO, // out_ch_layout * AV_SAMPLE_FMT_S16, // out_sample_fmt * 44100, // out_sample_rate - * AV_CH_LAYOUT_5POINT1, // in_ch_layout + * &(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT1, // in_ch_layout * AV_SAMPLE_FMT_FLTP, // in_sample_fmt * 48000, // in_sample_rate * 0, // log_offset @@ -72,8 +73,8 @@ * * Once all values have been set, it must be initialized with swr_init(). If * you need to change the conversion parameters, you can change the parameters - * using @ref AVOptions, as described above in the first example; or by using - * swr_alloc_set_opts(), but with the first argument the allocated context. + * using @ref avoptions, as described above in the first example; or by using + * swr_alloc_set_opts2(), but with the first argument the allocated context. * You must then call swr_init() again. * * The conversion itself is done by repeatedly calling swr_convert(). @@ -124,7 +125,13 @@ #include "libavutil/frame.h" #include "libavutil/samplefmt.h" +#include "libswresample/version_major.h" +#ifndef HAVE_AV_CONFIG_H +/* When included as part of the ffmpeg build, only include the major version + * to avoid unnecessary rebuilds. When included externally, keep including + * the full version information. */ #include "libswresample/version.h" +#endif /** * @name Option constants @@ -199,9 +206,9 @@ const AVClass *swr_get_class(void); * Allocate SwrContext. * * If you use this function you will need to set the parameters (manually or - * with swr_alloc_set_opts()) before calling swr_init(). + * with swr_alloc_set_opts2()) before calling swr_init(). * - * @see swr_alloc_set_opts(), swr_init(), swr_free() + * @see swr_alloc_set_opts2(), swr_init(), swr_free() * @return NULL on error, allocated context otherwise */ struct SwrContext *swr_alloc(void); @@ -227,6 +234,7 @@ int swr_init(struct SwrContext *s); */ int swr_is_initialized(struct SwrContext *s); +#if FF_API_OLD_CHANNEL_LAYOUT /** * Allocate SwrContext if needed and set/reset common parameters. * @@ -246,12 +254,41 @@ int swr_is_initialized(struct SwrContext *s); * * @see swr_init(), swr_free() * @return NULL on error, allocated context otherwise + * @deprecated use @ref swr_alloc_set_opts2() */ +attribute_deprecated struct SwrContext *swr_alloc_set_opts(struct SwrContext *s, int64_t out_ch_layout, enum AVSampleFormat out_sample_fmt, int out_sample_rate, int64_t in_ch_layout, enum AVSampleFormat in_sample_fmt, int in_sample_rate, int log_offset, void *log_ctx); +#endif +/** + * Allocate SwrContext if needed and set/reset common parameters. + * + * This function does not require *ps to be allocated with swr_alloc(). On the + * other hand, swr_alloc() can use swr_alloc_set_opts2() to set the parameters + * on the allocated context. + * + * @param ps Pointer to an existing Swr context if available, or to NULL if not. + * On success, *ps will be set to the allocated context. + * @param out_ch_layout output channel layout (e.g. AV_CHANNEL_LAYOUT_*) + * @param out_sample_fmt output sample format (AV_SAMPLE_FMT_*). + * @param out_sample_rate output sample rate (frequency in Hz) + * @param in_ch_layout input channel layout (e.g. AV_CHANNEL_LAYOUT_*) + * @param in_sample_fmt input sample format (AV_SAMPLE_FMT_*). + * @param in_sample_rate input sample rate (frequency in Hz) + * @param log_offset logging level offset + * @param log_ctx parent logging context, can be NULL + * + * @see swr_init(), swr_free() + * @return 0 on success, a negative AVERROR code on error. + * On error, the Swr context is freed and *ps set to NULL. + */ +int swr_alloc_set_opts2(struct SwrContext **ps, + const AVChannelLayout *out_ch_layout, enum AVSampleFormat out_sample_fmt, int out_sample_rate, + const AVChannelLayout *in_ch_layout, enum AVSampleFormat in_sample_fmt, int in_sample_rate, + int log_offset, void *log_ctx); /** * @} * @@ -317,8 +354,8 @@ int swr_convert(struct SwrContext *s, uint8_t **out, int out_count, * in this case the output timestamps will match output sample numbers. * See ffmpeg-resampler(1) for the two modes of compensation. * - * @param s[in] initialized Swr context - * @param pts[in] timestamp for the next input sample, INT64_MIN if unknown + * @param[in] s initialized Swr context + * @param[in] pts timestamp for the next input sample, INT64_MIN if unknown * @see swr_set_compensation(), swr_drop_output(), and swr_inject_silence() are * function used internally for timestamp compensation. * @return the output timestamp for the next output sample @@ -362,6 +399,7 @@ int swr_set_compensation(struct SwrContext *s, int sample_delta, int compensatio */ int swr_set_channel_mapping(struct SwrContext *s, const int *channel_map); +#if FF_API_OLD_CHANNEL_LAYOUT /** * Generate a channel mixing matrix. * @@ -384,13 +422,46 @@ int swr_set_channel_mapping(struct SwrContext *s, const int *channel_map); * @param matrix_encoding matrixed stereo downmix mode (e.g. dplii) * @param log_ctx parent logging context, can be NULL * @return 0 on success, negative AVERROR code on failure + * @deprecated use @ref swr_build_matrix2() */ +attribute_deprecated int swr_build_matrix(uint64_t in_layout, uint64_t out_layout, double center_mix_level, double surround_mix_level, double lfe_mix_level, double rematrix_maxval, double rematrix_volume, double *matrix, int stride, enum AVMatrixEncoding matrix_encoding, void *log_ctx); +#endif + +/** + * Generate a channel mixing matrix. + * + * This function is the one used internally by libswresample for building the + * default mixing matrix. It is made public just as a utility function for + * building custom matrices. + * + * @param in_layout input channel layout + * @param out_layout output channel layout + * @param center_mix_level mix level for the center channel + * @param surround_mix_level mix level for the surround channel(s) + * @param lfe_mix_level mix level for the low-frequency effects channel + * @param rematrix_maxval if 1.0, coefficients will be normalized to prevent + * overflow. if INT_MAX, coefficients will not be + * normalized. + * @param[out] matrix mixing coefficients; matrix[i + stride * o] is + * the weight of input channel i in output channel o. + * @param stride distance between adjacent input channels in the + * matrix array + * @param matrix_encoding matrixed stereo downmix mode (e.g. dplii) + * @param log_ctx parent logging context, can be NULL + * @return 0 on success, negative AVERROR code on failure + */ +int swr_build_matrix2(const AVChannelLayout *in_layout, const AVChannelLayout *out_layout, + double center_mix_level, double surround_mix_level, + double lfe_mix_level, double maxval, + double rematrix_volume, double *matrix, + ptrdiff_t stride, enum AVMatrixEncoding matrix_encoding, + void *log_context); /** * Set a customized remix matrix. @@ -565,8 +636,8 @@ int swr_convert_frame(SwrContext *swr, * @see swr_close(); * * @param swr audio resample context - * @param output output AVFrame - * @param input input AVFrame + * @param out output AVFrame + * @param in input AVFrame * @return 0 on success, AVERROR on failure. */ int swr_config_frame(SwrContext *swr, const AVFrame *out, const AVFrame *in); diff --git a/library/FFmpeg/include/libswresample/version.h b/library/FFmpeg/include/libswresample/version.h index ed7ce529..46a4e2fc 100644 --- a/library/FFmpeg/include/libswresample/version.h +++ b/library/FFmpeg/include/libswresample/version.h @@ -26,10 +26,11 @@ * Libswresample version macros */ -#include "libavutil/avutil.h" +#include "libavutil/version.h" -#define LIBSWRESAMPLE_VERSION_MAJOR 4 -#define LIBSWRESAMPLE_VERSION_MINOR 0 +#include "version_major.h" + +#define LIBSWRESAMPLE_VERSION_MINOR 13 #define LIBSWRESAMPLE_VERSION_MICRO 100 #define LIBSWRESAMPLE_VERSION_INT AV_VERSION_INT(LIBSWRESAMPLE_VERSION_MAJOR, \ diff --git a/library/FFmpeg/include/libswresample/version_major.h b/library/FFmpeg/include/libswresample/version_major.h new file mode 100644 index 00000000..7f265c20 --- /dev/null +++ b/library/FFmpeg/include/libswresample/version_major.h @@ -0,0 +1,31 @@ +/* + * Version macros. + * + * This file is part of libswresample + * + * libswresample is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * libswresample is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with libswresample; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef SWRESAMPLE_VERSION_MAJOR_H +#define SWRESAMPLE_VERSION_MAJOR_H + +/** + * @file + * Libswresample version macros + */ + +#define LIBSWRESAMPLE_VERSION_MAJOR 4 + +#endif /* SWRESAMPLE_VERSION_MAJOR_H */ diff --git a/library/FFmpeg/include/libswscale/swscale.h b/library/FFmpeg/include/libswscale/swscale.h index 50d6d465..9d4612aa 100644 --- a/library/FFmpeg/include/libswscale/swscale.h +++ b/library/FFmpeg/include/libswscale/swscale.h @@ -30,9 +30,16 @@ #include #include "libavutil/avutil.h" +#include "libavutil/frame.h" #include "libavutil/log.h" #include "libavutil/pixfmt.h" +#include "version_major.h" +#ifndef HAVE_AV_CONFIG_H +/* When included as part of the ffmpeg build, only include the major version + * to avoid unnecessary rebuilds. When included externally, keep including + * the full version information. */ #include "version.h" +#endif /** * @defgroup libsws libswscale @@ -219,6 +226,107 @@ int sws_scale(struct SwsContext *c, const uint8_t *const srcSlice[], uint8_t *const dst[], const int dstStride[]); /** + * Scale source data from src and write the output to dst. + * + * This is merely a convenience wrapper around + * - sws_frame_start() + * - sws_send_slice(0, src->height) + * - sws_receive_slice(0, dst->height) + * - sws_frame_end() + * + * @param c The scaling context + * @param dst The destination frame. See documentation for sws_frame_start() for + * more details. + * @param src The source frame. + * + * @return 0 on success, a negative AVERROR code on failure + */ +int sws_scale_frame(struct SwsContext *c, AVFrame *dst, const AVFrame *src); + +/** + * Initialize the scaling process for a given pair of source/destination frames. + * Must be called before any calls to sws_send_slice() and sws_receive_slice(). + * + * This function will retain references to src and dst, so they must both use + * refcounted buffers (if allocated by the caller, in case of dst). + * + * @param c The scaling context + * @param dst The destination frame. + * + * The data buffers may either be already allocated by the caller or + * left clear, in which case they will be allocated by the scaler. + * The latter may have performance advantages - e.g. in certain cases + * some output planes may be references to input planes, rather than + * copies. + * + * Output data will be written into this frame in successful + * sws_receive_slice() calls. + * @param src The source frame. The data buffers must be allocated, but the + * frame data does not have to be ready at this point. Data + * availability is then signalled by sws_send_slice(). + * @return 0 on success, a negative AVERROR code on failure + * + * @see sws_frame_end() + */ +int sws_frame_start(struct SwsContext *c, AVFrame *dst, const AVFrame *src); + +/** + * Finish the scaling process for a pair of source/destination frames previously + * submitted with sws_frame_start(). Must be called after all sws_send_slice() + * and sws_receive_slice() calls are done, before any new sws_frame_start() + * calls. + * + * @param c The scaling context + */ +void sws_frame_end(struct SwsContext *c); + +/** + * Indicate that a horizontal slice of input data is available in the source + * frame previously provided to sws_frame_start(). The slices may be provided in + * any order, but may not overlap. For vertically subsampled pixel formats, the + * slices must be aligned according to subsampling. + * + * @param c The scaling context + * @param slice_start first row of the slice + * @param slice_height number of rows in the slice + * + * @return a non-negative number on success, a negative AVERROR code on failure. + */ +int sws_send_slice(struct SwsContext *c, unsigned int slice_start, + unsigned int slice_height); + +/** + * Request a horizontal slice of the output data to be written into the frame + * previously provided to sws_frame_start(). + * + * @param c The scaling context + * @param slice_start first row of the slice; must be a multiple of + * sws_receive_slice_alignment() + * @param slice_height number of rows in the slice; must be a multiple of + * sws_receive_slice_alignment(), except for the last slice + * (i.e. when slice_start+slice_height is equal to output + * frame height) + * + * @return a non-negative number if the data was successfully written into the output + * AVERROR(EAGAIN) if more input data needs to be provided before the + * output can be produced + * another negative AVERROR code on other kinds of scaling failure + */ +int sws_receive_slice(struct SwsContext *c, unsigned int slice_start, + unsigned int slice_height); + +/** + * Get the alignment required for slices + * + * @param c The scaling context + * @return alignment required for output slices requested with sws_receive_slice(). + * Slice offsets and sizes passed to sws_receive_slice() must be + * multiples of the value returned from this function. + */ +unsigned int sws_receive_slice_alignment(const struct SwsContext *c); + +/** + * @param c the scaling context * @param dstRange flag indicating the while-black range of the output (1=jpeg / 0=mpeg) * @param srcRange flag indicating the while-black range of the input (1=jpeg / 0=mpeg) * @param table the yuv2rgb coefficients describing the output yuv space, normally ff_yuv2rgb_coeffs[x] @@ -226,14 +334,17 @@ int sws_scale(struct SwsContext *c, const uint8_t *const srcSlice[], * @param brightness 16.16 fixed point brightness correction * @param contrast 16.16 fixed point contrast correction * @param saturation 16.16 fixed point saturation correction - * @return -1 if not supported + * + * @return A negative error code on error, non negative otherwise. + * If `LIBSWSCALE_VERSION_MAJOR < 7`, returns -1 if not supported. */ int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4], int srcRange, const int table[4], int dstRange, int brightness, int contrast, int saturation); /** - * @return -1 if not supported + * @return A negative error code on error, non negative otherwise. + * If `LIBSWSCALE_VERSION_MAJOR < 7`, returns -1 if not supported. */ int sws_getColorspaceDetails(struct SwsContext *c, int **inv_table, int *srcRange, int **table, int *dstRange, diff --git a/library/FFmpeg/include/libswscale/version.h b/library/FFmpeg/include/libswscale/version.h index f86a8049..f573bef6 100644 --- a/library/FFmpeg/include/libswscale/version.h +++ b/library/FFmpeg/include/libswscale/version.h @@ -26,8 +26,9 @@ #include "libavutil/version.h" -#define LIBSWSCALE_VERSION_MAJOR 6 -#define LIBSWSCALE_VERSION_MINOR 0 +#include "version_major.h" + +#define LIBSWSCALE_VERSION_MINOR 6 #define LIBSWSCALE_VERSION_MICRO 100 #define LIBSWSCALE_VERSION_INT AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \ @@ -40,10 +41,4 @@ #define LIBSWSCALE_IDENT "SwS" AV_STRINGIFY(LIBSWSCALE_VERSION) -/** - * FF_API_* defines may be placed below to indicate public API that will be - * dropped at a future version bump. The defines themselves are not part of - * the public API and may change, break or disappear at any time. - */ - #endif /* SWSCALE_VERSION_H */ diff --git a/library/FFmpeg/include/libswscale/version_major.h b/library/FFmpeg/include/libswscale/version_major.h new file mode 100644 index 00000000..88577a2b --- /dev/null +++ b/library/FFmpeg/include/libswscale/version_major.h @@ -0,0 +1,35 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef SWSCALE_VERSION_MAJOR_H +#define SWSCALE_VERSION_MAJOR_H + +/** + * @file + * swscale version macros + */ + +#define LIBSWSCALE_VERSION_MAJOR 7 + +/** + * FF_API_* defines may be placed below to indicate public API that will be + * dropped at a future version bump. The defines themselves are not part of + * the public API and may change, break or disappear at any time. + */ + +#endif /* SWSCALE_VERSION_MAJOR_H */ diff --git a/library/FFmpeg/lib/libavcodec.a b/library/FFmpeg/lib/libavcodec.a index 24908756..bb538e5f 100644 Binary files a/library/FFmpeg/lib/libavcodec.a and b/library/FFmpeg/lib/libavcodec.a differ diff --git a/library/FFmpeg/lib/libavfilter.a b/library/FFmpeg/lib/libavfilter.a index a7c98d36..f80d9105 100644 Binary files a/library/FFmpeg/lib/libavfilter.a and b/library/FFmpeg/lib/libavfilter.a differ diff --git a/library/FFmpeg/lib/libavformat.a b/library/FFmpeg/lib/libavformat.a index e019377f..19ebbd91 100644 Binary files a/library/FFmpeg/lib/libavformat.a and b/library/FFmpeg/lib/libavformat.a differ diff --git a/library/FFmpeg/lib/libavutil.a b/library/FFmpeg/lib/libavutil.a index 13fc710c..4b8975d3 100644 Binary files a/library/FFmpeg/lib/libavutil.a and b/library/FFmpeg/lib/libavutil.a differ diff --git a/library/FFmpeg/lib/libswresample.a b/library/FFmpeg/lib/libswresample.a index b010783d..d48c6c20 100644 Binary files a/library/FFmpeg/lib/libswresample.a and b/library/FFmpeg/lib/libswresample.a differ diff --git a/library/FFmpeg/lib/libswscale.a b/library/FFmpeg/lib/libswscale.a index 5a302c7f..a45f09aa 100644 Binary files a/library/FFmpeg/lib/libswscale.a and b/library/FFmpeg/lib/libswscale.a differ diff --git a/library/libctru/include/3ds.h b/library/libctru/include/3ds.h index 9aeb842d..141c6ccc 100644 --- a/library/libctru/include/3ds.h +++ b/library/libctru/include/3ds.h @@ -79,6 +79,7 @@ extern "C" { #include <3ds/services/loader.h> #include <3ds/services/y2r.h> #include <3ds/services/mcuhwc.h> +#include <3ds/services/cdcchk.h> #include <3ds/gpu/gx.h> #include <3ds/gpu/gpu.h> diff --git a/library/libctru/include/3ds/allocator/linear.h b/library/libctru/include/3ds/allocator/linear.h index 1e993676..56135a99 100644 --- a/library/libctru/include/3ds/allocator/linear.h +++ b/library/libctru/include/3ds/allocator/linear.h @@ -4,6 +4,8 @@ */ #pragma once +#include + /** * @brief Allocates a 0x80-byte aligned buffer. * @param size Size of the buffer to allocate. diff --git a/library/libctru/include/3ds/errf.h b/library/libctru/include/3ds/errf.h index f1c10b53..ea830b43 100644 --- a/library/libctru/include/3ds/errf.h +++ b/library/libctru/include/3ds/errf.h @@ -9,12 +9,12 @@ /// Types of errors that can be thrown by err:f. typedef enum { - ERRF_ERRTYPE_GENERIC = 0, ///< For generic errors. Shows miscellaneous info. - ERRF_ERRTYPE_MEM_CORRUPT = 1, ///< Same output as generic, but informs the user that "the System Memory has been damaged". - ERRF_ERRTYPE_CARD_REMOVED = 2, ///< Displays the "The Game Card was removed." message. - ERRF_ERRTYPE_EXCEPTION = 3, ///< For exceptions, or more specifically 'crashes'. union data should be exception_data. - ERRF_ERRTYPE_FAILURE = 4, ///< For general failure. Shows a message. union data should have a string set in failure_mesg - ERRF_ERRTYPE_LOGGED = 5, ///< Outputs logs to NAND in some cases. + ERRF_ERRTYPE_GENERIC = 0, ///< Generic fatal error. Shows miscellaneous info, including the address of the caller + ERRF_ERRTYPE_NAND_DAMAGED = 1, ///< Damaged NAND (CC_ERROR after reading CSR) + ERRF_ERRTYPE_CARD_REMOVED = 2, ///< Game content storage medium (cartridge and/or SD card) ejected. Not logged + ERRF_ERRTYPE_EXCEPTION = 3, ///< CPU or VFP exception + ERRF_ERRTYPE_FAILURE = 4, ///< Fatal error with a message instead of the caller's address + ERRF_ERRTYPE_LOG_ONLY = 5, ///< Log-level failure. Does not display the exception and does not force the system to reboot } ERRF_ErrType; /// Types of 'Exceptions' thrown for ERRF_ERRTYPE_EXCEPTION @@ -46,12 +46,12 @@ typedef struct { u16 revLow; ///< Low revision ID u32 resCode; ///< Result code u32 pcAddr; ///< PC address at exception - u32 procId; ///< Process ID. - u64 titleId; ///< Title ID. - u64 appTitleId; ///< Application Title ID. + u32 procId; ///< Process ID of the caller + u64 titleId; ///< Title ID of the caller + u64 appTitleId; ///< Title ID of the running application union { ERRF_ExceptionData exception_data; ///< Data for when type is ERRF_ERRTYPE_EXCEPTION - char failure_mesg[0x60]; ///< String for when type is ERRF_ERRTYPE_FAILURE + char failure_mesg[0x60]; ///< String for when type is ERRF_ERRTYPE_FAILURE } data; ///< The different types of data for errors. } ERRF_FatalErrInfo; @@ -68,13 +68,19 @@ void errfExit(void); Handle *errfGetSessionHandle(void); /** - * @brief Throws a system error and possibly results in ErrDisp triggering. + * @brief Throws a system error and possibly logs it. * @param[in] error Error to throw. * - * After performing this, the system may panic and need to be rebooted. Extra information will be displayed on the - * top screen with a developer console or the proper patches in a CFW applied. + * ErrDisp may convert the error info to \ref ERRF_ERRTYPE_NAND_DAMAGED or \ref ERRF_ERRTYPE_CARD_REMOVED + * depending on the error code. * - * The error may not be shown and execution aborted until errfExit(void) is called. + * Except with \ref ERRF_ERRTYPE_LOG_ONLY, the system will panic and will need to be rebooted. + * Fatal error information will also be logged into a file, unless the type either \ref ERRF_ERRTYPE_NAND_DAMAGED + * or \ref ERRF_ERRTYPE_CARD_REMOVED. + * + * No error will be shown if the system is asleep. + * + * On retail units with vanilla firmware, no detailed information will be displayed on screen. * * You may wish to use ERRF_ThrowResult() or ERRF_ThrowResultWithMessage() instead of * constructing the ERRF_FatalErrInfo struct yourself. @@ -82,35 +88,44 @@ Handle *errfGetSessionHandle(void); Result ERRF_Throw(const ERRF_FatalErrInfo* error); /** - * @brief Throws a system error with the given Result code. + * @brief Throws (and logs) a system error with the given Result code. * @param[in] failure Result code to throw. * - * This calls ERRF_Throw() with error type ERRF_ERRTYPE_GENERIC and fills in the required data. + * This calls \ref ERRF_Throw with error type \ref ERRF_ERRTYPE_GENERIC and fills in the required data. * * This function \em does fill in the address where this function was called from. - * - * See https://3dbrew.org/wiki/ERR:Throw#Generic for expected top screen output - * on development units/patched ErrDisp. */ Result ERRF_ThrowResult(Result failure); +/** + * @brief Logs a system error with the given Result code. + * @param[in] failure Result code to log. + * + * Similar to \ref ERRF_Throw, except that it does not display anything on the screen, + * nor does it force the system to reboot. + * + * This function \em does fill in the address where this function was called from. + */ +Result ERRF_LogResult(Result failure); + /** * @brief Throws a system error with the given Result code and message. * @param[in] failure Result code to throw. * @param[in] message The message to display. * - * This calls ERRF_Throw() with error type ERRF_ERRTYPE_FAILURE and fills in the required data. + * This calls \ref ERRF_Throw with error type \ref ERRF_ERRTYPE_FAILURE and fills in the required data. * * This function does \em not fill in the address where this function was called from because it * would not be displayed. - * - * The message is only displayed on development units/patched ErrDisp. - * - * See https://3dbrew.org/wiki/ERR:Throw#Result_Failure for expected top screen output - * on development units/patched ErrDisp. */ Result ERRF_ThrowResultWithMessage(Result failure, const char* message); +/** + * @brief Specify an additional user string to use for error reporting. + * @param[in] user_string User string (up to 256 bytes, not including NUL byte) + */ +Result ERRF_SetUserString(const char* user_string); + /** * @brief Handles an exception using ErrDisp. * @param excep Exception information diff --git a/library/libctru/include/3ds/gfx.h b/library/libctru/include/3ds/gfx.h index 9d65b052..b1502c3f 100644 --- a/library/libctru/include/3ds/gfx.h +++ b/library/libctru/include/3ds/gfx.h @@ -166,7 +166,7 @@ void gfxScreenSwapBuffers(gfxScreen_t scr, bool hasStereo); * @param immediate This parameter no longer has any effect and is thus ignored. * @deprecated This function has been superseded by \ref gfxScreenSwapBuffers, please use that instead. */ -DEPRECATED void gfxConfigScreen(gfxScreen_t scr, bool immediate); +CTR_DEPRECATED void gfxConfigScreen(gfxScreen_t scr, bool immediate); /** * @brief Updates the configuration of both screens. diff --git a/library/libctru/include/3ds/gpu/enums.h b/library/libctru/include/3ds/gpu/enums.h index 76ac488c..45f81773 100644 --- a/library/libctru/include/3ds/gpu/enums.h +++ b/library/libctru/include/3ds/gpu/enums.h @@ -368,7 +368,8 @@ typedef enum GPU_ADD_SIGNED = 0x03, ///< Signed add. GPU_INTERPOLATE = 0x04, ///< Interpolate. GPU_SUBTRACT = 0x05, ///< Subtract. - GPU_DOT3_RGB = 0x06, ///< Dot3. RGB only. + GPU_DOT3_RGB = 0x06, ///< Dot3. Scalar result is written to RGB only. + GPU_DOT3_RGBA = 0x07, ///< Dot3. Scalar result is written to RGBA. GPU_MULTIPLY_ADD = 0x08, ///< Multiply then add. GPU_ADD_MULTIPLY = 0x09, ///< Add then multiply. } GPU_COMBINEFUNC; diff --git a/library/libctru/include/3ds/ipc.h b/library/libctru/include/3ds/ipc.h index e3a44b45..4c4ff82e 100644 --- a/library/libctru/include/3ds/ipc.h +++ b/library/libctru/include/3ds/ipc.h @@ -70,7 +70,7 @@ static inline u32 IPC_Desc_CurProcessId(void) return 0x20; } -static inline DEPRECATED u32 IPC_Desc_CurProcessHandle(void) +static inline CTR_DEPRECATED u32 IPC_Desc_CurProcessHandle(void) { return IPC_Desc_CurProcessId(); } diff --git a/library/libctru/include/3ds/mii.h b/library/libctru/include/3ds/mii.h index 692ceccf..fc395d95 100644 --- a/library/libctru/include/3ds/mii.h +++ b/library/libctru/include/3ds/mii.h @@ -147,7 +147,7 @@ typedef struct } glasses_details; /// Mole details - struct + struct { bool enable : 1; u16 scale : 5; @@ -156,4 +156,4 @@ typedef struct } mole_details; u16 author_name[10]; ///< Name of Mii's author (Encoded using UTF16) -} PACKED MiiData; +} CTR_PACKED MiiData; diff --git a/library/libctru/include/3ds/ndsp/channel.h b/library/libctru/include/3ds/ndsp/channel.h index d3c81b49..b2335940 100644 --- a/library/libctru/include/3ds/ndsp/channel.h +++ b/library/libctru/include/3ds/ndsp/channel.h @@ -107,6 +107,14 @@ void ndspChnSetPaused(int id, bool paused); */ void ndspChnSetFormat(int id, u16 format); +/** + * + * @brief Gets the format of a channel. + * @param id ID of the channel (0..23). + * @return The format of the channel. + */ +u16 ndspChnGetFormat(int id); + /** * @brief Sets the interpolation type of a channel. * @param id ID of the channel (0..23). @@ -114,6 +122,13 @@ void ndspChnSetFormat(int id, u16 format); */ void ndspChnSetInterp(int id, ndspInterpType type); +/** + * @brief Gets the interpolation type of a channel. + * @param id ID of the channel (0..23). + * @return The interpolation type of the channel. + */ +ndspInterpType ndspChnGetInterp(int id); + /** * @brief Sets the sample rate of a channel. * @param id ID of the channel (0..23). @@ -121,6 +136,13 @@ void ndspChnSetInterp(int id, ndspInterpType type); */ void ndspChnSetRate(int id, float rate); +/** + * @brief Gets the sample rate of a channel. + * @param id ID of the channel (0..23). + * @return The sample rate of the channel. + */ +float ndspChnGetRate(int id); + /** * @brief Sets the mix parameters (volumes) of a channel. * @param id ID of the channel (0..23). @@ -134,6 +156,13 @@ void ndspChnSetRate(int id, float rate); */ void ndspChnSetMix(int id, float mix[12]); +/** + * @brief Gets the mix parameters (volumes) of a channel. + * @param id ID of the channel (0..23) + * @param mix Mix parameters to write out to. See \ref ndspChnSetMix. + */ +void ndspChnGetMix(int id, float mix[12]); + /** * @brief Sets the DSPADPCM coefficients of a channel. * @param id ID of the channel (0..23). diff --git a/library/libctru/include/3ds/ndsp/ndsp.h b/library/libctru/include/3ds/ndsp/ndsp.h index 928d3ee1..9673ccfb 100644 --- a/library/libctru/include/3ds/ndsp/ndsp.h +++ b/library/libctru/include/3ds/ndsp/ndsp.h @@ -118,24 +118,48 @@ u32 ndspGetFrameCount(void); */ void ndspSetMasterVol(float volume); +/** + * @brief Gets the master volume. + * @return The master volume. + */ +float ndspGetMasterVol(void); + /** * @brief Sets the output mode. * @param mode Output mode to set. Defaults to NDSP_OUTPUT_STEREO. */ void ndspSetOutputMode(ndspOutputMode mode); +/** + * @brief Gets the output mode. + * @return The output mode. + */ +ndspOutputMode ndspGetOutputMode(void); + /** * @brief Sets the clipping mode. * @param mode Clipping mode to set. Defaults to NDSP_CLIP_SOFT. */ void ndspSetClippingMode(ndspClippingMode mode); +/** + * @brief Gets the clipping mode. + * @return The clipping mode. + */ +ndspClippingMode ndspGetClippingMode(void); + /** * @brief Sets the output count. * @param count Output count to set. Defaults to 2. */ void ndspSetOutputCount(int count); +/** + * @brief Gets the output count. + * @return The output count. + */ +int ndspGetOutputCount(void); + /** * @brief Sets the wave buffer to capture audio to. * @param capture Wave buffer to capture to. @@ -158,17 +182,35 @@ void ndspSetCallback(ndspCallback callback, void* data); */ void ndspSurroundSetDepth(u16 depth); +/** + * @brief Gets the surround sound depth. + * @return The surround sound depth. + */ +u16 ndspSurroundGetDepth(void); + /** * @brief Sets the surround sound position. * @param pos Position to set. Defaults to NDSP_SPKPOS_SQUARE. */ void ndspSurroundSetPos(ndspSpeakerPos pos); +/** + * @brief Gets the surround sound position. + * @return The surround sound speaker position. + */ +ndspSpeakerPos ndspSurroundGetPos(void); + /** * @brief Sets the surround sound rear ratio. * @param ratio Rear ratio to set. Defaults to 0x8000. */ void ndspSurroundSetRearRatio(u16 ratio); + +/** + * @brief Gets the surround sound rear ratio. + * @return The rear ratio. + */ +u16 ndspSurroundGetRearRatio(void); ///@} ///@name Auxiliary output @@ -180,6 +222,13 @@ void ndspSurroundSetRearRatio(u16 ratio); */ void ndspAuxSetEnable(int id, bool enable); +/** + * @brief Gets whether auxiliary output is enabled. + * @param id ID of the auxiliary output. + * @return Whether auxiliary output is enabled. + */ +bool ndspAuxIsEnabled(int id); + /** * @brief Configures whether an auxiliary output should use front bypass. * @param id ID of the auxiliary output. @@ -187,6 +236,13 @@ void ndspAuxSetEnable(int id, bool enable); */ void ndspAuxSetFrontBypass(int id, bool bypass); +/** + * @brief Gets whether auxiliary output front bypass is enabled. + * @param id ID of the auxiliary output. + * @return Whether auxiliary output front bypass is enabled. + */ +bool ndspAuxGetFrontBypass(int id); + /** * @brief Sets the volume of an auxiliary output. * @param id ID of the auxiliary output. @@ -194,6 +250,13 @@ void ndspAuxSetFrontBypass(int id, bool bypass); */ void ndspAuxSetVolume(int id, float volume); +/** + * @brief Gets the volume of an auxiliary output. + * @param id ID of the auxiliary output. + * @return Volume of the auxiliary output. + */ +float ndspAuxGetVolume(int id); + /** * @brief Sets the callback of an auxiliary output. * @param id ID of the auxiliary output. diff --git a/library/libctru/include/3ds/services/ac.h b/library/libctru/include/3ds/services/ac.h index bc1ad79c..a39f389d 100644 --- a/library/libctru/include/3ds/services/ac.h +++ b/library/libctru/include/3ds/services/ac.h @@ -27,6 +27,9 @@ Result acInit(void); /// Exits AC. void acExit(void); +/// Gets the current AC session handle. +Handle *acGetSessionHandle(void); + /// Waits for the system to connect to the internet. Result acWaitInternetConnection(void); @@ -128,3 +131,15 @@ Result ACU_SetRequestEulaVersion(acuConfig* config); * @param connectionHandle Handle created with svcCreateEvent to wait on until the connection succeeds or fails. */ Result ACU_ConnectAsync(const acuConfig* config, Handle connectionHandle); + +/** + * @brief Selects the WiFi configuration slot for further ac:i operations. + * @param slot WiFi slot (0, 1 or 2). + */ +Result ACI_LoadNetworkSetting(u32 slot); + +/** + * @brief Fetches the SSID of the previously selected WiFi configuration slot. + * @param[out] ssid Pointer to the output buffer of size 32B the SSID will be stored in. + */ +Result ACI_GetNetworkWirelessEssidSecuritySsid(void *ssid); diff --git a/library/libctru/include/3ds/services/apt.h b/library/libctru/include/3ds/services/apt.h index 6f9f6d6f..4e9de7e9 100644 --- a/library/libctru/include/3ds/services/apt.h +++ b/library/libctru/include/3ds/services/apt.h @@ -176,7 +176,7 @@ bool aptShouldJumpToHome(void); bool aptCheckHomePressRejected(void); /// \deprecated Alias for \ref aptCheckHomePressRejected. -static inline DEPRECATED bool aptIsHomePressed(void) +static inline CTR_DEPRECATED bool aptIsHomePressed(void) { return aptCheckHomePressRejected(); } @@ -237,9 +237,22 @@ void aptClearChainloader(void); */ void aptSetChainloader(u64 programID, u8 mediatype); +/// Configures the chainloader to launch the previous application. +void aptSetChainloaderToCaller(void); + /// Configures the chainloader to relaunch the current application (i.e. soft-reset) void aptSetChainloaderToSelf(void); +/** + * @brief Sets the "deliver arg" and HMAC for the chainloader, which will + * be passed to the target 3DS/DS(i) application. The meaning of each + * parameter varies on a per-application basis. + * @param deliverArg Deliver arg to pass to the target application. + * @param deliverArgSize Size of the deliver arg, maximum 0x300 bytes. + * @param hmac HMAC buffer, 32 bytes. Use NULL to pass an all-zero dummy HMAC. + */ +void aptSetChainloaderArgs(const void *deliverArg, size_t deliverArgSize, const void *hmac); + /** * @brief Gets an APT lock handle. * @param flags Flags to use. @@ -565,4 +578,4 @@ Result APT_GetSharedFont(Handle* fontHandle, u32* mapAddr); * @param sender Pointer to output the sender's AppID to. * @param received Pointer to output whether an argument was received to. */ -Result APT_ReceiveDeliverArg(const void* param, size_t paramSize, const void* hmac, u64* sender, bool* received); +Result APT_ReceiveDeliverArg(void* param, size_t paramSize, void* hmac, u64* sender, bool* received); diff --git a/library/libctru/include/3ds/services/cdcchk.h b/library/libctru/include/3ds/services/cdcchk.h new file mode 100644 index 00000000..8917f89f --- /dev/null +++ b/library/libctru/include/3ds/services/cdcchk.h @@ -0,0 +1,90 @@ +/** + * @file cdcchk.h + * @brief CODEC Hardware Check service. + */ +#pragma once + +#include <3ds/types.h> + +/// I2S line enumeration +typedef enum { + CODEC_I2S_LINE_1, ///< Primary I2S line, used by DSP/Mic (configurable)/GBA sound controller. + CODEC_I2S_LINE_2, ///< Secondary I2S line, used by CSND hardware. +} CodecI2sLine; + +/// Initializes CDCCHK. +Result cdcChkInit(void); + +/// Exits CDCCHK. +void cdcChkExit(void); + +/** + * @brief Gets a pointer to the current cdc:CHK session handle. + * @return A pointer to the current cdc:CHK session handle. + */ +Handle *cdcChkGetSessionHandle(void); + +/** + * @brief Reads multiple registers from the CODEC, using the old + * SPI hardware interface and a 4MHz baudrate. + * @param pageId CODEC Page ID. + * @param initialRegAddr Address of the CODEC register to start with. + * @param[out] outData Where to write the read data to. + * @param size Number of registers to read (bytes to read, max. 64). + */ +Result CDCCHK_ReadRegisters1(u8 pageId, u8 initialRegAddr, void *outData, size_t size); + +/** + * @brief Reads multiple registers from the CODEC, using the new + * SPI hardware interface and a 16MHz baudrate. + * @param pageId CODEC Page ID. + * @param initialRegAddr Address of the CODEC register to start with. + * @param[out] outData Where to read the data to. + * @param size Number of registers to read (bytes to read, max. 64). + */ +Result CDCCHK_ReadRegisters2(u8 pageId, u8 initialRegAddr, void *outData, size_t size); + +/** + * @brief Writes multiple registers to the CODEC, using the old + * SPI hardware interface and a 4MHz baudrate. + * @param pageId CODEC Page ID. + * @param initialRegAddr Address of the CODEC register to start with. + * @param data Where to read the data to write from. + * @param size Number of registers to write (bytes to read, max. 64). + */ +Result CDCCHK_WriteRegisters1(u8 pageId, u8 initialRegAddr, const void *data, size_t size); + +/** + * @brief Writes multiple registers to the CODEC, using the new + * SPI hardware interface and a 16MHz baudrate. + * @param pageId CODEC Page ID. + * @param initialRegAddr Address of the CODEC register to start with. + * @param data Where to read the data to write from. + * @param size Number of registers to write (bytes to read, max. 64). + */ +Result CDCCHK_WriteRegisters2(u8 pageId, u8 initialRegAddr, const void *data, size_t size); + +/** + * @brief Reads a single register from the NTR PMIC. + * @param[out] outData Where to read the data to (1 byte). + * @param regAddr Register address. + * @note The NTR PMIC is emulated by the CODEC hardware and sends + * IRQs to the MCU when relevant. + */ +Result CDCCHK_ReadNtrPmicRegister(u8 *outData, u8 regAddr); + +/** + * @brief Writes a single register from the NTR PMIC. + * @param regAddr Register address. + * @param data Data to write (1 byte). + * @note The NTR PMIC is emulated by the CODEC hardware and sends + * IRQs to the MCU when relevant. + */ +Result CDCCHK_WriteNtrPmicRegister(u8 regAddr, u8 data); + +/** + * @brief Sets the DAC volume level for the specified I2S line. + * @param i2sLine I2S line to set the volume for. + * @param volume Volume level (-128 to 0). +*/ +Result CDCCHK_SetI2sVolume(CodecI2sLine i2sLine, s8 volume); diff --git a/library/libctru/include/3ds/services/fs.h b/library/libctru/include/3ds/services/fs.h index 5a3956d3..1552bb86 100644 --- a/library/libctru/include/3ds/services/fs.h +++ b/library/libctru/include/3ds/services/fs.h @@ -202,7 +202,7 @@ typedef struct } FS_IntegrityVerificationSeed; /// Ext save data information. -typedef struct PACKED +typedef struct CTR_PACKED { FS_MediaType mediaType : 8; ///< Media type. u8 unknown; ///< Unknown. @@ -647,7 +647,7 @@ Result FSUSER_GetLegacyRomHeader(FS_MediaType mediaType, u64 programId, void* he * @brief Gets the legacy banner data of a program. * @param mediaType Media type of the program. * @param programId ID of the program. - * @param header Pointer to output the legacy banner data to. (size = 0x23C0) + * @param banner Pointer to output the legacy banner data to. (size = 0x23C0) */ Result FSUSER_GetLegacyBannerData(FS_MediaType mediaType, u64 programId, void* banner); diff --git a/library/libctru/include/3ds/services/gspgpu.h b/library/libctru/include/3ds/services/gspgpu.h index 948c70cd..edec3090 100644 --- a/library/libctru/include/3ds/services/gspgpu.h +++ b/library/libctru/include/3ds/services/gspgpu.h @@ -89,6 +89,12 @@ Result gspInit(void); /// Exits GSPGPU. void gspExit(void); +/** + * @brief Gets a pointer to the current gsp::Gpu session handle. + * @return A pointer to the current gsp::Gpu session handle. + */ +Handle *gspGetSessionHandle(void); + /// Returns true if the application currently has GPU rights. bool gspHasGpuRight(void); diff --git a/library/libctru/include/3ds/services/gsplcd.h b/library/libctru/include/3ds/services/gsplcd.h index 8e52d8e4..af9c4293 100644 --- a/library/libctru/include/3ds/services/gsplcd.h +++ b/library/libctru/include/3ds/services/gsplcd.h @@ -20,6 +20,12 @@ Result gspLcdInit(void); /// Exits GSPLCD. void gspLcdExit(void); +/** + * @brief Gets a pointer to the current gsp::Lcd session handle. + * @return A pointer to the current gsp::Lcd session handle. + */ +Handle *gspLcdGetSessionHandle(void); + /// Powers on both backlights. Result GSPLCD_PowerOnAllBacklights(void); @@ -69,4 +75,4 @@ Result GSPLCD_SetBrightness(u32 screen, u32 brightness); * @param screen Screen to set the brightness value of. * @param brightness Brightness value set. */ -Result GSPLCD_SetBrightnessRaw(u32 screen, u32 brightness); \ No newline at end of file +Result GSPLCD_SetBrightnessRaw(u32 screen, u32 brightness); diff --git a/library/libctru/include/3ds/services/ir.h b/library/libctru/include/3ds/services/ir.h index 95213163..95117d33 100644 --- a/library/libctru/include/3ds/services/ir.h +++ b/library/libctru/include/3ds/services/ir.h @@ -91,3 +91,15 @@ Result IRU_SetIRLEDState(u32 value); * @param out Pointer to write the IR LED state to. */ Result IRU_GetIRLEDRecvState(u32 *out); + +/** + * @brief Gets an event which is signaled once a send finishes. + * @param out Pointer to write the event handle to. + */ +Result IRU_GetSendFinishedEvent(Handle *out); + +/** + * @brief Gets an event which is signaled once a receive finishes. + * @param out Pointer to write the event handle to. + */ +Result IRU_GetRecvFinishedEvent(Handle *out); diff --git a/library/libctru/include/3ds/services/mcuhwc.h b/library/libctru/include/3ds/services/mcuhwc.h index 6fbdfcf6..aac7ea60 100644 --- a/library/libctru/include/3ds/services/mcuhwc.h +++ b/library/libctru/include/3ds/services/mcuhwc.h @@ -20,6 +20,12 @@ Result mcuHwcInit(void); /// Exits mcuHwc. void mcuHwcExit(void); +/** + * @brief Gets the current mcuHwc session handle. + * @return A pointer to the current mcuHwc session handle. + */ +Handle* mcuHwcGetSessionHandle(void); + /** * @brief Reads data from an i2c device3 register * @param reg Register number. See https://www.3dbrew.org/wiki/I2C_Registers#Device_3 for more info diff --git a/library/libctru/include/3ds/services/soc.h b/library/libctru/include/3ds/services/soc.h index 1a716244..dad9c344 100644 --- a/library/libctru/include/3ds/services/soc.h +++ b/library/libctru/include/3ds/services/soc.h @@ -16,7 +16,7 @@ typedef enum { NETOPT_MAC_ADDRESS = 0x1004, ///< The mac address of the interface (u32 mac[6]) NETOPT_ARP_TABLE = 0x3002, ///< The ARP table @see SOCU_ARPTableEntry - NETOPT_IP_INFO = 0x4003, ///< The cureent IP setup @see SOCU_IPInfo + NETOPT_IP_INFO = 0x4003, ///< The current IP setup @see SOCU_IPInfo NETOPT_IP_MTU = 0x4004, ///< The value of the IP MTU (u32) NETOPT_ROUTING_TABLE = 0x4006, ///< The routing table @see SOCU_RoutingTableEntry NETOPT_UDP_NUMBER = 0x8002, ///< The number of sockets in the UDP table (u32) diff --git a/library/libctru/include/3ds/svc.h b/library/libctru/include/3ds/svc.h index 57183053..68276009 100644 --- a/library/libctru/include/3ds/svc.h +++ b/library/libctru/include/3ds/svc.h @@ -497,9 +497,8 @@ typedef enum { /// Information on address space for process. All sizes are in pages (0x1000 bytes) typedef struct { u8 name[8]; ///< ASCII name of codeset - u16 unk1; - u16 unk2; - u32 unk3; + u16 version; ///< Version field of codeset (unused) + u16 padding[3]; ///< Padding u32 text_addr; ///< .text start address u32 text_size; ///< .text number of pages u32 ro_addr; ///< .rodata start address @@ -509,9 +508,9 @@ typedef struct { u32 text_size_total; ///< total pages for .text (aligned) u32 ro_size_total; ///< total pages for .rodata (aligned) u32 rw_size_total; ///< total pages for .data, .bss (aligned) - u32 unk4; + u32 padding2; ///< Padding u64 program_id; ///< Program ID -} CodeSetInfo; +} CodeSetHeader; /// Information for the main thread of a process. typedef struct @@ -527,7 +526,7 @@ typedef struct /** * @brief Gets the thread local storage buffer. - * @return The thread local storage bufger. + * @return The thread local storage buffer. */ static inline void* getThreadLocalStorage(void) { @@ -538,7 +537,7 @@ static inline void* getThreadLocalStorage(void) /** * @brief Gets the thread command buffer. - * @return The thread command bufger. + * @return The thread command buffer. */ static inline u32* getThreadCommandBuffer(void) { @@ -547,7 +546,7 @@ static inline u32* getThreadCommandBuffer(void) /** * @brief Gets the thread static buffer. - * @return The thread static bufger. + * @return The thread static buffer. */ static inline u32* getThreadStaticBuffers(void) { @@ -699,7 +698,7 @@ Result svcQueryProcessMemory(MemInfo* info, PageInfo* out, Handle process, u32 a Result svcOpenProcess(Handle* process, u32 processId); /// Exits the current process. -void __attribute__((noreturn)) svcExitProcess(); +void svcExitProcess(void) __attribute__((noreturn)); /** * @brief Terminates a process. @@ -756,23 +755,24 @@ Result svcCreatePort(Handle* portServer, Handle* portClient, const char* name, s Result svcConnectToPort(volatile Handle* out, const char* portName); /** - * @brief Sets up virtual address space for a new process - * @param[out] out Pointer to output the code set handle to. - * @param info Description for setting up the addresses - * @param code_ptr Pointer to .text in shared memory - * @param ro_ptr Pointer to .rodata in shared memory - * @param data_ptr Pointer to .data in shared memory + * @brief Sets up virtual address space for a new process. + * @param[out] out Pointer to output the codeset handle to. + * @param info Codeset header, contains process name, titleId and segment info. + * @param textSegmentLma Address of executable segment in caller's address space. + * @param roSegmentLma Address of read-only segment in caller's address space. + * @param dataSegmentLma Address of read-write segment in caller's address space. + * @note On success, the provided segments are unmapped from the caller's address space. */ -Result svcCreateCodeSet(Handle* out, const CodeSetInfo *info, void* code_ptr, void* ro_ptr, void* data_ptr); +Result svcCreateCodeSet(Handle* out, const CodeSetHeader* info, u32 textSegmentLma, u32 roSegmentLma, u32 dataSegmentLma); /** - * @brief Sets up virtual address space for a new process + * @brief Create a new process. * @param[out] out Pointer to output the process handle to. - * @param codeset Codeset created for this process - * @param arm11kernelcaps ARM11 Kernel Capabilities from exheader - * @param arm11kernelcaps_num Number of kernel capabilities + * @param codeset Codeset created for this process. + * @param arm11KernelCaps Arm11 Kernel Capabilities from exheader. + * @param numArm11KernelCaps Number of kernel capabilities. */ -Result svcCreateProcess(Handle* out, Handle codeset, const u32 *arm11kernelcaps, u32 arm11kernelcaps_num); +Result svcCreateProcess(Handle* out, Handle codeset, const u32* arm11KernelCaps, s32 numArm11KernelCaps); /** * @brief Gets a process's affinity mask. diff --git a/library/libctru/include/3ds/synchronization.h b/library/libctru/include/3ds/synchronization.h index d8edfdc3..60cc2c80 100644 --- a/library/libctru/include/3ds/synchronization.h +++ b/library/libctru/include/3ds/synchronization.h @@ -42,6 +42,12 @@ static inline void __dmb(void) __asm__ __volatile__("mcr p15, 0, %[val], c7, c10, 5" :: [val] "r" (0) : "memory"); } +/// Performs an Instruction Synchronization Barrier (officially "flush prefetch buffer") operation. +static inline void __isb(void) +{ + __asm__ __volatile__("mcr p15, 0, %[val], c7, c5, 4" :: [val] "r" (0) : "memory"); +} + /// Performs a clrex operation. static inline void __clrex(void) { diff --git a/library/libctru/include/3ds/thread.h b/library/libctru/include/3ds/thread.h index 68c99ebf..d37fdf3d 100644 --- a/library/libctru/include/3ds/thread.h +++ b/library/libctru/include/3ds/thread.h @@ -117,4 +117,7 @@ static inline void threadOnException(ExceptionHandler handler, void* stack_top, *(u32*)(tls + 0x40) = (u32)handler; *(u32*)(tls + 0x44) = (u32)stack_top; *(u32*)(tls + 0x48) = (u32)exception_data; + + __dsb(); + __isb(); } diff --git a/library/libctru/include/3ds/types.h b/library/libctru/include/3ds/types.h index eed876a7..02f4d96c 100644 --- a/library/libctru/include/3ds/types.h +++ b/library/libctru/include/3ds/types.h @@ -47,16 +47,16 @@ typedef void (*voidfn)(void); #define BIT(n) (1U<<(n)) /// Aligns a struct (and other types?) to m, making sure that the size of the struct is a multiple of m. -#define ALIGN(m) __attribute__((aligned(m))) +#define CTR_ALIGN(m) __attribute__((aligned(m))) /// Packs a struct (and other types?) so it won't include padding bytes. -#define PACKED __attribute__((packed)) +#define CTR_PACKED __attribute__((packed)) -#ifndef LIBCTRU_NO_DEPRECATION +#ifndef CTR_NO_DEPRECATION /// Flags a function as deprecated. -#define DEPRECATED __attribute__ ((deprecated)) +#define CTR_DEPRECATED __attribute__ ((deprecated)) #else /// Flags a function as deprecated. -#define DEPRECATED +#define CTR_DEPRECATED #endif /// Structure representing CPU registers @@ -71,7 +71,7 @@ typedef struct { /// Structure representing FPU registers typedef struct { union { - struct PACKED { double d[16]; }; ///< d0-d15. + struct CTR_PACKED { double d[16]; }; ///< d0-d15. float s[32]; ///< s0-s31. }; u32 fpscr; ///< fpscr. diff --git a/library/libctru/include/netdb.h b/library/libctru/include/netdb.h index 836195aa..0f4b0470 100644 --- a/library/libctru/include/netdb.h +++ b/library/libctru/include/netdb.h @@ -9,14 +9,13 @@ #define TRY_AGAIN 4 struct hostent { - char *h_name; - char **h_aliases; - int h_addrtype; - int h_length; - char **h_addr_list; - char *h_addr; + char *h_name; /* official name of host */ + char **h_aliases; /* alias list */ + uint16_t h_addrtype; /* host address type */ + uint16_t h_length; /* length of address */ + char **h_addr_list; /* list of addresses from name server */ }; - +#define h_addr h_addr_list[0] /* for backward compatibility */ #define AI_PASSIVE 0x01 #define AI_CANONNAME 0x02 diff --git a/library/libctru/include/sys/socket.h b/library/libctru/include/sys/socket.h index 8f6d78ed..edee7db4 100644 --- a/library/libctru/include/sys/socket.h +++ b/library/libctru/include/sys/socket.h @@ -44,6 +44,8 @@ #define SO_BROADCAST 0x0000 // unrequired, included for compatibility +#define _SOCKLEN_T_DECLARED + typedef uint32_t socklen_t; typedef uint16_t sa_family_t; diff --git a/library/libctru/lib/libctru.a b/library/libctru/lib/libctru.a index fecf3ce9..ce3808de 100644 Binary files a/library/libctru/lib/libctru.a and b/library/libctru/lib/libctru.a differ diff --git a/library/libctru/lib/libctrud.a b/library/libctru/lib/libctrud.a index 891aa56b..ef221506 100644 Binary files a/library/libctru/lib/libctrud.a and b/library/libctru/lib/libctrud.a differ diff --git a/library/libctru/source b/library/libctru/source index bac1fb81..060f7840 160000 --- a/library/libctru/source +++ b/library/libctru/source @@ -1 +1 @@ -Subproject commit bac1fb8199a6d1a2199eeddfe6b77450eb08fe5b +Subproject commit 060f78401c8e65d340f2b5e04621ce759deb9fb7 diff --git a/source/system/fake_pthread.cpp b/source/system/fake_pthread.cpp index 7d9ed174..827fc1f5 100644 --- a/source/system/fake_pthread.cpp +++ b/source/system/fake_pthread.cpp @@ -1,5 +1,7 @@ #include "headers.hpp" -#define _POSIX_THREADS +#ifndef _POSIX_THREADS +# define _POSIX_THREADS +#endif #include #include "fake_pthread.hpp" @@ -29,191 +31,134 @@ void Util_fake_pthread_set_enabled_core(bool enabled_core[4]) util_fake_pthread_core_offset = 0; } -// seems like pthread_mutex_t is u32 and LightLock is s32 int pthread_mutex_lock(pthread_mutex_t *mutex) { - LightLock_Lock((LightLock *) mutex); + LightLock_Lock(&mutex->normal); return 0; } int pthread_mutex_trylock(pthread_mutex_t *mutex) { - int res = LightLock_TryLock((LightLock *) mutex); + int res = LightLock_TryLock(&mutex->normal); return res ? EBUSY : 0; } int pthread_mutex_unlock(pthread_mutex_t *mutex) { - LightLock_Unlock((LightLock *) mutex); + LightLock_Unlock(&mutex->normal); return 0; } - int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr) { - LightLock_Init((LightLock *) mutex); + LightLock_Init(&mutex->normal); return 0; } - int pthread_mutex_destroy(pthread_mutex_t *mutex) { // LightLock doesn't need any resource releasing return 0; } +#define PTHREAD_ONCE_NOT_RUN 0 +#define PTHREAD_ONCE_RUNNING 1 +#define PTHREAD_ONCE_FINISHED 2 + int pthread_once(pthread_once_t *once_control, void (*init_routine)(void)) { - if (once_control->init_executed == 0) { - once_control->is_initialized = 1; - once_control->init_executed = 1; + s32 val; + s32 next; + do { + val = __ldrex((s32 *) &once_control->status); + if (val == PTHREAD_ONCE_NOT_RUN) next = PTHREAD_ONCE_RUNNING; + else next = val; + } while (__strex((s32 *) &once_control->status, val)); + + if (val == PTHREAD_ONCE_NOT_RUN) { init_routine(); + once_control->status = PTHREAD_ONCE_FINISHED; } + __dmb(); return 0; } -int pthread_cond_wait(pthread_cond_t *__cond, pthread_mutex_t *__mutex) { - pthread_mutex_unlock(__mutex); - int res = -1; - - while (true) { - uint result = svcWaitSynchronization((Handle)*__cond, U64_MAX); - if (result == 0) { - res = 0; - break; - } - if (result == 0xD8E007F7) { - result = pthread_cond_init(__cond, NULL); - if (result != 0) { - res = -1; - break; - } - } - } - pthread_mutex_lock(__mutex); - return res; +int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t* attr) { + CondVar_Init((CondVar *) &cond->cond); + return 0; } - -int pthread_cond_signal(pthread_cond_t *__cond) -{ - return svcSignalEvent((Handle)*__cond); +int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) { + CondVar_Wait((CondVar *) &cond->cond, &mutex->normal); + return 0; } -int pthread_cond_broadcast(pthread_cond_t *__cond) -{ - uint result = 0; - - while(true) - { - result = svcSignalEvent((Handle)*__cond); - if(result == 0xD8E007F7) - { - result = pthread_cond_init(__cond, NULL); - if(result != 0) - return -1; - else - continue; - } - - result = svcWaitSynchronization((Handle)*__cond, 0); - if(result == 0) - return 0; - } +int pthread_cond_signal(pthread_cond_t *cond) { + CondVar_Signal((CondVar *) &cond->cond); + return 0; } - -int pthread_cond_init(pthread_cond_t *__cond, const pthread_condattr_t *__attr) -{ - int res = svcCreateEvent((Handle*)__cond, RESET_ONESHOT); - if (res) logger.error("pthread", "cond init FAIL"); - return res; +int pthread_cond_broadcast(pthread_cond_t *cond) { + CondVar_Broadcast((CondVar *) &cond->cond); + return 0; } - -int pthread_cond_destroy(pthread_cond_t *__mutex) -{ - return svcCloseHandle((Handle)*__mutex); +int pthread_cond_destroy(pthread_cond_t *cond) { + return 0; } -int pthread_create(pthread_t *__pthread, const pthread_attr_t *__attr, void *(*__start_routine)(void *), void *__arg) + +int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg) { Thread handle = 0; if(util_fake_pthread_enabled_cores == 0) return -1; - handle = threadCreate((ThreadFunc)(void *) __start_routine, __arg, DEF_STACKSIZE, DEF_THREAD_PRIORITY_LOW, util_fake_pthread_enabled_core_list[util_fake_pthread_core_offset], true); - *__pthread = (pthread_t)handle; + handle = threadCreate((ThreadFunc)(void *) start_routine, arg, DEF_STACKSIZE, DEF_THREAD_PRIORITY_LOW, + util_fake_pthread_enabled_core_list[util_fake_pthread_core_offset], true); + *thread = (pthread_t) handle; if(util_fake_pthread_core_offset + 1 < util_fake_pthread_enabled_cores) util_fake_pthread_core_offset++; else util_fake_pthread_core_offset = 0; - if(!handle) - return -1; - else - return 0; + if (!handle) return -1; + else return 0; } -int pthread_join(pthread_t __pthread, void **__value_ptr) -{ - int result = -1; - while(true) - { - result = threadJoin((Thread)__pthread, U64_MAX); - if(result == 0) - return 0; +int pthread_join(pthread_t thread, void **__value_ptr) { + while (true) { + int result = threadJoin((Thread) thread, U64_MAX); + if (result == 0) return 0; } } -int pthread_attr_init(pthread_attr_t *attr) -{ - if(!attr) - return -1; +int pthread_attr_init(pthread_attr_t *attr) { + if (!attr) return -1; - attr->is_initialized = true; attr->stackaddr = NULL; attr->stacksize = DEF_STACKSIZE; - attr->contentionscope = PTHREAD_SCOPE_SYSTEM; - attr->inheritsched = PTHREAD_INHERIT_SCHED; - attr->schedpolicy = SCHED_FIFO; attr->schedparam.sched_priority = DEF_THREAD_PRIORITY_LOW; attr->detachstate = PTHREAD_CREATE_JOINABLE; return 0; } -int pthread_attr_destroy(pthread_attr_t *attr) -{ - if(!attr) - return -1; - - attr->is_initialized = false; +int pthread_attr_destroy(pthread_attr_t *attr) { return 0; } -int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize) -{ - if(!attr || stacksize < 16384) - return -1; +int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize) { + if (!attr || stacksize < 16384) return -1; attr->stacksize = stacksize; return 0; } -int posix_memalign(void **memptr, size_t alignment, size_t size) -{ +int posix_memalign(void **memptr, size_t alignment, size_t size) { *memptr = memalign(alignment, size); - if(!*memptr) - return -1; - else - return 0; + if (!*memptr) return -1; + else return 0; } -long sysconf(int name) -{ - if(name == _SC_NPROCESSORS_CONF) - { +long sysconf(int name) { + if (name == _SC_NPROCESSORS_CONF) { if(var_model == CFG_MODEL_N2DSXL || var_model == CFG_MODEL_N3DS || var_model == CFG_MODEL_N3DSXL) return 4; else return 2; - } - else if(name == _SC_NPROCESSORS_ONLN) - { + } else if(name == _SC_NPROCESSORS_ONLN) { if(var_model == CFG_MODEL_N2DSXL || var_model == CFG_MODEL_N3DS || var_model == CFG_MODEL_N3DSXL) return 2 + var_core2_available + var_core3_available; else return 2; - } - else - return -1; + } else return -1; } diff --git a/source/youtube_parser/video.cpp b/source/youtube_parser/video.cpp index da182525..5d044d0f 100644 --- a/source/youtube_parser/video.cpp +++ b/source/youtube_parser/video.cpp @@ -115,12 +115,24 @@ static bool extract_player_data(Document &json_root, RJson player_response, YouT } static void extract_like_dislike_counts(RJson buttons, YouTubeVideoDetail &res) { - for (auto button : buttons.array_items()) if (button.has_key("slimMetadataToggleButtonRenderer")) { - auto content = get_text_from_object(button["slimMetadataToggleButtonRenderer"]["button"]["toggleButtonRenderer"]["defaultText"]); - if (content.size() && !isdigit(content[0])) content = "hidden"; - if (button["slimMetadataToggleButtonRenderer"]["isLike"].bool_value()) res.like_count_str = content; - else if (button["slimMetadataToggleButtonRenderer"]["isDislike"].bool_value()) res.dislike_count_str = content; - if (button["slimMetadataToggleButtonRenderer"]["target"]["videoId"].is_valid()) res.id = button["slimMetadataToggleButtonRenderer"]["target"]["videoId"].string_value(); + for (auto button : buttons.array_items()) { + if (button.has_key("slimMetadataToggleButtonRenderer")) { // legacy? + auto content = get_text_from_object(button["slimMetadataToggleButtonRenderer"]["button"]["toggleButtonRenderer"]["defaultText"]); + if (content.size() && !isdigit(content[0])) content = "hidden"; + if (button["slimMetadataToggleButtonRenderer"]["isLike"].bool_value()) res.like_count_str = content; + else if (button["slimMetadataToggleButtonRenderer"]["isDislike"].bool_value()) res.dislike_count_str = content; + if (button["slimMetadataToggleButtonRenderer"]["target"]["videoId"].is_valid()) res.id = button["slimMetadataToggleButtonRenderer"]["target"]["videoId"].string_value(); + } + if (button["slimMetadataButtonRenderer"]["button"].has_key("segmentedLikeDislikeButtonRenderer")) { + auto renderer = button["slimMetadataButtonRenderer"]["button"]["segmentedLikeDislikeButtonRenderer"]; + auto get_text = [] (RJson button) -> std::string { + auto text = get_text_from_object(button["toggleButtonRenderer"]["defaultText"]); + if (text.size() && !isdigit(text[0])) return "hidden"; + return text; + }; + res.like_count_str = get_text(renderer["likeButton"]); + res.dislike_count_str = get_text(renderer["dislikeButton"]); + } } } @@ -223,8 +235,10 @@ static void extract_metadata(RJson data, YouTubeVideoDetail &res) { } } for (auto j : i["engagementPanelSectionListRenderer"]["content"]["structuredDescriptionContentRenderer"]["items"].array_items()) { - if (j.has_key("expandableVideoDescriptionBodyRenderer")) + if (j["expandableVideoDescriptionBodyRenderer"].has_key("descriptionBodyText")) res.description = get_text_from_object(j["expandableVideoDescriptionBodyRenderer"]["descriptionBodyText"]); + if (j["expandableVideoDescriptionBodyRenderer"].has_key("attributedDescriptionBodyText")) + res.description = j["expandableVideoDescriptionBodyRenderer"]["attributedDescriptionBodyText"]["content"].string_value(); if (j.has_key("videoDescriptionHeaderRenderer")) { res.publish_date = get_text_from_object(j["videoDescriptionHeaderRenderer"]["publishDate"]); res.views_str = get_text_from_object(j["videoDescriptionHeaderRenderer"]["views"]);