[FFmpeg] Update FFmpeg library and decoder plugin

Update based on newest changes from upstream.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
lastfm
Christopher Snowhill 2022-06-24 23:51:12 -07:00
parent d79275b285
commit a6b6c8120b
46 changed files with 1813 additions and 334 deletions

1
.gitignore vendored
View File

@ -22,7 +22,6 @@ Cog.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
/ThirdParty/fdk-aac/lib/libfdk-aac.a /ThirdParty/fdk-aac/lib/libfdk-aac.a
/ThirdParty/fdk-aac/lib/libfdk-aac.dylib /ThirdParty/fdk-aac/lib/libfdk-aac.dylib
/ThirdParty/fdk-aac/lib/libfdk-aac.la /ThirdParty/fdk-aac/lib/libfdk-aac.la
/ThirdParty/fdk-aac/lib/pkgconfig/
/ThirdParty/fdk-aac/lib/pkgconfig/fdk-aac.pc /ThirdParty/fdk-aac/lib/pkgconfig/fdk-aac.pc
/ThirdParty/ffmpeg/lib/libavcodec.59.dylib /ThirdParty/ffmpeg/lib/libavcodec.59.dylib
/ThirdParty/ffmpeg/lib/libavformat.59.dylib /ThirdParty/ffmpeg/lib/libavformat.59.dylib

View File

@ -282,9 +282,10 @@ static uint8_t reverse_bits[0x100];
seekFrame = -1; seekFrame = -1;
if(!rawDSD) { if(!rawDSD) {
AVChannelLayout *layout = &codecCtx->ch_layout;
frequency = codecCtx->sample_rate; frequency = codecCtx->sample_rate;
channels = codecCtx->channels; channels = layout->nb_channels;
channelConfig = (uint32_t)codecCtx->channel_layout; channelConfig = (uint32_t)layout->u.mask;
floatingPoint = NO; floatingPoint = NO;
switch(codecCtx->sample_fmt) { switch(codecCtx->sample_fmt) {
@ -319,9 +320,10 @@ static uint8_t reverse_bits[0x100];
return NO; return NO;
} }
} else { } else {
AVChannelLayout *layout = &codecCtx->ch_layout;
frequency = codecPar->sample_rate * 8; frequency = codecPar->sample_rate * 8;
channels = codecPar->channels; channels = layout->nb_channels;
channelConfig = (uint32_t)codecPar->channel_layout; channelConfig = (uint32_t)layout->u.mask;
bitsPerSample = 1; bitsPerSample = 1;
floatingPoint = NO; floatingPoint = NO;
} }
@ -691,7 +693,7 @@ static uint8_t reverse_bits[0x100];
int planar; int planar;
if(!rawDSD) { if(!rawDSD) {
planar = av_sample_fmt_is_planar(codecCtx->sample_fmt); planar = av_sample_fmt_is_planar(codecCtx->sample_fmt);
dataSize = av_samples_get_buffer_size(&planeSize, codecCtx->channels, dataSize = av_samples_get_buffer_size(&planeSize, channels,
lastDecodedFrame->nb_samples, lastDecodedFrame->nb_samples,
codecCtx->sample_fmt, 1); codecCtx->sample_fmt, 1);
} else { } else {
@ -761,7 +763,7 @@ static uint8_t reverse_bits[0x100];
} }
// Something has been successfully decoded // Something has been successfully decoded
dataSize = av_samples_get_buffer_size(&planeSize, codecCtx->channels, dataSize = av_samples_get_buffer_size(&planeSize, channels,
lastDecodedFrame->nb_samples, lastDecodedFrame->nb_samples,
codecCtx->sample_fmt, 1); codecCtx->sample_fmt, 1);
} else { } else {
@ -823,8 +825,9 @@ static uint8_t reverse_bits[0x100];
} }
if(!rawDSD) { if(!rawDSD) {
int _channels = codecCtx->channels; AVChannelLayout *layout = &codecCtx->ch_layout;
uint32_t _channelConfig = (uint32_t)codecCtx->channel_layout; int _channels = layout->nb_channels;
uint32_t _channelConfig = (uint32_t)layout->u.mask;
float _frequency = codecCtx->sample_rate; float _frequency = codecCtx->sample_rate;
if(_channels != channels || if(_channels != channels ||

View File

@ -43,7 +43,13 @@
#include "codec_id.h" #include "codec_id.h"
#include "defs.h" #include "defs.h"
#include "packet.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 "version.h"
#endif
/** /**
* @defgroup libavc libavcodec * @defgroup libavc libavcodec
@ -990,7 +996,15 @@ typedef struct AVCodecContext {
/* audio only */ /* audio only */
int sample_rate; ///< samples per second 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 * audio sample format
@ -1035,19 +1049,25 @@ typedef struct AVCodecContext {
*/ */
int cutoff; int cutoff;
#if FF_API_OLD_CHANNEL_LAYOUT
/** /**
* Audio channel layout. * Audio channel layout.
* - encoding: set by user. * - encoding: set by user.
* - decoding: set by user, may be overwritten by libavcodec. * - decoding: set by user, may be overwritten by libavcodec.
* @deprecated use ch_layout
*/ */
attribute_deprecated
uint64_t channel_layout; uint64_t channel_layout;
/** /**
* Request decoder to use this channel layout if it can (0 for default) * Request decoder to use this channel layout if it can (0 for default)
* - encoding: unused * - encoding: unused
* - decoding: Set by user. * - decoding: Set by user.
* @deprecated use "downmix" codec private option
*/ */
attribute_deprecated
uint64_t request_channel_layout; uint64_t request_channel_layout;
#endif
/** /**
* Type of service that the audio stream conveys. * Type of service that the audio stream conveys.
@ -1407,7 +1427,10 @@ typedef struct AVCodecContext {
#define FF_IDCT_SIMPLEARMV6 17 #define FF_IDCT_SIMPLEARMV6 17
#define FF_IDCT_FAAN 20 #define FF_IDCT_FAAN 20
#define FF_IDCT_SIMPLENEON 22 #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 #define FF_IDCT_SIMPLEAUTO 128
/** /**
@ -2024,9 +2047,15 @@ typedef struct AVCodecContext {
* - decoding: unused * - decoding: unused
*/ */
int (*get_encode_buffer)(struct AVCodecContext *s, AVPacket *pkt, int flags); 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;
} AVCodecContext;
/** /**
* @defgroup lavc_hwaccel AVHWAccel * @defgroup lavc_hwaccel AVHWAccel
@ -2119,7 +2148,6 @@ typedef struct AVHWAccel {
* *
* Meaningful slice information (codec specific) is guaranteed to * Meaningful slice information (codec specific) is guaranteed to
* be parsed at this point. This function is mandatory. * 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 avctx the codec context
* @param buf the slice data buffer base * @param buf the slice data buffer base
@ -2148,17 +2176,6 @@ typedef struct AVHWAccel {
*/ */
int frame_priv_data_size; 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. * Initialize the hwaccel private data.
* *
@ -2384,8 +2401,6 @@ int avcodec_parameters_to_context(AVCodecContext *codec,
* avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for
* retrieving a codec. * retrieving a codec.
* *
* @warning This function is not thread safe!
*
* @note Always call this function before using decoding routines (such as * @note Always call this function before using decoding routines (such as
* @ref avcodec_receive_frame()). * @ref avcodec_receive_frame()).
* *

View File

@ -30,7 +30,28 @@
#include "packet.h" #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().
* @{ * @{
*/ */
@ -107,20 +128,6 @@ typedef struct AVBitStreamFilter {
* code to this class. * code to this class.
*/ */
const AVClass *priv_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; } AVBitStreamFilter;
/** /**
@ -146,9 +153,9 @@ const AVBitStreamFilter *av_bsf_iterate(void **opaque);
* av_bsf_init() before sending any data to the filter. * av_bsf_init() before sending any data to the filter.
* *
* @param filter the filter for which to allocate an instance. * @param filter the filter for which to allocate an instance.
* @param ctx a pointer into which the pointer to the newly-allocated context * @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 * will be written. It must be freed with av_bsf_free() after the
* filtering is done. * filtering is done.
* *
* @return 0 on success, a negative AVERROR code on failure * @return 0 on success, a negative AVERROR code on failure
*/ */
@ -174,9 +181,11 @@ int av_bsf_init(AVBSFContext *ctx);
* sending more empty packets does nothing) and will cause the filter to output * sending more empty packets does nothing) and will cause the filter to output
* any packets it may have buffered internally. * any packets it may have buffered internally.
* *
* @return 0 on success. AVERROR(EAGAIN) if packets need to be retrieved from the * @return
* filter (using av_bsf_receive_packet()) before new input can be consumed. Another * - 0 on success.
* negative AVERROR value if an error occurs. * - 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); int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt);
@ -193,10 +202,12 @@ int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt);
* overwritten by the returned data. On failure, pkt is not * overwritten by the returned data. On failure, pkt is not
* touched. * touched.
* *
* @return 0 on success. AVERROR(EAGAIN) if more packets need to be sent to the * @return
* filter (using av_bsf_send_packet()) to get more output. AVERROR_EOF if there * - 0 on success.
* will be no further output from the filter. Another negative AVERROR value if * - AVERROR(EAGAIN) if more packets need to be sent to the filter (using
* an error occurs. * 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 * @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 * a packet with av_bsf_send_packet(), this function needs to be called

View File

@ -31,7 +31,7 @@
#include "libavutil/samplefmt.h" #include "libavutil/samplefmt.h"
#include "libavcodec/codec_id.h" #include "libavcodec/codec_id.h"
#include "libavcodec/version.h" #include "libavcodec/version_major.h"
/** /**
* @addtogroup lavc_core * @addtogroup lavc_core
@ -190,12 +190,6 @@ typedef struct AVProfile {
const char *name; ///< short name for the profile const char *name; ///< short name for the profile
} AVProfile; } AVProfile;
typedef struct AVCodecDefault AVCodecDefault;
struct AVCodecContext;
struct AVSubtitle;
struct AVPacket;
/** /**
* AVCodec. * AVCodec.
*/ */
@ -224,7 +218,13 @@ typedef struct AVCodec {
const enum AVPixelFormat *pix_fmts; ///< array of supported pixel formats, or NULL if unknown, array is terminated by -1 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 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 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 const uint64_t *channel_layouts; ///< array of support channel layouts, or NULL if unknown. array is terminated by 0
#endif
const AVClass *priv_class; ///< AVClass for the private context 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 {FF_PROFILE_UNKNOWN}
@ -240,120 +240,10 @@ typedef struct AVCodec {
*/ */
const char *wrapper_name; 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.
*****************************************************************
*/
/** /**
* Internal codec capabilities. * Array of supported channel layouts, terminated with a zeroed layout.
* See FF_CODEC_CAP_* in internal.h
*/ */
int caps_internal; const AVChannelLayout *ch_layouts;
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 *);
/**
* 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.
*/
const uint32_t *codec_tags;
} AVCodec; } AVCodec;
/** /**

View File

@ -308,6 +308,9 @@ enum AVCodecID {
AV_CODEC_ID_SIMBIOSIS_IMX, AV_CODEC_ID_SIMBIOSIS_IMX,
AV_CODEC_ID_SGA_VIDEO, AV_CODEC_ID_SGA_VIDEO,
AV_CODEC_ID_GEM, AV_CODEC_ID_GEM,
AV_CODEC_ID_VBN,
AV_CODEC_ID_JPEGXL,
AV_CODEC_ID_QOI,
/* various PCM "codecs" */ /* various PCM "codecs" */
AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs
@ -516,6 +519,7 @@ enum AVCodecID {
AV_CODEC_ID_HCA, AV_CODEC_ID_HCA,
AV_CODEC_ID_FASTAUDIO, AV_CODEC_ID_FASTAUDIO,
AV_CODEC_ID_MSNSIREN, AV_CODEC_ID_MSNSIREN,
AV_CODEC_ID_DFPWM,
/* subtitle codecs */ /* subtitle codecs */
AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs. AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs.

View File

@ -24,6 +24,7 @@
#include <stdint.h> #include <stdint.h>
#include "libavutil/avutil.h" #include "libavutil/avutil.h"
#include "libavutil/channel_layout.h"
#include "libavutil/rational.h" #include "libavutil/rational.h"
#include "libavutil/pixfmt.h" #include "libavutil/pixfmt.h"
@ -154,16 +155,22 @@ typedef struct AVCodecParameters {
*/ */
int video_delay; int video_delay;
#if FF_API_OLD_CHANNEL_LAYOUT
/** /**
* Audio only. The channel layout bitmask. May be 0 if the channel layout is * 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 * unknown or unspecified, otherwise the number of bits set must be equal to
* the channels field. * the channels field.
* @deprecated use ch_layout
*/ */
attribute_deprecated
uint64_t channel_layout; uint64_t channel_layout;
/** /**
* Audio only. The number of audio channels. * Audio only. The number of audio channels.
* @deprecated use ch_layout.nb_channels
*/ */
attribute_deprecated
int channels; int channels;
#endif
/** /**
* Audio only. The number of audio samples per second. * Audio only. The number of audio samples per second.
*/ */
@ -198,6 +205,11 @@ typedef struct AVCodecParameters {
* Audio only. Number of samples to skip after a discontinuity. * Audio only. Number of samples to skip after a discontinuity.
*/ */
int seek_preroll; int seek_preroll;
/**
* Audio only. The channel layout and number of channels.
*/
AVChannelLayout ch_layout;
} AVCodecParameters; } AVCodecParameters;
/** /**

View File

@ -28,8 +28,9 @@
#include "libavutil/buffer.h" #include "libavutil/buffer.h"
#include "libavutil/dict.h" #include "libavutil/dict.h"
#include "libavutil/rational.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 AVPacket
@ -447,8 +448,13 @@ typedef struct AVPacketList {
#define AV_PKT_FLAG_DISPOSABLE 0x0010 #define AV_PKT_FLAG_DISPOSABLE 0x0010
enum AVSideDataParamChangeFlags { 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_COUNT = 0x0001,
AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT = 0x0002, AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT = 0x0002,
#endif
AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE = 0x0004, AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE = 0x0004,
AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS = 0x0008, AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS = 0x0008,
}; };

View File

@ -27,8 +27,9 @@
#include "libavutil/version.h" #include "libavutil/version.h"
#define LIBAVCODEC_VERSION_MAJOR 59 #include "version_major.h"
#define LIBAVCODEC_VERSION_MINOR 18
#define LIBAVCODEC_VERSION_MINOR 34
#define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
@ -41,27 +42,4 @@
#define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION) #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.
*/
#define FF_API_OPENH264_SLICE_MODE (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_OPENH264_CABAC (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_UNUSED_CODEC_CAPS (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_THREAD_SAFE_CALLBACKS (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_DEBUG_MV (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_GET_FRAME_CLASS (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_AUTO_THREADS (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_INIT_PACKET (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_AVCTX_TIMEBASE (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_MPEGVIDEO_OPTS (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_FLAG_TRUNCATED (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_SUB_TEXT_FORMAT (LIBAVCODEC_VERSION_MAJOR < 60)
#endif /* AVCODEC_VERSION_H */ #endif /* AVCODEC_VERSION_H */

View File

@ -0,0 +1,54 @@
/*
* 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 59
/**
* 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_OPENH264_SLICE_MODE (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_OPENH264_CABAC (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_UNUSED_CODEC_CAPS (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_THREAD_SAFE_CALLBACKS (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_DEBUG_MV (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_GET_FRAME_CLASS (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_AUTO_THREADS (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_INIT_PACKET (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_AVCTX_TIMEBASE (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_FLAG_TRUNCATED (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_SUB_TEXT_FORMAT (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_IDCT_NONE (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_SVTAV1_OPTS (LIBAVCODEC_VERSION_MAJOR < 60)
#endif /* AVCODEC_VERSION_MAJOR_H */

View File

@ -27,10 +27,11 @@
* Public libavcodec XvMC header. * Public libavcodec XvMC header.
*/ */
#pragma message("XvMC is no longer supported; this header is deprecated and will be removed")
#include <X11/extensions/XvMC.h> #include <X11/extensions/XvMC.h>
#include "libavutil/attributes.h" #include "libavutil/attributes.h"
#include "version.h"
#include "avcodec.h" #include "avcodec.h"
/** /**

View File

@ -319,7 +319,13 @@
#include "libavutil/log.h" #include "libavutil/log.h"
#include "avio.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" #include "libavformat/version.h"
#endif
struct AVFormatContext; struct AVFormatContext;
struct AVStream; struct AVStream;
@ -879,6 +885,13 @@ typedef struct AVIndexEntry {
*/ */
#define AV_DISPOSITION_TIMED_THUMBNAILS (1 << 11) #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 * The subtitle stream contains captions, providing a transcription and possibly
* a translation of audio. Typically intended for hearing-impaired audiences. * a translation of audio. Typically intended for hearing-impaired audiences.
@ -1527,12 +1540,13 @@ typedef struct AVFormatContext {
/** /**
* Avoid negative timestamps during muxing. * Avoid negative timestamps during muxing.
* Any value of the AVFMT_AVOID_NEG_TS_* constants. * 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 * - muxing: Set by user
* - demuxing: unused * - demuxing: unused
*/ */
int avoid_negative_ts; int avoid_negative_ts;
#define AVFMT_AVOID_NEG_TS_AUTO -1 ///< Enabled when required by target format #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_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 #define AVFMT_AVOID_NEG_TS_MAKE_ZERO 2 ///< Shift timestamps so that they start at 0

View File

@ -27,12 +27,13 @@
*/ */
#include <stdint.h> #include <stdint.h>
#include <stdio.h>
#include "libavutil/common.h" #include "libavutil/attributes.h"
#include "libavutil/dict.h" #include "libavutil/dict.h"
#include "libavutil/log.h" #include "libavutil/log.h"
#include "libavformat/version.h" #include "libavformat/version_major.h"
/** /**
* Seeking works like for a local file. * Seeking works like for a local file.
@ -518,6 +519,12 @@ int64_t avio_size(AVIOContext *s);
*/ */
int avio_feof(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. * Writes a formatted string to the context.
* @return number of bytes written, < 0 on error. * @return number of bytes written, < 0 on error.

View File

@ -29,10 +29,9 @@
#include "libavutil/version.h" #include "libavutil/version.h"
// Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium) #include "version_major.h"
// Also please add any ticket numbers that you believe might be affected here
#define LIBAVFORMAT_VERSION_MAJOR 59 #define LIBAVFORMAT_VERSION_MINOR 25
#define LIBAVFORMAT_VERSION_MINOR 16
#define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_MICRO 100
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
@ -45,23 +44,4 @@
#define LIBAVFORMAT_IDENT "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION) #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.
*
*/
#define FF_API_LAVF_PRIV_OPT (LIBAVFORMAT_VERSION_MAJOR < 60)
#define FF_API_COMPUTE_PKT_FIELDS2 (LIBAVFORMAT_VERSION_MAJOR < 60)
#define FF_API_AVIOCONTEXT_WRITTEN (LIBAVFORMAT_VERSION_MAJOR < 60)
#define FF_HLS_TS_OPTIONS (LIBAVFORMAT_VERSION_MAJOR < 60)
#define FF_API_AVSTREAM_CLASS (LIBAVFORMAT_VERSION_MAJOR > 59)
#define FF_HTTP_CACHE_REDIRECT_DEFAULT (LIBAVFORMAT_VERSION_MAJOR < 60)
#define FF_API_R_FRAME_RATE 1
#endif /* AVFORMAT_VERSION_H */ #endif /* AVFORMAT_VERSION_H */

View File

@ -0,0 +1,53 @@
/*
* 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 59
/**
* 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_LAVF_PRIV_OPT (LIBAVFORMAT_VERSION_MAJOR < 60)
#define FF_API_COMPUTE_PKT_FIELDS2 (LIBAVFORMAT_VERSION_MAJOR < 60)
#define FF_API_AVIOCONTEXT_WRITTEN (LIBAVFORMAT_VERSION_MAJOR < 60)
#define FF_HLS_TS_OPTIONS (LIBAVFORMAT_VERSION_MAJOR < 60)
#define FF_API_AVSTREAM_CLASS (LIBAVFORMAT_VERSION_MAJOR > 59)
#define FF_API_R_FRAME_RATE 1
#endif /* AVFORMAT_VERSION_MAJOR_H */

View File

@ -110,7 +110,7 @@
* scheduled for removal. * scheduled for removal.
*/ */
#ifndef AV_NOWARN_DEPRECATED #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) \ # define AV_NOWARN_DEPRECATED(code) \
_Pragma("GCC diagnostic push") \ _Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") \ _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") \

View File

@ -27,8 +27,7 @@
#ifndef AVUTIL_AUDIO_FIFO_H #ifndef AVUTIL_AUDIO_FIFO_H
#define AVUTIL_AUDIO_FIFO_H #define AVUTIL_AUDIO_FIFO_H
#include "avutil.h" #include "attributes.h"
#include "fifo.h"
#include "samplefmt.h" #include "samplefmt.h"
/** /**

View File

@ -28,8 +28,8 @@
#define AVUTIL_AVASSERT_H #define AVUTIL_AVASSERT_H
#include <stdlib.h> #include <stdlib.h>
#include "avutil.h"
#include "log.h" #include "log.h"
#include "macros.h"
/** /**
* assert() equivalent, that is always enabled. * assert() equivalent, that is always enabled.

View File

@ -331,12 +331,18 @@ unsigned av_int_list_length_for_size(unsigned elsize,
#define av_int_list_length(list, term) \ #define av_int_list_length(list, term) \
av_int_list_length_for_size(sizeof(*(list)), 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. * Open a file using a UTF-8 filename.
* The API of this function matches POSIX fopen(), errors are returned through * The API of this function matches POSIX fopen(), errors are returned through
* errno. * 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); FILE *av_fopen_utf8(const char *path, const char *mode);
#endif
/** /**
* Return the fractional representation of the internal time base. * Return the fractional representation of the internal time base.

View File

@ -23,6 +23,10 @@
#define AVUTIL_CHANNEL_LAYOUT_H #define AVUTIL_CHANNEL_LAYOUT_H
#include <stdint.h> #include <stdint.h>
#include <stdlib.h>
#include "version.h"
#include "attributes.h"
/** /**
* @file * @file
@ -34,6 +38,111 @@
* @{ * @{
*/ */
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 <i> between AV_CHAN_AMBISONIC_BASE and
* AV_CHAN_AMBISONIC_END (inclusive), the ACN index of the channel <n> is
* <n> = <i> - 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 * @defgroup channel_masks Audio channel masks
* *
@ -46,41 +155,46 @@
* *
* @{ * @{
*/ */
#define AV_CH_FRONT_LEFT 0x00000001 #define AV_CH_FRONT_LEFT (1ULL << AV_CHAN_FRONT_LEFT )
#define AV_CH_FRONT_RIGHT 0x00000002 #define AV_CH_FRONT_RIGHT (1ULL << AV_CHAN_FRONT_RIGHT )
#define AV_CH_FRONT_CENTER 0x00000004 #define AV_CH_FRONT_CENTER (1ULL << AV_CHAN_FRONT_CENTER )
#define AV_CH_LOW_FREQUENCY 0x00000008 #define AV_CH_LOW_FREQUENCY (1ULL << AV_CHAN_LOW_FREQUENCY )
#define AV_CH_BACK_LEFT 0x00000010 #define AV_CH_BACK_LEFT (1ULL << AV_CHAN_BACK_LEFT )
#define AV_CH_BACK_RIGHT 0x00000020 #define AV_CH_BACK_RIGHT (1ULL << AV_CHAN_BACK_RIGHT )
#define AV_CH_FRONT_LEFT_OF_CENTER 0x00000040 #define AV_CH_FRONT_LEFT_OF_CENTER (1ULL << AV_CHAN_FRONT_LEFT_OF_CENTER )
#define AV_CH_FRONT_RIGHT_OF_CENTER 0x00000080 #define AV_CH_FRONT_RIGHT_OF_CENTER (1ULL << AV_CHAN_FRONT_RIGHT_OF_CENTER)
#define AV_CH_BACK_CENTER 0x00000100 #define AV_CH_BACK_CENTER (1ULL << AV_CHAN_BACK_CENTER )
#define AV_CH_SIDE_LEFT 0x00000200 #define AV_CH_SIDE_LEFT (1ULL << AV_CHAN_SIDE_LEFT )
#define AV_CH_SIDE_RIGHT 0x00000400 #define AV_CH_SIDE_RIGHT (1ULL << AV_CHAN_SIDE_RIGHT )
#define AV_CH_TOP_CENTER 0x00000800 #define AV_CH_TOP_CENTER (1ULL << AV_CHAN_TOP_CENTER )
#define AV_CH_TOP_FRONT_LEFT 0x00001000 #define AV_CH_TOP_FRONT_LEFT (1ULL << AV_CHAN_TOP_FRONT_LEFT )
#define AV_CH_TOP_FRONT_CENTER 0x00002000 #define AV_CH_TOP_FRONT_CENTER (1ULL << AV_CHAN_TOP_FRONT_CENTER )
#define AV_CH_TOP_FRONT_RIGHT 0x00004000 #define AV_CH_TOP_FRONT_RIGHT (1ULL << AV_CHAN_TOP_FRONT_RIGHT )
#define AV_CH_TOP_BACK_LEFT 0x00008000 #define AV_CH_TOP_BACK_LEFT (1ULL << AV_CHAN_TOP_BACK_LEFT )
#define AV_CH_TOP_BACK_CENTER 0x00010000 #define AV_CH_TOP_BACK_CENTER (1ULL << AV_CHAN_TOP_BACK_CENTER )
#define AV_CH_TOP_BACK_RIGHT 0x00020000 #define AV_CH_TOP_BACK_RIGHT (1ULL << AV_CHAN_TOP_BACK_RIGHT )
#define AV_CH_STEREO_LEFT 0x20000000 ///< Stereo downmix. #define AV_CH_STEREO_LEFT (1ULL << AV_CHAN_STEREO_LEFT )
#define AV_CH_STEREO_RIGHT 0x40000000 ///< See AV_CH_STEREO_LEFT. #define AV_CH_STEREO_RIGHT (1ULL << AV_CHAN_STEREO_RIGHT )
#define AV_CH_WIDE_LEFT 0x0000000080000000ULL #define AV_CH_WIDE_LEFT (1ULL << AV_CHAN_WIDE_LEFT )
#define AV_CH_WIDE_RIGHT 0x0000000100000000ULL #define AV_CH_WIDE_RIGHT (1ULL << AV_CHAN_WIDE_RIGHT )
#define AV_CH_SURROUND_DIRECT_LEFT 0x0000000200000000ULL #define AV_CH_SURROUND_DIRECT_LEFT (1ULL << AV_CHAN_SURROUND_DIRECT_LEFT )
#define AV_CH_SURROUND_DIRECT_RIGHT 0x0000000400000000ULL #define AV_CH_SURROUND_DIRECT_RIGHT (1ULL << AV_CHAN_SURROUND_DIRECT_RIGHT)
#define AV_CH_LOW_FREQUENCY_2 0x0000000800000000ULL #define AV_CH_LOW_FREQUENCY_2 (1ULL << AV_CHAN_LOW_FREQUENCY_2 )
#define AV_CH_TOP_SIDE_LEFT 0x0000001000000000ULL #define AV_CH_TOP_SIDE_LEFT (1ULL << AV_CHAN_TOP_SIDE_LEFT )
#define AV_CH_TOP_SIDE_RIGHT 0x0000002000000000ULL #define AV_CH_TOP_SIDE_RIGHT (1ULL << AV_CHAN_TOP_SIDE_RIGHT )
#define AV_CH_BOTTOM_FRONT_CENTER 0x0000004000000000ULL #define AV_CH_BOTTOM_FRONT_CENTER (1ULL << AV_CHAN_BOTTOM_FRONT_CENTER )
#define AV_CH_BOTTOM_FRONT_LEFT 0x0000008000000000ULL #define AV_CH_BOTTOM_FRONT_LEFT (1ULL << AV_CHAN_BOTTOM_FRONT_LEFT )
#define AV_CH_BOTTOM_FRONT_RIGHT 0x0000010000000000ULL #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 /** Channel mask value used for AVCodecContext.request_channel_layout
to indicate that the user requests the channel order of the decoder output 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 #define AV_CH_LAYOUT_NATIVE 0x8000000000000000ULL
#endif
/** /**
* @} * @}
@ -128,6 +242,149 @@ enum AVMatrixEncoding {
AV_MATRIX_ENCODING_NB 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).
*
* Unlike most structures in Libav, 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;
#define AV_CHANNEL_LAYOUT_MASK(nb, m) \
{ .order = AV_CHANNEL_ORDER_NATIVE, .nb_channels = (nb), .u = { .mask = (m) }}
#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_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_OCTAGONAL AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_OCTAGONAL)
#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_AMBISONIC_FIRST_ORDER \
{ .order = AV_CHANNEL_ORDER_AMBISONIC, .nb_channels = 4, .u = { .mask = 0 }}
struct AVBPrint;
#if FF_API_OLD_CHANNEL_LAYOUT
/** /**
* Return a channel layout id that matches name, or 0 if no match is found. * Return a channel layout id that matches name, or 0 if no match is found.
* *
@ -144,7 +401,10 @@ enum AVMatrixEncoding {
* AV_CH_* macros). * AV_CH_* macros).
* *
* Example: "stereo+FC" = "2c+FC" = "2c+1c" = "0x7" * 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); uint64_t av_get_channel_layout(const char *name);
/** /**
@ -158,7 +418,9 @@ uint64_t av_get_channel_layout(const char *name);
* @param[out] nb_channels number of channels * @param[out] nb_channels number of channels
* *
* @return 0 on success, AVERROR(EINVAL) if the parsing fails. * @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); int av_get_extended_channel_layout(const char *name, uint64_t* channel_layout, int* nb_channels);
/** /**
@ -167,23 +429,31 @@ 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 put here the string containing the channel layout
* @param buf_size size in bytes of the buffer * @param buf_size size in bytes of the buffer
* @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); 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. * 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); void av_bprint_channel_layout(struct AVBPrint *bp, int nb_channels, uint64_t channel_layout);
/** /**
* Return the number of channels in the 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); int av_get_channel_layout_nb_channels(uint64_t channel_layout);
/** /**
* Return default channel layout for a given number of channels. * 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); int64_t av_get_default_channel_layout(int nb_channels);
/** /**
@ -194,20 +464,28 @@ int64_t av_get_default_channel_layout(int nb_channels);
* *
* @return index of channel in channel_layout on success, a negative AVERROR * @return index of channel in channel_layout on success, a negative AVERROR
* on error. * on error.
*
* @deprecated use av_channel_layout_index_from_channel()
*/ */
attribute_deprecated
int av_get_channel_layout_channel_index(uint64_t channel_layout, int av_get_channel_layout_channel_index(uint64_t channel_layout,
uint64_t channel); uint64_t channel);
/** /**
* Get the channel with the given index in channel_layout. * 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); uint64_t av_channel_layout_extract_channel(uint64_t channel_layout, int index);
/** /**
* Get the name of a given channel. * Get the name of a given channel.
* *
* @return channel name on success, NULL on error. * @return channel name on success, NULL on error.
*
* @deprecated use av_channel_name()
*/ */
attribute_deprecated
const char *av_get_channel_name(uint64_t channel); const char *av_get_channel_name(uint64_t channel);
/** /**
@ -215,7 +493,9 @@ const char *av_get_channel_name(uint64_t channel);
* *
* @param channel a channel layout with a single channel * @param channel a channel layout with a single channel
* @return channel description on success, NULL on error * @return channel description on success, NULL on error
* @deprecated use av_channel_description()
*/ */
attribute_deprecated
const char *av_get_channel_description(uint64_t channel); const char *av_get_channel_description(uint64_t channel);
/** /**
@ -226,9 +506,240 @@ const char *av_get_channel_description(uint64_t channel);
* @param[out] name name of the layout * @param[out] name name of the layout
* @return 0 if the layout exists, * @return 0 if the layout exists,
* <0 if index is beyond the limits * <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, int av_get_standard_channel_layout(unsigned index, uint64_t *layout,
const char **name); 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.
* @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.
* @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 channel_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
* @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
* @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
* @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
* @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);
/** /**
* @} * @}

View File

@ -41,7 +41,6 @@
#include "attributes.h" #include "attributes.h"
#include "macros.h" #include "macros.h"
#include "version.h"
//rounded division & shift //rounded division & shift
#define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b)) #define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b))

View File

@ -54,6 +54,7 @@
#define AV_CPU_FLAG_BMI1 0x20000 ///< Bit Manipulation Instruction Set 1 #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_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_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_SLOW_GATHER 0x2000000 ///< CPU has slow gathers.
#define AV_CPU_FLAG_ALTIVEC 0x0001 ///< standard #define AV_CPU_FLAG_ALTIVEC 0x0001 ///< standard

View File

@ -0,0 +1,106 @@
/*
* Copyright (c) 2016 Ronald S. Bultje <rsbultje@gmail.com>
* 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.
* @author Ronald S. Bultje <rsbultje@gmail.com>
* @author Leo Izen <leo.izen@gmail.com>
* @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;
/**
* 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);
/**
* @}
*/
#endif /* AVUTIL_CSP_H */

View File

@ -27,7 +27,6 @@
#define AVUTIL_DISPLAY_H #define AVUTIL_DISPLAY_H
#include <stdint.h> #include <stdint.h>
#include "common.h"
/** /**
* @addtogroup lavu_video * @addtogroup lavu_video

View File

@ -26,8 +26,6 @@
#ifndef AVUTIL_EVAL_H #ifndef AVUTIL_EVAL_H
#define AVUTIL_EVAL_H #define AVUTIL_EVAL_H
#include "avutil.h"
typedef struct AVExpr AVExpr; typedef struct AVExpr AVExpr;
/** /**

View File

@ -1,5 +1,5 @@
/* Automatically generated by version.sh, do not manually edit! */ /* Automatically generated by version.sh, do not manually edit! */
#ifndef AVUTIL_FFVERSION_H #ifndef AVUTIL_FFVERSION_H
#define AVUTIL_FFVERSION_H #define AVUTIL_FFVERSION_H
#define FFMPEG_VERSION "n5.0" #define FFMPEG_VERSION "N-107242-gc7ce03d826"
#endif /* AVUTIL_FFVERSION_H */ #endif /* AVUTIL_FFVERSION_H */

View File

@ -24,10 +24,205 @@
#ifndef AVUTIL_FIFO_H #ifndef AVUTIL_FIFO_H
#define AVUTIL_FIFO_H #define AVUTIL_FIFO_H
#include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include "avutil.h"
#include "attributes.h"
#include "attributes.h"
#include "version.h"
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.
*/
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), nothing is written and an error
* is returned.
*
* @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(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(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 { typedef struct AVFifoBuffer {
uint8_t *buffer; uint8_t *buffer;
uint8_t *rptr, *wptr, *end; uint8_t *rptr, *wptr, *end;
@ -38,7 +233,9 @@ typedef struct AVFifoBuffer {
* Initialize an AVFifoBuffer. * Initialize an AVFifoBuffer.
* @param size of FIFO * @param size of FIFO
* @return AVFifoBuffer or NULL in case of memory allocation failure * @return AVFifoBuffer or NULL in case of memory allocation failure
* @deprecated use av_fifo_alloc2()
*/ */
attribute_deprecated
AVFifoBuffer *av_fifo_alloc(unsigned int size); AVFifoBuffer *av_fifo_alloc(unsigned int size);
/** /**
@ -46,25 +243,33 @@ AVFifoBuffer *av_fifo_alloc(unsigned int size);
* @param nmemb number of elements * @param nmemb number of elements
* @param size size of the single element * @param size size of the single element
* @return AVFifoBuffer or NULL in case of memory allocation failure * @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); AVFifoBuffer *av_fifo_alloc_array(size_t nmemb, size_t size);
/** /**
* Free an AVFifoBuffer. * Free an AVFifoBuffer.
* @param f AVFifoBuffer to free * @param f AVFifoBuffer to free
* @deprecated use the AVFifo API with av_fifo_freep2()
*/ */
attribute_deprecated
void av_fifo_free(AVFifoBuffer *f); void av_fifo_free(AVFifoBuffer *f);
/** /**
* Free an AVFifoBuffer and reset pointer to NULL. * Free an AVFifoBuffer and reset pointer to NULL.
* @param f AVFifoBuffer to free * @param f AVFifoBuffer to free
* @deprecated use the AVFifo API with av_fifo_freep2()
*/ */
attribute_deprecated
void av_fifo_freep(AVFifoBuffer **f); void av_fifo_freep(AVFifoBuffer **f);
/** /**
* Reset the AVFifoBuffer to the state right after av_fifo_alloc, in particular it is emptied. * Reset the AVFifoBuffer to the state right after av_fifo_alloc, in particular it is emptied.
* @param f AVFifoBuffer to reset * @param f AVFifoBuffer to reset
* @deprecated use av_fifo_reset2() with the new AVFifo-API
*/ */
attribute_deprecated
void av_fifo_reset(AVFifoBuffer *f); void av_fifo_reset(AVFifoBuffer *f);
/** /**
@ -72,7 +277,9 @@ void av_fifo_reset(AVFifoBuffer *f);
* amount of data you can read from it. * amount of data you can read from it.
* @param f AVFifoBuffer to read from * @param f AVFifoBuffer to read from
* @return size * @return size
* @deprecated use av_fifo_can_read() with the new AVFifo-API
*/ */
attribute_deprecated
int av_fifo_size(const AVFifoBuffer *f); int av_fifo_size(const AVFifoBuffer *f);
/** /**
@ -80,7 +287,9 @@ int av_fifo_size(const AVFifoBuffer *f);
* amount of data you can write into it. * amount of data you can write into it.
* @param f AVFifoBuffer to write into * @param f AVFifoBuffer to write into
* @return size * @return size
* @deprecated use av_fifo_can_write() with the new AVFifo-API
*/ */
attribute_deprecated
int av_fifo_space(const AVFifoBuffer *f); int av_fifo_space(const AVFifoBuffer *f);
/** /**
@ -91,7 +300,13 @@ int av_fifo_space(const AVFifoBuffer *f);
* @param buf_size number of bytes to read * @param buf_size number of bytes to read
* @param func generic read function * @param func generic read function
* @param dest data destination * @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)); int av_fifo_generic_peek_at(AVFifoBuffer *f, void *dest, int offset, int buf_size, void (*func)(void*, void*, int));
/** /**
@ -101,7 +316,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 buf_size number of bytes to read
* @param func generic read function * @param func generic read function
* @param dest data destination * @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)); int av_fifo_generic_peek(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void*, void*, int));
/** /**
@ -110,7 +331,13 @@ int av_fifo_generic_peek(AVFifoBuffer *f, void *dest, int buf_size, void (*func)
* @param buf_size number of bytes to read * @param buf_size number of bytes to read
* @param func generic read function * @param func generic read function
* @param dest data destination * @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)); int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void*, void*, int));
/** /**
@ -124,8 +351,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 * func must return the number of bytes written to dest_buf, or <= 0 to
* indicate no more data available to write. * indicate no more data available to write.
* If func is NULL, src is interpreted as a simple byte array for source data. * 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)); int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void*, void*, int));
/** /**
@ -135,7 +366,11 @@ int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void
* @param f AVFifoBuffer to resize * @param f AVFifoBuffer to resize
* @param size new AVFifoBuffer size in bytes * @param size new AVFifoBuffer size in bytes
* @return <0 for failure, >=0 otherwise * @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); int av_fifo_realloc2(AVFifoBuffer *f, unsigned int size);
/** /**
@ -146,16 +381,24 @@ int av_fifo_realloc2(AVFifoBuffer *f, unsigned int size);
* @param f AVFifoBuffer to resize * @param f AVFifoBuffer to resize
* @param additional_space the amount of space in bytes to allocate in addition to av_fifo_size() * @param additional_space the amount of space in bytes to allocate in addition to av_fifo_size()
* @return <0 for failure, >=0 otherwise * @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); int av_fifo_grow(AVFifoBuffer *f, unsigned int additional_space);
/** /**
* Read and discard the specified amount of data from an AVFifoBuffer. * Read and discard the specified amount of data from an AVFifoBuffer.
* @param f AVFifoBuffer to read from * @param f AVFifoBuffer to read from
* @param size amount of data to read in bytes * @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); 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. * Return a pointer to the data stored in a FIFO buffer at a certain offset.
* The FIFO buffer is not modified. * The FIFO buffer is not modified.
@ -165,7 +408,9 @@ void av_fifo_drain(AVFifoBuffer *f, int size);
* than the used buffer size or the returned pointer will * than the used buffer size or the returned pointer will
* point outside to the buffer data. * point outside to the buffer data.
* The used buffer size can be checked with av_fifo_size(). * 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) static inline uint8_t *av_fifo_peek2(const AVFifoBuffer *f, int offs)
{ {
uint8_t *ptr = f->rptr + offs; uint8_t *ptr = f->rptr + offs;
@ -175,5 +420,7 @@ static inline uint8_t *av_fifo_peek2(const AVFifoBuffer *f, int offs)
ptr = f->end - (f->buffer - ptr); ptr = f->end - (f->buffer - ptr);
return ptr; return ptr;
} }
#endif
#endif
#endif /* AVUTIL_FIFO_H */ #endif /* AVUTIL_FIFO_H */

View File

@ -19,9 +19,10 @@
#ifndef AVUTIL_FILE_H #ifndef AVUTIL_FILE_H
#define AVUTIL_FILE_H #define AVUTIL_FILE_H
#include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include "avutil.h" #include "attributes.h"
/** /**
* @file * @file

View File

@ -30,6 +30,7 @@
#include "avutil.h" #include "avutil.h"
#include "buffer.h" #include "buffer.h"
#include "channel_layout.h"
#include "dict.h" #include "dict.h"
#include "rational.h" #include "rational.h"
#include "samplefmt.h" #include "samplefmt.h"
@ -201,6 +202,13 @@ enum AVFrameSideDataType {
* libavutil/dovi_meta.h. * libavutil/dovi_meta.h.
*/ */
AV_FRAME_DATA_DOVI_METADATA, 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,
}; };
enum AVActiveFormatDescription { enum AVActiveFormatDescription {
@ -493,10 +501,14 @@ typedef struct AVFrame {
*/ */
int sample_rate; int sample_rate;
#if FF_API_OLD_CHANNEL_LAYOUT
/** /**
* Channel layout of the audio data. * Channel layout of the audio data.
* @deprecated use ch_layout instead
*/ */
attribute_deprecated
uint64_t channel_layout; uint64_t channel_layout;
#endif
/** /**
* AVBuffer references backing the data for this frame. All the pointers in * AVBuffer references backing the data for this frame. All the pointers in
@ -620,12 +632,16 @@ typedef struct AVFrame {
#define FF_DECODE_ERROR_CONCEALMENT_ACTIVE 4 #define FF_DECODE_ERROR_CONCEALMENT_ACTIVE 4
#define FF_DECODE_ERROR_DECODE_SLICES 8 #define FF_DECODE_ERROR_DECODE_SLICES 8
#if FF_API_OLD_CHANNEL_LAYOUT
/** /**
* number of audio channels, only used for audio. * number of audio channels, only used for audio.
* - encoding: unused * - encoding: unused
* - decoding: Read by user. * - decoding: Read by user.
* @deprecated use ch_layout instead
*/ */
attribute_deprecated
int channels; int channels;
#endif
/** /**
* size of the corresponding packet containing the compressed * size of the corresponding packet containing the compressed
@ -681,6 +697,11 @@ typedef struct AVFrame {
* for the target frame's private_ref field. * for the target frame's private_ref field.
*/ */
AVBufferRef *private_ref; AVBufferRef *private_ref;
/**
* Channel layout of the audio data.
*/
AVChannelLayout ch_layout;
} AVFrame; } AVFrame;
@ -760,7 +781,7 @@ void av_frame_move_ref(AVFrame *dst, AVFrame *src);
* The following fields must be set on frame before calling this function: * The following fields must be set on frame before calling this function:
* - format (pixel format for video, sample format for audio) * - format (pixel format for video, sample format for audio)
* - width and height for video * - 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 * This function will fill AVFrame.data and AVFrame.buf arrays and, if
* necessary, allocate and fill AVFrame.extended_data and AVFrame.extended_buf. * necessary, allocate and fill AVFrame.extended_data and AVFrame.extended_buf.

View File

@ -0,0 +1,285 @@
/*
* Copyright (c) 2021 Limin Wang <lance.lmwang at gmail.com>
*
* 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"
/**
* 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;
/**
* The mode of three Spline. the value shall be in the range
* of 0 to 3, inclusive.
*/
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.
*
*/
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.
*/
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.
*/
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.
*/
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.
*/
AVRational three_Spline_enable_Strength;
} 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 */

View File

@ -571,6 +571,10 @@ enum {
* possible with the given arguments and hwframe setup, while other return * possible with the given arguments and hwframe setup, while other return
* values indicate that it failed somehow. * 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 dst Destination frame, to contain the mapping.
* @param src Source frame, to be mapped. * @param src Source frame, to be mapped.
* @param flags Some combination of AV_HWFRAME_MAP_* flags. * @param flags Some combination of AV_HWFRAME_MAP_* flags.

View File

@ -27,8 +27,10 @@
* @{ * @{
*/ */
#include "avutil.h" #include <stddef.h>
#include <stdint.h>
#include "pixdesc.h" #include "pixdesc.h"
#include "pixfmt.h"
#include "rational.h" #include "rational.h"
/** /**

View File

@ -22,8 +22,8 @@
#define AVUTIL_LOG_H #define AVUTIL_LOG_H
#include <stdarg.h> #include <stdarg.h>
#include "avutil.h"
#include "attributes.h" #include "attributes.h"
#include "version.h"
typedef enum { typedef enum {
AV_CLASS_CATEGORY_NA = 0, AV_CLASS_CATEGORY_NA = 0,

View File

@ -250,8 +250,7 @@ void *av_mallocz_array(size_t nmemb, size_t size) av_malloc_attrib av_alloc_size
/** /**
* Allocate, reallocate, or free a block of memory. * Allocate, reallocate, or free a block of memory.
* *
* If `ptr` is `NULL` and `size` > 0, allocate a new block. If `size` is * If `ptr` is `NULL` and `size` > 0, allocate a new block. Otherwise, expand or
* zero, free the memory block pointed to by `ptr`. Otherwise, expand or
* shrink that block of memory according to `size`. * shrink that block of memory according to `size`.
* *
* @param ptr Pointer to a memory block already allocated with * @param ptr Pointer to a memory block already allocated with
@ -260,10 +259,11 @@ void *av_mallocz_array(size_t nmemb, size_t size) av_malloc_attrib av_alloc_size
* reallocated * reallocated
* *
* @return Pointer to a newly-reallocated block or `NULL` if the block * @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 * @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_fast_realloc()
* @see av_reallocp() * @see av_reallocp()
*/ */
@ -311,8 +311,7 @@ void *av_realloc_f(void *ptr, size_t nelem, size_t elsize);
/** /**
* Allocate, reallocate, or free an array. * Allocate, reallocate, or free an array.
* *
* If `ptr` is `NULL` and `nmemb` > 0, allocate a new block. If * If `ptr` is `NULL` and `nmemb` > 0, allocate a new block.
* `nmemb` is zero, free the memory block pointed to by `ptr`.
* *
* @param ptr Pointer to a memory block already allocated with * @param ptr Pointer to a memory block already allocated with
* av_realloc() or `NULL` * av_realloc() or `NULL`
@ -320,19 +319,19 @@ void *av_realloc_f(void *ptr, size_t nelem, size_t elsize);
* @param size Size of the single element of the array * @param size Size of the single element of the array
* *
* @return Pointer to a newly-reallocated block or NULL if the block * @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 * @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() * @see av_reallocp_array()
*/ */
av_alloc_size(2, 3) void *av_realloc_array(void *ptr, size_t nmemb, size_t size); 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 * If `*ptr` is `NULL` and `nmemb` > 0, allocate a new block.
* zero, free the memory block pointed to by `*ptr`.
* *
* @param[in,out] ptr Pointer to a pointer to a memory block already * @param[in,out] ptr Pointer to a pointer to a memory block already
* allocated with av_realloc(), or a pointer to `NULL`. * allocated with av_realloc(), or a pointer to `NULL`.
@ -343,7 +342,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 * @return Zero on success, an AVERROR error code on failure
* *
* @warning Unlike av_malloc(), the allocated memory is not guaranteed to be * @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); int av_reallocp_array(void *ptr, size_t nmemb, size_t size);

View File

@ -29,6 +29,7 @@
#include "rational.h" #include "rational.h"
#include "avutil.h" #include "avutil.h"
#include "channel_layout.h"
#include "dict.h" #include "dict.h"
#include "log.h" #include "log.h"
#include "pixfmt.h" #include "pixfmt.h"
@ -237,8 +238,11 @@ enum AVOptionType{
AV_OPT_TYPE_VIDEO_RATE, ///< offset must point to AVRational AV_OPT_TYPE_VIDEO_RATE, ///< offset must point to AVRational
AV_OPT_TYPE_DURATION, AV_OPT_TYPE_DURATION,
AV_OPT_TYPE_COLOR, AV_OPT_TYPE_COLOR,
#if FF_API_OLD_CHANNEL_LAYOUT
AV_OPT_TYPE_CHANNEL_LAYOUT, AV_OPT_TYPE_CHANNEL_LAYOUT,
#endif
AV_OPT_TYPE_BOOL, AV_OPT_TYPE_BOOL,
AV_OPT_TYPE_CHLAYOUT,
}; };
/** /**
@ -693,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_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_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); 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); 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 * @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. * caller still owns val is and responsible for freeing it.
@ -748,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_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_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); 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); 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 * @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 * be freed with av_dict_free() by the caller

View File

@ -21,7 +21,6 @@
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include "common.h"
/** /**
* Sum of abs(src1[x] - src2[x]) * Sum of abs(src1[x] - src2[x])

View File

@ -260,7 +260,9 @@ enum AVPixelFormat {
AV_PIX_FMT_BAYER_GRBG16LE, ///< bayer, GRGR..(odd line), BGBG..(even line), 16-bit samples, little-endian 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 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 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_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 AV_PIX_FMT_YUV440P10BE, ///< planar YUV 4:4:0,20bpp, (1 Cr & Cb sample per 1x2 Y samples), big-endian
@ -360,7 +362,7 @@ enum AVPixelFormat {
AV_PIX_FMT_P410LE, ///< interleaved chroma YUV 4:4:4, 30bpp, data in the high bits, little-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_P216BE, ///< interleaved chroma YUV 4:2:2, 32bpp, big-endian
AV_PIX_FMT_P216LE, ///< interleaved chroma YUV 4:2:2, 32bpp, liddle-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_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_P416LE, ///< interleaved chroma YUV 4:4:4, 48bpp, little-endian

View File

@ -21,9 +21,6 @@
#include <stdint.h> #include <stdint.h>
#include "avutil.h"
#include "attributes.h"
/** /**
* @addtogroup lavu_audio * @addtogroup lavu_audio
* @{ * @{

View File

@ -38,50 +38,59 @@ typedef struct AVComplexInt32 {
enum AVTXType { 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. * 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 * Standard MDCT with a sample data type of float, double or int32_t,
* float. Length is the frame size, not the window size (which is 2x frame) * 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 * For forward transforms, the stride specifies the spacing between each
* sample in the output array in bytes. The input must be a flat array. * sample in the output array in bytes. The input must be a flat array.
* *
* For inverse transforms, the stride specifies the spacing between each * For inverse transforms, the stride specifies the spacing between each
* sample in the input array in bytes. The output will be a flat array. * sample in the input array in bytes. The output must be a flat array.
* Stride must be a non-zero multiple of sizeof(float).
* *
* NOTE: the inverse transform is half-length, meaning the output will not * 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 * 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. * inverse transform, set the AV_TX_FULL_IMDCT flag on init.
*/ */
AV_TX_FLOAT_MDCT = 1, AV_TX_FLOAT_MDCT = 1,
/**
* Same as AV_TX_FLOAT_FFT with a data type of AVComplexDouble.
*/
AV_TX_DOUBLE_FFT = 2,
/**
* Same as AV_TX_FLOAT_MDCT with data and scale type of double.
* Stride must be a non-zero multiple of sizeof(double).
*/
AV_TX_DOUBLE_MDCT = 3, AV_TX_DOUBLE_MDCT = 3,
AV_TX_INT32_MDCT = 5,
/** /**
* Same as AV_TX_FLOAT_FFT with a data type of AVComplexInt32. * 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.
*
* The stride parameter must be set to the size of a single sample 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_INT32_FFT = 4, AV_TX_FLOAT_RDFT = 6,
AV_TX_DOUBLE_RDFT = 7,
AV_TX_INT32_RDFT = 8,
/** /* Not part of the API, do not use */
* Same as AV_TX_FLOAT_MDCT with data type of int32_t and scale type of float. AV_TX_NB,
* Only scale values less than or equal to 1.0 are supported.
* Stride must be a non-zero multiple of sizeof(int32_t).
*/
AV_TX_INT32_MDCT = 5,
}; };
/** /**
@ -145,7 +154,7 @@ int av_tx_init(AVTXContext **ctx, av_tx_fn *tx, enum AVTXType type,
int inv, int len, const void *scale, uint64_t flags); 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); void av_tx_uninit(AVTXContext **ctx);

View File

@ -0,0 +1,147 @@
/*
* Copyright (c) 2022 Pierre-Anthony Lemieux <pal@palemieux.com>
* Zane van Iperen <zane@zanevaniperen.com>
*
* 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 <pal@palemieux.com>
* @author Zane van Iperen <zane@zanevaniperen.com>
*/
#ifndef AVUTIL_UUID_H
#define AVUTIL_UUID_H
#include <stdint.h>
#include <string.h>
#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.
* @return A non-zero value in case of an error.
*/
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 */

View File

@ -79,7 +79,7 @@
*/ */
#define LIBAVUTIL_VERSION_MAJOR 57 #define LIBAVUTIL_VERSION_MAJOR 57
#define LIBAVUTIL_VERSION_MINOR 17 #define LIBAVUTIL_VERSION_MINOR 27
#define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
@ -109,6 +109,11 @@
#define FF_API_DECLARE_ALIGNED (LIBAVUTIL_VERSION_MAJOR < 58) #define FF_API_DECLARE_ALIGNED (LIBAVUTIL_VERSION_MAJOR < 58)
#define FF_API_COLORSPACE_NAME (LIBAVUTIL_VERSION_MAJOR < 58) #define FF_API_COLORSPACE_NAME (LIBAVUTIL_VERSION_MAJOR < 58)
#define FF_API_AV_MALLOCZ_ARRAY (LIBAVUTIL_VERSION_MAJOR < 58) #define FF_API_AV_MALLOCZ_ARRAY (LIBAVUTIL_VERSION_MAJOR < 58)
#define FF_API_FIFO_PEEK2 (LIBAVUTIL_VERSION_MAJOR < 58)
#define FF_API_FIFO_OLD_API (LIBAVUTIL_VERSION_MAJOR < 58)
#define FF_API_XVMC (LIBAVUTIL_VERSION_MAJOR < 58)
#define FF_API_OLD_CHANNEL_LAYOUT (LIBAVUTIL_VERSION_MAJOR < 58)
#define FF_API_AV_FOPEN_UTF8 (LIBAVUTIL_VERSION_MAJOR < 58)
/** /**
* @} * @}

View File

@ -34,11 +34,11 @@
* Audio resampling, sample format conversion and mixing library. * Audio resampling, sample format conversion and mixing library.
* *
* Interaction with lswr is done through SwrContext, which is * 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. * must be set with the @ref avoptions API.
* *
* The first thing you will need to do in order to use lswr is to allocate * 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. * 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 * The latter function provides the same feature, but it allows you to set some
* common options in the same statement. * common options in the same statement.
@ -57,13 +57,14 @@
* av_opt_set_sample_fmt(swr, "out_sample_fmt", AV_SAMPLE_FMT_S16, 0); * av_opt_set_sample_fmt(swr, "out_sample_fmt", AV_SAMPLE_FMT_S16, 0);
* @endcode * @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 * @code
* SwrContext *swr = swr_alloc_set_opts(NULL, // we're allocating a new context * SwrContext *swr = NULL;
* AV_CH_LAYOUT_STEREO, // out_ch_layout * 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 * AV_SAMPLE_FMT_S16, // out_sample_fmt
* 44100, // out_sample_rate * 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 * AV_SAMPLE_FMT_FLTP, // in_sample_fmt
* 48000, // in_sample_rate * 48000, // in_sample_rate
* 0, // log_offset * 0, // log_offset
@ -73,7 +74,7 @@
* Once all values have been set, it must be initialized with swr_init(). If * 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 * 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 * 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. * swr_alloc_set_opts2(), but with the first argument the allocated context.
* You must then call swr_init() again. * You must then call swr_init() again.
* *
* The conversion itself is done by repeatedly calling swr_convert(). * The conversion itself is done by repeatedly calling swr_convert().
@ -124,7 +125,13 @@
#include "libavutil/frame.h" #include "libavutil/frame.h"
#include "libavutil/samplefmt.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" #include "libswresample/version.h"
#endif
/** /**
* @name Option constants * @name Option constants
@ -199,9 +206,9 @@ const AVClass *swr_get_class(void);
* Allocate SwrContext. * Allocate SwrContext.
* *
* If you use this function you will need to set the parameters (manually or * 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 * @return NULL on error, allocated context otherwise
*/ */
struct SwrContext *swr_alloc(void); struct SwrContext *swr_alloc(void);
@ -227,6 +234,7 @@ int swr_init(struct SwrContext *s);
*/ */
int swr_is_initialized(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. * 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() * @see swr_init(), swr_free()
* @return NULL on error, allocated context otherwise * @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, 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 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, int64_t in_ch_layout, enum AVSampleFormat in_sample_fmt, int in_sample_rate,
int log_offset, void *log_ctx); 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,
AVChannelLayout *out_ch_layout, enum AVSampleFormat out_sample_fmt, int out_sample_rate,
AVChannelLayout *in_ch_layout, enum AVSampleFormat in_sample_fmt, int in_sample_rate,
int log_offset, void *log_ctx);
/** /**
* @} * @}
* *
@ -362,6 +399,40 @@ int swr_set_compensation(struct SwrContext *s, int sample_delta, int compensatio
*/ */
int swr_set_channel_mapping(struct SwrContext *s, const int *channel_map); int swr_set_channel_mapping(struct SwrContext *s, const int *channel_map);
#if FF_API_OLD_CHANNEL_LAYOUT
/**
* 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
* @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. * Generate a channel mixing matrix.
* *
@ -385,12 +456,12 @@ int swr_set_channel_mapping(struct SwrContext *s, const int *channel_map);
* @param log_ctx parent logging context, can be NULL * @param log_ctx parent logging context, can be NULL
* @return 0 on success, negative AVERROR code on failure * @return 0 on success, negative AVERROR code on failure
*/ */
int swr_build_matrix(uint64_t in_layout, uint64_t out_layout, int swr_build_matrix2(const AVChannelLayout *in_layout, const AVChannelLayout *out_layout,
double center_mix_level, double surround_mix_level, double center_mix_level, double surround_mix_level,
double lfe_mix_level, double rematrix_maxval, double lfe_mix_level, double maxval,
double rematrix_volume, double *matrix, double rematrix_volume, double *matrix,
int stride, enum AVMatrixEncoding matrix_encoding, ptrdiff_t stride, enum AVMatrixEncoding matrix_encoding,
void *log_ctx); void *log_context);
/** /**
* Set a customized remix matrix. * Set a customized remix matrix.

View File

@ -28,8 +28,9 @@
#include "libavutil/version.h" #include "libavutil/version.h"
#define LIBSWRESAMPLE_VERSION_MAJOR 4 #include "version_major.h"
#define LIBSWRESAMPLE_VERSION_MINOR 3
#define LIBSWRESAMPLE_VERSION_MINOR 6
#define LIBSWRESAMPLE_VERSION_MICRO 100 #define LIBSWRESAMPLE_VERSION_MICRO 100
#define LIBSWRESAMPLE_VERSION_INT AV_VERSION_INT(LIBSWRESAMPLE_VERSION_MAJOR, \ #define LIBSWRESAMPLE_VERSION_INT AV_VERSION_INT(LIBSWRESAMPLE_VERSION_MAJOR, \

View File

@ -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 */

Binary file not shown.

Binary file not shown.