mirror of
https://github.com/RPCS3/ffmpeg-core.git
synced 2026-01-31 01:25:19 +01:00
include: Update headers (#24)
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -19,6 +19,10 @@
|
||||
#ifndef AVCODEC_AVFFT_H
|
||||
#define AVCODEC_AVFFT_H
|
||||
|
||||
#include "libavutil/attributes.h"
|
||||
#include "version_major.h"
|
||||
#if FF_API_AVFFT
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavc_fft
|
||||
@@ -44,26 +48,42 @@ typedef struct FFTContext FFTContext;
|
||||
* Set up a complex FFT.
|
||||
* @param nbits log2 of the length of the input array
|
||||
* @param inverse if 0 perform the forward transform, if 1 perform the inverse
|
||||
* @deprecated use av_tx_init from libavutil/tx.h with a type of AV_TX_FLOAT_FFT
|
||||
*/
|
||||
attribute_deprecated
|
||||
FFTContext *av_fft_init(int nbits, int inverse);
|
||||
|
||||
/**
|
||||
* Do the permutation needed BEFORE calling ff_fft_calc().
|
||||
* @deprecated without replacement
|
||||
*/
|
||||
attribute_deprecated
|
||||
void av_fft_permute(FFTContext *s, FFTComplex *z);
|
||||
|
||||
/**
|
||||
* Do a complex FFT with the parameters defined in av_fft_init(). The
|
||||
* input data must be permuted before. No 1.0/sqrt(n) normalization is done.
|
||||
* @deprecated use the av_tx_fn value returned by av_tx_init, which also does permutation
|
||||
*/
|
||||
attribute_deprecated
|
||||
void av_fft_calc(FFTContext *s, FFTComplex *z);
|
||||
|
||||
attribute_deprecated
|
||||
void av_fft_end(FFTContext *s);
|
||||
|
||||
/**
|
||||
* @deprecated use av_tx_init from libavutil/tx.h with a type of AV_TX_FLOAT_MDCT,
|
||||
* with a flag of AV_TX_FULL_IMDCT for a replacement to av_imdct_calc.
|
||||
*/
|
||||
attribute_deprecated
|
||||
FFTContext *av_mdct_init(int nbits, int inverse, double scale);
|
||||
attribute_deprecated
|
||||
void av_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input);
|
||||
attribute_deprecated
|
||||
void av_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input);
|
||||
attribute_deprecated
|
||||
void av_mdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input);
|
||||
attribute_deprecated
|
||||
void av_mdct_end(FFTContext *s);
|
||||
|
||||
/* Real Discrete Fourier Transform */
|
||||
@@ -81,9 +101,14 @@ typedef struct RDFTContext RDFTContext;
|
||||
* Set up a real FFT.
|
||||
* @param nbits log2 of the length of the input array
|
||||
* @param trans the type of transform
|
||||
*
|
||||
* @deprecated use av_tx_init from libavutil/tx.h with a type of AV_TX_FLOAT_RDFT
|
||||
*/
|
||||
attribute_deprecated
|
||||
RDFTContext *av_rdft_init(int nbits, enum RDFTransformType trans);
|
||||
attribute_deprecated
|
||||
void av_rdft_calc(RDFTContext *s, FFTSample *data);
|
||||
attribute_deprecated
|
||||
void av_rdft_end(RDFTContext *s);
|
||||
|
||||
/* Discrete Cosine Transform */
|
||||
@@ -106,13 +131,19 @@ enum DCTTransformType {
|
||||
* @param type the type of transform
|
||||
*
|
||||
* @note the first element of the input of DST-I is ignored
|
||||
*
|
||||
* @deprecated use av_tx_init from libavutil/tx.h with an appropriate type of AV_TX_FLOAT_DCT
|
||||
*/
|
||||
attribute_deprecated
|
||||
DCTContext *av_dct_init(int nbits, enum DCTTransformType type);
|
||||
attribute_deprecated
|
||||
void av_dct_calc(DCTContext *s, FFTSample *data);
|
||||
attribute_deprecated
|
||||
void av_dct_end (DCTContext *s);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* FF_API_AVFFT */
|
||||
#endif /* AVCODEC_AVFFT_H */
|
||||
|
||||
@@ -164,6 +164,8 @@ int av_bsf_alloc(const AVBitStreamFilter *filter, AVBSFContext **ctx);
|
||||
/**
|
||||
* Prepare the filter for use, after all the parameters and options have been
|
||||
* set.
|
||||
*
|
||||
* @param ctx a AVBSFContext previously allocated with av_bsf_alloc()
|
||||
*/
|
||||
int av_bsf_init(AVBSFContext *ctx);
|
||||
|
||||
@@ -174,6 +176,7 @@ int av_bsf_init(AVBSFContext *ctx);
|
||||
* av_bsf_receive_packet() repeatedly until it returns AVERROR(EAGAIN) or
|
||||
* AVERROR_EOF.
|
||||
*
|
||||
* @param ctx an initialized AVBSFContext
|
||||
* @param pkt the packet to filter. The bitstream filter will take ownership of
|
||||
* the packet and reset the contents of pkt. pkt is not touched if an error occurs.
|
||||
* If pkt is empty (i.e. NULL, or pkt->data is NULL and pkt->side_data_elems zero),
|
||||
@@ -192,6 +195,7 @@ int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt);
|
||||
/**
|
||||
* Retrieve a filtered packet.
|
||||
*
|
||||
* @param ctx an initialized AVBSFContext
|
||||
* @param[out] pkt this struct will be filled with the contents of the filtered
|
||||
* packet. It is owned by the caller and must be freed using
|
||||
* av_packet_unref() when it is no longer needed.
|
||||
|
||||
51
include/libavcodec/cabac.h
Normal file
51
include/libavcodec/cabac.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder
|
||||
* Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* 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
|
||||
* Context Adaptive Binary Arithmetic Coder.
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_CABAC_H
|
||||
#define AVCODEC_CABAC_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
extern const uint8_t ff_h264_cabac_tables[512 + 4*2*64 + 4*64 + 63];
|
||||
#define H264_NORM_SHIFT_OFFSET 0
|
||||
#define H264_LPS_RANGE_OFFSET 512
|
||||
#define H264_MLPS_STATE_OFFSET 1024
|
||||
#define H264_LAST_COEFF_FLAG_OFFSET_8x8_OFFSET 1280
|
||||
|
||||
#define CABAC_BITS 16
|
||||
#define CABAC_MASK ((1<<CABAC_BITS)-1)
|
||||
|
||||
typedef struct CABACContext{
|
||||
int low;
|
||||
int range;
|
||||
const uint8_t *bytestream_start;
|
||||
const uint8_t *bytestream;
|
||||
const uint8_t *bytestream_end;
|
||||
}CABACContext;
|
||||
|
||||
int ff_init_cabac_decoder(CABACContext *c, const uint8_t *buf, int buf_size);
|
||||
|
||||
#endif /* AVCODEC_CABAC_H */
|
||||
@@ -50,12 +50,6 @@
|
||||
* avcodec_default_get_buffer2 or avcodec_default_get_encode_buffer.
|
||||
*/
|
||||
#define AV_CODEC_CAP_DR1 (1 << 1)
|
||||
#if FF_API_FLAG_TRUNCATED
|
||||
/**
|
||||
* @deprecated Use parsers to always send proper frames.
|
||||
*/
|
||||
#define AV_CODEC_CAP_TRUNCATED (1 << 3)
|
||||
#endif
|
||||
/**
|
||||
* Encoder or decoder requires flushing with NULL input at the end in order to
|
||||
* give the complete and correct output.
|
||||
@@ -86,6 +80,7 @@
|
||||
*/
|
||||
#define AV_CODEC_CAP_SMALL_LAST_FRAME (1 << 6)
|
||||
|
||||
#if FF_API_SUBFRAMES
|
||||
/**
|
||||
* Codec can output multiple frames per AVPacket
|
||||
* Normally demuxers return one frame at a time, demuxers which do not do
|
||||
@@ -98,6 +93,8 @@
|
||||
* as a last resort.
|
||||
*/
|
||||
#define AV_CODEC_CAP_SUBFRAMES (1 << 8)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Codec is experimental and is thus avoided in favor of non experimental
|
||||
* encoders
|
||||
@@ -125,9 +122,6 @@
|
||||
* multithreading-capable external libraries.
|
||||
*/
|
||||
#define AV_CODEC_CAP_OTHER_THREADS (1 << 15)
|
||||
#if FF_API_AUTO_THREADS
|
||||
#define AV_CODEC_CAP_AUTO_THREADS AV_CODEC_CAP_OTHER_THREADS
|
||||
#endif
|
||||
/**
|
||||
* Audio encoder supports receiving a different number of samples in each call.
|
||||
*/
|
||||
@@ -143,17 +137,6 @@
|
||||
*/
|
||||
#define AV_CODEC_CAP_AVOID_PROBING (1 << 17)
|
||||
|
||||
#if FF_API_UNUSED_CODEC_CAPS
|
||||
/**
|
||||
* Deprecated and unused. Use AVCodecDescriptor.props instead
|
||||
*/
|
||||
#define AV_CODEC_CAP_INTRA_ONLY 0x40000000
|
||||
/**
|
||||
* Deprecated and unused. Use AVCodecDescriptor.props instead
|
||||
*/
|
||||
#define AV_CODEC_CAP_LOSSLESS 0x80000000
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Codec is backed by a hardware implementation. Typically used to
|
||||
* identify a non-hwaccel hardware decoder. For information about hwaccels, use
|
||||
@@ -169,9 +152,9 @@
|
||||
#define AV_CODEC_CAP_HYBRID (1 << 19)
|
||||
|
||||
/**
|
||||
* This codec takes the reordered_opaque field from input AVFrames
|
||||
* and returns it in the corresponding field in AVCodecContext after
|
||||
* encoding.
|
||||
* This encoder can reorder user opaque values from input AVFrames and return
|
||||
* them with corresponding output packets.
|
||||
* @see AV_CODEC_FLAG_COPY_OPAQUE
|
||||
*/
|
||||
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE (1 << 20)
|
||||
|
||||
@@ -182,6 +165,14 @@
|
||||
*/
|
||||
#define AV_CODEC_CAP_ENCODER_FLUSH (1 << 21)
|
||||
|
||||
/**
|
||||
* The encoder is able to output reconstructed frame data, i.e. raw frames that
|
||||
* would be produced by decoding the encoded bitstream.
|
||||
*
|
||||
* Reconstructed frame output is enabled by the AV_CODEC_FLAG_RECON_FRAME flag.
|
||||
*/
|
||||
#define AV_CODEC_CAP_ENCODER_RECON_FRAME (1 << 22)
|
||||
|
||||
/**
|
||||
* AVProfile.
|
||||
*/
|
||||
@@ -214,19 +205,21 @@ typedef struct AVCodec {
|
||||
*/
|
||||
int capabilities;
|
||||
uint8_t max_lowres; ///< maximum value for lowres supported by the decoder
|
||||
const AVRational *supported_framerates; ///< array of supported framerates, or NULL if any, array is terminated by {0,0}
|
||||
const enum AVPixelFormat *pix_fmts; ///< array of supported pixel formats, or NULL if unknown, array is terminated by -1
|
||||
const int *supported_samplerates; ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0
|
||||
const enum AVSampleFormat *sample_fmts; ///< array of supported sample formats, or NULL if unknown, array is terminated by -1
|
||||
#if FF_API_OLD_CHANNEL_LAYOUT
|
||||
|
||||
/**
|
||||
* @deprecated use ch_layouts instead
|
||||
* Deprecated codec capabilities.
|
||||
*/
|
||||
attribute_deprecated
|
||||
const uint64_t *channel_layouts; ///< array of support channel layouts, or NULL if unknown. array is terminated by 0
|
||||
#endif
|
||||
const AVRational *supported_framerates; ///< @deprecated use avcodec_get_supported_config()
|
||||
attribute_deprecated
|
||||
const enum AVPixelFormat *pix_fmts; ///< @deprecated use avcodec_get_supported_config()
|
||||
attribute_deprecated
|
||||
const int *supported_samplerates; ///< @deprecated use avcodec_get_supported_config()
|
||||
attribute_deprecated
|
||||
const enum AVSampleFormat *sample_fmts; ///< @deprecated use avcodec_get_supported_config()
|
||||
|
||||
const AVClass *priv_class; ///< AVClass for the private context
|
||||
const AVProfile *profiles; ///< array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN}
|
||||
const AVProfile *profiles; ///< array of recognized profiles, or NULL if unknown, array is terminated by {AV_PROFILE_UNKNOWN}
|
||||
|
||||
/**
|
||||
* Group name of the codec implementation.
|
||||
@@ -242,7 +235,9 @@ typedef struct AVCodec {
|
||||
|
||||
/**
|
||||
* Array of supported channel layouts, terminated with a zeroed layout.
|
||||
* @deprecated use avcodec_get_supported_config()
|
||||
*/
|
||||
attribute_deprecated
|
||||
const AVChannelLayout *ch_layouts;
|
||||
} AVCodec;
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ typedef struct AVCodecDescriptor {
|
||||
const char *const *mime_types;
|
||||
/**
|
||||
* If non-NULL, an array of profiles recognized for this codec.
|
||||
* Terminated with FF_PROFILE_UNKNOWN.
|
||||
* Terminated with AV_PROFILE_UNKNOWN.
|
||||
*/
|
||||
const struct AVProfile *profiles;
|
||||
} AVCodecDescriptor;
|
||||
@@ -90,6 +90,12 @@ typedef struct AVCodecDescriptor {
|
||||
* equal.
|
||||
*/
|
||||
#define AV_CODEC_PROP_REORDER (1 << 3)
|
||||
|
||||
/**
|
||||
* Video codec supports separate coding of fields in interlaced frames.
|
||||
*/
|
||||
#define AV_CODEC_PROP_FIELDS (1 << 4)
|
||||
|
||||
/**
|
||||
* Subtitle codec is bitmap based
|
||||
* Decoded AVSubtitle data can be read from the AVSubtitleRect->pict field.
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
#include "libavutil/avutil.h"
|
||||
#include "libavutil/samplefmt.h"
|
||||
|
||||
#include "version_major.h"
|
||||
|
||||
/**
|
||||
* @addtogroup lavc_core
|
||||
* @{
|
||||
@@ -251,7 +253,6 @@ enum AVCodecID {
|
||||
AV_CODEC_ID_AVRP,
|
||||
AV_CODEC_ID_012V,
|
||||
AV_CODEC_ID_AVUI,
|
||||
AV_CODEC_ID_AYUV,
|
||||
AV_CODEC_ID_TARGA_Y216,
|
||||
AV_CODEC_ID_V308,
|
||||
AV_CODEC_ID_V408,
|
||||
@@ -312,6 +313,15 @@ enum AVCodecID {
|
||||
AV_CODEC_ID_JPEGXL,
|
||||
AV_CODEC_ID_QOI,
|
||||
AV_CODEC_ID_PHM,
|
||||
AV_CODEC_ID_RADIANCE_HDR,
|
||||
AV_CODEC_ID_WBMP,
|
||||
AV_CODEC_ID_MEDIA100,
|
||||
AV_CODEC_ID_VQC,
|
||||
AV_CODEC_ID_PDV,
|
||||
AV_CODEC_ID_EVC,
|
||||
AV_CODEC_ID_RTV1,
|
||||
AV_CODEC_ID_VMIX,
|
||||
AV_CODEC_ID_LEAD,
|
||||
|
||||
/* various PCM "codecs" */
|
||||
AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs
|
||||
@@ -405,6 +415,7 @@ enum AVCodecID {
|
||||
AV_CODEC_ID_ADPCM_IMA_CUNNING,
|
||||
AV_CODEC_ID_ADPCM_IMA_MOFLEX,
|
||||
AV_CODEC_ID_ADPCM_IMA_ACORN,
|
||||
AV_CODEC_ID_ADPCM_XMD,
|
||||
|
||||
/* AMR */
|
||||
AV_CODEC_ID_AMR_NB = 0x12000,
|
||||
@@ -422,6 +433,8 @@ enum AVCodecID {
|
||||
AV_CODEC_ID_SDX2_DPCM,
|
||||
AV_CODEC_ID_GREMLIN_DPCM,
|
||||
AV_CODEC_ID_DERF_DPCM,
|
||||
AV_CODEC_ID_WADY_DPCM,
|
||||
AV_CODEC_ID_CBD2_DPCM,
|
||||
|
||||
/* audio codecs */
|
||||
AV_CODEC_ID_MP2 = 0x15000,
|
||||
@@ -521,6 +534,16 @@ enum AVCodecID {
|
||||
AV_CODEC_ID_FASTAUDIO,
|
||||
AV_CODEC_ID_MSNSIREN,
|
||||
AV_CODEC_ID_DFPWM,
|
||||
AV_CODEC_ID_BONK,
|
||||
AV_CODEC_ID_MISC4,
|
||||
AV_CODEC_ID_APAC,
|
||||
AV_CODEC_ID_FTR,
|
||||
AV_CODEC_ID_WAVARC,
|
||||
AV_CODEC_ID_RKA,
|
||||
AV_CODEC_ID_AC4,
|
||||
AV_CODEC_ID_OSQ,
|
||||
AV_CODEC_ID_QOA,
|
||||
AV_CODEC_ID_LC3,
|
||||
|
||||
/* subtitle codecs */
|
||||
AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs.
|
||||
@@ -565,6 +588,8 @@ enum AVCodecID {
|
||||
AV_CODEC_ID_DVD_NAV,
|
||||
AV_CODEC_ID_TIMED_ID3,
|
||||
AV_CODEC_ID_BIN_DATA,
|
||||
AV_CODEC_ID_SMPTE_2038,
|
||||
AV_CODEC_ID_LCEVC,
|
||||
|
||||
|
||||
AV_CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify it
|
||||
@@ -575,6 +600,16 @@ enum AVCodecID {
|
||||
* stream (only used by libavformat) */
|
||||
AV_CODEC_ID_FFMETADATA = 0x21000, ///< Dummy codec for streams containing only metadata information.
|
||||
AV_CODEC_ID_WRAPPED_AVFRAME = 0x21001, ///< Passthrough codec, AVFrames wrapped in AVPacket
|
||||
/**
|
||||
* Dummy null video codec, useful mainly for development and debugging.
|
||||
* Null encoder/decoder discard all input and never return any output.
|
||||
*/
|
||||
AV_CODEC_ID_VNULL,
|
||||
/**
|
||||
* Dummy null audio codec, useful mainly for development and debugging.
|
||||
* Null encoder/decoder discard all input and never return any output.
|
||||
*/
|
||||
AV_CODEC_ID_ANULL,
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,14 +21,17 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libavcodec/codec.h"
|
||||
#include "libavutil/attributes.h"
|
||||
#include "avcodec.h"
|
||||
#include "codec.h"
|
||||
|
||||
/**
|
||||
* The codec does not modify any global variables in the init function,
|
||||
* allowing to call the init function without locking any global mutexes.
|
||||
* The codec is not known to be init-threadsafe (i.e. it might be unsafe
|
||||
* to initialize this codec and another codec concurrently, typically because
|
||||
* the codec calls external APIs that are not known to be thread-safe).
|
||||
* Therefore calling the codec's init function needs to be guarded with a lock.
|
||||
*/
|
||||
#define FF_CODEC_CAP_INIT_THREADSAFE (1 << 0)
|
||||
#define FF_CODEC_CAP_NOT_INIT_THREADSAFE (1 << 0)
|
||||
/**
|
||||
* The codec allows calling the close function for deallocation even if
|
||||
* the init function returned a failure. Without this capability flag, a
|
||||
@@ -36,43 +39,54 @@
|
||||
* init function and does not expect the close function to be called at
|
||||
* all.
|
||||
*/
|
||||
#define FF_CODEC_CAP_INIT_CLEANUP (1 << 1)
|
||||
#define FF_CODEC_CAP_INIT_CLEANUP (1 << 1)
|
||||
/**
|
||||
* Decoders marked with FF_CODEC_CAP_SETS_PKT_DTS want to set
|
||||
* AVFrame.pkt_dts manually. If the flag is set, decode.c won't overwrite
|
||||
* this field. If it's unset, decode.c tries to guess the pkt_dts field
|
||||
* from the input AVPacket.
|
||||
*/
|
||||
#define FF_CODEC_CAP_SETS_PKT_DTS (1 << 2)
|
||||
#define FF_CODEC_CAP_SETS_PKT_DTS (1 << 2)
|
||||
/**
|
||||
* The decoder extracts and fills its parameters even if the frame is
|
||||
* skipped due to the skip_frame setting.
|
||||
*/
|
||||
#define FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM (1 << 3)
|
||||
#define FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM (1 << 3)
|
||||
/**
|
||||
* The decoder sets the cropping fields in the output frames manually.
|
||||
* If this cap is set, the generic code will initialize output frame
|
||||
* dimensions to coded rather than display values.
|
||||
*/
|
||||
#define FF_CODEC_CAP_EXPORTS_CROPPING (1 << 4)
|
||||
#define FF_CODEC_CAP_EXPORTS_CROPPING (1 << 4)
|
||||
/**
|
||||
* Codec initializes slice-based threading with a main function
|
||||
*/
|
||||
#define FF_CODEC_CAP_SLICE_THREAD_HAS_MF (1 << 5)
|
||||
/*
|
||||
* The codec supports frame threading and has inter-frame dependencies, so it
|
||||
* uses ff_thread_report/await_progress().
|
||||
#define FF_CODEC_CAP_SLICE_THREAD_HAS_MF (1 << 5)
|
||||
/**
|
||||
* The decoder might make use of the ProgressFrame API.
|
||||
*/
|
||||
#define FF_CODEC_CAP_ALLOCATE_PROGRESS (1 << 6)
|
||||
#define FF_CODEC_CAP_USES_PROGRESSFRAMES (1 << 6)
|
||||
/**
|
||||
* Codec handles avctx->thread_count == 0 (auto) internally.
|
||||
*/
|
||||
#define FF_CODEC_CAP_AUTO_THREADS (1 << 7)
|
||||
#define FF_CODEC_CAP_AUTO_THREADS (1 << 7)
|
||||
/**
|
||||
* Codec handles output frame properties internally instead of letting the
|
||||
* internal logic derive them from AVCodecInternal.last_pkt_props.
|
||||
*/
|
||||
#define FF_CODEC_CAP_SETS_FRAME_PROPS (1 << 8)
|
||||
#define FF_CODEC_CAP_SETS_FRAME_PROPS (1 << 8)
|
||||
/**
|
||||
* Codec supports embedded ICC profiles (AV_FRAME_DATA_ICC_PROFILE).
|
||||
*/
|
||||
#define FF_CODEC_CAP_ICC_PROFILES (1 << 9)
|
||||
/**
|
||||
* The encoder has AV_CODEC_CAP_DELAY set, but does not actually have delay - it
|
||||
* only wants to be flushed at the end to update some context variables (e.g.
|
||||
* 2pass stats) or produce a trailing packet. Besides that it immediately
|
||||
* produces exactly one output packet per each input frame, just as no-delay
|
||||
* encoders do.
|
||||
*/
|
||||
#define FF_CODEC_CAP_EOF_FLUSH (1 << 10)
|
||||
|
||||
/**
|
||||
* FFCodec.codec_tags termination value
|
||||
@@ -118,14 +132,20 @@ typedef struct FFCodec {
|
||||
/**
|
||||
* Internal codec capabilities FF_CODEC_CAP_*.
|
||||
*/
|
||||
unsigned caps_internal : 29;
|
||||
unsigned caps_internal:27;
|
||||
|
||||
/**
|
||||
* This field determines the video color ranges supported by an encoder.
|
||||
* Should be set to a bitmask of AVCOL_RANGE_MPEG and AVCOL_RANGE_JPEG.
|
||||
*/
|
||||
unsigned color_ranges:2;
|
||||
|
||||
/**
|
||||
* This field determines the type of the codec (decoder/encoder)
|
||||
* and also the exact callback cb implemented by the codec.
|
||||
* cb_type uses enum FFCodecType values.
|
||||
*/
|
||||
unsigned cb_type : 3;
|
||||
unsigned cb_type:3;
|
||||
|
||||
int priv_data_size;
|
||||
/**
|
||||
@@ -152,14 +172,6 @@ typedef struct FFCodec {
|
||||
*/
|
||||
const FFCodecDefault *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 FFCodec *codec);
|
||||
|
||||
int (*init)(struct AVCodecContext *);
|
||||
|
||||
union {
|
||||
@@ -176,7 +188,7 @@ typedef struct FFCodec {
|
||||
* negative error code on failure
|
||||
*/
|
||||
int (*decode)(struct AVCodecContext *avctx, struct AVFrame *frame,
|
||||
int *got_frame_ptr, struct AVPacket *avpkt);
|
||||
int *got_frame_ptr, struct AVPacket *avpkt);
|
||||
/**
|
||||
* Decode subtitle data to an AVSubtitle.
|
||||
* cb is in this state if cb_type is FF_CODEC_CB_TYPE_DECODE_SUB.
|
||||
@@ -184,7 +196,7 @@ typedef struct FFCodec {
|
||||
* Apart from that this is like the decode callback.
|
||||
*/
|
||||
int (*decode_sub)(struct AVCodecContext *avctx, struct AVSubtitle *sub,
|
||||
int *got_frame_ptr, const struct AVPacket *avpkt);
|
||||
int *got_frame_ptr, const struct AVPacket *avpkt);
|
||||
/**
|
||||
* Decode API with decoupled packet/frame dataflow.
|
||||
* cb is in this state if cb_type is FF_CODEC_CB_TYPE_RECEIVE_FRAME.
|
||||
@@ -205,13 +217,13 @@ typedef struct FFCodec {
|
||||
* @return 0 on success, negative error code on failure
|
||||
*/
|
||||
int (*encode)(struct AVCodecContext *avctx, struct AVPacket *avpkt,
|
||||
const struct AVFrame *frame, int *got_packet_ptr);
|
||||
const struct AVFrame *frame, int *got_packet_ptr);
|
||||
/**
|
||||
* Encode subtitles to a raw buffer.
|
||||
* cb is in this state if cb_type is FF_CODEC_CB_TYPE_ENCODE_SUB.
|
||||
*/
|
||||
int (*encode_sub)(struct AVCodecContext *avctx, uint8_t *buf,
|
||||
int buf_size, const struct AVSubtitle *sub);
|
||||
int buf_size, const struct AVSubtitle *sub);
|
||||
/**
|
||||
* Encode API with decoupled frame/packet dataflow.
|
||||
* cb is in this state if cb_type is FF_CODEC_CB_TYPE_RECEIVE_PACKET.
|
||||
@@ -249,29 +261,68 @@ typedef struct FFCodec {
|
||||
* List of supported codec_tags, terminated by FF_CODEC_TAGS_END.
|
||||
*/
|
||||
const uint32_t *codec_tags;
|
||||
|
||||
/**
|
||||
* Custom callback for avcodec_get_supported_config(). If absent,
|
||||
* ff_default_get_supported_config() will be used. `out_num_configs` will
|
||||
* always be set to a valid pointer.
|
||||
*/
|
||||
int (*get_supported_config)(const AVCodecContext *avctx,
|
||||
const AVCodec *codec,
|
||||
enum AVCodecConfig config,
|
||||
unsigned flags,
|
||||
const void **out_configs,
|
||||
int *out_num_configs);
|
||||
} FFCodec;
|
||||
|
||||
#define FF_CODEC_DECODE_CB(func) \
|
||||
.cb_type = FF_CODEC_CB_TYPE_DECODE, \
|
||||
.cb.decode = (func)
|
||||
#define FF_CODEC_DECODE_SUB_CB(func) \
|
||||
.cb_type = FF_CODEC_CB_TYPE_DECODE_SUB, \
|
||||
.cb.decode_sub = (func)
|
||||
#define FF_CODEC_RECEIVE_FRAME_CB(func) \
|
||||
.cb_type = FF_CODEC_CB_TYPE_RECEIVE_FRAME, \
|
||||
.cb.receive_frame = (func)
|
||||
#define FF_CODEC_ENCODE_CB(func) \
|
||||
.cb_type = FF_CODEC_CB_TYPE_ENCODE, \
|
||||
.cb.encode = (func)
|
||||
#define FF_CODEC_ENCODE_SUB_CB(func) \
|
||||
.cb_type = FF_CODEC_CB_TYPE_ENCODE_SUB, \
|
||||
.cb.encode_sub = (func)
|
||||
#define FF_CODEC_RECEIVE_PACKET_CB(func) \
|
||||
.cb_type = FF_CODEC_CB_TYPE_RECEIVE_PACKET, \
|
||||
/**
|
||||
* Default implementation for avcodec_get_supported_config(). Will return the
|
||||
* relevant fields from AVCodec if present, or NULL otherwise.
|
||||
*
|
||||
* For AVCODEC_CONFIG_COLOR_RANGE, the output will depend on the bitmask in
|
||||
* FFCodec.color_ranges, with a value of 0 returning NULL.
|
||||
*/
|
||||
int ff_default_get_supported_config(const AVCodecContext *avctx,
|
||||
const AVCodec *codec,
|
||||
enum AVCodecConfig config,
|
||||
unsigned flags,
|
||||
const void **out_configs,
|
||||
int *out_num_configs);
|
||||
|
||||
#if HAVE_THREADS
|
||||
#define UPDATE_THREAD_CONTEXT(func) \
|
||||
.update_thread_context = (func)
|
||||
#define UPDATE_THREAD_CONTEXT_FOR_USER(func) \
|
||||
.update_thread_context_for_user = (func)
|
||||
#else
|
||||
#define UPDATE_THREAD_CONTEXT(func) \
|
||||
.update_thread_context = NULL
|
||||
#define UPDATE_THREAD_CONTEXT_FOR_USER(func) \
|
||||
.update_thread_context_for_user = NULL
|
||||
#endif
|
||||
|
||||
#define FF_CODEC_DECODE_CB(func) \
|
||||
.cb_type = FF_CODEC_CB_TYPE_DECODE, \
|
||||
.cb.decode = (func)
|
||||
#define FF_CODEC_DECODE_SUB_CB(func) \
|
||||
.cb_type = FF_CODEC_CB_TYPE_DECODE_SUB, \
|
||||
.cb.decode_sub = (func)
|
||||
#define FF_CODEC_RECEIVE_FRAME_CB(func) \
|
||||
.cb_type = FF_CODEC_CB_TYPE_RECEIVE_FRAME, \
|
||||
.cb.receive_frame = (func)
|
||||
#define FF_CODEC_ENCODE_CB(func) \
|
||||
.cb_type = FF_CODEC_CB_TYPE_ENCODE, \
|
||||
.cb.encode = (func)
|
||||
#define FF_CODEC_ENCODE_SUB_CB(func) \
|
||||
.cb_type = FF_CODEC_CB_TYPE_ENCODE_SUB, \
|
||||
.cb.encode_sub = (func)
|
||||
#define FF_CODEC_RECEIVE_PACKET_CB(func) \
|
||||
.cb_type = FF_CODEC_CB_TYPE_RECEIVE_PACKET, \
|
||||
.cb.receive_packet = (func)
|
||||
|
||||
static av_always_inline const FFCodec *ffcodec(const AVCodec *codec) {
|
||||
return (const FFCodec *)codec;
|
||||
static av_always_inline const FFCodec *ffcodec(const AVCodec *codec)
|
||||
{
|
||||
return (const FFCodec*)codec;
|
||||
}
|
||||
|
||||
#endif /* AVCODEC_CODEC_INTERNAL_H */
|
||||
|
||||
@@ -29,20 +29,14 @@
|
||||
#include "libavutil/pixfmt.h"
|
||||
|
||||
#include "codec_id.h"
|
||||
#include "defs.h"
|
||||
#include "packet.h"
|
||||
|
||||
/**
|
||||
* @addtogroup lavc_core
|
||||
* @{
|
||||
*/
|
||||
|
||||
enum AVFieldOrder {
|
||||
AV_FIELD_UNKNOWN,
|
||||
AV_FIELD_PROGRESSIVE,
|
||||
AV_FIELD_TT, //< Top coded_first, top displayed first
|
||||
AV_FIELD_BB, //< Bottom coded first, bottom displayed first
|
||||
AV_FIELD_TB, //< Top coded first, bottom displayed first
|
||||
AV_FIELD_BT, //< Bottom coded first, top displayed first
|
||||
};
|
||||
|
||||
/**
|
||||
* This struct describes the properties of an encoded stream.
|
||||
*
|
||||
@@ -78,6 +72,19 @@ typedef struct AVCodecParameters {
|
||||
*/
|
||||
int extradata_size;
|
||||
|
||||
/**
|
||||
* Additional data associated with the entire stream.
|
||||
*
|
||||
* Should be allocated with av_packet_side_data_new() or
|
||||
* av_packet_side_data_add(), and will be freed by avcodec_parameters_free().
|
||||
*/
|
||||
AVPacketSideData *coded_side_data;
|
||||
|
||||
/**
|
||||
* Amount of entries in @ref coded_side_data.
|
||||
*/
|
||||
int nb_coded_side_data;
|
||||
|
||||
/**
|
||||
* - video: the pixel format, the value corresponds to enum AVPixelFormat.
|
||||
* - audio: the sample format, the value corresponds to enum AVSampleFormat.
|
||||
@@ -136,6 +143,18 @@ typedef struct AVCodecParameters {
|
||||
*/
|
||||
AVRational sample_aspect_ratio;
|
||||
|
||||
/**
|
||||
* Video only. Number of frames per second, for streams with constant frame
|
||||
* durations. Should be set to { 0, 1 } when some frames have differing
|
||||
* durations or if the value is not known.
|
||||
*
|
||||
* @note This field correponds to values that are stored in codec-level
|
||||
* headers and is typically overridden by container/transport-layer
|
||||
* timestamps, when available. It should thus be used only as a last resort,
|
||||
* when no higher-level timing information is available.
|
||||
*/
|
||||
AVRational framerate;
|
||||
|
||||
/**
|
||||
* Video only. The order of the fields in interlaced video.
|
||||
*/
|
||||
@@ -155,22 +174,10 @@ typedef struct AVCodecParameters {
|
||||
*/
|
||||
int video_delay;
|
||||
|
||||
#if FF_API_OLD_CHANNEL_LAYOUT
|
||||
/**
|
||||
* Audio only. The channel layout bitmask. May be 0 if the channel layout is
|
||||
* unknown or unspecified, otherwise the number of bits set must be equal to
|
||||
* the channels field.
|
||||
* @deprecated use ch_layout
|
||||
* Audio only. The channel layout and number of channels.
|
||||
*/
|
||||
attribute_deprecated
|
||||
uint64_t channel_layout;
|
||||
/**
|
||||
* Audio only. The number of audio channels.
|
||||
* @deprecated use ch_layout.nb_channels
|
||||
*/
|
||||
attribute_deprecated
|
||||
int channels;
|
||||
#endif
|
||||
AVChannelLayout ch_layout;
|
||||
/**
|
||||
* Audio only. The number of audio samples per second.
|
||||
*/
|
||||
@@ -205,11 +212,6 @@ typedef struct AVCodecParameters {
|
||||
* Audio only. Number of samples to skip after a discontinuity.
|
||||
*/
|
||||
int seek_preroll;
|
||||
|
||||
/**
|
||||
* Audio only. The channel layout and number of channels.
|
||||
*/
|
||||
AVChannelLayout ch_layout;
|
||||
} AVCodecParameters;
|
||||
|
||||
/**
|
||||
|
||||
@@ -45,9 +45,6 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG 1 ///< Work around for Direct3D11 and old UVD/UVD+ ATI video cards
|
||||
#define FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO 2 ///< Work around for Direct3D11 and old Intel GPUs with ClearVideo interface
|
||||
|
||||
/**
|
||||
* This structure is used to provides the necessary configurations and data
|
||||
* to the Direct3D11 FFmpeg HWAccel implementation.
|
||||
|
||||
@@ -39,6 +39,173 @@
|
||||
*/
|
||||
#define AV_INPUT_BUFFER_PADDING_SIZE 64
|
||||
|
||||
/**
|
||||
* Verify checksums embedded in the bitstream (could be of either encoded or
|
||||
* decoded data, depending on the format) and print an error message on mismatch.
|
||||
* If AV_EF_EXPLODE is also set, a mismatching checksum will result in the
|
||||
* decoder/demuxer returning an error.
|
||||
*/
|
||||
#define AV_EF_CRCCHECK (1<<0)
|
||||
#define AV_EF_BITSTREAM (1<<1) ///< detect bitstream specification deviations
|
||||
#define AV_EF_BUFFER (1<<2) ///< detect improper bitstream length
|
||||
#define AV_EF_EXPLODE (1<<3) ///< abort decoding on minor error detection
|
||||
|
||||
#define AV_EF_IGNORE_ERR (1<<15) ///< ignore errors and continue
|
||||
#define AV_EF_CAREFUL (1<<16) ///< consider things that violate the spec, are fast to calculate and have not been seen in the wild as errors
|
||||
#define AV_EF_COMPLIANT (1<<17) ///< consider all spec non compliances as errors
|
||||
#define AV_EF_AGGRESSIVE (1<<18) ///< consider things that a sane encoder/muxer should not do as an error
|
||||
|
||||
#define FF_COMPLIANCE_VERY_STRICT 2 ///< Strictly conform to an older more strict version of the spec or reference software.
|
||||
#define FF_COMPLIANCE_STRICT 1 ///< Strictly conform to all the things in the spec no matter what consequences.
|
||||
#define FF_COMPLIANCE_NORMAL 0
|
||||
#define FF_COMPLIANCE_UNOFFICIAL -1 ///< Allow unofficial extensions
|
||||
#define FF_COMPLIANCE_EXPERIMENTAL -2 ///< Allow nonstandardized experimental things.
|
||||
|
||||
|
||||
#define AV_PROFILE_UNKNOWN -99
|
||||
#define AV_PROFILE_RESERVED -100
|
||||
|
||||
#define AV_PROFILE_AAC_MAIN 0
|
||||
#define AV_PROFILE_AAC_LOW 1
|
||||
#define AV_PROFILE_AAC_SSR 2
|
||||
#define AV_PROFILE_AAC_LTP 3
|
||||
#define AV_PROFILE_AAC_HE 4
|
||||
#define AV_PROFILE_AAC_HE_V2 28
|
||||
#define AV_PROFILE_AAC_LD 22
|
||||
#define AV_PROFILE_AAC_ELD 38
|
||||
#define AV_PROFILE_AAC_USAC 41
|
||||
#define AV_PROFILE_MPEG2_AAC_LOW 128
|
||||
#define AV_PROFILE_MPEG2_AAC_HE 131
|
||||
|
||||
#define AV_PROFILE_DNXHD 0
|
||||
#define AV_PROFILE_DNXHR_LB 1
|
||||
#define AV_PROFILE_DNXHR_SQ 2
|
||||
#define AV_PROFILE_DNXHR_HQ 3
|
||||
#define AV_PROFILE_DNXHR_HQX 4
|
||||
#define AV_PROFILE_DNXHR_444 5
|
||||
|
||||
#define AV_PROFILE_DTS 20
|
||||
#define AV_PROFILE_DTS_ES 30
|
||||
#define AV_PROFILE_DTS_96_24 40
|
||||
#define AV_PROFILE_DTS_HD_HRA 50
|
||||
#define AV_PROFILE_DTS_HD_MA 60
|
||||
#define AV_PROFILE_DTS_EXPRESS 70
|
||||
#define AV_PROFILE_DTS_HD_MA_X 61
|
||||
#define AV_PROFILE_DTS_HD_MA_X_IMAX 62
|
||||
|
||||
#define AV_PROFILE_EAC3_DDP_ATMOS 30
|
||||
|
||||
#define AV_PROFILE_TRUEHD_ATMOS 30
|
||||
|
||||
#define AV_PROFILE_MPEG2_422 0
|
||||
#define AV_PROFILE_MPEG2_HIGH 1
|
||||
#define AV_PROFILE_MPEG2_SS 2
|
||||
#define AV_PROFILE_MPEG2_SNR_SCALABLE 3
|
||||
#define AV_PROFILE_MPEG2_MAIN 4
|
||||
#define AV_PROFILE_MPEG2_SIMPLE 5
|
||||
|
||||
#define AV_PROFILE_H264_CONSTRAINED (1<<9) // 8+1; constraint_set1_flag
|
||||
#define AV_PROFILE_H264_INTRA (1<<11) // 8+3; constraint_set3_flag
|
||||
|
||||
#define AV_PROFILE_H264_BASELINE 66
|
||||
#define AV_PROFILE_H264_CONSTRAINED_BASELINE (66|AV_PROFILE_H264_CONSTRAINED)
|
||||
#define AV_PROFILE_H264_MAIN 77
|
||||
#define AV_PROFILE_H264_EXTENDED 88
|
||||
#define AV_PROFILE_H264_HIGH 100
|
||||
#define AV_PROFILE_H264_HIGH_10 110
|
||||
#define AV_PROFILE_H264_HIGH_10_INTRA (110|AV_PROFILE_H264_INTRA)
|
||||
#define AV_PROFILE_H264_MULTIVIEW_HIGH 118
|
||||
#define AV_PROFILE_H264_HIGH_422 122
|
||||
#define AV_PROFILE_H264_HIGH_422_INTRA (122|AV_PROFILE_H264_INTRA)
|
||||
#define AV_PROFILE_H264_STEREO_HIGH 128
|
||||
#define AV_PROFILE_H264_HIGH_444 144
|
||||
#define AV_PROFILE_H264_HIGH_444_PREDICTIVE 244
|
||||
#define AV_PROFILE_H264_HIGH_444_INTRA (244|AV_PROFILE_H264_INTRA)
|
||||
#define AV_PROFILE_H264_CAVLC_444 44
|
||||
|
||||
#define AV_PROFILE_VC1_SIMPLE 0
|
||||
#define AV_PROFILE_VC1_MAIN 1
|
||||
#define AV_PROFILE_VC1_COMPLEX 2
|
||||
#define AV_PROFILE_VC1_ADVANCED 3
|
||||
|
||||
#define AV_PROFILE_MPEG4_SIMPLE 0
|
||||
#define AV_PROFILE_MPEG4_SIMPLE_SCALABLE 1
|
||||
#define AV_PROFILE_MPEG4_CORE 2
|
||||
#define AV_PROFILE_MPEG4_MAIN 3
|
||||
#define AV_PROFILE_MPEG4_N_BIT 4
|
||||
#define AV_PROFILE_MPEG4_SCALABLE_TEXTURE 5
|
||||
#define AV_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION 6
|
||||
#define AV_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE 7
|
||||
#define AV_PROFILE_MPEG4_HYBRID 8
|
||||
#define AV_PROFILE_MPEG4_ADVANCED_REAL_TIME 9
|
||||
#define AV_PROFILE_MPEG4_CORE_SCALABLE 10
|
||||
#define AV_PROFILE_MPEG4_ADVANCED_CODING 11
|
||||
#define AV_PROFILE_MPEG4_ADVANCED_CORE 12
|
||||
#define AV_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE 13
|
||||
#define AV_PROFILE_MPEG4_SIMPLE_STUDIO 14
|
||||
#define AV_PROFILE_MPEG4_ADVANCED_SIMPLE 15
|
||||
|
||||
#define AV_PROFILE_JPEG2000_CSTREAM_RESTRICTION_0 1
|
||||
#define AV_PROFILE_JPEG2000_CSTREAM_RESTRICTION_1 2
|
||||
#define AV_PROFILE_JPEG2000_CSTREAM_NO_RESTRICTION 32768
|
||||
#define AV_PROFILE_JPEG2000_DCINEMA_2K 3
|
||||
#define AV_PROFILE_JPEG2000_DCINEMA_4K 4
|
||||
|
||||
#define AV_PROFILE_VP9_0 0
|
||||
#define AV_PROFILE_VP9_1 1
|
||||
#define AV_PROFILE_VP9_2 2
|
||||
#define AV_PROFILE_VP9_3 3
|
||||
|
||||
#define AV_PROFILE_HEVC_MAIN 1
|
||||
#define AV_PROFILE_HEVC_MAIN_10 2
|
||||
#define AV_PROFILE_HEVC_MAIN_STILL_PICTURE 3
|
||||
#define AV_PROFILE_HEVC_REXT 4
|
||||
#define AV_PROFILE_HEVC_MULTIVIEW_MAIN 6
|
||||
#define AV_PROFILE_HEVC_SCC 9
|
||||
|
||||
#define AV_PROFILE_VVC_MAIN_10 1
|
||||
#define AV_PROFILE_VVC_MAIN_10_444 33
|
||||
|
||||
#define AV_PROFILE_AV1_MAIN 0
|
||||
#define AV_PROFILE_AV1_HIGH 1
|
||||
#define AV_PROFILE_AV1_PROFESSIONAL 2
|
||||
|
||||
#define AV_PROFILE_MJPEG_HUFFMAN_BASELINE_DCT 0xc0
|
||||
#define AV_PROFILE_MJPEG_HUFFMAN_EXTENDED_SEQUENTIAL_DCT 0xc1
|
||||
#define AV_PROFILE_MJPEG_HUFFMAN_PROGRESSIVE_DCT 0xc2
|
||||
#define AV_PROFILE_MJPEG_HUFFMAN_LOSSLESS 0xc3
|
||||
#define AV_PROFILE_MJPEG_JPEG_LS 0xf7
|
||||
|
||||
#define AV_PROFILE_SBC_MSBC 1
|
||||
|
||||
#define AV_PROFILE_PRORES_PROXY 0
|
||||
#define AV_PROFILE_PRORES_LT 1
|
||||
#define AV_PROFILE_PRORES_STANDARD 2
|
||||
#define AV_PROFILE_PRORES_HQ 3
|
||||
#define AV_PROFILE_PRORES_4444 4
|
||||
#define AV_PROFILE_PRORES_XQ 5
|
||||
|
||||
#define AV_PROFILE_ARIB_PROFILE_A 0
|
||||
#define AV_PROFILE_ARIB_PROFILE_C 1
|
||||
|
||||
#define AV_PROFILE_KLVA_SYNC 0
|
||||
#define AV_PROFILE_KLVA_ASYNC 1
|
||||
|
||||
#define AV_PROFILE_EVC_BASELINE 0
|
||||
#define AV_PROFILE_EVC_MAIN 1
|
||||
|
||||
|
||||
#define AV_LEVEL_UNKNOWN -99
|
||||
|
||||
enum AVFieldOrder {
|
||||
AV_FIELD_UNKNOWN,
|
||||
AV_FIELD_PROGRESSIVE,
|
||||
AV_FIELD_TT, ///< Top coded_first, top displayed first
|
||||
AV_FIELD_BB, ///< Bottom coded first, bottom displayed first
|
||||
AV_FIELD_TB, ///< Top coded first, bottom displayed first
|
||||
AV_FIELD_BT, ///< Bottom coded first, top displayed first
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup lavc_decoding
|
||||
*/
|
||||
|
||||
@@ -31,7 +31,11 @@
|
||||
* @author Jordi Ortiz
|
||||
*/
|
||||
|
||||
#include "avcodec.h"
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libavutil/pixfmt.h"
|
||||
#include "libavutil/rational.h"
|
||||
|
||||
/**
|
||||
* The spec limits the number of wavelet decompositions to 4 for both
|
||||
|
||||
@@ -45,9 +45,6 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG 1 ///< Work around for DXVA2 and old UVD/UVD+ ATI video cards
|
||||
#define FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO 2 ///< Work around for DXVA2 and old Intel GPUs with ClearVideo interface
|
||||
|
||||
/**
|
||||
* This structure is used to provides the necessary configurations and data
|
||||
* to the DXVA2 FFmpeg HWAccel implementation.
|
||||
|
||||
106
include/libavcodec/error_resilience.h
Normal file
106
include/libavcodec/error_resilience.h
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* 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_ERROR_RESILIENCE_H
|
||||
#define AVCODEC_ERROR_RESILIENCE_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdatomic.h>
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "me_cmp.h"
|
||||
|
||||
///< current MB is the first after a resync marker
|
||||
#define VP_START 1
|
||||
#define ER_AC_ERROR 2
|
||||
#define ER_DC_ERROR 4
|
||||
#define ER_MV_ERROR 8
|
||||
#define ER_AC_END 16
|
||||
#define ER_DC_END 32
|
||||
#define ER_MV_END 64
|
||||
|
||||
#define ER_MB_ERROR (ER_AC_ERROR|ER_DC_ERROR|ER_MV_ERROR)
|
||||
#define ER_MB_END (ER_AC_END|ER_DC_END|ER_MV_END)
|
||||
|
||||
typedef struct ERPicture {
|
||||
AVFrame *f;
|
||||
const struct ThreadFrame *tf;
|
||||
|
||||
// it is the caller's responsibility to allocate these buffers
|
||||
int16_t (*motion_val[2])[2];
|
||||
int8_t *ref_index[2];
|
||||
|
||||
uint32_t *mb_type;
|
||||
int field_picture;
|
||||
} ERPicture;
|
||||
|
||||
typedef struct ERContext {
|
||||
AVCodecContext *avctx;
|
||||
|
||||
me_cmp_func sad;
|
||||
int mecc_inited;
|
||||
|
||||
int *mb_index2xy;
|
||||
int mb_num;
|
||||
int mb_width, mb_height;
|
||||
ptrdiff_t mb_stride;
|
||||
ptrdiff_t b8_stride;
|
||||
|
||||
atomic_int error_count;
|
||||
int error_occurred;
|
||||
uint8_t *error_status_table;
|
||||
uint8_t *er_temp_buffer;
|
||||
int16_t *dc_val[3];
|
||||
uint8_t *mbskip_table;
|
||||
uint8_t *mbintra_table;
|
||||
int mv[2][4][2];
|
||||
|
||||
ERPicture cur_pic;
|
||||
ERPicture last_pic;
|
||||
ERPicture next_pic;
|
||||
|
||||
int8_t *ref_index[2];
|
||||
int16_t (*motion_val_base[2])[2];
|
||||
|
||||
uint16_t pp_time;
|
||||
uint16_t pb_time;
|
||||
int quarter_sample;
|
||||
int partitioned_frame;
|
||||
|
||||
void (*decode_mb)(void *opaque, int ref, int mv_dir, int mv_type,
|
||||
int (*mv)[2][4][2],
|
||||
int mb_x, int mb_y, int mb_intra, int mb_skipped);
|
||||
void *opaque;
|
||||
} ERContext;
|
||||
|
||||
void ff_er_frame_start(ERContext *s);
|
||||
|
||||
/**
|
||||
* Indicate that a frame has finished decoding and perform error concealment
|
||||
* in case it has been enabled and is necessary and supported.
|
||||
*
|
||||
* @param s ERContext in use
|
||||
* @param decode_error_flags pointer where updated decode_error_flags are written
|
||||
* if supplied; if not, the new flags are directly
|
||||
* applied to the AVFrame whose errors are concealed
|
||||
*/
|
||||
void ff_er_frame_end(ERContext *s, int *decode_error_flags);
|
||||
void ff_er_add_slice(ERContext *s, int startx, int starty, int endx, int endy,
|
||||
int status);
|
||||
|
||||
#endif /* AVCODEC_ERROR_RESILIENCE_H */
|
||||
113
include/libavcodec/h264.h
Normal file
113
include/libavcodec/h264.h
Normal file
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* 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
|
||||
* H.264 common definitions
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_H264_H
|
||||
#define AVCODEC_H264_H
|
||||
|
||||
#define QP_MAX_NUM (51 + 6*6) // The maximum supported qp
|
||||
|
||||
/*
|
||||
* Table 7-1 – NAL unit type codes, syntax element categories, and NAL unit type classes in
|
||||
* T-REC-H.264-201704
|
||||
*/
|
||||
enum {
|
||||
H264_NAL_UNSPECIFIED = 0,
|
||||
H264_NAL_SLICE = 1,
|
||||
H264_NAL_DPA = 2,
|
||||
H264_NAL_DPB = 3,
|
||||
H264_NAL_DPC = 4,
|
||||
H264_NAL_IDR_SLICE = 5,
|
||||
H264_NAL_SEI = 6,
|
||||
H264_NAL_SPS = 7,
|
||||
H264_NAL_PPS = 8,
|
||||
H264_NAL_AUD = 9,
|
||||
H264_NAL_END_SEQUENCE = 10,
|
||||
H264_NAL_END_STREAM = 11,
|
||||
H264_NAL_FILLER_DATA = 12,
|
||||
H264_NAL_SPS_EXT = 13,
|
||||
H264_NAL_PREFIX = 14,
|
||||
H264_NAL_SUB_SPS = 15,
|
||||
H264_NAL_DPS = 16,
|
||||
H264_NAL_RESERVED17 = 17,
|
||||
H264_NAL_RESERVED18 = 18,
|
||||
H264_NAL_AUXILIARY_SLICE = 19,
|
||||
H264_NAL_EXTEN_SLICE = 20,
|
||||
H264_NAL_DEPTH_EXTEN_SLICE = 21,
|
||||
H264_NAL_RESERVED22 = 22,
|
||||
H264_NAL_RESERVED23 = 23,
|
||||
H264_NAL_UNSPECIFIED24 = 24,
|
||||
H264_NAL_UNSPECIFIED25 = 25,
|
||||
H264_NAL_UNSPECIFIED26 = 26,
|
||||
H264_NAL_UNSPECIFIED27 = 27,
|
||||
H264_NAL_UNSPECIFIED28 = 28,
|
||||
H264_NAL_UNSPECIFIED29 = 29,
|
||||
H264_NAL_UNSPECIFIED30 = 30,
|
||||
H264_NAL_UNSPECIFIED31 = 31,
|
||||
};
|
||||
|
||||
|
||||
enum {
|
||||
// 7.4.2.1.1: seq_parameter_set_id is in [0, 31].
|
||||
H264_MAX_SPS_COUNT = 32,
|
||||
// 7.4.2.2: pic_parameter_set_id is in [0, 255].
|
||||
H264_MAX_PPS_COUNT = 256,
|
||||
|
||||
// A.3: MaxDpbFrames is bounded above by 16.
|
||||
H264_MAX_DPB_FRAMES = 16,
|
||||
// 7.4.2.1.1: max_num_ref_frames is in [0, MaxDpbFrames], and
|
||||
// each reference frame can have two fields.
|
||||
H264_MAX_REFS = 2 * H264_MAX_DPB_FRAMES,
|
||||
|
||||
// 7.4.3.1: modification_of_pic_nums_idc is not equal to 3 at most
|
||||
// num_ref_idx_lN_active_minus1 + 1 times (that is, once for each
|
||||
// possible reference), then equal to 3 once.
|
||||
H264_MAX_RPLM_COUNT = H264_MAX_REFS + 1,
|
||||
|
||||
// 7.4.3.3: in the worst case, we begin with a full short-term
|
||||
// reference picture list. Each picture in turn is moved to the
|
||||
// long-term list (type 3) and then discarded from there (type 2).
|
||||
// Then, we set the length of the long-term list (type 4), mark
|
||||
// the current picture as long-term (type 6) and terminate the
|
||||
// process (type 0).
|
||||
H264_MAX_MMCO_COUNT = H264_MAX_REFS * 2 + 3,
|
||||
|
||||
// A.2.1, A.2.3: profiles supporting FMO constrain
|
||||
// num_slice_groups_minus1 to be in [0, 7].
|
||||
H264_MAX_SLICE_GROUPS = 8,
|
||||
|
||||
// E.2.2: cpb_cnt_minus1 is in [0, 31].
|
||||
H264_MAX_CPB_CNT = 32,
|
||||
|
||||
// A.3: in table A-1 the highest level allows a MaxFS of 139264.
|
||||
H264_MAX_MB_PIC_SIZE = 139264,
|
||||
// A.3.1, A.3.2: PicWidthInMbs and PicHeightInMbs are constrained
|
||||
// to be not greater than sqrt(MaxFS * 8). Hence height/width are
|
||||
// bounded above by sqrt(139264 * 8) = 1055.5 macroblocks.
|
||||
H264_MAX_MB_WIDTH = 1055,
|
||||
H264_MAX_MB_HEIGHT = 1055,
|
||||
H264_MAX_WIDTH = H264_MAX_MB_WIDTH * 16,
|
||||
H264_MAX_HEIGHT = H264_MAX_MB_HEIGHT * 16,
|
||||
};
|
||||
|
||||
|
||||
#endif /* AVCODEC_H264_H */
|
||||
51
include/libavcodec/h264_levels.h
Normal file
51
include/libavcodec/h264_levels.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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_H264_LEVELS_H
|
||||
#define AVCODEC_H264_LEVELS_H
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct H264LevelDescriptor {
|
||||
char name[4]; // Large enough for all current levels like "4.1"
|
||||
uint8_t level_idc;
|
||||
uint8_t constraint_set3_flag;
|
||||
uint32_t max_mbps;
|
||||
uint32_t max_fs;
|
||||
uint32_t max_dpb_mbs;
|
||||
uint32_t max_br;
|
||||
uint32_t max_cpb;
|
||||
uint16_t max_v_mv_r;
|
||||
uint8_t min_cr;
|
||||
uint8_t max_mvs_per_2mb;
|
||||
} H264LevelDescriptor;
|
||||
|
||||
/**
|
||||
* Guess the level of a stream from some parameters.
|
||||
*
|
||||
* Unknown parameters may be zero, in which case they are ignored.
|
||||
*/
|
||||
const H264LevelDescriptor *ff_h264_guess_level(int profile_idc,
|
||||
int64_t bitrate,
|
||||
int framerate,
|
||||
int width, int height,
|
||||
int max_dec_frame_buffering);
|
||||
|
||||
|
||||
#endif /* AVCODEC_H264_LEVELS_H */
|
||||
967
include/libavcodec/h264_mvpred.h
Normal file
967
include/libavcodec/h264_mvpred.h
Normal file
@@ -0,0 +1,967 @@
|
||||
/*
|
||||
* H.26L/H.264/AVC/JVT/14496-10/... motion vector prediction
|
||||
* Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* 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
|
||||
* H.264 / AVC / MPEG-4 part10 motion vector prediction.
|
||||
* @author Michael Niedermayer <michaelni@gmx.at>
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_H264_MVPRED_H
|
||||
#define AVCODEC_H264_MVPRED_H
|
||||
|
||||
#include "h264dec.h"
|
||||
#include "mpegutils.h"
|
||||
#include "rectangle.h"
|
||||
|
||||
#include "libavutil/avassert.h"
|
||||
#include "libavutil/mem_internal.h"
|
||||
|
||||
|
||||
/**
|
||||
* Get the predicted intra4x4 prediction mode.
|
||||
*/
|
||||
static av_always_inline int pred_intra_mode(const H264Context *h,
|
||||
H264SliceContext *sl, int n)
|
||||
{
|
||||
const int index8 = scan8[n];
|
||||
const int left = sl->intra4x4_pred_mode_cache[index8 - 1];
|
||||
const int top = sl->intra4x4_pred_mode_cache[index8 - 8];
|
||||
const int min = FFMIN(left, top);
|
||||
|
||||
ff_tlog(h->avctx, "mode:%d %d min:%d\n", left, top, min);
|
||||
|
||||
if (min < 0)
|
||||
return DC_PRED;
|
||||
else
|
||||
return min;
|
||||
}
|
||||
|
||||
static av_always_inline void write_back_intra_pred_mode(const H264Context *h,
|
||||
H264SliceContext *sl)
|
||||
{
|
||||
int8_t *i4x4 = sl->intra4x4_pred_mode + h->mb2br_xy[sl->mb_xy];
|
||||
int8_t *i4x4_cache = sl->intra4x4_pred_mode_cache;
|
||||
|
||||
AV_COPY32(i4x4, i4x4_cache + 4 + 8 * 4);
|
||||
i4x4[4] = i4x4_cache[7 + 8 * 3];
|
||||
i4x4[5] = i4x4_cache[7 + 8 * 2];
|
||||
i4x4[6] = i4x4_cache[7 + 8 * 1];
|
||||
}
|
||||
|
||||
static av_always_inline void write_back_non_zero_count(const H264Context *h,
|
||||
H264SliceContext *sl)
|
||||
{
|
||||
const int mb_xy = sl->mb_xy;
|
||||
uint8_t *nnz = h->non_zero_count[mb_xy];
|
||||
uint8_t *nnz_cache = sl->non_zero_count_cache;
|
||||
|
||||
AV_COPY32(&nnz[ 0], &nnz_cache[4 + 8 * 1]);
|
||||
AV_COPY32(&nnz[ 4], &nnz_cache[4 + 8 * 2]);
|
||||
AV_COPY32(&nnz[ 8], &nnz_cache[4 + 8 * 3]);
|
||||
AV_COPY32(&nnz[12], &nnz_cache[4 + 8 * 4]);
|
||||
AV_COPY32(&nnz[16], &nnz_cache[4 + 8 * 6]);
|
||||
AV_COPY32(&nnz[20], &nnz_cache[4 + 8 * 7]);
|
||||
AV_COPY32(&nnz[32], &nnz_cache[4 + 8 * 11]);
|
||||
AV_COPY32(&nnz[36], &nnz_cache[4 + 8 * 12]);
|
||||
|
||||
if (!h->chroma_y_shift) {
|
||||
AV_COPY32(&nnz[24], &nnz_cache[4 + 8 * 8]);
|
||||
AV_COPY32(&nnz[28], &nnz_cache[4 + 8 * 9]);
|
||||
AV_COPY32(&nnz[40], &nnz_cache[4 + 8 * 13]);
|
||||
AV_COPY32(&nnz[44], &nnz_cache[4 + 8 * 14]);
|
||||
}
|
||||
}
|
||||
|
||||
static av_always_inline void write_back_motion_list(const H264Context *h,
|
||||
H264SliceContext *sl,
|
||||
int b_stride,
|
||||
int b_xy, int b8_xy,
|
||||
int mb_type, int list)
|
||||
{
|
||||
int16_t(*mv_dst)[2] = &h->cur_pic.motion_val[list][b_xy];
|
||||
int16_t(*mv_src)[2] = &sl->mv_cache[list][scan8[0]];
|
||||
AV_COPY128(mv_dst + 0 * b_stride, mv_src + 8 * 0);
|
||||
AV_COPY128(mv_dst + 1 * b_stride, mv_src + 8 * 1);
|
||||
AV_COPY128(mv_dst + 2 * b_stride, mv_src + 8 * 2);
|
||||
AV_COPY128(mv_dst + 3 * b_stride, mv_src + 8 * 3);
|
||||
if (CABAC(h)) {
|
||||
uint8_t (*mvd_dst)[2] = &sl->mvd_table[list][FMO ? 8 * sl->mb_xy
|
||||
: h->mb2br_xy[sl->mb_xy]];
|
||||
uint8_t(*mvd_src)[2] = &sl->mvd_cache[list][scan8[0]];
|
||||
if (IS_SKIP(mb_type)) {
|
||||
AV_ZERO128(mvd_dst);
|
||||
} else {
|
||||
AV_COPY64(mvd_dst, mvd_src + 8 * 3);
|
||||
AV_COPY16(mvd_dst + 3 + 3, mvd_src + 3 + 8 * 0);
|
||||
AV_COPY16(mvd_dst + 3 + 2, mvd_src + 3 + 8 * 1);
|
||||
AV_COPY16(mvd_dst + 3 + 1, mvd_src + 3 + 8 * 2);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
int8_t *ref_index = &h->cur_pic.ref_index[list][b8_xy];
|
||||
int8_t *ref_cache = sl->ref_cache[list];
|
||||
ref_index[0 + 0 * 2] = ref_cache[scan8[0]];
|
||||
ref_index[1 + 0 * 2] = ref_cache[scan8[4]];
|
||||
ref_index[0 + 1 * 2] = ref_cache[scan8[8]];
|
||||
ref_index[1 + 1 * 2] = ref_cache[scan8[12]];
|
||||
}
|
||||
}
|
||||
|
||||
static av_always_inline void write_back_motion(const H264Context *h,
|
||||
H264SliceContext *sl,
|
||||
int mb_type)
|
||||
{
|
||||
const int b_stride = h->b_stride;
|
||||
const int b_xy = 4 * sl->mb_x + 4 * sl->mb_y * h->b_stride; // try mb2b(8)_xy
|
||||
const int b8_xy = 4 * sl->mb_xy;
|
||||
|
||||
if (USES_LIST(mb_type, 0)) {
|
||||
write_back_motion_list(h, sl, b_stride, b_xy, b8_xy, mb_type, 0);
|
||||
} else {
|
||||
fill_rectangle(&h->cur_pic.ref_index[0][b8_xy],
|
||||
2, 2, 2, (uint8_t)LIST_NOT_USED, 1);
|
||||
}
|
||||
if (USES_LIST(mb_type, 1))
|
||||
write_back_motion_list(h, sl, b_stride, b_xy, b8_xy, mb_type, 1);
|
||||
|
||||
if (sl->slice_type_nos == AV_PICTURE_TYPE_B && CABAC(h)) {
|
||||
if (IS_8X8(mb_type)) {
|
||||
uint8_t *direct_table = &h->direct_table[4 * sl->mb_xy];
|
||||
direct_table[1] = sl->sub_mb_type[1] >> 1;
|
||||
direct_table[2] = sl->sub_mb_type[2] >> 1;
|
||||
direct_table[3] = sl->sub_mb_type[3] >> 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static av_always_inline int get_dct8x8_allowed(const H264Context *h, H264SliceContext *sl)
|
||||
{
|
||||
if (h->ps.sps->direct_8x8_inference_flag)
|
||||
return !(AV_RN64A(sl->sub_mb_type) &
|
||||
((MB_TYPE_16x8 | MB_TYPE_8x16 | MB_TYPE_8x8) *
|
||||
0x0001000100010001ULL));
|
||||
else
|
||||
return !(AV_RN64A(sl->sub_mb_type) &
|
||||
((MB_TYPE_16x8 | MB_TYPE_8x16 | MB_TYPE_8x8 | MB_TYPE_DIRECT2) *
|
||||
0x0001000100010001ULL));
|
||||
}
|
||||
|
||||
static av_always_inline int fetch_diagonal_mv(const H264Context *h, H264SliceContext *sl,
|
||||
const int16_t **C,
|
||||
int i, int list, int part_width)
|
||||
{
|
||||
const int topright_ref = sl->ref_cache[list][i - 8 + part_width];
|
||||
|
||||
/* there is no consistent mapping of mvs to neighboring locations that will
|
||||
* make mbaff happy, so we can't move all this logic to fill_caches */
|
||||
if (FRAME_MBAFF(h)) {
|
||||
#define SET_DIAG_MV(MV_OP, REF_OP, XY, Y4) \
|
||||
const int xy = XY, y4 = Y4; \
|
||||
const int mb_type = mb_types[xy + (y4 >> 2) * h->mb_stride]; \
|
||||
if (!USES_LIST(mb_type, list)) \
|
||||
return LIST_NOT_USED; \
|
||||
mv = h->cur_pic_ptr->motion_val[list][h->mb2b_xy[xy] + 3 + y4 * h->b_stride]; \
|
||||
sl->mv_cache[list][scan8[0] - 2][0] = mv[0]; \
|
||||
sl->mv_cache[list][scan8[0] - 2][1] = mv[1] MV_OP; \
|
||||
return h->cur_pic_ptr->ref_index[list][4 * xy + 1 + (y4 & ~1)] REF_OP;
|
||||
|
||||
if (topright_ref == PART_NOT_AVAILABLE
|
||||
&& i >= scan8[0] + 8 && (i & 7) == 4
|
||||
&& sl->ref_cache[list][scan8[0] - 1] != PART_NOT_AVAILABLE) {
|
||||
const uint32_t *mb_types = h->cur_pic_ptr->mb_type;
|
||||
const int16_t *mv;
|
||||
AV_ZERO32(sl->mv_cache[list][scan8[0] - 2]);
|
||||
*C = sl->mv_cache[list][scan8[0] - 2];
|
||||
|
||||
if (!MB_FIELD(sl) && IS_INTERLACED(sl->left_type[0])) {
|
||||
SET_DIAG_MV(* 2, >> 1, sl->left_mb_xy[0] + h->mb_stride,
|
||||
(sl->mb_y & 1) * 2 + (i >> 5));
|
||||
}
|
||||
if (MB_FIELD(sl) && !IS_INTERLACED(sl->left_type[0])) {
|
||||
// left shift will turn LIST_NOT_USED into PART_NOT_AVAILABLE, but that's OK.
|
||||
SET_DIAG_MV(/ 2, *2, sl->left_mb_xy[i >= 36], ((i >> 2)) & 3);
|
||||
}
|
||||
}
|
||||
#undef SET_DIAG_MV
|
||||
}
|
||||
|
||||
if (topright_ref != PART_NOT_AVAILABLE) {
|
||||
*C = sl->mv_cache[list][i - 8 + part_width];
|
||||
return topright_ref;
|
||||
} else {
|
||||
ff_tlog(h->avctx, "topright MV not available\n");
|
||||
|
||||
*C = sl->mv_cache[list][i - 8 - 1];
|
||||
return sl->ref_cache[list][i - 8 - 1];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the predicted MV.
|
||||
* @param n the block index
|
||||
* @param part_width the width of the partition (4, 8,16) -> (1, 2, 4)
|
||||
* @param mx the x component of the predicted motion vector
|
||||
* @param my the y component of the predicted motion vector
|
||||
*/
|
||||
static av_always_inline void pred_motion(const H264Context *const h,
|
||||
H264SliceContext *sl,
|
||||
int n,
|
||||
int part_width, int list, int ref,
|
||||
int *const mx, int *const my)
|
||||
{
|
||||
const int index8 = scan8[n];
|
||||
const int top_ref = sl->ref_cache[list][index8 - 8];
|
||||
const int left_ref = sl->ref_cache[list][index8 - 1];
|
||||
const int16_t *const A = sl->mv_cache[list][index8 - 1];
|
||||
const int16_t *const B = sl->mv_cache[list][index8 - 8];
|
||||
const int16_t *C;
|
||||
int diagonal_ref, match_count;
|
||||
|
||||
av_assert2(part_width == 1 || part_width == 2 || part_width == 4);
|
||||
|
||||
/* mv_cache
|
||||
* B . . A T T T T
|
||||
* U . . L . . , .
|
||||
* U . . L . . . .
|
||||
* U . . L . . , .
|
||||
* . . . L . . . .
|
||||
*/
|
||||
|
||||
diagonal_ref = fetch_diagonal_mv(h, sl, &C, index8, list, part_width);
|
||||
match_count = (diagonal_ref == ref) + (top_ref == ref) + (left_ref == ref);
|
||||
ff_tlog(h->avctx, "pred_motion match_count=%d\n", match_count);
|
||||
if (match_count > 1) { //most common
|
||||
*mx = mid_pred(A[0], B[0], C[0]);
|
||||
*my = mid_pred(A[1], B[1], C[1]);
|
||||
} else if (match_count == 1) {
|
||||
if (left_ref == ref) {
|
||||
*mx = A[0];
|
||||
*my = A[1];
|
||||
} else if (top_ref == ref) {
|
||||
*mx = B[0];
|
||||
*my = B[1];
|
||||
} else {
|
||||
*mx = C[0];
|
||||
*my = C[1];
|
||||
}
|
||||
} else {
|
||||
if (top_ref == PART_NOT_AVAILABLE &&
|
||||
diagonal_ref == PART_NOT_AVAILABLE &&
|
||||
left_ref != PART_NOT_AVAILABLE) {
|
||||
*mx = A[0];
|
||||
*my = A[1];
|
||||
} else {
|
||||
*mx = mid_pred(A[0], B[0], C[0]);
|
||||
*my = mid_pred(A[1], B[1], C[1]);
|
||||
}
|
||||
}
|
||||
|
||||
ff_tlog(h->avctx,
|
||||
"pred_motion (%2d %2d %2d) (%2d %2d %2d) (%2d %2d %2d) -> (%2d %2d %2d) at %2d %2d %d list %d\n",
|
||||
top_ref, B[0], B[1], diagonal_ref, C[0], C[1], left_ref,
|
||||
A[0], A[1], ref, *mx, *my, sl->mb_x, sl->mb_y, n, list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the directionally predicted 16x8 MV.
|
||||
* @param n the block index
|
||||
* @param mx the x component of the predicted motion vector
|
||||
* @param my the y component of the predicted motion vector
|
||||
*/
|
||||
static av_always_inline void pred_16x8_motion(const H264Context *const h,
|
||||
H264SliceContext *sl,
|
||||
int n, int list, int ref,
|
||||
int *const mx, int *const my)
|
||||
{
|
||||
if (n == 0) {
|
||||
const int top_ref = sl->ref_cache[list][scan8[0] - 8];
|
||||
const int16_t *const B = sl->mv_cache[list][scan8[0] - 8];
|
||||
|
||||
ff_tlog(h->avctx, "pred_16x8: (%2d %2d %2d) at %2d %2d %d list %d\n",
|
||||
top_ref, B[0], B[1], sl->mb_x, sl->mb_y, n, list);
|
||||
|
||||
if (top_ref == ref) {
|
||||
*mx = B[0];
|
||||
*my = B[1];
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
const int left_ref = sl->ref_cache[list][scan8[8] - 1];
|
||||
const int16_t *const A = sl->mv_cache[list][scan8[8] - 1];
|
||||
|
||||
ff_tlog(h->avctx, "pred_16x8: (%2d %2d %2d) at %2d %2d %d list %d\n",
|
||||
left_ref, A[0], A[1], sl->mb_x, sl->mb_y, n, list);
|
||||
|
||||
if (left_ref == ref) {
|
||||
*mx = A[0];
|
||||
*my = A[1];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//RARE
|
||||
pred_motion(h, sl, n, 4, list, ref, mx, my);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the directionally predicted 8x16 MV.
|
||||
* @param n the block index
|
||||
* @param mx the x component of the predicted motion vector
|
||||
* @param my the y component of the predicted motion vector
|
||||
*/
|
||||
static av_always_inline void pred_8x16_motion(const H264Context *const h,
|
||||
H264SliceContext *sl,
|
||||
int n, int list, int ref,
|
||||
int *const mx, int *const my)
|
||||
{
|
||||
if (n == 0) {
|
||||
const int left_ref = sl->ref_cache[list][scan8[0] - 1];
|
||||
const int16_t *const A = sl->mv_cache[list][scan8[0] - 1];
|
||||
|
||||
ff_tlog(h->avctx, "pred_8x16: (%2d %2d %2d) at %2d %2d %d list %d\n",
|
||||
left_ref, A[0], A[1], sl->mb_x, sl->mb_y, n, list);
|
||||
|
||||
if (left_ref == ref) {
|
||||
*mx = A[0];
|
||||
*my = A[1];
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
const int16_t *C;
|
||||
int diagonal_ref;
|
||||
|
||||
diagonal_ref = fetch_diagonal_mv(h, sl, &C, scan8[4], list, 2);
|
||||
|
||||
ff_tlog(h->avctx, "pred_8x16: (%2d %2d %2d) at %2d %2d %d list %d\n",
|
||||
diagonal_ref, C[0], C[1], sl->mb_x, sl->mb_y, n, list);
|
||||
|
||||
if (diagonal_ref == ref) {
|
||||
*mx = C[0];
|
||||
*my = C[1];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//RARE
|
||||
pred_motion(h, sl, n, 2, list, ref, mx, my);
|
||||
}
|
||||
|
||||
#define FIX_MV_MBAFF(type, refn, mvn, idx) \
|
||||
if (FRAME_MBAFF(h)) { \
|
||||
if (MB_FIELD(sl)) { \
|
||||
if (!IS_INTERLACED(type)) { \
|
||||
refn <<= 1; \
|
||||
AV_COPY32(mvbuf[idx], mvn); \
|
||||
mvbuf[idx][1] /= 2; \
|
||||
mvn = mvbuf[idx]; \
|
||||
} \
|
||||
} else { \
|
||||
if (IS_INTERLACED(type)) { \
|
||||
refn >>= 1; \
|
||||
AV_COPY32(mvbuf[idx], mvn); \
|
||||
mvbuf[idx][1] *= 2; \
|
||||
mvn = mvbuf[idx]; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
static av_always_inline void pred_pskip_motion(const H264Context *const h,
|
||||
H264SliceContext *sl)
|
||||
{
|
||||
DECLARE_ALIGNED(4, static const int16_t, zeromv)[2] = { 0 };
|
||||
DECLARE_ALIGNED(4, int16_t, mvbuf)[3][2];
|
||||
int8_t *ref = h->cur_pic.ref_index[0];
|
||||
int16_t(*mv)[2] = h->cur_pic.motion_val[0];
|
||||
int top_ref, left_ref, diagonal_ref, match_count, mx, my;
|
||||
const int16_t *A, *B, *C;
|
||||
int b_stride = h->b_stride;
|
||||
|
||||
fill_rectangle(&sl->ref_cache[0][scan8[0]], 4, 4, 8, 0, 1);
|
||||
|
||||
/* To avoid doing an entire fill_decode_caches, we inline the relevant
|
||||
* parts here.
|
||||
* FIXME: this is a partial duplicate of the logic in fill_decode_caches,
|
||||
* but it's faster this way. Is there a way to avoid this duplication?
|
||||
*/
|
||||
if (USES_LIST(sl->left_type[LTOP], 0)) {
|
||||
left_ref = ref[4 * sl->left_mb_xy[LTOP] + 1 + (sl->left_block[0] & ~1)];
|
||||
A = mv[h->mb2b_xy[sl->left_mb_xy[LTOP]] + 3 + b_stride * sl->left_block[0]];
|
||||
FIX_MV_MBAFF(sl->left_type[LTOP], left_ref, A, 0);
|
||||
if (!(left_ref | AV_RN32A(A)))
|
||||
goto zeromv;
|
||||
} else if (sl->left_type[LTOP]) {
|
||||
left_ref = LIST_NOT_USED;
|
||||
A = zeromv;
|
||||
} else {
|
||||
goto zeromv;
|
||||
}
|
||||
|
||||
if (USES_LIST(sl->top_type, 0)) {
|
||||
top_ref = ref[4 * sl->top_mb_xy + 2];
|
||||
B = mv[h->mb2b_xy[sl->top_mb_xy] + 3 * b_stride];
|
||||
FIX_MV_MBAFF(sl->top_type, top_ref, B, 1);
|
||||
if (!(top_ref | AV_RN32A(B)))
|
||||
goto zeromv;
|
||||
} else if (sl->top_type) {
|
||||
top_ref = LIST_NOT_USED;
|
||||
B = zeromv;
|
||||
} else {
|
||||
goto zeromv;
|
||||
}
|
||||
|
||||
ff_tlog(h->avctx, "pred_pskip: (%d) (%d) at %2d %2d\n",
|
||||
top_ref, left_ref, sl->mb_x, sl->mb_y);
|
||||
|
||||
if (USES_LIST(sl->topright_type, 0)) {
|
||||
diagonal_ref = ref[4 * sl->topright_mb_xy + 2];
|
||||
C = mv[h->mb2b_xy[sl->topright_mb_xy] + 3 * b_stride];
|
||||
FIX_MV_MBAFF(sl->topright_type, diagonal_ref, C, 2);
|
||||
} else if (sl->topright_type) {
|
||||
diagonal_ref = LIST_NOT_USED;
|
||||
C = zeromv;
|
||||
} else {
|
||||
if (USES_LIST(sl->topleft_type, 0)) {
|
||||
diagonal_ref = ref[4 * sl->topleft_mb_xy + 1 +
|
||||
(sl->topleft_partition & 2)];
|
||||
C = mv[h->mb2b_xy[sl->topleft_mb_xy] + 3 + b_stride +
|
||||
(sl->topleft_partition & 2 * b_stride)];
|
||||
FIX_MV_MBAFF(sl->topleft_type, diagonal_ref, C, 2);
|
||||
} else if (sl->topleft_type) {
|
||||
diagonal_ref = LIST_NOT_USED;
|
||||
C = zeromv;
|
||||
} else {
|
||||
diagonal_ref = PART_NOT_AVAILABLE;
|
||||
C = zeromv;
|
||||
}
|
||||
}
|
||||
|
||||
match_count = !diagonal_ref + !top_ref + !left_ref;
|
||||
ff_tlog(h->avctx, "pred_pskip_motion match_count=%d\n", match_count);
|
||||
if (match_count > 1) {
|
||||
mx = mid_pred(A[0], B[0], C[0]);
|
||||
my = mid_pred(A[1], B[1], C[1]);
|
||||
} else if (match_count == 1) {
|
||||
if (!left_ref) {
|
||||
mx = A[0];
|
||||
my = A[1];
|
||||
} else if (!top_ref) {
|
||||
mx = B[0];
|
||||
my = B[1];
|
||||
} else {
|
||||
mx = C[0];
|
||||
my = C[1];
|
||||
}
|
||||
} else {
|
||||
mx = mid_pred(A[0], B[0], C[0]);
|
||||
my = mid_pred(A[1], B[1], C[1]);
|
||||
}
|
||||
|
||||
fill_rectangle(sl->mv_cache[0][scan8[0]], 4, 4, 8, pack16to32(mx, my), 4);
|
||||
return;
|
||||
|
||||
zeromv:
|
||||
fill_rectangle(sl->mv_cache[0][scan8[0]], 4, 4, 8, 0, 4);
|
||||
return;
|
||||
}
|
||||
|
||||
static void fill_decode_neighbors(const H264Context *h, H264SliceContext *sl, int mb_type)
|
||||
{
|
||||
const int mb_xy = sl->mb_xy;
|
||||
int topleft_xy, top_xy, topright_xy, left_xy[LEFT_MBS];
|
||||
static const uint8_t left_block_options[4][32] = {
|
||||
{ 0, 1, 2, 3, 7, 10, 8, 11, 3 + 0 * 4, 3 + 1 * 4, 3 + 2 * 4, 3 + 3 * 4, 1 + 4 * 4, 1 + 8 * 4, 1 + 5 * 4, 1 + 9 * 4 },
|
||||
{ 2, 2, 3, 3, 8, 11, 8, 11, 3 + 2 * 4, 3 + 2 * 4, 3 + 3 * 4, 3 + 3 * 4, 1 + 5 * 4, 1 + 9 * 4, 1 + 5 * 4, 1 + 9 * 4 },
|
||||
{ 0, 0, 1, 1, 7, 10, 7, 10, 3 + 0 * 4, 3 + 0 * 4, 3 + 1 * 4, 3 + 1 * 4, 1 + 4 * 4, 1 + 8 * 4, 1 + 4 * 4, 1 + 8 * 4 },
|
||||
{ 0, 2, 0, 2, 7, 10, 7, 10, 3 + 0 * 4, 3 + 2 * 4, 3 + 0 * 4, 3 + 2 * 4, 1 + 4 * 4, 1 + 8 * 4, 1 + 4 * 4, 1 + 8 * 4 }
|
||||
};
|
||||
|
||||
sl->topleft_partition = -1;
|
||||
|
||||
top_xy = mb_xy - (h->mb_stride << MB_FIELD(sl));
|
||||
|
||||
/* Wow, what a mess, why didn't they simplify the interlacing & intra
|
||||
* stuff, I can't imagine that these complex rules are worth it. */
|
||||
|
||||
topleft_xy = top_xy - 1;
|
||||
topright_xy = top_xy + 1;
|
||||
left_xy[LBOT] = left_xy[LTOP] = mb_xy - 1;
|
||||
sl->left_block = left_block_options[0];
|
||||
if (FRAME_MBAFF(h)) {
|
||||
const int left_mb_field_flag = IS_INTERLACED(h->cur_pic.mb_type[mb_xy - 1]);
|
||||
const int curr_mb_field_flag = IS_INTERLACED(mb_type);
|
||||
if (sl->mb_y & 1) {
|
||||
if (left_mb_field_flag != curr_mb_field_flag) {
|
||||
left_xy[LBOT] = left_xy[LTOP] = mb_xy - h->mb_stride - 1;
|
||||
if (curr_mb_field_flag) {
|
||||
left_xy[LBOT] += h->mb_stride;
|
||||
sl->left_block = left_block_options[3];
|
||||
} else {
|
||||
topleft_xy += h->mb_stride;
|
||||
/* take top left mv from the middle of the mb, as opposed
|
||||
* to all other modes which use the bottom right partition */
|
||||
sl->topleft_partition = 0;
|
||||
sl->left_block = left_block_options[1];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (curr_mb_field_flag) {
|
||||
topleft_xy += h->mb_stride & (((h->cur_pic.mb_type[top_xy - 1] >> 7) & 1) - 1);
|
||||
topright_xy += h->mb_stride & (((h->cur_pic.mb_type[top_xy + 1] >> 7) & 1) - 1);
|
||||
top_xy += h->mb_stride & (((h->cur_pic.mb_type[top_xy] >> 7) & 1) - 1);
|
||||
}
|
||||
if (left_mb_field_flag != curr_mb_field_flag) {
|
||||
if (curr_mb_field_flag) {
|
||||
left_xy[LBOT] += h->mb_stride;
|
||||
sl->left_block = left_block_options[3];
|
||||
} else {
|
||||
sl->left_block = left_block_options[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sl->topleft_mb_xy = topleft_xy;
|
||||
sl->top_mb_xy = top_xy;
|
||||
sl->topright_mb_xy = topright_xy;
|
||||
sl->left_mb_xy[LTOP] = left_xy[LTOP];
|
||||
sl->left_mb_xy[LBOT] = left_xy[LBOT];
|
||||
//FIXME do we need all in the context?
|
||||
|
||||
sl->topleft_type = h->cur_pic.mb_type[topleft_xy];
|
||||
sl->top_type = h->cur_pic.mb_type[top_xy];
|
||||
sl->topright_type = h->cur_pic.mb_type[topright_xy];
|
||||
sl->left_type[LTOP] = h->cur_pic.mb_type[left_xy[LTOP]];
|
||||
sl->left_type[LBOT] = h->cur_pic.mb_type[left_xy[LBOT]];
|
||||
|
||||
if (FMO) {
|
||||
if (h->slice_table[topleft_xy] != sl->slice_num)
|
||||
sl->topleft_type = 0;
|
||||
if (h->slice_table[top_xy] != sl->slice_num)
|
||||
sl->top_type = 0;
|
||||
if (h->slice_table[left_xy[LTOP]] != sl->slice_num)
|
||||
sl->left_type[LTOP] = sl->left_type[LBOT] = 0;
|
||||
} else {
|
||||
if (h->slice_table[topleft_xy] != sl->slice_num) {
|
||||
sl->topleft_type = 0;
|
||||
if (h->slice_table[top_xy] != sl->slice_num)
|
||||
sl->top_type = 0;
|
||||
if (h->slice_table[left_xy[LTOP]] != sl->slice_num)
|
||||
sl->left_type[LTOP] = sl->left_type[LBOT] = 0;
|
||||
}
|
||||
}
|
||||
if (h->slice_table[topright_xy] != sl->slice_num)
|
||||
sl->topright_type = 0;
|
||||
}
|
||||
|
||||
static void fill_decode_caches(const H264Context *h, H264SliceContext *sl, int mb_type)
|
||||
{
|
||||
int topleft_xy, top_xy, topright_xy, left_xy[LEFT_MBS];
|
||||
int topleft_type, top_type, topright_type, left_type[LEFT_MBS];
|
||||
const uint8_t *left_block = sl->left_block;
|
||||
int i;
|
||||
uint8_t *nnz;
|
||||
uint8_t *nnz_cache;
|
||||
|
||||
topleft_xy = sl->topleft_mb_xy;
|
||||
top_xy = sl->top_mb_xy;
|
||||
topright_xy = sl->topright_mb_xy;
|
||||
left_xy[LTOP] = sl->left_mb_xy[LTOP];
|
||||
left_xy[LBOT] = sl->left_mb_xy[LBOT];
|
||||
topleft_type = sl->topleft_type;
|
||||
top_type = sl->top_type;
|
||||
topright_type = sl->topright_type;
|
||||
left_type[LTOP] = sl->left_type[LTOP];
|
||||
left_type[LBOT] = sl->left_type[LBOT];
|
||||
|
||||
if (!IS_SKIP(mb_type)) {
|
||||
if (IS_INTRA(mb_type)) {
|
||||
int type_mask = h->ps.pps->constrained_intra_pred ? IS_INTRA(-1) : -1;
|
||||
sl->topleft_samples_available =
|
||||
sl->top_samples_available =
|
||||
sl->left_samples_available = 0xFFFF;
|
||||
sl->topright_samples_available = 0xEEEA;
|
||||
|
||||
if (!(top_type & type_mask)) {
|
||||
sl->topleft_samples_available = 0xB3FF;
|
||||
sl->top_samples_available = 0x33FF;
|
||||
sl->topright_samples_available = 0x26EA;
|
||||
}
|
||||
if (IS_INTERLACED(mb_type) != IS_INTERLACED(left_type[LTOP])) {
|
||||
if (IS_INTERLACED(mb_type)) {
|
||||
if (!(left_type[LTOP] & type_mask)) {
|
||||
sl->topleft_samples_available &= 0xDFFF;
|
||||
sl->left_samples_available &= 0x5FFF;
|
||||
}
|
||||
if (!(left_type[LBOT] & type_mask)) {
|
||||
sl->topleft_samples_available &= 0xFF5F;
|
||||
sl->left_samples_available &= 0xFF5F;
|
||||
}
|
||||
} else {
|
||||
int left_typei = h->cur_pic.mb_type[left_xy[LTOP] + h->mb_stride];
|
||||
|
||||
av_assert2(left_xy[LTOP] == left_xy[LBOT]);
|
||||
if (!((left_typei & type_mask) && (left_type[LTOP] & type_mask))) {
|
||||
sl->topleft_samples_available &= 0xDF5F;
|
||||
sl->left_samples_available &= 0x5F5F;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!(left_type[LTOP] & type_mask)) {
|
||||
sl->topleft_samples_available &= 0xDF5F;
|
||||
sl->left_samples_available &= 0x5F5F;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(topleft_type & type_mask))
|
||||
sl->topleft_samples_available &= 0x7FFF;
|
||||
|
||||
if (!(topright_type & type_mask))
|
||||
sl->topright_samples_available &= 0xFBFF;
|
||||
|
||||
if (IS_INTRA4x4(mb_type)) {
|
||||
if (IS_INTRA4x4(top_type)) {
|
||||
AV_COPY32(sl->intra4x4_pred_mode_cache + 4 + 8 * 0, sl->intra4x4_pred_mode + h->mb2br_xy[top_xy]);
|
||||
} else {
|
||||
sl->intra4x4_pred_mode_cache[4 + 8 * 0] =
|
||||
sl->intra4x4_pred_mode_cache[5 + 8 * 0] =
|
||||
sl->intra4x4_pred_mode_cache[6 + 8 * 0] =
|
||||
sl->intra4x4_pred_mode_cache[7 + 8 * 0] = 2 - 3 * !(top_type & type_mask);
|
||||
}
|
||||
for (i = 0; i < 2; i++) {
|
||||
if (IS_INTRA4x4(left_type[LEFT(i)])) {
|
||||
int8_t *mode = sl->intra4x4_pred_mode + h->mb2br_xy[left_xy[LEFT(i)]];
|
||||
sl->intra4x4_pred_mode_cache[3 + 8 * 1 + 2 * 8 * i] = mode[6 - left_block[0 + 2 * i]];
|
||||
sl->intra4x4_pred_mode_cache[3 + 8 * 2 + 2 * 8 * i] = mode[6 - left_block[1 + 2 * i]];
|
||||
} else {
|
||||
sl->intra4x4_pred_mode_cache[3 + 8 * 1 + 2 * 8 * i] =
|
||||
sl->intra4x4_pred_mode_cache[3 + 8 * 2 + 2 * 8 * i] = 2 - 3 * !(left_type[LEFT(i)] & type_mask);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 0 . T T. T T T T
|
||||
* 1 L . .L . . . .
|
||||
* 2 L . .L . . . .
|
||||
* 3 . T TL . . . .
|
||||
* 4 L . .L . . . .
|
||||
* 5 L . .. . . . .
|
||||
*/
|
||||
/* FIXME: constraint_intra_pred & partitioning & nnz
|
||||
* (let us hope this is just a typo in the spec) */
|
||||
nnz_cache = sl->non_zero_count_cache;
|
||||
if (top_type) {
|
||||
nnz = h->non_zero_count[top_xy];
|
||||
AV_COPY32(&nnz_cache[4 + 8 * 0], &nnz[4 * 3]);
|
||||
if (!h->chroma_y_shift) {
|
||||
AV_COPY32(&nnz_cache[4 + 8 * 5], &nnz[4 * 7]);
|
||||
AV_COPY32(&nnz_cache[4 + 8 * 10], &nnz[4 * 11]);
|
||||
} else {
|
||||
AV_COPY32(&nnz_cache[4 + 8 * 5], &nnz[4 * 5]);
|
||||
AV_COPY32(&nnz_cache[4 + 8 * 10], &nnz[4 * 9]);
|
||||
}
|
||||
} else {
|
||||
uint32_t top_empty = CABAC(h) && !IS_INTRA(mb_type) ? 0 : 0x40404040;
|
||||
AV_WN32A(&nnz_cache[4 + 8 * 0], top_empty);
|
||||
AV_WN32A(&nnz_cache[4 + 8 * 5], top_empty);
|
||||
AV_WN32A(&nnz_cache[4 + 8 * 10], top_empty);
|
||||
}
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
if (left_type[LEFT(i)]) {
|
||||
nnz = h->non_zero_count[left_xy[LEFT(i)]];
|
||||
nnz_cache[3 + 8 * 1 + 2 * 8 * i] = nnz[left_block[8 + 0 + 2 * i]];
|
||||
nnz_cache[3 + 8 * 2 + 2 * 8 * i] = nnz[left_block[8 + 1 + 2 * i]];
|
||||
if (CHROMA444(h)) {
|
||||
nnz_cache[3 + 8 * 6 + 2 * 8 * i] = nnz[left_block[8 + 0 + 2 * i] + 4 * 4];
|
||||
nnz_cache[3 + 8 * 7 + 2 * 8 * i] = nnz[left_block[8 + 1 + 2 * i] + 4 * 4];
|
||||
nnz_cache[3 + 8 * 11 + 2 * 8 * i] = nnz[left_block[8 + 0 + 2 * i] + 8 * 4];
|
||||
nnz_cache[3 + 8 * 12 + 2 * 8 * i] = nnz[left_block[8 + 1 + 2 * i] + 8 * 4];
|
||||
} else if (CHROMA422(h)) {
|
||||
nnz_cache[3 + 8 * 6 + 2 * 8 * i] = nnz[left_block[8 + 0 + 2 * i] - 2 + 4 * 4];
|
||||
nnz_cache[3 + 8 * 7 + 2 * 8 * i] = nnz[left_block[8 + 1 + 2 * i] - 2 + 4 * 4];
|
||||
nnz_cache[3 + 8 * 11 + 2 * 8 * i] = nnz[left_block[8 + 0 + 2 * i] - 2 + 8 * 4];
|
||||
nnz_cache[3 + 8 * 12 + 2 * 8 * i] = nnz[left_block[8 + 1 + 2 * i] - 2 + 8 * 4];
|
||||
} else {
|
||||
nnz_cache[3 + 8 * 6 + 8 * i] = nnz[left_block[8 + 4 + 2 * i]];
|
||||
nnz_cache[3 + 8 * 11 + 8 * i] = nnz[left_block[8 + 5 + 2 * i]];
|
||||
}
|
||||
} else {
|
||||
nnz_cache[3 + 8 * 1 + 2 * 8 * i] =
|
||||
nnz_cache[3 + 8 * 2 + 2 * 8 * i] =
|
||||
nnz_cache[3 + 8 * 6 + 2 * 8 * i] =
|
||||
nnz_cache[3 + 8 * 7 + 2 * 8 * i] =
|
||||
nnz_cache[3 + 8 * 11 + 2 * 8 * i] =
|
||||
nnz_cache[3 + 8 * 12 + 2 * 8 * i] = CABAC(h) && !IS_INTRA(mb_type) ? 0 : 64;
|
||||
}
|
||||
}
|
||||
|
||||
if (CABAC(h)) {
|
||||
// top_cbp
|
||||
if (top_type)
|
||||
sl->top_cbp = h->cbp_table[top_xy];
|
||||
else
|
||||
sl->top_cbp = IS_INTRA(mb_type) ? 0x7CF : 0x00F;
|
||||
// left_cbp
|
||||
if (left_type[LTOP]) {
|
||||
sl->left_cbp = (h->cbp_table[left_xy[LTOP]] & 0x7F0) |
|
||||
((h->cbp_table[left_xy[LTOP]] >> (left_block[0] & (~1))) & 2) |
|
||||
(((h->cbp_table[left_xy[LBOT]] >> (left_block[2] & (~1))) & 2) << 2);
|
||||
} else {
|
||||
sl->left_cbp = IS_INTRA(mb_type) ? 0x7CF : 0x00F;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (IS_INTER(mb_type) || (IS_DIRECT(mb_type) && sl->direct_spatial_mv_pred)) {
|
||||
int list;
|
||||
int b_stride = h->b_stride;
|
||||
for (list = 0; list < sl->list_count; list++) {
|
||||
int8_t *ref_cache = &sl->ref_cache[list][scan8[0]];
|
||||
int8_t *ref = h->cur_pic.ref_index[list];
|
||||
int16_t(*mv_cache)[2] = &sl->mv_cache[list][scan8[0]];
|
||||
int16_t(*mv)[2] = h->cur_pic.motion_val[list];
|
||||
if (!USES_LIST(mb_type, list))
|
||||
continue;
|
||||
av_assert2(!(IS_DIRECT(mb_type) && !sl->direct_spatial_mv_pred));
|
||||
|
||||
if (USES_LIST(top_type, list)) {
|
||||
const int b_xy = h->mb2b_xy[top_xy] + 3 * b_stride;
|
||||
AV_COPY128(mv_cache[0 - 1 * 8], mv[b_xy + 0]);
|
||||
ref_cache[0 - 1 * 8] =
|
||||
ref_cache[1 - 1 * 8] = ref[4 * top_xy + 2];
|
||||
ref_cache[2 - 1 * 8] =
|
||||
ref_cache[3 - 1 * 8] = ref[4 * top_xy + 3];
|
||||
} else {
|
||||
AV_ZERO128(mv_cache[0 - 1 * 8]);
|
||||
AV_WN32A(&ref_cache[0 - 1 * 8],
|
||||
((top_type ? LIST_NOT_USED : PART_NOT_AVAILABLE) & 0xFF) * 0x01010101u);
|
||||
}
|
||||
|
||||
if (mb_type & (MB_TYPE_16x8 | MB_TYPE_8x8)) {
|
||||
for (i = 0; i < 2; i++) {
|
||||
int cache_idx = -1 + i * 2 * 8;
|
||||
if (USES_LIST(left_type[LEFT(i)], list)) {
|
||||
const int b_xy = h->mb2b_xy[left_xy[LEFT(i)]] + 3;
|
||||
const int b8_xy = 4 * left_xy[LEFT(i)] + 1;
|
||||
AV_COPY32(mv_cache[cache_idx],
|
||||
mv[b_xy + b_stride * left_block[0 + i * 2]]);
|
||||
AV_COPY32(mv_cache[cache_idx + 8],
|
||||
mv[b_xy + b_stride * left_block[1 + i * 2]]);
|
||||
ref_cache[cache_idx] = ref[b8_xy + (left_block[0 + i * 2] & ~1)];
|
||||
ref_cache[cache_idx + 8] = ref[b8_xy + (left_block[1 + i * 2] & ~1)];
|
||||
} else {
|
||||
AV_ZERO32(mv_cache[cache_idx]);
|
||||
AV_ZERO32(mv_cache[cache_idx + 8]);
|
||||
ref_cache[cache_idx] =
|
||||
ref_cache[cache_idx + 8] = (left_type[LEFT(i)]) ? LIST_NOT_USED
|
||||
: PART_NOT_AVAILABLE;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (USES_LIST(left_type[LTOP], list)) {
|
||||
const int b_xy = h->mb2b_xy[left_xy[LTOP]] + 3;
|
||||
const int b8_xy = 4 * left_xy[LTOP] + 1;
|
||||
AV_COPY32(mv_cache[-1], mv[b_xy + b_stride * left_block[0]]);
|
||||
ref_cache[-1] = ref[b8_xy + (left_block[0] & ~1)];
|
||||
} else {
|
||||
AV_ZERO32(mv_cache[-1]);
|
||||
ref_cache[-1] = left_type[LTOP] ? LIST_NOT_USED
|
||||
: PART_NOT_AVAILABLE;
|
||||
}
|
||||
}
|
||||
|
||||
if (USES_LIST(topright_type, list)) {
|
||||
const int b_xy = h->mb2b_xy[topright_xy] + 3 * b_stride;
|
||||
AV_COPY32(mv_cache[4 - 1 * 8], mv[b_xy]);
|
||||
ref_cache[4 - 1 * 8] = ref[4 * topright_xy + 2];
|
||||
} else {
|
||||
AV_ZERO32(mv_cache[4 - 1 * 8]);
|
||||
ref_cache[4 - 1 * 8] = topright_type ? LIST_NOT_USED
|
||||
: PART_NOT_AVAILABLE;
|
||||
}
|
||||
if(ref_cache[2 - 1*8] < 0 || ref_cache[4 - 1 * 8] < 0) {
|
||||
if (USES_LIST(topleft_type, list)) {
|
||||
const int b_xy = h->mb2b_xy[topleft_xy] + 3 + b_stride +
|
||||
(sl->topleft_partition & 2 * b_stride);
|
||||
const int b8_xy = 4 * topleft_xy + 1 + (sl->topleft_partition & 2);
|
||||
AV_COPY32(mv_cache[-1 - 1 * 8], mv[b_xy]);
|
||||
ref_cache[-1 - 1 * 8] = ref[b8_xy];
|
||||
} else {
|
||||
AV_ZERO32(mv_cache[-1 - 1 * 8]);
|
||||
ref_cache[-1 - 1 * 8] = topleft_type ? LIST_NOT_USED
|
||||
: PART_NOT_AVAILABLE;
|
||||
}
|
||||
}
|
||||
|
||||
if ((mb_type & (MB_TYPE_SKIP | MB_TYPE_DIRECT2)) && !FRAME_MBAFF(h))
|
||||
continue;
|
||||
|
||||
if (!(mb_type & (MB_TYPE_SKIP | MB_TYPE_DIRECT2))) {
|
||||
uint8_t(*mvd_cache)[2] = &sl->mvd_cache[list][scan8[0]];
|
||||
uint8_t(*mvd)[2] = sl->mvd_table[list];
|
||||
ref_cache[2 + 8 * 0] =
|
||||
ref_cache[2 + 8 * 2] = PART_NOT_AVAILABLE;
|
||||
AV_ZERO32(mv_cache[2 + 8 * 0]);
|
||||
AV_ZERO32(mv_cache[2 + 8 * 2]);
|
||||
|
||||
if (CABAC(h)) {
|
||||
if (USES_LIST(top_type, list)) {
|
||||
const int b_xy = h->mb2br_xy[top_xy];
|
||||
AV_COPY64(mvd_cache[0 - 1 * 8], mvd[b_xy + 0]);
|
||||
} else {
|
||||
AV_ZERO64(mvd_cache[0 - 1 * 8]);
|
||||
}
|
||||
if (USES_LIST(left_type[LTOP], list)) {
|
||||
const int b_xy = h->mb2br_xy[left_xy[LTOP]] + 6;
|
||||
AV_COPY16(mvd_cache[-1 + 0 * 8], mvd[b_xy - left_block[0]]);
|
||||
AV_COPY16(mvd_cache[-1 + 1 * 8], mvd[b_xy - left_block[1]]);
|
||||
} else {
|
||||
AV_ZERO16(mvd_cache[-1 + 0 * 8]);
|
||||
AV_ZERO16(mvd_cache[-1 + 1 * 8]);
|
||||
}
|
||||
if (USES_LIST(left_type[LBOT], list)) {
|
||||
const int b_xy = h->mb2br_xy[left_xy[LBOT]] + 6;
|
||||
AV_COPY16(mvd_cache[-1 + 2 * 8], mvd[b_xy - left_block[2]]);
|
||||
AV_COPY16(mvd_cache[-1 + 3 * 8], mvd[b_xy - left_block[3]]);
|
||||
} else {
|
||||
AV_ZERO16(mvd_cache[-1 + 2 * 8]);
|
||||
AV_ZERO16(mvd_cache[-1 + 3 * 8]);
|
||||
}
|
||||
AV_ZERO16(mvd_cache[2 + 8 * 0]);
|
||||
AV_ZERO16(mvd_cache[2 + 8 * 2]);
|
||||
if (sl->slice_type_nos == AV_PICTURE_TYPE_B) {
|
||||
uint8_t *direct_cache = &sl->direct_cache[scan8[0]];
|
||||
uint8_t *direct_table = h->direct_table;
|
||||
fill_rectangle(direct_cache, 4, 4, 8, MB_TYPE_16x16 >> 1, 1);
|
||||
|
||||
if (IS_DIRECT(top_type)) {
|
||||
AV_WN32A(&direct_cache[-1 * 8],
|
||||
0x01010101u * (MB_TYPE_DIRECT2 >> 1));
|
||||
} else if (IS_8X8(top_type)) {
|
||||
int b8_xy = 4 * top_xy;
|
||||
direct_cache[0 - 1 * 8] = direct_table[b8_xy + 2];
|
||||
direct_cache[2 - 1 * 8] = direct_table[b8_xy + 3];
|
||||
} else {
|
||||
AV_WN32A(&direct_cache[-1 * 8],
|
||||
0x01010101 * (MB_TYPE_16x16 >> 1));
|
||||
}
|
||||
|
||||
if (IS_DIRECT(left_type[LTOP]))
|
||||
direct_cache[-1 + 0 * 8] = MB_TYPE_DIRECT2 >> 1;
|
||||
else if (IS_8X8(left_type[LTOP]))
|
||||
direct_cache[-1 + 0 * 8] = direct_table[4 * left_xy[LTOP] + 1 + (left_block[0] & ~1)];
|
||||
else
|
||||
direct_cache[-1 + 0 * 8] = MB_TYPE_16x16 >> 1;
|
||||
|
||||
if (IS_DIRECT(left_type[LBOT]))
|
||||
direct_cache[-1 + 2 * 8] = MB_TYPE_DIRECT2 >> 1;
|
||||
else if (IS_8X8(left_type[LBOT]))
|
||||
direct_cache[-1 + 2 * 8] = direct_table[4 * left_xy[LBOT] + 1 + (left_block[2] & ~1)];
|
||||
else
|
||||
direct_cache[-1 + 2 * 8] = MB_TYPE_16x16 >> 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define MAP_MVS \
|
||||
MAP_F2F(scan8[0] - 1 - 1 * 8, topleft_type) \
|
||||
MAP_F2F(scan8[0] + 0 - 1 * 8, top_type) \
|
||||
MAP_F2F(scan8[0] + 1 - 1 * 8, top_type) \
|
||||
MAP_F2F(scan8[0] + 2 - 1 * 8, top_type) \
|
||||
MAP_F2F(scan8[0] + 3 - 1 * 8, top_type) \
|
||||
MAP_F2F(scan8[0] + 4 - 1 * 8, topright_type) \
|
||||
MAP_F2F(scan8[0] - 1 + 0 * 8, left_type[LTOP]) \
|
||||
MAP_F2F(scan8[0] - 1 + 1 * 8, left_type[LTOP]) \
|
||||
MAP_F2F(scan8[0] - 1 + 2 * 8, left_type[LBOT]) \
|
||||
MAP_F2F(scan8[0] - 1 + 3 * 8, left_type[LBOT])
|
||||
|
||||
if (FRAME_MBAFF(h)) {
|
||||
if (MB_FIELD(sl)) {
|
||||
|
||||
#define MAP_F2F(idx, mb_type) \
|
||||
if (!IS_INTERLACED(mb_type) && sl->ref_cache[list][idx] >= 0) { \
|
||||
sl->ref_cache[list][idx] *= 2; \
|
||||
sl->mv_cache[list][idx][1] /= 2; \
|
||||
sl->mvd_cache[list][idx][1] >>= 1; \
|
||||
}
|
||||
|
||||
MAP_MVS
|
||||
} else {
|
||||
|
||||
#undef MAP_F2F
|
||||
#define MAP_F2F(idx, mb_type) \
|
||||
if (IS_INTERLACED(mb_type) && sl->ref_cache[list][idx] >= 0) { \
|
||||
sl->ref_cache[list][idx] >>= 1; \
|
||||
sl->mv_cache[list][idx][1] *= 2; \
|
||||
sl->mvd_cache[list][idx][1] <<= 1; \
|
||||
}
|
||||
|
||||
MAP_MVS
|
||||
#undef MAP_F2F
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sl->neighbor_transform_size = !!IS_8x8DCT(top_type) + !!IS_8x8DCT(left_type[LTOP]);
|
||||
}
|
||||
|
||||
/**
|
||||
* decodes a P_SKIP or B_SKIP macroblock
|
||||
*/
|
||||
static void av_unused decode_mb_skip(const H264Context *h, H264SliceContext *sl)
|
||||
{
|
||||
const int mb_xy = sl->mb_xy;
|
||||
int mb_type = 0;
|
||||
|
||||
memset(h->non_zero_count[mb_xy], 0, 48);
|
||||
|
||||
if (MB_FIELD(sl))
|
||||
mb_type |= MB_TYPE_INTERLACED;
|
||||
|
||||
if (sl->slice_type_nos == AV_PICTURE_TYPE_B) {
|
||||
// just for fill_caches. pred_direct_motion will set the real mb_type
|
||||
mb_type |= MB_TYPE_L0L1 | MB_TYPE_DIRECT2 | MB_TYPE_SKIP;
|
||||
if (sl->direct_spatial_mv_pred) {
|
||||
fill_decode_neighbors(h, sl, mb_type);
|
||||
fill_decode_caches(h, sl, mb_type); //FIXME check what is needed and what not ...
|
||||
}
|
||||
ff_h264_pred_direct_motion(h, sl, &mb_type);
|
||||
mb_type |= MB_TYPE_SKIP;
|
||||
} else {
|
||||
mb_type |= MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P1L0 | MB_TYPE_SKIP;
|
||||
|
||||
fill_decode_neighbors(h, sl, mb_type);
|
||||
pred_pskip_motion(h, sl);
|
||||
}
|
||||
|
||||
write_back_motion(h, sl, mb_type);
|
||||
h->cur_pic.mb_type[mb_xy] = mb_type;
|
||||
h->cur_pic.qscale_table[mb_xy] = sl->qscale;
|
||||
h->slice_table[mb_xy] = sl->slice_num;
|
||||
sl->prev_mb_skipped = 1;
|
||||
}
|
||||
|
||||
#endif /* AVCODEC_H264_MVPRED_H */
|
||||
136
include/libavcodec/h264_parse.h
Normal file
136
include/libavcodec/h264_parse.h
Normal file
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* 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
|
||||
* H.264 decoder/parser shared code
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_H264_PARSE_H
|
||||
#define AVCODEC_H264_PARSE_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libavutil/attributes.h"
|
||||
|
||||
#include "get_bits.h"
|
||||
#include "h264_ps.h"
|
||||
|
||||
#define MB_TYPE_REF0 MB_TYPE_ACPRED // dirty but it fits in 16 bit
|
||||
#define MB_TYPE_8x8DCT 0x01000000
|
||||
|
||||
// This table must be here because scan8[constant] must be known at compiletime
|
||||
static const uint8_t scan8[16 * 3 + 3] = {
|
||||
4 + 1 * 8, 5 + 1 * 8, 4 + 2 * 8, 5 + 2 * 8,
|
||||
6 + 1 * 8, 7 + 1 * 8, 6 + 2 * 8, 7 + 2 * 8,
|
||||
4 + 3 * 8, 5 + 3 * 8, 4 + 4 * 8, 5 + 4 * 8,
|
||||
6 + 3 * 8, 7 + 3 * 8, 6 + 4 * 8, 7 + 4 * 8,
|
||||
4 + 6 * 8, 5 + 6 * 8, 4 + 7 * 8, 5 + 7 * 8,
|
||||
6 + 6 * 8, 7 + 6 * 8, 6 + 7 * 8, 7 + 7 * 8,
|
||||
4 + 8 * 8, 5 + 8 * 8, 4 + 9 * 8, 5 + 9 * 8,
|
||||
6 + 8 * 8, 7 + 8 * 8, 6 + 9 * 8, 7 + 9 * 8,
|
||||
4 + 11 * 8, 5 + 11 * 8, 4 + 12 * 8, 5 + 12 * 8,
|
||||
6 + 11 * 8, 7 + 11 * 8, 6 + 12 * 8, 7 + 12 * 8,
|
||||
4 + 13 * 8, 5 + 13 * 8, 4 + 14 * 8, 5 + 14 * 8,
|
||||
6 + 13 * 8, 7 + 13 * 8, 6 + 14 * 8, 7 + 14 * 8,
|
||||
0 + 0 * 8, 0 + 5 * 8, 0 + 10 * 8
|
||||
};
|
||||
|
||||
/**
|
||||
* Memory management control operation opcode.
|
||||
*/
|
||||
typedef enum MMCOOpcode {
|
||||
MMCO_END = 0,
|
||||
MMCO_SHORT2UNUSED,
|
||||
MMCO_LONG2UNUSED,
|
||||
MMCO_SHORT2LONG,
|
||||
MMCO_SET_MAX_LONG,
|
||||
MMCO_RESET,
|
||||
MMCO_LONG,
|
||||
} MMCOOpcode;
|
||||
|
||||
typedef struct H264PredWeightTable {
|
||||
int use_weight;
|
||||
int use_weight_chroma;
|
||||
int luma_log2_weight_denom;
|
||||
int chroma_log2_weight_denom;
|
||||
int luma_weight_flag[2]; ///< 7.4.3.2 luma_weight_lX_flag
|
||||
int chroma_weight_flag[2]; ///< 7.4.3.2 chroma_weight_lX_flag
|
||||
// The following 2 can be changed to int8_t but that causes a 10 CPU cycles speed loss
|
||||
int luma_weight[48][2][2];
|
||||
int chroma_weight[48][2][2][2];
|
||||
int implicit_weight[48][48][2];
|
||||
} H264PredWeightTable;
|
||||
|
||||
typedef struct H264POCContext {
|
||||
int poc_lsb;
|
||||
int poc_msb;
|
||||
int delta_poc_bottom;
|
||||
int delta_poc[2];
|
||||
int frame_num;
|
||||
int prev_poc_msb; ///< poc_msb of the last reference pic for POC type 0
|
||||
int prev_poc_lsb; ///< poc_lsb of the last reference pic for POC type 0
|
||||
int frame_num_offset; ///< for POC type 2
|
||||
int prev_frame_num_offset; ///< for POC type 2
|
||||
int prev_frame_num; ///< frame_num of the last pic for POC type 1/2
|
||||
} H264POCContext;
|
||||
|
||||
int ff_h264_pred_weight_table(GetBitContext *gb, const SPS *sps,
|
||||
const int *ref_count, int slice_type_nos,
|
||||
H264PredWeightTable *pwt,
|
||||
int picture_structure, void *logctx);
|
||||
|
||||
/**
|
||||
* Check if the top & left blocks are available if needed & change the
|
||||
* dc mode so it only uses the available blocks.
|
||||
*/
|
||||
int ff_h264_check_intra4x4_pred_mode(int8_t *pred_mode_cache, void *logctx,
|
||||
int top_samples_available, int left_samples_available);
|
||||
|
||||
/**
|
||||
* Check if the top & left blocks are available if needed & change the
|
||||
* dc mode so it only uses the available blocks.
|
||||
*/
|
||||
int ff_h264_check_intra_pred_mode(void *logctx, int top_samples_available,
|
||||
int left_samples_available,
|
||||
int mode, int is_chroma);
|
||||
|
||||
int ff_h264_parse_ref_count(int *plist_count, int ref_count[2],
|
||||
GetBitContext *gb, const PPS *pps,
|
||||
int slice_type_nos, int picture_structure, void *logctx);
|
||||
|
||||
int ff_h264_init_poc(int pic_field_poc[2], int *pic_poc,
|
||||
const SPS *sps, H264POCContext *poc,
|
||||
int picture_structure, int nal_ref_idc);
|
||||
|
||||
int ff_h264_decode_extradata(const uint8_t *data, int size, H264ParamSets *ps,
|
||||
int *is_avc, int *nal_length_size,
|
||||
int err_recognition, void *logctx);
|
||||
|
||||
static av_always_inline uint32_t pack16to32(unsigned a, unsigned b)
|
||||
{
|
||||
#if HAVE_BIGENDIAN
|
||||
return (b & 0xFFFF) + (a << 16);
|
||||
#else
|
||||
return (a & 0xFFFF) + (b << 16);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* AVCODEC_H264_PARSE_H */
|
||||
177
include/libavcodec/h264_ps.h
Normal file
177
include/libavcodec/h264_ps.h
Normal file
@@ -0,0 +1,177 @@
|
||||
/*
|
||||
* 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
|
||||
* H.264 parameter set handling
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_H264_PS_H
|
||||
#define AVCODEC_H264_PS_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libavutil/pixfmt.h"
|
||||
#include "libavutil/rational.h"
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "get_bits.h"
|
||||
#include "h264.h"
|
||||
#include "h2645_vui.h"
|
||||
|
||||
#define MAX_SPS_COUNT 32
|
||||
#define MAX_PPS_COUNT 256
|
||||
#define MAX_LOG2_MAX_FRAME_NUM (12 + 4)
|
||||
|
||||
/**
|
||||
* Sequence parameter set
|
||||
*/
|
||||
typedef struct SPS {
|
||||
unsigned int sps_id;
|
||||
int profile_idc;
|
||||
int level_idc;
|
||||
int chroma_format_idc;
|
||||
int transform_bypass; ///< qpprime_y_zero_transform_bypass_flag
|
||||
int log2_max_frame_num; ///< log2_max_frame_num_minus4 + 4
|
||||
int poc_type; ///< pic_order_cnt_type
|
||||
int log2_max_poc_lsb; ///< log2_max_pic_order_cnt_lsb_minus4
|
||||
int delta_pic_order_always_zero_flag;
|
||||
int offset_for_non_ref_pic;
|
||||
int offset_for_top_to_bottom_field;
|
||||
int poc_cycle_length; ///< num_ref_frames_in_pic_order_cnt_cycle
|
||||
int ref_frame_count; ///< num_ref_frames
|
||||
int gaps_in_frame_num_allowed_flag;
|
||||
int mb_width; ///< pic_width_in_mbs_minus1 + 1
|
||||
///< (pic_height_in_map_units_minus1 + 1) * (2 - frame_mbs_only_flag)
|
||||
int mb_height;
|
||||
int frame_mbs_only_flag;
|
||||
int mb_aff; ///< mb_adaptive_frame_field_flag
|
||||
int direct_8x8_inference_flag;
|
||||
int crop; ///< frame_cropping_flag
|
||||
|
||||
/* those 4 are already in luma samples */
|
||||
unsigned int crop_left; ///< frame_cropping_rect_left_offset
|
||||
unsigned int crop_right; ///< frame_cropping_rect_right_offset
|
||||
unsigned int crop_top; ///< frame_cropping_rect_top_offset
|
||||
unsigned int crop_bottom; ///< frame_cropping_rect_bottom_offset
|
||||
int vui_parameters_present_flag;
|
||||
H2645VUI vui;
|
||||
|
||||
int timing_info_present_flag;
|
||||
uint32_t num_units_in_tick;
|
||||
uint32_t time_scale;
|
||||
int fixed_frame_rate_flag;
|
||||
int32_t offset_for_ref_frame[256];
|
||||
int bitstream_restriction_flag;
|
||||
int num_reorder_frames;
|
||||
int max_dec_frame_buffering;
|
||||
int scaling_matrix_present;
|
||||
uint16_t scaling_matrix_present_mask;
|
||||
uint8_t scaling_matrix4[6][16];
|
||||
uint8_t scaling_matrix8[6][64];
|
||||
int nal_hrd_parameters_present_flag;
|
||||
int vcl_hrd_parameters_present_flag;
|
||||
int pic_struct_present_flag;
|
||||
int time_offset_length;
|
||||
int cpb_cnt; ///< See H.264 E.1.2
|
||||
int bit_rate_scale;
|
||||
uint32_t bit_rate_value[32]; ///< bit_rate_value_minus1 + 1
|
||||
uint32_t cpb_size_value[32]; ///< cpb_size_value_minus1 + 1
|
||||
uint32_t cpr_flag;
|
||||
int initial_cpb_removal_delay_length; ///< initial_cpb_removal_delay_length_minus1 + 1
|
||||
int cpb_removal_delay_length; ///< cpb_removal_delay_length_minus1 + 1
|
||||
int dpb_output_delay_length; ///< dpb_output_delay_length_minus1 + 1
|
||||
int bit_depth_luma; ///< bit_depth_luma_minus8 + 8
|
||||
int bit_depth_chroma; ///< bit_depth_chroma_minus8 + 8
|
||||
int residual_color_transform_flag; ///< residual_colour_transform_flag
|
||||
int constraint_set_flags; ///< constraint_set[0-3]_flag
|
||||
uint8_t data[4096];
|
||||
size_t data_size;
|
||||
} SPS;
|
||||
|
||||
/**
|
||||
* Picture parameter set
|
||||
*/
|
||||
typedef struct PPS {
|
||||
unsigned int pps_id;
|
||||
unsigned int sps_id;
|
||||
int cabac; ///< entropy_coding_mode_flag
|
||||
int pic_order_present; ///< bottom_field_pic_order_in_frame_present_flag
|
||||
int slice_group_count; ///< num_slice_groups_minus1 + 1
|
||||
int mb_slice_group_map_type;
|
||||
unsigned int ref_count[2]; ///< num_ref_idx_l0/1_active_minus1 + 1
|
||||
int weighted_pred; ///< weighted_pred_flag
|
||||
int weighted_bipred_idc;
|
||||
int init_qp; ///< pic_init_qp_minus26 + 26
|
||||
int init_qs; ///< pic_init_qs_minus26 + 26
|
||||
int chroma_qp_index_offset[2];
|
||||
int deblocking_filter_parameters_present; ///< deblocking_filter_parameters_present_flag
|
||||
int constrained_intra_pred; ///< constrained_intra_pred_flag
|
||||
int redundant_pic_cnt_present; ///< redundant_pic_cnt_present_flag
|
||||
int transform_8x8_mode; ///< transform_8x8_mode_flag
|
||||
int pic_scaling_matrix_present_flag;
|
||||
uint16_t pic_scaling_matrix_present_mask;
|
||||
uint8_t scaling_matrix4[6][16];
|
||||
uint8_t scaling_matrix8[6][64];
|
||||
uint8_t chroma_qp_table[2][QP_MAX_NUM+1]; ///< pre-scaled (with chroma_qp_index_offset) version of qp_table
|
||||
int chroma_qp_diff;
|
||||
uint8_t data[4096];
|
||||
size_t data_size;
|
||||
|
||||
uint32_t dequant4_buffer[6][QP_MAX_NUM + 1][16];
|
||||
uint32_t dequant8_buffer[6][QP_MAX_NUM + 1][64];
|
||||
uint32_t(*dequant4_coeff[6])[16];
|
||||
uint32_t(*dequant8_coeff[6])[64];
|
||||
|
||||
const SPS *sps; ///< RefStruct reference
|
||||
} PPS;
|
||||
|
||||
typedef struct H264ParamSets {
|
||||
const SPS *sps_list[MAX_SPS_COUNT]; ///< RefStruct references
|
||||
const PPS *pps_list[MAX_PPS_COUNT]; ///< RefStruct references
|
||||
|
||||
/* currently active parameters sets */
|
||||
const PPS *pps; ///< RefStruct reference
|
||||
const SPS *sps; ///< ordinary pointer, no RefStruct reference
|
||||
|
||||
int overread_warning_printed[2];
|
||||
} H264ParamSets;
|
||||
|
||||
/**
|
||||
* compute profile from sps
|
||||
*/
|
||||
int ff_h264_get_profile(const SPS *sps);
|
||||
|
||||
/**
|
||||
* Decode SPS
|
||||
*/
|
||||
int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx,
|
||||
H264ParamSets *ps, int ignore_truncation);
|
||||
|
||||
/**
|
||||
* Decode PPS
|
||||
*/
|
||||
int ff_h264_decode_picture_parameter_set(GetBitContext *gb, AVCodecContext *avctx,
|
||||
H264ParamSets *ps, int bit_length);
|
||||
|
||||
/**
|
||||
* Uninit H264 param sets structure.
|
||||
*/
|
||||
void ff_h264_ps_uninit(H264ParamSets *ps);
|
||||
|
||||
#endif /* AVCODEC_H264_PS_H */
|
||||
154
include/libavcodec/h264_sei.h
Normal file
154
include/libavcodec/h264_sei.h
Normal file
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* 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_H264_SEI_H
|
||||
#define AVCODEC_H264_SEI_H
|
||||
|
||||
#include "get_bits.h"
|
||||
#include "h2645_sei.h"
|
||||
#include "h264_ps.h"
|
||||
#include "sei.h"
|
||||
|
||||
|
||||
/**
|
||||
* pic_struct in picture timing SEI message
|
||||
*/
|
||||
typedef enum {
|
||||
H264_SEI_PIC_STRUCT_FRAME = 0, ///< 0: %frame
|
||||
H264_SEI_PIC_STRUCT_TOP_FIELD = 1, ///< 1: top field
|
||||
H264_SEI_PIC_STRUCT_BOTTOM_FIELD = 2, ///< 2: bottom field
|
||||
H264_SEI_PIC_STRUCT_TOP_BOTTOM = 3, ///< 3: top field, bottom field, in that order
|
||||
H264_SEI_PIC_STRUCT_BOTTOM_TOP = 4, ///< 4: bottom field, top field, in that order
|
||||
H264_SEI_PIC_STRUCT_TOP_BOTTOM_TOP = 5, ///< 5: top field, bottom field, top field repeated, in that order
|
||||
H264_SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM = 6, ///< 6: bottom field, top field, bottom field repeated, in that order
|
||||
H264_SEI_PIC_STRUCT_FRAME_DOUBLING = 7, ///< 7: %frame doubling
|
||||
H264_SEI_PIC_STRUCT_FRAME_TRIPLING = 8 ///< 8: %frame tripling
|
||||
} H264_SEI_PicStructType;
|
||||
|
||||
typedef struct H264SEITimeCode {
|
||||
/* When not continuously receiving full timecodes, we have to reference
|
||||
the previous timecode received */
|
||||
int full;
|
||||
int frame;
|
||||
int seconds;
|
||||
int minutes;
|
||||
int hours;
|
||||
int dropframe;
|
||||
} H264SEITimeCode;
|
||||
|
||||
typedef struct H264SEIPictureTiming {
|
||||
// maximum size of pic_timing according to the spec should be 274 bits
|
||||
uint8_t payload[40];
|
||||
int payload_size_bytes;
|
||||
|
||||
int present;
|
||||
H264_SEI_PicStructType pic_struct;
|
||||
|
||||
/**
|
||||
* Bit set of clock types for fields/frames in picture timing SEI message.
|
||||
* For each found ct_type, appropriate bit is set (e.g., bit 1 for
|
||||
* interlaced).
|
||||
*/
|
||||
int ct_type;
|
||||
|
||||
/**
|
||||
* dpb_output_delay in picture timing SEI message, see H.264 C.2.2
|
||||
*/
|
||||
int dpb_output_delay;
|
||||
|
||||
/**
|
||||
* cpb_removal_delay in picture timing SEI message, see H.264 C.1.2
|
||||
*/
|
||||
int cpb_removal_delay;
|
||||
|
||||
/**
|
||||
* Maximum three timecodes in a pic_timing SEI.
|
||||
*/
|
||||
H264SEITimeCode timecode[3];
|
||||
|
||||
/**
|
||||
* Number of timecode in use
|
||||
*/
|
||||
int timecode_cnt;
|
||||
} H264SEIPictureTiming;
|
||||
|
||||
typedef struct H264SEIRecoveryPoint {
|
||||
/**
|
||||
* recovery_frame_cnt
|
||||
*
|
||||
* Set to -1 if no recovery point SEI message found or to number of frames
|
||||
* before playback synchronizes. Frames having recovery point are key
|
||||
* frames.
|
||||
*/
|
||||
int recovery_frame_cnt;
|
||||
} H264SEIRecoveryPoint;
|
||||
|
||||
typedef struct H264SEIBufferingPeriod {
|
||||
int present; ///< Buffering period SEI flag
|
||||
int initial_cpb_removal_delay[32]; ///< Initial timestamps for CPBs
|
||||
} H264SEIBufferingPeriod;
|
||||
|
||||
typedef struct H264SEIGreenMetaData {
|
||||
uint8_t green_metadata_type;
|
||||
uint8_t period_type;
|
||||
uint16_t num_seconds;
|
||||
uint16_t num_pictures;
|
||||
uint8_t percent_non_zero_macroblocks;
|
||||
uint8_t percent_intra_coded_macroblocks;
|
||||
uint8_t percent_six_tap_filtering;
|
||||
uint8_t percent_alpha_point_deblocking_instance;
|
||||
uint8_t xsd_metric_type;
|
||||
uint16_t xsd_metric_value;
|
||||
} H264SEIGreenMetaData;
|
||||
|
||||
typedef struct H264SEIContext {
|
||||
H2645SEI common;
|
||||
H264SEIPictureTiming picture_timing;
|
||||
H264SEIRecoveryPoint recovery_point;
|
||||
H264SEIBufferingPeriod buffering_period;
|
||||
H264SEIGreenMetaData green_metadata;
|
||||
} H264SEIContext;
|
||||
|
||||
struct H264ParamSets;
|
||||
|
||||
int ff_h264_sei_decode(H264SEIContext *h, GetBitContext *gb,
|
||||
const struct H264ParamSets *ps, void *logctx);
|
||||
|
||||
static inline int ff_h264_sei_ctx_replace(H264SEIContext *dst,
|
||||
const H264SEIContext *src)
|
||||
{
|
||||
return ff_h2645_sei_ctx_replace(&dst->common, &src->common);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset SEI values at the beginning of the frame.
|
||||
*/
|
||||
void ff_h264_sei_uninit(H264SEIContext *h);
|
||||
|
||||
/**
|
||||
* Get stereo_mode string from the h264 frame_packing_arrangement
|
||||
*/
|
||||
const char *ff_h264_sei_stereo_mode(const H2645SEIFramePacking *h);
|
||||
|
||||
/**
|
||||
* Parse the contents of a picture timing message given an active SPS.
|
||||
*/
|
||||
int ff_h264_sei_process_picture_timing(H264SEIPictureTiming *h, const SPS *sps,
|
||||
void *logctx);
|
||||
|
||||
#endif /* AVCODEC_H264_SEI_H */
|
||||
42
include/libavcodec/h264chroma.h
Normal file
42
include/libavcodec/h264chroma.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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_H264CHROMA_H
|
||||
#define AVCODEC_H264CHROMA_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef void (*h264_chroma_mc_func)(uint8_t *dst /*align 8*/, const uint8_t *src /*align 1*/, ptrdiff_t srcStride, int h, int x, int y);
|
||||
|
||||
typedef struct H264ChromaContext {
|
||||
h264_chroma_mc_func put_h264_chroma_pixels_tab[4];
|
||||
h264_chroma_mc_func avg_h264_chroma_pixels_tab[4];
|
||||
} H264ChromaContext;
|
||||
|
||||
void ff_h264chroma_init(H264ChromaContext *c, int bit_depth);
|
||||
|
||||
void ff_h264chroma_init_aarch64(H264ChromaContext *c, int bit_depth);
|
||||
void ff_h264chroma_init_arm(H264ChromaContext *c, int bit_depth);
|
||||
void ff_h264chroma_init_ppc(H264ChromaContext *c, int bit_depth);
|
||||
void ff_h264chroma_init_x86(H264ChromaContext *c, int bit_depth);
|
||||
void ff_h264chroma_init_mips(H264ChromaContext *c, int bit_depth);
|
||||
void ff_h264chroma_init_loongarch(H264ChromaContext *c, int bit_depth);
|
||||
void ff_h264chroma_init_riscv(H264ChromaContext *c, int bit_depth);
|
||||
|
||||
#endif /* AVCODEC_H264CHROMA_H */
|
||||
60
include/libavcodec/h264data.h
Normal file
60
include/libavcodec/h264data.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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_H264DATA_H
|
||||
#define AVCODEC_H264DATA_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libavutil/rational.h"
|
||||
#include "h264.h"
|
||||
|
||||
extern const uint8_t ff_h264_golomb_to_pict_type[5];
|
||||
extern const uint8_t ff_h264_golomb_to_intra4x4_cbp[48];
|
||||
extern const uint8_t ff_h264_golomb_to_inter_cbp[48];
|
||||
|
||||
extern const uint8_t ff_h264_chroma_dc_scan[4];
|
||||
extern const uint8_t ff_h264_chroma422_dc_scan[8];
|
||||
|
||||
typedef struct IMbInfo {
|
||||
uint16_t type;
|
||||
uint8_t pred_mode;
|
||||
uint8_t cbp;
|
||||
} IMbInfo;
|
||||
|
||||
extern const IMbInfo ff_h264_i_mb_type_info[26];
|
||||
|
||||
typedef struct PMbInfo {
|
||||
uint16_t type;
|
||||
uint8_t partition_count;
|
||||
} PMbInfo;
|
||||
|
||||
extern const PMbInfo ff_h264_p_mb_type_info[5];
|
||||
extern const PMbInfo ff_h264_p_sub_mb_type_info[4];
|
||||
extern const PMbInfo ff_h264_b_mb_type_info[23];
|
||||
extern const PMbInfo ff_h264_b_sub_mb_type_info[13];
|
||||
|
||||
extern const uint8_t ff_h264_dequant4_coeff_init[6][3];
|
||||
extern const uint8_t ff_h264_dequant8_coeff_init_scan[16];
|
||||
extern const uint8_t ff_h264_dequant8_coeff_init[6][6];
|
||||
extern const uint8_t ff_h264_quant_rem6[QP_MAX_NUM + 1];
|
||||
extern const uint8_t ff_h264_quant_div6[QP_MAX_NUM + 1];
|
||||
|
||||
extern const uint8_t ff_h264_chroma_qp[7][QP_MAX_NUM + 1];
|
||||
|
||||
#endif /* AVCODEC_H264DATA_H */
|
||||
702
include/libavcodec/h264dec.h
Normal file
702
include/libavcodec/h264dec.h
Normal file
@@ -0,0 +1,702 @@
|
||||
/*
|
||||
* H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder
|
||||
* Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* 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
|
||||
* H.264 / AVC / MPEG-4 part10 codec.
|
||||
* @author Michael Niedermayer <michaelni@gmx.at>
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_H264DEC_H
|
||||
#define AVCODEC_H264DEC_H
|
||||
|
||||
#include "libavutil/buffer.h"
|
||||
#include "libavutil/mem_internal.h"
|
||||
|
||||
#include "cabac.h"
|
||||
#include "error_resilience.h"
|
||||
#include "h264_parse.h"
|
||||
#include "h264_ps.h"
|
||||
#include "h264_sei.h"
|
||||
#include "h2645_parse.h"
|
||||
#include "h264chroma.h"
|
||||
#include "h264dsp.h"
|
||||
#include "h264pred.h"
|
||||
#include "h264qpel.h"
|
||||
#include "h274.h"
|
||||
#include "mpegutils.h"
|
||||
#include "threadframe.h"
|
||||
#include "videodsp.h"
|
||||
|
||||
#define H264_MAX_PICTURE_COUNT 36
|
||||
|
||||
/* Compiling in interlaced support reduces the speed
|
||||
* of progressive decoding by about 2%. */
|
||||
#define ALLOW_INTERLACE
|
||||
|
||||
#define FMO 0
|
||||
|
||||
/**
|
||||
* The maximum number of slices supported by the decoder.
|
||||
* must be a power of 2
|
||||
*/
|
||||
#define MAX_SLICES 32
|
||||
|
||||
#ifdef ALLOW_INTERLACE
|
||||
#define MB_MBAFF(h) (h)->mb_mbaff
|
||||
#define MB_FIELD(sl) (sl)->mb_field_decoding_flag
|
||||
#define FRAME_MBAFF(h) (h)->mb_aff_frame
|
||||
#define FIELD_PICTURE(h) ((h)->picture_structure != PICT_FRAME)
|
||||
#define LEFT_MBS 2
|
||||
#define LTOP 0
|
||||
#define LBOT 1
|
||||
#define LEFT(i) (i)
|
||||
#else
|
||||
#define MB_MBAFF(h) 0
|
||||
#define MB_FIELD(sl) 0
|
||||
#define FRAME_MBAFF(h) 0
|
||||
#define FIELD_PICTURE(h) 0
|
||||
#undef IS_INTERLACED
|
||||
#define IS_INTERLACED(mb_type) 0
|
||||
#define LEFT_MBS 1
|
||||
#define LTOP 0
|
||||
#define LBOT 0
|
||||
#define LEFT(i) 0
|
||||
#endif
|
||||
#define FIELD_OR_MBAFF_PICTURE(h) (FRAME_MBAFF(h) || FIELD_PICTURE(h))
|
||||
|
||||
#ifndef CABAC
|
||||
#define CABAC(h) (h)->ps.pps->cabac
|
||||
#endif
|
||||
|
||||
#define CHROMA(h) ((h)->ps.sps->chroma_format_idc)
|
||||
#define CHROMA422(h) ((h)->ps.sps->chroma_format_idc == 2)
|
||||
#define CHROMA444(h) ((h)->ps.sps->chroma_format_idc == 3)
|
||||
|
||||
#define IS_REF0(a) ((a) & MB_TYPE_REF0)
|
||||
#define IS_8x8DCT(a) ((a) & MB_TYPE_8x8DCT)
|
||||
|
||||
/**
|
||||
* Memory management control operation.
|
||||
*/
|
||||
typedef struct MMCO {
|
||||
MMCOOpcode opcode;
|
||||
int short_pic_num; ///< pic_num without wrapping (pic_num & max_pic_num)
|
||||
int long_arg; ///< index, pic_num, or num long refs depending on opcode
|
||||
} MMCO;
|
||||
|
||||
typedef struct H264Picture {
|
||||
AVFrame *f;
|
||||
ThreadFrame tf;
|
||||
|
||||
AVFrame *f_grain;
|
||||
|
||||
int8_t *qscale_table_base; ///< RefStruct reference
|
||||
int8_t *qscale_table;
|
||||
|
||||
int16_t (*motion_val_base[2])[2]; ///< RefStruct reference
|
||||
int16_t (*motion_val[2])[2];
|
||||
|
||||
uint32_t *mb_type_base; ///< RefStruct reference
|
||||
uint32_t *mb_type;
|
||||
|
||||
/// RefStruct reference for hardware accelerator private data
|
||||
void *hwaccel_picture_private;
|
||||
|
||||
int8_t *ref_index[2]; ///< RefStruct reference
|
||||
|
||||
int field_poc[2]; ///< top/bottom POC
|
||||
int poc; ///< frame POC
|
||||
int frame_num; ///< frame_num (raw frame_num from slice header)
|
||||
int mmco_reset; /**< MMCO_RESET set this 1. Reordering code must
|
||||
not mix pictures before and after MMCO_RESET. */
|
||||
int pic_id; /**< pic_num (short -> no wrap version of pic_num,
|
||||
pic_num & max_pic_num; long -> long_pic_num) */
|
||||
int long_ref; ///< 1->long term reference 0->short term reference
|
||||
int ref_poc[2][2][32]; ///< POCs of the frames/fields used as reference (FIXME need per slice)
|
||||
int ref_count[2][2]; ///< number of entries in ref_poc (FIXME need per slice)
|
||||
int mbaff; ///< 1 -> MBAFF frame 0-> not MBAFF
|
||||
int field_picture; ///< whether or not picture was encoded in separate fields
|
||||
|
||||
/**
|
||||
* H264Picture.reference has this flag set,
|
||||
* when the picture is held for delayed output.
|
||||
*/
|
||||
#define DELAYED_PIC_REF (1 << 2)
|
||||
int reference;
|
||||
int recovered; ///< picture at IDR or recovery point + recovery count
|
||||
int invalid_gap;
|
||||
int sei_recovery_frame_cnt;
|
||||
int needs_fg; ///< whether picture needs film grain synthesis (see `f_grain`)
|
||||
|
||||
const PPS *pps;
|
||||
|
||||
int mb_width, mb_height;
|
||||
int mb_stride;
|
||||
|
||||
/// RefStruct reference; its pointee is shared between decoding threads.
|
||||
atomic_int *decode_error_flags;
|
||||
|
||||
int gray;
|
||||
} H264Picture;
|
||||
|
||||
typedef struct H264Ref {
|
||||
uint8_t *data[3];
|
||||
int linesize[3];
|
||||
|
||||
int reference;
|
||||
int poc;
|
||||
int pic_id;
|
||||
|
||||
const H264Picture *parent;
|
||||
} H264Ref;
|
||||
|
||||
typedef struct H264SliceContext {
|
||||
const struct H264Context *h264;
|
||||
GetBitContext gb;
|
||||
ERContext *er;
|
||||
|
||||
int slice_num;
|
||||
int slice_type;
|
||||
int slice_type_nos; ///< S free slice type (SI/SP are remapped to I/P)
|
||||
int slice_type_fixed;
|
||||
|
||||
int qscale;
|
||||
int chroma_qp[2]; // QPc
|
||||
int qp_thresh; ///< QP threshold to skip loopfilter
|
||||
int last_qscale_diff;
|
||||
|
||||
// deblock
|
||||
int deblocking_filter; ///< disable_deblocking_filter_idc with 1 <-> 0
|
||||
int slice_alpha_c0_offset;
|
||||
int slice_beta_offset;
|
||||
|
||||
H264PredWeightTable pwt;
|
||||
|
||||
int prev_mb_skipped;
|
||||
int next_mb_skipped;
|
||||
|
||||
int chroma_pred_mode;
|
||||
int intra16x16_pred_mode;
|
||||
|
||||
int8_t intra4x4_pred_mode_cache[5 * 8];
|
||||
int8_t(*intra4x4_pred_mode);
|
||||
|
||||
int topleft_mb_xy;
|
||||
int top_mb_xy;
|
||||
int topright_mb_xy;
|
||||
int left_mb_xy[LEFT_MBS];
|
||||
|
||||
int topleft_type;
|
||||
int top_type;
|
||||
int topright_type;
|
||||
int left_type[LEFT_MBS];
|
||||
|
||||
const uint8_t *left_block;
|
||||
int topleft_partition;
|
||||
|
||||
unsigned int topleft_samples_available;
|
||||
unsigned int top_samples_available;
|
||||
unsigned int topright_samples_available;
|
||||
unsigned int left_samples_available;
|
||||
|
||||
ptrdiff_t linesize, uvlinesize;
|
||||
ptrdiff_t mb_linesize; ///< may be equal to s->linesize or s->linesize * 2, for mbaff
|
||||
ptrdiff_t mb_uvlinesize;
|
||||
|
||||
int mb_x, mb_y;
|
||||
int mb_xy;
|
||||
int resync_mb_x;
|
||||
int resync_mb_y;
|
||||
unsigned int first_mb_addr;
|
||||
// index of the first MB of the next slice
|
||||
int next_slice_idx;
|
||||
int mb_skip_run;
|
||||
int is_complex;
|
||||
|
||||
int picture_structure;
|
||||
int mb_field_decoding_flag;
|
||||
int mb_mbaff; ///< mb_aff_frame && mb_field_decoding_flag
|
||||
|
||||
int redundant_pic_count;
|
||||
|
||||
/**
|
||||
* number of neighbors (top and/or left) that used 8x8 dct
|
||||
*/
|
||||
int neighbor_transform_size;
|
||||
|
||||
int direct_spatial_mv_pred;
|
||||
int col_parity;
|
||||
int col_fieldoff;
|
||||
|
||||
int cbp;
|
||||
int top_cbp;
|
||||
int left_cbp;
|
||||
|
||||
int dist_scale_factor[32];
|
||||
int dist_scale_factor_field[2][32];
|
||||
int map_col_to_list0[2][16 + 32];
|
||||
int map_col_to_list0_field[2][2][16 + 32];
|
||||
|
||||
/**
|
||||
* num_ref_idx_l0/1_active_minus1 + 1
|
||||
*/
|
||||
unsigned int ref_count[2]; ///< counts frames or fields, depending on current mb mode
|
||||
unsigned int list_count;
|
||||
H264Ref ref_list[2][48]; /**< 0..15: frame refs, 16..47: mbaff field refs.
|
||||
* Reordered version of default_ref_list
|
||||
* according to picture reordering in slice header */
|
||||
struct {
|
||||
uint8_t op;
|
||||
uint32_t val;
|
||||
} ref_modifications[2][32];
|
||||
int nb_ref_modifications[2];
|
||||
|
||||
unsigned int pps_id;
|
||||
|
||||
const uint8_t *intra_pcm_ptr;
|
||||
|
||||
uint8_t *bipred_scratchpad;
|
||||
uint8_t *edge_emu_buffer;
|
||||
uint8_t (*top_borders[2])[(16 * 3) * 2];
|
||||
int bipred_scratchpad_allocated;
|
||||
int edge_emu_buffer_allocated;
|
||||
int top_borders_allocated[2];
|
||||
|
||||
/**
|
||||
* non zero coeff count cache.
|
||||
* is 64 if not available.
|
||||
*/
|
||||
DECLARE_ALIGNED(8, uint8_t, non_zero_count_cache)[15 * 8];
|
||||
|
||||
/**
|
||||
* Motion vector cache.
|
||||
*/
|
||||
DECLARE_ALIGNED(16, int16_t, mv_cache)[2][5 * 8][2];
|
||||
DECLARE_ALIGNED(8, int8_t, ref_cache)[2][5 * 8];
|
||||
DECLARE_ALIGNED(16, uint8_t, mvd_cache)[2][5 * 8][2];
|
||||
uint8_t direct_cache[5 * 8];
|
||||
|
||||
DECLARE_ALIGNED(8, uint16_t, sub_mb_type)[4];
|
||||
|
||||
///< as a DCT coefficient is int32_t in high depth, we need to reserve twice the space.
|
||||
DECLARE_ALIGNED(16, int16_t, mb)[16 * 48 * 2];
|
||||
DECLARE_ALIGNED(16, int16_t, mb_luma_dc)[3][16 * 2];
|
||||
///< as mb is addressed by scantable[i] and scantable is uint8_t we can either
|
||||
///< check that i is not too large or ensure that there is some unused stuff after mb
|
||||
int16_t mb_padding[256 * 2];
|
||||
|
||||
uint8_t (*mvd_table[2])[2];
|
||||
|
||||
/**
|
||||
* Cabac
|
||||
*/
|
||||
CABACContext cabac;
|
||||
uint8_t cabac_state[1024];
|
||||
int cabac_init_idc;
|
||||
|
||||
MMCO mmco[H264_MAX_MMCO_COUNT];
|
||||
int nb_mmco;
|
||||
int explicit_ref_marking;
|
||||
|
||||
int frame_num;
|
||||
int idr_pic_id;
|
||||
int poc_lsb;
|
||||
int delta_poc_bottom;
|
||||
int delta_poc[2];
|
||||
int curr_pic_num;
|
||||
int max_pic_num;
|
||||
} H264SliceContext;
|
||||
|
||||
/**
|
||||
* H264Context
|
||||
*/
|
||||
typedef struct H264Context {
|
||||
const AVClass *class;
|
||||
AVCodecContext *avctx;
|
||||
VideoDSPContext vdsp;
|
||||
H264DSPContext h264dsp;
|
||||
H264ChromaContext h264chroma;
|
||||
H264QpelContext h264qpel;
|
||||
H274FilmGrainDatabase h274db;
|
||||
|
||||
H264Picture DPB[H264_MAX_PICTURE_COUNT];
|
||||
H264Picture *cur_pic_ptr;
|
||||
H264Picture cur_pic;
|
||||
H264Picture last_pic_for_ec;
|
||||
|
||||
H264SliceContext *slice_ctx;
|
||||
int nb_slice_ctx;
|
||||
int nb_slice_ctx_queued;
|
||||
|
||||
H2645Packet pkt;
|
||||
|
||||
int pixel_shift; ///< 0 for 8-bit H.264, 1 for high-bit-depth H.264
|
||||
|
||||
/* coded dimensions -- 16 * mb w/h */
|
||||
int width, height;
|
||||
int chroma_x_shift, chroma_y_shift;
|
||||
|
||||
int droppable;
|
||||
int coded_picture_number;
|
||||
|
||||
int context_initialized;
|
||||
int flags;
|
||||
int workaround_bugs;
|
||||
int x264_build;
|
||||
/* Set when slice threading is used and at least one slice uses deblocking
|
||||
* mode 1 (i.e. across slice boundaries). Then we disable the loop filter
|
||||
* during normal MB decoding and execute it serially at the end.
|
||||
*/
|
||||
int postpone_filter;
|
||||
|
||||
/*
|
||||
* Set to 1 when the current picture is IDR, 0 otherwise.
|
||||
*/
|
||||
int picture_idr;
|
||||
|
||||
/*
|
||||
* Set to 1 when the current picture contains only I slices, 0 otherwise.
|
||||
*/
|
||||
int picture_intra_only;
|
||||
|
||||
int crop_left;
|
||||
int crop_right;
|
||||
int crop_top;
|
||||
int crop_bottom;
|
||||
|
||||
int8_t(*intra4x4_pred_mode);
|
||||
H264PredContext hpc;
|
||||
|
||||
uint8_t (*non_zero_count)[48];
|
||||
|
||||
#define LIST_NOT_USED -1 // FIXME rename?
|
||||
|
||||
/**
|
||||
* block_offset[ 0..23] for frame macroblocks
|
||||
* block_offset[24..47] for field macroblocks
|
||||
*/
|
||||
int block_offset[2 * (16 * 3)];
|
||||
|
||||
uint32_t *mb2b_xy; // FIXME are these 4 a good idea?
|
||||
uint32_t *mb2br_xy;
|
||||
int b_stride; // FIXME use s->b4_stride
|
||||
|
||||
uint16_t *slice_table; ///< slice_table_base + 2*mb_stride + 1
|
||||
|
||||
// interlacing specific flags
|
||||
int mb_aff_frame;
|
||||
int picture_structure;
|
||||
int first_field;
|
||||
|
||||
uint8_t *list_counts; ///< Array of list_count per MB specifying the slice type
|
||||
|
||||
/* 0x100 -> non null luma_dc, 0x80/0x40 -> non null chroma_dc (cb/cr), 0x?0 -> chroma_cbp(0, 1, 2), 0x0? luma_cbp */
|
||||
uint16_t *cbp_table;
|
||||
|
||||
/* chroma_pred_mode for i4x4 or i16x16, else 0 */
|
||||
uint8_t *chroma_pred_mode_table;
|
||||
uint8_t (*mvd_table[2])[2];
|
||||
uint8_t *direct_table;
|
||||
|
||||
uint8_t scan_padding[16];
|
||||
uint8_t zigzag_scan[16];
|
||||
uint8_t zigzag_scan8x8[64];
|
||||
uint8_t zigzag_scan8x8_cavlc[64];
|
||||
uint8_t field_scan[16];
|
||||
uint8_t field_scan8x8[64];
|
||||
uint8_t field_scan8x8_cavlc[64];
|
||||
uint8_t zigzag_scan_q0[16];
|
||||
uint8_t zigzag_scan8x8_q0[64];
|
||||
uint8_t zigzag_scan8x8_cavlc_q0[64];
|
||||
uint8_t field_scan_q0[16];
|
||||
uint8_t field_scan8x8_q0[64];
|
||||
uint8_t field_scan8x8_cavlc_q0[64];
|
||||
|
||||
int mb_y;
|
||||
int mb_height, mb_width;
|
||||
int mb_stride;
|
||||
int mb_num;
|
||||
|
||||
// =============================================================
|
||||
// Things below are not used in the MB or more inner code
|
||||
|
||||
int nal_ref_idc;
|
||||
int nal_unit_type;
|
||||
|
||||
int has_slice; ///< slice NAL is found in the packet, set by decode_nal_units, its state does not need to be preserved outside h264_decode_frame()
|
||||
|
||||
/**
|
||||
* Used to parse AVC variant of H.264
|
||||
*/
|
||||
int is_avc; ///< this flag is != 0 if codec is avc1
|
||||
int nal_length_size; ///< Number of bytes used for nal length (1, 2 or 4)
|
||||
|
||||
int bit_depth_luma; ///< luma bit depth from sps to detect changes
|
||||
int chroma_format_idc; ///< chroma format from sps to detect changes
|
||||
|
||||
H264ParamSets ps;
|
||||
|
||||
uint16_t *slice_table_base;
|
||||
|
||||
H264POCContext poc;
|
||||
|
||||
H264Ref default_ref[2];
|
||||
H264Picture *short_ref[32];
|
||||
H264Picture *long_ref[32];
|
||||
H264Picture *delayed_pic[H264_MAX_DPB_FRAMES + 2]; // FIXME size?
|
||||
int last_pocs[H264_MAX_DPB_FRAMES];
|
||||
H264Picture *next_output_pic;
|
||||
int next_outputed_poc;
|
||||
int poc_offset; ///< PicOrderCnt_offset from SMPTE RDD-2006
|
||||
|
||||
/**
|
||||
* memory management control operations buffer.
|
||||
*/
|
||||
MMCO mmco[H264_MAX_MMCO_COUNT];
|
||||
int nb_mmco;
|
||||
int mmco_reset;
|
||||
int explicit_ref_marking;
|
||||
|
||||
int long_ref_count; ///< number of actual long term references
|
||||
int short_ref_count; ///< number of actual short term references
|
||||
|
||||
/**
|
||||
* @name Members for slice based multithreading
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* current slice number, used to initialize slice_num of each thread/context
|
||||
*/
|
||||
int current_slice;
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* Complement sei_pic_struct
|
||||
* SEI_PIC_STRUCT_TOP_BOTTOM and SEI_PIC_STRUCT_BOTTOM_TOP indicate interlaced frames.
|
||||
* However, soft telecined frames may have these values.
|
||||
* This is used in an attempt to flag soft telecine progressive.
|
||||
*/
|
||||
int prev_interlaced_frame;
|
||||
|
||||
/**
|
||||
* Are the SEI recovery points looking valid.
|
||||
*/
|
||||
int valid_recovery_point;
|
||||
|
||||
/**
|
||||
* recovery_frame is the frame_num at which the next frame should
|
||||
* be fully constructed.
|
||||
*
|
||||
* Set to -1 when not expecting a recovery point.
|
||||
*/
|
||||
int recovery_frame;
|
||||
|
||||
/**
|
||||
* We have seen an IDR, so all the following frames in coded order are correctly
|
||||
* decodable.
|
||||
*/
|
||||
#define FRAME_RECOVERED_IDR (1 << 0)
|
||||
/**
|
||||
* Sufficient number of frames have been decoded since a SEI recovery point,
|
||||
* so all the following frames in presentation order are correct.
|
||||
*/
|
||||
#define FRAME_RECOVERED_SEI (1 << 1)
|
||||
/**
|
||||
* Recovery point detected by heuristic
|
||||
*/
|
||||
#define FRAME_RECOVERED_HEURISTIC (1 << 2)
|
||||
|
||||
/**
|
||||
* Initial frame has been completely recovered.
|
||||
*
|
||||
* Once this is set, all following decoded as well as displayed frames will be marked as recovered
|
||||
* If a frame is marked as recovered frame_recovered will be set once this frame is output and thus
|
||||
* all subsequently output fraames are also marked as recovered
|
||||
*
|
||||
* In effect, if you want all subsequent DECODED frames marked as recovered, set frame_recovered
|
||||
* If you want all subsequent DISPAYED frames marked as recovered, set the frame->recovered
|
||||
*/
|
||||
int frame_recovered;
|
||||
|
||||
int has_recovery_point;
|
||||
|
||||
int missing_fields;
|
||||
|
||||
/* for frame threading, this is set to 1
|
||||
* after finish_setup() has been called, so we cannot modify
|
||||
* some context properties (which are supposed to stay constant between
|
||||
* slices) anymore */
|
||||
int setup_finished;
|
||||
|
||||
int cur_chroma_format_idc;
|
||||
int cur_bit_depth_luma;
|
||||
int16_t slice_row[MAX_SLICES]; ///< to detect when MAX_SLICES is too low
|
||||
|
||||
/* original AVCodecContext dimensions, used to handle container
|
||||
* cropping */
|
||||
int width_from_caller;
|
||||
int height_from_caller;
|
||||
|
||||
int enable_er;
|
||||
ERContext er;
|
||||
int16_t *dc_val_base;
|
||||
|
||||
H264SEIContext sei;
|
||||
|
||||
struct FFRefStructPool *qscale_table_pool;
|
||||
struct FFRefStructPool *mb_type_pool;
|
||||
struct FFRefStructPool *motion_val_pool;
|
||||
struct FFRefStructPool *ref_index_pool;
|
||||
struct FFRefStructPool *decode_error_flags_pool;
|
||||
int ref2frm[MAX_SLICES][2][64]; ///< reference to frame number lists, used in the loop filter, the first 2 are for -2,-1
|
||||
|
||||
int non_gray; ///< Did we encounter a intra frame after a gray gap frame
|
||||
int noref_gray;
|
||||
int skip_gray;
|
||||
} H264Context;
|
||||
|
||||
extern const uint16_t ff_h264_mb_sizes[4];
|
||||
|
||||
/**
|
||||
* Reconstruct bitstream slice_type.
|
||||
*/
|
||||
int ff_h264_get_slice_type(const H264SliceContext *sl);
|
||||
|
||||
/**
|
||||
* Allocate tables.
|
||||
* needs width/height
|
||||
*/
|
||||
int ff_h264_alloc_tables(H264Context *h);
|
||||
|
||||
int ff_h264_decode_ref_pic_list_reordering(H264SliceContext *sl, void *logctx);
|
||||
int ff_h264_build_ref_list(H264Context *h, H264SliceContext *sl);
|
||||
void ff_h264_remove_all_refs(H264Context *h);
|
||||
|
||||
/**
|
||||
* Execute the reference picture marking (memory management control operations).
|
||||
*/
|
||||
int ff_h264_execute_ref_pic_marking(H264Context *h);
|
||||
|
||||
int ff_h264_decode_ref_pic_marking(H264SliceContext *sl, GetBitContext *gb,
|
||||
const H2645NAL *nal, void *logctx);
|
||||
|
||||
void ff_h264_hl_decode_mb(const H264Context *h, H264SliceContext *sl);
|
||||
void ff_h264_decode_init_vlc(void);
|
||||
|
||||
/**
|
||||
* Decode a macroblock
|
||||
* @return 0 if OK, ER_AC_ERROR / ER_DC_ERROR / ER_MV_ERROR on error
|
||||
*/
|
||||
int ff_h264_decode_mb_cavlc(const H264Context *h, H264SliceContext *sl);
|
||||
|
||||
/**
|
||||
* Decode a CABAC coded macroblock
|
||||
* @return 0 if OK, ER_AC_ERROR / ER_DC_ERROR / ER_MV_ERROR on error
|
||||
*/
|
||||
int ff_h264_decode_mb_cabac(const H264Context *h, H264SliceContext *sl);
|
||||
|
||||
void ff_h264_init_cabac_states(const H264Context *h, H264SliceContext *sl);
|
||||
|
||||
void ff_h264_direct_dist_scale_factor(const H264Context *const h, H264SliceContext *sl);
|
||||
void ff_h264_direct_ref_list_init(const H264Context *const h, H264SliceContext *sl);
|
||||
void ff_h264_pred_direct_motion(const H264Context *const h, H264SliceContext *sl,
|
||||
int *mb_type);
|
||||
|
||||
void ff_h264_filter_mb_fast(const H264Context *h, H264SliceContext *sl, int mb_x, int mb_y,
|
||||
uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr,
|
||||
unsigned int linesize, unsigned int uvlinesize);
|
||||
void ff_h264_filter_mb(const H264Context *h, H264SliceContext *sl, int mb_x, int mb_y,
|
||||
uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr,
|
||||
unsigned int linesize, unsigned int uvlinesize);
|
||||
|
||||
/*
|
||||
* o-o o-o
|
||||
* / / /
|
||||
* o-o o-o
|
||||
* ,---'
|
||||
* o-o o-o
|
||||
* / / /
|
||||
* o-o o-o
|
||||
*/
|
||||
|
||||
/* Scan8 organization:
|
||||
* 0 1 2 3 4 5 6 7
|
||||
* 0 DY y y y y y
|
||||
* 1 y Y Y Y Y
|
||||
* 2 y Y Y Y Y
|
||||
* 3 y Y Y Y Y
|
||||
* 4 y Y Y Y Y
|
||||
* 5 DU u u u u u
|
||||
* 6 u U U U U
|
||||
* 7 u U U U U
|
||||
* 8 u U U U U
|
||||
* 9 u U U U U
|
||||
* 10 DV v v v v v
|
||||
* 11 v V V V V
|
||||
* 12 v V V V V
|
||||
* 13 v V V V V
|
||||
* 14 v V V V V
|
||||
* DY/DU/DV are for luma/chroma DC.
|
||||
*/
|
||||
|
||||
#define LUMA_DC_BLOCK_INDEX 48
|
||||
#define CHROMA_DC_BLOCK_INDEX 49
|
||||
|
||||
/**
|
||||
* Get the chroma qp.
|
||||
*/
|
||||
static av_always_inline int get_chroma_qp(const PPS *pps, int t, int qscale)
|
||||
{
|
||||
return pps->chroma_qp_table[t][qscale];
|
||||
}
|
||||
|
||||
int ff_h264_field_end(H264Context *h, H264SliceContext *sl, int in_setup);
|
||||
|
||||
int ff_h264_ref_picture(H264Picture *dst, const H264Picture *src);
|
||||
int ff_h264_replace_picture(H264Picture *dst, const H264Picture *src);
|
||||
void ff_h264_unref_picture(H264Picture *pic);
|
||||
|
||||
void ff_h264_slice_context_init(H264Context *h, H264SliceContext *sl);
|
||||
|
||||
void ff_h264_draw_horiz_band(const H264Context *h, H264SliceContext *sl, int y, int height);
|
||||
|
||||
/**
|
||||
* Submit a slice for decoding.
|
||||
*
|
||||
* Parse the slice header, starting a new field/frame if necessary. If any
|
||||
* slices are queued for the previous field, they are decoded.
|
||||
*/
|
||||
int ff_h264_queue_decode_slice(H264Context *h, const H2645NAL *nal);
|
||||
int ff_h264_execute_decode_slices(H264Context *h);
|
||||
int ff_h264_update_thread_context(AVCodecContext *dst,
|
||||
const AVCodecContext *src);
|
||||
int ff_h264_update_thread_context_for_user(AVCodecContext *dst,
|
||||
const AVCodecContext *src);
|
||||
|
||||
void ff_h264_flush_change(H264Context *h);
|
||||
|
||||
void ff_h264_free_tables(H264Context *h);
|
||||
|
||||
void ff_h264_set_erpic(ERPicture *dst, const H264Picture *src);
|
||||
|
||||
#endif /* AVCODEC_H264DEC_H */
|
||||
135
include/libavcodec/h264dsp.h
Normal file
135
include/libavcodec/h264dsp.h
Normal file
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2010 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* 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
|
||||
* H.264 DSP functions.
|
||||
* @author Michael Niedermayer <michaelni@gmx.at>
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_H264DSP_H
|
||||
#define AVCODEC_H264DSP_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
typedef void (*h264_weight_func)(uint8_t *block, ptrdiff_t stride, int height,
|
||||
int log2_denom, int weight, int offset);
|
||||
typedef void (*h264_biweight_func)(uint8_t *dst, uint8_t *src,
|
||||
ptrdiff_t stride, int height, int log2_denom,
|
||||
int weightd, int weights, int offset);
|
||||
|
||||
/**
|
||||
* Context for storing H.264 DSP functions
|
||||
*/
|
||||
typedef struct H264DSPContext {
|
||||
/* weighted MC */
|
||||
h264_weight_func weight_h264_pixels_tab[4];
|
||||
h264_biweight_func biweight_h264_pixels_tab[4];
|
||||
|
||||
/* loop filter */
|
||||
void (*h264_v_loop_filter_luma)(uint8_t *pix /*align 16*/, ptrdiff_t stride,
|
||||
int alpha, int beta, int8_t *tc0);
|
||||
void (*h264_h_loop_filter_luma)(uint8_t *pix /*align 4 */, ptrdiff_t stride,
|
||||
int alpha, int beta, int8_t *tc0);
|
||||
void (*h264_h_loop_filter_luma_mbaff)(uint8_t *pix /*align 16*/, ptrdiff_t stride,
|
||||
int alpha, int beta, int8_t *tc0);
|
||||
/* v/h_loop_filter_luma_intra: align 16 */
|
||||
void (*h264_v_loop_filter_luma_intra)(uint8_t *pix, ptrdiff_t stride,
|
||||
int alpha, int beta);
|
||||
void (*h264_h_loop_filter_luma_intra)(uint8_t *pix, ptrdiff_t stride,
|
||||
int alpha, int beta);
|
||||
void (*h264_h_loop_filter_luma_mbaff_intra)(uint8_t *pix /*align 16*/,
|
||||
ptrdiff_t stride, int alpha, int beta);
|
||||
void (*h264_v_loop_filter_chroma)(uint8_t *pix /*align 8*/, ptrdiff_t stride,
|
||||
int alpha, int beta, int8_t *tc0);
|
||||
void (*h264_h_loop_filter_chroma)(uint8_t *pix /*align 4*/, ptrdiff_t stride,
|
||||
int alpha, int beta, int8_t *tc0);
|
||||
void (*h264_h_loop_filter_chroma_mbaff)(uint8_t *pix /*align 8*/,
|
||||
ptrdiff_t stride, int alpha, int beta,
|
||||
int8_t *tc0);
|
||||
void (*h264_v_loop_filter_chroma_intra)(uint8_t *pix /*align 8*/,
|
||||
ptrdiff_t stride, int alpha, int beta);
|
||||
void (*h264_h_loop_filter_chroma_intra)(uint8_t *pix /*align 8*/,
|
||||
ptrdiff_t stride, int alpha, int beta);
|
||||
void (*h264_h_loop_filter_chroma_mbaff_intra)(uint8_t *pix /*align 8*/,
|
||||
ptrdiff_t stride, int alpha, int beta);
|
||||
// h264_loop_filter_strength: simd only. the C version is inlined in h264_loopfilter.c
|
||||
void (*h264_loop_filter_strength)(int16_t bS[2][4][4], uint8_t nnz[40],
|
||||
int8_t ref[2][40], int16_t mv[2][40][2],
|
||||
int bidir, int edges, int step,
|
||||
int mask_mv0, int mask_mv1, int field);
|
||||
|
||||
/* IDCT */
|
||||
void (*h264_idct_add)(uint8_t *dst /*align 4*/,
|
||||
int16_t *block /*align 16*/, int stride);
|
||||
void (*h264_idct8_add)(uint8_t *dst /*align 8*/,
|
||||
int16_t *block /*align 16*/, int stride);
|
||||
void (*h264_idct_dc_add)(uint8_t *dst /*align 4*/,
|
||||
int16_t *block /*align 16*/, int stride);
|
||||
void (*h264_idct8_dc_add)(uint8_t *dst /*align 8*/,
|
||||
int16_t *block /*align 16*/, int stride);
|
||||
|
||||
void (*h264_idct_add16)(uint8_t *dst /*align 16*/, const int *blockoffset,
|
||||
int16_t *block /*align 16*/, int stride,
|
||||
const uint8_t nnzc[5 * 8]);
|
||||
void (*h264_idct8_add4)(uint8_t *dst /*align 16*/, const int *blockoffset,
|
||||
int16_t *block /*align 16*/, int stride,
|
||||
const uint8_t nnzc[5 * 8]);
|
||||
void (*h264_idct_add8)(uint8_t **dst /*align 16*/, const int *blockoffset,
|
||||
int16_t *block /*align 16*/, int stride,
|
||||
const uint8_t nnzc[15 * 8]);
|
||||
void (*h264_idct_add16intra)(uint8_t *dst /*align 16*/, const int *blockoffset,
|
||||
int16_t *block /*align 16*/,
|
||||
int stride, const uint8_t nnzc[5 * 8]);
|
||||
void (*h264_luma_dc_dequant_idct)(int16_t *output,
|
||||
int16_t *input /*align 16*/, int qmul);
|
||||
void (*h264_chroma_dc_dequant_idct)(int16_t *block, int qmul);
|
||||
|
||||
/* bypass-transform */
|
||||
void (*h264_add_pixels8_clear)(uint8_t *dst, int16_t *block, int stride);
|
||||
void (*h264_add_pixels4_clear)(uint8_t *dst, int16_t *block, int stride);
|
||||
|
||||
/**
|
||||
* Search buf from the start for up to size bytes. Return the index
|
||||
* of a zero byte, or >= size if not found. Ideally, use lookahead
|
||||
* to filter out any zero bytes that are known to not be followed by
|
||||
* one or more further zero bytes and a one byte. Better still, filter
|
||||
* out any bytes that form the trailing_zero_8bits syntax element too.
|
||||
*/
|
||||
int (*startcode_find_candidate)(const uint8_t *buf, int size);
|
||||
} H264DSPContext;
|
||||
|
||||
void ff_h264dsp_init(H264DSPContext *c, const int bit_depth,
|
||||
const int chroma_format_idc);
|
||||
void ff_h264dsp_init_aarch64(H264DSPContext *c, const int bit_depth,
|
||||
const int chroma_format_idc);
|
||||
void ff_h264dsp_init_arm(H264DSPContext *c, const int bit_depth,
|
||||
const int chroma_format_idc);
|
||||
void ff_h264dsp_init_ppc(H264DSPContext *c, const int bit_depth,
|
||||
const int chroma_format_idc);
|
||||
void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth,
|
||||
const int chroma_format_idc);
|
||||
void ff_h264dsp_init_mips(H264DSPContext *c, const int bit_depth,
|
||||
const int chroma_format_idc);
|
||||
void ff_h264dsp_init_loongarch(H264DSPContext *c, const int bit_depth,
|
||||
const int chroma_format_idc);
|
||||
|
||||
#endif /* AVCODEC_H264DSP_H */
|
||||
44
include/libavcodec/h264idct.h
Normal file
44
include/libavcodec/h264idct.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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_H264IDCT_H
|
||||
#define AVCODEC_H264IDCT_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define H264_IDCT(depth) \
|
||||
void ff_h264_idct8_add_ ## depth ## _c(uint8_t *dst, int16_t *block, int stride);\
|
||||
void ff_h264_idct_add_ ## depth ## _c(uint8_t *dst, int16_t *block, int stride);\
|
||||
void ff_h264_idct8_dc_add_ ## depth ## _c(uint8_t *dst, int16_t *block, int stride);\
|
||||
void ff_h264_idct_dc_add_ ## depth ## _c(uint8_t *dst, int16_t *block, int stride);\
|
||||
void ff_h264_idct_add16_ ## depth ## _c(uint8_t *dst, const int *blockoffset, int16_t *block, int stride, const uint8_t nnzc[5 * 8]);\
|
||||
void ff_h264_idct_add16intra_ ## depth ## _c(uint8_t *dst, const int *blockoffset, int16_t *block, int stride, const uint8_t nnzc[5 * 8]);\
|
||||
void ff_h264_idct8_add4_ ## depth ## _c(uint8_t *dst, const int *blockoffset, int16_t *block, int stride, const uint8_t nnzc[5 * 8]);\
|
||||
void ff_h264_idct_add8_422_ ## depth ## _c(uint8_t **dest, const int *blockoffset, int16_t *block, int stride, const uint8_t nnzc[15 * 8]);\
|
||||
void ff_h264_idct_add8_ ## depth ## _c(uint8_t **dest, const int *blockoffset, int16_t *block, int stride, const uint8_t nnzc[15 * 8]);\
|
||||
void ff_h264_luma_dc_dequant_idct_ ## depth ## _c(int16_t *output, int16_t *input, int qmul);\
|
||||
void ff_h264_chroma422_dc_dequant_idct_ ## depth ## _c(int16_t *block, int qmul);\
|
||||
void ff_h264_chroma_dc_dequant_idct_ ## depth ## _c(int16_t *block, int qmul);
|
||||
|
||||
H264_IDCT( 8)
|
||||
H264_IDCT( 9)
|
||||
H264_IDCT(10)
|
||||
H264_IDCT(12)
|
||||
H264_IDCT(14)
|
||||
|
||||
#endif /* AVCODEC_H264IDCT_H */
|
||||
130
include/libavcodec/h264pred.h
Normal file
130
include/libavcodec/h264pred.h
Normal file
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder
|
||||
* Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* 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
|
||||
* H.264 / AVC / MPEG-4 prediction functions.
|
||||
* @author Michael Niedermayer <michaelni@gmx.at>
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_H264PRED_H
|
||||
#define AVCODEC_H264PRED_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* Prediction types
|
||||
*/
|
||||
//@{
|
||||
#define VERT_PRED 0
|
||||
#define HOR_PRED 1
|
||||
#define DC_PRED 2
|
||||
#define DIAG_DOWN_LEFT_PRED 3
|
||||
#define DIAG_DOWN_RIGHT_PRED 4
|
||||
#define VERT_RIGHT_PRED 5
|
||||
#define HOR_DOWN_PRED 6
|
||||
#define VERT_LEFT_PRED 7
|
||||
#define HOR_UP_PRED 8
|
||||
|
||||
// DC edge (not for VP8)
|
||||
#define LEFT_DC_PRED 9
|
||||
#define TOP_DC_PRED 10
|
||||
#define DC_128_PRED 11
|
||||
|
||||
// RV40 specific
|
||||
#define DIAG_DOWN_LEFT_PRED_RV40_NODOWN 12
|
||||
#define HOR_UP_PRED_RV40_NODOWN 13
|
||||
#define VERT_LEFT_PRED_RV40_NODOWN 14
|
||||
|
||||
// VP8 specific
|
||||
#define TM_VP8_PRED 9 ///< "True Motion", used instead of plane
|
||||
#define VERT_VP8_PRED 10 ///< for VP8, #VERT_PRED is the average of
|
||||
///< (left col+cur col x2+right col) / 4;
|
||||
///< this is the "unaveraged" one
|
||||
#define HOR_VP8_PRED 14 ///< unaveraged version of #HOR_PRED, see
|
||||
///< #VERT_VP8_PRED for details
|
||||
#define DC_127_PRED 12
|
||||
#define DC_129_PRED 13
|
||||
|
||||
#define DC_PRED8x8 0
|
||||
#define HOR_PRED8x8 1
|
||||
#define VERT_PRED8x8 2
|
||||
#define PLANE_PRED8x8 3
|
||||
|
||||
// DC edge
|
||||
#define LEFT_DC_PRED8x8 4
|
||||
#define TOP_DC_PRED8x8 5
|
||||
#define DC_128_PRED8x8 6
|
||||
|
||||
// H.264/SVQ3 (8x8) specific
|
||||
#define ALZHEIMER_DC_L0T_PRED8x8 7
|
||||
#define ALZHEIMER_DC_0LT_PRED8x8 8
|
||||
#define ALZHEIMER_DC_L00_PRED8x8 9
|
||||
#define ALZHEIMER_DC_0L0_PRED8x8 10
|
||||
|
||||
// VP8 specific
|
||||
#define DC_127_PRED8x8 7
|
||||
#define DC_129_PRED8x8 8
|
||||
//@}
|
||||
|
||||
#define PART_NOT_AVAILABLE -2
|
||||
|
||||
/**
|
||||
* Context for storing H.264 prediction functions
|
||||
*/
|
||||
typedef struct H264PredContext {
|
||||
void(*pred4x4[9 + 3 + 3])(uint8_t *src, const uint8_t *topright,
|
||||
ptrdiff_t stride);
|
||||
void(*pred8x8l[9 + 3])(uint8_t *src, int topleft, int topright,
|
||||
ptrdiff_t stride);
|
||||
void(*pred8x8[4 + 3 + 4])(uint8_t *src, ptrdiff_t stride);
|
||||
void(*pred16x16[4 + 3 + 2])(uint8_t *src, ptrdiff_t stride);
|
||||
|
||||
void(*pred4x4_add[2])(uint8_t *pix /*align 4*/,
|
||||
int16_t *block /*align 16*/, ptrdiff_t stride);
|
||||
void(*pred8x8l_add[2])(uint8_t *pix /*align 8*/,
|
||||
int16_t *block /*align 16*/, ptrdiff_t stride);
|
||||
void(*pred8x8l_filter_add[2])(uint8_t *pix /*align 8*/,
|
||||
int16_t *block /*align 16*/, int topleft, int topright, ptrdiff_t stride);
|
||||
void(*pred8x8_add[3])(uint8_t *pix /*align 8*/,
|
||||
const int *block_offset,
|
||||
int16_t *block /*align 16*/, ptrdiff_t stride);
|
||||
void(*pred16x16_add[3])(uint8_t *pix /*align 16*/,
|
||||
const int *block_offset,
|
||||
int16_t *block /*align 16*/, ptrdiff_t stride);
|
||||
} H264PredContext;
|
||||
|
||||
void ff_h264_pred_init(H264PredContext *h, int codec_id,
|
||||
const int bit_depth, const int chroma_format_idc);
|
||||
void ff_h264_pred_init_aarch64(H264PredContext *h, int codec_id,
|
||||
const int bit_depth,
|
||||
const int chroma_format_idc);
|
||||
void ff_h264_pred_init_arm(H264PredContext *h, int codec_id,
|
||||
const int bit_depth, const int chroma_format_idc);
|
||||
void ff_h264_pred_init_x86(H264PredContext *h, int codec_id,
|
||||
const int bit_depth, const int chroma_format_idc);
|
||||
void ff_h264_pred_init_mips(H264PredContext *h, int codec_id,
|
||||
const int bit_depth, const int chroma_format_idc);
|
||||
void ff_h264_pred_init_loongarch(H264PredContext *h, int codec_id,
|
||||
const int bit_depth, const int chroma_format_idc);
|
||||
|
||||
#endif /* AVCODEC_H264PRED_H */
|
||||
41
include/libavcodec/h264qpel.h
Normal file
41
include/libavcodec/h264qpel.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder
|
||||
* Copyright (c) 2003-2010 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* 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_H264QPEL_H
|
||||
#define AVCODEC_H264QPEL_H
|
||||
|
||||
#include "qpeldsp.h"
|
||||
|
||||
typedef struct H264QpelContext {
|
||||
qpel_mc_func put_h264_qpel_pixels_tab[4][16];
|
||||
qpel_mc_func avg_h264_qpel_pixels_tab[4][16];
|
||||
} H264QpelContext;
|
||||
|
||||
void ff_h264qpel_init(H264QpelContext *c, int bit_depth);
|
||||
|
||||
void ff_h264qpel_init_aarch64(H264QpelContext *c, int bit_depth);
|
||||
void ff_h264qpel_init_arm(H264QpelContext *c, int bit_depth);
|
||||
void ff_h264qpel_init_ppc(H264QpelContext *c, int bit_depth);
|
||||
void ff_h264qpel_init_x86(H264QpelContext *c, int bit_depth);
|
||||
void ff_h264qpel_init_mips(H264QpelContext *c, int bit_depth);
|
||||
void ff_h264qpel_init_loongarch(H264QpelContext *c, int bit_depth);
|
||||
|
||||
#endif /* AVCODEC_H264QPEL_H */
|
||||
@@ -43,4 +43,25 @@ int av_jni_set_java_vm(void *vm, void *log_ctx);
|
||||
*/
|
||||
void *av_jni_get_java_vm(void *log_ctx);
|
||||
|
||||
/*
|
||||
* Set the Android application context which will be used to retrieve the Android
|
||||
* content resolver to handle content uris.
|
||||
*
|
||||
* This function is only available on Android.
|
||||
*
|
||||
* @param app_ctx global JNI reference to the Android application context
|
||||
* @return 0 on success, < 0 otherwise
|
||||
*/
|
||||
int av_jni_set_android_app_ctx(void *app_ctx, void *log_ctx);
|
||||
|
||||
/*
|
||||
* Get the Android application context that has been set with
|
||||
* av_jni_set_android_app_ctx.
|
||||
*
|
||||
* This function is only available on Android.
|
||||
*
|
||||
* @return a pointer the the Android application context
|
||||
*/
|
||||
void *av_jni_get_android_app_ctx(void);
|
||||
|
||||
#endif /* AVCODEC_JNI_H */
|
||||
|
||||
97
include/libavcodec/me_cmp.h
Normal file
97
include/libavcodec/me_cmp.h
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* 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_ME_CMP_H
|
||||
#define AVCODEC_ME_CMP_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libavutil/attributes_internal.h"
|
||||
|
||||
#include "avcodec.h"
|
||||
|
||||
extern const uint32_t attribute_visibility_hidden ff_square_tab[512];
|
||||
|
||||
|
||||
/* minimum alignment rules ;)
|
||||
* If you notice errors in the align stuff, need more alignment for some ASM code
|
||||
* for some CPU or need to use a function with less aligned data then send a mail
|
||||
* to the ffmpeg-devel mailing list, ...
|
||||
*
|
||||
* !warning These alignments might not match reality, (missing attribute((align))
|
||||
* stuff somewhere possible).
|
||||
* I (Michael) did not check them, these are just the alignments which I think
|
||||
* could be reached easily ...
|
||||
*
|
||||
* !future video codecs might need functions with less strict alignment
|
||||
*/
|
||||
|
||||
struct MpegEncContext;
|
||||
/* Motion estimation:
|
||||
* h is limited to { width / 2, width, 2 * width },
|
||||
* but never larger than 16 and never smaller than 2.
|
||||
* Although currently h < 4 is not used as functions with
|
||||
* width < 8 are neither used nor implemented. */
|
||||
typedef int (*me_cmp_func)(struct MpegEncContext *c,
|
||||
const uint8_t *blk1 /* align width (8 or 16) */,
|
||||
const uint8_t *blk2 /* align 1 */, ptrdiff_t stride,
|
||||
int h);
|
||||
|
||||
typedef struct MECmpContext {
|
||||
int (*sum_abs_dctelem)(const int16_t *block /* align 16 */);
|
||||
|
||||
me_cmp_func sad[6]; /* identical to pix_absAxA except additional void * */
|
||||
me_cmp_func sse[6];
|
||||
me_cmp_func hadamard8_diff[6];
|
||||
me_cmp_func dct_sad[6];
|
||||
me_cmp_func quant_psnr[6];
|
||||
me_cmp_func bit[6];
|
||||
me_cmp_func rd[6];
|
||||
me_cmp_func vsad[6];
|
||||
me_cmp_func vsse[6];
|
||||
me_cmp_func nsse[6];
|
||||
me_cmp_func w53[6];
|
||||
me_cmp_func w97[6];
|
||||
me_cmp_func dct_max[6];
|
||||
me_cmp_func dct264_sad[6];
|
||||
|
||||
me_cmp_func me_pre_cmp[6];
|
||||
me_cmp_func me_cmp[6];
|
||||
me_cmp_func me_sub_cmp[6];
|
||||
me_cmp_func mb_cmp[6];
|
||||
me_cmp_func ildct_cmp[6]; // only width 16 used
|
||||
me_cmp_func frame_skip_cmp[6]; // only width 8 used
|
||||
|
||||
me_cmp_func pix_abs[2][4];
|
||||
me_cmp_func median_sad[6];
|
||||
} MECmpContext;
|
||||
|
||||
void ff_me_cmp_init(MECmpContext *c, AVCodecContext *avctx);
|
||||
void ff_me_cmp_init_aarch64(MECmpContext *c, AVCodecContext *avctx);
|
||||
void ff_me_cmp_init_alpha(MECmpContext *c, AVCodecContext *avctx);
|
||||
void ff_me_cmp_init_arm(MECmpContext *c, AVCodecContext *avctx);
|
||||
void ff_me_cmp_init_ppc(MECmpContext *c, AVCodecContext *avctx);
|
||||
void ff_me_cmp_init_riscv(MECmpContext *c, AVCodecContext *avctx);
|
||||
void ff_me_cmp_init_x86(MECmpContext *c, AVCodecContext *avctx);
|
||||
void ff_me_cmp_init_mips(MECmpContext *c, AVCodecContext *avctx);
|
||||
|
||||
int ff_set_cmp(MECmpContext *c, me_cmp_func *cmp, int type);
|
||||
|
||||
void ff_dsputil_init_dwt(MECmpContext *c);
|
||||
|
||||
#endif /* AVCODEC_ME_CMP_H */
|
||||
@@ -88,13 +88,15 @@ int av_mediacodec_release_buffer(AVMediaCodecBuffer *buffer, int render);
|
||||
/**
|
||||
* Release a MediaCodec buffer and render it at the given time to the surface
|
||||
* that is associated with the decoder. The timestamp must be within one second
|
||||
* of the current java/lang/System#nanoTime() (which is implemented using
|
||||
* CLOCK_MONOTONIC on Android). See the Android MediaCodec documentation
|
||||
* of android/media/MediaCodec#releaseOutputBuffer(int,long) for more details.
|
||||
* of the current `java/lang/System#nanoTime()` (which is implemented using
|
||||
* `CLOCK_MONOTONIC` on Android). See the Android MediaCodec documentation
|
||||
* of [`android/media/MediaCodec#releaseOutputBuffer(int,long)`][0] for more details.
|
||||
*
|
||||
* @param buffer the buffer to render
|
||||
* @param time timestamp in nanoseconds of when to render the buffer
|
||||
* @return 0 on success, < 0 otherwise
|
||||
*
|
||||
* [0]: https://developer.android.com/reference/android/media/MediaCodec#releaseOutputBuffer(int,%20long)
|
||||
*/
|
||||
int av_mediacodec_render_buffer_at_time(AVMediaCodecBuffer *buffer, int64_t time);
|
||||
|
||||
|
||||
@@ -33,9 +33,9 @@
|
||||
#include "libavcodec/version_major.h"
|
||||
|
||||
/**
|
||||
* @defgroup lavc_packet AVPacket
|
||||
* @defgroup lavc_packet_side_data AVPacketSideData
|
||||
*
|
||||
* Types and functions for working with AVPacket.
|
||||
* Types and functions for working with AVPacketSideData.
|
||||
* @{
|
||||
*/
|
||||
enum AVPacketSideDataType {
|
||||
@@ -59,10 +59,6 @@ enum AVPacketSideDataType {
|
||||
* An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows:
|
||||
* @code
|
||||
* u32le param_flags
|
||||
* if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT)
|
||||
* s32le channel_count
|
||||
* if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT)
|
||||
* u64le channel_layout
|
||||
* if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE)
|
||||
* s32le sample_rate
|
||||
* if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS)
|
||||
@@ -161,7 +157,7 @@ enum AVPacketSideDataType {
|
||||
* the packet may contain "dual mono" audio specific to Japanese DTV
|
||||
* and if it is true, recommends only the selected channel to be used.
|
||||
* @code
|
||||
* u8 selected channels (0=mail/left, 1=sub/right, 2=both)
|
||||
* u8 selected channels (0=main/left, 1=sub/right, 2=both)
|
||||
* @endcode
|
||||
*/
|
||||
AV_PKT_DATA_JP_DUALMONO,
|
||||
@@ -299,6 +295,56 @@ enum AVPacketSideDataType {
|
||||
*/
|
||||
AV_PKT_DATA_DYNAMIC_HDR10_PLUS,
|
||||
|
||||
/**
|
||||
* IAMF Mix Gain Parameter Data associated with the audio frame. This metadata
|
||||
* is in the form of the AVIAMFParamDefinition struct and contains information
|
||||
* defined in sections 3.6.1 and 3.8.1 of the Immersive Audio Model and
|
||||
* Formats standard.
|
||||
*/
|
||||
AV_PKT_DATA_IAMF_MIX_GAIN_PARAM,
|
||||
|
||||
/**
|
||||
* IAMF Demixing Info Parameter Data associated with the audio frame. This
|
||||
* metadata is in the form of the AVIAMFParamDefinition struct and contains
|
||||
* information defined in sections 3.6.1 and 3.8.2 of the Immersive Audio Model
|
||||
* and Formats standard.
|
||||
*/
|
||||
AV_PKT_DATA_IAMF_DEMIXING_INFO_PARAM,
|
||||
|
||||
/**
|
||||
* IAMF Recon Gain Info Parameter Data associated with the audio frame. This
|
||||
* metadata is in the form of the AVIAMFParamDefinition struct and contains
|
||||
* information defined in sections 3.6.1 and 3.8.3 of the Immersive Audio Model
|
||||
* and Formats standard.
|
||||
*/
|
||||
AV_PKT_DATA_IAMF_RECON_GAIN_INFO_PARAM,
|
||||
|
||||
/**
|
||||
* Ambient viewing environment metadata, as defined by H.274. This metadata
|
||||
* should be associated with a video stream and contains data in the form
|
||||
* of the AVAmbientViewingEnvironment struct.
|
||||
*/
|
||||
AV_PKT_DATA_AMBIENT_VIEWING_ENVIRONMENT,
|
||||
|
||||
/**
|
||||
* The number of pixels to discard from the top/bottom/left/right border of the
|
||||
* decoded frame to obtain the sub-rectangle intended for presentation.
|
||||
*
|
||||
* @code
|
||||
* u32le crop_top
|
||||
* u32le crop_bottom
|
||||
* u32le crop_left
|
||||
* u32le crop_right
|
||||
* @endcode
|
||||
*/
|
||||
AV_PKT_DATA_FRAME_CROPPING,
|
||||
|
||||
/**
|
||||
* Raw LCEVC payload data, as a uint8_t array, with NAL emulation
|
||||
* bytes intact.
|
||||
*/
|
||||
AV_PKT_DATA_LCEVC,
|
||||
|
||||
/**
|
||||
* The number of side data types.
|
||||
* This is not part of the public API/ABI in the sense that it may
|
||||
@@ -310,14 +356,133 @@ enum AVPacketSideDataType {
|
||||
AV_PKT_DATA_NB
|
||||
};
|
||||
|
||||
#if FF_API_QUALITY_FACTOR
|
||||
#define AV_PKT_DATA_QUALITY_FACTOR AV_PKT_DATA_QUALITY_STATS //DEPRECATED
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This structure stores auxiliary information for decoding, presenting, or
|
||||
* otherwise processing the coded stream. It is typically exported by demuxers
|
||||
* and encoders and can be fed to decoders and muxers either in a per packet
|
||||
* basis, or as global side data (applying to the entire coded stream).
|
||||
*
|
||||
* Global side data is handled as follows:
|
||||
* - During demuxing, it may be exported through
|
||||
* @ref AVStream.codecpar.side_data "AVStream's codec parameters", which can
|
||||
* then be passed as input to decoders through the
|
||||
* @ref AVCodecContext.coded_side_data "decoder context's side data", for
|
||||
* initialization.
|
||||
* - For muxing, it can be fed through @ref AVStream.codecpar.side_data
|
||||
* "AVStream's codec parameters", typically the output of encoders through
|
||||
* the @ref AVCodecContext.coded_side_data "encoder context's side data", for
|
||||
* initialization.
|
||||
*
|
||||
* Packet specific side data is handled as follows:
|
||||
* - During demuxing, it may be exported through @ref AVPacket.side_data
|
||||
* "AVPacket's side data", which can then be passed as input to decoders.
|
||||
* - For muxing, it can be fed through @ref AVPacket.side_data "AVPacket's
|
||||
* side data", typically the output of encoders.
|
||||
*
|
||||
* Different modules may accept or export different types of side data
|
||||
* depending on media type and codec. Refer to @ref AVPacketSideDataType for a
|
||||
* list of defined types and where they may be found or used.
|
||||
*/
|
||||
typedef struct AVPacketSideData {
|
||||
uint8_t *data;
|
||||
size_t size;
|
||||
enum AVPacketSideDataType type;
|
||||
} AVPacketSideData;
|
||||
|
||||
/**
|
||||
* Allocate a new packet side data.
|
||||
*
|
||||
* @param sd pointer to an array of side data to which the side data should
|
||||
* be added. *sd may be NULL, in which case the array will be
|
||||
* initialized.
|
||||
* @param nb_sd pointer to an integer containing the number of entries in
|
||||
* the array. The integer value will be increased by 1 on success.
|
||||
* @param type side data type
|
||||
* @param size desired side data size
|
||||
* @param flags currently unused. Must be zero
|
||||
*
|
||||
* @return pointer to freshly allocated side data on success, or NULL otherwise.
|
||||
*/
|
||||
AVPacketSideData *av_packet_side_data_new(AVPacketSideData **psd, int *pnb_sd,
|
||||
enum AVPacketSideDataType type,
|
||||
size_t size, int flags);
|
||||
|
||||
/**
|
||||
* Wrap existing data as packet side data.
|
||||
*
|
||||
* @param sd pointer to an array of side data to which the side data should
|
||||
* be added. *sd may be NULL, in which case the array will be
|
||||
* initialized
|
||||
* @param nb_sd pointer to an integer containing the number of entries in
|
||||
* the array. The integer value will be increased by 1 on success.
|
||||
* @param type side data type
|
||||
* @param data a data array. It must be allocated with the av_malloc() family
|
||||
* of functions. The ownership of the data is transferred to the
|
||||
* side data array on success
|
||||
* @param size size of the data array
|
||||
* @param flags currently unused. Must be zero
|
||||
*
|
||||
* @return pointer to freshly allocated side data on success, or NULL otherwise
|
||||
* On failure, the side data array is unchanged and the data remains
|
||||
* owned by the caller.
|
||||
*/
|
||||
AVPacketSideData *av_packet_side_data_add(AVPacketSideData **sd, int *nb_sd,
|
||||
enum AVPacketSideDataType type,
|
||||
void *data, size_t size, int flags);
|
||||
|
||||
/**
|
||||
* Get side information from a side data array.
|
||||
*
|
||||
* @param sd the array from which the side data should be fetched
|
||||
* @param nb_sd value containing the number of entries in the array.
|
||||
* @param type desired side information type
|
||||
*
|
||||
* @return pointer to side data if present or NULL otherwise
|
||||
*/
|
||||
const AVPacketSideData *av_packet_side_data_get(const AVPacketSideData *sd,
|
||||
int nb_sd,
|
||||
enum AVPacketSideDataType type);
|
||||
|
||||
/**
|
||||
* Remove side data of the given type from a side data array.
|
||||
*
|
||||
* @param sd the array from which the side data should be removed
|
||||
* @param nb_sd pointer to an integer containing the number of entries in
|
||||
* the array. Will be reduced by the amount of entries removed
|
||||
* upon return
|
||||
* @param type side information type
|
||||
*/
|
||||
void av_packet_side_data_remove(AVPacketSideData *sd, int *nb_sd,
|
||||
enum AVPacketSideDataType type);
|
||||
|
||||
/**
|
||||
* Convenience function to free all the side data stored in an array, and
|
||||
* the array itself.
|
||||
*
|
||||
* @param sd pointer to array of side data to free. Will be set to NULL
|
||||
* upon return.
|
||||
* @param nb_sd pointer to an integer containing the number of entries in
|
||||
* the array. Will be set to 0 upon return.
|
||||
*/
|
||||
void av_packet_side_data_free(AVPacketSideData **sd, int *nb_sd);
|
||||
|
||||
const char *av_packet_side_data_name(enum AVPacketSideDataType type);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup lavc_packet AVPacket
|
||||
*
|
||||
* Types and functions for working with AVPacket.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* This structure stores compressed data. It is typically exported by demuxers
|
||||
* and then passed as input to decoders, or received as output from encoders and
|
||||
@@ -448,13 +613,6 @@ typedef struct AVPacketList {
|
||||
#define AV_PKT_FLAG_DISPOSABLE 0x0010
|
||||
|
||||
enum AVSideDataParamChangeFlags {
|
||||
#if FF_API_OLD_CHANNEL_LAYOUT
|
||||
/**
|
||||
* @deprecated those are not used by any decoder
|
||||
*/
|
||||
AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT = 0x0001,
|
||||
AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT = 0x0002,
|
||||
#endif
|
||||
AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE = 0x0004,
|
||||
AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS = 0x0008,
|
||||
};
|
||||
@@ -603,8 +761,6 @@ int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
|
||||
uint8_t* av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type,
|
||||
size_t *size);
|
||||
|
||||
const char *av_packet_side_data_name(enum AVPacketSideDataType type);
|
||||
|
||||
/**
|
||||
* Pack a dictionary for use in side_data.
|
||||
*
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#ifndef AVCODEC_QSV_H
|
||||
#define AVCODEC_QSV_H
|
||||
|
||||
#include <mfx/mfxvideo.h>
|
||||
#include <mfxvideo.h>
|
||||
|
||||
#include "libavutil/buffer.h"
|
||||
|
||||
@@ -61,6 +61,8 @@ typedef struct AVQSVContext {
|
||||
* required by the encoder and the user-provided value nb_opaque_surfaces.
|
||||
* The array of the opaque surfaces will be exported to the caller through
|
||||
* the opaque_surfaces field.
|
||||
*
|
||||
* The caller must set this field to zero for oneVPL (MFX_VERSION >= 2.0)
|
||||
*/
|
||||
int opaque_alloc;
|
||||
|
||||
|
||||
@@ -66,16 +66,14 @@ typedef int (*AVVDPAU_Render2)(struct AVCodecContext *, struct AVFrame *,
|
||||
/**
|
||||
* This structure is used to share data between the libavcodec library and
|
||||
* the client video application.
|
||||
* The user shall allocate the structure via the av_alloc_vdpau_hwaccel
|
||||
* function and make it available as
|
||||
* AVCodecContext.hwaccel_context. Members can be set by the user once
|
||||
* This structure will be allocated and stored in AVCodecContext.hwaccel_context
|
||||
* by av_vdpau_bind_context(). Members can be set by the user once
|
||||
* during initialization or through each AVCodecContext.get_buffer()
|
||||
* function call. In any case, they must be valid prior to calling
|
||||
* decoding functions.
|
||||
*
|
||||
* The size of this structure is not a part of the public ABI and must not
|
||||
* be used outside of libavcodec. Use av_vdpau_alloc_context() to allocate an
|
||||
* AVVDPAUContext.
|
||||
* be used outside of libavcodec.
|
||||
*/
|
||||
typedef struct AVVDPAUContext {
|
||||
/**
|
||||
@@ -95,15 +93,27 @@ typedef struct AVVDPAUContext {
|
||||
AVVDPAU_Render2 render2;
|
||||
} AVVDPAUContext;
|
||||
|
||||
#if FF_API_VDPAU_ALLOC_GET_SET
|
||||
/**
|
||||
* @brief allocation function for AVVDPAUContext
|
||||
*
|
||||
* Allows extending the struct without breaking API/ABI
|
||||
* @deprecated use av_vdpau_bind_context() instead
|
||||
*/
|
||||
attribute_deprecated
|
||||
AVVDPAUContext *av_alloc_vdpaucontext(void);
|
||||
|
||||
/**
|
||||
* @deprecated render2 is public and can be accessed directly
|
||||
*/
|
||||
attribute_deprecated
|
||||
AVVDPAU_Render2 av_vdpau_hwaccel_get_render2(const AVVDPAUContext *);
|
||||
/**
|
||||
* @deprecated render2 is public and can be accessed directly
|
||||
*/
|
||||
attribute_deprecated
|
||||
void av_vdpau_hwaccel_set_render2(AVVDPAUContext *, AVVDPAU_Render2);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Associate a VDPAU device with a codec context for hardware acceleration.
|
||||
@@ -145,13 +155,17 @@ int av_vdpau_bind_context(AVCodecContext *avctx, VdpDevice device,
|
||||
int av_vdpau_get_surface_parameters(AVCodecContext *avctx, VdpChromaType *type,
|
||||
uint32_t *width, uint32_t *height);
|
||||
|
||||
#if FF_API_VDPAU_ALLOC_GET_SET
|
||||
/**
|
||||
* Allocate an AVVDPAUContext.
|
||||
*
|
||||
* @return Newly-allocated AVVDPAUContext or NULL on failure.
|
||||
* @deprecated use av_vdpau_bind_context() instead
|
||||
*/
|
||||
attribute_deprecated
|
||||
AVVDPAUContext *av_vdpau_alloc_context(void);
|
||||
#endif
|
||||
|
||||
/* @}*/
|
||||
/** @} */
|
||||
|
||||
#endif /* AVCODEC_VDPAU_H */
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
|
||||
#include "version_major.h"
|
||||
|
||||
#define LIBAVCODEC_VERSION_MINOR 37
|
||||
#define LIBAVCODEC_VERSION_MICRO 100
|
||||
#define LIBAVCODEC_VERSION_MINOR 19
|
||||
#define LIBAVCODEC_VERSION_MICRO 101
|
||||
|
||||
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
|
||||
LIBAVCODEC_VERSION_MINOR, \
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
* Libavcodec version macros.
|
||||
*/
|
||||
|
||||
#define LIBAVCODEC_VERSION_MAJOR 59
|
||||
#define LIBAVCODEC_VERSION_MAJOR 61
|
||||
|
||||
/**
|
||||
* FF_API_* defines may be placed below to indicate public API that will be
|
||||
@@ -37,18 +37,16 @@
|
||||
* 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)
|
||||
#define FF_API_INIT_PACKET (LIBAVCODEC_VERSION_MAJOR < 62)
|
||||
#define FF_API_SUBFRAMES (LIBAVCODEC_VERSION_MAJOR < 62)
|
||||
#define FF_API_TICKS_PER_FRAME (LIBAVCODEC_VERSION_MAJOR < 62)
|
||||
#define FF_API_DROPCHANGED (LIBAVCODEC_VERSION_MAJOR < 62)
|
||||
|
||||
#define FF_API_AVFFT (LIBAVCODEC_VERSION_MAJOR < 62)
|
||||
#define FF_API_FF_PROFILE_LEVEL (LIBAVCODEC_VERSION_MAJOR < 62)
|
||||
#define FF_API_AVCODEC_CLOSE (LIBAVCODEC_VERSION_MAJOR < 62)
|
||||
#define FF_API_BUFFER_MIN_SIZE (LIBAVCODEC_VERSION_MAJOR < 62)
|
||||
#define FF_API_VDPAU_ALLOC_GET_SET (LIBAVCODEC_VERSION_MAJOR < 62)
|
||||
#define FF_API_QUALITY_FACTOR (LIBAVCODEC_VERSION_MAJOR < 62)
|
||||
|
||||
#endif /* AVCODEC_VERSION_MAJOR_H */
|
||||
|
||||
@@ -29,6 +29,15 @@
|
||||
* Public libavcodec Videotoolbox header.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup lavc_codec_hwaccel_videotoolbox VideoToolbox Decoder
|
||||
* @ingroup lavc_codec_hwaccel
|
||||
*
|
||||
* Hardware accelerated decoding using VideoToolbox on Apple Platforms
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define Picture QuickdrawPicture
|
||||
@@ -37,6 +46,8 @@
|
||||
|
||||
#include "libavcodec/avcodec.h"
|
||||
|
||||
#include "libavutil/attributes.h"
|
||||
|
||||
/**
|
||||
* This struct holds all the information that needs to be passed
|
||||
* between the caller and libavcodec for initializing Videotoolbox decoding.
|
||||
@@ -46,16 +57,9 @@
|
||||
typedef struct AVVideotoolboxContext {
|
||||
/**
|
||||
* Videotoolbox decompression session object.
|
||||
* Created and freed the caller.
|
||||
*/
|
||||
VTDecompressionSessionRef session;
|
||||
|
||||
/**
|
||||
* The output callback that must be passed to the session.
|
||||
* Set by av_videottoolbox_default_init()
|
||||
*/
|
||||
VTDecompressionOutputCallback output_callback;
|
||||
|
||||
/**
|
||||
* CVPixelBuffer Format Type that Videotoolbox will use for decoded frames.
|
||||
* set by the caller. If this is set to 0, then no specific format is
|
||||
@@ -65,61 +69,15 @@ typedef struct AVVideotoolboxContext {
|
||||
|
||||
/**
|
||||
* CoreMedia Format Description that Videotoolbox will use to create the decompression session.
|
||||
* Set by the caller.
|
||||
*/
|
||||
CMVideoFormatDescriptionRef cm_fmt_desc;
|
||||
|
||||
/**
|
||||
* CoreMedia codec type that Videotoolbox will use to create the decompression session.
|
||||
* Set by the caller.
|
||||
*/
|
||||
int cm_codec_type;
|
||||
} AVVideotoolboxContext;
|
||||
|
||||
/**
|
||||
* Allocate and initialize a Videotoolbox context.
|
||||
*
|
||||
* This function should be called from the get_format() callback when the caller
|
||||
* selects the AV_PIX_FMT_VIDETOOLBOX format. The caller must then create
|
||||
* the decoder object (using the output callback provided by libavcodec) that
|
||||
* will be used for Videotoolbox-accelerated decoding.
|
||||
*
|
||||
* When decoding with Videotoolbox is finished, the caller must destroy the decoder
|
||||
* object and free the Videotoolbox context using av_free().
|
||||
*
|
||||
* @return the newly allocated context or NULL on failure
|
||||
*/
|
||||
AVVideotoolboxContext *av_videotoolbox_alloc_context(void);
|
||||
|
||||
/**
|
||||
* This is a convenience function that creates and sets up the Videotoolbox context using
|
||||
* an internal implementation.
|
||||
*
|
||||
* @param avctx the corresponding codec context
|
||||
*
|
||||
* @return >= 0 on success, a negative AVERROR code on failure
|
||||
*/
|
||||
int av_videotoolbox_default_init(AVCodecContext *avctx);
|
||||
|
||||
/**
|
||||
* This is a convenience function that creates and sets up the Videotoolbox context using
|
||||
* an internal implementation.
|
||||
*
|
||||
* @param avctx the corresponding codec context
|
||||
* @param vtctx the Videotoolbox context to use
|
||||
*
|
||||
* @return >= 0 on success, a negative AVERROR code on failure
|
||||
*/
|
||||
int av_videotoolbox_default_init2(AVCodecContext *avctx, AVVideotoolboxContext *vtctx);
|
||||
|
||||
/**
|
||||
* This function must be called to free the Videotoolbox context initialized with
|
||||
* av_videotoolbox_default_init().
|
||||
*
|
||||
* @param avctx the corresponding codec context
|
||||
*/
|
||||
void av_videotoolbox_default_free(AVCodecContext *avctx);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
@@ -1,171 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2003 Ivan Kalvachev
|
||||
*
|
||||
* 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_XVMC_H
|
||||
#define AVCODEC_XVMC_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavc_codec_hwaccel_xvmc
|
||||
* 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 "libavutil/attributes.h"
|
||||
#include "avcodec.h"
|
||||
|
||||
/**
|
||||
* @defgroup lavc_codec_hwaccel_xvmc XvMC
|
||||
* @ingroup lavc_codec_hwaccel
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define AV_XVMC_ID 0x1DC711C0 /**< special value to ensure that regular pixel routines haven't corrupted the struct
|
||||
the number is 1337 speak for the letters IDCT MCo (motion compensation) */
|
||||
|
||||
struct attribute_deprecated xvmc_pix_fmt {
|
||||
/** The field contains the special constant value AV_XVMC_ID.
|
||||
It is used as a test that the application correctly uses the API,
|
||||
and that there is no corruption caused by pixel routines.
|
||||
- application - set during initialization
|
||||
- libavcodec - unchanged
|
||||
*/
|
||||
int xvmc_id;
|
||||
|
||||
/** Pointer to the block array allocated by XvMCCreateBlocks().
|
||||
The array has to be freed by XvMCDestroyBlocks().
|
||||
Each group of 64 values represents one data block of differential
|
||||
pixel information (in MoCo mode) or coefficients for IDCT.
|
||||
- application - set the pointer during initialization
|
||||
- libavcodec - fills coefficients/pixel data into the array
|
||||
*/
|
||||
short* data_blocks;
|
||||
|
||||
/** Pointer to the macroblock description array allocated by
|
||||
XvMCCreateMacroBlocks() and freed by XvMCDestroyMacroBlocks().
|
||||
- application - set the pointer during initialization
|
||||
- libavcodec - fills description data into the array
|
||||
*/
|
||||
XvMCMacroBlock* mv_blocks;
|
||||
|
||||
/** Number of macroblock descriptions that can be stored in the mv_blocks
|
||||
array.
|
||||
- application - set during initialization
|
||||
- libavcodec - unchanged
|
||||
*/
|
||||
int allocated_mv_blocks;
|
||||
|
||||
/** Number of blocks that can be stored at once in the data_blocks array.
|
||||
- application - set during initialization
|
||||
- libavcodec - unchanged
|
||||
*/
|
||||
int allocated_data_blocks;
|
||||
|
||||
/** Indicate that the hardware would interpret data_blocks as IDCT
|
||||
coefficients and perform IDCT on them.
|
||||
- application - set during initialization
|
||||
- libavcodec - unchanged
|
||||
*/
|
||||
int idct;
|
||||
|
||||
/** In MoCo mode it indicates that intra macroblocks are assumed to be in
|
||||
unsigned format; same as the XVMC_INTRA_UNSIGNED flag.
|
||||
- application - set during initialization
|
||||
- libavcodec - unchanged
|
||||
*/
|
||||
int unsigned_intra;
|
||||
|
||||
/** Pointer to the surface allocated by XvMCCreateSurface().
|
||||
It has to be freed by XvMCDestroySurface() on application exit.
|
||||
It identifies the frame and its state on the video hardware.
|
||||
- application - set during initialization
|
||||
- libavcodec - unchanged
|
||||
*/
|
||||
XvMCSurface* p_surface;
|
||||
|
||||
/** Set by the decoder before calling ff_draw_horiz_band(),
|
||||
needed by the XvMCRenderSurface function. */
|
||||
//@{
|
||||
/** Pointer to the surface used as past reference
|
||||
- application - unchanged
|
||||
- libavcodec - set
|
||||
*/
|
||||
XvMCSurface* p_past_surface;
|
||||
|
||||
/** Pointer to the surface used as future reference
|
||||
- application - unchanged
|
||||
- libavcodec - set
|
||||
*/
|
||||
XvMCSurface* p_future_surface;
|
||||
|
||||
/** top/bottom field or frame
|
||||
- application - unchanged
|
||||
- libavcodec - set
|
||||
*/
|
||||
unsigned int picture_structure;
|
||||
|
||||
/** XVMC_SECOND_FIELD - 1st or 2nd field in the sequence
|
||||
- application - unchanged
|
||||
- libavcodec - set
|
||||
*/
|
||||
unsigned int flags;
|
||||
//}@
|
||||
|
||||
/** Number of macroblock descriptions in the mv_blocks array
|
||||
that have already been passed to the hardware.
|
||||
- application - zeroes it on get_buffer().
|
||||
A successful ff_draw_horiz_band() may increment it
|
||||
with filled_mb_block_num or zero both.
|
||||
- libavcodec - unchanged
|
||||
*/
|
||||
int start_mv_blocks_num;
|
||||
|
||||
/** Number of new macroblock descriptions in the mv_blocks array (after
|
||||
start_mv_blocks_num) that are filled by libavcodec and have to be
|
||||
passed to the hardware.
|
||||
- application - zeroes it on get_buffer() or after successful
|
||||
ff_draw_horiz_band().
|
||||
- libavcodec - increment with one of each stored MB
|
||||
*/
|
||||
int filled_mv_blocks_num;
|
||||
|
||||
/** Number of the next free data block; one data block consists of
|
||||
64 short values in the data_blocks array.
|
||||
All blocks before this one have already been claimed by placing their
|
||||
position into the corresponding block description structure field,
|
||||
that are part of the mv_blocks array.
|
||||
- application - zeroes it on get_buffer().
|
||||
A successful ff_draw_horiz_band() may zero it together
|
||||
with start_mb_blocks_num.
|
||||
- libavcodec - each decoded macroblock increases it by the number
|
||||
of coded blocks it contains.
|
||||
*/
|
||||
int next_free_data_block_num;
|
||||
};
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVCODEC_XVMC_H */
|
||||
@@ -327,136 +327,6 @@ int avdevice_dev_to_app_control_message(struct AVFormatContext *s,
|
||||
enum AVDevToAppMessageType type,
|
||||
void *data, size_t data_size);
|
||||
|
||||
#if FF_API_DEVICE_CAPABILITIES
|
||||
/**
|
||||
* Following API allows user to probe device capabilities (supported codecs,
|
||||
* pixel formats, sample formats, resolutions, channel counts, etc).
|
||||
* It is build on top op AVOption API.
|
||||
* Queried capabilities make it possible to set up converters of video or audio
|
||||
* parameters that fit to the device.
|
||||
*
|
||||
* List of capabilities that can be queried:
|
||||
* - Capabilities valid for both audio and video devices:
|
||||
* - codec: supported audio/video codecs.
|
||||
* type: AV_OPT_TYPE_INT (AVCodecID value)
|
||||
* - Capabilities valid for audio devices:
|
||||
* - sample_format: supported sample formats.
|
||||
* type: AV_OPT_TYPE_INT (AVSampleFormat value)
|
||||
* - sample_rate: supported sample rates.
|
||||
* type: AV_OPT_TYPE_INT
|
||||
* - channels: supported number of channels.
|
||||
* type: AV_OPT_TYPE_INT
|
||||
* - channel_layout: supported channel layouts.
|
||||
* type: AV_OPT_TYPE_INT64
|
||||
* - Capabilities valid for video devices:
|
||||
* - pixel_format: supported pixel formats.
|
||||
* type: AV_OPT_TYPE_INT (AVPixelFormat value)
|
||||
* - window_size: supported window sizes (describes size of the window size presented to the user).
|
||||
* type: AV_OPT_TYPE_IMAGE_SIZE
|
||||
* - frame_size: supported frame sizes (describes size of provided video frames).
|
||||
* type: AV_OPT_TYPE_IMAGE_SIZE
|
||||
* - fps: supported fps values
|
||||
* type: AV_OPT_TYPE_RATIONAL
|
||||
*
|
||||
* Value of the capability may be set by user using av_opt_set() function
|
||||
* and AVDeviceCapabilitiesQuery object. Following queries will
|
||||
* limit results to the values matching already set capabilities.
|
||||
* For example, setting a codec may impact number of formats or fps values
|
||||
* returned during next query. Setting invalid value may limit results to zero.
|
||||
*
|
||||
* Example of the usage basing on opengl output device:
|
||||
*
|
||||
* @code
|
||||
* AVFormatContext *oc = NULL;
|
||||
* AVDeviceCapabilitiesQuery *caps = NULL;
|
||||
* AVOptionRanges *ranges;
|
||||
* int ret;
|
||||
*
|
||||
* if ((ret = avformat_alloc_output_context2(&oc, NULL, "opengl", NULL)) < 0)
|
||||
* goto fail;
|
||||
* if (avdevice_capabilities_create(&caps, oc, NULL) < 0)
|
||||
* goto fail;
|
||||
*
|
||||
* //query codecs
|
||||
* if (av_opt_query_ranges(&ranges, caps, "codec", AV_OPT_MULTI_COMPONENT_RANGE)) < 0)
|
||||
* goto fail;
|
||||
* //pick codec here and set it
|
||||
* av_opt_set(caps, "codec", AV_CODEC_ID_RAWVIDEO, 0);
|
||||
*
|
||||
* //query format
|
||||
* if (av_opt_query_ranges(&ranges, caps, "pixel_format", AV_OPT_MULTI_COMPONENT_RANGE)) < 0)
|
||||
* goto fail;
|
||||
* //pick format here and set it
|
||||
* av_opt_set(caps, "pixel_format", AV_PIX_FMT_YUV420P, 0);
|
||||
*
|
||||
* //query and set more capabilities
|
||||
*
|
||||
* fail:
|
||||
* //clean up code
|
||||
* avdevice_capabilities_free(&query, oc);
|
||||
* avformat_free_context(oc);
|
||||
* @endcode
|
||||
*/
|
||||
|
||||
/**
|
||||
* Structure describes device capabilities.
|
||||
*
|
||||
* It is used by devices in conjunction with av_device_capabilities AVOption table
|
||||
* to implement capabilities probing API based on AVOption API. Should not be used directly.
|
||||
*/
|
||||
typedef struct AVDeviceCapabilitiesQuery {
|
||||
const AVClass *av_class;
|
||||
AVFormatContext *device_context;
|
||||
enum AVCodecID codec;
|
||||
enum AVSampleFormat sample_format;
|
||||
enum AVPixelFormat pixel_format;
|
||||
int sample_rate;
|
||||
int channels;
|
||||
int64_t channel_layout;
|
||||
int window_width;
|
||||
int window_height;
|
||||
int frame_width;
|
||||
int frame_height;
|
||||
AVRational fps;
|
||||
} AVDeviceCapabilitiesQuery;
|
||||
|
||||
/**
|
||||
* AVOption table used by devices to implement device capabilities API. Should not be used by a user.
|
||||
*/
|
||||
attribute_deprecated
|
||||
extern const AVOption av_device_capabilities[];
|
||||
|
||||
/**
|
||||
* Initialize capabilities probing API based on AVOption API.
|
||||
*
|
||||
* avdevice_capabilities_free() must be called when query capabilities API is
|
||||
* not used anymore.
|
||||
*
|
||||
* @param[out] caps Device capabilities data. Pointer to a NULL pointer must be passed.
|
||||
* @param s Context of the device.
|
||||
* @param device_options An AVDictionary filled with device-private options.
|
||||
* On return this parameter will be destroyed and replaced with a dict
|
||||
* containing options that were not found. May be NULL.
|
||||
* The same options must be passed later to avformat_write_header() for output
|
||||
* devices or avformat_open_input() for input devices, or at any other place
|
||||
* that affects device-private options.
|
||||
*
|
||||
* @return >= 0 on success, negative otherwise.
|
||||
*/
|
||||
attribute_deprecated
|
||||
int avdevice_capabilities_create(AVDeviceCapabilitiesQuery **caps, AVFormatContext *s,
|
||||
AVDictionary **device_options);
|
||||
|
||||
/**
|
||||
* Free resources created by avdevice_capabilities_create()
|
||||
*
|
||||
* @param caps Device capabilities data to be freed.
|
||||
* @param s Context of the device.
|
||||
*/
|
||||
attribute_deprecated
|
||||
void avdevice_capabilities_free(AVDeviceCapabilitiesQuery **caps, AVFormatContext *s);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Structure describes basic parameters of the device.
|
||||
*/
|
||||
@@ -494,7 +364,7 @@ int avdevice_list_devices(struct AVFormatContext *s, AVDeviceInfoList **device_l
|
||||
/**
|
||||
* Convenient function to free result of avdevice_list_devices().
|
||||
*
|
||||
* @param devices device list to be freed.
|
||||
* @param device_list device list to be freed.
|
||||
*/
|
||||
void avdevice_free_list_devices(AVDeviceInfoList **device_list);
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
#include "version_major.h"
|
||||
|
||||
#define LIBAVDEVICE_VERSION_MINOR 7
|
||||
#define LIBAVDEVICE_VERSION_MINOR 3
|
||||
#define LIBAVDEVICE_VERSION_MICRO 100
|
||||
|
||||
#define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \
|
||||
|
||||
@@ -25,13 +25,19 @@
|
||||
* Libavdevice version macros
|
||||
*/
|
||||
|
||||
#define LIBAVDEVICE_VERSION_MAJOR 59
|
||||
#define LIBAVDEVICE_VERSION_MAJOR 61
|
||||
|
||||
/**
|
||||
* FF_API_* defines may be placed below to indicate public API that will be
|
||||
* dropped at a future version bump. The defines themselves are not part of
|
||||
* the public API and may change, break or disappear at any time.
|
||||
*/
|
||||
#define FF_API_DEVICE_CAPABILITIES (LIBAVDEVICE_VERSION_MAJOR < 60)
|
||||
|
||||
// reminder to remove the bktr device on next major bump
|
||||
#define FF_API_BKTR_DEVICE (LIBAVDEVICE_VERSION_MAJOR < 62)
|
||||
// reminder to remove the opengl device on next major bump
|
||||
#define FF_API_OPENGL_DEVICE (LIBAVDEVICE_VERSION_MAJOR < 62)
|
||||
// reminder to remove the sdl2 device on next major bump
|
||||
#define FF_API_SDL2_DEVICE (LIBAVDEVICE_VERSION_MAJOR < 62)
|
||||
|
||||
#endif /* AVDEVICE_VERSION_MAJOR_H */
|
||||
|
||||
@@ -76,16 +76,6 @@ typedef struct AVFilterPad AVFilterPad;
|
||||
typedef struct AVFilterFormats AVFilterFormats;
|
||||
typedef struct AVFilterChannelLayouts AVFilterChannelLayouts;
|
||||
|
||||
#if FF_API_PAD_COUNT
|
||||
/**
|
||||
* Get the number of elements in an AVFilter's inputs or outputs array.
|
||||
*
|
||||
* @deprecated Use avfilter_filter_pad_count() instead.
|
||||
*/
|
||||
attribute_deprecated
|
||||
int avfilter_pad_count(const AVFilterPad *pads);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Get the name of an AVFilterPad.
|
||||
*
|
||||
@@ -108,6 +98,41 @@ const char *avfilter_pad_get_name(const AVFilterPad *pads, int pad_idx);
|
||||
*/
|
||||
enum AVMediaType avfilter_pad_get_type(const AVFilterPad *pads, int pad_idx);
|
||||
|
||||
/**
|
||||
* Lists of formats / etc. supported by an end of a link.
|
||||
*
|
||||
* This structure is directly part of AVFilterLink, in two copies:
|
||||
* one for the source filter, one for the destination filter.
|
||||
|
||||
* These lists are used for negotiating the format to actually be used,
|
||||
* which will be loaded into the format and channel_layout members of
|
||||
* AVFilterLink, when chosen.
|
||||
*/
|
||||
typedef struct AVFilterFormatsConfig {
|
||||
|
||||
/**
|
||||
* List of supported formats (pixel or sample).
|
||||
*/
|
||||
AVFilterFormats *formats;
|
||||
|
||||
/**
|
||||
* Lists of supported sample rates, only for audio.
|
||||
*/
|
||||
AVFilterFormats *samplerates;
|
||||
|
||||
/**
|
||||
* Lists of supported channel layouts, only for audio.
|
||||
*/
|
||||
AVFilterChannelLayouts *channel_layouts;
|
||||
|
||||
/**
|
||||
* Lists of supported YUV color metadata, only for YUV video.
|
||||
*/
|
||||
AVFilterFormats *color_spaces; ///< AVColorSpace
|
||||
AVFilterFormats *color_ranges; ///< AVColorRange
|
||||
|
||||
} AVFilterFormatsConfig;
|
||||
|
||||
/**
|
||||
* The number of the filter inputs is not determined just by AVFilter.inputs.
|
||||
* The filter might add additional inputs during initialization depending on the
|
||||
@@ -141,6 +166,11 @@ enum AVMediaType avfilter_pad_get_type(const AVFilterPad *pads, int pad_idx);
|
||||
* received by the filter on one of its inputs.
|
||||
*/
|
||||
#define AVFILTER_FLAG_METADATA_ONLY (1 << 3)
|
||||
|
||||
/**
|
||||
* The filter can create hardware frames using AVFilterContext.hw_device_ctx.
|
||||
*/
|
||||
#define AVFILTER_FLAG_HWDEVICE (1 << 4)
|
||||
/**
|
||||
* Some filters support a generic "enable" expression option that can be used
|
||||
* to enable or disable a filter in the timeline. Filters supporting this
|
||||
@@ -276,19 +306,6 @@ typedef struct AVFilter {
|
||||
*/
|
||||
int (*init)(AVFilterContext *ctx);
|
||||
|
||||
/**
|
||||
* Should be set instead of @ref AVFilter.init "init" by the filters that
|
||||
* want to pass a dictionary of AVOptions to nested contexts that are
|
||||
* allocated during init.
|
||||
*
|
||||
* On return, the options dict should be freed and replaced with one that
|
||||
* contains all the options which could not be processed by this filter (or
|
||||
* with NULL if all the options were processed).
|
||||
*
|
||||
* Otherwise the semantics is the same as for @ref AVFilter.init "init".
|
||||
*/
|
||||
int (*init_dict)(AVFilterContext *ctx, AVDictionary **options);
|
||||
|
||||
/**
|
||||
* Filter uninitialization function.
|
||||
*
|
||||
@@ -313,13 +330,28 @@ typedef struct AVFilter {
|
||||
* and outputs are fixed), shortly before the format negotiation. This
|
||||
* callback may be called more than once.
|
||||
*
|
||||
* This callback must set AVFilterLink.outcfg.formats on every input link
|
||||
* and AVFilterLink.incfg.formats on every output link to a list of
|
||||
* pixel/sample formats that the filter supports on that link. For audio
|
||||
* links, this filter must also set @ref AVFilterLink.incfg.samplerates
|
||||
* "in_samplerates" / @ref AVFilterLink.outcfg.samplerates "out_samplerates"
|
||||
* and @ref AVFilterLink.incfg.channel_layouts "in_channel_layouts" /
|
||||
* @ref AVFilterLink.outcfg.channel_layouts "out_channel_layouts" analogously.
|
||||
* This callback must set ::AVFilterLink's
|
||||
* @ref AVFilterFormatsConfig.formats "outcfg.formats"
|
||||
* on every input link and
|
||||
* @ref AVFilterFormatsConfig.formats "incfg.formats"
|
||||
* on every output link to a list of pixel/sample formats that the filter
|
||||
* supports on that link.
|
||||
* For video links, this filter may also set
|
||||
* @ref AVFilterFormatsConfig.color_spaces "incfg.color_spaces"
|
||||
* /
|
||||
* @ref AVFilterFormatsConfig.color_spaces "outcfg.color_spaces"
|
||||
* and @ref AVFilterFormatsConfig.color_ranges "incfg.color_ranges"
|
||||
* /
|
||||
* @ref AVFilterFormatsConfig.color_ranges "outcfg.color_ranges"
|
||||
* analogously.
|
||||
* For audio links, this filter must also set
|
||||
* @ref AVFilterFormatsConfig.samplerates "incfg.samplerates"
|
||||
* /
|
||||
* @ref AVFilterFormatsConfig.samplerates "outcfg.samplerates"
|
||||
* and @ref AVFilterFormatsConfig.channel_layouts "incfg.channel_layouts"
|
||||
* /
|
||||
* @ref AVFilterFormatsConfig.channel_layouts "outcfg.channel_layouts"
|
||||
* analogously.
|
||||
*
|
||||
* This callback must never be NULL if the union is in this state.
|
||||
*
|
||||
@@ -327,12 +359,31 @@ typedef struct AVFilter {
|
||||
* AVERROR code otherwise
|
||||
*/
|
||||
int (*query_func)(AVFilterContext *);
|
||||
|
||||
/**
|
||||
* Same as query_func(), except this function writes the results into
|
||||
* provided arrays.
|
||||
*
|
||||
* @param cfg_in array of input format configurations with as many
|
||||
* members as the filters has inputs (NULL when there are
|
||||
* no inputs);
|
||||
* @param cfg_out array of output format configurations with as many
|
||||
* members as the filters has outputs (NULL when there
|
||||
* are no outputs);
|
||||
*/
|
||||
int (*query_func2)(const AVFilterContext *,
|
||||
struct AVFilterFormatsConfig **cfg_in,
|
||||
struct AVFilterFormatsConfig **cfg_out);
|
||||
/**
|
||||
* A pointer to an array of admissible pixel formats delimited
|
||||
* by AV_PIX_FMT_NONE. The generic code will use this list
|
||||
* to indicate that this filter supports each of these pixel formats,
|
||||
* provided that all inputs and outputs use the same pixel format.
|
||||
*
|
||||
* In addition to that the generic code will mark all inputs
|
||||
* and all outputs as supporting all color spaces and ranges, as
|
||||
* long as all inputs and outputs use the same color space/range.
|
||||
*
|
||||
* This list must never be NULL if the union is in this state.
|
||||
* The type of all inputs and outputs of filters using this must
|
||||
* be AVMEDIA_TYPE_VIDEO.
|
||||
@@ -402,8 +453,6 @@ unsigned avfilter_filter_pad_count(const AVFilter *filter, int is_output);
|
||||
*/
|
||||
#define AVFILTER_THREAD_SLICE (1 << 0)
|
||||
|
||||
typedef struct AVFilterInternal AVFilterInternal;
|
||||
|
||||
/** An instance of a filter */
|
||||
struct AVFilterContext {
|
||||
const AVClass *av_class; ///< needed for av_log() and filters common options
|
||||
@@ -443,9 +492,11 @@ struct AVFilterContext {
|
||||
int thread_type;
|
||||
|
||||
/**
|
||||
* An opaque struct for libavfilter internal use.
|
||||
* Max number of threads allowed in this filter instance.
|
||||
* If <= 0, its value is ignored.
|
||||
* Overrides global number of threads set per filter graph.
|
||||
*/
|
||||
AVFilterInternal *internal;
|
||||
int nb_threads;
|
||||
|
||||
struct AVFilterCommand *command_queue;
|
||||
|
||||
@@ -460,16 +511,13 @@ struct AVFilterContext {
|
||||
* in particular, a filter which consumes or processes hardware frames will
|
||||
* instead use the hw_frames_ctx field in AVFilterLink to carry the
|
||||
* hardware context information.
|
||||
*
|
||||
* May be set by the caller on filters flagged with AVFILTER_FLAG_HWDEVICE
|
||||
* before initializing the filter with avfilter_init_str() or
|
||||
* avfilter_init_dict().
|
||||
*/
|
||||
AVBufferRef *hw_device_ctx;
|
||||
|
||||
/**
|
||||
* Max number of threads allowed in this filter instance.
|
||||
* If <= 0, its value is ignored.
|
||||
* Overrides global number of threads set per filter graph.
|
||||
*/
|
||||
int nb_threads;
|
||||
|
||||
/**
|
||||
* Ready status of the filter.
|
||||
* A non-0 value means that the filter needs activating;
|
||||
@@ -494,35 +542,6 @@ struct AVFilterContext {
|
||||
int extra_hw_frames;
|
||||
};
|
||||
|
||||
/**
|
||||
* Lists of formats / etc. supported by an end of a link.
|
||||
*
|
||||
* This structure is directly part of AVFilterLink, in two copies:
|
||||
* one for the source filter, one for the destination filter.
|
||||
|
||||
* These lists are used for negotiating the format to actually be used,
|
||||
* which will be loaded into the format and channel_layout members of
|
||||
* AVFilterLink, when chosen.
|
||||
*/
|
||||
typedef struct AVFilterFormatsConfig {
|
||||
|
||||
/**
|
||||
* List of supported formats (pixel or sample).
|
||||
*/
|
||||
AVFilterFormats *formats;
|
||||
|
||||
/**
|
||||
* Lists of supported sample rates, only for audio.
|
||||
*/
|
||||
AVFilterFormats *samplerates;
|
||||
|
||||
/**
|
||||
* Lists of supported channel layouts, only for audio.
|
||||
*/
|
||||
AVFilterChannelLayouts *channel_layouts;
|
||||
|
||||
} AVFilterFormatsConfig;
|
||||
|
||||
/**
|
||||
* A link between two filters. This contains pointers to the source and
|
||||
* destination filters between which this link exists, and the indexes of
|
||||
@@ -544,22 +563,25 @@ struct AVFilterLink {
|
||||
|
||||
enum AVMediaType type; ///< filter media type
|
||||
|
||||
int format; ///< agreed upon media format
|
||||
|
||||
/* These parameters apply only to video */
|
||||
int w; ///< agreed upon image width
|
||||
int h; ///< agreed upon image height
|
||||
AVRational sample_aspect_ratio; ///< agreed upon sample aspect ratio
|
||||
/* These parameters apply only to audio */
|
||||
#if FF_API_OLD_CHANNEL_LAYOUT
|
||||
/**
|
||||
* channel layout of current buffer (see libavutil/channel_layout.h)
|
||||
* @deprecated use ch_layout
|
||||
* For non-YUV links, these are respectively set to fallback values (as
|
||||
* appropriate for that colorspace).
|
||||
*
|
||||
* Note: This includes grayscale formats, as these are currently treated
|
||||
* as forced full range always.
|
||||
*/
|
||||
attribute_deprecated
|
||||
uint64_t channel_layout;
|
||||
#endif
|
||||
int sample_rate; ///< samples per second
|
||||
enum AVColorSpace colorspace; ///< agreed upon YUV color space
|
||||
enum AVColorRange color_range; ///< agreed upon YUV color range
|
||||
|
||||
int format; ///< agreed upon media format
|
||||
/* These parameters apply only to audio */
|
||||
int sample_rate; ///< samples per second
|
||||
AVChannelLayout ch_layout; ///< channel layout of current buffer (see libavutil/channel_layout.h)
|
||||
|
||||
/**
|
||||
* Define the time base used by the PTS of the frames/samples
|
||||
@@ -570,8 +592,6 @@ struct AVFilterLink {
|
||||
*/
|
||||
AVRational time_base;
|
||||
|
||||
AVChannelLayout ch_layout; ///< channel layout of current buffer (see libavutil/channel_layout.h)
|
||||
|
||||
/*****************************************************************
|
||||
* All fields below this line are not part of the public API. They
|
||||
* may not be used outside of libavfilter and can be changed and
|
||||
@@ -589,136 +609,6 @@ struct AVFilterLink {
|
||||
* Lists of supported formats / etc. supported by the output filter.
|
||||
*/
|
||||
AVFilterFormatsConfig outcfg;
|
||||
|
||||
/** stage of the initialization of the link properties (dimensions, etc) */
|
||||
enum {
|
||||
AVLINK_UNINIT = 0, ///< not started
|
||||
AVLINK_STARTINIT, ///< started, but incomplete
|
||||
AVLINK_INIT ///< complete
|
||||
} init_state;
|
||||
|
||||
/**
|
||||
* Graph the filter belongs to.
|
||||
*/
|
||||
struct AVFilterGraph *graph;
|
||||
|
||||
/**
|
||||
* Current timestamp of the link, as defined by the most recent
|
||||
* frame(s), in link time_base units.
|
||||
*/
|
||||
int64_t current_pts;
|
||||
|
||||
/**
|
||||
* Current timestamp of the link, as defined by the most recent
|
||||
* frame(s), in AV_TIME_BASE units.
|
||||
*/
|
||||
int64_t current_pts_us;
|
||||
|
||||
/**
|
||||
* Index in the age array.
|
||||
*/
|
||||
int age_index;
|
||||
|
||||
/**
|
||||
* Frame rate of the stream on the link, or 1/0 if unknown or variable;
|
||||
* if left to 0/0, will be automatically copied from the first input
|
||||
* of the source filter if it exists.
|
||||
*
|
||||
* Sources should set it to the best estimation of the real frame rate.
|
||||
* If the source frame rate is unknown or variable, set this to 1/0.
|
||||
* Filters should update it if necessary depending on their function.
|
||||
* Sinks can use it to set a default output frame rate.
|
||||
* It is similar to the r_frame_rate field in AVStream.
|
||||
*/
|
||||
AVRational frame_rate;
|
||||
|
||||
/**
|
||||
* Minimum number of samples to filter at once. If filter_frame() is
|
||||
* called with fewer samples, it will accumulate them in fifo.
|
||||
* This field and the related ones must not be changed after filtering
|
||||
* has started.
|
||||
* If 0, all related fields are ignored.
|
||||
*/
|
||||
int min_samples;
|
||||
|
||||
/**
|
||||
* Maximum number of samples to filter at once. If filter_frame() is
|
||||
* called with more samples, it will split them.
|
||||
*/
|
||||
int max_samples;
|
||||
|
||||
/**
|
||||
* Number of past frames sent through the link.
|
||||
*/
|
||||
int64_t frame_count_in, frame_count_out;
|
||||
|
||||
/**
|
||||
* Number of past samples sent through the link.
|
||||
*/
|
||||
int64_t sample_count_in, sample_count_out;
|
||||
|
||||
/**
|
||||
* A pointer to a FFFramePool struct.
|
||||
*/
|
||||
void *frame_pool;
|
||||
|
||||
/**
|
||||
* True if a frame is currently wanted on the output of this filter.
|
||||
* Set when ff_request_frame() is called by the output,
|
||||
* cleared when a frame is filtered.
|
||||
*/
|
||||
int frame_wanted_out;
|
||||
|
||||
/**
|
||||
* For hwaccel pixel formats, this should be a reference to the
|
||||
* AVHWFramesContext describing the frames.
|
||||
*/
|
||||
AVBufferRef *hw_frames_ctx;
|
||||
|
||||
#ifndef FF_INTERNAL_FIELDS
|
||||
|
||||
/**
|
||||
* Internal structure members.
|
||||
* The fields below this limit are internal for libavfilter's use
|
||||
* and must in no way be accessed by applications.
|
||||
*/
|
||||
char reserved[0xF000];
|
||||
|
||||
#else /* FF_INTERNAL_FIELDS */
|
||||
|
||||
/**
|
||||
* Queue of frames waiting to be filtered.
|
||||
*/
|
||||
FFFrameQueue fifo;
|
||||
|
||||
/**
|
||||
* If set, the source filter can not generate a frame as is.
|
||||
* The goal is to avoid repeatedly calling the request_frame() method on
|
||||
* the same link.
|
||||
*/
|
||||
int frame_blocked_in;
|
||||
|
||||
/**
|
||||
* Link input status.
|
||||
* If not zero, all attempts of filter_frame will fail with the
|
||||
* corresponding code.
|
||||
*/
|
||||
int status_in;
|
||||
|
||||
/**
|
||||
* Timestamp of the input status change.
|
||||
*/
|
||||
int64_t status_in_pts;
|
||||
|
||||
/**
|
||||
* Link output status.
|
||||
* If not zero, all attempts of request_frame will fail with the
|
||||
* corresponding code.
|
||||
*/
|
||||
int status_out;
|
||||
|
||||
#endif /* FF_INTERNAL_FIELDS */
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -733,18 +623,19 @@ struct AVFilterLink {
|
||||
int avfilter_link(AVFilterContext *src, unsigned srcpad,
|
||||
AVFilterContext *dst, unsigned dstpad);
|
||||
|
||||
#if FF_API_LINK_PUBLIC
|
||||
/**
|
||||
* Free the link in *link, and set its pointer to NULL.
|
||||
* @deprecated this function should never be called by users
|
||||
*/
|
||||
attribute_deprecated
|
||||
void avfilter_link_free(AVFilterLink **link);
|
||||
|
||||
/**
|
||||
* Negotiate the media format, dimensions, etc of all inputs to a filter.
|
||||
*
|
||||
* @param filter the filter to negotiate the properties for its inputs
|
||||
* @return zero on successful negotiation
|
||||
* @deprecated this function should never be called by users
|
||||
*/
|
||||
attribute_deprecated
|
||||
int avfilter_config_links(AVFilterContext *filter);
|
||||
#endif
|
||||
|
||||
#define AVFILTER_CMD_FLAG_ONE 1 ///< Stop once a filter understood the command (for target=all for example), fast filters are favored automatically
|
||||
#define AVFILTER_CMD_FLAG_FAST 2 ///< Only execute command when its fast (like a video out that supports contrast adjustment in hw)
|
||||
@@ -837,8 +728,6 @@ int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt,
|
||||
*/
|
||||
const AVClass *avfilter_get_class(void);
|
||||
|
||||
typedef struct AVFilterGraphInternal AVFilterGraphInternal;
|
||||
|
||||
/**
|
||||
* A function pointer passed to the @ref AVFilterGraph.execute callback to be
|
||||
* executed multiple times, possibly in parallel.
|
||||
@@ -896,11 +785,6 @@ typedef struct AVFilterGraph {
|
||||
*/
|
||||
int nb_threads;
|
||||
|
||||
/**
|
||||
* Opaque object for libavfilter internal use.
|
||||
*/
|
||||
AVFilterGraphInternal *internal;
|
||||
|
||||
/**
|
||||
* Opaque user data. May be set by the caller to an arbitrary value, e.g. to
|
||||
* be used from callbacks like @ref AVFilterGraph.execute.
|
||||
@@ -923,18 +807,6 @@ typedef struct AVFilterGraph {
|
||||
avfilter_execute_func *execute;
|
||||
|
||||
char *aresample_swr_opts; ///< swr options to use for the auto-inserted aresample filters, Access ONLY through AVOptions
|
||||
|
||||
/**
|
||||
* Private fields
|
||||
*
|
||||
* The following fields are for internal use only.
|
||||
* Their type, offset, number and semantic can change without notice.
|
||||
*/
|
||||
|
||||
AVFilterLink **sink_links;
|
||||
int sink_links_count;
|
||||
|
||||
unsigned disable_auto_convert;
|
||||
} AVFilterGraph;
|
||||
|
||||
/**
|
||||
@@ -1124,6 +996,317 @@ int avfilter_graph_parse2(AVFilterGraph *graph, const char *filters,
|
||||
AVFilterInOut **inputs,
|
||||
AVFilterInOut **outputs);
|
||||
|
||||
/**
|
||||
* Parameters of a filter's input or output pad.
|
||||
*
|
||||
* Created as a child of AVFilterParams by avfilter_graph_segment_parse().
|
||||
* Freed in avfilter_graph_segment_free().
|
||||
*/
|
||||
typedef struct AVFilterPadParams {
|
||||
/**
|
||||
* An av_malloc()'ed string containing the pad label.
|
||||
*
|
||||
* May be av_free()'d and set to NULL by the caller, in which case this pad
|
||||
* will be treated as unlabeled for linking.
|
||||
* May also be replaced by another av_malloc()'ed string.
|
||||
*/
|
||||
char *label;
|
||||
} AVFilterPadParams;
|
||||
|
||||
/**
|
||||
* Parameters describing a filter to be created in a filtergraph.
|
||||
*
|
||||
* Created as a child of AVFilterGraphSegment by avfilter_graph_segment_parse().
|
||||
* Freed in avfilter_graph_segment_free().
|
||||
*/
|
||||
typedef struct AVFilterParams {
|
||||
/**
|
||||
* The filter context.
|
||||
*
|
||||
* Created by avfilter_graph_segment_create_filters() based on
|
||||
* AVFilterParams.filter_name and instance_name.
|
||||
*
|
||||
* Callers may also create the filter context manually, then they should
|
||||
* av_free() filter_name and set it to NULL. Such AVFilterParams instances
|
||||
* are then skipped by avfilter_graph_segment_create_filters().
|
||||
*/
|
||||
AVFilterContext *filter;
|
||||
|
||||
/**
|
||||
* Name of the AVFilter to be used.
|
||||
*
|
||||
* An av_malloc()'ed string, set by avfilter_graph_segment_parse(). Will be
|
||||
* passed to avfilter_get_by_name() by
|
||||
* avfilter_graph_segment_create_filters().
|
||||
*
|
||||
* Callers may av_free() this string and replace it with another one or
|
||||
* NULL. If the caller creates the filter instance manually, this string
|
||||
* MUST be set to NULL.
|
||||
*
|
||||
* When both AVFilterParams.filter an AVFilterParams.filter_name are NULL,
|
||||
* this AVFilterParams instance is skipped by avfilter_graph_segment_*()
|
||||
* functions.
|
||||
*/
|
||||
char *filter_name;
|
||||
/**
|
||||
* Name to be used for this filter instance.
|
||||
*
|
||||
* An av_malloc()'ed string, may be set by avfilter_graph_segment_parse() or
|
||||
* left NULL. The caller may av_free() this string and replace with another
|
||||
* one or NULL.
|
||||
*
|
||||
* Will be used by avfilter_graph_segment_create_filters() - passed as the
|
||||
* third argument to avfilter_graph_alloc_filter(), then freed and set to
|
||||
* NULL.
|
||||
*/
|
||||
char *instance_name;
|
||||
|
||||
/**
|
||||
* Options to be apllied to the filter.
|
||||
*
|
||||
* Filled by avfilter_graph_segment_parse(). Afterwards may be freely
|
||||
* modified by the caller.
|
||||
*
|
||||
* Will be applied to the filter by avfilter_graph_segment_apply_opts()
|
||||
* with an equivalent of av_opt_set_dict2(filter, &opts, AV_OPT_SEARCH_CHILDREN),
|
||||
* i.e. any unapplied options will be left in this dictionary.
|
||||
*/
|
||||
AVDictionary *opts;
|
||||
|
||||
AVFilterPadParams **inputs;
|
||||
unsigned nb_inputs;
|
||||
|
||||
AVFilterPadParams **outputs;
|
||||
unsigned nb_outputs;
|
||||
} AVFilterParams;
|
||||
|
||||
/**
|
||||
* A filterchain is a list of filter specifications.
|
||||
*
|
||||
* Created as a child of AVFilterGraphSegment by avfilter_graph_segment_parse().
|
||||
* Freed in avfilter_graph_segment_free().
|
||||
*/
|
||||
typedef struct AVFilterChain {
|
||||
AVFilterParams **filters;
|
||||
size_t nb_filters;
|
||||
} AVFilterChain;
|
||||
|
||||
/**
|
||||
* A parsed representation of a filtergraph segment.
|
||||
*
|
||||
* A filtergraph segment is conceptually a list of filterchains, with some
|
||||
* supplementary information (e.g. format conversion flags).
|
||||
*
|
||||
* Created by avfilter_graph_segment_parse(). Must be freed with
|
||||
* avfilter_graph_segment_free().
|
||||
*/
|
||||
typedef struct AVFilterGraphSegment {
|
||||
/**
|
||||
* The filtergraph this segment is associated with.
|
||||
* Set by avfilter_graph_segment_parse().
|
||||
*/
|
||||
AVFilterGraph *graph;
|
||||
|
||||
/**
|
||||
* A list of filter chain contained in this segment.
|
||||
* Set in avfilter_graph_segment_parse().
|
||||
*/
|
||||
AVFilterChain **chains;
|
||||
size_t nb_chains;
|
||||
|
||||
/**
|
||||
* A string containing a colon-separated list of key=value options applied
|
||||
* to all scale filters in this segment.
|
||||
*
|
||||
* May be set by avfilter_graph_segment_parse().
|
||||
* The caller may free this string with av_free() and replace it with a
|
||||
* different av_malloc()'ed string.
|
||||
*/
|
||||
char *scale_sws_opts;
|
||||
} AVFilterGraphSegment;
|
||||
|
||||
/**
|
||||
* Parse a textual filtergraph description into an intermediate form.
|
||||
*
|
||||
* This intermediate representation is intended to be modified by the caller as
|
||||
* described in the documentation of AVFilterGraphSegment and its children, and
|
||||
* then applied to the graph either manually or with other
|
||||
* avfilter_graph_segment_*() functions. See the documentation for
|
||||
* avfilter_graph_segment_apply() for the canonical way to apply
|
||||
* AVFilterGraphSegment.
|
||||
*
|
||||
* @param graph Filter graph the parsed segment is associated with. Will only be
|
||||
* used for logging and similar auxiliary purposes. The graph will
|
||||
* not be actually modified by this function - the parsing results
|
||||
* are instead stored in seg for further processing.
|
||||
* @param graph_str a string describing the filtergraph segment
|
||||
* @param flags reserved for future use, caller must set to 0 for now
|
||||
* @param seg A pointer to the newly-created AVFilterGraphSegment is written
|
||||
* here on success. The graph segment is owned by the caller and must
|
||||
* be freed with avfilter_graph_segment_free() before graph itself is
|
||||
* freed.
|
||||
*
|
||||
* @retval "non-negative number" success
|
||||
* @retval "negative error code" failure
|
||||
*/
|
||||
int avfilter_graph_segment_parse(AVFilterGraph *graph, const char *graph_str,
|
||||
int flags, AVFilterGraphSegment **seg);
|
||||
|
||||
/**
|
||||
* Create filters specified in a graph segment.
|
||||
*
|
||||
* Walk through the creation-pending AVFilterParams in the segment and create
|
||||
* new filter instances for them.
|
||||
* Creation-pending params are those where AVFilterParams.filter_name is
|
||||
* non-NULL (and hence AVFilterParams.filter is NULL). All other AVFilterParams
|
||||
* instances are ignored.
|
||||
*
|
||||
* For any filter created by this function, the corresponding
|
||||
* AVFilterParams.filter is set to the newly-created filter context,
|
||||
* AVFilterParams.filter_name and AVFilterParams.instance_name are freed and set
|
||||
* to NULL.
|
||||
*
|
||||
* @param seg the filtergraph segment to process
|
||||
* @param flags reserved for future use, caller must set to 0 for now
|
||||
*
|
||||
* @retval "non-negative number" Success, all creation-pending filters were
|
||||
* successfully created
|
||||
* @retval AVERROR_FILTER_NOT_FOUND some filter's name did not correspond to a
|
||||
* known filter
|
||||
* @retval "another negative error code" other failures
|
||||
*
|
||||
* @note Calling this function multiple times is safe, as it is idempotent.
|
||||
*/
|
||||
int avfilter_graph_segment_create_filters(AVFilterGraphSegment *seg, int flags);
|
||||
|
||||
/**
|
||||
* Apply parsed options to filter instances in a graph segment.
|
||||
*
|
||||
* Walk through all filter instances in the graph segment that have option
|
||||
* dictionaries associated with them and apply those options with
|
||||
* av_opt_set_dict2(..., AV_OPT_SEARCH_CHILDREN). AVFilterParams.opts is
|
||||
* replaced by the dictionary output by av_opt_set_dict2(), which should be
|
||||
* empty (NULL) if all options were successfully applied.
|
||||
*
|
||||
* If any options could not be found, this function will continue processing all
|
||||
* other filters and finally return AVERROR_OPTION_NOT_FOUND (unless another
|
||||
* error happens). The calling program may then deal with unapplied options as
|
||||
* it wishes.
|
||||
*
|
||||
* Any creation-pending filters (see avfilter_graph_segment_create_filters())
|
||||
* present in the segment will cause this function to fail. AVFilterParams with
|
||||
* no associated filter context are simply skipped.
|
||||
*
|
||||
* @param seg the filtergraph segment to process
|
||||
* @param flags reserved for future use, caller must set to 0 for now
|
||||
*
|
||||
* @retval "non-negative number" Success, all options were successfully applied.
|
||||
* @retval AVERROR_OPTION_NOT_FOUND some options were not found in a filter
|
||||
* @retval "another negative error code" other failures
|
||||
*
|
||||
* @note Calling this function multiple times is safe, as it is idempotent.
|
||||
*/
|
||||
int avfilter_graph_segment_apply_opts(AVFilterGraphSegment *seg, int flags);
|
||||
|
||||
/**
|
||||
* Initialize all filter instances in a graph segment.
|
||||
*
|
||||
* Walk through all filter instances in the graph segment and call
|
||||
* avfilter_init_dict(..., NULL) on those that have not been initialized yet.
|
||||
*
|
||||
* Any creation-pending filters (see avfilter_graph_segment_create_filters())
|
||||
* present in the segment will cause this function to fail. AVFilterParams with
|
||||
* no associated filter context or whose filter context is already initialized,
|
||||
* are simply skipped.
|
||||
*
|
||||
* @param seg the filtergraph segment to process
|
||||
* @param flags reserved for future use, caller must set to 0 for now
|
||||
*
|
||||
* @retval "non-negative number" Success, all filter instances were successfully
|
||||
* initialized
|
||||
* @retval "negative error code" failure
|
||||
*
|
||||
* @note Calling this function multiple times is safe, as it is idempotent.
|
||||
*/
|
||||
int avfilter_graph_segment_init(AVFilterGraphSegment *seg, int flags);
|
||||
|
||||
/**
|
||||
* Link filters in a graph segment.
|
||||
*
|
||||
* Walk through all filter instances in the graph segment and try to link all
|
||||
* unlinked input and output pads. Any creation-pending filters (see
|
||||
* avfilter_graph_segment_create_filters()) present in the segment will cause
|
||||
* this function to fail. Disabled filters and already linked pads are skipped.
|
||||
*
|
||||
* Every filter output pad that has a corresponding AVFilterPadParams with a
|
||||
* non-NULL label is
|
||||
* - linked to the input with the matching label, if one exists;
|
||||
* - exported in the outputs linked list otherwise, with the label preserved.
|
||||
* Unlabeled outputs are
|
||||
* - linked to the first unlinked unlabeled input in the next non-disabled
|
||||
* filter in the chain, if one exists
|
||||
* - exported in the ouputs linked list otherwise, with NULL label
|
||||
*
|
||||
* Similarly, unlinked input pads are exported in the inputs linked list.
|
||||
*
|
||||
* @param seg the filtergraph segment to process
|
||||
* @param flags reserved for future use, caller must set to 0 for now
|
||||
* @param[out] inputs a linked list of all free (unlinked) inputs of the
|
||||
* filters in this graph segment will be returned here. It
|
||||
* is to be freed by the caller using avfilter_inout_free().
|
||||
* @param[out] outputs a linked list of all free (unlinked) outputs of the
|
||||
* filters in this graph segment will be returned here. It
|
||||
* is to be freed by the caller using avfilter_inout_free().
|
||||
*
|
||||
* @retval "non-negative number" success
|
||||
* @retval "negative error code" failure
|
||||
*
|
||||
* @note Calling this function multiple times is safe, as it is idempotent.
|
||||
*/
|
||||
int avfilter_graph_segment_link(AVFilterGraphSegment *seg, int flags,
|
||||
AVFilterInOut **inputs,
|
||||
AVFilterInOut **outputs);
|
||||
|
||||
/**
|
||||
* Apply all filter/link descriptions from a graph segment to the associated filtergraph.
|
||||
*
|
||||
* This functions is currently equivalent to calling the following in sequence:
|
||||
* - avfilter_graph_segment_create_filters();
|
||||
* - avfilter_graph_segment_apply_opts();
|
||||
* - avfilter_graph_segment_init();
|
||||
* - avfilter_graph_segment_link();
|
||||
* failing if any of them fails. This list may be extended in the future.
|
||||
*
|
||||
* Since the above functions are idempotent, the caller may call some of them
|
||||
* manually, then do some custom processing on the filtergraph, then call this
|
||||
* function to do the rest.
|
||||
*
|
||||
* @param seg the filtergraph segment to process
|
||||
* @param flags reserved for future use, caller must set to 0 for now
|
||||
* @param[out] inputs passed to avfilter_graph_segment_link()
|
||||
* @param[out] outputs passed to avfilter_graph_segment_link()
|
||||
*
|
||||
* @retval "non-negative number" success
|
||||
* @retval "negative error code" failure
|
||||
*
|
||||
* @note Calling this function multiple times is safe, as it is idempotent.
|
||||
*/
|
||||
int avfilter_graph_segment_apply(AVFilterGraphSegment *seg, int flags,
|
||||
AVFilterInOut **inputs,
|
||||
AVFilterInOut **outputs);
|
||||
|
||||
/**
|
||||
* Free the provided AVFilterGraphSegment and everything associated with it.
|
||||
*
|
||||
* @param seg double pointer to the AVFilterGraphSegment to be freed. NULL will
|
||||
* be written to this pointer on exit from this function.
|
||||
*
|
||||
* @note
|
||||
* The filter contexts (AVFilterParams.filter) are owned by AVFilterGraph rather
|
||||
* than AVFilterGraphSegment, so they are not freed.
|
||||
*/
|
||||
void avfilter_graph_segment_free(AVFilterGraphSegment **seg);
|
||||
|
||||
/**
|
||||
* Send a command to one or more filter instances.
|
||||
*
|
||||
|
||||
@@ -55,6 +55,8 @@
|
||||
* The format can be constrained by setting options, using av_opt_set() and
|
||||
* related functions with the AV_OPT_SEARCH_CHILDREN flag.
|
||||
* - pix_fmts (int list),
|
||||
* - color_spaces (int list),
|
||||
* - color_ranges (int list),
|
||||
* - sample_fmts (int list),
|
||||
* - sample_rates (int list),
|
||||
* - ch_layouts (string),
|
||||
@@ -94,42 +96,6 @@ int av_buffersink_get_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flag
|
||||
*/
|
||||
#define AV_BUFFERSINK_FLAG_NO_REQUEST 2
|
||||
|
||||
#if FF_API_BUFFERSINK_ALLOC
|
||||
/**
|
||||
* Deprecated and unused struct to use for initializing a buffersink context.
|
||||
*/
|
||||
typedef struct AVBufferSinkParams {
|
||||
const enum AVPixelFormat *pixel_fmts; ///< list of allowed pixel formats, terminated by AV_PIX_FMT_NONE
|
||||
} AVBufferSinkParams;
|
||||
|
||||
/**
|
||||
* Create an AVBufferSinkParams structure.
|
||||
*
|
||||
* Must be freed with av_free().
|
||||
*/
|
||||
attribute_deprecated
|
||||
AVBufferSinkParams *av_buffersink_params_alloc(void);
|
||||
|
||||
/**
|
||||
* Deprecated and unused struct to use for initializing an abuffersink context.
|
||||
*/
|
||||
typedef struct AVABufferSinkParams {
|
||||
const enum AVSampleFormat *sample_fmts; ///< list of allowed sample formats, terminated by AV_SAMPLE_FMT_NONE
|
||||
const int64_t *channel_layouts; ///< list of allowed channel layouts, terminated by -1
|
||||
const int *channel_counts; ///< list of allowed channel counts, terminated by -1
|
||||
int all_channel_counts; ///< if not 0, accept any channel count or layout
|
||||
int *sample_rates; ///< list of allowed sample rates, terminated by -1
|
||||
} AVABufferSinkParams;
|
||||
|
||||
/**
|
||||
* Create an AVABufferSinkParams structure.
|
||||
*
|
||||
* Must be freed with av_free().
|
||||
*/
|
||||
attribute_deprecated
|
||||
AVABufferSinkParams *av_abuffersink_params_alloc(void);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Set the frame size for an audio buffer sink.
|
||||
*
|
||||
@@ -153,12 +119,10 @@ AVRational av_buffersink_get_frame_rate (const AVFilterContext *c
|
||||
int av_buffersink_get_w (const AVFilterContext *ctx);
|
||||
int av_buffersink_get_h (const AVFilterContext *ctx);
|
||||
AVRational av_buffersink_get_sample_aspect_ratio (const AVFilterContext *ctx);
|
||||
enum AVColorSpace av_buffersink_get_colorspace (const AVFilterContext *ctx);
|
||||
enum AVColorRange av_buffersink_get_color_range (const AVFilterContext *ctx);
|
||||
|
||||
int av_buffersink_get_channels (const AVFilterContext *ctx);
|
||||
#if FF_API_OLD_CHANNEL_LAYOUT
|
||||
attribute_deprecated
|
||||
uint64_t av_buffersink_get_channel_layout (const AVFilterContext *ctx);
|
||||
#endif
|
||||
int av_buffersink_get_ch_layout (const AVFilterContext *ctx,
|
||||
AVChannelLayout *ch_layout);
|
||||
int av_buffersink_get_sample_rate (const AVFilterContext *ctx);
|
||||
|
||||
@@ -110,19 +110,16 @@ typedef struct AVBufferSrcParameters {
|
||||
*/
|
||||
int sample_rate;
|
||||
|
||||
#if FF_API_OLD_CHANNEL_LAYOUT
|
||||
/**
|
||||
* Audio only, the audio channel layout
|
||||
* @deprecated use ch_layout
|
||||
*/
|
||||
attribute_deprecated
|
||||
uint64_t channel_layout;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Audio only, the audio channel layout
|
||||
*/
|
||||
AVChannelLayout ch_layout;
|
||||
|
||||
/**
|
||||
* Video only, the YUV colorspace and range.
|
||||
*/
|
||||
enum AVColorSpace color_space;
|
||||
enum AVColorRange color_range;
|
||||
} AVBufferSrcParameters;
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
#include "version_major.h"
|
||||
|
||||
#define LIBAVFILTER_VERSION_MINOR 44
|
||||
#define LIBAVFILTER_VERSION_MINOR 4
|
||||
#define LIBAVFILTER_VERSION_MICRO 100
|
||||
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
* Libavfilter version macros
|
||||
*/
|
||||
|
||||
#define LIBAVFILTER_VERSION_MAJOR 8
|
||||
#define LIBAVFILTER_VERSION_MAJOR 10
|
||||
|
||||
/**
|
||||
* FF_API_* defines may be placed below to indicate public API that will be
|
||||
@@ -35,8 +35,6 @@
|
||||
* the public API and may change, break or disappear at any time.
|
||||
*/
|
||||
|
||||
#define FF_API_SWS_PARAM_OPTION (LIBAVFILTER_VERSION_MAJOR < 9)
|
||||
#define FF_API_BUFFERSINK_ALLOC (LIBAVFILTER_VERSION_MAJOR < 9)
|
||||
#define FF_API_PAD_COUNT (LIBAVFILTER_VERSION_MAJOR < 9)
|
||||
#define FF_API_LINK_PUBLIC (LIBAVFILTER_VERSION_MAJOR < 11)
|
||||
|
||||
#endif /* AVFILTER_VERSION_MAJOR_H */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -101,9 +101,7 @@ typedef struct AVIODirEntry {
|
||||
int64_t filemode; /**< Unix file mode, -1 if unknown. */
|
||||
} AVIODirEntry;
|
||||
|
||||
typedef struct AVIODirContext {
|
||||
struct URLContext *url_context;
|
||||
} AVIODirContext;
|
||||
typedef struct AVIODirContext AVIODirContext;
|
||||
|
||||
/**
|
||||
* Different data types that can be returned via the AVIO
|
||||
@@ -234,7 +232,7 @@ typedef struct AVIOContext {
|
||||
void *opaque; /**< A private pointer, passed to the read/write/seek/...
|
||||
functions. */
|
||||
int (*read_packet)(void *opaque, uint8_t *buf, int buf_size);
|
||||
int (*write_packet)(void *opaque, uint8_t *buf, int buf_size);
|
||||
int (*write_packet)(void *opaque, const uint8_t *buf, int buf_size);
|
||||
int64_t (*seek)(void *opaque, int64_t offset, int whence);
|
||||
int64_t pos; /**< position in the file of the current buffer */
|
||||
int eof_reached; /**< true if was unable to read due to error or eof */
|
||||
@@ -282,7 +280,7 @@ typedef struct AVIOContext {
|
||||
/**
|
||||
* A callback that is used instead of write_packet.
|
||||
*/
|
||||
int (*write_data_type)(void *opaque, uint8_t *buf, int buf_size,
|
||||
int (*write_data_type)(void *opaque, const uint8_t *buf, int buf_size,
|
||||
enum AVIODataMarkerType type, int64_t time);
|
||||
/**
|
||||
* If set, don't call write_data_type separately for AVIO_DATA_MARKER_BOUNDARY_POINT,
|
||||
@@ -291,16 +289,6 @@ typedef struct AVIOContext {
|
||||
*/
|
||||
int ignore_boundary_point;
|
||||
|
||||
#if FF_API_AVIOCONTEXT_WRITTEN
|
||||
/**
|
||||
* @deprecated field utilized privately by libavformat. For a public
|
||||
* statistic of how many bytes were written out, see
|
||||
* AVIOContext::bytes_written.
|
||||
*/
|
||||
attribute_deprecated
|
||||
int64_t written;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Maximum reached position before a backward seek in the write buffer,
|
||||
* used keeping track of already written data for a later flush.
|
||||
@@ -413,7 +401,7 @@ AVIOContext *avio_alloc_context(
|
||||
int write_flag,
|
||||
void *opaque,
|
||||
int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
|
||||
int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
|
||||
int (*write_packet)(void *opaque, const uint8_t *buf, int buf_size),
|
||||
int64_t (*seek)(void *opaque, int64_t offset, int whence));
|
||||
|
||||
/**
|
||||
@@ -464,6 +452,7 @@ int avio_put_str16be(AVIOContext *s, const char *str);
|
||||
*
|
||||
* Zero-length ranges are omitted from the output.
|
||||
*
|
||||
* @param s the AVIOContext
|
||||
* @param time the stream time the current bytestream pos corresponds to
|
||||
* (in AV_TIME_BASE units), or AV_NOPTS_VALUE if unknown or not
|
||||
* applicable
|
||||
@@ -536,7 +525,7 @@ int avio_printf(AVIOContext *s, const char *fmt, ...) av_printf_format(2, 3);
|
||||
* Usually you don't need to use this function directly but its macro wrapper,
|
||||
* avio_print.
|
||||
*/
|
||||
void avio_print_string_array(AVIOContext *s, const char *strings[]);
|
||||
void avio_print_string_array(AVIOContext *s, const char * const strings[]);
|
||||
|
||||
/**
|
||||
* Write strings (const char *) to the context.
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
#include "version_major.h"
|
||||
|
||||
#define LIBAVFORMAT_VERSION_MINOR 27
|
||||
#define LIBAVFORMAT_VERSION_MINOR 7
|
||||
#define LIBAVFORMAT_VERSION_MICRO 100
|
||||
|
||||
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
// Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
|
||||
// Also please add any ticket numbers that you believe might be affected here
|
||||
#define LIBAVFORMAT_VERSION_MAJOR 59
|
||||
#define LIBAVFORMAT_VERSION_MAJOR 61
|
||||
|
||||
/**
|
||||
* FF_API_* defines may be placed below to indicate public API that will be
|
||||
@@ -41,12 +41,13 @@
|
||||
* 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_COMPUTE_PKT_FIELDS2 (LIBAVFORMAT_VERSION_MAJOR < 62)
|
||||
#define FF_API_LAVF_SHORTEST (LIBAVFORMAT_VERSION_MAJOR < 62)
|
||||
#define FF_API_ALLOW_FLUSH (LIBAVFORMAT_VERSION_MAJOR < 62)
|
||||
#define FF_API_AVSTREAM_SIDE_DATA (LIBAVFORMAT_VERSION_MAJOR < 62)
|
||||
|
||||
#define FF_API_GET_DUR_ESTIMATE_METHOD (LIBAVFORMAT_VERSION_MAJOR < 62)
|
||||
#define FF_API_INTERNAL_TIMING (LIBAVFORMAT_VERSION_MAJOR < 62)
|
||||
|
||||
#define FF_API_R_FRAME_RATE 1
|
||||
|
||||
|
||||
@@ -42,6 +42,9 @@ struct AVAES *av_aes_alloc(void);
|
||||
|
||||
/**
|
||||
* Initialize an AVAES context.
|
||||
*
|
||||
* @param a The AVAES context
|
||||
* @param key Pointer to the key
|
||||
* @param key_bits 128, 192 or 256
|
||||
* @param decrypt 0 for encryption, 1 for decryption
|
||||
*/
|
||||
@@ -49,9 +52,11 @@ int av_aes_init(struct AVAES *a, const uint8_t *key, int key_bits, int decrypt);
|
||||
|
||||
/**
|
||||
* Encrypt or decrypt a buffer using a previously initialized context.
|
||||
* @param count number of 16 byte blocks
|
||||
*
|
||||
* @param a The AVAES context
|
||||
* @param dst destination array, can be equal to src
|
||||
* @param src source array, can be equal to dst
|
||||
* @param count number of 16 byte blocks
|
||||
* @param iv initialization vector for CBC mode, if NULL then ECB will be used
|
||||
* @param decrypt 0 for encryption, 1 for decryption
|
||||
*/
|
||||
|
||||
@@ -22,6 +22,12 @@
|
||||
#ifndef AVUTIL_AES_CTR_H
|
||||
#define AVUTIL_AES_CTR_H
|
||||
|
||||
/**
|
||||
* @defgroup lavu_aes_ctr AES-CTR
|
||||
* @ingroup lavu_crypto
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "attributes.h"
|
||||
@@ -38,17 +44,23 @@ struct AVAESCTR *av_aes_ctr_alloc(void);
|
||||
|
||||
/**
|
||||
* Initialize an AVAESCTR context.
|
||||
*
|
||||
* @param a The AVAESCTR context to initialize
|
||||
* @param key encryption key, must have a length of AES_CTR_KEY_SIZE
|
||||
*/
|
||||
int av_aes_ctr_init(struct AVAESCTR *a, const uint8_t *key);
|
||||
|
||||
/**
|
||||
* Release an AVAESCTR context.
|
||||
*
|
||||
* @param a The AVAESCTR context
|
||||
*/
|
||||
void av_aes_ctr_free(struct AVAESCTR *a);
|
||||
|
||||
/**
|
||||
* Process a buffer using a previously initialized context.
|
||||
*
|
||||
* @param a The AVAESCTR context
|
||||
* @param dst destination array, can be equal to src
|
||||
* @param src source array, can be equal to dst
|
||||
* @param size the size of src and dst
|
||||
|
||||
72
include/libavutil/ambient_viewing_environment.h
Normal file
72
include/libavutil/ambient_viewing_environment.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Jan Ekström <jeebjp@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_AMBIENT_VIEWING_ENVIRONMENT_H
|
||||
#define AVUTIL_AMBIENT_VIEWING_ENVIRONMENT_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include "frame.h"
|
||||
#include "rational.h"
|
||||
|
||||
/**
|
||||
* Ambient viewing environment metadata as defined by H.274. The values are
|
||||
* saved in AVRationals so that they keep their exactness, while allowing for
|
||||
* easy access to a double value with f.ex. av_q2d.
|
||||
*
|
||||
* @note sizeof(AVAmbientViewingEnvironment) is not part of the public ABI, and
|
||||
* it must be allocated using av_ambient_viewing_environment_alloc.
|
||||
*/
|
||||
typedef struct AVAmbientViewingEnvironment {
|
||||
/**
|
||||
* Environmental illuminance of the ambient viewing environment in lux.
|
||||
*/
|
||||
AVRational ambient_illuminance;
|
||||
|
||||
/**
|
||||
* Normalized x chromaticity coordinate of the environmental ambient light
|
||||
* in the nominal viewing environment according to the CIE 1931 definition
|
||||
* of x and y as specified in ISO/CIE 11664-1.
|
||||
*/
|
||||
AVRational ambient_light_x;
|
||||
|
||||
/**
|
||||
* Normalized y chromaticity coordinate of the environmental ambient light
|
||||
* in the nominal viewing environment according to the CIE 1931 definition
|
||||
* of x and y as specified in ISO/CIE 11664-1.
|
||||
*/
|
||||
AVRational ambient_light_y;
|
||||
} AVAmbientViewingEnvironment;
|
||||
|
||||
/**
|
||||
* Allocate an AVAmbientViewingEnvironment structure.
|
||||
*
|
||||
* @return the newly allocated struct or NULL on failure
|
||||
*/
|
||||
AVAmbientViewingEnvironment *av_ambient_viewing_environment_alloc(size_t *size);
|
||||
|
||||
/**
|
||||
* Allocate and add an AVAmbientViewingEnvironment structure to an existing
|
||||
* AVFrame as side data.
|
||||
*
|
||||
* @return the newly allocated struct, or NULL on failure
|
||||
*/
|
||||
AVAmbientViewingEnvironment *av_ambient_viewing_environment_create_side_data(AVFrame *frame);
|
||||
|
||||
#endif /* AVUTIL_AMBIENT_VIEWING_ENVIRONMENT_H */
|
||||
34
include/libavutil/attributes_internal.h
Normal file
34
include/libavutil/attributes_internal.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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_ATTRIBUTES_INTERNAL_H
|
||||
#define AVUTIL_ATTRIBUTES_INTERNAL_H
|
||||
|
||||
#include "attributes.h"
|
||||
|
||||
#if (AV_GCC_VERSION_AT_LEAST(4,0) || defined(__clang__)) && (defined(__ELF__) || defined(__MACH__))
|
||||
# define attribute_visibility_hidden __attribute__((visibility("hidden")))
|
||||
# define FF_VISIBILITY_PUSH_HIDDEN _Pragma("GCC visibility push(hidden)")
|
||||
# define FF_VISIBILITY_POP_HIDDEN _Pragma("GCC visibility pop")
|
||||
#else
|
||||
# define attribute_visibility_hidden
|
||||
# define FF_VISIBILITY_PUSH_HIDDEN
|
||||
# define FF_VISIBILITY_POP_HIDDEN
|
||||
#endif
|
||||
|
||||
#endif /* AVUTIL_ATTRIBUTES_INTERNAL_H */
|
||||
@@ -91,7 +91,7 @@ int av_audio_fifo_realloc(AVAudioFifo *af, int nb_samples);
|
||||
* code on failure. If successful, the number of samples
|
||||
* actually written will always be nb_samples.
|
||||
*/
|
||||
int av_audio_fifo_write(AVAudioFifo *af, void **data, int nb_samples);
|
||||
int av_audio_fifo_write(AVAudioFifo *af, void * const *data, int nb_samples);
|
||||
|
||||
/**
|
||||
* Peek data from an AVAudioFifo.
|
||||
@@ -107,7 +107,7 @@ int av_audio_fifo_write(AVAudioFifo *af, void **data, int nb_samples);
|
||||
* be greater than nb_samples, and will only be less than
|
||||
* nb_samples if av_audio_fifo_size is less than nb_samples.
|
||||
*/
|
||||
int av_audio_fifo_peek(AVAudioFifo *af, void **data, int nb_samples);
|
||||
int av_audio_fifo_peek(const AVAudioFifo *af, void * const *data, int nb_samples);
|
||||
|
||||
/**
|
||||
* Peek data from an AVAudioFifo.
|
||||
@@ -124,7 +124,8 @@ int av_audio_fifo_peek(AVAudioFifo *af, void **data, int nb_samples);
|
||||
* be greater than nb_samples, and will only be less than
|
||||
* nb_samples if av_audio_fifo_size is less than nb_samples.
|
||||
*/
|
||||
int av_audio_fifo_peek_at(AVAudioFifo *af, void **data, int nb_samples, int offset);
|
||||
int av_audio_fifo_peek_at(const AVAudioFifo *af, void * const *data,
|
||||
int nb_samples, int offset);
|
||||
|
||||
/**
|
||||
* Read data from an AVAudioFifo.
|
||||
@@ -140,7 +141,7 @@ int av_audio_fifo_peek_at(AVAudioFifo *af, void **data, int nb_samples, int offs
|
||||
* be greater than nb_samples, and will only be less than
|
||||
* nb_samples if av_audio_fifo_size is less than nb_samples.
|
||||
*/
|
||||
int av_audio_fifo_read(AVAudioFifo *af, void **data, int nb_samples);
|
||||
int av_audio_fifo_read(AVAudioFifo *af, void * const *data, int nb_samples);
|
||||
|
||||
/**
|
||||
* Drain data from an AVAudioFifo.
|
||||
|
||||
@@ -28,6 +28,9 @@
|
||||
#define AVUTIL_AVASSERT_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_AV_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
#include "log.h"
|
||||
#include "macros.h"
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include "attributes.h"
|
||||
#include "version.h"
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_string
|
||||
@@ -135,6 +134,7 @@ size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...) av_printf_forma
|
||||
/**
|
||||
* Get the count of continuous non zero chars starting from the beginning.
|
||||
*
|
||||
* @param s the string whose length to count
|
||||
* @param len maximum number of characters to check in the string, that
|
||||
* is the maximum value which is returned by the function
|
||||
*/
|
||||
@@ -156,15 +156,6 @@ static inline size_t av_strnlen(const char *s, size_t len)
|
||||
*/
|
||||
char *av_asprintf(const char *fmt, ...) av_printf_format(1, 2);
|
||||
|
||||
#if FF_API_D2STR
|
||||
/**
|
||||
* Convert a number to an av_malloced string.
|
||||
* @deprecated use av_asprintf() with "%f" or a more specific format
|
||||
*/
|
||||
attribute_deprecated
|
||||
char *av_d2str(double d);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Unescape the given string until a non escaped terminating char,
|
||||
* and return the token corresponding to the unescaped string.
|
||||
@@ -273,7 +264,7 @@ int av_strncasecmp(const char *a, const char *b, size_t n);
|
||||
|
||||
/**
|
||||
* Locale-independent strings replace.
|
||||
* @note This means only ASCII-range characters are replace
|
||||
* @note This means only ASCII-range characters are replaced.
|
||||
*/
|
||||
char *av_strireplace(const char *str, const char *from, const char *to);
|
||||
|
||||
|
||||
@@ -257,7 +257,12 @@ const char *av_get_media_type_string(enum AVMediaType media_type);
|
||||
* Internal time base represented as fractional value
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
/* ISO C++ forbids compound-literals. */
|
||||
#define AV_TIME_BASE_Q av_make_q(1, AV_TIME_BASE)
|
||||
#else
|
||||
#define AV_TIME_BASE_Q (AVRational){1, AV_TIME_BASE}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
@@ -294,7 +299,6 @@ char av_get_picture_type_char(enum AVPictureType pict_type);
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "error.h"
|
||||
#include "rational.h"
|
||||
#include "version.h"
|
||||
#include "macros.h"
|
||||
@@ -331,19 +335,6 @@ unsigned av_int_list_length_for_size(unsigned elsize,
|
||||
#define av_int_list_length(list, term) \
|
||||
av_int_list_length_for_size(sizeof(*(list)), list, term)
|
||||
|
||||
#if FF_API_AV_FOPEN_UTF8
|
||||
/**
|
||||
* Open a file using a UTF-8 filename.
|
||||
* The API of this function matches POSIX fopen(), errors are returned through
|
||||
* errno.
|
||||
* @deprecated Avoid using it, as on Windows, the FILE* allocated by this
|
||||
* function may be allocated with a different CRT than the caller
|
||||
* who uses the FILE*. No replacement provided in public API.
|
||||
*/
|
||||
attribute_deprecated
|
||||
FILE *av_fopen_utf8(const char *path, const char *mode);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Return the fractional representation of the internal time base.
|
||||
*/
|
||||
|
||||
@@ -18,6 +18,12 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavu_avbprint
|
||||
* AVBPrint public header
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_BPRINT_H
|
||||
#define AVUTIL_BPRINT_H
|
||||
|
||||
@@ -26,6 +32,14 @@
|
||||
#include "attributes.h"
|
||||
#include "avstring.h"
|
||||
|
||||
/**
|
||||
* @defgroup lavu_avbprint AVBPrint
|
||||
* @ingroup lavu_data
|
||||
*
|
||||
* A buffer to print data progressively
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Define a structure with extra padding to a fixed size
|
||||
* This helps ensuring binary compatibility with future versions.
|
||||
@@ -48,14 +62,14 @@ typedef struct name { \
|
||||
* Small buffers are kept in the structure itself, and thus require no
|
||||
* memory allocation at all (unless the contents of the buffer is needed
|
||||
* after the structure goes out of scope). This is almost as lightweight as
|
||||
* declaring a local "char buf[512]".
|
||||
* declaring a local `char buf[512]`.
|
||||
*
|
||||
* The length of the string can go beyond the allocated size: the buffer is
|
||||
* then truncated, but the functions still keep account of the actual total
|
||||
* length.
|
||||
*
|
||||
* In other words, buf->len can be greater than buf->size and records the
|
||||
* total length of what would have been to the buffer if there had been
|
||||
* In other words, AVBPrint.len can be greater than AVBPrint.size and records
|
||||
* the total length of what would have been to the buffer if there had been
|
||||
* enough memory.
|
||||
*
|
||||
* Append operations do not need to be tested for failure: if a memory
|
||||
@@ -63,20 +77,17 @@ typedef struct name { \
|
||||
* is still updated. This situation can be tested with
|
||||
* av_bprint_is_complete().
|
||||
*
|
||||
* The size_max field determines several possible behaviours:
|
||||
*
|
||||
* size_max = -1 (= UINT_MAX) or any large value will let the buffer be
|
||||
* reallocated as necessary, with an amortized linear cost.
|
||||
*
|
||||
* size_max = 0 prevents writing anything to the buffer: only the total
|
||||
* length is computed. The write operations can then possibly be repeated in
|
||||
* a buffer with exactly the necessary size
|
||||
* (using size_init = size_max = len + 1).
|
||||
*
|
||||
* size_max = 1 is automatically replaced by the exact size available in the
|
||||
* structure itself, thus ensuring no dynamic memory allocation. The
|
||||
* internal buffer is large enough to hold a reasonable paragraph of text,
|
||||
* such as the current paragraph.
|
||||
* The AVBPrint.size_max field determines several possible behaviours:
|
||||
* - `size_max = -1` (= `UINT_MAX`) or any large value will let the buffer be
|
||||
* reallocated as necessary, with an amortized linear cost.
|
||||
* - `size_max = 0` prevents writing anything to the buffer: only the total
|
||||
* length is computed. The write operations can then possibly be repeated in
|
||||
* a buffer with exactly the necessary size
|
||||
* (using `size_init = size_max = len + 1`).
|
||||
* - `size_max = 1` is automatically replaced by the exact size available in the
|
||||
* structure itself, thus ensuring no dynamic memory allocation. The
|
||||
* internal buffer is large enough to hold a reasonable paragraph of text,
|
||||
* such as the current paragraph.
|
||||
*/
|
||||
|
||||
FF_PAD_STRUCTURE(AVBPrint, 1024,
|
||||
@@ -88,12 +99,31 @@ FF_PAD_STRUCTURE(AVBPrint, 1024,
|
||||
)
|
||||
|
||||
/**
|
||||
* @name Max size special values
|
||||
* Convenience macros for special values for av_bprint_init() size_max
|
||||
* parameter.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Buffer will be reallocated as necessary, with an amortized linear cost.
|
||||
*/
|
||||
#define AV_BPRINT_SIZE_UNLIMITED ((unsigned)-1)
|
||||
/**
|
||||
* Use the exact size available in the AVBPrint structure itself.
|
||||
*
|
||||
* Thus ensuring no dynamic memory allocation. The internal buffer is large
|
||||
* enough to hold a reasonable paragraph of text, such as the current paragraph.
|
||||
*/
|
||||
#define AV_BPRINT_SIZE_AUTOMATIC 1
|
||||
/**
|
||||
* Do not write anything to the buffer, only calculate the total length.
|
||||
*
|
||||
* The write operations can then possibly be repeated in a buffer with
|
||||
* exactly the necessary size (using `size_init = size_max = AVBPrint.len + 1`).
|
||||
*/
|
||||
#define AV_BPRINT_SIZE_COUNT_ONLY 0
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* Init a print buffer.
|
||||
@@ -101,12 +131,12 @@ FF_PAD_STRUCTURE(AVBPrint, 1024,
|
||||
* @param buf buffer to init
|
||||
* @param size_init initial size (including the final 0)
|
||||
* @param size_max maximum size;
|
||||
* 0 means do not write anything, just count the length;
|
||||
* 1 is replaced by the maximum value for automatic storage;
|
||||
* any large value means that the internal buffer will be
|
||||
* reallocated as needed up to that limit; -1 is converted to
|
||||
* UINT_MAX, the largest limit possible.
|
||||
* Check also AV_BPRINT_SIZE_* macros.
|
||||
* - `0` means do not write anything, just count the length
|
||||
* - `1` is replaced by the maximum value for automatic storage
|
||||
* any large value means that the internal buffer will be
|
||||
* reallocated as needed up to that limit
|
||||
* - `-1` is converted to `UINT_MAX`, the largest limit possible.
|
||||
* Check also `AV_BPRINT_SIZE_*` macros.
|
||||
*/
|
||||
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max);
|
||||
|
||||
@@ -114,6 +144,9 @@ void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max);
|
||||
* Init a print buffer using a pre-existing buffer.
|
||||
*
|
||||
* The buffer will not be reallocated.
|
||||
* In case size equals zero, the AVBPrint will be initialized to use
|
||||
* the internal buffer as if using AV_BPRINT_SIZE_COUNT_ONLY with
|
||||
* av_bprint_init().
|
||||
*
|
||||
* @param buf buffer structure to init
|
||||
* @param buffer byte buffer to use for the string data
|
||||
@@ -139,9 +172,9 @@ void av_bprint_chars(AVBPrint *buf, char c, unsigned n);
|
||||
/**
|
||||
* Append data to a print buffer.
|
||||
*
|
||||
* param buf bprint buffer to use
|
||||
* param data pointer to data
|
||||
* param size size of data
|
||||
* @param buf bprint buffer to use
|
||||
* @param data pointer to data
|
||||
* @param size size of data
|
||||
*/
|
||||
void av_bprint_append_data(AVBPrint *buf, const char *data, unsigned size);
|
||||
|
||||
@@ -149,9 +182,9 @@ struct tm;
|
||||
/**
|
||||
* Append a formatted date and time to a print buffer.
|
||||
*
|
||||
* param buf bprint buffer to use
|
||||
* param fmt date and time format string, see strftime()
|
||||
* param tm broken-down time structure to translate
|
||||
* @param buf bprint buffer to use
|
||||
* @param fmt date and time format string, see strftime()
|
||||
* @param tm broken-down time structure to translate
|
||||
*
|
||||
* @note due to poor design of the standard strftime function, it may
|
||||
* produce poor results if the format string expands to a very long text and
|
||||
@@ -216,4 +249,6 @@ int av_bprint_finalize(AVBPrint *buf, char **ret_str);
|
||||
void av_bprint_escape(AVBPrint *dstbuf, const char *src, const char *special_chars,
|
||||
enum AVEscapeMode mode, int flags);
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif /* AVUTIL_BPRINT_H */
|
||||
|
||||
@@ -34,14 +34,10 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if ARCH_AARCH64
|
||||
# include "aarch64/bswap.h"
|
||||
#elif ARCH_ARM
|
||||
#if ARCH_ARM
|
||||
# include "arm/bswap.h"
|
||||
#elif ARCH_AVR32
|
||||
# include "avr32/bswap.h"
|
||||
#elif ARCH_SH4
|
||||
# include "sh4/bswap.h"
|
||||
#elif ARCH_RISCV
|
||||
# include "riscv/bswap.h"
|
||||
#elif ARCH_X86
|
||||
# include "x86/bswap.h"
|
||||
#endif
|
||||
|
||||
@@ -59,7 +59,7 @@ int av_camellia_init(struct AVCAMELLIA *ctx, const uint8_t *key, int key_bits);
|
||||
* @param dst destination array, can be equal to src
|
||||
* @param src source array, can be equal to dst
|
||||
* @param count number of 16 byte blocks
|
||||
* @paran iv initialization vector for CBC mode, NULL for ECB mode
|
||||
* @param iv initialization vector for CBC mode, NULL for ECB mode
|
||||
* @param decrypt 0 for encryption, 1 for decryption
|
||||
*/
|
||||
void av_camellia_crypt(struct AVCAMELLIA *ctx, uint8_t *dst, const uint8_t *src, int count, uint8_t* iv, int decrypt);
|
||||
|
||||
@@ -30,11 +30,17 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* audio channel layout utility functions
|
||||
* @ingroup lavu_audio_channels
|
||||
* Public libavutil channel layout APIs header.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_audio
|
||||
* @defgroup lavu_audio_channels Audio channels
|
||||
* @ingroup lavu_audio
|
||||
*
|
||||
* Audio channel layout utility functions
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
@@ -73,6 +79,10 @@ enum AVChannel {
|
||||
AV_CHAN_BOTTOM_FRONT_CENTER,
|
||||
AV_CHAN_BOTTOM_FRONT_LEFT,
|
||||
AV_CHAN_BOTTOM_FRONT_RIGHT,
|
||||
AV_CHAN_SIDE_SURROUND_LEFT, ///< +90 degrees, Lss, SiL
|
||||
AV_CHAN_SIDE_SURROUND_RIGHT, ///< -90 degrees, Rss, SiR
|
||||
AV_CHAN_TOP_SURROUND_LEFT, ///< +110 degrees, Lvs, TpLS
|
||||
AV_CHAN_TOP_SURROUND_RIGHT, ///< -110 degrees, Rvs, TpRS
|
||||
|
||||
/** Channel is empty can be safely skipped. */
|
||||
AV_CHAN_UNUSED = 0x200,
|
||||
@@ -84,9 +94,9 @@ enum AVChannel {
|
||||
* 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.
|
||||
* 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
|
||||
@@ -113,7 +123,7 @@ enum AVChannelOrder {
|
||||
/**
|
||||
* 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)
|
||||
* layouts with 64 or more channels, or with empty/skipped (AV_CHAN_UNUSED)
|
||||
* channels at arbitrary positions.
|
||||
*/
|
||||
AV_CHANNEL_ORDER_CUSTOM,
|
||||
@@ -140,6 +150,10 @@ enum AVChannelOrder {
|
||||
* as defined in AmbiX format $ 2.1.
|
||||
*/
|
||||
AV_CHANNEL_ORDER_AMBISONIC,
|
||||
/**
|
||||
* Number of channel orders, not part of ABI/API
|
||||
*/
|
||||
FF_CHANNEL_ORDER_NB
|
||||
};
|
||||
|
||||
|
||||
@@ -185,16 +199,10 @@ enum AVChannelOrder {
|
||||
#define AV_CH_BOTTOM_FRONT_CENTER (1ULL << AV_CHAN_BOTTOM_FRONT_CENTER )
|
||||
#define AV_CH_BOTTOM_FRONT_LEFT (1ULL << AV_CHAN_BOTTOM_FRONT_LEFT )
|
||||
#define AV_CH_BOTTOM_FRONT_RIGHT (1ULL << AV_CHAN_BOTTOM_FRONT_RIGHT )
|
||||
|
||||
#if FF_API_OLD_CHANNEL_LAYOUT
|
||||
/** Channel mask value used for AVCodecContext.request_channel_layout
|
||||
to indicate that the user requests the channel order of the decoder output
|
||||
to be the native codec channel order.
|
||||
@deprecated channel order is now indicated in a special field in
|
||||
AVChannelLayout
|
||||
*/
|
||||
#define AV_CH_LAYOUT_NATIVE 0x8000000000000000ULL
|
||||
#endif
|
||||
#define AV_CH_SIDE_SURROUND_LEFT (1ULL << AV_CHAN_SIDE_SURROUND_LEFT )
|
||||
#define AV_CH_SIDE_SURROUND_RIGHT (1ULL << AV_CHAN_SIDE_SURROUND_RIGHT )
|
||||
#define AV_CH_TOP_SURROUND_LEFT (1ULL << AV_CHAN_TOP_SURROUND_LEFT )
|
||||
#define AV_CH_TOP_SURROUND_RIGHT (1ULL << AV_CHAN_TOP_SURROUND_RIGHT )
|
||||
|
||||
/**
|
||||
* @}
|
||||
@@ -218,6 +226,7 @@ enum AVChannelOrder {
|
||||
#define AV_CH_LAYOUT_6POINT0 (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_CENTER)
|
||||
#define AV_CH_LAYOUT_6POINT0_FRONT (AV_CH_LAYOUT_2_2|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
|
||||
#define AV_CH_LAYOUT_HEXAGONAL (AV_CH_LAYOUT_5POINT0_BACK|AV_CH_BACK_CENTER)
|
||||
#define AV_CH_LAYOUT_3POINT1POINT2 (AV_CH_LAYOUT_3POINT1|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT)
|
||||
#define AV_CH_LAYOUT_6POINT1 (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_CENTER)
|
||||
#define AV_CH_LAYOUT_6POINT1_BACK (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_BACK_CENTER)
|
||||
#define AV_CH_LAYOUT_6POINT1_FRONT (AV_CH_LAYOUT_6POINT0_FRONT|AV_CH_LOW_FREQUENCY)
|
||||
@@ -226,10 +235,19 @@ enum AVChannelOrder {
|
||||
#define AV_CH_LAYOUT_7POINT1 (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
|
||||
#define AV_CH_LAYOUT_7POINT1_WIDE (AV_CH_LAYOUT_5POINT1|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
|
||||
#define AV_CH_LAYOUT_7POINT1_WIDE_BACK (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
|
||||
#define AV_CH_LAYOUT_5POINT1POINT2_BACK (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT)
|
||||
#define AV_CH_LAYOUT_OCTAGONAL (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_CENTER|AV_CH_BACK_RIGHT)
|
||||
#define AV_CH_LAYOUT_CUBE (AV_CH_LAYOUT_QUAD|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT|AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_RIGHT)
|
||||
#define AV_CH_LAYOUT_5POINT1POINT4_BACK (AV_CH_LAYOUT_5POINT1POINT2_BACK|AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_RIGHT)
|
||||
#define AV_CH_LAYOUT_7POINT1POINT2 (AV_CH_LAYOUT_7POINT1|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT)
|
||||
#define AV_CH_LAYOUT_7POINT1POINT4_BACK (AV_CH_LAYOUT_7POINT1POINT2|AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_RIGHT)
|
||||
#define AV_CH_LAYOUT_7POINT2POINT3 (AV_CH_LAYOUT_7POINT1POINT2|AV_CH_TOP_BACK_CENTER|AV_CH_LOW_FREQUENCY_2)
|
||||
#define AV_CH_LAYOUT_9POINT1POINT4_BACK (AV_CH_LAYOUT_7POINT1POINT4_BACK|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
|
||||
#define AV_CH_LAYOUT_HEXADECAGONAL (AV_CH_LAYOUT_OCTAGONAL|AV_CH_WIDE_LEFT|AV_CH_WIDE_RIGHT|AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_RIGHT|AV_CH_TOP_BACK_CENTER|AV_CH_TOP_FRONT_CENTER|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT)
|
||||
#define AV_CH_LAYOUT_STEREO_DOWNMIX (AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT)
|
||||
#define AV_CH_LAYOUT_22POINT2 (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER|AV_CH_BACK_CENTER|AV_CH_LOW_FREQUENCY_2|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT|AV_CH_TOP_FRONT_CENTER|AV_CH_TOP_CENTER|AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_RIGHT|AV_CH_TOP_SIDE_LEFT|AV_CH_TOP_SIDE_RIGHT|AV_CH_TOP_BACK_CENTER|AV_CH_BOTTOM_FRONT_CENTER|AV_CH_BOTTOM_FRONT_LEFT|AV_CH_BOTTOM_FRONT_RIGHT)
|
||||
#define AV_CH_LAYOUT_22POINT2 (AV_CH_LAYOUT_7POINT1POINT4_BACK|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER|AV_CH_BACK_CENTER|AV_CH_LOW_FREQUENCY_2|AV_CH_TOP_FRONT_CENTER|AV_CH_TOP_CENTER|AV_CH_TOP_SIDE_LEFT|AV_CH_TOP_SIDE_RIGHT|AV_CH_TOP_BACK_CENTER|AV_CH_BOTTOM_FRONT_CENTER|AV_CH_BOTTOM_FRONT_LEFT|AV_CH_BOTTOM_FRONT_RIGHT)
|
||||
|
||||
#define AV_CH_LAYOUT_7POINT1_TOP_BACK AV_CH_LAYOUT_5POINT1POINT2_BACK
|
||||
|
||||
enum AVMatrixEncoding {
|
||||
AV_MATRIX_ENCODING_NONE,
|
||||
@@ -266,8 +284,11 @@ typedef struct AVChannelCustom {
|
||||
* A channel layout here is defined as a set of channels ordered in a specific
|
||||
* way (unless the channel order is AV_CHANNEL_ORDER_UNSPEC, in which case an
|
||||
* AVChannelLayout carries only the channel count).
|
||||
* All orders may be treated as if they were AV_CHANNEL_ORDER_UNSPEC by
|
||||
* ignoring everything but the channel count, as long as av_channel_layout_check()
|
||||
* considers they are valid.
|
||||
*
|
||||
* Unlike most structures in Libav, sizeof(AVChannelLayout) is a part of the
|
||||
* Unlike most structures in FFmpeg, sizeof(AVChannelLayout) is a part of the
|
||||
* public ABI and may be used by the caller. E.g. it may be allocated on stack
|
||||
* or embedded in caller-defined structs.
|
||||
*
|
||||
@@ -347,9 +368,21 @@ typedef struct AVChannelLayout {
|
||||
void *opaque;
|
||||
} AVChannelLayout;
|
||||
|
||||
/**
|
||||
* Macro to define native channel layouts
|
||||
*
|
||||
* @note This doesn't use designated initializers for compatibility with C++ 17 and older.
|
||||
*/
|
||||
#define AV_CHANNEL_LAYOUT_MASK(nb, m) \
|
||||
{ .order = AV_CHANNEL_ORDER_NATIVE, .nb_channels = (nb), .u = { .mask = (m) }}
|
||||
{ /* .order */ AV_CHANNEL_ORDER_NATIVE, \
|
||||
/* .nb_channels */ (nb), \
|
||||
/* .u.mask */ { m }, \
|
||||
/* .opaque */ NULL }
|
||||
|
||||
/**
|
||||
* @name Common pre-defined channel layouts
|
||||
* @{
|
||||
*/
|
||||
#define AV_CHANNEL_LAYOUT_MONO AV_CHANNEL_LAYOUT_MASK(1, AV_CH_LAYOUT_MONO)
|
||||
#define AV_CHANNEL_LAYOUT_STEREO AV_CHANNEL_LAYOUT_MASK(2, AV_CH_LAYOUT_STEREO)
|
||||
#define AV_CHANNEL_LAYOUT_2POINT1 AV_CHANNEL_LAYOUT_MASK(3, AV_CH_LAYOUT_2POINT1)
|
||||
@@ -366,6 +399,7 @@ typedef struct AVChannelLayout {
|
||||
#define AV_CHANNEL_LAYOUT_5POINT1_BACK AV_CHANNEL_LAYOUT_MASK(6, AV_CH_LAYOUT_5POINT1_BACK)
|
||||
#define AV_CHANNEL_LAYOUT_6POINT0 AV_CHANNEL_LAYOUT_MASK(6, AV_CH_LAYOUT_6POINT0)
|
||||
#define AV_CHANNEL_LAYOUT_6POINT0_FRONT AV_CHANNEL_LAYOUT_MASK(6, AV_CH_LAYOUT_6POINT0_FRONT)
|
||||
#define AV_CHANNEL_LAYOUT_3POINT1POINT2 AV_CHANNEL_LAYOUT_MASK(6, AV_CH_LAYOUT_3POINT1POINT2)
|
||||
#define AV_CHANNEL_LAYOUT_HEXAGONAL AV_CHANNEL_LAYOUT_MASK(6, AV_CH_LAYOUT_HEXAGONAL)
|
||||
#define AV_CHANNEL_LAYOUT_6POINT1 AV_CHANNEL_LAYOUT_MASK(7, AV_CH_LAYOUT_6POINT1)
|
||||
#define AV_CHANNEL_LAYOUT_6POINT1_BACK AV_CHANNEL_LAYOUT_MASK(7, AV_CH_LAYOUT_6POINT1_BACK)
|
||||
@@ -375,150 +409,36 @@ typedef struct AVChannelLayout {
|
||||
#define AV_CHANNEL_LAYOUT_7POINT1 AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_7POINT1)
|
||||
#define AV_CHANNEL_LAYOUT_7POINT1_WIDE AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_7POINT1_WIDE)
|
||||
#define AV_CHANNEL_LAYOUT_7POINT1_WIDE_BACK AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_7POINT1_WIDE_BACK)
|
||||
#define AV_CHANNEL_LAYOUT_5POINT1POINT2_BACK AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_5POINT1POINT2_BACK)
|
||||
#define AV_CHANNEL_LAYOUT_OCTAGONAL AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_OCTAGONAL)
|
||||
#define AV_CHANNEL_LAYOUT_CUBE AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_CUBE)
|
||||
#define AV_CHANNEL_LAYOUT_5POINT1POINT4_BACK AV_CHANNEL_LAYOUT_MASK(10, AV_CH_LAYOUT_5POINT1POINT4_BACK)
|
||||
#define AV_CHANNEL_LAYOUT_7POINT1POINT2 AV_CHANNEL_LAYOUT_MASK(10, AV_CH_LAYOUT_7POINT1POINT2)
|
||||
#define AV_CHANNEL_LAYOUT_7POINT1POINT4_BACK AV_CHANNEL_LAYOUT_MASK(12, AV_CH_LAYOUT_7POINT1POINT4_BACK)
|
||||
#define AV_CHANNEL_LAYOUT_7POINT2POINT3 AV_CHANNEL_LAYOUT_MASK(12, AV_CH_LAYOUT_7POINT2POINT3)
|
||||
#define AV_CHANNEL_LAYOUT_9POINT1POINT4_BACK AV_CHANNEL_LAYOUT_MASK(14, AV_CH_LAYOUT_9POINT1POINT4_BACK)
|
||||
#define AV_CHANNEL_LAYOUT_HEXADECAGONAL AV_CHANNEL_LAYOUT_MASK(16, AV_CH_LAYOUT_HEXADECAGONAL)
|
||||
#define AV_CHANNEL_LAYOUT_STEREO_DOWNMIX AV_CHANNEL_LAYOUT_MASK(2, AV_CH_LAYOUT_STEREO_DOWNMIX)
|
||||
#define AV_CHANNEL_LAYOUT_22POINT2 AV_CHANNEL_LAYOUT_MASK(24, AV_CH_LAYOUT_22POINT2)
|
||||
|
||||
#define AV_CHANNEL_LAYOUT_7POINT1_TOP_BACK AV_CHANNEL_LAYOUT_5POINT1POINT2_BACK
|
||||
|
||||
#define AV_CHANNEL_LAYOUT_AMBISONIC_FIRST_ORDER \
|
||||
{ .order = AV_CHANNEL_ORDER_AMBISONIC, .nb_channels = 4, .u = { .mask = 0 }}
|
||||
{ /* .order */ AV_CHANNEL_ORDER_AMBISONIC, \
|
||||
/* .nb_channels */ 4, \
|
||||
/* .u.mask */ { 0 }, \
|
||||
/* .opaque */ NULL }
|
||||
/** @} */
|
||||
|
||||
struct AVBPrint;
|
||||
|
||||
#if FF_API_OLD_CHANNEL_LAYOUT
|
||||
/**
|
||||
* Return a channel layout id that matches name, or 0 if no match is found.
|
||||
*
|
||||
* name can be one or several of the following notations,
|
||||
* separated by '+' or '|':
|
||||
* - the name of an usual channel layout (mono, stereo, 4.0, quad, 5.0,
|
||||
* 5.0(side), 5.1, 5.1(side), 7.1, 7.1(wide), downmix);
|
||||
* - the name of a single channel (FL, FR, FC, LFE, BL, BR, FLC, FRC, BC,
|
||||
* SL, SR, TC, TFL, TFC, TFR, TBL, TBC, TBR, DL, DR);
|
||||
* - a number of channels, in decimal, followed by 'c', yielding
|
||||
* the default channel layout for that number of channels (@see
|
||||
* av_get_default_channel_layout);
|
||||
* - a channel layout mask, in hexadecimal starting with "0x" (see the
|
||||
* AV_CH_* macros).
|
||||
*
|
||||
* Example: "stereo+FC" = "2c+FC" = "2c+1c" = "0x7"
|
||||
*
|
||||
* @deprecated use av_channel_layout_from_string()
|
||||
*/
|
||||
attribute_deprecated
|
||||
uint64_t av_get_channel_layout(const char *name);
|
||||
|
||||
/**
|
||||
* Return a channel layout and the number of channels based on the specified name.
|
||||
*
|
||||
* This function is similar to (@see av_get_channel_layout), but can also parse
|
||||
* unknown channel layout specifications.
|
||||
*
|
||||
* @param[in] name channel layout specification string
|
||||
* @param[out] channel_layout parsed channel layout (0 if unknown)
|
||||
* @param[out] nb_channels number of channels
|
||||
*
|
||||
* @return 0 on success, AVERROR(EINVAL) if the parsing fails.
|
||||
* @deprecated use av_channel_layout_from_string()
|
||||
*/
|
||||
attribute_deprecated
|
||||
int av_get_extended_channel_layout(const char *name, uint64_t* channel_layout, int* nb_channels);
|
||||
|
||||
/**
|
||||
* Return a description of a channel layout.
|
||||
* If nb_channels is <= 0, it is guessed from the channel_layout.
|
||||
*
|
||||
* @param buf put here the string containing the channel layout
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* Append a description of a channel layout to a bprint buffer.
|
||||
* @deprecated use av_channel_layout_describe()
|
||||
*/
|
||||
attribute_deprecated
|
||||
void av_bprint_channel_layout(struct AVBPrint *bp, int nb_channels, uint64_t channel_layout);
|
||||
|
||||
/**
|
||||
* Return the number of channels in the channel layout.
|
||||
* @deprecated use AVChannelLayout.nb_channels
|
||||
*/
|
||||
attribute_deprecated
|
||||
int av_get_channel_layout_nb_channels(uint64_t channel_layout);
|
||||
|
||||
/**
|
||||
* Return default channel layout for a given number of channels.
|
||||
*
|
||||
* @deprecated use av_channel_layout_default()
|
||||
*/
|
||||
attribute_deprecated
|
||||
int64_t av_get_default_channel_layout(int nb_channels);
|
||||
|
||||
/**
|
||||
* Get the index of a channel in channel_layout.
|
||||
*
|
||||
* @param channel a channel layout describing exactly one channel which must be
|
||||
* present in channel_layout.
|
||||
*
|
||||
* @return index of channel in channel_layout on success, a negative AVERROR
|
||||
* on error.
|
||||
*
|
||||
* @deprecated use av_channel_layout_index_from_channel()
|
||||
*/
|
||||
attribute_deprecated
|
||||
int av_get_channel_layout_channel_index(uint64_t channel_layout,
|
||||
uint64_t channel);
|
||||
|
||||
/**
|
||||
* Get the channel with the given index in channel_layout.
|
||||
* @deprecated use av_channel_layout_channel_from_index()
|
||||
*/
|
||||
attribute_deprecated
|
||||
uint64_t av_channel_layout_extract_channel(uint64_t channel_layout, int index);
|
||||
|
||||
/**
|
||||
* Get the name of a given channel.
|
||||
*
|
||||
* @return channel name on success, NULL on error.
|
||||
*
|
||||
* @deprecated use av_channel_name()
|
||||
*/
|
||||
attribute_deprecated
|
||||
const char *av_get_channel_name(uint64_t channel);
|
||||
|
||||
/**
|
||||
* Get the description of a given channel.
|
||||
*
|
||||
* @param channel a channel layout with a single channel
|
||||
* @return channel description on success, NULL on error
|
||||
* @deprecated use av_channel_description()
|
||||
*/
|
||||
attribute_deprecated
|
||||
const char *av_get_channel_description(uint64_t channel);
|
||||
|
||||
/**
|
||||
* Get the value and name of a standard channel layout.
|
||||
*
|
||||
* @param[in] index index in an internal list, starting at 0
|
||||
* @param[out] layout channel layout mask
|
||||
* @param[out] name name of the layout
|
||||
* @return 0 if the layout exists,
|
||||
* <0 if index is beyond the limits
|
||||
* @deprecated use av_channel_layout_standard()
|
||||
*/
|
||||
attribute_deprecated
|
||||
int av_get_standard_channel_layout(unsigned index, uint64_t *layout,
|
||||
const char **name);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Get a human readable string in an abbreviated form describing a given channel.
|
||||
* This is the inverse function of @ref av_channel_from_string().
|
||||
*
|
||||
* @param buf pre-allocated buffer where to put the generated string
|
||||
* @param buf_size size in bytes of the buffer.
|
||||
* @param channel the AVChannel whose name to get
|
||||
* @return amount of bytes needed to hold the output string, or a negative AVERROR
|
||||
* on failure. If the returned value is bigger than buf_size, then the
|
||||
* string was truncated.
|
||||
@@ -537,6 +457,7 @@ void av_channel_name_bprint(struct AVBPrint *bp, enum AVChannel channel_id);
|
||||
*
|
||||
* @param buf pre-allocated buffer where to put the generated string
|
||||
* @param buf_size size in bytes of the buffer.
|
||||
* @param channel the AVChannel whose description to get
|
||||
* @return amount of bytes needed to hold the output string, or a negative AVERROR
|
||||
* on failure. If the returned value is bigger than buf_size, then the
|
||||
* string was truncated.
|
||||
@@ -558,6 +479,23 @@ void av_channel_description_bprint(struct AVBPrint *bp, enum AVChannel channel_i
|
||||
*/
|
||||
enum AVChannel av_channel_from_string(const char *name);
|
||||
|
||||
/**
|
||||
* Initialize a custom channel layout with the specified number of channels.
|
||||
* The channel map will be allocated and the designation of all channels will
|
||||
* be set to AV_CHAN_UNKNOWN.
|
||||
*
|
||||
* This is only a convenience helper function, a custom channel layout can also
|
||||
* be constructed without using this.
|
||||
*
|
||||
* @param channel_layout the layout structure to be initialized
|
||||
* @param nb_channels the number of channels
|
||||
*
|
||||
* @return 0 on success
|
||||
* AVERROR(EINVAL) if the number of channels <= 0
|
||||
* AVERROR(ENOMEM) if the channel map could not be allocated
|
||||
*/
|
||||
int av_channel_layout_custom_init(AVChannelLayout *channel_layout, int nb_channels);
|
||||
|
||||
/**
|
||||
* Initialize a native channel layout from a bitmask indicating which channels
|
||||
* are present.
|
||||
@@ -582,10 +520,14 @@ int av_channel_layout_from_mask(AVChannelLayout *channel_layout, uint64_t mask);
|
||||
* - the number of unordered channels (eg. "4C" or "4 channels")
|
||||
* - the ambisonic order followed by optional non-diegetic channels (eg.
|
||||
* "ambisonic 2+stereo")
|
||||
* On error, the channel layout will remain uninitialized, but not necessarily
|
||||
* untouched.
|
||||
*
|
||||
* @param channel_layout input channel layout
|
||||
* @param channel_layout uninitialized channel layout for the result
|
||||
* @param str string describing the channel layout
|
||||
* @return 0 channel layout was detected, AVERROR_INVALIDATATA otherwise
|
||||
* @return 0 on success parsing the channel layout
|
||||
* AVERROR(EINVAL) if an invalid channel layout string was provided
|
||||
* AVERROR(ENOMEM) if there was not enough memory
|
||||
*/
|
||||
int av_channel_layout_from_string(AVChannelLayout *channel_layout,
|
||||
const char *str);
|
||||
@@ -593,7 +535,7 @@ int av_channel_layout_from_string(AVChannelLayout *channel_layout,
|
||||
/**
|
||||
* Get the default channel layout for a given number of channels.
|
||||
*
|
||||
* @param channel_layout the layout structure to be initialized
|
||||
* @param ch_layout the layout structure to be initialized
|
||||
* @param nb_channels number of channels
|
||||
*/
|
||||
void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels);
|
||||
@@ -658,6 +600,7 @@ int av_channel_layout_describe_bprint(const AVChannelLayout *channel_layout,
|
||||
* Get the channel with the given index in a channel layout.
|
||||
*
|
||||
* @param channel_layout input channel layout
|
||||
* @param idx index of the channel
|
||||
* @return channel with the index idx in channel_layout on success or
|
||||
* AV_CHAN_NONE on failure (if idx is not valid or the channel order is
|
||||
* unspecified)
|
||||
@@ -670,6 +613,7 @@ av_channel_layout_channel_from_index(const AVChannelLayout *channel_layout, unsi
|
||||
* channels are found, only the first match will be returned.
|
||||
*
|
||||
* @param channel_layout input channel layout
|
||||
* @param channel the channel whose index to obtain
|
||||
* @return index of channel in channel_layout on success or a negative number if
|
||||
* channel is not present in channel_layout.
|
||||
*/
|
||||
@@ -684,6 +628,7 @@ int av_channel_layout_index_from_channel(const AVChannelLayout *channel_layout,
|
||||
* @ref av_channel_from_string().
|
||||
*
|
||||
* @param channel_layout input channel layout
|
||||
* @param name string describing the channel whose index to obtain
|
||||
* @return a channel index described by the given string, or a negative AVERROR
|
||||
* value.
|
||||
*/
|
||||
@@ -697,6 +642,7 @@ int av_channel_layout_index_from_string(const AVChannelLayout *channel_layout,
|
||||
* @ref av_channel_from_string().
|
||||
*
|
||||
* @param channel_layout input channel layout
|
||||
* @param name string describing the channel to obtain
|
||||
* @return a channel described by the given string in channel_layout on success
|
||||
* or AV_CHAN_NONE on failure (if the string is not valid or the channel
|
||||
* order is unspecified)
|
||||
@@ -742,7 +688,63 @@ int av_channel_layout_check(const AVChannelLayout *channel_layout);
|
||||
int av_channel_layout_compare(const AVChannelLayout *chl, const AVChannelLayout *chl1);
|
||||
|
||||
/**
|
||||
* @}
|
||||
* Return the order if the layout is n-th order standard-order ambisonic.
|
||||
* The presence of optional extra non-diegetic channels at the end is not taken
|
||||
* into account.
|
||||
*
|
||||
* @param channel_layout input channel layout
|
||||
* @return the order of the layout, a negative error code otherwise.
|
||||
*/
|
||||
int av_channel_layout_ambisonic_order(const AVChannelLayout *channel_layout);
|
||||
|
||||
/**
|
||||
* The conversion must be lossless.
|
||||
*/
|
||||
#define AV_CHANNEL_LAYOUT_RETYPE_FLAG_LOSSLESS (1 << 0)
|
||||
|
||||
/**
|
||||
* The specified retype target order is ignored and the simplest possible
|
||||
* (canonical) order is used for which the input layout can be losslessy
|
||||
* represented.
|
||||
*/
|
||||
#define AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL (1 << 1)
|
||||
|
||||
/**
|
||||
* Change the AVChannelOrder of a channel layout.
|
||||
*
|
||||
* Change of AVChannelOrder can be either lossless or lossy. In case of a
|
||||
* lossless conversion all the channel designations and the associated channel
|
||||
* names (if any) are kept. On a lossy conversion the channel names and channel
|
||||
* designations might be lost depending on the capabilities of the desired
|
||||
* AVChannelOrder. Note that some conversions are simply not possible in which
|
||||
* case this function returns AVERROR(ENOSYS).
|
||||
*
|
||||
* The following conversions are supported:
|
||||
*
|
||||
* Any -> Custom : Always possible, always lossless.
|
||||
* Any -> Unspecified: Always possible, lossless if channel designations
|
||||
* are all unknown and channel names are not used, lossy otherwise.
|
||||
* Custom -> Ambisonic : Possible if it contains ambisonic channels with
|
||||
* optional non-diegetic channels in the end. Lossy if the channels have
|
||||
* custom names, lossless otherwise.
|
||||
* Custom -> Native : Possible if it contains native channels in native
|
||||
* order. Lossy if the channels have custom names, lossless otherwise.
|
||||
*
|
||||
* On error this function keeps the original channel layout untouched.
|
||||
*
|
||||
* @param channel_layout channel layout which will be changed
|
||||
* @param order the desired channel layout order
|
||||
* @param flags a combination of AV_CHANNEL_LAYOUT_RETYPE_FLAG_* constants
|
||||
* @return 0 if the conversion was successful and lossless or if the channel
|
||||
* layout was already in the desired order
|
||||
* >0 if the conversion was successful but lossy
|
||||
* AVERROR(ENOSYS) if the conversion was not possible (or would be
|
||||
* lossy and AV_CHANNEL_LAYOUT_RETYPE_FLAG_LOSSLESS was specified)
|
||||
* AVERROR(EINVAL), AVERROR(ENOMEM) on error
|
||||
*/
|
||||
int av_channel_layout_retype(AVChannelLayout *channel_layout, enum AVChannelOrder order, int flags);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
@@ -40,7 +40,17 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "attributes.h"
|
||||
#include "error.h"
|
||||
#include "macros.h"
|
||||
#include "version.h"
|
||||
|
||||
#ifdef HAVE_AV_CONFIG_H
|
||||
# include "config.h"
|
||||
# include "intmath.h"
|
||||
# include "internal.h"
|
||||
#else
|
||||
# include "mem.h"
|
||||
#endif /* HAVE_AV_CONFIG_H */
|
||||
|
||||
//rounded division & shift
|
||||
#define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b))
|
||||
@@ -83,11 +93,6 @@
|
||||
|
||||
/* misc math functions */
|
||||
|
||||
#ifdef HAVE_AV_CONFIG_H
|
||||
# include "config.h"
|
||||
# include "intmath.h"
|
||||
#endif
|
||||
|
||||
#ifndef av_ceil_log2
|
||||
# define av_ceil_log2 av_ceil_log2_c
|
||||
#endif
|
||||
@@ -118,9 +123,6 @@
|
||||
#ifndef av_clip_uintp2
|
||||
# define av_clip_uintp2 av_clip_uintp2_c
|
||||
#endif
|
||||
#ifndef av_mod_uintp2
|
||||
# define av_mod_uintp2 av_mod_uintp2_c
|
||||
#endif
|
||||
#ifndef av_sat_add32
|
||||
# define av_sat_add32 av_sat_add32_c
|
||||
#endif
|
||||
@@ -145,6 +147,9 @@
|
||||
#ifndef av_clipd
|
||||
# define av_clipd av_clipd_c
|
||||
#endif
|
||||
#ifndef av_zero_extend
|
||||
# define av_zero_extend av_zero_extend_c
|
||||
#endif
|
||||
#ifndef av_popcount
|
||||
# define av_popcount av_popcount_c
|
||||
#endif
|
||||
@@ -248,8 +253,8 @@ static av_always_inline av_const int16_t av_clip_int16_c(int a)
|
||||
*/
|
||||
static av_always_inline av_const int32_t av_clipl_int32_c(int64_t a)
|
||||
{
|
||||
if ((a+0x80000000u) & ~UINT64_C(0xFFFFFFFF)) return (int32_t)((a>>63) ^ 0x7FFFFFFF);
|
||||
else return (int32_t)a;
|
||||
if ((a+UINT64_C(0x80000000)) & ~UINT64_C(0xFFFFFFFF)) return (int32_t)((a>>63) ^ 0x7FFFFFFF);
|
||||
else return (int32_t)a;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -260,7 +265,7 @@ static av_always_inline av_const int32_t av_clipl_int32_c(int64_t a)
|
||||
*/
|
||||
static av_always_inline av_const int av_clip_intp2_c(int a, int p)
|
||||
{
|
||||
if (((unsigned)a + (1 << p)) & ~((2 << p) - 1))
|
||||
if (((unsigned)a + (1U << p)) & ~((2U << p) - 1))
|
||||
return (a >> 31) ^ ((1 << p) - 1);
|
||||
else
|
||||
return a;
|
||||
@@ -274,21 +279,35 @@ static av_always_inline av_const int av_clip_intp2_c(int a, int p)
|
||||
*/
|
||||
static av_always_inline av_const unsigned av_clip_uintp2_c(int a, int p)
|
||||
{
|
||||
if (a & ~((1<<p) - 1)) return (~a) >> 31 & ((1<<p) - 1);
|
||||
else return a;
|
||||
if (a & ~((1U<<p) - 1)) return (~a) >> 31 & ((1U<<p) - 1);
|
||||
else return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear high bits from an unsigned integer starting with specific bit position
|
||||
* @param a value to clip
|
||||
* @param p bit position to clip at
|
||||
* @param p bit position to clip at. Must be between 0 and 31.
|
||||
* @return clipped value
|
||||
*/
|
||||
static av_always_inline av_const unsigned av_mod_uintp2_c(unsigned a, unsigned p)
|
||||
static av_always_inline av_const unsigned av_zero_extend_c(unsigned a, unsigned p)
|
||||
{
|
||||
#if defined(HAVE_AV_CONFIG_H) && defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2
|
||||
if (p > 31) abort();
|
||||
#endif
|
||||
return a & ((1U << p) - 1);
|
||||
}
|
||||
|
||||
#if FF_API_MOD_UINTP2
|
||||
#ifndef av_mod_uintp2
|
||||
# define av_mod_uintp2 av_mod_uintp2_c
|
||||
#endif
|
||||
attribute_deprecated
|
||||
static av_always_inline av_const unsigned av_mod_uintp2_c(unsigned a, unsigned p)
|
||||
{
|
||||
return av_zero_extend_c(a, p);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Add two signed 32-bit values with saturation.
|
||||
*
|
||||
@@ -567,12 +586,4 @@ static av_always_inline av_const int av_parity_c(uint32_t v)
|
||||
}\
|
||||
}\
|
||||
|
||||
|
||||
|
||||
#include "mem.h"
|
||||
|
||||
#ifdef HAVE_AV_CONFIG_H
|
||||
# include "internal.h"
|
||||
#endif /* HAVE_AV_CONFIG_H */
|
||||
|
||||
#endif /* AVUTIL_COMMON_H */
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#define AVUTIL_CPU_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include "version.h"
|
||||
|
||||
#define AV_CPU_FLAG_FORCE 0x80000000 /* force usage of selected flags (OR) */
|
||||
|
||||
@@ -69,6 +70,8 @@
|
||||
#define AV_CPU_FLAG_NEON (1 << 5)
|
||||
#define AV_CPU_FLAG_ARMV8 (1 << 6)
|
||||
#define AV_CPU_FLAG_VFP_VM (1 << 7) ///< VFPv2 vector mode, deprecated in ARMv7-A and unavailable in various CPUs implementations
|
||||
#define AV_CPU_FLAG_DOTPROD (1 << 8)
|
||||
#define AV_CPU_FLAG_I8MM (1 << 9)
|
||||
#define AV_CPU_FLAG_SETEND (1 <<16)
|
||||
|
||||
#define AV_CPU_FLAG_MMI (1 << 0)
|
||||
@@ -78,6 +81,24 @@
|
||||
#define AV_CPU_FLAG_LSX (1 << 0)
|
||||
#define AV_CPU_FLAG_LASX (1 << 1)
|
||||
|
||||
// RISC-V extensions
|
||||
#define AV_CPU_FLAG_RVI (1 << 0) ///< I (full GPR bank)
|
||||
#if FF_API_RISCV_FD_ZBA
|
||||
#define AV_CPU_FLAG_RVF (1 << 1) ///< F (single precision FP)
|
||||
#define AV_CPU_FLAG_RVD (1 << 2) ///< D (double precision FP)
|
||||
#endif
|
||||
#define AV_CPU_FLAG_RVV_I32 (1 << 3) ///< Vectors of 8/16/32-bit int's */
|
||||
#define AV_CPU_FLAG_RVV_F32 (1 << 4) ///< Vectors of float's */
|
||||
#define AV_CPU_FLAG_RVV_I64 (1 << 5) ///< Vectors of 64-bit int's */
|
||||
#define AV_CPU_FLAG_RVV_F64 (1 << 6) ///< Vectors of double's
|
||||
#define AV_CPU_FLAG_RVB_BASIC (1 << 7) ///< Basic bit-manipulations
|
||||
#if FF_API_RISCV_FD_ZBA
|
||||
#define AV_CPU_FLAG_RVB_ADDR (1 << 8) ///< Address bit-manipulations
|
||||
#endif
|
||||
#define AV_CPU_FLAG_RV_ZVBB (1 << 9) ///< Vector basic bit-manipulations
|
||||
#define AV_CPU_FLAG_RV_MISALIGNED (1 <<10) ///< Fast misaligned accesses
|
||||
#define AV_CPU_FLAG_RVB (1 <<11) ///< B (bit manipulations)
|
||||
|
||||
/**
|
||||
* Return the flags which specify extensions supported by the CPU.
|
||||
* The returned value is affected by av_force_cpu_flags() if that was used
|
||||
|
||||
@@ -84,7 +84,10 @@ const AVCRC *av_crc_get_table(AVCRCId crc_id);
|
||||
|
||||
/**
|
||||
* Calculate the CRC of a block.
|
||||
* @param ctx initialized AVCRC array (see av_crc_init())
|
||||
* @param crc CRC of previous blocks if any or initial value for CRC
|
||||
* @param buffer buffer whose CRC to calculate
|
||||
* @param length length of the buffer
|
||||
* @return CRC updated with the data from the given block
|
||||
*
|
||||
* @see av_crc_init() "le" parameter
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Kevin Wheatley <kevin.j.wheatley@gmail.com>
|
||||
* Copyright (c) 2016 Ronald S. Bultje <rsbultje@gmail.com>
|
||||
* Copyright (c) 2023 Leo Izen <leo.izen@gmail.com>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
@@ -24,9 +27,15 @@
|
||||
#include "rational.h"
|
||||
|
||||
/**
|
||||
* @file Colorspace value utility functions for libavutil.
|
||||
* @file
|
||||
* Colorspace value utility functions for libavutil.
|
||||
* @ingroup lavu_math_csp
|
||||
* @author Ronald S. Bultje <rsbultje@gmail.com>
|
||||
* @author Leo Izen <leo.izen@gmail.com>
|
||||
* @author Kevin Wheatley <kevin.j.wheatley@gmail.com>
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup lavu_math_csp Colorspace Utility
|
||||
* @ingroup lavu_math
|
||||
* @{
|
||||
@@ -71,6 +80,12 @@ typedef struct AVColorPrimariesDesc {
|
||||
AVPrimaryCoefficients prim;
|
||||
} AVColorPrimariesDesc;
|
||||
|
||||
/**
|
||||
* Function pointer representing a double -> double transfer function that performs
|
||||
* an EOTF transfer inversion. This function outputs linear light.
|
||||
*/
|
||||
typedef double (*av_csp_trc_function)(double);
|
||||
|
||||
/**
|
||||
* Retrieves the Luma coefficients necessary to construct a conversion matrix
|
||||
* from an enum constant describing the colorspace.
|
||||
@@ -99,6 +114,35 @@ const AVColorPrimariesDesc *av_csp_primaries_desc_from_id(enum AVColorPrimaries
|
||||
*/
|
||||
enum AVColorPrimaries av_csp_primaries_id_from_desc(const AVColorPrimariesDesc *prm);
|
||||
|
||||
/**
|
||||
* Determine a suitable 'gamma' value to match the supplied
|
||||
* AVColorTransferCharacteristic.
|
||||
*
|
||||
* See Apple Technical Note TN2257 (https://developer.apple.com/library/mac/technotes/tn2257/_index.html)
|
||||
*
|
||||
* This function returns the gamma exponent for the OETF. For example, sRGB is approximated
|
||||
* by gamma 2.2, not by gamma 0.45455.
|
||||
*
|
||||
* @return Will return an approximation to the simple gamma function matching
|
||||
* the supplied Transfer Characteristic, Will return 0.0 for any
|
||||
* we cannot reasonably match against.
|
||||
*/
|
||||
double av_csp_approximate_trc_gamma(enum AVColorTransferCharacteristic trc);
|
||||
|
||||
/**
|
||||
* Determine the function needed to apply the given
|
||||
* AVColorTransferCharacteristic to linear input.
|
||||
*
|
||||
* The function returned should expect a nominal domain and range of [0.0-1.0]
|
||||
* values outside of this range maybe valid depending on the chosen
|
||||
* characteristic function.
|
||||
*
|
||||
* @return Will return pointer to the function matching the
|
||||
* supplied Transfer Characteristic. If unspecified will
|
||||
* return NULL:
|
||||
*/
|
||||
av_csp_trc_function av_csp_trc_func_from_id(enum AVColorTransferCharacteristic trc);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
@@ -43,6 +43,8 @@ AVDES *av_des_alloc(void);
|
||||
/**
|
||||
* @brief Initializes an AVDES context.
|
||||
*
|
||||
* @param d pointer to a AVDES structure to initialize
|
||||
* @param key pointer to the key to use
|
||||
* @param key_bits must be 64 or 192
|
||||
* @param decrypt 0 for encryption/CBC-MAC, 1 for decryption
|
||||
* @return zero on success, negative value otherwise
|
||||
@@ -52,9 +54,10 @@ int av_des_init(struct AVDES *d, const uint8_t *key, int key_bits, int decrypt);
|
||||
/**
|
||||
* @brief Encrypts / decrypts using the DES algorithm.
|
||||
*
|
||||
* @param count number of 8 byte blocks
|
||||
* @param d pointer to the AVDES structure
|
||||
* @param dst destination array, can be equal to src, must be 8-byte aligned
|
||||
* @param src source array, can be equal to dst, must be 8-byte aligned, may be NULL
|
||||
* @param count number of 8 byte blocks
|
||||
* @param iv initialization vector for CBC mode, if NULL then ECB will be used,
|
||||
* must be 8-byte aligned
|
||||
* @param decrypt 0 for encryption, 1 for decryption
|
||||
@@ -64,9 +67,10 @@ void av_des_crypt(struct AVDES *d, uint8_t *dst, const uint8_t *src, int count,
|
||||
/**
|
||||
* @brief Calculates CBC-MAC using the DES algorithm.
|
||||
*
|
||||
* @param count number of 8 byte blocks
|
||||
* @param d pointer to the AVDES structure
|
||||
* @param dst destination array, can be equal to src, must be 8-byte aligned
|
||||
* @param src source array, can be equal to dst, must be 8-byte aligned, may be NULL
|
||||
* @param count number of 8 byte blocks
|
||||
*/
|
||||
void av_des_mac(struct AVDES *d, uint8_t *dst, const uint8_t *src, int count);
|
||||
|
||||
|
||||
@@ -93,6 +93,7 @@ av_get_detection_bbox(const AVDetectionBBoxHeader *header, unsigned int idx)
|
||||
* AVDetectionBBox, and initializes the variables.
|
||||
* Can be freed with a normal av_free() call.
|
||||
*
|
||||
* @param nb_bboxes number of AVDetectionBBox structures to allocate
|
||||
* @param out_size if non-NULL, the size in bytes of the resulting data array is
|
||||
* written here.
|
||||
*/
|
||||
|
||||
@@ -39,13 +39,15 @@
|
||||
* @brief Simple key:value store
|
||||
*
|
||||
* @{
|
||||
* Dictionaries are used for storing key:value pairs. To create
|
||||
* an AVDictionary, simply pass an address of a NULL pointer to
|
||||
* av_dict_set(). NULL can be used as an empty dictionary wherever
|
||||
* a pointer to an AVDictionary is required.
|
||||
* Use av_dict_get() to retrieve an entry or iterate over all
|
||||
* entries and finally av_dict_free() to free the dictionary
|
||||
* and all its contents.
|
||||
* Dictionaries are used for storing key-value pairs.
|
||||
*
|
||||
* - To **create an AVDictionary**, simply pass an address of a NULL
|
||||
* pointer to av_dict_set(). NULL can be used as an empty dictionary
|
||||
* wherever a pointer to an AVDictionary is required.
|
||||
* - To **insert an entry**, use av_dict_set().
|
||||
* - Use av_dict_get() to **retrieve an entry**.
|
||||
* - To **iterate over all entries**, use av_dict_iterate().
|
||||
* - In order to **free the dictionary and all its contents**, use av_dict_free().
|
||||
*
|
||||
@code
|
||||
AVDictionary *d = NULL; // "create" an empty dictionary
|
||||
@@ -57,13 +59,18 @@
|
||||
char *v = av_strdup("value"); // you can avoid copying them like this
|
||||
av_dict_set(&d, k, v, AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL);
|
||||
|
||||
while (t = av_dict_get(d, "", t, AV_DICT_IGNORE_SUFFIX)) {
|
||||
<....> // iterate over all entries in d
|
||||
while ((t = av_dict_iterate(d, t))) {
|
||||
<....> // iterate over all entries in d
|
||||
}
|
||||
av_dict_free(&d);
|
||||
@endcode
|
||||
*/
|
||||
|
||||
/**
|
||||
* @name AVDictionary Flags
|
||||
* Flags that influence behavior of the matching of keys or insertion to the dictionary.
|
||||
* @{
|
||||
*/
|
||||
#define AV_DICT_MATCH_CASE 1 /**< Only get an entry with exact-case key match. Only relevant in av_dict_get(). */
|
||||
#define AV_DICT_IGNORE_SUFFIX 2 /**< Return first entry in a dictionary whose first part corresponds to the search key,
|
||||
ignoring the suffix of the found key string. Only relevant in av_dict_get(). */
|
||||
@@ -71,10 +78,13 @@
|
||||
allocated with av_malloc() or another memory allocation function. */
|
||||
#define AV_DICT_DONT_STRDUP_VAL 8 /**< Take ownership of a value that's been
|
||||
allocated with av_malloc() or another memory allocation function. */
|
||||
#define AV_DICT_DONT_OVERWRITE 16 ///< Don't overwrite existing entries.
|
||||
#define AV_DICT_DONT_OVERWRITE 16 /**< Don't overwrite existing entries. */
|
||||
#define AV_DICT_APPEND 32 /**< If the entry already exists, append to it. Note that no
|
||||
delimiter is added, the strings are simply concatenated. */
|
||||
delimiter is added, the strings are simply concatenated. */
|
||||
#define AV_DICT_MULTIKEY 64 /**< Allow to store several equal keys in the dictionary */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
typedef struct AVDictionaryEntry {
|
||||
char *key;
|
||||
@@ -89,18 +99,44 @@ typedef struct AVDictionary AVDictionary;
|
||||
* The returned entry key or value must not be changed, or it will
|
||||
* cause undefined behavior.
|
||||
*
|
||||
* To iterate through all the dictionary entries, you can set the matching key
|
||||
* to the null string "" and set the AV_DICT_IGNORE_SUFFIX flag.
|
||||
* @param prev Set to the previous matching element to find the next.
|
||||
* If set to NULL the first matching element is returned.
|
||||
* @param key Matching key
|
||||
* @param flags A collection of AV_DICT_* flags controlling how the
|
||||
* entry is retrieved
|
||||
*
|
||||
* @param prev Set to the previous matching element to find the next.
|
||||
* If set to NULL the first matching element is returned.
|
||||
* @param key matching key
|
||||
* @param flags a collection of AV_DICT_* flags controlling how the entry is retrieved
|
||||
* @return found entry or NULL in case no matching entry was found in the dictionary
|
||||
* @return Found entry or NULL in case no matching entry was found in the dictionary
|
||||
*/
|
||||
AVDictionaryEntry *av_dict_get(const AVDictionary *m, const char *key,
|
||||
const AVDictionaryEntry *prev, int flags);
|
||||
|
||||
/**
|
||||
* Iterate over a dictionary
|
||||
*
|
||||
* Iterates through all entries in the dictionary.
|
||||
*
|
||||
* @warning The returned AVDictionaryEntry key/value must not be changed.
|
||||
*
|
||||
* @warning As av_dict_set() invalidates all previous entries returned
|
||||
* by this function, it must not be called while iterating over the dict.
|
||||
*
|
||||
* Typical usage:
|
||||
* @code
|
||||
* const AVDictionaryEntry *e = NULL;
|
||||
* while ((e = av_dict_iterate(m, e))) {
|
||||
* // ...
|
||||
* }
|
||||
* @endcode
|
||||
*
|
||||
* @param m The dictionary to iterate over
|
||||
* @param prev Pointer to the previous AVDictionaryEntry, NULL initially
|
||||
*
|
||||
* @retval AVDictionaryEntry* The next element in the dictionary
|
||||
* @retval NULL No more elements in the dictionary
|
||||
*/
|
||||
const AVDictionaryEntry *av_dict_iterate(const AVDictionary *m,
|
||||
const AVDictionaryEntry *prev);
|
||||
|
||||
/**
|
||||
* Get number of entries in dictionary.
|
||||
*
|
||||
@@ -115,23 +151,24 @@ int av_dict_count(const AVDictionary *m);
|
||||
* Note: If AV_DICT_DONT_STRDUP_KEY or AV_DICT_DONT_STRDUP_VAL is set,
|
||||
* these arguments will be freed on error.
|
||||
*
|
||||
* Warning: Adding a new entry to a dictionary invalidates all existing entries
|
||||
* previously returned with av_dict_get.
|
||||
* @warning Adding a new entry to a dictionary invalidates all existing entries
|
||||
* previously returned with av_dict_get() or av_dict_iterate().
|
||||
*
|
||||
* @param pm pointer to a pointer to a dictionary struct. If *pm is NULL
|
||||
* a dictionary struct is allocated and put in *pm.
|
||||
* @param key entry key to add to *pm (will either be av_strduped or added as a new key depending on flags)
|
||||
* @param value entry value to add to *pm (will be av_strduped or added as a new key depending on flags).
|
||||
* Passing a NULL value will cause an existing entry to be deleted.
|
||||
* @return >= 0 on success otherwise an error code <0
|
||||
* @param pm Pointer to a pointer to a dictionary struct. If *pm is NULL
|
||||
* a dictionary struct is allocated and put in *pm.
|
||||
* @param key Entry key to add to *pm (will either be av_strduped or added as a new key depending on flags)
|
||||
* @param value Entry value to add to *pm (will be av_strduped or added as a new key depending on flags).
|
||||
* Passing a NULL value will cause an existing entry to be deleted.
|
||||
*
|
||||
* @return >= 0 on success otherwise an error code <0
|
||||
*/
|
||||
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags);
|
||||
|
||||
/**
|
||||
* Convenience wrapper for av_dict_set that converts the value to a string
|
||||
* Convenience wrapper for av_dict_set() that converts the value to a string
|
||||
* and stores it.
|
||||
*
|
||||
* Note: If AV_DICT_DONT_STRDUP_KEY is set, key will be freed on error.
|
||||
* Note: If ::AV_DICT_DONT_STRDUP_KEY is set, key will be freed on error.
|
||||
*/
|
||||
int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int flags);
|
||||
|
||||
@@ -141,14 +178,15 @@ int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int flags
|
||||
* In case of failure, all the successfully set entries are stored in
|
||||
* *pm. You may need to manually free the created dictionary.
|
||||
*
|
||||
* @param key_val_sep a 0-terminated list of characters used to separate
|
||||
* @param key_val_sep A 0-terminated list of characters used to separate
|
||||
* key from value
|
||||
* @param pairs_sep a 0-terminated list of characters used to separate
|
||||
* @param pairs_sep A 0-terminated list of characters used to separate
|
||||
* two pairs from each other
|
||||
* @param flags flags to use when adding to dictionary.
|
||||
* AV_DICT_DONT_STRDUP_KEY and AV_DICT_DONT_STRDUP_VAL
|
||||
* @param flags Flags to use when adding to the dictionary.
|
||||
* ::AV_DICT_DONT_STRDUP_KEY and ::AV_DICT_DONT_STRDUP_VAL
|
||||
* are ignored since the key/value tokens will always
|
||||
* be duplicated.
|
||||
*
|
||||
* @return 0 on success, negative AVERROR code on failure
|
||||
*/
|
||||
int av_dict_parse_string(AVDictionary **pm, const char *str,
|
||||
@@ -157,11 +195,14 @@ int av_dict_parse_string(AVDictionary **pm, const char *str,
|
||||
|
||||
/**
|
||||
* Copy entries from one AVDictionary struct into another.
|
||||
* @param dst pointer to a pointer to a AVDictionary struct. If *dst is NULL,
|
||||
* this function will allocate a struct for you and put it in *dst
|
||||
* @param src pointer to source AVDictionary struct
|
||||
* @param flags flags to use when setting entries in *dst
|
||||
* @note metadata is read using the AV_DICT_IGNORE_SUFFIX flag
|
||||
*
|
||||
* @note Metadata is read using the ::AV_DICT_IGNORE_SUFFIX flag
|
||||
*
|
||||
* @param dst Pointer to a pointer to a AVDictionary struct to copy into. If *dst is NULL,
|
||||
* this function will allocate a struct for you and put it in *dst
|
||||
* @param src Pointer to the source AVDictionary struct to copy items from.
|
||||
* @param flags Flags to use when setting entries in *dst
|
||||
*
|
||||
* @return 0 on success, negative AVERROR code on failure. If dst was allocated
|
||||
* by this function, callers should free the associated memory.
|
||||
*/
|
||||
@@ -180,13 +221,15 @@ void av_dict_free(AVDictionary **m);
|
||||
* Such string may be passed back to av_dict_parse_string().
|
||||
* @note String is escaped with backslashes ('\').
|
||||
*
|
||||
* @param[in] m dictionary
|
||||
* @warning Separators cannot be neither '\\' nor '\0'. They also cannot be the same.
|
||||
*
|
||||
* @param[in] m The dictionary
|
||||
* @param[out] buffer Pointer to buffer that will be allocated with string containg entries.
|
||||
* Buffer must be freed by the caller when is no longer needed.
|
||||
* @param[in] key_val_sep character used to separate key from value
|
||||
* @param[in] pairs_sep character used to separate two pairs from each other
|
||||
* @param[in] key_val_sep Character used to separate key from value
|
||||
* @param[in] pairs_sep Character used to separate two pairs from each other
|
||||
*
|
||||
* @return >= 0 on success, negative on error
|
||||
* @warning Separators cannot be neither '\\' nor '\0'. They also cannot be the same.
|
||||
*/
|
||||
int av_dict_get_string(const AVDictionary *m, char **buffer,
|
||||
const char key_val_sep, const char pairs_sep);
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavu_video_display
|
||||
* Display matrix
|
||||
*/
|
||||
|
||||
@@ -29,15 +30,9 @@
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_video
|
||||
* @{
|
||||
*
|
||||
* @defgroup lavu_video_display Display transformation matrix functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_video_display
|
||||
* @ingroup lavu_video
|
||||
*
|
||||
* The display transformation matrix specifies an affine transformation that
|
||||
* should be applied to video frames for correct presentation. It is compatible
|
||||
* with the matrices stored in the ISO/IEC 14496-12 container format.
|
||||
@@ -71,6 +66,8 @@
|
||||
* q' = (b * p + d * q + y) / z;
|
||||
* z = u * p + v * q + w
|
||||
* @endcode
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -90,8 +87,8 @@ double av_display_rotation_get(const int32_t matrix[9]);
|
||||
* Initialize a transformation matrix describing a pure clockwise
|
||||
* rotation by the specified angle (in degrees).
|
||||
*
|
||||
* @param matrix an allocated transformation matrix (will be fully overwritten
|
||||
* by this function)
|
||||
* @param[out] matrix a transformation matrix (will be fully overwritten
|
||||
* by this function)
|
||||
* @param angle rotation angle in degrees.
|
||||
*/
|
||||
void av_display_rotation_set(int32_t matrix[9], double angle);
|
||||
@@ -99,14 +96,13 @@ void av_display_rotation_set(int32_t matrix[9], double angle);
|
||||
/**
|
||||
* Flip the input matrix horizontally and/or vertically.
|
||||
*
|
||||
* @param matrix an allocated transformation matrix
|
||||
* @param[in,out] matrix a transformation matrix
|
||||
* @param hflip whether the matrix should be flipped horizontally
|
||||
* @param vflip whether the matrix should be flipped vertically
|
||||
*/
|
||||
void av_display_matrix_flip(int32_t matrix[9], int hflip, int vflip);
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
@@ -29,7 +29,9 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "rational.h"
|
||||
#include "csp.h"
|
||||
|
||||
/*
|
||||
* DOVI configuration
|
||||
@@ -44,6 +46,7 @@
|
||||
* uint8_t el_present_flag
|
||||
* uint8_t bl_present_flag
|
||||
* uint8_t dv_bl_signal_compatibility_id
|
||||
* uint8_t dv_md_compression, the compression method in use
|
||||
* @endcode
|
||||
*
|
||||
* @note The struct must be allocated with av_dovi_alloc() and
|
||||
@@ -58,8 +61,16 @@ typedef struct AVDOVIDecoderConfigurationRecord {
|
||||
uint8_t el_present_flag;
|
||||
uint8_t bl_present_flag;
|
||||
uint8_t dv_bl_signal_compatibility_id;
|
||||
uint8_t dv_md_compression;
|
||||
} AVDOVIDecoderConfigurationRecord;
|
||||
|
||||
enum AVDOVICompression {
|
||||
AV_DOVI_COMPRESSION_NONE = 0,
|
||||
AV_DOVI_COMPRESSION_LIMITED = 1,
|
||||
AV_DOVI_COMPRESSION_RESERVED = 2,
|
||||
AV_DOVI_COMPRESSION_EXTENDED = 3,
|
||||
};
|
||||
|
||||
/**
|
||||
* Allocate a AVDOVIDecoderConfigurationRecord structure and initialize its
|
||||
* fields to default values.
|
||||
@@ -89,6 +100,8 @@ typedef struct AVDOVIRpuDataHeader {
|
||||
uint8_t spatial_resampling_filter_flag;
|
||||
uint8_t el_spatial_resampling_filter_flag;
|
||||
uint8_t disable_residual_flag;
|
||||
uint8_t ext_mapping_idc_0_4; /* extended base layer inverse mapping indicator */
|
||||
uint8_t ext_mapping_idc_5_7; /* reserved */
|
||||
} AVDOVIRpuDataHeader;
|
||||
|
||||
enum AVDOVIMappingMethod {
|
||||
@@ -147,6 +160,7 @@ typedef struct AVDOVIDataMapping {
|
||||
uint32_t num_x_partitions;
|
||||
uint32_t num_y_partitions;
|
||||
AVDOVINLQParams nlq[3]; /* per component */
|
||||
uint16_t nlq_pivots[2];
|
||||
} AVDOVIDataMapping;
|
||||
|
||||
/**
|
||||
@@ -186,6 +200,132 @@ typedef struct AVDOVIColorMetadata {
|
||||
uint16_t source_diagonal;
|
||||
} AVDOVIColorMetadata;
|
||||
|
||||
typedef struct AVDOVIDmLevel1 {
|
||||
/* Per-frame brightness metadata */
|
||||
uint16_t min_pq;
|
||||
uint16_t max_pq;
|
||||
uint16_t avg_pq;
|
||||
} AVDOVIDmLevel1;
|
||||
|
||||
typedef struct AVDOVIDmLevel2 {
|
||||
/* Usually derived from level 8 (at different levels) */
|
||||
uint16_t target_max_pq;
|
||||
uint16_t trim_slope;
|
||||
uint16_t trim_offset;
|
||||
uint16_t trim_power;
|
||||
uint16_t trim_chroma_weight;
|
||||
uint16_t trim_saturation_gain;
|
||||
int16_t ms_weight;
|
||||
} AVDOVIDmLevel2;
|
||||
|
||||
typedef struct AVDOVIDmLevel3 {
|
||||
uint16_t min_pq_offset;
|
||||
uint16_t max_pq_offset;
|
||||
uint16_t avg_pq_offset;
|
||||
} AVDOVIDmLevel3;
|
||||
|
||||
typedef struct AVDOVIDmLevel4 {
|
||||
uint16_t anchor_pq;
|
||||
uint16_t anchor_power;
|
||||
} AVDOVIDmLevel4;
|
||||
|
||||
typedef struct AVDOVIDmLevel5 {
|
||||
/* Active area definition */
|
||||
uint16_t left_offset;
|
||||
uint16_t right_offset;
|
||||
uint16_t top_offset;
|
||||
uint16_t bottom_offset;
|
||||
} AVDOVIDmLevel5;
|
||||
|
||||
typedef struct AVDOVIDmLevel6 {
|
||||
/* Static HDR10 metadata */
|
||||
uint16_t max_luminance;
|
||||
uint16_t min_luminance;
|
||||
uint16_t max_cll;
|
||||
uint16_t max_fall;
|
||||
} AVDOVIDmLevel6;
|
||||
|
||||
typedef struct AVDOVIDmLevel8 {
|
||||
/* Extended version of level 2 */
|
||||
uint8_t target_display_index;
|
||||
uint16_t trim_slope;
|
||||
uint16_t trim_offset;
|
||||
uint16_t trim_power;
|
||||
uint16_t trim_chroma_weight;
|
||||
uint16_t trim_saturation_gain;
|
||||
uint16_t ms_weight;
|
||||
uint16_t target_mid_contrast;
|
||||
uint16_t clip_trim;
|
||||
uint8_t saturation_vector_field[6];
|
||||
uint8_t hue_vector_field[6];
|
||||
} AVDOVIDmLevel8;
|
||||
|
||||
typedef struct AVDOVIDmLevel9 {
|
||||
/* Source display characteristics */
|
||||
uint8_t source_primary_index;
|
||||
AVColorPrimariesDesc source_display_primaries;
|
||||
} AVDOVIDmLevel9;
|
||||
|
||||
typedef struct AVDOVIDmLevel10 {
|
||||
/* Target display characteristics */
|
||||
uint8_t target_display_index;
|
||||
uint16_t target_max_pq;
|
||||
uint16_t target_min_pq;
|
||||
uint8_t target_primary_index;
|
||||
AVColorPrimariesDesc target_display_primaries;
|
||||
} AVDOVIDmLevel10;
|
||||
|
||||
typedef struct AVDOVIDmLevel11 {
|
||||
uint8_t content_type;
|
||||
uint8_t whitepoint;
|
||||
uint8_t reference_mode_flag;
|
||||
uint8_t sharpness;
|
||||
uint8_t noise_reduction;
|
||||
uint8_t mpeg_noise_reduction;
|
||||
uint8_t frame_rate_conversion;
|
||||
uint8_t brightness;
|
||||
uint8_t color;
|
||||
} AVDOVIDmLevel11;
|
||||
|
||||
typedef struct AVDOVIDmLevel254 {
|
||||
/* DMv2 info block, always present in samples with DMv2 metadata */
|
||||
uint8_t dm_mode;
|
||||
uint8_t dm_version_index;
|
||||
} AVDOVIDmLevel254;
|
||||
|
||||
typedef struct AVDOVIDmLevel255 {
|
||||
/* Debug block, not really used in samples */
|
||||
uint8_t dm_run_mode;
|
||||
uint8_t dm_run_version;
|
||||
uint8_t dm_debug[4];
|
||||
} AVDOVIDmLevel255;
|
||||
|
||||
/**
|
||||
* Dolby Vision metadata extension block. Dynamic extension blocks may change
|
||||
* from frame to frame, while static blocks are constant throughout the entire
|
||||
* sequence.
|
||||
*
|
||||
* @note sizeof(AVDOVIDmData) is not part of the public API.
|
||||
*/
|
||||
typedef struct AVDOVIDmData {
|
||||
uint8_t level; /* [1, 255] */
|
||||
union {
|
||||
AVDOVIDmLevel1 l1; /* dynamic */
|
||||
AVDOVIDmLevel2 l2; /* dynamic, may appear multiple times */
|
||||
AVDOVIDmLevel3 l3; /* dynamic */
|
||||
AVDOVIDmLevel4 l4; /* dynamic */
|
||||
AVDOVIDmLevel5 l5; /* dynamic */
|
||||
AVDOVIDmLevel6 l6; /* static */
|
||||
/* level 7 is currently unused */
|
||||
AVDOVIDmLevel8 l8; /* dynamic, may appear multiple times */
|
||||
AVDOVIDmLevel9 l9; /* dynamic */
|
||||
AVDOVIDmLevel10 l10; /* static, may appear multiple times */
|
||||
AVDOVIDmLevel11 l11; /* dynamic */
|
||||
AVDOVIDmLevel254 l254; /* static */
|
||||
AVDOVIDmLevel255 l255; /* static */
|
||||
};
|
||||
} AVDOVIDmData;
|
||||
|
||||
/**
|
||||
* Combined struct representing a combination of header, mapping and color
|
||||
* metadata, for attaching to frames as side data.
|
||||
@@ -202,6 +342,13 @@ typedef struct AVDOVIMetadata {
|
||||
size_t header_offset; /* AVDOVIRpuDataHeader */
|
||||
size_t mapping_offset; /* AVDOVIDataMapping */
|
||||
size_t color_offset; /* AVDOVIColorMetadata */
|
||||
|
||||
size_t ext_block_offset; /* offset to start of ext blocks array */
|
||||
size_t ext_block_size; /* size per element */
|
||||
int num_ext_blocks; /* number of extension blocks */
|
||||
|
||||
/* static limit on num_ext_blocks, derived from bitstream limitations */
|
||||
#define AV_DOVI_MAX_EXT_BLOCKS 32
|
||||
} AVDOVIMetadata;
|
||||
|
||||
static av_always_inline AVDOVIRpuDataHeader *
|
||||
@@ -222,6 +369,19 @@ av_dovi_get_color(const AVDOVIMetadata *data)
|
||||
return (AVDOVIColorMetadata *)((uint8_t *) data + data->color_offset);
|
||||
}
|
||||
|
||||
static av_always_inline AVDOVIDmData *
|
||||
av_dovi_get_ext(const AVDOVIMetadata *data, int index)
|
||||
{
|
||||
return (AVDOVIDmData *)((uint8_t *) data + data->ext_block_offset +
|
||||
data->ext_block_size * index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find an extension block with a given level, or NULL. In the case of
|
||||
* multiple extension blocks, only the first is returned.
|
||||
*/
|
||||
AVDOVIDmData *av_dovi_find_level(const AVDOVIMetadata *data, uint8_t level);
|
||||
|
||||
/**
|
||||
* Allocate an AVDOVIMetadata structure and initialize its
|
||||
* fields to default values.
|
||||
|
||||
@@ -79,6 +79,7 @@
|
||||
#define AVERROR_HTTP_UNAUTHORIZED FFERRTAG(0xF8,'4','0','1')
|
||||
#define AVERROR_HTTP_FORBIDDEN FFERRTAG(0xF8,'4','0','3')
|
||||
#define AVERROR_HTTP_NOT_FOUND FFERRTAG(0xF8,'4','0','4')
|
||||
#define AVERROR_HTTP_TOO_MANY_REQUESTS FFERRTAG(0xF8,'4','2','9')
|
||||
#define AVERROR_HTTP_OTHER_4XX FFERRTAG(0xF8,'4','X','X')
|
||||
#define AVERROR_HTTP_SERVER_ERROR FFERRTAG(0xF8,'5','X','X')
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ typedef struct AVExpr AVExpr;
|
||||
* @param func2_names NULL terminated array of zero terminated strings of funcs2 identifiers
|
||||
* @param funcs2 NULL terminated array of function pointers for functions which take 2 arguments
|
||||
* @param opaque a pointer which will be passed to all functions from funcs1 and funcs2
|
||||
* @param log_offset log level offset, can be used to silence error messages
|
||||
* @param log_ctx parent logging context
|
||||
* @return >= 0 in case of success, a negative value corresponding to an
|
||||
* AVERROR code otherwise
|
||||
@@ -65,6 +66,7 @@ int av_expr_parse_and_eval(double *res, const char *s,
|
||||
* @param funcs1 NULL terminated array of function pointers for functions which take 1 argument
|
||||
* @param func2_names NULL terminated array of zero terminated strings of funcs2 identifiers
|
||||
* @param funcs2 NULL terminated array of function pointers for functions which take 2 arguments
|
||||
* @param log_offset log level offset, can be used to silence error messages
|
||||
* @param log_ctx parent logging context
|
||||
* @return >= 0 in case of success, a negative value corresponding to an
|
||||
* AVERROR code otherwise
|
||||
@@ -78,6 +80,7 @@ int av_expr_parse(AVExpr **expr, const char *s,
|
||||
/**
|
||||
* Evaluate a previously parsed expression.
|
||||
*
|
||||
* @param e the AVExpr to evaluate
|
||||
* @param const_values a zero terminated array of values for the identifiers from av_expr_parse() const_names
|
||||
* @param opaque a pointer which will be passed to all functions from funcs1 and funcs2
|
||||
* @return the value of the expression
|
||||
@@ -87,6 +90,7 @@ double av_expr_eval(AVExpr *e, const double *const_values, void *opaque);
|
||||
/**
|
||||
* Track the presence of variables and their number of occurrences in a parsed expression
|
||||
*
|
||||
* @param e the AVExpr to track variables in
|
||||
* @param counter a zero-initialized array where the count of each variable will be stored
|
||||
* @param size size of array
|
||||
* @return 0 on success, a negative value indicates that no expression or array was passed
|
||||
@@ -98,9 +102,10 @@ int av_expr_count_vars(AVExpr *e, unsigned *counter, int size);
|
||||
* Track the presence of user provided functions and their number of occurrences
|
||||
* in a parsed expression.
|
||||
*
|
||||
* @param e the AVExpr to track user provided functions in
|
||||
* @param counter a zero-initialized array where the count of each function will be stored
|
||||
* if you passed 5 functions with 2 arguments to av_expr_parse()
|
||||
* then for arg=2 this will use upto 5 entries.
|
||||
* then for arg=2 this will use up to 5 entries.
|
||||
* @param size size of array
|
||||
* @param arg number of arguments the counted functions have
|
||||
* @return 0 on success, a negative value indicates that no expression or array was passed
|
||||
|
||||
67
include/libavutil/executor.h
Normal file
67
include/libavutil/executor.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Nuo Mi
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_EXECUTOR_H
|
||||
#define AVUTIL_EXECUTOR_H
|
||||
|
||||
typedef struct AVExecutor AVExecutor;
|
||||
typedef struct AVTask AVTask;
|
||||
|
||||
struct AVTask {
|
||||
AVTask *next;
|
||||
};
|
||||
|
||||
typedef struct AVTaskCallbacks {
|
||||
void *user_data;
|
||||
|
||||
int local_context_size;
|
||||
|
||||
// return 1 if a's priority > b's priority
|
||||
int (*priority_higher)(const AVTask *a, const AVTask *b);
|
||||
|
||||
// task is ready for run
|
||||
int (*ready)(const AVTask *t, void *user_data);
|
||||
|
||||
// run the task
|
||||
int (*run)(AVTask *t, void *local_context, void *user_data);
|
||||
} AVTaskCallbacks;
|
||||
|
||||
/**
|
||||
* Alloc executor
|
||||
* @param callbacks callback structure for executor
|
||||
* @param thread_count worker thread number, 0 for run on caller's thread directly
|
||||
* @return return the executor
|
||||
*/
|
||||
AVExecutor* av_executor_alloc(const AVTaskCallbacks *callbacks, int thread_count);
|
||||
|
||||
/**
|
||||
* Free executor
|
||||
* @param e pointer to executor
|
||||
*/
|
||||
void av_executor_free(AVExecutor **e);
|
||||
|
||||
/**
|
||||
* Add task to executor
|
||||
* @param e pointer to executor
|
||||
* @param t pointer to task. If NULL, it will wakeup one work thread
|
||||
*/
|
||||
void av_executor_execute(AVExecutor *e, AVTask *t);
|
||||
|
||||
#endif //AVUTIL_EXECUTOR_H
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Automatically generated by version.sh, do not manually edit! */
|
||||
#ifndef AVUTIL_FFVERSION_H
|
||||
#define AVUTIL_FFVERSION_H
|
||||
#define FFMPEG_VERSION "5.1.2"
|
||||
#define FFMPEG_VERSION "7.1.1"
|
||||
#endif /* AVUTIL_FFVERSION_H */
|
||||
|
||||
@@ -18,17 +18,22 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* a very simple circular buffer FIFO implementation
|
||||
* @ingroup lavu_fifo
|
||||
* A generic FIFO API
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_FIFO_H
|
||||
#define AVUTIL_FIFO_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "attributes.h"
|
||||
#include "version.h"
|
||||
/**
|
||||
* @defgroup lavu_fifo AVFifo
|
||||
* @ingroup lavu_data
|
||||
*
|
||||
* @{
|
||||
* A generic FIFO API
|
||||
*/
|
||||
|
||||
typedef struct AVFifo AVFifo;
|
||||
|
||||
@@ -88,7 +93,13 @@ void av_fifo_auto_grow_limit(AVFifo *f, size_t max_elems);
|
||||
size_t av_fifo_can_read(const AVFifo *f);
|
||||
|
||||
/**
|
||||
* @return number of elements that can be written into the given FIFO.
|
||||
* @return Number of elements that can be written into the given FIFO without
|
||||
* growing it.
|
||||
*
|
||||
* In other words, this number of elements or less is guaranteed to fit
|
||||
* into the FIFO. More data may be written when the
|
||||
* AV_FIFO_FLAG_AUTO_GROW flag was specified at FIFO creation, but this
|
||||
* may involve memory allocation, which can fail.
|
||||
*/
|
||||
size_t av_fifo_can_write(const AVFifo *f);
|
||||
|
||||
@@ -109,9 +120,12 @@ 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
|
||||
* In case nb_elems > av_fifo_can_write(f) and the AV_FIFO_FLAG_AUTO_GROW flag
|
||||
* was not specified at FIFO creation, nothing is written and an error
|
||||
* is returned.
|
||||
*
|
||||
* Calling function is guaranteed to succeed if nb_elems <= av_fifo_can_write(f).
|
||||
*
|
||||
* @param f the FIFO buffer
|
||||
* @param buf Data to be written. nb_elems * av_fifo_elem_size(f) bytes will be
|
||||
* read from buf on success.
|
||||
@@ -182,7 +196,7 @@ int av_fifo_read_to_cb(AVFifo *f, AVFifoCB write_cb,
|
||||
*
|
||||
* @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);
|
||||
int av_fifo_peek(const AVFifo *f, void *buf, size_t nb_elems, size_t offset);
|
||||
|
||||
/**
|
||||
* Feed data from a FIFO into a user-provided callback.
|
||||
@@ -199,7 +213,7 @@ int av_fifo_peek(AVFifo *f, void *buf, size_t nb_elems, size_t offset);
|
||||
*
|
||||
* @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,
|
||||
int av_fifo_peek_to_cb(const AVFifo *f, AVFifoCB write_cb, void *opaque,
|
||||
size_t *nb_elems, size_t offset);
|
||||
|
||||
/**
|
||||
@@ -221,206 +235,8 @@ void av_fifo_reset2(AVFifo *f);
|
||||
*/
|
||||
void av_fifo_freep2(AVFifo **f);
|
||||
|
||||
|
||||
#if FF_API_FIFO_OLD_API
|
||||
typedef struct AVFifoBuffer {
|
||||
uint8_t *buffer;
|
||||
uint8_t *rptr, *wptr, *end;
|
||||
uint32_t rndx, wndx;
|
||||
} AVFifoBuffer;
|
||||
|
||||
/**
|
||||
* Initialize an AVFifoBuffer.
|
||||
* @param size of FIFO
|
||||
* @return AVFifoBuffer or NULL in case of memory allocation failure
|
||||
* @deprecated use av_fifo_alloc2()
|
||||
* @}
|
||||
*/
|
||||
attribute_deprecated
|
||||
AVFifoBuffer *av_fifo_alloc(unsigned int size);
|
||||
|
||||
/**
|
||||
* Initialize an AVFifoBuffer.
|
||||
* @param nmemb number of elements
|
||||
* @param size size of the single element
|
||||
* @return AVFifoBuffer or NULL in case of memory allocation failure
|
||||
* @deprecated use av_fifo_alloc2()
|
||||
*/
|
||||
attribute_deprecated
|
||||
AVFifoBuffer *av_fifo_alloc_array(size_t nmemb, size_t size);
|
||||
|
||||
/**
|
||||
* Free an AVFifoBuffer.
|
||||
* @param f AVFifoBuffer to free
|
||||
* @deprecated use the AVFifo API with av_fifo_freep2()
|
||||
*/
|
||||
attribute_deprecated
|
||||
void av_fifo_free(AVFifoBuffer *f);
|
||||
|
||||
/**
|
||||
* Free an AVFifoBuffer and reset pointer to NULL.
|
||||
* @param f AVFifoBuffer to free
|
||||
* @deprecated use the AVFifo API with av_fifo_freep2()
|
||||
*/
|
||||
attribute_deprecated
|
||||
void av_fifo_freep(AVFifoBuffer **f);
|
||||
|
||||
/**
|
||||
* Reset the AVFifoBuffer to the state right after av_fifo_alloc, in particular it is emptied.
|
||||
* @param f AVFifoBuffer to reset
|
||||
* @deprecated use av_fifo_reset2() with the new AVFifo-API
|
||||
*/
|
||||
attribute_deprecated
|
||||
void av_fifo_reset(AVFifoBuffer *f);
|
||||
|
||||
/**
|
||||
* Return the amount of data in bytes in the AVFifoBuffer, that is the
|
||||
* amount of data you can read from it.
|
||||
* @param f AVFifoBuffer to read from
|
||||
* @return size
|
||||
* @deprecated use av_fifo_can_read() with the new AVFifo-API
|
||||
*/
|
||||
attribute_deprecated
|
||||
int av_fifo_size(const AVFifoBuffer *f);
|
||||
|
||||
/**
|
||||
* Return the amount of space in bytes in the AVFifoBuffer, that is the
|
||||
* amount of data you can write into it.
|
||||
* @param f AVFifoBuffer to write into
|
||||
* @return size
|
||||
* @deprecated use av_fifo_can_write() with the new AVFifo-API
|
||||
*/
|
||||
attribute_deprecated
|
||||
int av_fifo_space(const AVFifoBuffer *f);
|
||||
|
||||
/**
|
||||
* Feed data at specific position from an AVFifoBuffer to a user-supplied callback.
|
||||
* Similar as av_fifo_gereric_read but without discarding data.
|
||||
* @param f AVFifoBuffer to read from
|
||||
* @param offset offset from current read position
|
||||
* @param buf_size number of bytes to read
|
||||
* @param func generic read function
|
||||
* @param dest data destination
|
||||
*
|
||||
* @return a non-negative number on success, a negative error code on failure
|
||||
*
|
||||
* @deprecated use the new AVFifo-API with av_fifo_peek() when func == NULL,
|
||||
* av_fifo_peek_to_cb() otherwise
|
||||
*/
|
||||
attribute_deprecated
|
||||
int av_fifo_generic_peek_at(AVFifoBuffer *f, void *dest, int offset, int buf_size, void (*func)(void*, void*, int));
|
||||
|
||||
/**
|
||||
* Feed data from an AVFifoBuffer to a user-supplied callback.
|
||||
* Similar as av_fifo_gereric_read but without discarding data.
|
||||
* @param f AVFifoBuffer to read from
|
||||
* @param buf_size number of bytes to read
|
||||
* @param func generic read function
|
||||
* @param dest data destination
|
||||
*
|
||||
* @return a non-negative number on success, a negative error code on failure
|
||||
*
|
||||
* @deprecated use the new AVFifo-API with av_fifo_peek() when func == NULL,
|
||||
* av_fifo_peek_to_cb() otherwise
|
||||
*/
|
||||
attribute_deprecated
|
||||
int av_fifo_generic_peek(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void*, void*, int));
|
||||
|
||||
/**
|
||||
* Feed data from an AVFifoBuffer to a user-supplied callback.
|
||||
* @param f AVFifoBuffer to read from
|
||||
* @param buf_size number of bytes to read
|
||||
* @param func generic read function
|
||||
* @param dest data destination
|
||||
*
|
||||
* @return a non-negative number on success, a negative error code on failure
|
||||
*
|
||||
* @deprecated use the new AVFifo-API with av_fifo_read() when func == NULL,
|
||||
* av_fifo_read_to_cb() otherwise
|
||||
*/
|
||||
attribute_deprecated
|
||||
int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void*, void*, int));
|
||||
|
||||
/**
|
||||
* Feed data from a user-supplied callback to an AVFifoBuffer.
|
||||
* @param f AVFifoBuffer to write to
|
||||
* @param src data source; non-const since it may be used as a
|
||||
* modifiable context by the function defined in func
|
||||
* @param size number of bytes to write
|
||||
* @param func generic write function; the first parameter is src,
|
||||
* the second is dest_buf, the third is dest_buf_size.
|
||||
* func must return the number of bytes written to dest_buf, or <= 0 to
|
||||
* indicate no more data available to write.
|
||||
* If func is NULL, src is interpreted as a simple byte array for source data.
|
||||
* @return the number of bytes written to the FIFO 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));
|
||||
|
||||
/**
|
||||
* Resize an AVFifoBuffer.
|
||||
* In case of reallocation failure, the old FIFO is kept unchanged.
|
||||
*
|
||||
* @param f AVFifoBuffer to resize
|
||||
* @param size new AVFifoBuffer size in bytes
|
||||
* @return <0 for failure, >=0 otherwise
|
||||
*
|
||||
* @deprecated use the new AVFifo-API with av_fifo_grow2() to increase FIFO size,
|
||||
* decreasing FIFO size is not supported
|
||||
*/
|
||||
attribute_deprecated
|
||||
int av_fifo_realloc2(AVFifoBuffer *f, unsigned int size);
|
||||
|
||||
/**
|
||||
* Enlarge an AVFifoBuffer.
|
||||
* In case of reallocation failure, the old FIFO is kept unchanged.
|
||||
* The new fifo size may be larger than the requested size.
|
||||
*
|
||||
* @param f AVFifoBuffer to resize
|
||||
* @param additional_space the amount of space in bytes to allocate in addition to av_fifo_size()
|
||||
* @return <0 for failure, >=0 otherwise
|
||||
*
|
||||
* @deprecated use the new AVFifo-API with av_fifo_grow2(); note that unlike
|
||||
* this function it adds to the allocated size, rather than to the used size
|
||||
*/
|
||||
attribute_deprecated
|
||||
int av_fifo_grow(AVFifoBuffer *f, unsigned int additional_space);
|
||||
|
||||
/**
|
||||
* Read and discard the specified amount of data from an AVFifoBuffer.
|
||||
* @param f AVFifoBuffer to read from
|
||||
* @param size amount of data to read in bytes
|
||||
*
|
||||
* @deprecated use the new AVFifo-API with av_fifo_drain2()
|
||||
*/
|
||||
attribute_deprecated
|
||||
void av_fifo_drain(AVFifoBuffer *f, int size);
|
||||
|
||||
#if FF_API_FIFO_PEEK2
|
||||
/**
|
||||
* Return a pointer to the data stored in a FIFO buffer at a certain offset.
|
||||
* The FIFO buffer is not modified.
|
||||
*
|
||||
* @param f AVFifoBuffer to peek at, f must be non-NULL
|
||||
* @param offs an offset in bytes, its absolute value must be less
|
||||
* than the used buffer size or the returned pointer will
|
||||
* point outside to the buffer data.
|
||||
* The used buffer size can be checked with av_fifo_size().
|
||||
* @deprecated use the new AVFifo-API with av_fifo_peek() or av_fifo_peek_to_cb()
|
||||
*/
|
||||
attribute_deprecated
|
||||
static inline uint8_t *av_fifo_peek2(const AVFifoBuffer *f, int offs)
|
||||
{
|
||||
uint8_t *ptr = f->rptr + offs;
|
||||
if (ptr >= f->end)
|
||||
ptr = f->buffer + (ptr - f->end);
|
||||
else if (ptr < f->buffer)
|
||||
ptr = f->end - (f->buffer - ptr);
|
||||
return ptr;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* AVUTIL_FIFO_H */
|
||||
|
||||
@@ -38,6 +38,9 @@
|
||||
* case *bufptr will be set to NULL and *size will be set to 0.
|
||||
* The returned buffer must be released with av_file_unmap().
|
||||
*
|
||||
* @param filename path to the file
|
||||
* @param[out] bufptr pointee is set to the mapped or allocated buffer
|
||||
* @param[out] size pointee is set to the size in bytes of the buffer
|
||||
* @param log_offset loglevel offset used for logging
|
||||
* @param log_ctx context used for logging
|
||||
* @return a non negative number in case of success, a negative value
|
||||
@@ -50,23 +53,10 @@ int av_file_map(const char *filename, uint8_t **bufptr, size_t *size,
|
||||
/**
|
||||
* Unmap or free the buffer bufptr created by av_file_map().
|
||||
*
|
||||
* @param bufptr the buffer previously created with av_file_map()
|
||||
* @param size size in bytes of bufptr, must be the same as returned
|
||||
* by av_file_map()
|
||||
*/
|
||||
void av_file_unmap(uint8_t *bufptr, size_t size);
|
||||
|
||||
/**
|
||||
* Wrapper to work around the lack of mkstemp() on mingw.
|
||||
* Also, tries to create file in /tmp first, if possible.
|
||||
* *prefix can be a character constant; *filename will be allocated internally.
|
||||
* @return file descriptor of opened file (or negative value corresponding to an
|
||||
* AVERROR code on error)
|
||||
* and opened file name in **filename.
|
||||
* @note On very old libcs it is necessary to set a secure umask before
|
||||
* calling this, av_tempfile() can't call umask itself as it is used in
|
||||
* libraries and could interfere with the calling application.
|
||||
* @deprecated as fd numbers cannot be passed saftely between libs on some platforms
|
||||
*/
|
||||
int av_tempfile(const char *prefix, char **filename, int log_offset, void *log_ctx);
|
||||
|
||||
#endif /* AVUTIL_FILE_H */
|
||||
|
||||
@@ -136,20 +136,42 @@ typedef struct AVFilmGrainH274Params {
|
||||
*/
|
||||
int model_id;
|
||||
|
||||
/**
|
||||
* Specifies the bit depth used for the luma component.
|
||||
*/
|
||||
#if FF_API_H274_FILM_GRAIN_VCS
|
||||
/**
|
||||
* TODO: On this ABI bump, please also re-order the fields in
|
||||
* AVFilmGrainParams (see below)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Specifies the bit depth used for the luma component.
|
||||
*
|
||||
* @deprecated use AVFilmGrainParams.bit_depth_luma.
|
||||
*/
|
||||
attribute_deprecated
|
||||
int bit_depth_luma;
|
||||
|
||||
/**
|
||||
* Specifies the bit depth used for the chroma components.
|
||||
*
|
||||
* @deprecated use AVFilmGrainParams.bit_depth_chroma.
|
||||
*/
|
||||
attribute_deprecated
|
||||
int bit_depth_chroma;
|
||||
|
||||
/**
|
||||
* Specifies the video signal characteristics.
|
||||
*
|
||||
* @deprecated use AVFilmGrainParams.color_{range,primaries,trc,space}.
|
||||
*/
|
||||
attribute_deprecated
|
||||
enum AVColorRange color_range;
|
||||
attribute_deprecated
|
||||
enum AVColorPrimaries color_primaries;
|
||||
attribute_deprecated
|
||||
enum AVColorTransferCharacteristic color_trc;
|
||||
attribute_deprecated
|
||||
enum AVColorSpace color_space;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Specifies the blending mode used to blend the simulated film grain
|
||||
@@ -231,11 +253,40 @@ typedef struct AVFilmGrainParams {
|
||||
* Additional fields may be added both here and in any structure included.
|
||||
* If a codec's film grain structure differs slightly over another
|
||||
* codec's, fields within may change meaning depending on the type.
|
||||
*
|
||||
* TODO: Move this to the end of the structure, at the next ABI bump.
|
||||
*/
|
||||
union {
|
||||
AVFilmGrainAOMParams aom;
|
||||
AVFilmGrainH274Params h274;
|
||||
} codec;
|
||||
|
||||
/**
|
||||
* Intended display resolution. May be 0 if the codec does not specify
|
||||
* any restrictions.
|
||||
*/
|
||||
|
||||
int width, height;
|
||||
|
||||
/**
|
||||
* Intended subsampling ratio, or 0 for luma-only streams.
|
||||
*/
|
||||
int subsampling_x, subsampling_y;
|
||||
|
||||
/**
|
||||
* Intended video signal characteristics.
|
||||
*/
|
||||
enum AVColorRange color_range;
|
||||
enum AVColorPrimaries color_primaries;
|
||||
enum AVColorTransferCharacteristic color_trc;
|
||||
enum AVColorSpace color_space;
|
||||
|
||||
/**
|
||||
* Intended bit depth, or 0 for unknown/unspecified.
|
||||
*/
|
||||
int bit_depth_luma;
|
||||
int bit_depth_chroma;
|
||||
|
||||
} AVFilmGrainParams;
|
||||
|
||||
/**
|
||||
@@ -257,4 +308,15 @@ AVFilmGrainParams *av_film_grain_params_alloc(size_t *size);
|
||||
*/
|
||||
AVFilmGrainParams *av_film_grain_params_create_side_data(AVFrame *frame);
|
||||
|
||||
/**
|
||||
* Select the most appropriate film grain parameters set for the frame,
|
||||
* taking into account the frame's format, resolution and video signal
|
||||
* characteristics.
|
||||
*
|
||||
* @note, for H.274, this may select a film grain parameter set with
|
||||
* greater chroma resolution than the frame. Users should take care to
|
||||
* correctly adjust the chroma grain frequency to the frame.
|
||||
*/
|
||||
const AVFilmGrainParams *av_film_grain_params_select(const AVFrame *frame);
|
||||
|
||||
#endif /* AVUTIL_FILM_GRAIN_PARAMS_H */
|
||||
|
||||
@@ -180,6 +180,10 @@ enum AVFrameSideDataType {
|
||||
/**
|
||||
* Film grain parameters for a frame, described by AVFilmGrainParams.
|
||||
* Must be present for every frame which should have film grain applied.
|
||||
*
|
||||
* May be present multiple times, for example when there are multiple
|
||||
* alternative parameter sets for different video signal characteristics.
|
||||
* The user should select the most appropriate set for the application.
|
||||
*/
|
||||
AV_FRAME_DATA_FILM_GRAIN_PARAMS,
|
||||
|
||||
@@ -209,6 +213,36 @@ enum AVFrameSideDataType {
|
||||
* volume transform - CUVA 005.1-2021.
|
||||
*/
|
||||
AV_FRAME_DATA_DYNAMIC_HDR_VIVID,
|
||||
|
||||
/**
|
||||
* Ambient viewing environment metadata, as defined by H.274.
|
||||
*/
|
||||
AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT,
|
||||
|
||||
/**
|
||||
* Provide encoder-specific hinting information about changed/unchanged
|
||||
* portions of a frame. It can be used to pass information about which
|
||||
* macroblocks can be skipped because they didn't change from the
|
||||
* corresponding ones in the previous frame. This could be useful for
|
||||
* applications which know this information in advance to speed up
|
||||
* encoding.
|
||||
*/
|
||||
AV_FRAME_DATA_VIDEO_HINT,
|
||||
|
||||
/**
|
||||
* Raw LCEVC payload data, as a uint8_t array, with NAL emulation
|
||||
* bytes intact.
|
||||
*/
|
||||
AV_FRAME_DATA_LCEVC,
|
||||
|
||||
/**
|
||||
* This side data must be associated with a video frame.
|
||||
* The presence of this side data indicates that the video stream is
|
||||
* composed of multiple views (e.g. stereoscopic 3D content,
|
||||
* cf. H.264 Annex H or H.265 Annex G).
|
||||
* The data is an int storing the view ID.
|
||||
*/
|
||||
AV_FRAME_DATA_VIEW_ID,
|
||||
};
|
||||
|
||||
enum AVActiveFormatDescription {
|
||||
@@ -236,6 +270,37 @@ typedef struct AVFrameSideData {
|
||||
AVBufferRef *buf;
|
||||
} AVFrameSideData;
|
||||
|
||||
enum AVSideDataProps {
|
||||
/**
|
||||
* The side data type can be used in stream-global structures.
|
||||
* Side data types without this property are only meaningful on per-frame
|
||||
* basis.
|
||||
*/
|
||||
AV_SIDE_DATA_PROP_GLOBAL = (1 << 0),
|
||||
|
||||
/**
|
||||
* Multiple instances of this side data type can be meaningfully present in
|
||||
* a single side data array.
|
||||
*/
|
||||
AV_SIDE_DATA_PROP_MULTI = (1 << 1),
|
||||
};
|
||||
|
||||
/**
|
||||
* This struct describes the properties of a side data type. Its instance
|
||||
* corresponding to a given type can be obtained from av_frame_side_data_desc().
|
||||
*/
|
||||
typedef struct AVSideDataDescriptor {
|
||||
/**
|
||||
* Human-readable side data description.
|
||||
*/
|
||||
const char *name;
|
||||
|
||||
/**
|
||||
* Side data property flags, a combination of AVSideDataProps values.
|
||||
*/
|
||||
unsigned props;
|
||||
} AVSideDataDescriptor;
|
||||
|
||||
/**
|
||||
* Structure describing a single Region Of Interest.
|
||||
*
|
||||
@@ -319,8 +384,7 @@ typedef struct AVRegionOfInterest {
|
||||
* to the end with a minor bump.
|
||||
*
|
||||
* Fields can be accessed through AVOptions, the name string used, matches the
|
||||
* C structure field name for fields accessible through AVOptions. The AVClass
|
||||
* for AVFrame can be obtained from avcodec_get_frame_class()
|
||||
* C structure field name for fields accessible through AVOptions.
|
||||
*/
|
||||
typedef struct AVFrame {
|
||||
#define AV_NUM_DATA_POINTERS 8
|
||||
@@ -411,10 +475,15 @@ typedef struct AVFrame {
|
||||
*/
|
||||
int format;
|
||||
|
||||
#if FF_API_FRAME_KEY
|
||||
/**
|
||||
* 1 -> keyframe, 0-> not
|
||||
*
|
||||
* @deprecated Use AV_FRAME_FLAG_KEY instead
|
||||
*/
|
||||
attribute_deprecated
|
||||
int key_frame;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Picture type of the frame.
|
||||
@@ -446,70 +515,78 @@ typedef struct AVFrame {
|
||||
*/
|
||||
AVRational time_base;
|
||||
|
||||
/**
|
||||
* picture number in bitstream order
|
||||
*/
|
||||
int coded_picture_number;
|
||||
/**
|
||||
* picture number in display order
|
||||
*/
|
||||
int display_picture_number;
|
||||
|
||||
/**
|
||||
* quality (between 1 (good) and FF_LAMBDA_MAX (bad))
|
||||
*/
|
||||
int quality;
|
||||
|
||||
/**
|
||||
* for some private data of the user
|
||||
* Frame owner's private data.
|
||||
*
|
||||
* This field may be set by the code that allocates/owns the frame data.
|
||||
* It is then not touched by any library functions, except:
|
||||
* - it is copied to other references by av_frame_copy_props() (and hence by
|
||||
* av_frame_ref());
|
||||
* - it is set to NULL when the frame is cleared by av_frame_unref()
|
||||
* - on the caller's explicit request. E.g. libavcodec encoders/decoders
|
||||
* will copy this field to/from @ref AVPacket "AVPackets" if the caller sets
|
||||
* @ref AV_CODEC_FLAG_COPY_OPAQUE.
|
||||
*
|
||||
* @see opaque_ref the reference-counted analogue
|
||||
*/
|
||||
void *opaque;
|
||||
|
||||
/**
|
||||
* When decoding, this signals how much the picture must be delayed.
|
||||
* extra_delay = repeat_pict / (2*fps)
|
||||
* Number of fields in this frame which should be repeated, i.e. the total
|
||||
* duration of this frame should be repeat_pict + 2 normal field durations.
|
||||
*
|
||||
* For interlaced frames this field may be set to 1, which signals that this
|
||||
* frame should be presented as 3 fields: beginning with the first field (as
|
||||
* determined by AV_FRAME_FLAG_TOP_FIELD_FIRST being set or not), followed
|
||||
* by the second field, and then the first field again.
|
||||
*
|
||||
* For progressive frames this field may be set to a multiple of 2, which
|
||||
* signals that this frame's duration should be (repeat_pict + 2) / 2
|
||||
* normal frame durations.
|
||||
*
|
||||
* @note This field is computed from MPEG2 repeat_first_field flag and its
|
||||
* associated flags, H.264 pic_struct from picture timing SEI, and
|
||||
* their analogues in other codecs. Typically it should only be used when
|
||||
* higher-layer timing information is not available.
|
||||
*/
|
||||
int repeat_pict;
|
||||
|
||||
#if FF_API_INTERLACED_FRAME
|
||||
/**
|
||||
* The content of the picture is interlaced.
|
||||
*
|
||||
* @deprecated Use AV_FRAME_FLAG_INTERLACED instead
|
||||
*/
|
||||
attribute_deprecated
|
||||
int interlaced_frame;
|
||||
|
||||
/**
|
||||
* If the content is interlaced, is top field displayed first.
|
||||
*
|
||||
* @deprecated Use AV_FRAME_FLAG_TOP_FIELD_FIRST instead
|
||||
*/
|
||||
attribute_deprecated
|
||||
int top_field_first;
|
||||
#endif
|
||||
|
||||
#if FF_API_PALETTE_HAS_CHANGED
|
||||
/**
|
||||
* Tell user application that palette has changed from previous frame.
|
||||
*/
|
||||
attribute_deprecated
|
||||
int palette_has_changed;
|
||||
|
||||
/**
|
||||
* reordered opaque 64 bits (generally an integer or a double precision float
|
||||
* PTS but can be anything).
|
||||
* The user sets AVCodecContext.reordered_opaque to represent the input at
|
||||
* that time,
|
||||
* the decoder reorders values as needed and sets AVFrame.reordered_opaque
|
||||
* to exactly one of the values provided by the user through AVCodecContext.reordered_opaque
|
||||
*/
|
||||
int64_t reordered_opaque;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Sample rate of the audio data.
|
||||
*/
|
||||
int sample_rate;
|
||||
|
||||
#if FF_API_OLD_CHANNEL_LAYOUT
|
||||
/**
|
||||
* Channel layout of the audio data.
|
||||
* @deprecated use ch_layout instead
|
||||
*/
|
||||
attribute_deprecated
|
||||
uint64_t channel_layout;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* AVBuffer references backing the data for this frame. All the pointers in
|
||||
* data and extended_data must point inside one of the buffers in buf or
|
||||
@@ -557,10 +634,23 @@ typedef struct AVFrame {
|
||||
* The frame data may be corrupted, e.g. due to decoding errors.
|
||||
*/
|
||||
#define AV_FRAME_FLAG_CORRUPT (1 << 0)
|
||||
/**
|
||||
* A flag to mark frames that are keyframes.
|
||||
*/
|
||||
#define AV_FRAME_FLAG_KEY (1 << 1)
|
||||
/**
|
||||
* A flag to mark the frames which need to be decoded, but shouldn't be output.
|
||||
*/
|
||||
#define AV_FRAME_FLAG_DISCARD (1 << 2)
|
||||
/**
|
||||
* A flag to mark frames whose content is interlaced.
|
||||
*/
|
||||
#define AV_FRAME_FLAG_INTERLACED (1 << 3)
|
||||
/**
|
||||
* A flag to mark frames where the top field is displayed first if the content
|
||||
* is interlaced.
|
||||
*/
|
||||
#define AV_FRAME_FLAG_TOP_FIELD_FIRST (1 << 4)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@@ -597,20 +687,17 @@ typedef struct AVFrame {
|
||||
*/
|
||||
int64_t best_effort_timestamp;
|
||||
|
||||
#if FF_API_FRAME_PKT
|
||||
/**
|
||||
* reordered pos from the last AVPacket that has been input into the decoder
|
||||
* - encoding: unused
|
||||
* - decoding: Read by user.
|
||||
* @deprecated use AV_CODEC_FLAG_COPY_OPAQUE to pass through arbitrary user
|
||||
* data from packets to frames
|
||||
*/
|
||||
attribute_deprecated
|
||||
int64_t pkt_pos;
|
||||
|
||||
/**
|
||||
* duration of the corresponding packet, expressed in
|
||||
* AVStream->time_base units, 0 if unknown.
|
||||
* - encoding: unused
|
||||
* - decoding: Read by user.
|
||||
*/
|
||||
int64_t pkt_duration;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* metadata.
|
||||
@@ -632,25 +719,19 @@ typedef struct AVFrame {
|
||||
#define FF_DECODE_ERROR_CONCEALMENT_ACTIVE 4
|
||||
#define FF_DECODE_ERROR_DECODE_SLICES 8
|
||||
|
||||
#if FF_API_OLD_CHANNEL_LAYOUT
|
||||
/**
|
||||
* number of audio channels, only used for audio.
|
||||
* - encoding: unused
|
||||
* - decoding: Read by user.
|
||||
* @deprecated use ch_layout instead
|
||||
*/
|
||||
attribute_deprecated
|
||||
int channels;
|
||||
#endif
|
||||
|
||||
#if FF_API_FRAME_PKT
|
||||
/**
|
||||
* size of the corresponding packet containing the compressed
|
||||
* frame.
|
||||
* It is set to a negative value if unknown.
|
||||
* - encoding: unused
|
||||
* - decoding: set by libavcodec, read by user.
|
||||
* @deprecated use AV_CODEC_FLAG_COPY_OPAQUE to pass through arbitrary user
|
||||
* data from packets to frames
|
||||
*/
|
||||
attribute_deprecated
|
||||
int pkt_size;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* For hwaccel-format frames, this should be a reference to the
|
||||
@@ -659,13 +740,18 @@ typedef struct AVFrame {
|
||||
AVBufferRef *hw_frames_ctx;
|
||||
|
||||
/**
|
||||
* AVBufferRef for free use by the API user. FFmpeg will never check the
|
||||
* contents of the buffer ref. FFmpeg calls av_buffer_unref() on it when
|
||||
* the frame is unreferenced. av_frame_copy_props() calls create a new
|
||||
* reference with av_buffer_ref() for the target frame's opaque_ref field.
|
||||
* Frame owner's private data.
|
||||
*
|
||||
* This is unrelated to the opaque field, although it serves a similar
|
||||
* purpose.
|
||||
* This field may be set by the code that allocates/owns the frame data.
|
||||
* It is then not touched by any library functions, except:
|
||||
* - a new reference to the underlying buffer is propagated by
|
||||
* av_frame_copy_props() (and hence by av_frame_ref());
|
||||
* - it is unreferenced in av_frame_unref();
|
||||
* - on the caller's explicit request. E.g. libavcodec encoders/decoders
|
||||
* will propagate a new reference to/from @ref AVPacket "AVPackets" if the
|
||||
* caller sets @ref AV_CODEC_FLAG_COPY_OPAQUE.
|
||||
*
|
||||
* @see opaque the plain pointer analogue
|
||||
*/
|
||||
AVBufferRef *opaque_ref;
|
||||
|
||||
@@ -702,18 +788,14 @@ typedef struct AVFrame {
|
||||
* Channel layout of the audio data.
|
||||
*/
|
||||
AVChannelLayout ch_layout;
|
||||
|
||||
/**
|
||||
* Duration of the frame, in the same units as pts. 0 if unknown.
|
||||
*/
|
||||
int64_t duration;
|
||||
} AVFrame;
|
||||
|
||||
|
||||
#if FF_API_COLORSPACE_NAME
|
||||
/**
|
||||
* Get the name of a colorspace.
|
||||
* @return a static string identifying the colorspace; can be NULL.
|
||||
* @deprecated use av_color_space_name()
|
||||
*/
|
||||
attribute_deprecated
|
||||
const char *av_get_colorspace_name(enum AVColorSpace val);
|
||||
#endif
|
||||
/**
|
||||
* Allocate an AVFrame and set its fields to default values. The resulting
|
||||
* struct must be freed using av_frame_free().
|
||||
@@ -752,6 +834,19 @@ void av_frame_free(AVFrame **frame);
|
||||
*/
|
||||
int av_frame_ref(AVFrame *dst, const AVFrame *src);
|
||||
|
||||
/**
|
||||
* Ensure the destination frame refers to the same data described by the source
|
||||
* frame, either by creating a new reference for each AVBufferRef from src if
|
||||
* they differ from those in dst, by allocating new buffers and copying data if
|
||||
* src is not reference counted, or by unrefencing it if src is empty.
|
||||
*
|
||||
* Frame properties on dst will be replaced by those from src.
|
||||
*
|
||||
* @return 0 on success, a negative AVERROR on error. On error, dst is
|
||||
* unreferenced.
|
||||
*/
|
||||
int av_frame_replace(AVFrame *dst, const AVFrame *src);
|
||||
|
||||
/**
|
||||
* Create a new frame that references the same data as src.
|
||||
*
|
||||
@@ -818,7 +913,8 @@ int av_frame_is_writable(AVFrame *frame);
|
||||
* Ensure that the frame data is writable, avoiding data copy if possible.
|
||||
*
|
||||
* Do nothing if the frame is writable, allocate new buffers and copy the data
|
||||
* if it is not.
|
||||
* if it is not. Non-refcounted frames behave as non-writable, i.e. a copy
|
||||
* is always made.
|
||||
*
|
||||
* @return 0 on success, a negative AVERROR on error.
|
||||
*
|
||||
@@ -853,12 +949,13 @@ int av_frame_copy_props(AVFrame *dst, const AVFrame *src);
|
||||
/**
|
||||
* Get the buffer reference a given data plane is stored in.
|
||||
*
|
||||
* @param frame the frame to get the plane's buffer from
|
||||
* @param plane index of the data plane of interest in frame->extended_data.
|
||||
*
|
||||
* @return the buffer reference that contains the plane or NULL if the input
|
||||
* frame is not valid.
|
||||
*/
|
||||
AVBufferRef *av_frame_get_plane_buffer(AVFrame *frame, int plane);
|
||||
AVBufferRef *av_frame_get_plane_buffer(const AVFrame *frame, int plane);
|
||||
|
||||
/**
|
||||
* Add a new side data to a frame.
|
||||
@@ -940,6 +1037,137 @@ int av_frame_apply_cropping(AVFrame *frame, int flags);
|
||||
*/
|
||||
const char *av_frame_side_data_name(enum AVFrameSideDataType type);
|
||||
|
||||
/**
|
||||
* @return side data descriptor corresponding to a given side data type, NULL
|
||||
* when not available.
|
||||
*/
|
||||
const AVSideDataDescriptor *av_frame_side_data_desc(enum AVFrameSideDataType type);
|
||||
|
||||
/**
|
||||
* Free all side data entries and their contents, then zeroes out the
|
||||
* values which the pointers are pointing to.
|
||||
*
|
||||
* @param sd pointer to array of side data to free. Will be set to NULL
|
||||
* upon return.
|
||||
* @param nb_sd pointer to an integer containing the number of entries in
|
||||
* the array. Will be set to 0 upon return.
|
||||
*/
|
||||
void av_frame_side_data_free(AVFrameSideData ***sd, int *nb_sd);
|
||||
|
||||
/**
|
||||
* Remove existing entries before adding new ones.
|
||||
*/
|
||||
#define AV_FRAME_SIDE_DATA_FLAG_UNIQUE (1 << 0)
|
||||
/**
|
||||
* Don't add a new entry if another of the same type exists.
|
||||
* Applies only for side data types without the AV_SIDE_DATA_PROP_MULTI prop.
|
||||
*/
|
||||
#define AV_FRAME_SIDE_DATA_FLAG_REPLACE (1 << 1)
|
||||
|
||||
/**
|
||||
* Add new side data entry to an array.
|
||||
*
|
||||
* @param sd pointer to array of side data to which to add another entry,
|
||||
* or to NULL in order to start a new array.
|
||||
* @param nb_sd pointer to an integer containing the number of entries in
|
||||
* the array.
|
||||
* @param type type of the added side data
|
||||
* @param size size of the side data
|
||||
* @param flags Some combination of AV_FRAME_SIDE_DATA_FLAG_* flags, or 0.
|
||||
*
|
||||
* @return newly added side data on success, NULL on error.
|
||||
* @note In case of AV_FRAME_SIDE_DATA_FLAG_UNIQUE being set, entries of
|
||||
* matching AVFrameSideDataType will be removed before the addition
|
||||
* is attempted.
|
||||
* @note In case of AV_FRAME_SIDE_DATA_FLAG_REPLACE being set, if an
|
||||
* entry of the same type already exists, it will be replaced instead.
|
||||
*/
|
||||
AVFrameSideData *av_frame_side_data_new(AVFrameSideData ***sd, int *nb_sd,
|
||||
enum AVFrameSideDataType type,
|
||||
size_t size, unsigned int flags);
|
||||
|
||||
/**
|
||||
* Add a new side data entry to an array from an existing AVBufferRef.
|
||||
*
|
||||
* @param sd pointer to array of side data to which to add another entry,
|
||||
* or to NULL in order to start a new array.
|
||||
* @param nb_sd pointer to an integer containing the number of entries in
|
||||
* the array.
|
||||
* @param type type of the added side data
|
||||
* @param buf Pointer to AVBufferRef to add to the array. On success,
|
||||
* the function takes ownership of the AVBufferRef and *buf is
|
||||
* set to NULL, unless AV_FRAME_SIDE_DATA_FLAG_NEW_REF is set
|
||||
* in which case the ownership will remain with the caller.
|
||||
* @param flags Some combination of AV_FRAME_SIDE_DATA_FLAG_* flags, or 0.
|
||||
*
|
||||
* @return newly added side data on success, NULL on error.
|
||||
* @note In case of AV_FRAME_SIDE_DATA_FLAG_UNIQUE being set, entries of
|
||||
* matching AVFrameSideDataType will be removed before the addition
|
||||
* is attempted.
|
||||
* @note In case of AV_FRAME_SIDE_DATA_FLAG_REPLACE being set, if an
|
||||
* entry of the same type already exists, it will be replaced instead.
|
||||
*
|
||||
*/
|
||||
AVFrameSideData *av_frame_side_data_add(AVFrameSideData ***sd, int *nb_sd,
|
||||
enum AVFrameSideDataType type,
|
||||
AVBufferRef **buf, unsigned int flags);
|
||||
|
||||
/**
|
||||
* Add a new side data entry to an array based on existing side data, taking
|
||||
* a reference towards the contained AVBufferRef.
|
||||
*
|
||||
* @param sd pointer to array of side data to which to add another entry,
|
||||
* or to NULL in order to start a new array.
|
||||
* @param nb_sd pointer to an integer containing the number of entries in
|
||||
* the array.
|
||||
* @param src side data to be cloned, with a new reference utilized
|
||||
* for the buffer.
|
||||
* @param flags Some combination of AV_FRAME_SIDE_DATA_FLAG_* flags, or 0.
|
||||
*
|
||||
* @return negative error code on failure, >=0 on success.
|
||||
* @note In case of AV_FRAME_SIDE_DATA_FLAG_UNIQUE being set, entries of
|
||||
* matching AVFrameSideDataType will be removed before the addition
|
||||
* is attempted.
|
||||
* @note In case of AV_FRAME_SIDE_DATA_FLAG_REPLACE being set, if an
|
||||
* entry of the same type already exists, it will be replaced instead.
|
||||
*/
|
||||
int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd,
|
||||
const AVFrameSideData *src, unsigned int flags);
|
||||
|
||||
/**
|
||||
* Get a side data entry of a specific type from an array.
|
||||
*
|
||||
* @param sd array of side data.
|
||||
* @param nb_sd integer containing the number of entries in the array.
|
||||
* @param type type of side data to be queried
|
||||
*
|
||||
* @return a pointer to the side data of a given type on success, NULL if there
|
||||
* is no side data with such type in this set.
|
||||
*/
|
||||
const AVFrameSideData *av_frame_side_data_get_c(const AVFrameSideData * const *sd,
|
||||
const int nb_sd,
|
||||
enum AVFrameSideDataType type);
|
||||
|
||||
/**
|
||||
* Wrapper around av_frame_side_data_get_c() to workaround the limitation
|
||||
* that for any type T the conversion from T * const * to const T * const *
|
||||
* is not performed automatically in C.
|
||||
* @see av_frame_side_data_get_c()
|
||||
*/
|
||||
static inline
|
||||
const AVFrameSideData *av_frame_side_data_get(AVFrameSideData * const *sd,
|
||||
const int nb_sd,
|
||||
enum AVFrameSideDataType type)
|
||||
{
|
||||
return av_frame_side_data_get_c((const AVFrameSideData * const *)sd,
|
||||
nb_sd, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove and free all side data instances of the given type from an array.
|
||||
*/
|
||||
void av_frame_side_data_remove(AVFrameSideData ***sd, int *nb_sd,
|
||||
enum AVFrameSideDataType type);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
@@ -340,4 +340,37 @@ AVDynamicHDRPlus *av_dynamic_hdr_plus_alloc(size_t *size);
|
||||
*/
|
||||
AVDynamicHDRPlus *av_dynamic_hdr_plus_create_side_data(AVFrame *frame);
|
||||
|
||||
/**
|
||||
* Parse the user data registered ITU-T T.35 to AVbuffer (AVDynamicHDRPlus).
|
||||
* The T.35 buffer must begin with the application mode, skipping the
|
||||
* country code, terminal provider codes, and application identifier.
|
||||
* @param s A pointer containing the decoded AVDynamicHDRPlus structure.
|
||||
* @param data The byte array containing the raw ITU-T T.35 data.
|
||||
* @param size Size of the data array in bytes.
|
||||
*
|
||||
* @return >= 0 on success. Otherwise, returns the appropriate AVERROR.
|
||||
*/
|
||||
int av_dynamic_hdr_plus_from_t35(AVDynamicHDRPlus *s, const uint8_t *data,
|
||||
size_t size);
|
||||
|
||||
#define AV_HDR_PLUS_MAX_PAYLOAD_SIZE 907
|
||||
|
||||
/**
|
||||
* Serialize dynamic HDR10+ metadata to a user data registered ITU-T T.35 buffer,
|
||||
* excluding the first 48 bytes of the header, and beginning with the application mode.
|
||||
* @param s A pointer containing the decoded AVDynamicHDRPlus structure.
|
||||
* @param[in,out] data A pointer to pointer to a byte buffer to be filled with the
|
||||
* serialized metadata.
|
||||
* If *data is NULL, a buffer be will be allocated and a pointer to
|
||||
* it stored in its place. The caller assumes ownership of the buffer.
|
||||
* May be NULL, in which case the function will only store the
|
||||
* required buffer size in *size.
|
||||
* @param[in,out] size A pointer to a size to be set to the returned buffer's size.
|
||||
* If *data is not NULL, *size must contain the size of the input
|
||||
* buffer. May be NULL only if *data is NULL.
|
||||
*
|
||||
* @return >= 0 on success. Otherwise, returns the appropriate AVERROR.
|
||||
*/
|
||||
int av_dynamic_hdr_plus_to_t35(const AVDynamicHDRPlus *s, uint8_t **data, size_t *size);
|
||||
|
||||
#endif /* AVUTIL_HDR_DYNAMIC_METADATA_H */
|
||||
|
||||
@@ -24,6 +24,52 @@
|
||||
#include "frame.h"
|
||||
#include "rational.h"
|
||||
|
||||
/**
|
||||
* HDR Vivid three spline params.
|
||||
*/
|
||||
typedef struct AVHDRVivid3SplineParams {
|
||||
/**
|
||||
* The mode of three Spline. the value shall be in the range
|
||||
* of 0 to 3, inclusive.
|
||||
*/
|
||||
int th_mode;
|
||||
|
||||
/**
|
||||
* three_Spline_TH_enable_MB is in the range of 0.0 to 1.0, inclusive
|
||||
* and in multiples of 1.0/255.
|
||||
*
|
||||
*/
|
||||
AVRational th_enable_mb;
|
||||
|
||||
/**
|
||||
* 3Spline_TH_enable of three Spline.
|
||||
* The value shall be in the range of 0.0 to 1.0, inclusive.
|
||||
* and in multiples of 1.0/4095.
|
||||
*/
|
||||
AVRational th_enable;
|
||||
|
||||
/**
|
||||
* 3Spline_TH_Delta1 of three Spline.
|
||||
* The value shall be in the range of 0.0 to 0.25, inclusive,
|
||||
* and in multiples of 0.25/1023.
|
||||
*/
|
||||
AVRational th_delta1;
|
||||
|
||||
/**
|
||||
* 3Spline_TH_Delta2 of three Spline.
|
||||
* The value shall be in the range of 0.0 to 0.25, inclusive,
|
||||
* and in multiples of 0.25/1023.
|
||||
*/
|
||||
AVRational th_delta2;
|
||||
|
||||
/**
|
||||
* 3Spline_enable_Strength of three Spline.
|
||||
* The value shall be in the range of 0.0 to 1.0, inclusive,
|
||||
* and in multiples of 1.0/255.
|
||||
*/
|
||||
AVRational enable_strength;
|
||||
} AVHDRVivid3SplineParams;
|
||||
|
||||
/**
|
||||
* Color tone mapping parameters at a processing window in a dynamic metadata for
|
||||
* CUVA 005.1:2021.
|
||||
@@ -122,46 +168,61 @@ typedef struct AVHDRVividColorToneMappingParams {
|
||||
*/
|
||||
int three_Spline_num;
|
||||
|
||||
#if FF_API_HDR_VIVID_THREE_SPLINE
|
||||
/**
|
||||
* The mode of three Spline. the value shall be in the range
|
||||
* of 0 to 3, inclusive.
|
||||
* @deprecated Use three_spline instead
|
||||
*/
|
||||
attribute_deprecated
|
||||
int three_Spline_TH_mode;
|
||||
|
||||
/**
|
||||
* three_Spline_TH_enable_MB is in the range of 0.0 to 1.0, inclusive
|
||||
* and in multiples of 1.0/255.
|
||||
*
|
||||
* @deprecated Use three_spline instead
|
||||
*/
|
||||
attribute_deprecated
|
||||
AVRational three_Spline_TH_enable_MB;
|
||||
|
||||
/**
|
||||
* 3Spline_TH_enable of three Spline.
|
||||
* The value shall be in the range of 0.0 to 1.0, inclusive.
|
||||
* and in multiples of 1.0/4095.
|
||||
* @deprecated Use three_spline instead
|
||||
*/
|
||||
attribute_deprecated
|
||||
AVRational three_Spline_TH_enable;
|
||||
|
||||
/**
|
||||
* 3Spline_TH_Delta1 of three Spline.
|
||||
* The value shall be in the range of 0.0 to 0.25, inclusive,
|
||||
* and in multiples of 0.25/1023.
|
||||
* @deprecated Use three_spline instead
|
||||
*/
|
||||
attribute_deprecated
|
||||
AVRational three_Spline_TH_Delta1;
|
||||
|
||||
/**
|
||||
* 3Spline_TH_Delta2 of three Spline.
|
||||
* The value shall be in the range of 0.0 to 0.25, inclusive,
|
||||
* and in multiples of 0.25/1023.
|
||||
* @deprecated Use three_spline instead
|
||||
*/
|
||||
attribute_deprecated
|
||||
AVRational three_Spline_TH_Delta2;
|
||||
|
||||
/**
|
||||
* 3Spline_enable_Strength of three Spline.
|
||||
* The value shall be in the range of 0.0 to 1.0, inclusive,
|
||||
* and in multiples of 1.0/255.
|
||||
* @deprecated Use three_spline instead
|
||||
*/
|
||||
attribute_deprecated
|
||||
AVRational three_Spline_enable_Strength;
|
||||
#endif
|
||||
|
||||
AVHDRVivid3SplineParams three_spline[2];
|
||||
} AVHDRVividColorToneMappingParams;
|
||||
|
||||
|
||||
|
||||
@@ -37,10 +37,9 @@ enum AVHWDeviceType {
|
||||
AV_HWDEVICE_TYPE_OPENCL,
|
||||
AV_HWDEVICE_TYPE_MEDIACODEC,
|
||||
AV_HWDEVICE_TYPE_VULKAN,
|
||||
AV_HWDEVICE_TYPE_D3D12VA,
|
||||
};
|
||||
|
||||
typedef struct AVHWDeviceInternal AVHWDeviceInternal;
|
||||
|
||||
/**
|
||||
* This struct aggregates all the (hardware/vendor-specific) "high-level" state,
|
||||
* i.e. state that is not tied to a concrete processing configuration.
|
||||
@@ -64,12 +63,6 @@ typedef struct AVHWDeviceContext {
|
||||
*/
|
||||
const AVClass *av_class;
|
||||
|
||||
/**
|
||||
* Private data used internally by libavutil. Must not be accessed in any
|
||||
* way by the caller.
|
||||
*/
|
||||
AVHWDeviceInternal *internal;
|
||||
|
||||
/**
|
||||
* This field identifies the underlying API used for hardware access.
|
||||
*
|
||||
@@ -109,8 +102,6 @@ typedef struct AVHWDeviceContext {
|
||||
void *user_opaque;
|
||||
} AVHWDeviceContext;
|
||||
|
||||
typedef struct AVHWFramesInternal AVHWFramesInternal;
|
||||
|
||||
/**
|
||||
* This struct describes a set or pool of "hardware" frames (i.e. those with
|
||||
* data not located in normal system memory). All the frames in the pool are
|
||||
@@ -127,12 +118,6 @@ typedef struct AVHWFramesContext {
|
||||
*/
|
||||
const AVClass *av_class;
|
||||
|
||||
/**
|
||||
* Private data used internally by libavutil. Must not be accessed in any
|
||||
* way by the caller.
|
||||
*/
|
||||
AVHWFramesInternal *internal;
|
||||
|
||||
/**
|
||||
* A reference to the parent AVHWDeviceContext. This reference is owned and
|
||||
* managed by the enclosing AVHWFramesContext, but the caller may derive
|
||||
@@ -152,9 +137,12 @@ typedef struct AVHWFramesContext {
|
||||
* The format-specific data, allocated and freed automatically along with
|
||||
* this context.
|
||||
*
|
||||
* Should be cast by the user to the format-specific context defined in the
|
||||
* corresponding header (hwframe_*.h) and filled as described in the
|
||||
* documentation before calling av_hwframe_ctx_init().
|
||||
* The user shall ignore this field if the corresponding format-specific
|
||||
* header (hwcontext_*.h) does not define a context to be used as
|
||||
* AVHWFramesContext.hwctx.
|
||||
*
|
||||
* Otherwise, it should be cast by the user to said context and filled
|
||||
* as described in the documentation before calling av_hwframe_ctx_init().
|
||||
*
|
||||
* After any frames using this context are created, the contents of this
|
||||
* struct should not be modified by the caller.
|
||||
@@ -249,7 +237,7 @@ const char *av_hwdevice_get_type_name(enum AVHWDeviceType type);
|
||||
/**
|
||||
* Iterate over supported device types.
|
||||
*
|
||||
* @param type AV_HWDEVICE_TYPE_NONE initially, then the previous type
|
||||
* @param prev AV_HWDEVICE_TYPE_NONE initially, then the previous type
|
||||
* returned by this function in subsequent iterations.
|
||||
* @return The next usable device type from enum AVHWDeviceType, or
|
||||
* AV_HWDEVICE_TYPE_NONE if there are no more.
|
||||
@@ -591,6 +579,7 @@ int av_hwframe_map(AVFrame *dst, const AVFrame *src, int flags);
|
||||
*
|
||||
* @param derived_frame_ctx On success, a reference to the newly created
|
||||
* AVHWFramesContext.
|
||||
* @param format The AVPixelFormat for the derived context.
|
||||
* @param derived_device_ctx A reference to the device to create the new
|
||||
* AVHWFramesContext on.
|
||||
* @param source_frame_ctx A reference to an existing AVHWFramesContext
|
||||
|
||||
@@ -62,6 +62,11 @@ typedef struct AVCUDADeviceContext {
|
||||
*/
|
||||
#define AV_CUDA_USE_PRIMARY_CONTEXT (1 << 0)
|
||||
|
||||
/**
|
||||
* Use current device context instead of creating a new one.
|
||||
*/
|
||||
#define AV_CUDA_USE_CURRENT_CONTEXT (1 << 1)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
142
include/libavutil/hwcontext_d3d12va.h
Normal file
142
include/libavutil/hwcontext_d3d12va.h
Normal file
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
* Direct3D 12 HW acceleration.
|
||||
*
|
||||
* copyright (c) 2022-2023 Wu Jianhua <toqsxw@outlook.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_HWCONTEXT_D3D12VA_H
|
||||
#define AVUTIL_HWCONTEXT_D3D12VA_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* An API-specific header for AV_HWDEVICE_TYPE_D3D12VA.
|
||||
*
|
||||
* AVHWFramesContext.pool must contain AVBufferRefs whose
|
||||
* data pointer points to an AVD3D12VAFrame struct.
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <initguid.h>
|
||||
#include <d3d12.h>
|
||||
#include <d3d12sdklayers.h>
|
||||
#include <d3d12video.h>
|
||||
|
||||
/**
|
||||
* @brief This struct is allocated as AVHWDeviceContext.hwctx
|
||||
*
|
||||
*/
|
||||
typedef struct AVD3D12VADeviceContext {
|
||||
/**
|
||||
* Device used for objects creation and access. This can also be
|
||||
* used to set the libavcodec decoding device.
|
||||
*
|
||||
* Can be set by the user. This is the only mandatory field - the other
|
||||
* device context fields are set from this and are available for convenience.
|
||||
*
|
||||
* Deallocating the AVHWDeviceContext will always release this interface,
|
||||
* and it does not matter whether it was user-allocated.
|
||||
*/
|
||||
ID3D12Device *device;
|
||||
|
||||
/**
|
||||
* If unset, this will be set from the device field on init.
|
||||
*
|
||||
* Deallocating the AVHWDeviceContext will always release this interface,
|
||||
* and it does not matter whether it was user-allocated.
|
||||
*/
|
||||
ID3D12VideoDevice *video_device;
|
||||
|
||||
/**
|
||||
* Callbacks for locking. They protect access to the internal staging
|
||||
* texture (for av_hwframe_transfer_data() calls). They do NOT protect
|
||||
* access to hwcontext or decoder state in general.
|
||||
*
|
||||
* If unset on init, the hwcontext implementation will set them to use an
|
||||
* internal mutex.
|
||||
*
|
||||
* The underlying lock must be recursive. lock_ctx is for free use by the
|
||||
* locking implementation.
|
||||
*/
|
||||
void (*lock)(void *lock_ctx);
|
||||
void (*unlock)(void *lock_ctx);
|
||||
void *lock_ctx;
|
||||
} AVD3D12VADeviceContext;
|
||||
|
||||
/**
|
||||
* @brief This struct is used to sync d3d12 execution
|
||||
*
|
||||
*/
|
||||
typedef struct AVD3D12VASyncContext {
|
||||
/**
|
||||
* D3D12 fence object
|
||||
*/
|
||||
ID3D12Fence *fence;
|
||||
|
||||
/**
|
||||
* A handle to the event object that's raised when the fence
|
||||
* reaches a certain value.
|
||||
*/
|
||||
HANDLE event;
|
||||
|
||||
/**
|
||||
* The fence value used for sync
|
||||
*/
|
||||
uint64_t fence_value;
|
||||
} AVD3D12VASyncContext;
|
||||
|
||||
/**
|
||||
* @brief D3D12VA frame descriptor for pool allocation.
|
||||
*
|
||||
*/
|
||||
typedef struct AVD3D12VAFrame {
|
||||
/**
|
||||
* The texture in which the frame is located. The reference count is
|
||||
* managed by the AVBufferRef, and destroying the reference will release
|
||||
* the interface.
|
||||
*/
|
||||
ID3D12Resource *texture;
|
||||
|
||||
/**
|
||||
* The sync context for the texture
|
||||
*
|
||||
* @see: https://learn.microsoft.com/en-us/windows/win32/medfound/direct3d-12-video-overview#directx-12-fences
|
||||
*/
|
||||
AVD3D12VASyncContext sync_ctx;
|
||||
} AVD3D12VAFrame;
|
||||
|
||||
/**
|
||||
* @brief This struct is allocated as AVHWFramesContext.hwctx
|
||||
*
|
||||
*/
|
||||
typedef struct AVD3D12VAFramesContext {
|
||||
/**
|
||||
* DXGI_FORMAT format. MUST be compatible with the pixel format.
|
||||
* If unset, will be automatically set.
|
||||
*/
|
||||
DXGI_FORMAT format;
|
||||
|
||||
/**
|
||||
* Options for working with resources.
|
||||
* If unset, this will be D3D12_RESOURCE_FLAG_NONE.
|
||||
*
|
||||
* @see https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ne-d3d12-d3d12_resource_flags
|
||||
*/
|
||||
D3D12_RESOURCE_FLAGS flags;
|
||||
} AVD3D12VAFramesContext;
|
||||
|
||||
#endif /* AVUTIL_HWCONTEXT_D3D12VA_H */
|
||||
@@ -31,6 +31,31 @@ typedef struct AVMediaCodecDeviceContext {
|
||||
* This is the default surface used by decoders on this device.
|
||||
*/
|
||||
void *surface;
|
||||
|
||||
/**
|
||||
* Pointer to ANativeWindow.
|
||||
*
|
||||
* It both surface and native_window is NULL, try to create it
|
||||
* automatically if create_window is true and OS support
|
||||
* createPersistentInputSurface.
|
||||
*
|
||||
* It can be used as output surface for decoder and input surface for
|
||||
* encoder.
|
||||
*/
|
||||
void *native_window;
|
||||
|
||||
/**
|
||||
* Enable createPersistentInputSurface automatically.
|
||||
*
|
||||
* Disabled by default.
|
||||
*
|
||||
* It can be enabled by setting this flag directly, or by setting
|
||||
* AVDictionary of av_hwdevice_ctx_create(), with "create_window" as key.
|
||||
* The second method is useful for ffmpeg cmdline, e.g., we can enable it
|
||||
* via:
|
||||
* -init_hw_device mediacodec=mediacodec,create_window=1
|
||||
*/
|
||||
int create_window;
|
||||
} AVMediaCodecDeviceContext;
|
||||
|
||||
#endif /* AVUTIL_HWCONTEXT_MEDIACODEC_H */
|
||||
|
||||
@@ -19,14 +19,14 @@
|
||||
#ifndef AVUTIL_HWCONTEXT_QSV_H
|
||||
#define AVUTIL_HWCONTEXT_QSV_H
|
||||
|
||||
#include <mfx/mfxvideo.h>
|
||||
#include <mfxvideo.h>
|
||||
|
||||
/**
|
||||
* @file
|
||||
* An API-specific header for AV_HWDEVICE_TYPE_QSV.
|
||||
*
|
||||
* This API does not support dynamic frame pools. AVHWFramesContext.pool must
|
||||
* contain AVBufferRefs whose data pointer points to an mfxFrameSurface1 struct.
|
||||
* AVHWFramesContext.pool must contain AVBufferRefs whose data pointer points
|
||||
* to a mfxFrameSurface1 struct.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -34,19 +34,53 @@
|
||||
*/
|
||||
typedef struct AVQSVDeviceContext {
|
||||
mfxSession session;
|
||||
/**
|
||||
* The mfxLoader handle used for mfxSession creation
|
||||
*
|
||||
* This field is only available for oneVPL user. For non-oneVPL user, this
|
||||
* field must be set to NULL.
|
||||
*
|
||||
* Filled by the user before calling av_hwdevice_ctx_init() and should be
|
||||
* cast to mfxLoader handle. Deallocating the AVHWDeviceContext will always
|
||||
* release this interface.
|
||||
*/
|
||||
void *loader;
|
||||
} AVQSVDeviceContext;
|
||||
|
||||
/**
|
||||
* This struct is allocated as AVHWFramesContext.hwctx
|
||||
*/
|
||||
typedef struct AVQSVFramesContext {
|
||||
/**
|
||||
* A pointer to a mfxFrameSurface1 struct
|
||||
*
|
||||
* It is available when nb_surfaces is non-zero.
|
||||
*/
|
||||
mfxFrameSurface1 *surfaces;
|
||||
|
||||
/**
|
||||
* Number of frames in the pool
|
||||
*
|
||||
* It is 0 for dynamic frame pools or AVHWFramesContext.initial_pool_size
|
||||
* for fixed frame pools.
|
||||
*
|
||||
* Note only oneVPL GPU runtime 2.9+ can support dynamic frame pools
|
||||
* on d3d11va or vaapi
|
||||
*/
|
||||
int nb_surfaces;
|
||||
|
||||
/**
|
||||
* A combination of MFX_MEMTYPE_* describing the frame pool.
|
||||
*/
|
||||
int frame_type;
|
||||
|
||||
/**
|
||||
* A pointer to a mfxFrameInfo struct
|
||||
*
|
||||
* It is available when nb_surfaces is 0, all buffers allocated from the
|
||||
* pool have the same mfxFrameInfo.
|
||||
*/
|
||||
mfxFrameInfo *info;
|
||||
} AVQSVFramesContext;
|
||||
|
||||
#endif /* AVUTIL_HWCONTEXT_QSV_H */
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include <VideoToolbox/VideoToolbox.h>
|
||||
|
||||
#include "frame.h"
|
||||
#include "pixfmt.h"
|
||||
|
||||
/**
|
||||
@@ -38,10 +39,13 @@
|
||||
* depending on application usage, so it is preferable to let CoreVideo manage
|
||||
* the pool using the default implementation.
|
||||
*
|
||||
* Currently AVHWDeviceContext.hwctx and AVHWFramesContext.hwctx are always
|
||||
* NULL.
|
||||
* Currently AVHWDeviceContext.hwctx are always NULL.
|
||||
*/
|
||||
|
||||
typedef struct AVVTFramesContext {
|
||||
enum AVColorRange color_range;
|
||||
} AVVTFramesContext;
|
||||
|
||||
/**
|
||||
* Convert a VideoToolbox (actually CoreVideo) format to AVPixelFormat.
|
||||
* Returns AV_PIX_FMT_NONE if no known equivalent was found.
|
||||
@@ -86,8 +90,15 @@ CFStringRef av_map_videotoolbox_color_primaries_from_av(enum AVColorPrimaries pr
|
||||
CFStringRef av_map_videotoolbox_color_trc_from_av(enum AVColorTransferCharacteristic trc);
|
||||
|
||||
/**
|
||||
* Update a CVPixelBufferRef's metadata to based on an AVFrame.
|
||||
* Returns 0 if no known equivalent was found.
|
||||
* Set CVPixelBufferRef's metadata based on an AVFrame.
|
||||
*
|
||||
* Sets/unsets the CVPixelBuffer attachments to match as closely as possible the
|
||||
* AVFrame metadata. To prevent inconsistent attachments, the attachments for properties
|
||||
* that could not be matched or are unspecified in the given AVFrame are unset. So if
|
||||
* any attachments already covered by AVFrame metadata need to be set to a specific
|
||||
* value, this should happen after calling this function.
|
||||
*
|
||||
* Returns < 0 in case of an error.
|
||||
*/
|
||||
int av_vt_pixbuf_set_attachments(void *log_ctx,
|
||||
CVPixelBufferRef pixbuf, const struct AVFrame *src);
|
||||
|
||||
@@ -26,6 +26,23 @@
|
||||
|
||||
#include "pixfmt.h"
|
||||
#include "frame.h"
|
||||
#include "hwcontext.h"
|
||||
|
||||
typedef struct AVVkFrame AVVkFrame;
|
||||
|
||||
typedef struct AVVulkanDeviceQueueFamily {
|
||||
/* Queue family index */
|
||||
int idx;
|
||||
/* Number of queues in the queue family in use */
|
||||
int num;
|
||||
/* Queue family capabilities. Must be non-zero.
|
||||
* Flags may be removed to indicate the queue family may not be used
|
||||
* for a given purpose. */
|
||||
VkQueueFlagBits flags;
|
||||
/* Vulkan implementations are allowed to list multiple video queues
|
||||
* which differ in what they can encode or decode. */
|
||||
VkVideoCodecOperationFlagBitsKHR video_caps;
|
||||
} AVVulkanDeviceQueueFamily;
|
||||
|
||||
/**
|
||||
* @file
|
||||
@@ -46,14 +63,13 @@ typedef struct AVVulkanDeviceContext {
|
||||
const VkAllocationCallbacks *alloc;
|
||||
|
||||
/**
|
||||
* Pointer to the instance-provided vkGetInstanceProcAddr loading function.
|
||||
* If NULL, will pick either libvulkan or libvolk, depending on libavutil's
|
||||
* compilation settings, and set this field.
|
||||
* Pointer to a vkGetInstanceProcAddr loading function.
|
||||
* If unset, will dynamically load and use libvulkan.
|
||||
*/
|
||||
PFN_vkGetInstanceProcAddr get_proc_addr;
|
||||
|
||||
/**
|
||||
* Vulkan instance. Must be at least version 1.2.
|
||||
* Vulkan instance. Must be at least version 1.3.
|
||||
*/
|
||||
VkInstance inst;
|
||||
|
||||
@@ -96,6 +112,7 @@ typedef struct AVVulkanDeviceContext {
|
||||
const char * const *enabled_dev_extensions;
|
||||
int nb_enabled_dev_extensions;
|
||||
|
||||
#if FF_API_VULKAN_FIXED_QUEUES
|
||||
/**
|
||||
* Queue family index for graphics operations, and the number of queues
|
||||
* enabled for it. If unavaiable, will be set to -1. Not required.
|
||||
@@ -103,21 +120,27 @@ typedef struct AVVulkanDeviceContext {
|
||||
* queue family, or pick the one with the least unrelated flags set.
|
||||
* Queue indices here may overlap if a queue has to share capabilities.
|
||||
*/
|
||||
attribute_deprecated
|
||||
int queue_family_index;
|
||||
attribute_deprecated
|
||||
int nb_graphics_queues;
|
||||
|
||||
/**
|
||||
* Queue family index for transfer operations and the number of queues
|
||||
* enabled. Required.
|
||||
*/
|
||||
attribute_deprecated
|
||||
int queue_family_tx_index;
|
||||
attribute_deprecated
|
||||
int nb_tx_queues;
|
||||
|
||||
/**
|
||||
* Queue family index for compute operations and the number of queues
|
||||
* enabled. Required.
|
||||
*/
|
||||
attribute_deprecated
|
||||
int queue_family_comp_index;
|
||||
attribute_deprecated
|
||||
int nb_comp_queues;
|
||||
|
||||
/**
|
||||
@@ -125,7 +148,9 @@ typedef struct AVVulkanDeviceContext {
|
||||
* If the device doesn't support such, queue_family_encode_index will be -1.
|
||||
* Not required.
|
||||
*/
|
||||
attribute_deprecated
|
||||
int queue_family_encode_index;
|
||||
attribute_deprecated
|
||||
int nb_encode_queues;
|
||||
|
||||
/**
|
||||
@@ -133,8 +158,35 @@ typedef struct AVVulkanDeviceContext {
|
||||
* If the device doesn't support such, queue_family_decode_index will be -1.
|
||||
* Not required.
|
||||
*/
|
||||
attribute_deprecated
|
||||
int queue_family_decode_index;
|
||||
attribute_deprecated
|
||||
int nb_decode_queues;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Locks a queue, preventing other threads from submitting any command
|
||||
* buffers to this queue.
|
||||
* If set to NULL, will be set to lavu-internal functions that utilize a
|
||||
* mutex.
|
||||
*/
|
||||
void (*lock_queue)(struct AVHWDeviceContext *ctx, uint32_t queue_family, uint32_t index);
|
||||
|
||||
/**
|
||||
* Similar to lock_queue(), unlocks a queue. Must only be called after locking.
|
||||
*/
|
||||
void (*unlock_queue)(struct AVHWDeviceContext *ctx, uint32_t queue_family, uint32_t index);
|
||||
|
||||
/**
|
||||
* Queue families used. Must be preferentially ordered. List may contain
|
||||
* duplicates.
|
||||
*
|
||||
* For compatibility reasons, all the enabled queue families listed above
|
||||
* (queue_family_(tx/comp/encode/decode)_index) must also be included in
|
||||
* this list until they're removed after deprecation.
|
||||
*/
|
||||
AVVulkanDeviceQueueFamily qf[64];
|
||||
int nb_qf;
|
||||
} AVVulkanDeviceContext;
|
||||
|
||||
/**
|
||||
@@ -145,10 +197,14 @@ typedef enum AVVkFrameFlags {
|
||||
* device and tiling during av_hwframe_ctx_init(). */
|
||||
AV_VK_FRAME_FLAG_NONE = (1ULL << 0),
|
||||
|
||||
/* Image planes will be allocated in a single VkDeviceMemory, rather
|
||||
* than as per-plane VkDeviceMemory allocations. Required for exporting
|
||||
* to VAAPI on Intel devices. */
|
||||
#if FF_API_VULKAN_CONTIGUOUS_MEMORY
|
||||
/* DEPRECATED: does nothing. Replaced by multiplane images. */
|
||||
AV_VK_FRAME_FLAG_CONTIGUOUS_MEMORY = (1ULL << 1),
|
||||
#endif
|
||||
|
||||
/* Disables multiplane images.
|
||||
* This is required to export/import images from CUDA. */
|
||||
AV_VK_FRAME_FLAG_DISABLE_MULTIPLANE = (1ULL << 2),
|
||||
} AVVkFrameFlags;
|
||||
|
||||
/**
|
||||
@@ -156,26 +212,32 @@ typedef enum AVVkFrameFlags {
|
||||
*/
|
||||
typedef struct AVVulkanFramesContext {
|
||||
/**
|
||||
* Controls the tiling of allocated frames. If left as optimal tiling,
|
||||
* then during av_hwframe_ctx_init() will decide based on whether the device
|
||||
* supports DRM modifiers, or if the linear_images flag is set, otherwise
|
||||
* will allocate optimally-tiled images.
|
||||
* Controls the tiling of allocated frames.
|
||||
* If left as VK_IMAGE_TILING_OPTIMAL (0), will use optimal tiling.
|
||||
* Can be set to VK_IMAGE_TILING_LINEAR to force linear images,
|
||||
* or VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT to force DMABUF-backed
|
||||
* images.
|
||||
* @note Imported frames from other APIs ignore this.
|
||||
*/
|
||||
VkImageTiling tiling;
|
||||
|
||||
/**
|
||||
* Defines extra usage of output frames. If left as 0, the following bits
|
||||
* are set: TRANSFER_SRC, TRANSFER_DST. SAMPLED and STORAGE.
|
||||
* Defines extra usage of output frames. If non-zero, all flags MUST be
|
||||
* supported by the VkFormat. Otherwise, will use supported flags amongst:
|
||||
* - VK_IMAGE_USAGE_SAMPLED_BIT
|
||||
* - VK_IMAGE_USAGE_STORAGE_BIT
|
||||
* - VK_IMAGE_USAGE_TRANSFER_SRC_BIT
|
||||
* - VK_IMAGE_USAGE_TRANSFER_DST_BIT
|
||||
*/
|
||||
VkImageUsageFlagBits usage;
|
||||
|
||||
/**
|
||||
* Extension data for image creation.
|
||||
* If VkImageDrmFormatModifierListCreateInfoEXT is present in the chain,
|
||||
* and the device supports DRM modifiers, then images will be allocated
|
||||
* with the specific requested DRM modifiers.
|
||||
* If DRM tiling is used, a VkImageDrmFormatModifierListCreateInfoEXT structure
|
||||
* can be added to specify the exact modifier to use.
|
||||
*
|
||||
* Additional structures may be added at av_hwframe_ctx_init() time,
|
||||
* which will be freed automatically on uninit(), so users need only free
|
||||
* which will be freed automatically on uninit(), so users must only free
|
||||
* any structures they've allocated themselves.
|
||||
*/
|
||||
void *create_pnext;
|
||||
@@ -195,36 +257,65 @@ typedef struct AVVulkanFramesContext {
|
||||
* av_hwframe_ctx_init().
|
||||
*/
|
||||
AVVkFrameFlags flags;
|
||||
|
||||
/**
|
||||
* Flags to set during image creation. If unset, defaults to
|
||||
* VK_IMAGE_CREATE_ALIAS_BIT.
|
||||
*/
|
||||
VkImageCreateFlags img_flags;
|
||||
|
||||
/**
|
||||
* Vulkan format for each image. MUST be compatible with the pixel format.
|
||||
* If unset, will be automatically set.
|
||||
* There are at most two compatible formats for a frame - a multiplane
|
||||
* format, and a single-plane multi-image format.
|
||||
*/
|
||||
VkFormat format[AV_NUM_DATA_POINTERS];
|
||||
|
||||
/**
|
||||
* Number of layers each image will have.
|
||||
*/
|
||||
int nb_layers;
|
||||
|
||||
/**
|
||||
* Locks a frame, preventing other threads from changing frame properties.
|
||||
* Users SHOULD only ever lock just before command submission in order
|
||||
* to get accurate frame properties, and unlock immediately after command
|
||||
* submission without waiting for it to finish.
|
||||
*
|
||||
* If unset, will be set to lavu-internal functions that utilize a mutex.
|
||||
*/
|
||||
void (*lock_frame)(struct AVHWFramesContext *fc, AVVkFrame *vkf);
|
||||
|
||||
/**
|
||||
* Similar to lock_frame(), unlocks a frame. Must only be called after locking.
|
||||
*/
|
||||
void (*unlock_frame)(struct AVHWFramesContext *fc, AVVkFrame *vkf);
|
||||
} AVVulkanFramesContext;
|
||||
|
||||
/*
|
||||
* Frame structure, the VkFormat of the image will always match
|
||||
* the pool's sw_format.
|
||||
* All frames, imported or allocated, will be created with the
|
||||
* VK_IMAGE_CREATE_ALIAS_BIT flag set, so the memory may be aliased if needed.
|
||||
*
|
||||
* If all queue family indices in the device context are the same,
|
||||
* images will be created with the EXCLUSIVE sharing mode. Otherwise, all images
|
||||
* will be created using the CONCURRENT sharing mode.
|
||||
* Frame structure.
|
||||
*
|
||||
* @note the size of this structure is not part of the ABI, to allocate
|
||||
* you must use @av_vk_frame_alloc().
|
||||
*/
|
||||
typedef struct AVVkFrame {
|
||||
struct AVVkFrame {
|
||||
/**
|
||||
* Vulkan images to which the memory is bound to.
|
||||
* May be one for multiplane formats, or multiple.
|
||||
*/
|
||||
VkImage img[AV_NUM_DATA_POINTERS];
|
||||
|
||||
/**
|
||||
* The same tiling must be used for all images in the frame.
|
||||
* Tiling for the frame.
|
||||
*/
|
||||
VkImageTiling tiling;
|
||||
|
||||
/**
|
||||
* Memory backing the images. Could be less than the amount of planes,
|
||||
* in which case the offset value will indicate the binding offset of
|
||||
* each plane in the memory.
|
||||
* Memory backing the images. Either one, or as many as there are planes
|
||||
* in the sw_format.
|
||||
* In case of having multiple VkImages, but one memory, the offset field
|
||||
* will indicate the bound offset for each image.
|
||||
*/
|
||||
VkDeviceMemory mem[AV_NUM_DATA_POINTERS];
|
||||
size_t size[AV_NUM_DATA_POINTERS];
|
||||
@@ -235,13 +326,13 @@ typedef struct AVVkFrame {
|
||||
VkMemoryPropertyFlagBits flags;
|
||||
|
||||
/**
|
||||
* Updated after every barrier
|
||||
* Updated after every barrier. One per VkImage.
|
||||
*/
|
||||
VkAccessFlagBits access[AV_NUM_DATA_POINTERS];
|
||||
VkImageLayout layout[AV_NUM_DATA_POINTERS];
|
||||
|
||||
/**
|
||||
* Synchronization timeline semaphores, one for each sw_format plane.
|
||||
* Synchronization timeline semaphores, one for each VkImage.
|
||||
* Must not be freed manually. Must be waited on at every submission using
|
||||
* the value in sem_value, and must be signalled at every submission,
|
||||
* using an incremented value.
|
||||
@@ -250,6 +341,7 @@ typedef struct AVVkFrame {
|
||||
|
||||
/**
|
||||
* Up to date semaphore value at which each image becomes accessible.
|
||||
* One per VkImage.
|
||||
* Clients must wait on this value when submitting a command queue,
|
||||
* and increment it when signalling.
|
||||
*/
|
||||
@@ -261,10 +353,18 @@ typedef struct AVVkFrame {
|
||||
struct AVVkFrameInternal *internal;
|
||||
|
||||
/**
|
||||
* Describes the binding offset of each plane to the VkDeviceMemory.
|
||||
* Describes the binding offset of each image to the VkDeviceMemory.
|
||||
* One per VkImage.
|
||||
*/
|
||||
ptrdiff_t offset[AV_NUM_DATA_POINTERS];
|
||||
} AVVkFrame;
|
||||
|
||||
/**
|
||||
* Queue family of the images. Must be VK_QUEUE_FAMILY_IGNORED if
|
||||
* the image was allocated with the CONCURRENT concurrency option.
|
||||
* One per VkImage.
|
||||
*/
|
||||
uint32_t queue_family[AV_NUM_DATA_POINTERS];
|
||||
};
|
||||
|
||||
/**
|
||||
* Allocates a single AVVkFrame and initializes everything as 0.
|
||||
@@ -273,7 +373,8 @@ typedef struct AVVkFrame {
|
||||
AVVkFrame *av_vk_frame_alloc(void);
|
||||
|
||||
/**
|
||||
* Returns the format of each image up to the number of planes for a given sw_format.
|
||||
* Returns the optimal per-plane Vulkan format for a given sw_format,
|
||||
* one for each plane.
|
||||
* Returns NULL on unsupported formats.
|
||||
*/
|
||||
const VkFormat *av_vkfmt_from_pixfmt(enum AVPixelFormat p);
|
||||
|
||||
690
include/libavutil/iamf.h
Normal file
690
include/libavutil/iamf.h
Normal file
@@ -0,0 +1,690 @@
|
||||
/*
|
||||
* Immersive Audio Model and Formats helper functions and defines
|
||||
*
|
||||
* 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_IAMF_H
|
||||
#define AVUTIL_IAMF_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Immersive Audio Model and Formats API header
|
||||
* @see <a href="https://aomediacodec.github.io/iamf/">Immersive Audio Model and Formats</a>
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "attributes.h"
|
||||
#include "avassert.h"
|
||||
#include "channel_layout.h"
|
||||
#include "dict.h"
|
||||
#include "rational.h"
|
||||
|
||||
/**
|
||||
* @defgroup lavu_iamf Immersive Audio Model and Formats
|
||||
* @ingroup lavu_audio
|
||||
*
|
||||
* Immersive Audio Model and Formats related functions and defines
|
||||
*
|
||||
* @defgroup lavu_iamf_params Parameter Definition
|
||||
* @ingroup lavu_iamf
|
||||
* @{
|
||||
* Parameters as defined in section 3.6.1 and 3.8 of IAMF.
|
||||
* @}
|
||||
*
|
||||
* @defgroup lavu_iamf_audio Audio Element
|
||||
* @ingroup lavu_iamf
|
||||
* @{
|
||||
* Audio Elements as defined in section 3.6 of IAMF.
|
||||
* @}
|
||||
*
|
||||
* @defgroup lavu_iamf_mix Mix Presentation
|
||||
* @ingroup lavu_iamf
|
||||
* @{
|
||||
* Mix Presentations as defined in section 3.7 of IAMF.
|
||||
* @}
|
||||
*
|
||||
* @addtogroup lavu_iamf_params
|
||||
* @{
|
||||
*/
|
||||
enum AVIAMFAnimationType {
|
||||
AV_IAMF_ANIMATION_TYPE_STEP,
|
||||
AV_IAMF_ANIMATION_TYPE_LINEAR,
|
||||
AV_IAMF_ANIMATION_TYPE_BEZIER,
|
||||
};
|
||||
|
||||
/**
|
||||
* Mix Gain Parameter Data as defined in section 3.8.1 of IAMF.
|
||||
*
|
||||
* @note This struct's size is not a part of the public ABI.
|
||||
*/
|
||||
typedef struct AVIAMFMixGain {
|
||||
const AVClass *av_class;
|
||||
|
||||
/**
|
||||
* Duration for the given subblock, in units of
|
||||
* 1 / @ref AVIAMFParamDefinition.parameter_rate "parameter_rate".
|
||||
* It must not be 0.
|
||||
*/
|
||||
unsigned int subblock_duration;
|
||||
/**
|
||||
* The type of animation applied to the parameter values.
|
||||
*/
|
||||
enum AVIAMFAnimationType animation_type;
|
||||
/**
|
||||
* Parameter value that is applied at the start of the subblock.
|
||||
* Applies to all defined Animation Types.
|
||||
*
|
||||
* Valid range of values is -128.0 to 128.0
|
||||
*/
|
||||
AVRational start_point_value;
|
||||
/**
|
||||
* Parameter value that is applied at the end of the subblock.
|
||||
* Applies only to AV_IAMF_ANIMATION_TYPE_LINEAR and
|
||||
* AV_IAMF_ANIMATION_TYPE_BEZIER Animation Types.
|
||||
*
|
||||
* Valid range of values is -128.0 to 128.0
|
||||
*/
|
||||
AVRational end_point_value;
|
||||
/**
|
||||
* Parameter value of the middle control point of a quadratic Bezier
|
||||
* curve, i.e., its y-axis value.
|
||||
* Applies only to AV_IAMF_ANIMATION_TYPE_BEZIER Animation Type.
|
||||
*
|
||||
* Valid range of values is -128.0 to 128.0
|
||||
*/
|
||||
AVRational control_point_value;
|
||||
/**
|
||||
* Parameter value of the time of the middle control point of a
|
||||
* quadratic Bezier curve, i.e., its x-axis value.
|
||||
* Applies only to AV_IAMF_ANIMATION_TYPE_BEZIER Animation Type.
|
||||
*
|
||||
* Valid range of values is 0.0 to 1.0
|
||||
*/
|
||||
AVRational control_point_relative_time;
|
||||
} AVIAMFMixGain;
|
||||
|
||||
/**
|
||||
* Demixing Info Parameter Data as defined in section 3.8.2 of IAMF.
|
||||
*
|
||||
* @note This struct's size is not a part of the public ABI.
|
||||
*/
|
||||
typedef struct AVIAMFDemixingInfo {
|
||||
const AVClass *av_class;
|
||||
|
||||
/**
|
||||
* Duration for the given subblock, in units of
|
||||
* 1 / @ref AVIAMFParamDefinition.parameter_rate "parameter_rate".
|
||||
* It must not be 0.
|
||||
*/
|
||||
unsigned int subblock_duration;
|
||||
/**
|
||||
* Pre-defined combination of demixing parameters.
|
||||
*/
|
||||
unsigned int dmixp_mode;
|
||||
} AVIAMFDemixingInfo;
|
||||
|
||||
/**
|
||||
* Recon Gain Info Parameter Data as defined in section 3.8.3 of IAMF.
|
||||
*
|
||||
* @note This struct's size is not a part of the public ABI.
|
||||
*/
|
||||
typedef struct AVIAMFReconGain {
|
||||
const AVClass *av_class;
|
||||
|
||||
/**
|
||||
* Duration for the given subblock, in units of
|
||||
* 1 / @ref AVIAMFParamDefinition.parameter_rate "parameter_rate".
|
||||
* It must not be 0.
|
||||
*/
|
||||
unsigned int subblock_duration;
|
||||
|
||||
/**
|
||||
* Array of gain values to be applied to each channel for each layer
|
||||
* defined in the Audio Element referencing the parent Parameter Definition.
|
||||
* Values for layers where the AV_IAMF_LAYER_FLAG_RECON_GAIN flag is not set
|
||||
* are undefined.
|
||||
*
|
||||
* Channel order is: FL, C, FR, SL, SR, TFL, TFR, BL, BR, TBL, TBR, LFE
|
||||
*/
|
||||
uint8_t recon_gain[6][12];
|
||||
} AVIAMFReconGain;
|
||||
|
||||
enum AVIAMFParamDefinitionType {
|
||||
/**
|
||||
* Subblocks are of struct type AVIAMFMixGain
|
||||
*/
|
||||
AV_IAMF_PARAMETER_DEFINITION_MIX_GAIN,
|
||||
/**
|
||||
* Subblocks are of struct type AVIAMFDemixingInfo
|
||||
*/
|
||||
AV_IAMF_PARAMETER_DEFINITION_DEMIXING,
|
||||
/**
|
||||
* Subblocks are of struct type AVIAMFReconGain
|
||||
*/
|
||||
AV_IAMF_PARAMETER_DEFINITION_RECON_GAIN,
|
||||
};
|
||||
|
||||
/**
|
||||
* Parameters as defined in section 3.6.1 of IAMF.
|
||||
*
|
||||
* The struct is allocated by av_iamf_param_definition_alloc() along with an
|
||||
* array of subblocks, its type depending on the value of type.
|
||||
* This array is placed subblocks_offset bytes after the start of this struct.
|
||||
*
|
||||
* @note This struct's size is not a part of the public ABI.
|
||||
*/
|
||||
typedef struct AVIAMFParamDefinition {
|
||||
const AVClass *av_class;
|
||||
|
||||
/**
|
||||
* Offset in bytes from the start of this struct, at which the subblocks
|
||||
* array is located.
|
||||
*/
|
||||
size_t subblocks_offset;
|
||||
/**
|
||||
* Size in bytes of each element in the subblocks array.
|
||||
*/
|
||||
size_t subblock_size;
|
||||
/**
|
||||
* Number of subblocks in the array.
|
||||
*/
|
||||
unsigned int nb_subblocks;
|
||||
|
||||
/**
|
||||
* Parameters type. Determines the type of the subblock elements.
|
||||
*/
|
||||
enum AVIAMFParamDefinitionType type;
|
||||
|
||||
/**
|
||||
* Identifier for the paremeter substream.
|
||||
*/
|
||||
unsigned int parameter_id;
|
||||
/**
|
||||
* Sample rate for the paremeter substream. It must not be 0.
|
||||
*/
|
||||
unsigned int parameter_rate;
|
||||
|
||||
/**
|
||||
* The accumulated duration of all blocks in this parameter definition,
|
||||
* in units of 1 / @ref parameter_rate.
|
||||
*
|
||||
* May be 0, in which case all duration values should be specified in
|
||||
* another parameter definition referencing the same parameter_id.
|
||||
*/
|
||||
unsigned int duration;
|
||||
/**
|
||||
* The duration of every subblock in the case where all subblocks, with
|
||||
* the optional exception of the last subblock, have equal durations.
|
||||
*
|
||||
* Must be 0 if subblocks have different durations.
|
||||
*/
|
||||
unsigned int constant_subblock_duration;
|
||||
} AVIAMFParamDefinition;
|
||||
|
||||
const AVClass *av_iamf_param_definition_get_class(void);
|
||||
|
||||
/**
|
||||
* Allocates memory for AVIAMFParamDefinition, plus an array of {@code nb_subblocks}
|
||||
* amount of subblocks of the given type and initializes the variables. Can be
|
||||
* freed with a normal av_free() call.
|
||||
*
|
||||
* @param size if non-NULL, the size in bytes of the resulting data array is written here.
|
||||
*/
|
||||
AVIAMFParamDefinition *av_iamf_param_definition_alloc(enum AVIAMFParamDefinitionType type,
|
||||
unsigned int nb_subblocks, size_t *size);
|
||||
|
||||
/**
|
||||
* Get the subblock at the specified {@code idx}. Must be between 0 and nb_subblocks - 1.
|
||||
*
|
||||
* The @ref AVIAMFParamDefinition.type "param definition type" defines
|
||||
* the struct type of the returned pointer.
|
||||
*/
|
||||
static av_always_inline void*
|
||||
av_iamf_param_definition_get_subblock(const AVIAMFParamDefinition *par, unsigned int idx)
|
||||
{
|
||||
av_assert0(idx < par->nb_subblocks);
|
||||
return (void *)((uint8_t *)par + par->subblocks_offset + idx * par->subblock_size);
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @addtogroup lavu_iamf_audio
|
||||
* @{
|
||||
*/
|
||||
|
||||
enum AVIAMFAmbisonicsMode {
|
||||
AV_IAMF_AMBISONICS_MODE_MONO,
|
||||
AV_IAMF_AMBISONICS_MODE_PROJECTION,
|
||||
};
|
||||
|
||||
/**
|
||||
* Recon gain information for the layer is present in AVIAMFReconGain
|
||||
*/
|
||||
#define AV_IAMF_LAYER_FLAG_RECON_GAIN (1 << 0)
|
||||
|
||||
/**
|
||||
* A layer defining a Channel Layout in the Audio Element.
|
||||
*
|
||||
* When @ref AVIAMFAudioElement.audio_element_type "the parent's Audio Element type"
|
||||
* is AV_IAMF_AUDIO_ELEMENT_TYPE_CHANNEL, this corresponds to an Scalable Channel
|
||||
* Layout layer as defined in section 3.6.2 of IAMF.
|
||||
* For AV_IAMF_AUDIO_ELEMENT_TYPE_SCENE, it is an Ambisonics channel
|
||||
* layout as defined in section 3.6.3 of IAMF.
|
||||
*
|
||||
* @note The struct should be allocated with av_iamf_audio_element_add_layer()
|
||||
* and its size is not a part of the public ABI.
|
||||
*/
|
||||
typedef struct AVIAMFLayer {
|
||||
const AVClass *av_class;
|
||||
|
||||
AVChannelLayout ch_layout;
|
||||
|
||||
/**
|
||||
* A bitmask which may contain a combination of AV_IAMF_LAYER_FLAG_* flags.
|
||||
*/
|
||||
unsigned int flags;
|
||||
/**
|
||||
* Output gain channel flags as defined in section 3.6.2 of IAMF.
|
||||
*
|
||||
* This field is defined only if @ref AVIAMFAudioElement.audio_element_type
|
||||
* "the parent's Audio Element type" is AV_IAMF_AUDIO_ELEMENT_TYPE_CHANNEL,
|
||||
* must be 0 otherwise.
|
||||
*/
|
||||
unsigned int output_gain_flags;
|
||||
/**
|
||||
* Output gain as defined in section 3.6.2 of IAMF.
|
||||
*
|
||||
* Must be 0 if @ref output_gain_flags is 0.
|
||||
*/
|
||||
AVRational output_gain;
|
||||
/**
|
||||
* Ambisonics mode as defined in section 3.6.3 of IAMF.
|
||||
*
|
||||
* This field is defined only if @ref AVIAMFAudioElement.audio_element_type
|
||||
* "the parent's Audio Element type" is AV_IAMF_AUDIO_ELEMENT_TYPE_SCENE.
|
||||
*
|
||||
* If AV_IAMF_AMBISONICS_MODE_MONO, channel_mapping is defined implicitly
|
||||
* (Ambisonic Order) or explicitly (Custom Order with ambi channels) in
|
||||
* @ref ch_layout.
|
||||
* If AV_IAMF_AMBISONICS_MODE_PROJECTION, @ref demixing_matrix must be set.
|
||||
*/
|
||||
enum AVIAMFAmbisonicsMode ambisonics_mode;
|
||||
|
||||
/**
|
||||
* Demixing matrix as defined in section 3.6.3 of IAMF.
|
||||
*
|
||||
* The length of the array is ch_layout.nb_channels multiplied by the sum of
|
||||
* the amount of streams in the group plus the amount of streams in the group
|
||||
* that are stereo.
|
||||
*
|
||||
* May be set only if @ref ambisonics_mode == AV_IAMF_AMBISONICS_MODE_PROJECTION,
|
||||
* must be NULL otherwise.
|
||||
*/
|
||||
AVRational *demixing_matrix;
|
||||
} AVIAMFLayer;
|
||||
|
||||
|
||||
enum AVIAMFAudioElementType {
|
||||
AV_IAMF_AUDIO_ELEMENT_TYPE_CHANNEL,
|
||||
AV_IAMF_AUDIO_ELEMENT_TYPE_SCENE,
|
||||
};
|
||||
|
||||
/**
|
||||
* Information on how to combine one or more audio streams, as defined in
|
||||
* section 3.6 of IAMF.
|
||||
*
|
||||
* @note The struct should be allocated with av_iamf_audio_element_alloc()
|
||||
* and its size is not a part of the public ABI.
|
||||
*/
|
||||
typedef struct AVIAMFAudioElement {
|
||||
const AVClass *av_class;
|
||||
|
||||
AVIAMFLayer **layers;
|
||||
/**
|
||||
* Number of layers, or channel groups, in the Audio Element.
|
||||
* There may be 6 layers at most, and for @ref audio_element_type
|
||||
* AV_IAMF_AUDIO_ELEMENT_TYPE_SCENE, there may be exactly 1.
|
||||
*
|
||||
* Set by av_iamf_audio_element_add_layer(), must not be
|
||||
* modified by any other code.
|
||||
*/
|
||||
unsigned int nb_layers;
|
||||
|
||||
/**
|
||||
* Demixing information used to reconstruct a scalable channel audio
|
||||
* representation.
|
||||
* The @ref AVIAMFParamDefinition.type "type" must be
|
||||
* AV_IAMF_PARAMETER_DEFINITION_DEMIXING.
|
||||
*/
|
||||
AVIAMFParamDefinition *demixing_info;
|
||||
/**
|
||||
* Recon gain information used to reconstruct a scalable channel audio
|
||||
* representation.
|
||||
* The @ref AVIAMFParamDefinition.type "type" must be
|
||||
* AV_IAMF_PARAMETER_DEFINITION_RECON_GAIN.
|
||||
*/
|
||||
AVIAMFParamDefinition *recon_gain_info;
|
||||
|
||||
/**
|
||||
* Audio element type as defined in section 3.6 of IAMF.
|
||||
*/
|
||||
enum AVIAMFAudioElementType audio_element_type;
|
||||
|
||||
/**
|
||||
* Default weight value as defined in section 3.6 of IAMF.
|
||||
*/
|
||||
unsigned int default_w;
|
||||
} AVIAMFAudioElement;
|
||||
|
||||
const AVClass *av_iamf_audio_element_get_class(void);
|
||||
|
||||
/**
|
||||
* Allocates a AVIAMFAudioElement, and initializes its fields with default values.
|
||||
* No layers are allocated. Must be freed with av_iamf_audio_element_free().
|
||||
*
|
||||
* @see av_iamf_audio_element_add_layer()
|
||||
*/
|
||||
AVIAMFAudioElement *av_iamf_audio_element_alloc(void);
|
||||
|
||||
/**
|
||||
* Allocate a layer and add it to a given AVIAMFAudioElement.
|
||||
* It is freed by av_iamf_audio_element_free() alongside the rest of the parent
|
||||
* AVIAMFAudioElement.
|
||||
*
|
||||
* @return a pointer to the allocated layer.
|
||||
*/
|
||||
AVIAMFLayer *av_iamf_audio_element_add_layer(AVIAMFAudioElement *audio_element);
|
||||
|
||||
/**
|
||||
* Free an AVIAMFAudioElement and all its contents.
|
||||
*
|
||||
* @param audio_element pointer to pointer to an allocated AVIAMFAudioElement.
|
||||
* upon return, *audio_element will be set to NULL.
|
||||
*/
|
||||
void av_iamf_audio_element_free(AVIAMFAudioElement **audio_element);
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @addtogroup lavu_iamf_mix
|
||||
* @{
|
||||
*/
|
||||
|
||||
enum AVIAMFHeadphonesMode {
|
||||
/**
|
||||
* The referenced Audio Element shall be rendered to stereo loudspeakers.
|
||||
*/
|
||||
AV_IAMF_HEADPHONES_MODE_STEREO,
|
||||
/**
|
||||
* The referenced Audio Element shall be rendered with a binaural renderer.
|
||||
*/
|
||||
AV_IAMF_HEADPHONES_MODE_BINAURAL,
|
||||
};
|
||||
|
||||
/**
|
||||
* Submix element as defined in section 3.7 of IAMF.
|
||||
*
|
||||
* @note The struct should be allocated with av_iamf_submix_add_element()
|
||||
* and its size is not a part of the public ABI.
|
||||
*/
|
||||
typedef struct AVIAMFSubmixElement {
|
||||
const AVClass *av_class;
|
||||
|
||||
/**
|
||||
* The id of the Audio Element this submix element references.
|
||||
*/
|
||||
unsigned int audio_element_id;
|
||||
|
||||
/**
|
||||
* Information required required for applying any processing to the
|
||||
* referenced and rendered Audio Element before being summed with other
|
||||
* processed Audio Elements.
|
||||
* The @ref AVIAMFParamDefinition.type "type" must be
|
||||
* AV_IAMF_PARAMETER_DEFINITION_MIX_GAIN.
|
||||
*/
|
||||
AVIAMFParamDefinition *element_mix_config;
|
||||
|
||||
/**
|
||||
* Default mix gain value to apply when there are no AVIAMFParamDefinition
|
||||
* with @ref element_mix_config "element_mix_config's"
|
||||
* @ref AVIAMFParamDefinition.parameter_id "parameter_id" available for a
|
||||
* given audio frame.
|
||||
*/
|
||||
AVRational default_mix_gain;
|
||||
|
||||
/**
|
||||
* A value that indicates whether the referenced channel-based Audio Element
|
||||
* shall be rendered to stereo loudspeakers or spatialized with a binaural
|
||||
* renderer when played back on headphones.
|
||||
* If the Audio Element is not of @ref AVIAMFAudioElement.audio_element_type
|
||||
* "type" AV_IAMF_AUDIO_ELEMENT_TYPE_CHANNEL, then this field is undefined.
|
||||
*/
|
||||
enum AVIAMFHeadphonesMode headphones_rendering_mode;
|
||||
|
||||
/**
|
||||
* A dictionary of strings describing the submix in different languages.
|
||||
* Must have the same amount of entries as
|
||||
* @ref AVIAMFMixPresentation.annotations "the mix's annotations", stored
|
||||
* in the same order, and with the same key strings.
|
||||
*
|
||||
* @ref AVDictionaryEntry.key "key" is a string conforming to BCP-47 that
|
||||
* specifies the language for the string stored in
|
||||
* @ref AVDictionaryEntry.value "value".
|
||||
*/
|
||||
AVDictionary *annotations;
|
||||
} AVIAMFSubmixElement;
|
||||
|
||||
enum AVIAMFSubmixLayoutType {
|
||||
/**
|
||||
* The layout follows the loudspeaker sound system convention of ITU-2051-3.
|
||||
*/
|
||||
AV_IAMF_SUBMIX_LAYOUT_TYPE_LOUDSPEAKERS = 2,
|
||||
/**
|
||||
* The layout is binaural.
|
||||
*/
|
||||
AV_IAMF_SUBMIX_LAYOUT_TYPE_BINAURAL = 3,
|
||||
};
|
||||
|
||||
/**
|
||||
* Submix layout as defined in section 3.7.6 of IAMF.
|
||||
*
|
||||
* @note The struct should be allocated with av_iamf_submix_add_layout()
|
||||
* and its size is not a part of the public ABI.
|
||||
*/
|
||||
typedef struct AVIAMFSubmixLayout {
|
||||
const AVClass *av_class;
|
||||
|
||||
enum AVIAMFSubmixLayoutType layout_type;
|
||||
|
||||
/**
|
||||
* Channel layout matching one of Sound Systems A to J of ITU-2051-3, plus
|
||||
* 7.1.2ch and 3.1.2ch
|
||||
* If layout_type is not AV_IAMF_SUBMIX_LAYOUT_TYPE_LOUDSPEAKERS, this field
|
||||
* is undefined.
|
||||
*/
|
||||
AVChannelLayout sound_system;
|
||||
/**
|
||||
* The program integrated loudness information, as defined in
|
||||
* ITU-1770-4.
|
||||
*/
|
||||
AVRational integrated_loudness;
|
||||
/**
|
||||
* The digital (sampled) peak value of the audio signal, as defined
|
||||
* in ITU-1770-4.
|
||||
*/
|
||||
AVRational digital_peak;
|
||||
/**
|
||||
* The true peak of the audio signal, as defined in ITU-1770-4.
|
||||
*/
|
||||
AVRational true_peak;
|
||||
/**
|
||||
* The Dialogue loudness information, as defined in ITU-1770-4.
|
||||
*/
|
||||
AVRational dialogue_anchored_loudness;
|
||||
/**
|
||||
* The Album loudness information, as defined in ITU-1770-4.
|
||||
*/
|
||||
AVRational album_anchored_loudness;
|
||||
} AVIAMFSubmixLayout;
|
||||
|
||||
/**
|
||||
* Submix layout as defined in section 3.7 of IAMF.
|
||||
*
|
||||
* @note The struct should be allocated with av_iamf_mix_presentation_add_submix()
|
||||
* and its size is not a part of the public ABI.
|
||||
*/
|
||||
typedef struct AVIAMFSubmix {
|
||||
const AVClass *av_class;
|
||||
|
||||
/**
|
||||
* Array of submix elements.
|
||||
*
|
||||
* Set by av_iamf_submix_add_element(), must not be modified by any
|
||||
* other code.
|
||||
*/
|
||||
AVIAMFSubmixElement **elements;
|
||||
/**
|
||||
* Number of elements in the submix.
|
||||
*
|
||||
* Set by av_iamf_submix_add_element(), must not be modified by any
|
||||
* other code.
|
||||
*/
|
||||
unsigned int nb_elements;
|
||||
|
||||
/**
|
||||
* Array of submix layouts.
|
||||
*
|
||||
* Set by av_iamf_submix_add_layout(), must not be modified by any
|
||||
* other code.
|
||||
*/
|
||||
AVIAMFSubmixLayout **layouts;
|
||||
/**
|
||||
* Number of layouts in the submix.
|
||||
*
|
||||
* Set by av_iamf_submix_add_layout(), must not be modified by any
|
||||
* other code.
|
||||
*/
|
||||
unsigned int nb_layouts;
|
||||
|
||||
/**
|
||||
* Information required for post-processing the mixed audio signal to
|
||||
* generate the audio signal for playback.
|
||||
* The @ref AVIAMFParamDefinition.type "type" must be
|
||||
* AV_IAMF_PARAMETER_DEFINITION_MIX_GAIN.
|
||||
*/
|
||||
AVIAMFParamDefinition *output_mix_config;
|
||||
|
||||
/**
|
||||
* Default mix gain value to apply when there are no AVIAMFParamDefinition
|
||||
* with @ref output_mix_config "output_mix_config's"
|
||||
* @ref AVIAMFParamDefinition.parameter_id "parameter_id" available for a
|
||||
* given audio frame.
|
||||
*/
|
||||
AVRational default_mix_gain;
|
||||
} AVIAMFSubmix;
|
||||
|
||||
/**
|
||||
* Information on how to render and mix one or more AVIAMFAudioElement to generate
|
||||
* the final audio output, as defined in section 3.7 of IAMF.
|
||||
*
|
||||
* @note The struct should be allocated with av_iamf_mix_presentation_alloc()
|
||||
* and its size is not a part of the public ABI.
|
||||
*/
|
||||
typedef struct AVIAMFMixPresentation {
|
||||
const AVClass *av_class;
|
||||
|
||||
/**
|
||||
* Array of submixes.
|
||||
*
|
||||
* Set by av_iamf_mix_presentation_add_submix(), must not be modified
|
||||
* by any other code.
|
||||
*/
|
||||
AVIAMFSubmix **submixes;
|
||||
/**
|
||||
* Number of submixes in the presentation.
|
||||
*
|
||||
* Set by av_iamf_mix_presentation_add_submix(), must not be modified
|
||||
* by any other code.
|
||||
*/
|
||||
unsigned int nb_submixes;
|
||||
|
||||
/**
|
||||
* A dictionary of strings describing the mix in different languages.
|
||||
* Must have the same amount of entries as every
|
||||
* @ref AVIAMFSubmixElement.annotations "Submix element annotations",
|
||||
* stored in the same order, and with the same key strings.
|
||||
*
|
||||
* @ref AVDictionaryEntry.key "key" is a string conforming to BCP-47
|
||||
* that specifies the language for the string stored in
|
||||
* @ref AVDictionaryEntry.value "value".
|
||||
*/
|
||||
AVDictionary *annotations;
|
||||
} AVIAMFMixPresentation;
|
||||
|
||||
const AVClass *av_iamf_mix_presentation_get_class(void);
|
||||
|
||||
/**
|
||||
* Allocates a AVIAMFMixPresentation, and initializes its fields with default
|
||||
* values. No submixes are allocated.
|
||||
* Must be freed with av_iamf_mix_presentation_free().
|
||||
*
|
||||
* @see av_iamf_mix_presentation_add_submix()
|
||||
*/
|
||||
AVIAMFMixPresentation *av_iamf_mix_presentation_alloc(void);
|
||||
|
||||
/**
|
||||
* Allocate a submix and add it to a given AVIAMFMixPresentation.
|
||||
* It is freed by av_iamf_mix_presentation_free() alongside the rest of the
|
||||
* parent AVIAMFMixPresentation.
|
||||
*
|
||||
* @return a pointer to the allocated submix.
|
||||
*/
|
||||
AVIAMFSubmix *av_iamf_mix_presentation_add_submix(AVIAMFMixPresentation *mix_presentation);
|
||||
|
||||
/**
|
||||
* Allocate a submix element and add it to a given AVIAMFSubmix.
|
||||
* It is freed by av_iamf_mix_presentation_free() alongside the rest of the
|
||||
* parent AVIAMFSubmix.
|
||||
*
|
||||
* @return a pointer to the allocated submix.
|
||||
*/
|
||||
AVIAMFSubmixElement *av_iamf_submix_add_element(AVIAMFSubmix *submix);
|
||||
|
||||
/**
|
||||
* Allocate a submix layout and add it to a given AVIAMFSubmix.
|
||||
* It is freed by av_iamf_mix_presentation_free() alongside the rest of the
|
||||
* parent AVIAMFSubmix.
|
||||
*
|
||||
* @return a pointer to the allocated submix.
|
||||
*/
|
||||
AVIAMFSubmixLayout *av_iamf_submix_add_layout(AVIAMFSubmix *submix);
|
||||
|
||||
/**
|
||||
* Free an AVIAMFMixPresentation and all its contents.
|
||||
*
|
||||
* @param mix_presentation pointer to pointer to an allocated AVIAMFMixPresentation.
|
||||
* upon return, *mix_presentation will be set to NULL.
|
||||
*/
|
||||
void av_iamf_mix_presentation_free(AVIAMFMixPresentation **mix_presentation);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_IAMF_H */
|
||||
@@ -48,6 +48,7 @@
|
||||
* component in the plane with the max pixel step.
|
||||
* @param max_pixstep_comps an array which is filled with the component
|
||||
* for each plane which has the max pixel step. May be NULL.
|
||||
* @param pixdesc the AVPixFmtDescriptor for the image, describing its format
|
||||
*/
|
||||
void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4],
|
||||
const AVPixFmtDescriptor *pixdesc);
|
||||
@@ -65,6 +66,8 @@ int av_image_get_linesize(enum AVPixelFormat pix_fmt, int width, int plane);
|
||||
* width width.
|
||||
*
|
||||
* @param linesizes array to be filled with the linesize for each plane
|
||||
* @param pix_fmt the AVPixelFormat of the image
|
||||
* @param width width of the image in pixels
|
||||
* @return >= 0 in case of success, a negative error code otherwise
|
||||
*/
|
||||
int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width);
|
||||
@@ -73,6 +76,8 @@ int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int wi
|
||||
* Fill plane sizes for an image with pixel format pix_fmt and height height.
|
||||
*
|
||||
* @param size the array to be filled with the size of each image plane
|
||||
* @param pix_fmt the AVPixelFormat of the image
|
||||
* @param height height of the image in pixels
|
||||
* @param linesizes the array containing the linesize for each
|
||||
* plane, should be filled by av_image_fill_linesizes()
|
||||
* @return >= 0 in case of success, a negative error code otherwise
|
||||
@@ -88,6 +93,8 @@ int av_image_fill_plane_sizes(size_t size[4], enum AVPixelFormat pix_fmt,
|
||||
* height height.
|
||||
*
|
||||
* @param data pointers array to be filled with the pointer for each image plane
|
||||
* @param pix_fmt the AVPixelFormat of the image
|
||||
* @param height height of the image in pixels
|
||||
* @param ptr the pointer to a buffer which will contain the image
|
||||
* @param linesizes the array containing the linesize for each
|
||||
* plane, should be filled by av_image_fill_linesizes()
|
||||
@@ -103,6 +110,11 @@ int av_image_fill_pointers(uint8_t *data[4], enum AVPixelFormat pix_fmt, int hei
|
||||
* The allocated image buffer has to be freed by using
|
||||
* av_freep(&pointers[0]).
|
||||
*
|
||||
* @param pointers array to be filled with the pointer for each image plane
|
||||
* @param linesizes the array filled with the linesize for each plane
|
||||
* @param w width of the image in pixels
|
||||
* @param h height of the image in pixels
|
||||
* @param pix_fmt the AVPixelFormat of the image
|
||||
* @param align the value to use for buffer size alignment
|
||||
* @return the size in bytes required for the image buffer, a negative
|
||||
* error code in case of failure
|
||||
@@ -119,8 +131,11 @@ int av_image_alloc(uint8_t *pointers[4], int linesizes[4],
|
||||
* bytewidth must be contained by both absolute values of dst_linesize
|
||||
* and src_linesize, otherwise the function behavior is undefined.
|
||||
*
|
||||
* @param dst destination plane to copy to
|
||||
* @param dst_linesize linesize for the image plane in dst
|
||||
* @param src source plane to copy from
|
||||
* @param src_linesize linesize for the image plane in src
|
||||
* @param height height (number of lines) of the plane
|
||||
*/
|
||||
void av_image_copy_plane(uint8_t *dst, int dst_linesize,
|
||||
const uint8_t *src, int src_linesize,
|
||||
@@ -147,13 +162,34 @@ void av_image_copy_plane_uc_from(uint8_t *dst, ptrdiff_t dst_linesize,
|
||||
/**
|
||||
* Copy image in src_data to dst_data.
|
||||
*
|
||||
* @param dst_data destination image data buffer to copy to
|
||||
* @param dst_linesizes linesizes for the image in dst_data
|
||||
* @param src_data source image data buffer to copy from
|
||||
* @param src_linesizes linesizes for the image in src_data
|
||||
* @param pix_fmt the AVPixelFormat of the image
|
||||
* @param width width of the image in pixels
|
||||
* @param height height of the image in pixels
|
||||
*/
|
||||
void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4],
|
||||
const uint8_t *src_data[4], const int src_linesizes[4],
|
||||
void av_image_copy(uint8_t * const dst_data[4], const int dst_linesizes[4],
|
||||
const uint8_t * const src_data[4], const int src_linesizes[4],
|
||||
enum AVPixelFormat pix_fmt, int width, int height);
|
||||
|
||||
/**
|
||||
* Wrapper around av_image_copy() to workaround the limitation
|
||||
* that the conversion from uint8_t * const * to const uint8_t * const *
|
||||
* is not performed automatically in C.
|
||||
* @see av_image_copy()
|
||||
*/
|
||||
static inline
|
||||
void av_image_copy2(uint8_t * const dst_data[4], const int dst_linesizes[4],
|
||||
uint8_t * const src_data[4], const int src_linesizes[4],
|
||||
enum AVPixelFormat pix_fmt, int width, int height)
|
||||
{
|
||||
av_image_copy(dst_data, dst_linesizes,
|
||||
(const uint8_t * const *)src_data, src_linesizes,
|
||||
pix_fmt, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy image data located in uncacheable (e.g. GPU mapped) memory. Where
|
||||
* available, this function will use special functionality for reading from such
|
||||
@@ -168,8 +204,8 @@ void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4],
|
||||
* @note On x86, the linesizes currently need to be aligned to the cacheline
|
||||
* size (i.e. 64) to get improved performance.
|
||||
*/
|
||||
void av_image_copy_uc_from(uint8_t *dst_data[4], const ptrdiff_t dst_linesizes[4],
|
||||
const uint8_t *src_data[4], const ptrdiff_t src_linesizes[4],
|
||||
void av_image_copy_uc_from(uint8_t * const dst_data[4], const ptrdiff_t dst_linesizes[4],
|
||||
const uint8_t * const src_data[4], const ptrdiff_t src_linesizes[4],
|
||||
enum AVPixelFormat pix_fmt, int width, int height);
|
||||
|
||||
/**
|
||||
@@ -299,10 +335,40 @@ int av_image_check_sar(unsigned int w, unsigned int h, AVRational sar);
|
||||
* @param height the height of the image in pixels
|
||||
* @return 0 if the image data was cleared, a negative AVERROR code otherwise
|
||||
*/
|
||||
int av_image_fill_black(uint8_t *dst_data[4], const ptrdiff_t dst_linesize[4],
|
||||
int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesize[4],
|
||||
enum AVPixelFormat pix_fmt, enum AVColorRange range,
|
||||
int width, int height);
|
||||
|
||||
/**
|
||||
* Overwrite the image data with a color. This is suitable for filling a
|
||||
* sub-rectangle of an image, meaning the padding between the right most pixel
|
||||
* and the left most pixel on the next line will not be overwritten. For some
|
||||
* formats, the image size might be rounded up due to inherent alignment.
|
||||
*
|
||||
* If the pixel format has alpha, it is also replaced. Color component values
|
||||
* are interpreted as native integers (or intfloats) regardless of actual pixel
|
||||
* format endianness.
|
||||
*
|
||||
* This can return an error if the pixel format is not supported. Normally, all
|
||||
* non-hwaccel pixel formats should be supported.
|
||||
*
|
||||
* Passing NULL for dst_data is allowed. Then the function returns whether the
|
||||
* operation would have succeeded. (It can return an error if the pix_fmt is
|
||||
* not supported.)
|
||||
*
|
||||
* @param dst_data data pointers to destination image
|
||||
* @param dst_linesize linesizes for the destination image
|
||||
* @param pix_fmt the pixel format of the image
|
||||
* @param color the color components to be used for the fill
|
||||
* @param width the width of the image in pixels
|
||||
* @param height the height of the image in pixels
|
||||
* @param flags currently unused
|
||||
* @return 0 if the image data was filled, a negative AVERROR code otherwise
|
||||
*/
|
||||
int av_image_fill_color(uint8_t * const dst_data[4], const ptrdiff_t dst_linesize[4],
|
||||
enum AVPixelFormat pix_fmt, const uint32_t color[4],
|
||||
int width, int height, int flags);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
@@ -64,16 +64,12 @@ typedef union {
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if ARCH_ARM
|
||||
# include "arm/intreadwrite.h"
|
||||
#elif ARCH_AVR32
|
||||
# include "avr32/intreadwrite.h"
|
||||
#if ARCH_AARCH64
|
||||
# include "aarch64/intreadwrite.h"
|
||||
#elif ARCH_MIPS
|
||||
# include "mips/intreadwrite.h"
|
||||
#elif ARCH_PPC
|
||||
# include "ppc/intreadwrite.h"
|
||||
#elif ARCH_TOMI
|
||||
# include "tomi/intreadwrite.h"
|
||||
#elif ARCH_X86
|
||||
# include "x86/intreadwrite.h"
|
||||
#endif
|
||||
@@ -215,7 +211,7 @@ typedef union {
|
||||
* by per-arch headers.
|
||||
*/
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
|
||||
union unaligned_64 { uint64_t l; } __attribute__((packed)) av_alias;
|
||||
union unaligned_32 { uint32_t l; } __attribute__((packed)) av_alias;
|
||||
@@ -545,9 +541,41 @@ union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias;
|
||||
#if AV_HAVE_BIGENDIAN
|
||||
# define AV_RLA(s, p) av_bswap##s(AV_RN##s##A(p))
|
||||
# define AV_WLA(s, p, v) AV_WN##s##A(p, av_bswap##s(v))
|
||||
# define AV_RBA(s, p) AV_RN##s##A(p)
|
||||
# define AV_WBA(s, p, v) AV_WN##s##A(p, v)
|
||||
#else
|
||||
# define AV_RLA(s, p) AV_RN##s##A(p)
|
||||
# define AV_WLA(s, p, v) AV_WN##s##A(p, v)
|
||||
# define AV_RBA(s, p) av_bswap##s(AV_RN##s##A(p))
|
||||
# define AV_WBA(s, p, v) AV_WN##s##A(p, av_bswap##s(v))
|
||||
#endif
|
||||
|
||||
#ifndef AV_RL16A
|
||||
# define AV_RL16A(p) AV_RLA(16, p)
|
||||
#endif
|
||||
#ifndef AV_WL16A
|
||||
# define AV_WL16A(p, v) AV_WLA(16, p, v)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RB16A
|
||||
# define AV_RB16A(p) AV_RBA(16, p)
|
||||
#endif
|
||||
#ifndef AV_WB16A
|
||||
# define AV_WB16A(p, v) AV_WBA(16, p, v)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RL32A
|
||||
# define AV_RL32A(p) AV_RLA(32, p)
|
||||
#endif
|
||||
#ifndef AV_WL32A
|
||||
# define AV_WL32A(p, v) AV_WLA(32, p, v)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RB32A
|
||||
# define AV_RB32A(p) AV_RBA(32, p)
|
||||
#endif
|
||||
#ifndef AV_WB32A
|
||||
# define AV_WB32A(p, v) AV_WBA(32, p, v)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RL64A
|
||||
@@ -557,6 +585,13 @@ union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias;
|
||||
# define AV_WL64A(p, v) AV_WLA(64, p, v)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RB64A
|
||||
# define AV_RB64A(p) AV_RBA(64, p)
|
||||
#endif
|
||||
#ifndef AV_WB64A
|
||||
# define AV_WB64A(p, v) AV_WBA(64, p, v)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The AV_COPYxxU macros are suitable for copying data to/from unaligned
|
||||
* memory locations.
|
||||
@@ -585,9 +620,7 @@ union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias;
|
||||
#endif
|
||||
|
||||
/* Parameters for AV_COPY*, AV_SWAP*, AV_ZERO* must be
|
||||
* naturally aligned. They may be implemented using MMX,
|
||||
* so emms_c() must be called before using any float code
|
||||
* afterwards.
|
||||
* naturally aligned.
|
||||
*/
|
||||
|
||||
#define AV_COPY(n, d, s) \
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
/**
|
||||
* Context structure for the Lagged Fibonacci PRNG.
|
||||
* The exact layout, types and content of this struct may change and should
|
||||
* not be accessed directly. Only its sizeof() is guranteed to stay the same
|
||||
* not be accessed directly. Only its `sizeof()` is guaranteed to stay the same
|
||||
* to allow easy instanciation.
|
||||
*/
|
||||
typedef struct AVLFG {
|
||||
@@ -40,7 +40,7 @@ void av_lfg_init(AVLFG *c, unsigned int seed);
|
||||
/**
|
||||
* Seed the state of the ALFG using binary data.
|
||||
*
|
||||
* Return value: 0 on success, negative value (AVERROR) on failure.
|
||||
* @return 0 on success, negative value (AVERROR) on failure.
|
||||
*/
|
||||
int av_lfg_init_from_data(AVLFG *c, const uint8_t *data, unsigned int length);
|
||||
|
||||
@@ -73,6 +73,7 @@ static inline unsigned int av_mlfg_get(AVLFG *c){
|
||||
* Get the next two numbers generated by a Box-Muller Gaussian
|
||||
* generator using the random numbers issued by lfg.
|
||||
*
|
||||
* @param lfg pointer to the contex structure
|
||||
* @param out array where the two generated numbers are placed
|
||||
*/
|
||||
void av_bmg_get(AVLFG *lfg, double out[2]);
|
||||
|
||||
@@ -77,6 +77,15 @@ typedef struct AVMasteringDisplayMetadata {
|
||||
*/
|
||||
AVMasteringDisplayMetadata *av_mastering_display_metadata_alloc(void);
|
||||
|
||||
/**
|
||||
* Allocate an AVMasteringDisplayMetadata structure and set its fields to
|
||||
* default values. The resulting struct can be freed using av_freep().
|
||||
*
|
||||
* @return An AVMasteringDisplayMetadata filled with default values or NULL
|
||||
* on failure.
|
||||
*/
|
||||
AVMasteringDisplayMetadata *av_mastering_display_metadata_alloc_size(size_t *size);
|
||||
|
||||
/**
|
||||
* Allocate a complete AVMasteringDisplayMetadata and add it to the frame.
|
||||
*
|
||||
|
||||
@@ -36,30 +36,81 @@
|
||||
#ifndef M_E
|
||||
#define M_E 2.7182818284590452354 /* e */
|
||||
#endif
|
||||
#ifndef M_Ef
|
||||
#define M_Ef 2.7182818284590452354f /* e */
|
||||
#endif
|
||||
#ifndef M_LN2
|
||||
#define M_LN2 0.69314718055994530942 /* log_e 2 */
|
||||
#endif
|
||||
#ifndef M_LN2f
|
||||
#define M_LN2f 0.69314718055994530942f /* log_e 2 */
|
||||
#endif
|
||||
#ifndef M_LN10
|
||||
#define M_LN10 2.30258509299404568402 /* log_e 10 */
|
||||
#endif
|
||||
#ifndef M_LN10f
|
||||
#define M_LN10f 2.30258509299404568402f /* log_e 10 */
|
||||
#endif
|
||||
#ifndef M_LOG2_10
|
||||
#define M_LOG2_10 3.32192809488736234787 /* log_2 10 */
|
||||
#endif
|
||||
#ifndef M_LOG2_10f
|
||||
#define M_LOG2_10f 3.32192809488736234787f /* log_2 10 */
|
||||
#endif
|
||||
#ifndef M_PHI
|
||||
#define M_PHI 1.61803398874989484820 /* phi / golden ratio */
|
||||
#endif
|
||||
#ifndef M_PHIf
|
||||
#define M_PHIf 1.61803398874989484820f /* phi / golden ratio */
|
||||
#endif
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846 /* pi */
|
||||
#endif
|
||||
#ifndef M_PIf
|
||||
#define M_PIf 3.14159265358979323846f /* pi */
|
||||
#endif
|
||||
#ifndef M_PI_2
|
||||
#define M_PI_2 1.57079632679489661923 /* pi/2 */
|
||||
#endif
|
||||
#ifndef M_PI_2f
|
||||
#define M_PI_2f 1.57079632679489661923f /* pi/2 */
|
||||
#endif
|
||||
#ifndef M_PI_4
|
||||
#define M_PI_4 0.78539816339744830962 /* pi/4 */
|
||||
#endif
|
||||
#ifndef M_PI_4f
|
||||
#define M_PI_4f 0.78539816339744830962f /* pi/4 */
|
||||
#endif
|
||||
#ifndef M_1_PI
|
||||
#define M_1_PI 0.31830988618379067154 /* 1/pi */
|
||||
#endif
|
||||
#ifndef M_1_PIf
|
||||
#define M_1_PIf 0.31830988618379067154f /* 1/pi */
|
||||
#endif
|
||||
#ifndef M_2_PI
|
||||
#define M_2_PI 0.63661977236758134308 /* 2/pi */
|
||||
#endif
|
||||
#ifndef M_2_PIf
|
||||
#define M_2_PIf 0.63661977236758134308f /* 2/pi */
|
||||
#endif
|
||||
#ifndef M_2_SQRTPI
|
||||
#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
|
||||
#endif
|
||||
#ifndef M_2_SQRTPIf
|
||||
#define M_2_SQRTPIf 1.12837916709551257390f /* 2/sqrt(pi) */
|
||||
#endif
|
||||
#ifndef M_SQRT1_2
|
||||
#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
|
||||
#endif
|
||||
#ifndef M_SQRT1_2f
|
||||
#define M_SQRT1_2f 0.70710678118654752440f /* 1/sqrt(2) */
|
||||
#endif
|
||||
#ifndef M_SQRT2
|
||||
#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
|
||||
#endif
|
||||
#ifndef M_SQRT2f
|
||||
#define M_SQRT2f 1.41421356237309504880f /* sqrt(2) */
|
||||
#endif
|
||||
#ifndef NAN
|
||||
#define NAN av_int2float(0x7fc00000)
|
||||
#endif
|
||||
@@ -111,7 +162,8 @@ enum AVRounding {
|
||||
/**
|
||||
* Compute the greatest common divisor of two integer operands.
|
||||
*
|
||||
* @param a,b Operands
|
||||
* @param a Operand
|
||||
* @param b Operand
|
||||
* @return GCD of a and b up to sign; if a >= 0 and b >= 0, return value is >= 0;
|
||||
* if a == 0 and b == 0, returns 0.
|
||||
*/
|
||||
@@ -186,7 +238,8 @@ int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b);
|
||||
* av_compare_mod(0x11, 0x02, 0x20) > 0 // since 0x11 % 0x20 (0x11) > 0x02 % 0x20 (0x02)
|
||||
* @endcode
|
||||
*
|
||||
* @param a,b Operands
|
||||
* @param a Operand
|
||||
* @param b Operand
|
||||
* @param mod Divisor; must be a power of 2
|
||||
* @return
|
||||
* - a negative value if `a % mod < b % mod`
|
||||
@@ -235,6 +288,10 @@ int64_t av_rescale_delta(AVRational in_tb, int64_t in_ts, AVRational fs_tb, int
|
||||
*/
|
||||
int64_t av_add_stable(AVRational ts_tb, int64_t ts, AVRational inc_tb, int64_t inc);
|
||||
|
||||
/**
|
||||
* 0th order modified bessel function of the first kind.
|
||||
*/
|
||||
double av_bessel_i0(double x);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -27,12 +27,10 @@
|
||||
#ifndef AVUTIL_MEM_H
|
||||
#define AVUTIL_MEM_H
|
||||
|
||||
#include <limits.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "attributes.h"
|
||||
#include "avutil.h"
|
||||
#include "version.h"
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_mem
|
||||
@@ -51,86 +49,6 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if FF_API_DECLARE_ALIGNED
|
||||
/**
|
||||
*
|
||||
* @defgroup lavu_mem_macros Alignment Macros
|
||||
* Helper macros for declaring aligned variables.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @def DECLARE_ALIGNED(n,t,v)
|
||||
* Declare a variable that is aligned in memory.
|
||||
*
|
||||
* @code{.c}
|
||||
* DECLARE_ALIGNED(16, uint16_t, aligned_int) = 42;
|
||||
* DECLARE_ALIGNED(32, uint8_t, aligned_array)[128];
|
||||
*
|
||||
* // The default-alignment equivalent would be
|
||||
* uint16_t aligned_int = 42;
|
||||
* uint8_t aligned_array[128];
|
||||
* @endcode
|
||||
*
|
||||
* @param n Minimum alignment in bytes
|
||||
* @param t Type of the variable (or array element)
|
||||
* @param v Name of the variable
|
||||
*/
|
||||
|
||||
/**
|
||||
* @def DECLARE_ASM_ALIGNED(n,t,v)
|
||||
* Declare an aligned variable appropriate for use in inline assembly code.
|
||||
*
|
||||
* @code{.c}
|
||||
* DECLARE_ASM_ALIGNED(16, uint64_t, pw_08) = UINT64_C(0x0008000800080008);
|
||||
* @endcode
|
||||
*
|
||||
* @param n Minimum alignment in bytes
|
||||
* @param t Type of the variable (or array element)
|
||||
* @param v Name of the variable
|
||||
*/
|
||||
|
||||
/**
|
||||
* @def DECLARE_ASM_CONST(n,t,v)
|
||||
* Declare a static constant aligned variable appropriate for use in inline
|
||||
* assembly code.
|
||||
*
|
||||
* @code{.c}
|
||||
* DECLARE_ASM_CONST(16, uint64_t, pw_08) = UINT64_C(0x0008000800080008);
|
||||
* @endcode
|
||||
*
|
||||
* @param n Minimum alignment in bytes
|
||||
* @param t Type of the variable (or array element)
|
||||
* @param v Name of the variable
|
||||
*/
|
||||
|
||||
#if defined(__INTEL_COMPILER) && __INTEL_COMPILER < 1110 || defined(__SUNPRO_C)
|
||||
#define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v
|
||||
#define DECLARE_ASM_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v
|
||||
#define DECLARE_ASM_CONST(n,t,v) const t __attribute__ ((aligned (n))) v
|
||||
#elif defined(__DJGPP__)
|
||||
#define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (FFMIN(n, 16)))) v
|
||||
#define DECLARE_ASM_ALIGNED(n,t,v) t av_used __attribute__ ((aligned (FFMIN(n, 16)))) v
|
||||
#define DECLARE_ASM_CONST(n,t,v) static const t av_used __attribute__ ((aligned (FFMIN(n, 16)))) v
|
||||
#elif defined(__GNUC__) || defined(__clang__)
|
||||
#define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v
|
||||
#define DECLARE_ASM_ALIGNED(n,t,v) t av_used __attribute__ ((aligned (n))) v
|
||||
#define DECLARE_ASM_CONST(n,t,v) static const t av_used __attribute__ ((aligned (n))) v
|
||||
#elif defined(_MSC_VER)
|
||||
#define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v
|
||||
#define DECLARE_ASM_ALIGNED(n,t,v) __declspec(align(n)) t v
|
||||
#define DECLARE_ASM_CONST(n,t,v) __declspec(align(n)) static const t v
|
||||
#else
|
||||
#define DECLARE_ALIGNED(n,t,v) t v
|
||||
#define DECLARE_ASM_ALIGNED(n,t,v) t v
|
||||
#define DECLARE_ASM_CONST(n,t,v) static const t v
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup lavu_mem_attrs Function Attributes
|
||||
* Function attributes applicable to memory handling functions.
|
||||
@@ -239,14 +157,6 @@ av_alloc_size(1, 2) void *av_malloc_array(size_t nmemb, size_t size);
|
||||
*/
|
||||
void *av_calloc(size_t nmemb, size_t size) av_malloc_attrib av_alloc_size(1, 2);
|
||||
|
||||
#if FF_API_AV_MALLOCZ_ARRAY
|
||||
/**
|
||||
* @deprecated use av_calloc()
|
||||
*/
|
||||
attribute_deprecated
|
||||
void *av_mallocz_array(size_t nmemb, size_t size) av_malloc_attrib av_alloc_size(1, 2);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Allocate, reallocate, or free a block of memory.
|
||||
*
|
||||
@@ -667,7 +577,8 @@ void *av_dynarray2_add(void **tab_ptr, int *nb_ptr, size_t elem_size,
|
||||
/**
|
||||
* Multiply two `size_t` values checking for overflow.
|
||||
*
|
||||
* @param[in] a,b Operands of multiplication
|
||||
* @param[in] a Operand of multiplication
|
||||
* @param[in] b Operand of multiplication
|
||||
* @param[out] r Pointer to the result of the operation
|
||||
* @return 0 on success, AVERROR(EINVAL) on overflow
|
||||
*/
|
||||
|
||||
159
include/libavutil/mem_internal.h
Normal file
159
include/libavutil/mem_internal.h
Normal file
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
* Copyright (c) 2002 Fabrice Bellard
|
||||
*
|
||||
* 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_MEM_INTERNAL_H
|
||||
#define AVUTIL_MEM_INTERNAL_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "attributes.h"
|
||||
#include "macros.h"
|
||||
|
||||
/**
|
||||
* @def DECLARE_ALIGNED(n,t,v)
|
||||
* Declare a variable that is aligned in memory.
|
||||
*
|
||||
* @code{.c}
|
||||
* DECLARE_ALIGNED(16, uint16_t, aligned_int) = 42;
|
||||
* DECLARE_ALIGNED(32, uint8_t, aligned_array)[128];
|
||||
*
|
||||
* // The default-alignment equivalent would be
|
||||
* uint16_t aligned_int = 42;
|
||||
* uint8_t aligned_array[128];
|
||||
* @endcode
|
||||
*
|
||||
* @param n Minimum alignment in bytes
|
||||
* @param t Type of the variable (or array element)
|
||||
* @param v Name of the variable
|
||||
*/
|
||||
|
||||
/**
|
||||
* @def DECLARE_ASM_ALIGNED(n,t,v)
|
||||
* Declare an aligned variable appropriate for use in inline assembly code.
|
||||
*
|
||||
* @code{.c}
|
||||
* DECLARE_ASM_ALIGNED(16, uint64_t, pw_08) = UINT64_C(0x0008000800080008);
|
||||
* @endcode
|
||||
*
|
||||
* @param n Minimum alignment in bytes
|
||||
* @param t Type of the variable (or array element)
|
||||
* @param v Name of the variable
|
||||
*/
|
||||
|
||||
/**
|
||||
* @def DECLARE_ASM_CONST(n,t,v)
|
||||
* Declare a static constant aligned variable appropriate for use in inline
|
||||
* assembly code.
|
||||
*
|
||||
* @code{.c}
|
||||
* DECLARE_ASM_CONST(16, uint64_t, pw_08) = UINT64_C(0x0008000800080008);
|
||||
* @endcode
|
||||
*
|
||||
* @param n Minimum alignment in bytes
|
||||
* @param t Type of the variable (or array element)
|
||||
* @param v Name of the variable
|
||||
*/
|
||||
|
||||
#if defined(__INTEL_COMPILER) && __INTEL_COMPILER < 1110 || defined(__SUNPRO_C)
|
||||
#define DECLARE_ALIGNED_T(n,t,v) t __attribute__ ((aligned (n))) v
|
||||
#define DECLARE_ASM_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v
|
||||
#define DECLARE_ASM_CONST(n,t,v) const t __attribute__ ((aligned (n))) v
|
||||
#elif defined(__DJGPP__)
|
||||
#define DECLARE_ALIGNED_T(n,t,v) t __attribute__ ((aligned (FFMIN(n, 16)))) v
|
||||
#define DECLARE_ASM_ALIGNED(n,t,v) t av_used __attribute__ ((aligned (FFMIN(n, 16)))) v
|
||||
#define DECLARE_ASM_CONST(n,t,v) static const t av_used __attribute__ ((aligned (FFMIN(n, 16)))) v
|
||||
#elif defined(__GNUC__) || defined(__clang__)
|
||||
#define DECLARE_ALIGNED_T(n,t,v) t __attribute__ ((aligned (n))) v
|
||||
#define DECLARE_ASM_ALIGNED(n,t,v) t av_used __attribute__ ((aligned (n))) v
|
||||
#define DECLARE_ASM_CONST(n,t,v) static const t av_used __attribute__ ((aligned (n))) v
|
||||
#elif defined(_MSC_VER)
|
||||
#define DECLARE_ALIGNED_T(n,t,v) __declspec(align(n)) t v
|
||||
#define DECLARE_ASM_ALIGNED(n,t,v) __declspec(align(n)) t v
|
||||
#define DECLARE_ASM_CONST(n,t,v) __declspec(align(n)) static const t v
|
||||
#else
|
||||
#define DECLARE_ALIGNED_T(n,t,v) t v
|
||||
#define DECLARE_ASM_ALIGNED(n,t,v) t v
|
||||
#define DECLARE_ASM_CONST(n,t,v) static const t v
|
||||
#endif
|
||||
|
||||
#if HAVE_SIMD_ALIGN_64
|
||||
#define ALIGN_64 64
|
||||
#define ALIGN_32 32
|
||||
#elif HAVE_SIMD_ALIGN_32
|
||||
#define ALIGN_64 32
|
||||
#define ALIGN_32 32
|
||||
#else
|
||||
#define ALIGN_64 16
|
||||
#define ALIGN_32 16
|
||||
#endif
|
||||
|
||||
#define DECLARE_ALIGNED(n,t,v) DECLARE_ALIGNED_V(n,t,v)
|
||||
|
||||
// Macro needs to be double-wrapped in order to expand
|
||||
// possible other macros being passed for n.
|
||||
#define DECLARE_ALIGNED_V(n,t,v) DECLARE_ALIGNED_##n(t,v)
|
||||
|
||||
#define DECLARE_ALIGNED_4(t,v) DECLARE_ALIGNED_T( 4, t, v)
|
||||
#define DECLARE_ALIGNED_8(t,v) DECLARE_ALIGNED_T( 8, t, v)
|
||||
#define DECLARE_ALIGNED_16(t,v) DECLARE_ALIGNED_T( 16, t, v)
|
||||
#define DECLARE_ALIGNED_32(t,v) DECLARE_ALIGNED_T(ALIGN_32, t, v)
|
||||
#define DECLARE_ALIGNED_64(t,v) DECLARE_ALIGNED_T(ALIGN_64, t, v)
|
||||
|
||||
// Some broken preprocessors need a second expansion
|
||||
// to be forced to tokenize __VA_ARGS__
|
||||
#define E1(x) x
|
||||
|
||||
#define LOCAL_ALIGNED_A(a, t, v, s, o, ...) \
|
||||
uint8_t la_##v[sizeof(t s o) + (a)]; \
|
||||
t (*v) o = (void *)FFALIGN((uintptr_t)la_##v, a)
|
||||
|
||||
#define LOCAL_ALIGNED_D(a, t, v, s, o, ...) \
|
||||
DECLARE_ALIGNED(a, t, la_##v) s o; \
|
||||
t (*v) o = la_##v
|
||||
|
||||
#define LOCAL_ALIGNED(a, t, v, ...) LOCAL_ALIGNED_##a(t, v, __VA_ARGS__)
|
||||
|
||||
#if HAVE_LOCAL_ALIGNED
|
||||
# define LOCAL_ALIGNED_4(t, v, ...) E1(LOCAL_ALIGNED_D(4, t, v, __VA_ARGS__,,))
|
||||
#else
|
||||
# define LOCAL_ALIGNED_4(t, v, ...) E1(LOCAL_ALIGNED_A(4, t, v, __VA_ARGS__,,))
|
||||
#endif
|
||||
|
||||
#if HAVE_LOCAL_ALIGNED
|
||||
# define LOCAL_ALIGNED_8(t, v, ...) E1(LOCAL_ALIGNED_D(8, t, v, __VA_ARGS__,,))
|
||||
#else
|
||||
# define LOCAL_ALIGNED_8(t, v, ...) E1(LOCAL_ALIGNED_A(8, t, v, __VA_ARGS__,,))
|
||||
#endif
|
||||
|
||||
#if HAVE_LOCAL_ALIGNED
|
||||
# define LOCAL_ALIGNED_16(t, v, ...) E1(LOCAL_ALIGNED_D(16, t, v, __VA_ARGS__,,))
|
||||
#else
|
||||
# define LOCAL_ALIGNED_16(t, v, ...) E1(LOCAL_ALIGNED_A(16, t, v, __VA_ARGS__,,))
|
||||
#endif
|
||||
|
||||
#if HAVE_LOCAL_ALIGNED
|
||||
# define LOCAL_ALIGNED_32(t, v, ...) E1(LOCAL_ALIGNED_D(32, t, v, __VA_ARGS__,,))
|
||||
#else
|
||||
# define LOCAL_ALIGNED_32(t, v, ...) E1(LOCAL_ALIGNED_A(32, t, v, __VA_ARGS__,,))
|
||||
#endif
|
||||
|
||||
#endif /* AVUTIL_MEM_INTERNAL_H */
|
||||
@@ -43,6 +43,26 @@
|
||||
* ("objects"). An option can have a help text, a type and a range of possible
|
||||
* values. Options may then be enumerated, read and written to.
|
||||
*
|
||||
* There are two modes of access to members of AVOption and its child structs.
|
||||
* One is called 'native access', and refers to access from the code that
|
||||
* declares the AVOption in question. The other is 'foreign access', and refers
|
||||
* to access from other code.
|
||||
*
|
||||
* Certain struct members in this header are documented as 'native access only'
|
||||
* or similar - it means that only the code that declared the AVOption in
|
||||
* question is allowed to access the field. This allows us to extend the
|
||||
* semantics of those fields without breaking API compatibility.
|
||||
*
|
||||
* @section avoptions_scope Scope of AVOptions
|
||||
*
|
||||
* AVOptions is designed to support any set of multimedia configuration options
|
||||
* that can be defined at compile-time. Although it is mainly used to expose
|
||||
* FFmpeg options, you are welcome to adapt it to your own use case.
|
||||
*
|
||||
* No single approach can ever fully solve the problem of configuration,
|
||||
* but please submit a patch if you believe you have found a problem
|
||||
* that is best solved by extending AVOptions.
|
||||
*
|
||||
* @section avoptions_implement Implementing AVOptions
|
||||
* This section describes how to add AVOptions capabilities to a struct.
|
||||
*
|
||||
@@ -220,31 +240,189 @@
|
||||
* before the file is actually opened.
|
||||
*/
|
||||
|
||||
/**
|
||||
* An option type determines:
|
||||
* - for native access, the underlying C type of the field that an AVOption
|
||||
* refers to;
|
||||
* - for foreign access, the semantics of accessing the option through this API,
|
||||
* e.g. which av_opt_get_*() and av_opt_set_*() functions can be called, or
|
||||
* what format will av_opt_get()/av_opt_set() expect/produce.
|
||||
*/
|
||||
enum AVOptionType{
|
||||
AV_OPT_TYPE_FLAGS,
|
||||
/**
|
||||
* Underlying C type is unsigned int.
|
||||
*/
|
||||
AV_OPT_TYPE_FLAGS = 1,
|
||||
/**
|
||||
* Underlying C type is int.
|
||||
*/
|
||||
AV_OPT_TYPE_INT,
|
||||
/**
|
||||
* Underlying C type is int64_t.
|
||||
*/
|
||||
AV_OPT_TYPE_INT64,
|
||||
/**
|
||||
* Underlying C type is double.
|
||||
*/
|
||||
AV_OPT_TYPE_DOUBLE,
|
||||
/**
|
||||
* Underlying C type is float.
|
||||
*/
|
||||
AV_OPT_TYPE_FLOAT,
|
||||
/**
|
||||
* Underlying C type is a uint8_t* that is either NULL or points to a C
|
||||
* string allocated with the av_malloc() family of functions.
|
||||
*/
|
||||
AV_OPT_TYPE_STRING,
|
||||
/**
|
||||
* Underlying C type is AVRational.
|
||||
*/
|
||||
AV_OPT_TYPE_RATIONAL,
|
||||
AV_OPT_TYPE_BINARY, ///< offset must point to a pointer immediately followed by an int for the length
|
||||
/**
|
||||
* Underlying C type is a uint8_t* that is either NULL or points to an array
|
||||
* allocated with the av_malloc() family of functions. The pointer is
|
||||
* immediately followed by an int containing the array length in bytes.
|
||||
*/
|
||||
AV_OPT_TYPE_BINARY,
|
||||
/**
|
||||
* Underlying C type is AVDictionary*.
|
||||
*/
|
||||
AV_OPT_TYPE_DICT,
|
||||
/**
|
||||
* Underlying C type is uint64_t.
|
||||
*/
|
||||
AV_OPT_TYPE_UINT64,
|
||||
/**
|
||||
* Special option type for declaring named constants. Does not correspond to
|
||||
* an actual field in the object, offset must be 0.
|
||||
*/
|
||||
AV_OPT_TYPE_CONST,
|
||||
AV_OPT_TYPE_IMAGE_SIZE, ///< offset must point to two consecutive integers
|
||||
/**
|
||||
* Underlying C type is two consecutive integers.
|
||||
*/
|
||||
AV_OPT_TYPE_IMAGE_SIZE,
|
||||
/**
|
||||
* Underlying C type is enum AVPixelFormat.
|
||||
*/
|
||||
AV_OPT_TYPE_PIXEL_FMT,
|
||||
/**
|
||||
* Underlying C type is enum AVSampleFormat.
|
||||
*/
|
||||
AV_OPT_TYPE_SAMPLE_FMT,
|
||||
AV_OPT_TYPE_VIDEO_RATE, ///< offset must point to AVRational
|
||||
/**
|
||||
* Underlying C type is AVRational.
|
||||
*/
|
||||
AV_OPT_TYPE_VIDEO_RATE,
|
||||
/**
|
||||
* Underlying C type is int64_t.
|
||||
*/
|
||||
AV_OPT_TYPE_DURATION,
|
||||
/**
|
||||
* Underlying C type is uint8_t[4].
|
||||
*/
|
||||
AV_OPT_TYPE_COLOR,
|
||||
#if FF_API_OLD_CHANNEL_LAYOUT
|
||||
AV_OPT_TYPE_CHANNEL_LAYOUT,
|
||||
#endif
|
||||
/**
|
||||
* Underlying C type is int.
|
||||
*/
|
||||
AV_OPT_TYPE_BOOL,
|
||||
/**
|
||||
* Underlying C type is AVChannelLayout.
|
||||
*/
|
||||
AV_OPT_TYPE_CHLAYOUT,
|
||||
/**
|
||||
* Underlying C type is unsigned int.
|
||||
*/
|
||||
AV_OPT_TYPE_UINT,
|
||||
|
||||
/**
|
||||
* May be combined with another regular option type to declare an array
|
||||
* option.
|
||||
*
|
||||
* For array options, @ref AVOption.offset should refer to a pointer
|
||||
* corresponding to the option type. The pointer should be immediately
|
||||
* followed by an unsigned int that will store the number of elements in the
|
||||
* array.
|
||||
*/
|
||||
AV_OPT_TYPE_FLAG_ARRAY = (1 << 16),
|
||||
};
|
||||
|
||||
/**
|
||||
* A generic parameter which can be set by the user for muxing or encoding.
|
||||
*/
|
||||
#define AV_OPT_FLAG_ENCODING_PARAM (1 << 0)
|
||||
/**
|
||||
* A generic parameter which can be set by the user for demuxing or decoding.
|
||||
*/
|
||||
#define AV_OPT_FLAG_DECODING_PARAM (1 << 1)
|
||||
#define AV_OPT_FLAG_AUDIO_PARAM (1 << 3)
|
||||
#define AV_OPT_FLAG_VIDEO_PARAM (1 << 4)
|
||||
#define AV_OPT_FLAG_SUBTITLE_PARAM (1 << 5)
|
||||
/**
|
||||
* The option is intended for exporting values to the caller.
|
||||
*/
|
||||
#define AV_OPT_FLAG_EXPORT (1 << 6)
|
||||
/**
|
||||
* The option may not be set through the AVOptions API, only read.
|
||||
* This flag only makes sense when AV_OPT_FLAG_EXPORT is also set.
|
||||
*/
|
||||
#define AV_OPT_FLAG_READONLY (1 << 7)
|
||||
/**
|
||||
* A generic parameter which can be set by the user for bit stream filtering.
|
||||
*/
|
||||
#define AV_OPT_FLAG_BSF_PARAM (1 << 8)
|
||||
|
||||
/**
|
||||
* A generic parameter which can be set by the user at runtime.
|
||||
*/
|
||||
#define AV_OPT_FLAG_RUNTIME_PARAM (1 << 15)
|
||||
/**
|
||||
* A generic parameter which can be set by the user for filtering.
|
||||
*/
|
||||
#define AV_OPT_FLAG_FILTERING_PARAM (1 << 16)
|
||||
/**
|
||||
* Set if option is deprecated, users should refer to AVOption.help text for
|
||||
* more information.
|
||||
*/
|
||||
#define AV_OPT_FLAG_DEPRECATED (1 << 17)
|
||||
/**
|
||||
* Set if option constants can also reside in child objects.
|
||||
*/
|
||||
#define AV_OPT_FLAG_CHILD_CONSTS (1 << 18)
|
||||
|
||||
/**
|
||||
* May be set as default_val for AV_OPT_TYPE_FLAG_ARRAY options.
|
||||
*/
|
||||
typedef struct AVOptionArrayDef {
|
||||
/**
|
||||
* Native access only.
|
||||
*
|
||||
* Default value of the option, as would be serialized by av_opt_get() (i.e.
|
||||
* using the value of sep as the separator).
|
||||
*/
|
||||
const char *def;
|
||||
|
||||
/**
|
||||
* Minimum number of elements in the array. When this field is non-zero, def
|
||||
* must be non-NULL and contain at least this number of elements.
|
||||
*/
|
||||
unsigned size_min;
|
||||
/**
|
||||
* Maximum number of elements in the array, 0 when unlimited.
|
||||
*/
|
||||
unsigned size_max;
|
||||
|
||||
/**
|
||||
* Separator between array elements in string representations of this
|
||||
* option, used by av_opt_set() and av_opt_get(). It must be a printable
|
||||
* ASCII character, excluding alphanumeric and the backslash. A comma is
|
||||
* used when sep=0.
|
||||
*
|
||||
* The separator and the backslash must be backslash-escaped in order to
|
||||
* appear in string representations of the option value.
|
||||
*/
|
||||
char sep;
|
||||
} AVOptionArrayDef;
|
||||
|
||||
/**
|
||||
* AVOption
|
||||
*/
|
||||
@@ -258,6 +436,8 @@ typedef struct AVOption {
|
||||
const char *help;
|
||||
|
||||
/**
|
||||
* Native access only.
|
||||
*
|
||||
* The offset relative to the context structure where the option
|
||||
* value is stored. It should be 0 for named constants.
|
||||
*/
|
||||
@@ -265,6 +445,7 @@ typedef struct AVOption {
|
||||
enum AVOptionType type;
|
||||
|
||||
/**
|
||||
* Native access only, except when documented otherwise.
|
||||
* the default value for scalar options
|
||||
*/
|
||||
union {
|
||||
@@ -273,31 +454,22 @@ typedef struct AVOption {
|
||||
const char *str;
|
||||
/* TODO those are unused now */
|
||||
AVRational q;
|
||||
|
||||
/**
|
||||
* Used for AV_OPT_TYPE_FLAG_ARRAY options. May be NULL.
|
||||
*
|
||||
* Foreign access to some members allowed, as noted in AVOptionArrayDef
|
||||
* documentation.
|
||||
*/
|
||||
const AVOptionArrayDef *arr;
|
||||
} default_val;
|
||||
double min; ///< minimum valid value for the option
|
||||
double max; ///< maximum valid value for the option
|
||||
|
||||
/**
|
||||
* A combination of AV_OPT_FLAG_*.
|
||||
*/
|
||||
int flags;
|
||||
#define AV_OPT_FLAG_ENCODING_PARAM 1 ///< a generic parameter which can be set by the user for muxing or encoding
|
||||
#define AV_OPT_FLAG_DECODING_PARAM 2 ///< a generic parameter which can be set by the user for demuxing or decoding
|
||||
#define AV_OPT_FLAG_AUDIO_PARAM 8
|
||||
#define AV_OPT_FLAG_VIDEO_PARAM 16
|
||||
#define AV_OPT_FLAG_SUBTITLE_PARAM 32
|
||||
/**
|
||||
* The option is intended for exporting values to the caller.
|
||||
*/
|
||||
#define AV_OPT_FLAG_EXPORT 64
|
||||
/**
|
||||
* The option may not be set through the AVOptions API, only read.
|
||||
* This flag only makes sense when AV_OPT_FLAG_EXPORT is also set.
|
||||
*/
|
||||
#define AV_OPT_FLAG_READONLY 128
|
||||
#define AV_OPT_FLAG_BSF_PARAM (1<<8) ///< a generic parameter which can be set by the user for bit stream filtering
|
||||
#define AV_OPT_FLAG_RUNTIME_PARAM (1<<15) ///< a generic parameter which can be set by the user at runtime
|
||||
#define AV_OPT_FLAG_FILTERING_PARAM (1<<16) ///< a generic parameter which can be set by the user for filtering
|
||||
#define AV_OPT_FLAG_DEPRECATED (1<<17) ///< set if option is deprecated, users should refer to AVOption.help text for more information
|
||||
#define AV_OPT_FLAG_CHILD_CONSTS (1<<18) ///< set if option constants can also reside in child objects
|
||||
//FIXME think about enc-audio, ... style flags
|
||||
|
||||
/**
|
||||
* The logical unit to which the option belongs. Non-constant
|
||||
@@ -376,15 +548,9 @@ typedef struct AVOptionRanges {
|
||||
} AVOptionRanges;
|
||||
|
||||
/**
|
||||
* Show the obj options.
|
||||
*
|
||||
* @param req_flags requested flags for the options to show. Show only the
|
||||
* options for which it is opt->flags & req_flags.
|
||||
* @param rej_flags rejected flags for the options to show. Show only the
|
||||
* options for which it is !(opt->flags & req_flags).
|
||||
* @param av_log_obj log context to use for showing the options
|
||||
* @defgroup opt_mng AVOption (un)initialization and inspection.
|
||||
* @{
|
||||
*/
|
||||
int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags);
|
||||
|
||||
/**
|
||||
* Set the values of all AVOption fields to their default values.
|
||||
@@ -404,161 +570,37 @@ void av_opt_set_defaults(void *s);
|
||||
*/
|
||||
void av_opt_set_defaults2(void *s, int mask, int flags);
|
||||
|
||||
/**
|
||||
* Parse the key/value pairs list in opts. For each key/value pair
|
||||
* found, stores the value in the field in ctx that is named like the
|
||||
* key. ctx must be an AVClass context, storing is done using
|
||||
* AVOptions.
|
||||
*
|
||||
* @param opts options string to parse, may be NULL
|
||||
* @param key_val_sep a 0-terminated list of characters used to
|
||||
* separate key from value
|
||||
* @param pairs_sep a 0-terminated list of characters used to separate
|
||||
* two pairs from each other
|
||||
* @return the number of successfully set key/value pairs, or a negative
|
||||
* value corresponding to an AVERROR code in case of error:
|
||||
* AVERROR(EINVAL) if opts cannot be parsed,
|
||||
* the error code issued by av_opt_set() if a key/value pair
|
||||
* cannot be set
|
||||
*/
|
||||
int av_set_options_string(void *ctx, const char *opts,
|
||||
const char *key_val_sep, const char *pairs_sep);
|
||||
|
||||
/**
|
||||
* Parse the key-value pairs list in opts. For each key=value pair found,
|
||||
* set the value of the corresponding option in ctx.
|
||||
*
|
||||
* @param ctx the AVClass object to set options on
|
||||
* @param opts the options string, key-value pairs separated by a
|
||||
* delimiter
|
||||
* @param shorthand a NULL-terminated array of options names for shorthand
|
||||
* notation: if the first field in opts has no key part,
|
||||
* the key is taken from the first element of shorthand;
|
||||
* then again for the second, etc., until either opts is
|
||||
* finished, shorthand is finished or a named option is
|
||||
* found; after that, all options must be named
|
||||
* @param key_val_sep a 0-terminated list of characters used to separate
|
||||
* key from value, for example '='
|
||||
* @param pairs_sep a 0-terminated list of characters used to separate
|
||||
* two pairs from each other, for example ':' or ','
|
||||
* @return the number of successfully set key=value pairs, or a negative
|
||||
* value corresponding to an AVERROR code in case of error:
|
||||
* AVERROR(EINVAL) if opts cannot be parsed,
|
||||
* the error code issued by av_set_string3() if a key/value pair
|
||||
* cannot be set
|
||||
*
|
||||
* Options names must use only the following characters: a-z A-Z 0-9 - . / _
|
||||
* Separators must use characters distinct from option names and from each
|
||||
* other.
|
||||
*/
|
||||
int av_opt_set_from_string(void *ctx, const char *opts,
|
||||
const char *const *shorthand,
|
||||
const char *key_val_sep, const char *pairs_sep);
|
||||
/**
|
||||
* Free all allocated objects in obj.
|
||||
*/
|
||||
void av_opt_free(void *obj);
|
||||
|
||||
/**
|
||||
* Check whether a particular flag is set in a flags field.
|
||||
* Iterate over all AVOptions belonging to obj.
|
||||
*
|
||||
* @param field_name the name of the flag field option
|
||||
* @param flag_name the name of the flag to check
|
||||
* @return non-zero if the flag is set, zero if the flag isn't set,
|
||||
* isn't of the right type, or the flags field doesn't exist.
|
||||
* @param obj an AVOptions-enabled struct or a double pointer to an
|
||||
* AVClass describing it.
|
||||
* @param prev result of the previous call to av_opt_next() on this object
|
||||
* or NULL
|
||||
* @return next AVOption or NULL
|
||||
*/
|
||||
int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name);
|
||||
const AVOption *av_opt_next(const void *obj, const AVOption *prev);
|
||||
|
||||
/**
|
||||
* Set all the options from a given dictionary on an object.
|
||||
* Iterate over AVOptions-enabled children of obj.
|
||||
*
|
||||
* @param obj a struct whose first element is a pointer to AVClass
|
||||
* @param options options to process. This dictionary will be freed and replaced
|
||||
* by a new one containing all options not found in obj.
|
||||
* Of course this new dictionary needs to be freed by caller
|
||||
* with av_dict_free().
|
||||
*
|
||||
* @return 0 on success, a negative AVERROR if some option was found in obj,
|
||||
* but could not be set.
|
||||
*
|
||||
* @see av_dict_copy()
|
||||
* @param prev result of a previous call to this function or NULL
|
||||
* @return next AVOptions-enabled child or NULL
|
||||
*/
|
||||
int av_opt_set_dict(void *obj, struct AVDictionary **options);
|
||||
|
||||
void *av_opt_child_next(void *obj, void *prev);
|
||||
|
||||
/**
|
||||
* Set all the options from a given dictionary on an object.
|
||||
* Iterate over potential AVOptions-enabled children of parent.
|
||||
*
|
||||
* @param obj a struct whose first element is a pointer to AVClass
|
||||
* @param options options to process. This dictionary will be freed and replaced
|
||||
* by a new one containing all options not found in obj.
|
||||
* Of course this new dictionary needs to be freed by caller
|
||||
* with av_dict_free().
|
||||
* @param search_flags A combination of AV_OPT_SEARCH_*.
|
||||
*
|
||||
* @return 0 on success, a negative AVERROR if some option was found in obj,
|
||||
* but could not be set.
|
||||
*
|
||||
* @see av_dict_copy()
|
||||
*/
|
||||
int av_opt_set_dict2(void *obj, struct AVDictionary **options, int search_flags);
|
||||
|
||||
/**
|
||||
* Extract a key-value pair from the beginning of a string.
|
||||
*
|
||||
* @param ropts pointer to the options string, will be updated to
|
||||
* point to the rest of the string (one of the pairs_sep
|
||||
* or the final NUL)
|
||||
* @param key_val_sep a 0-terminated list of characters used to separate
|
||||
* key from value, for example '='
|
||||
* @param pairs_sep a 0-terminated list of characters used to separate
|
||||
* two pairs from each other, for example ':' or ','
|
||||
* @param flags flags; see the AV_OPT_FLAG_* values below
|
||||
* @param rkey parsed key; must be freed using av_free()
|
||||
* @param rval parsed value; must be freed using av_free()
|
||||
*
|
||||
* @return >=0 for success, or a negative value corresponding to an
|
||||
* AVERROR code in case of error; in particular:
|
||||
* AVERROR(EINVAL) if no key is present
|
||||
*
|
||||
*/
|
||||
int av_opt_get_key_value(const char **ropts,
|
||||
const char *key_val_sep, const char *pairs_sep,
|
||||
unsigned flags,
|
||||
char **rkey, char **rval);
|
||||
|
||||
enum {
|
||||
|
||||
/**
|
||||
* Accept to parse a value without a key; the key will then be returned
|
||||
* as NULL.
|
||||
*/
|
||||
AV_OPT_FLAG_IMPLICIT_KEY = 1,
|
||||
};
|
||||
|
||||
/**
|
||||
* @defgroup opt_eval_funcs Evaluating option strings
|
||||
* @{
|
||||
* This group of functions can be used to evaluate option strings
|
||||
* and get numbers out of them. They do the same thing as av_opt_set(),
|
||||
* except the result is written into the caller-supplied pointer.
|
||||
*
|
||||
* @param obj a struct whose first element is a pointer to AVClass.
|
||||
* @param o an option for which the string is to be evaluated.
|
||||
* @param val string to be evaluated.
|
||||
* @param *_out value of the string will be written here.
|
||||
*
|
||||
* @return 0 on success, a negative number on failure.
|
||||
*/
|
||||
int av_opt_eval_flags (void *obj, const AVOption *o, const char *val, int *flags_out);
|
||||
int av_opt_eval_int (void *obj, const AVOption *o, const char *val, int *int_out);
|
||||
int av_opt_eval_int64 (void *obj, const AVOption *o, const char *val, int64_t *int64_out);
|
||||
int av_opt_eval_float (void *obj, const AVOption *o, const char *val, float *float_out);
|
||||
int av_opt_eval_double(void *obj, const AVOption *o, const char *val, double *double_out);
|
||||
int av_opt_eval_q (void *obj, const AVOption *o, const char *val, AVRational *q_out);
|
||||
/**
|
||||
* @}
|
||||
* @param iter a pointer where iteration state is stored.
|
||||
* @return AVClass corresponding to next potential child or NULL
|
||||
*/
|
||||
const AVClass *av_opt_child_class_iterate(const AVClass *parent, void **iter);
|
||||
|
||||
#define AV_OPT_SEARCH_CHILDREN (1 << 0) /**< Search in possible children of the
|
||||
given object first. */
|
||||
@@ -576,6 +618,12 @@ int av_opt_eval_q (void *obj, const AVOption *o, const char *val, AVRational
|
||||
*/
|
||||
#define AV_OPT_ALLOW_NULL (1 << 2)
|
||||
|
||||
/**
|
||||
* May be used with av_opt_set_array() to signal that new elements should
|
||||
* replace the existing ones in the indicated range.
|
||||
*/
|
||||
#define AV_OPT_ARRAY_REPLACE (1 << 3)
|
||||
|
||||
/**
|
||||
* Allows av_opt_query_ranges and av_opt_query_ranges_default to return more than
|
||||
* one component for certain option types.
|
||||
@@ -633,31 +681,161 @@ const AVOption *av_opt_find2(void *obj, const char *name, const char *unit,
|
||||
int opt_flags, int search_flags, void **target_obj);
|
||||
|
||||
/**
|
||||
* Iterate over all AVOptions belonging to obj.
|
||||
* Show the obj options.
|
||||
*
|
||||
* @param obj an AVOptions-enabled struct or a double pointer to an
|
||||
* AVClass describing it.
|
||||
* @param prev result of the previous call to av_opt_next() on this object
|
||||
* or NULL
|
||||
* @return next AVOption or NULL
|
||||
* @param req_flags requested flags for the options to show. Show only the
|
||||
* options for which it is opt->flags & req_flags.
|
||||
* @param rej_flags rejected flags for the options to show. Show only the
|
||||
* options for which it is !(opt->flags & req_flags).
|
||||
* @param av_log_obj log context to use for showing the options
|
||||
*/
|
||||
const AVOption *av_opt_next(const void *obj, const AVOption *prev);
|
||||
int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags);
|
||||
|
||||
/**
|
||||
* Iterate over AVOptions-enabled children of obj.
|
||||
* Extract a key-value pair from the beginning of a string.
|
||||
*
|
||||
* @param ropts pointer to the options string, will be updated to
|
||||
* point to the rest of the string (one of the pairs_sep
|
||||
* or the final NUL)
|
||||
* @param key_val_sep a 0-terminated list of characters used to separate
|
||||
* key from value, for example '='
|
||||
* @param pairs_sep a 0-terminated list of characters used to separate
|
||||
* two pairs from each other, for example ':' or ','
|
||||
* @param flags flags; see the AV_OPT_FLAG_* values below
|
||||
* @param rkey parsed key; must be freed using av_free()
|
||||
* @param rval parsed value; must be freed using av_free()
|
||||
*
|
||||
* @return >=0 for success, or a negative value corresponding to an
|
||||
* AVERROR code in case of error; in particular:
|
||||
* AVERROR(EINVAL) if no key is present
|
||||
*
|
||||
* @param prev result of a previous call to this function or NULL
|
||||
* @return next AVOptions-enabled child or NULL
|
||||
*/
|
||||
void *av_opt_child_next(void *obj, void *prev);
|
||||
int av_opt_get_key_value(const char **ropts,
|
||||
const char *key_val_sep, const char *pairs_sep,
|
||||
unsigned flags,
|
||||
char **rkey, char **rval);
|
||||
|
||||
enum {
|
||||
|
||||
/**
|
||||
* Accept to parse a value without a key; the key will then be returned
|
||||
* as NULL.
|
||||
*/
|
||||
AV_OPT_FLAG_IMPLICIT_KEY = 1,
|
||||
};
|
||||
|
||||
/**
|
||||
* Iterate over potential AVOptions-enabled children of parent.
|
||||
*
|
||||
* @param iter a pointer where iteration state is stored.
|
||||
* @return AVClass corresponding to next potential child or NULL
|
||||
* @}
|
||||
*/
|
||||
const AVClass *av_opt_child_class_iterate(const AVClass *parent, void **iter);
|
||||
|
||||
/**
|
||||
* @defgroup opt_write Setting and modifying option values
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Parse the key/value pairs list in opts. For each key/value pair
|
||||
* found, stores the value in the field in ctx that is named like the
|
||||
* key. ctx must be an AVClass context, storing is done using
|
||||
* AVOptions.
|
||||
*
|
||||
* @param opts options string to parse, may be NULL
|
||||
* @param key_val_sep a 0-terminated list of characters used to
|
||||
* separate key from value
|
||||
* @param pairs_sep a 0-terminated list of characters used to separate
|
||||
* two pairs from each other
|
||||
* @return the number of successfully set key/value pairs, or a negative
|
||||
* value corresponding to an AVERROR code in case of error:
|
||||
* AVERROR(EINVAL) if opts cannot be parsed,
|
||||
* the error code issued by av_opt_set() if a key/value pair
|
||||
* cannot be set
|
||||
*/
|
||||
int av_set_options_string(void *ctx, const char *opts,
|
||||
const char *key_val_sep, const char *pairs_sep);
|
||||
|
||||
/**
|
||||
* Parse the key-value pairs list in opts. For each key=value pair found,
|
||||
* set the value of the corresponding option in ctx.
|
||||
*
|
||||
* @param ctx the AVClass object to set options on
|
||||
* @param opts the options string, key-value pairs separated by a
|
||||
* delimiter
|
||||
* @param shorthand a NULL-terminated array of options names for shorthand
|
||||
* notation: if the first field in opts has no key part,
|
||||
* the key is taken from the first element of shorthand;
|
||||
* then again for the second, etc., until either opts is
|
||||
* finished, shorthand is finished or a named option is
|
||||
* found; after that, all options must be named
|
||||
* @param key_val_sep a 0-terminated list of characters used to separate
|
||||
* key from value, for example '='
|
||||
* @param pairs_sep a 0-terminated list of characters used to separate
|
||||
* two pairs from each other, for example ':' or ','
|
||||
* @return the number of successfully set key=value pairs, or a negative
|
||||
* value corresponding to an AVERROR code in case of error:
|
||||
* AVERROR(EINVAL) if opts cannot be parsed,
|
||||
* the error code issued by av_set_string3() if a key/value pair
|
||||
* cannot be set
|
||||
*
|
||||
* Options names must use only the following characters: a-z A-Z 0-9 - . / _
|
||||
* Separators must use characters distinct from option names and from each
|
||||
* other.
|
||||
*/
|
||||
int av_opt_set_from_string(void *ctx, const char *opts,
|
||||
const char *const *shorthand,
|
||||
const char *key_val_sep, const char *pairs_sep);
|
||||
|
||||
/**
|
||||
* Set all the options from a given dictionary on an object.
|
||||
*
|
||||
* @param obj a struct whose first element is a pointer to AVClass
|
||||
* @param options options to process. This dictionary will be freed and replaced
|
||||
* by a new one containing all options not found in obj.
|
||||
* Of course this new dictionary needs to be freed by caller
|
||||
* with av_dict_free().
|
||||
*
|
||||
* @return 0 on success, a negative AVERROR if some option was found in obj,
|
||||
* but could not be set.
|
||||
*
|
||||
* @see av_dict_copy()
|
||||
*/
|
||||
int av_opt_set_dict(void *obj, struct AVDictionary **options);
|
||||
|
||||
|
||||
/**
|
||||
* Set all the options from a given dictionary on an object.
|
||||
*
|
||||
* @param obj a struct whose first element is a pointer to AVClass
|
||||
* @param options options to process. This dictionary will be freed and replaced
|
||||
* by a new one containing all options not found in obj.
|
||||
* Of course this new dictionary needs to be freed by caller
|
||||
* with av_dict_free().
|
||||
* @param search_flags A combination of AV_OPT_SEARCH_*.
|
||||
*
|
||||
* @return 0 on success, a negative AVERROR if some option was found in obj,
|
||||
* but could not be set.
|
||||
*
|
||||
* @see av_dict_copy()
|
||||
*/
|
||||
int av_opt_set_dict2(void *obj, struct AVDictionary **options, int search_flags);
|
||||
|
||||
/**
|
||||
* Copy options from src object into dest object.
|
||||
*
|
||||
* The underlying AVClass of both src and dest must coincide. The guarantee
|
||||
* below does not apply if this is not fulfilled.
|
||||
*
|
||||
* Options that require memory allocation (e.g. string or binary) are malloc'ed in dest object.
|
||||
* Original memory allocated for such options is freed unless both src and dest options points to the same memory.
|
||||
*
|
||||
* Even on error it is guaranteed that allocated options from src and dest
|
||||
* no longer alias each other afterwards; in particular calling av_opt_free()
|
||||
* on both src and dest is safe afterwards if dest has been memdup'ed from src.
|
||||
*
|
||||
* @param dest Object to copy from
|
||||
* @param src Object to copy into
|
||||
* @return 0 on success, negative on error
|
||||
*/
|
||||
int av_opt_copy(void *dest, const void *src);
|
||||
|
||||
/**
|
||||
* @defgroup opt_set_funcs Option setting functions
|
||||
@@ -697,10 +875,10 @@ int av_opt_set_image_size(void *obj, const char *name, int w, int h, int search_
|
||||
int av_opt_set_pixel_fmt (void *obj, const char *name, enum AVPixelFormat fmt, int search_flags);
|
||||
int av_opt_set_sample_fmt(void *obj, const char *name, enum AVSampleFormat fmt, int search_flags);
|
||||
int av_opt_set_video_rate(void *obj, const char *name, AVRational val, int search_flags);
|
||||
#if FF_API_OLD_CHANNEL_LAYOUT
|
||||
attribute_deprecated
|
||||
int av_opt_set_channel_layout(void *obj, const char *name, int64_t ch_layout, int search_flags);
|
||||
#endif
|
||||
/**
|
||||
* @note Any old chlayout present is discarded and replaced with a copy of the new one. The
|
||||
* caller still owns layout and is responsible for uninitializing it.
|
||||
*/
|
||||
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
|
||||
@@ -724,8 +902,64 @@ int av_opt_set_dict_val(void *obj, const char *name, const AVDictionary *val, in
|
||||
av_opt_set_bin(obj, name, (const uint8_t *)(val), \
|
||||
av_int_list_length(val, term) * sizeof(*(val)), flags))
|
||||
|
||||
/**
|
||||
* Add, replace, or remove elements for an array option. Which of these
|
||||
* operations is performed depends on the values of val and search_flags.
|
||||
*
|
||||
* @param start_elem Index of the first array element to modify; must not be
|
||||
* larger than array size as returned by
|
||||
* av_opt_get_array_size().
|
||||
* @param nb_elems number of array elements to modify; when val is NULL,
|
||||
* start_elem+nb_elems must not be larger than array size as
|
||||
* returned by av_opt_get_array_size()
|
||||
*
|
||||
* @param val_type Option type corresponding to the type of val, ignored when val is
|
||||
* NULL.
|
||||
*
|
||||
* The effect of this function will will be as if av_opt_setX()
|
||||
* was called for each element, where X is specified by type.
|
||||
* E.g. AV_OPT_TYPE_STRING corresponds to av_opt_set().
|
||||
*
|
||||
* Typically this should be the same as the scalarized type of
|
||||
* the AVOption being set, but certain conversions are also
|
||||
* possible - the same as those done by the corresponding
|
||||
* av_opt_set*() function. E.g. any option type can be set from
|
||||
* a string, numeric types can be set from int64, double, or
|
||||
* rational, etc.
|
||||
*
|
||||
* @param val Array with nb_elems elements or NULL.
|
||||
*
|
||||
* When NULL, nb_elems array elements starting at start_elem are
|
||||
* removed from the array. Any array elements remaining at the end
|
||||
* are shifted by nb_elems towards the first element in order to keep
|
||||
* the array contiguous.
|
||||
*
|
||||
* Otherwise (val is non-NULL), the type of val must match the
|
||||
* underlying C type as documented for val_type.
|
||||
*
|
||||
* When AV_OPT_ARRAY_REPLACE is not set in search_flags, the array is
|
||||
* enlarged by nb_elems, and the contents of val are inserted at
|
||||
* start_elem. Previously existing array elements from start_elem
|
||||
* onwards (if present) are shifted by nb_elems away from the first
|
||||
* element in order to make space for the new elements.
|
||||
*
|
||||
* When AV_OPT_ARRAY_REPLACE is set in search_flags, the contents
|
||||
* of val replace existing array elements from start_elem to
|
||||
* start_elem+nb_elems (if present). New array size is
|
||||
* max(start_elem + nb_elems, old array size).
|
||||
*/
|
||||
int av_opt_set_array(void *obj, const char *name, int search_flags,
|
||||
unsigned int start_elem, unsigned int nb_elems,
|
||||
enum AVOptionType val_type, const void *val);
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup opt_read Reading option values
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -756,19 +990,85 @@ int av_opt_get_image_size(void *obj, const char *name, int search_flags, int *w_
|
||||
int av_opt_get_pixel_fmt (void *obj, const char *name, int search_flags, enum AVPixelFormat *out_fmt);
|
||||
int av_opt_get_sample_fmt(void *obj, const char *name, int search_flags, enum AVSampleFormat *out_fmt);
|
||||
int av_opt_get_video_rate(void *obj, const char *name, int search_flags, AVRational *out_val);
|
||||
#if FF_API_OLD_CHANNEL_LAYOUT
|
||||
attribute_deprecated
|
||||
int av_opt_get_channel_layout(void *obj, const char *name, int search_flags, int64_t *ch_layout);
|
||||
#endif
|
||||
/**
|
||||
* @param[out] layout The returned layout is a copy of the actual value and must
|
||||
* be freed with av_channel_layout_uninit() by the caller
|
||||
*/
|
||||
int av_opt_get_chlayout(void *obj, const char *name, int search_flags, AVChannelLayout *layout);
|
||||
/**
|
||||
* @param[out] out_val The returned dictionary is a copy of the actual value and must
|
||||
* be freed with av_dict_free() by the caller
|
||||
*/
|
||||
int av_opt_get_dict_val(void *obj, const char *name, int search_flags, AVDictionary **out_val);
|
||||
|
||||
/**
|
||||
* For an array-type option, get the number of elements in the array.
|
||||
*/
|
||||
int av_opt_get_array_size(void *obj, const char *name, int search_flags,
|
||||
unsigned int *out_val);
|
||||
|
||||
/**
|
||||
* For an array-type option, retrieve the values of one or more array elements.
|
||||
*
|
||||
* @param start_elem index of the first array element to retrieve
|
||||
* @param nb_elems number of array elements to retrieve; start_elem+nb_elems
|
||||
* must not be larger than array size as returned by
|
||||
* av_opt_get_array_size()
|
||||
*
|
||||
* @param out_type Option type corresponding to the desired output.
|
||||
*
|
||||
* The array elements produced by this function will
|
||||
* will be as if av_opt_getX() was called for each element,
|
||||
* where X is specified by out_type. E.g. AV_OPT_TYPE_STRING
|
||||
* corresponds to av_opt_get().
|
||||
*
|
||||
* Typically this should be the same as the scalarized type of
|
||||
* the AVOption being retrieved, but certain conversions are
|
||||
* also possible - the same as those done by the corresponding
|
||||
* av_opt_get*() function. E.g. any option type can be retrieved
|
||||
* as a string, numeric types can be retrieved as int64, double,
|
||||
* or rational, etc.
|
||||
*
|
||||
* @param out_val Array with nb_elems members into which the output will be
|
||||
* written. The array type must match the underlying C type as
|
||||
* documented for out_type, and be zeroed on entry to this
|
||||
* function.
|
||||
*
|
||||
* For dynamically allocated types (strings, binary, dicts,
|
||||
* etc.), the result is owned and freed by the caller.
|
||||
*/
|
||||
int av_opt_get_array(void *obj, const char *name, int search_flags,
|
||||
unsigned int start_elem, unsigned int nb_elems,
|
||||
enum AVOptionType out_type, void *out_val);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup opt_eval_funcs Evaluating option strings
|
||||
* @{
|
||||
* This group of functions can be used to evaluate option strings
|
||||
* and get numbers out of them. They do the same thing as av_opt_set(),
|
||||
* except the result is written into the caller-supplied pointer.
|
||||
*
|
||||
* @param obj a struct whose first element is a pointer to AVClass.
|
||||
* @param o an option for which the string is to be evaluated.
|
||||
* @param val string to be evaluated.
|
||||
* @param *_out value of the string will be written here.
|
||||
*
|
||||
* @return 0 on success, a negative number on failure.
|
||||
*/
|
||||
int av_opt_eval_flags (void *obj, const AVOption *o, const char *val, int *flags_out);
|
||||
int av_opt_eval_int (void *obj, const AVOption *o, const char *val, int *int_out);
|
||||
int av_opt_eval_uint (void *obj, const AVOption *o, const char *val, unsigned *uint_out);
|
||||
int av_opt_eval_int64 (void *obj, const AVOption *o, const char *val, int64_t *int64_out);
|
||||
int av_opt_eval_float (void *obj, const AVOption *o, const char *val, float *float_out);
|
||||
int av_opt_eval_double(void *obj, const AVOption *o, const char *val, double *double_out);
|
||||
int av_opt_eval_q (void *obj, const AVOption *o, const char *val, AVRational *q_out);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Gets a pointer to the requested field in a struct.
|
||||
* This function allows accessing a struct even when its fields are moved or
|
||||
@@ -779,61 +1079,6 @@ int av_opt_get_dict_val(void *obj, const char *name, int search_flags, AVDiction
|
||||
*/
|
||||
void *av_opt_ptr(const AVClass *avclass, void *obj, const char *name);
|
||||
|
||||
/**
|
||||
* Free an AVOptionRanges struct and set it to NULL.
|
||||
*/
|
||||
void av_opt_freep_ranges(AVOptionRanges **ranges);
|
||||
|
||||
/**
|
||||
* Get a list of allowed ranges for the given option.
|
||||
*
|
||||
* The returned list may depend on other fields in obj like for example profile.
|
||||
*
|
||||
* @param flags is a bitmask of flags, undefined flags should not be set and should be ignored
|
||||
* AV_OPT_SEARCH_FAKE_OBJ indicates that the obj is a double pointer to a AVClass instead of a full instance
|
||||
* AV_OPT_MULTI_COMPONENT_RANGE indicates that function may return more than one component, @see AVOptionRanges
|
||||
*
|
||||
* The result must be freed with av_opt_freep_ranges.
|
||||
*
|
||||
* @return number of compontents returned on success, a negative errro code otherwise
|
||||
*/
|
||||
int av_opt_query_ranges(AVOptionRanges **, void *obj, const char *key, int flags);
|
||||
|
||||
/**
|
||||
* Copy options from src object into dest object.
|
||||
*
|
||||
* The underlying AVClass of both src and dest must coincide. The guarantee
|
||||
* below does not apply if this is not fulfilled.
|
||||
*
|
||||
* Options that require memory allocation (e.g. string or binary) are malloc'ed in dest object.
|
||||
* Original memory allocated for such options is freed unless both src and dest options points to the same memory.
|
||||
*
|
||||
* Even on error it is guaranteed that allocated options from src and dest
|
||||
* no longer alias each other afterwards; in particular calling av_opt_free()
|
||||
* on both src and dest is safe afterwards if dest has been memdup'ed from src.
|
||||
*
|
||||
* @param dest Object to copy from
|
||||
* @param src Object to copy into
|
||||
* @return 0 on success, negative on error
|
||||
*/
|
||||
int av_opt_copy(void *dest, const void *src);
|
||||
|
||||
/**
|
||||
* Get a default list of allowed ranges for the given option.
|
||||
*
|
||||
* This list is constructed without using the AVClass.query_ranges() callback
|
||||
* and can be used as fallback from within the callback.
|
||||
*
|
||||
* @param flags is a bitmask of flags, undefined flags should not be set and should be ignored
|
||||
* AV_OPT_SEARCH_FAKE_OBJ indicates that the obj is a double pointer to a AVClass instead of a full instance
|
||||
* AV_OPT_MULTI_COMPONENT_RANGE indicates that function may return more than one component, @see AVOptionRanges
|
||||
*
|
||||
* The result must be freed with av_opt_free_ranges.
|
||||
*
|
||||
* @return number of compontents returned on success, a negative errro code otherwise
|
||||
*/
|
||||
int av_opt_query_ranges_default(AVOptionRanges **, void *obj, const char *key, int flags);
|
||||
|
||||
/**
|
||||
* Check if given option is set to its default value.
|
||||
*
|
||||
@@ -860,9 +1105,19 @@ int av_opt_is_set_to_default(void *obj, const AVOption *o);
|
||||
*/
|
||||
int av_opt_is_set_to_default_by_name(void *obj, const char *name, int search_flags);
|
||||
|
||||
/**
|
||||
* Check whether a particular flag is set in a flags field.
|
||||
*
|
||||
* @param field_name the name of the flag field option
|
||||
* @param flag_name the name of the flag to check
|
||||
* @return non-zero if the flag is set, zero if the flag isn't set,
|
||||
* isn't of the right type, or the flags field doesn't exist.
|
||||
*/
|
||||
int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name);
|
||||
|
||||
#define AV_OPT_SERIALIZE_SKIP_DEFAULTS 0x00000001 ///< Serialize options that are not set to default values only.
|
||||
#define AV_OPT_SERIALIZE_OPT_FLAGS_EXACT 0x00000002 ///< Serialize options that exactly match opt_flags only.
|
||||
#define AV_OPT_SERIALIZE_SEARCH_CHILDREN 0x00000004 ///< Serialize options in possible children of the given object.
|
||||
|
||||
/**
|
||||
* Serialize object's options.
|
||||
@@ -884,6 +1139,47 @@ int av_opt_is_set_to_default_by_name(void *obj, const char *name, int search_fla
|
||||
*/
|
||||
int av_opt_serialize(void *obj, int opt_flags, int flags, char **buffer,
|
||||
const char key_val_sep, const char pairs_sep);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Free an AVOptionRanges struct and set it to NULL.
|
||||
*/
|
||||
void av_opt_freep_ranges(AVOptionRanges **ranges);
|
||||
|
||||
/**
|
||||
* Get a list of allowed ranges for the given option.
|
||||
*
|
||||
* The returned list may depend on other fields in obj like for example profile.
|
||||
*
|
||||
* @param flags is a bitmask of flags, undefined flags should not be set and should be ignored
|
||||
* AV_OPT_SEARCH_FAKE_OBJ indicates that the obj is a double pointer to a AVClass instead of a full instance
|
||||
* AV_OPT_MULTI_COMPONENT_RANGE indicates that function may return more than one component, @see AVOptionRanges
|
||||
*
|
||||
* The result must be freed with av_opt_freep_ranges.
|
||||
*
|
||||
* @return number of compontents returned on success, a negative errro code otherwise
|
||||
*/
|
||||
int av_opt_query_ranges(AVOptionRanges **, void *obj, const char *key, int flags);
|
||||
|
||||
/**
|
||||
* Get a default list of allowed ranges for the given option.
|
||||
*
|
||||
* This list is constructed without using the AVClass.query_ranges() callback
|
||||
* and can be used as fallback from within the callback.
|
||||
*
|
||||
* @param flags is a bitmask of flags, undefined flags should not be set and should be ignored
|
||||
* AV_OPT_SEARCH_FAKE_OBJ indicates that the obj is a double pointer to a AVClass instead of a full instance
|
||||
* AV_OPT_MULTI_COMPONENT_RANGE indicates that function may return more than one component, @see AVOptionRanges
|
||||
*
|
||||
* The result must be freed with av_opt_free_ranges.
|
||||
*
|
||||
* @return number of compontents returned on success, a negative errro code otherwise
|
||||
*/
|
||||
int av_opt_query_ranges_default(AVOptionRanges **, void *obj, const char *key, int flags);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
@@ -79,6 +79,8 @@ int av_parse_video_rate(AVRational *rate, const char *str);
|
||||
/**
|
||||
* Put the RGBA values that correspond to color_string in rgba_color.
|
||||
*
|
||||
* @param rgba_color 4-elements array of uint8_t values, where the respective
|
||||
* red, green, blue and alpha component values are written.
|
||||
* @param color_string a string specifying a color. It can be the name of
|
||||
* a color (case insensitive match) or a [0x|#]RRGGBB[AA] sequence,
|
||||
* possibly followed by "@" and a string representing the alpha
|
||||
@@ -92,6 +94,8 @@ int av_parse_video_rate(AVRational *rate, const char *str);
|
||||
* @param slen length of the initial part of color_string containing the
|
||||
* color. It can be set to -1 if color_string is a null terminated string
|
||||
* containing nothing else than the color.
|
||||
* @param log_ctx a pointer to an arbitrary struct of which the first field
|
||||
* is a pointer to an AVClass struct (used for av_log()). Can be NULL.
|
||||
* @return >= 0 in case of success, a negative value in case of
|
||||
* failure (for example if color_string cannot be parsed).
|
||||
*/
|
||||
@@ -106,7 +110,7 @@ int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen,
|
||||
* av_parse_color().
|
||||
*
|
||||
* @param color_idx index of the requested color, starting from 0
|
||||
* @param rgbp if not NULL, will point to a 3-elements array with the color value in RGB
|
||||
* @param rgb if not NULL, will point to a 3-elements array with the color value in RGB
|
||||
* @return the color name string or NULL if color_idx is not in the array
|
||||
*/
|
||||
const char *av_get_known_color_name(int color_idx, const uint8_t **rgb);
|
||||
@@ -162,19 +166,19 @@ int av_find_info_tag(char *arg, int arg_size, const char *tag1, const char *info
|
||||
* by the standard strptime().
|
||||
*
|
||||
* The supported input field descriptors are listed below.
|
||||
* - %H: the hour as a decimal number, using a 24-hour clock, in the
|
||||
* - `%%H`: the hour as a decimal number, using a 24-hour clock, in the
|
||||
* range '00' through '23'
|
||||
* - %J: hours as a decimal number, in the range '0' through INT_MAX
|
||||
* - %M: the minute as a decimal number, using a 24-hour clock, in the
|
||||
* - `%%J`: hours as a decimal number, in the range '0' through INT_MAX
|
||||
* - `%%M`: the minute as a decimal number, using a 24-hour clock, in the
|
||||
* range '00' through '59'
|
||||
* - %S: the second as a decimal number, using a 24-hour clock, in the
|
||||
* - `%%S`: the second as a decimal number, using a 24-hour clock, in the
|
||||
* range '00' through '59'
|
||||
* - %Y: the year as a decimal number, using the Gregorian calendar
|
||||
* - %m: the month as a decimal number, in the range '1' through '12'
|
||||
* - %d: the day of the month as a decimal number, in the range '1'
|
||||
* - `%%Y`: the year as a decimal number, using the Gregorian calendar
|
||||
* - `%%m`: the month as a decimal number, in the range '1' through '12'
|
||||
* - `%%d`: the day of the month as a decimal number, in the range '1'
|
||||
* through '31'
|
||||
* - %T: alias for '%H:%M:%S'
|
||||
* - %%: a literal '%'
|
||||
* - `%%T`: alias for `%%H:%%M:%%S`
|
||||
* - `%%`: a literal `%`
|
||||
*
|
||||
* @return a pointer to the first character not processed in this function
|
||||
* call. In case the input string contains more characters than
|
||||
|
||||
@@ -157,6 +157,11 @@ typedef struct AVPixFmtDescriptor {
|
||||
*/
|
||||
#define AV_PIX_FMT_FLAG_FLOAT (1 << 9)
|
||||
|
||||
/**
|
||||
* The pixel format contains XYZ-like data (as opposed to YUV/RGB/grayscale).
|
||||
*/
|
||||
#define AV_PIX_FMT_FLAG_XYZ (1 << 10)
|
||||
|
||||
/**
|
||||
* Return the number of bits per pixel used by the pixel format
|
||||
* described by pixdesc. Note that this is not the same as the number
|
||||
@@ -264,6 +269,28 @@ const char *av_chroma_location_name(enum AVChromaLocation location);
|
||||
*/
|
||||
int av_chroma_location_from_name(const char *name);
|
||||
|
||||
/**
|
||||
* Converts AVChromaLocation to swscale x/y chroma position.
|
||||
*
|
||||
* The positions represent the chroma (0,0) position in a coordinates system
|
||||
* with luma (0,0) representing the origin and luma(1,1) representing 256,256
|
||||
*
|
||||
* @param xpos horizontal chroma sample position
|
||||
* @param ypos vertical chroma sample position
|
||||
*/
|
||||
int av_chroma_location_enum_to_pos(int *xpos, int *ypos, enum AVChromaLocation pos);
|
||||
|
||||
/**
|
||||
* Converts swscale x/y chroma position to AVChromaLocation.
|
||||
*
|
||||
* The positions represent the chroma (0,0) position in a coordinates system
|
||||
* with luma (0,0) representing the origin and luma(1,1) representing 256,256
|
||||
*
|
||||
* @param xpos horizontal chroma sample position
|
||||
* @param ypos vertical chroma sample position
|
||||
*/
|
||||
enum AVChromaLocation av_chroma_location_pos_to_enum(int xpos, int ypos);
|
||||
|
||||
/**
|
||||
* Return the pixel format corresponding to name.
|
||||
*
|
||||
@@ -357,12 +384,15 @@ void av_write_image_line(const uint16_t *src, uint8_t *data[4],
|
||||
*/
|
||||
enum AVPixelFormat av_pix_fmt_swap_endianness(enum AVPixelFormat pix_fmt);
|
||||
|
||||
#define FF_LOSS_RESOLUTION 0x0001 /**< loss due to resolution change */
|
||||
#define FF_LOSS_DEPTH 0x0002 /**< loss due to color depth change */
|
||||
#define FF_LOSS_COLORSPACE 0x0004 /**< loss due to color space conversion */
|
||||
#define FF_LOSS_ALPHA 0x0008 /**< loss of alpha bits */
|
||||
#define FF_LOSS_COLORQUANT 0x0010 /**< loss due to color quantization */
|
||||
#define FF_LOSS_CHROMA 0x0020 /**< loss of chroma (e.g. RGB to gray conversion) */
|
||||
#define FF_LOSS_RESOLUTION 0x0001 /**< loss due to resolution change */
|
||||
#define FF_LOSS_DEPTH 0x0002 /**< loss due to color depth change */
|
||||
#define FF_LOSS_COLORSPACE 0x0004 /**< loss due to color space conversion */
|
||||
#define FF_LOSS_ALPHA 0x0008 /**< loss of alpha bits */
|
||||
#define FF_LOSS_COLORQUANT 0x0010 /**< loss due to color quantization */
|
||||
#define FF_LOSS_CHROMA 0x0020 /**< loss of chroma (e.g. RGB to gray conversion) */
|
||||
#define FF_LOSS_EXCESS_RESOLUTION 0x0040 /**< loss due to unneeded extra resolution */
|
||||
#define FF_LOSS_EXCESS_DEPTH 0x0080 /**< loss due to unneeded extra color depth */
|
||||
|
||||
|
||||
/**
|
||||
* Compute what kind of losses will occur when converting from one specific
|
||||
|
||||
@@ -32,6 +32,13 @@
|
||||
#define AVPALETTE_SIZE 1024
|
||||
#define AVPALETTE_COUNT 256
|
||||
|
||||
/**
|
||||
* Maximum number of planes in any pixel format.
|
||||
* This should be used when a maximum is needed, but code should not
|
||||
* be written to require a maximum for no good reason.
|
||||
*/
|
||||
#define AV_VIDEO_MAX_PLANES 4
|
||||
|
||||
/**
|
||||
* Pixel format.
|
||||
*
|
||||
@@ -83,7 +90,7 @@ enum AVPixelFormat {
|
||||
AV_PIX_FMT_BGR8, ///< packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
|
||||
AV_PIX_FMT_BGR4, ///< packed RGB 1:2:1 bitstream, 4bpp, (msb)1B 2G 1R(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits
|
||||
AV_PIX_FMT_BGR4_BYTE, ///< packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb)
|
||||
AV_PIX_FMT_RGB8, ///< packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
|
||||
AV_PIX_FMT_RGB8, ///< packed RGB 3:3:2, 8bpp, (msb)3R 3G 2B(lsb)
|
||||
AV_PIX_FMT_RGB4, ///< packed RGB 1:2:1 bitstream, 4bpp, (msb)1R 2G 1B(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits
|
||||
AV_PIX_FMT_RGB4_BYTE, ///< packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb)
|
||||
AV_PIX_FMT_NV12, ///< planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (first byte U and the following byte V)
|
||||
@@ -206,8 +213,36 @@ enum AVPixelFormat {
|
||||
AV_PIX_FMT_GBRAP16BE, ///< planar GBRA 4:4:4:4 64bpp, big-endian
|
||||
AV_PIX_FMT_GBRAP16LE, ///< planar GBRA 4:4:4:4 64bpp, little-endian
|
||||
/**
|
||||
* HW acceleration through QSV, data[3] contains a pointer to the
|
||||
* mfxFrameSurface1 structure.
|
||||
* HW acceleration through QSV, data[3] contains a pointer to the
|
||||
* mfxFrameSurface1 structure.
|
||||
*
|
||||
* Before FFmpeg 5.0:
|
||||
* mfxFrameSurface1.Data.MemId contains a pointer when importing
|
||||
* the following frames as QSV frames:
|
||||
*
|
||||
* VAAPI:
|
||||
* mfxFrameSurface1.Data.MemId contains a pointer to VASurfaceID
|
||||
*
|
||||
* DXVA2:
|
||||
* mfxFrameSurface1.Data.MemId contains a pointer to IDirect3DSurface9
|
||||
*
|
||||
* FFmpeg 5.0 and above:
|
||||
* mfxFrameSurface1.Data.MemId contains a pointer to the mfxHDLPair
|
||||
* structure when importing the following frames as QSV frames:
|
||||
*
|
||||
* VAAPI:
|
||||
* mfxHDLPair.first contains a VASurfaceID pointer.
|
||||
* mfxHDLPair.second is always MFX_INFINITE.
|
||||
*
|
||||
* DXVA2:
|
||||
* mfxHDLPair.first contains IDirect3DSurface9 pointer.
|
||||
* mfxHDLPair.second is always MFX_INFINITE.
|
||||
*
|
||||
* D3D11:
|
||||
* mfxHDLPair.first contains a ID3D11Texture2D pointer.
|
||||
* mfxHDLPair.second contains the texture array index of the frame if the
|
||||
* ID3D11Texture2D is an array texture, or always MFX_INFINITE if it is a
|
||||
* normal texture.
|
||||
*/
|
||||
AV_PIX_FMT_QSV,
|
||||
/**
|
||||
@@ -260,10 +295,6 @@ enum AVPixelFormat {
|
||||
AV_PIX_FMT_BAYER_GRBG16LE, ///< bayer, GRGR..(odd line), BGBG..(even line), 16-bit samples, little-endian
|
||||
AV_PIX_FMT_BAYER_GRBG16BE, ///< bayer, GRGR..(odd line), BGBG..(even line), 16-bit samples, big-endian
|
||||
|
||||
#if FF_API_XVMC
|
||||
AV_PIX_FMT_XVMC,///< XVideo Motion Acceleration via common packet passing
|
||||
#endif
|
||||
|
||||
AV_PIX_FMT_YUV440P10LE, ///< planar YUV 4:4:0,20bpp, (1 Cr & Cb sample per 1x2 Y samples), little-endian
|
||||
AV_PIX_FMT_YUV440P10BE, ///< planar YUV 4:4:0,20bpp, (1 Cr & Cb sample per 1x2 Y samples), big-endian
|
||||
AV_PIX_FMT_YUV440P12LE, ///< planar YUV 4:4:0,24bpp, (1 Cr & Cb sample per 1x2 Y samples), little-endian
|
||||
@@ -367,6 +398,47 @@ enum AVPixelFormat {
|
||||
AV_PIX_FMT_P416BE, ///< interleaved chroma YUV 4:4:4, 48bpp, big-endian
|
||||
AV_PIX_FMT_P416LE, ///< interleaved chroma YUV 4:4:4, 48bpp, little-endian
|
||||
|
||||
AV_PIX_FMT_VUYA, ///< packed VUYA 4:4:4, 32bpp, VUYAVUYA...
|
||||
|
||||
AV_PIX_FMT_RGBAF16BE, ///< IEEE-754 half precision packed RGBA 16:16:16:16, 64bpp, RGBARGBA..., big-endian
|
||||
AV_PIX_FMT_RGBAF16LE, ///< IEEE-754 half precision packed RGBA 16:16:16:16, 64bpp, RGBARGBA..., little-endian
|
||||
|
||||
AV_PIX_FMT_VUYX, ///< packed VUYX 4:4:4, 32bpp, Variant of VUYA where alpha channel is left undefined
|
||||
|
||||
AV_PIX_FMT_P012LE, ///< like NV12, with 12bpp per component, data in the high bits, zeros in the low bits, little-endian
|
||||
AV_PIX_FMT_P012BE, ///< like NV12, with 12bpp per component, data in the high bits, zeros in the low bits, big-endian
|
||||
|
||||
AV_PIX_FMT_Y212BE, ///< packed YUV 4:2:2 like YUYV422, 24bpp, data in the high bits, zeros in the low bits, big-endian
|
||||
AV_PIX_FMT_Y212LE, ///< packed YUV 4:2:2 like YUYV422, 24bpp, data in the high bits, zeros in the low bits, little-endian
|
||||
|
||||
AV_PIX_FMT_XV30BE, ///< packed XVYU 4:4:4, 32bpp, (msb)2X 10V 10Y 10U(lsb), big-endian, variant of Y410 where alpha channel is left undefined
|
||||
AV_PIX_FMT_XV30LE, ///< packed XVYU 4:4:4, 32bpp, (msb)2X 10V 10Y 10U(lsb), little-endian, variant of Y410 where alpha channel is left undefined
|
||||
|
||||
AV_PIX_FMT_XV36BE, ///< packed XVYU 4:4:4, 48bpp, data in the high bits, zeros in the low bits, big-endian, variant of Y412 where alpha channel is left undefined
|
||||
AV_PIX_FMT_XV36LE, ///< packed XVYU 4:4:4, 48bpp, data in the high bits, zeros in the low bits, little-endian, variant of Y412 where alpha channel is left undefined
|
||||
|
||||
AV_PIX_FMT_RGBF32BE, ///< IEEE-754 single precision packed RGB 32:32:32, 96bpp, RGBRGB..., big-endian
|
||||
AV_PIX_FMT_RGBF32LE, ///< IEEE-754 single precision packed RGB 32:32:32, 96bpp, RGBRGB..., little-endian
|
||||
|
||||
AV_PIX_FMT_RGBAF32BE, ///< IEEE-754 single precision packed RGBA 32:32:32:32, 128bpp, RGBARGBA..., big-endian
|
||||
AV_PIX_FMT_RGBAF32LE, ///< IEEE-754 single precision packed RGBA 32:32:32:32, 128bpp, RGBARGBA..., little-endian
|
||||
|
||||
AV_PIX_FMT_P212BE, ///< interleaved chroma YUV 4:2:2, 24bpp, data in the high bits, big-endian
|
||||
AV_PIX_FMT_P212LE, ///< interleaved chroma YUV 4:2:2, 24bpp, data in the high bits, little-endian
|
||||
|
||||
AV_PIX_FMT_P412BE, ///< interleaved chroma YUV 4:4:4, 36bpp, data in the high bits, big-endian
|
||||
AV_PIX_FMT_P412LE, ///< interleaved chroma YUV 4:4:4, 36bpp, data in the high bits, little-endian
|
||||
|
||||
AV_PIX_FMT_GBRAP14BE, ///< planar GBR 4:4:4:4 56bpp, big-endian
|
||||
AV_PIX_FMT_GBRAP14LE, ///< planar GBR 4:4:4:4 56bpp, little-endian
|
||||
|
||||
/**
|
||||
* Hardware surfaces for Direct3D 12.
|
||||
*
|
||||
* data[0] points to an AVD3D12VAFrame
|
||||
*/
|
||||
AV_PIX_FMT_D3D12,
|
||||
|
||||
AV_PIX_FMT_NB ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions
|
||||
};
|
||||
|
||||
@@ -425,6 +497,7 @@ enum AVPixelFormat {
|
||||
#define AV_PIX_FMT_GBRP16 AV_PIX_FMT_NE(GBRP16BE, GBRP16LE)
|
||||
#define AV_PIX_FMT_GBRAP10 AV_PIX_FMT_NE(GBRAP10BE, GBRAP10LE)
|
||||
#define AV_PIX_FMT_GBRAP12 AV_PIX_FMT_NE(GBRAP12BE, GBRAP12LE)
|
||||
#define AV_PIX_FMT_GBRAP14 AV_PIX_FMT_NE(GBRAP14BE, GBRAP14LE)
|
||||
#define AV_PIX_FMT_GBRAP16 AV_PIX_FMT_NE(GBRAP16BE, GBRAP16LE)
|
||||
|
||||
#define AV_PIX_FMT_BAYER_BGGR16 AV_PIX_FMT_NE(BAYER_BGGR16BE, BAYER_BGGR16LE)
|
||||
@@ -453,17 +526,28 @@ enum AVPixelFormat {
|
||||
#define AV_PIX_FMT_NV20 AV_PIX_FMT_NE(NV20BE, NV20LE)
|
||||
#define AV_PIX_FMT_AYUV64 AV_PIX_FMT_NE(AYUV64BE, AYUV64LE)
|
||||
#define AV_PIX_FMT_P010 AV_PIX_FMT_NE(P010BE, P010LE)
|
||||
#define AV_PIX_FMT_P012 AV_PIX_FMT_NE(P012BE, P012LE)
|
||||
#define AV_PIX_FMT_P016 AV_PIX_FMT_NE(P016BE, P016LE)
|
||||
|
||||
#define AV_PIX_FMT_Y210 AV_PIX_FMT_NE(Y210BE, Y210LE)
|
||||
#define AV_PIX_FMT_Y212 AV_PIX_FMT_NE(Y212BE, Y212LE)
|
||||
#define AV_PIX_FMT_XV30 AV_PIX_FMT_NE(XV30BE, XV30LE)
|
||||
#define AV_PIX_FMT_XV36 AV_PIX_FMT_NE(XV36BE, XV36LE)
|
||||
#define AV_PIX_FMT_X2RGB10 AV_PIX_FMT_NE(X2RGB10BE, X2RGB10LE)
|
||||
#define AV_PIX_FMT_X2BGR10 AV_PIX_FMT_NE(X2BGR10BE, X2BGR10LE)
|
||||
|
||||
#define AV_PIX_FMT_P210 AV_PIX_FMT_NE(P210BE, P210LE)
|
||||
#define AV_PIX_FMT_P410 AV_PIX_FMT_NE(P410BE, P410LE)
|
||||
#define AV_PIX_FMT_P212 AV_PIX_FMT_NE(P212BE, P212LE)
|
||||
#define AV_PIX_FMT_P412 AV_PIX_FMT_NE(P412BE, P412LE)
|
||||
#define AV_PIX_FMT_P216 AV_PIX_FMT_NE(P216BE, P216LE)
|
||||
#define AV_PIX_FMT_P416 AV_PIX_FMT_NE(P416BE, P416LE)
|
||||
|
||||
#define AV_PIX_FMT_RGBAF16 AV_PIX_FMT_NE(RGBAF16BE, RGBAF16LE)
|
||||
|
||||
#define AV_PIX_FMT_RGBF32 AV_PIX_FMT_NE(RGBF32BE, RGBF32LE)
|
||||
#define AV_PIX_FMT_RGBAF32 AV_PIX_FMT_NE(RGBAF32BE, RGBAF32LE)
|
||||
|
||||
/**
|
||||
* Chromaticity coordinates of the source primaries.
|
||||
* These values match the ones defined by ISO/IEC 23091-2_2019 subclause 8.1 and ITU-T H.273.
|
||||
@@ -539,6 +623,9 @@ enum AVColorSpace {
|
||||
AVCOL_SPC_CHROMA_DERIVED_NCL = 12, ///< Chromaticity-derived non-constant luminance system
|
||||
AVCOL_SPC_CHROMA_DERIVED_CL = 13, ///< Chromaticity-derived constant luminance system
|
||||
AVCOL_SPC_ICTCP = 14, ///< ITU-R BT.2100-0, ICtCp
|
||||
AVCOL_SPC_IPT_C2 = 15, ///< SMPTE ST 2128, IPT-C2
|
||||
AVCOL_SPC_YCGCO_RE = 16, ///< YCgCo-R, even addition of bits
|
||||
AVCOL_SPC_YCGCO_RO = 17, ///< YCgCo-R, odd addition of bits
|
||||
AVCOL_SPC_NB ///< Not part of ABI
|
||||
};
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#ifndef AVUTIL_RANDOM_SEED_H
|
||||
#define AVUTIL_RANDOM_SEED_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
/**
|
||||
* @addtogroup lavu_crypto
|
||||
@@ -36,6 +37,19 @@
|
||||
*/
|
||||
uint32_t av_get_random_seed(void);
|
||||
|
||||
/**
|
||||
* Generate cryptographically secure random data, i.e. suitable for use as
|
||||
* encryption keys and similar.
|
||||
*
|
||||
* @param buf buffer into which the random data will be written
|
||||
* @param len size of buf in bytes
|
||||
*
|
||||
* @retval 0 success, len bytes of random data was written
|
||||
* into buf
|
||||
* @retval "a negative AVERROR code" random data could not be generated
|
||||
*/
|
||||
int av_random_bytes(uint8_t *buf, size_t len);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user