Go to the documentation of this file.
41 if (left < 11 || codec_config->audio_roll_distance >= 0)
64 int object_type_id,
codec_id, stream_type;
75 if (object_type_id != 0x40)
79 if (((stream_type >> 2) != 5) || ((stream_type >> 1) & 1))
148 static const enum AVCodecID sample_fmt[2][3] = {
153 int sample_size = (
avio_r8(pb) / 8 - 2);
173 unsigned codec_config_id, nb_samples,
codec_id;
174 int16_t audio_roll_distance;
208 for (
int i = 0;
i <
c->nb_codec_configs;
i++)
209 if (
c->codec_configs[
i]->codec_config_id == codec_config_id) {
219 c->codec_configs =
tmp;
221 codec_config =
av_mallocz(
sizeof(*codec_config));
228 codec_config->
codec_id = avcodec_id;
257 c->codec_configs[
c->nb_codec_configs++] = codec_config;
389 int nb_layers, k = 0;
394 if (nb_layers > 6 || nb_layers == 0)
398 if (!audio_element->
layers)
402 for (
int i = 0, n = 0;
i < nb_layers;
i++) {
405 int loudspeaker_layout, output_gain_is_present_flag;
406 int substream_count, coupled_substream_count;
407 int expanded_loudspeaker_layout = -1;
414 loudspeaker_layout =
byte >> 4;
415 output_gain_is_present_flag = (
byte >> 3) & 1;
417 layer->
flags |= AV_IAMF_LAYER_FLAG_RECON_GAIN;
419 coupled_substream_count =
avio_r8(pb);
421 if (!substream_count || coupled_substream_count > substream_count ||
427 if (output_gain_is_present_flag) {
432 if (loudspeaker_layout == 15) {
434 av_log(
s,
AV_LOG_ERROR,
"expanded_loudspeaker_layout set with more than one layer in Audio Element #%d\n",
438 expanded_loudspeaker_layout =
avio_r8(pb);
440 if (expanded_loudspeaker_layout >= 0 && expanded_loudspeaker_layout < 13) {
442 }
else if (loudspeaker_layout < 10) {
455 .nb_channels = substream_count +
456 coupled_substream_count };
461 for (
int j = 0; j < substream_count; j++) {
477 for (
int j = 0; j < n; j++)
481 while (coupled_substream_count--) {
487 while (substream_count--) {
519 unsigned ambisonics_mode;
520 int output_channel_count, substream_count, order;
524 if (ambisonics_mode > 1)
527 output_channel_count =
avio_r8(pb);
529 if (audio_element->
nb_substreams != substream_count || output_channel_count == 0)
532 order =
floor(sqrt(output_channel_count - 1));
534 if ((order + 1) * (order + 1) != output_channel_count)
538 if (!audio_element->
layers)
549 if (ambisonics_mode == 0) {
550 for (
int i = 0;
i < substream_count;
i++) {
564 for (
int i = 0;
i < output_channel_count;
i++)
571 int coupled_substream_count =
avio_r8(pb);
572 int nb_demixing_matrix = substream_count + coupled_substream_count;
573 int demixing_matrix_size = nb_demixing_matrix * output_channel_count;
582 for (
int i = 0;
i < demixing_matrix_size;
i++)
585 for (
int i = 0;
i < substream_count;
i++) {
608 unsigned int parameter_id, parameter_rate,
mode;
609 unsigned int duration = 0, constant_subblock_duration = 0, nb_subblocks = 0;
610 unsigned int total_duration = 0;
615 for (
int i = 0;
i <
c->nb_param_definitions;
i++)
616 if (
c->param_definitions[
i]->param->parameter_id == parameter_id) {
629 if (constant_subblock_duration == 0)
632 nb_subblocks =
duration / constant_subblock_duration;
641 for (
int i = 0;
i < nb_subblocks;
i++) {
643 unsigned int subblock_duration = constant_subblock_duration;
645 if (constant_subblock_duration == 0) {
647 total_duration += subblock_duration;
648 }
else if (
i == nb_subblocks - 1)
649 subblock_duration =
duration -
i * constant_subblock_duration;
654 mix->subblock_duration = subblock_duration;
677 if (!
mode && !constant_subblock_duration && total_duration !=
duration) {
697 sizeof(*
c->param_definitions));
702 c->param_definitions =
tmp;
718 *out_param_definition = param;
731 unsigned audio_element_id, nb_substreams, codec_config_id, num_parameters;
732 int audio_element_type,
ret;
747 for (
int i = 0;
i <
c->nb_audio_elements;
i++)
748 if (
c->audio_elements[
i]->audio_element_id == audio_element_id) {
754 audio_element_type =
avio_r8(pbc) >> 5;
756 av_log(
s,
AV_LOG_DEBUG,
"Unknown audio_element_type referenced in an audio element. Ignoring\n");
765 av_log(
s,
AV_LOG_ERROR,
"Non existent codec config id %d referenced in an audio element\n", codec_config_id);
781 c->audio_elements =
tmp;
783 audio_element =
av_mallocz(
sizeof(*audio_element));
784 if (!audio_element) {
842 if (num_parameters > 2 && audio_element_type == 0) {
844 " for Channel representations\n", num_parameters);
848 if (num_parameters && audio_element_type != 0) {
850 " for Scene representations\n", num_parameters);
855 for (
int i = 0;
i < num_parameters;
i++) {
893 c->audio_elements[
c->nb_audio_elements++] = audio_element;
931 unsigned nb_submixes, mix_presentation_id;
947 for (
int i = 0;
i <
c->nb_mix_presentations;
i++)
948 if (
c->mix_presentations[
i]->mix_presentation_id == mix_presentation_id) {
959 c->mix_presentations =
tmp;
961 mix_presentation =
av_mallocz(
sizeof(*mix_presentation));
962 if (!mix_presentation) {
991 char *annotation =
NULL;
1002 for (
int i = 0;
i < nb_submixes;
i++) {
1004 unsigned nb_elements, nb_layouts;
1013 for (
int j = 0; j < nb_elements; j++) {
1016 unsigned int rendering_config_extension_size;
1019 if (!submix_element) {
1026 for (
int k = 0; k <
c->nb_audio_elements; k++)
1027 if (
c->audio_elements[k]->audio_element_id == submix_element->
audio_element_id) {
1028 audio_element =
c->audio_elements[k];
1032 if (!audio_element) {
1033 av_log(
s,
AV_LOG_ERROR,
"Invalid Audio Element with id %u referenced by Mix Parameters %u\n",
1039 for (
int k = 0; k < mix_presentation->
count_label; k++) {
1040 char *annotation =
NULL;
1053 avio_skip(pbc, rendering_config_extension_size);
1069 for (
int j = 0; j < nb_layouts; j++) {
1075 if (!submix_layout) {
1090 sound_system = (
byte >> 2) & 0xF;
1105 if (info_type & 2) {
1106 unsigned int num_anchored_loudness =
avio_r8(pbc);
1108 for (
int k = 0; k < num_anchored_loudness; k++) {
1109 unsigned int anchor_element =
avio_r8(pbc);
1120 if (info_type & 0xFC) {
1127 c->mix_presentations[
c->nb_mix_presentations++] = mix_presentation;
1143 unsigned *skip_samples,
unsigned *discard_padding)
1146 int ret, extension_flag, trimming, start;
1147 unsigned skip = 0, discard = 0;
1160 if (*obu_size > INT_MAX)
1171 *skip_samples =
skip;
1172 if (discard_padding)
1173 *discard_padding = discard;
1175 if (extension_flag) {
1176 unsigned int extension_bytes;
1177 extension_bytes =
get_leb(&gb);
1178 if (extension_bytes > INT_MAX / 8)
1186 size = *obu_size + start;
1191 *start_pos =
size - *obu_size;
1197 int max_size,
void *log_ctx)
1215 if (len < 0 || obu_size > max_size) {
1248 max_size -= obu_size + start_pos;
static int update_extradata(AVCodecParameters *codecpar)
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
@ AV_IAMF_SUBMIX_LAYOUT_TYPE_LOUDSPEAKERS
The layout follows the loudspeaker sound system convention of ITU-2051-3.
#define AV_LOG_WARNING
Something somehow does not look correct.
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
#define MP4DecConfigDescrTag
void ffio_init_context(FFIOContext *s, unsigned char *buffer, int buffer_size, int write_flag, void *opaque, int(*read_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))
static int mix(int c0, int c1)
static int get_bits_left(GetBitContext *gb)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
#define AV_CH_TOP_SIDE_LEFT
enum AVMediaType codec_type
General type of the encoded data.
#define AV_CHANNEL_LAYOUT_STEREO
static int put_bytes_output(const PutBitContext *s)
const AVCodecTag ff_mp4_obj_type[]
This struct describes the properties of an encoded stream.
unsigned int default_w
Default weight value as defined in section 3.6 of IAMF.
unsigned int nb_substreams
AVIAMFParamDefinition * av_iamf_param_definition_alloc(enum AVIAMFParamDefinitionType type, unsigned int nb_subblocks, size_t *out_size)
Allocates memory for AVIAMFParamDefinition, plus an array of.
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
static int get_bits_count(const GetBitContext *s)
AVChannelCustom * map
This member must be used when the channel order is AV_CHANNEL_ORDER_CUSTOM.
#define AV_CH_TOP_FRONT_RIGHT
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
enum AVChannel av_channel_layout_channel_from_index(const AVChannelLayout *channel_layout, unsigned int idx)
Get the channel with the given index in a channel layout.
int seek_preroll
Audio only.
int error
contains the error code or 0 if no error happened
enum AVIAMFSubmixLayoutType layout_type
#define AV_CH_TOP_FRONT_LEFT
static av_unused void put_bits32(PutBitContext *s, uint32_t value)
Write exactly 32 bits into a bitstream.
Parameters as defined in section 3.6.1 of IAMF.
AVRational default_mix_gain
Default mix gain value to apply when there are no AVIAMFParamDefinition with element_mix_config's par...
enum AVChannelOrder order
Channel order used in this layout.
uint64_t mask
This member must be used for AV_CHANNEL_ORDER_NATIVE, and may be used for AV_CHANNEL_ORDER_AMBISONIC ...
static int ambisonics_config(void *s, AVIOContext *pb, IAMFAudioElement *audio_element, const IAMFCodecConfig *codec_config)
int nb_channels
Number of channels in this layout.
static int flac_decoder_config(IAMFCodecConfig *codec_config, AVIOContext *pb, int len)
const AVIAMFMixPresentation * cmix
#define AV_CH_TOP_BACK_LEFT
AVRational digital_peak
The digital (sampled) peak value of the audio signal, as defined in ITU-1770-4.
static void skip_bits(GetBitContext *s, int n)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
AVRational integrated_loudness
The program integrated loudness information, as defined in ITU-1770-4.
AVIAMFSubmix * av_iamf_mix_presentation_add_submix(AVIAMFMixPresentation *mix_presentation)
Allocate a submix and add it to a given AVIAMFMixPresentation.
#define MP4DecSpecificDescrTag
@ AOT_ESCAPE
Y Escape Value.
Submix layout as defined in section 3.7.6 of IAMF.
static int put_bits_left(PutBitContext *s)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
AVIAMFAudioElement * av_iamf_audio_element_alloc(void)
Allocates a AVIAMFAudioElement, and initializes its fields with default values.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
enum AVIAMFAudioElementType audio_element_type
Audio element type as defined in section 3.6 of IAMF.
static int opus_decoder_config(IAMFCodecConfig *codec_config, AVIOContext *pb, int len)
Recon Gain Info Parameter Data as defined in section 3.8.3 of IAMF.
#define AV_CH_LAYOUT_STEREO
static int param_parse(void *s, IAMFContext *c, AVIOContext *pb, unsigned int type, const IAMFAudioElement *audio_element, AVIAMFParamDefinition **out_param_definition)
static int codec_config_obu(void *s, IAMFContext *c, AVIOContext *pb, int len)
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
AVIAMFAudioElement * element
element backs celement iff the AVIAMFAudioElement is owned by this structure.
@ AV_IAMF_PARAMETER_DEFINITION_RECON_GAIN
Subblocks are of struct type AVIAMFReconGain.
AVDictionary * annotations
A dictionary of strings describing the submix in different languages.
unsigned int avio_rb32(AVIOContext *s)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_ARRAY_ELEMS(a)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
#define AV_CH_LOW_FREQUENCY
int frame_size
Audio only.
AVIAMFSubmixLayout * av_iamf_submix_add_layout(AVIAMFSubmix *submix)
Allocate a submix layout and add it to a given AVIAMFSubmix.
int avpriv_mpeg4audio_get_config2(MPEG4AudioConfig *c, const uint8_t *buf, int size, int sync_extension, void *logctx)
Parse MPEG-4 systems extradata from a raw buffer to retrieve audio configuration.
unsigned int audio_substream_id
unsigned int substream_count
AVRational dialogue_anchored_loudness
The Dialogue loudness information, as defined in ITU-1770-4.
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
static __device__ float floor(float a)
static av_always_inline void * av_iamf_param_definition_get_subblock(const AVIAMFParamDefinition *par, unsigned int idx)
Get the subblock at the specified.
@ AV_CHANNEL_ORDER_UNSPEC
Only the channel count is specified, without any further information about the channel order.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
enum AVIAMFHeadphonesMode headphones_rendering_mode
A value that indicates whether the referenced channel-based Audio Element shall be rendered to stereo...
unsigned int ffio_read_leb(AVIOContext *s)
Read a unsigned integer coded as a variable number of up to eight little-endian bytes,...
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_CH_TOP_SIDE_RIGHT
static void put_bits63(PutBitContext *s, int n, uint64_t value)
Write up to 63 bits into a bitstream.
AVChannelLayout ch_layout
int ff_iamfdec_read_descriptors(IAMFContext *c, AVIOContext *pb, int max_size, void *log_ctx)
unsigned int audio_element_id
Demixing Info Parameter Data as defined in section 3.8.2 of IAMF.
@ AV_CHANNEL_ORDER_AMBISONIC
The audio is represented as the decomposition of the sound field into spherical harmonics.
static unsigned get_leb(GetBitContext *s)
Read a unsigned integer coded as a variable number of up to eight little-endian bytes,...
Rational number (pair of numerator and denominator).
unsigned int duration
The accumulated duration of all blocks in this parameter definition, in units of 1 / parameter_rate.
static unsigned int get_bits1(GetBitContext *s)
static int audio_element_obu(void *s, IAMFContext *c, AVIOContext *pb, int len)
A layer defining a Channel Layout in the Audio Element.
#define FLAC_STREAMINFO_SIZE
#define AV_DICT_DONT_OVERWRITE
Don't overwrite existing entries.
#define AV_CH_FRONT_CENTER
AVChannelLayout ch_layout
Audio only.
const AVIAMFAudioElement * celement
#define AV_CH_FRONT_LEFT_OF_CENTER
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
int ff_mp4_read_descr(void *logctx, AVIOContext *pb, int *tag)
int sample_rate
Audio only.
@ AV_CHAN_FRONT_RIGHT_OF_CENTER
int ff_iamf_parse_obu_header(const uint8_t *buf, int buf_size, unsigned *obu_size, int *start_pos, enum IAMF_OBU_Type *type, unsigned *skip_samples, unsigned *discard_padding)
unsigned int output_gain_flags
Output gain channel flags as defined in section 3.6.2 of IAMF.
AVCodecID
Identify the syntax and semantics of the bitstream.
unsigned int audio_element_id
The id of the Audio Element this submix element references.
int extradata_size
Size of the extradata content in bytes.
Submix layout as defined in section 3.7 of IAMF.
union AVChannelLayout::@491 u
Details about which channels are present in this layout.
unsigned int subblock_duration
Duration for the given subblock, in units of 1 / parameter_rate.
unsigned int subblock_duration
Duration for the given subblock, in units of 1 / parameter_rate.
An AVChannelLayout holds information about the channel layout of audio data.
int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen)
Read a string from pb into buf.
static AVRational av_make_q(int num, int den)
Create an AVRational.
unsigned int coupled_substream_count
#define MKBETAG(a, b, c, d)
AVIAMFMixPresentation * av_iamf_mix_presentation_alloc(void)
Allocates a AVIAMFMixPresentation, and initializes its fields with default values.
static const uint8_t header[24]
int avio_r8(AVIOContext *s)
IAMFSubStream * substreams
unsigned int constant_subblock_duration
The duration of every subblock in the case where all subblocks, with the optional exception of the la...
AVIAMFSubmixElement * av_iamf_submix_add_element(AVIAMFSubmix *submix)
Allocate a submix element and add it to a given AVIAMFSubmix.
int av_channel_layout_retype(AVChannelLayout *channel_layout, enum AVChannelOrder order, int flags)
Change the AVChannelOrder of a channel layout.
Information on how to combine one or more audio streams, as defined in section 3.6 of IAMF.
static int ipcm_decoder_config(IAMFCodecConfig *codec_config, AVIOContext *pb, int len)
int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
Ensures that the requested seekback buffer size will be available.
@ AV_CHAN_TOP_FRONT_RIGHT
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
#define AV_CH_TOP_BACK_RIGHT
@ AV_CHANNEL_ORDER_NATIVE
The native channel order, i.e.
Mix Gain Parameter Data as defined in section 3.8.1 of IAMF.
#define AV_CH_FRONT_RIGHT_OF_CENTER
@ AV_CHAN_FRONT_LEFT_OF_CENTER
int av_channel_layout_custom_init(AVChannelLayout *channel_layout, int nb_channels)
Initialize a custom channel layout with the specified number of channels.
AVCodecParameters * avcodec_parameters_alloc(void)
Allocate a new AVCodecParameters and set its fields to default values (unknown/invalid/0).
static uint64_t get_bits64(GetBitContext *s, int n)
Read 0-64 bits.
#define i(width, name, range_min, range_max)
unsigned int parameter_id
Identifier for the parameter substream.
AVRational * demixing_matrix
Demixing matrix as defined in section 3.6.3 of IAMF.
#define av_malloc_array(a, b)
Information on how to render and mix one or more AVIAMFAudioElement to generate the final audio outpu...
static int aac_decoder_config(IAMFCodecConfig *codec_config, AVIOContext *pb, int len, void *logctx)
static int param_definition(const IAMFContext *iamf, const IAMFParamDefinition *param_def, AVIOContext *dyn_bc, void *log_ctx)
void * av_calloc(size_t nmemb, size_t size)
static int parse_coupled_substream(AVChannelLayout *out, AVChannelLayout *in, int n)
unsigned int nb_subblocks
Number of subblocks in the array.
@ AV_IAMF_AUDIO_ELEMENT_TYPE_SCENE
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
void * av_malloc(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
unsigned int avio_rb16(AVIOContext *s)
#define AV_INPUT_BUFFER_PADDING_SIZE
Tag MUST be and< 10hcoeff half pel interpolation filter coefficients, hcoeff[0] are the 2 middle coefficients[1] are the next outer ones and so on, resulting in a filter like:...eff[2], hcoeff[1], hcoeff[0], hcoeff[0], hcoeff[1], hcoeff[2] ... the sign of the coefficients is not explicitly stored but alternates after each coeff and coeff[0] is positive, so ...,+,-,+,-,+,+,-,+,-,+,... hcoeff[0] is not explicitly stored but found by subtracting the sum of all stored coefficients with signs from 32 hcoeff[0]=32 - hcoeff[1] - hcoeff[2] - ... a good choice for hcoeff and htaps is htaps=6 hcoeff={40,-10, 2} an alternative which requires more computations at both encoder and decoder side and may or may not be better is htaps=8 hcoeff={42,-14, 6,-2}ref_frames minimum of the number of available reference frames and max_ref_frames for example the first frame after a key frame always has ref_frames=1spatial_decomposition_type wavelet type 0 is a 9/7 symmetric compact integer wavelet 1 is a 5/3 symmetric compact integer wavelet others are reserved stored as delta from last, last is reset to 0 if always_reset||keyframeqlog quality(logarithmic quantizer scale) stored as delta from last, last is reset to 0 if always_reset||keyframemv_scale stored as delta from last, last is reset to 0 if always_reset||keyframe FIXME check that everything works fine if this changes between framesqbias dequantization bias stored as delta from last, last is reset to 0 if always_reset||keyframeblock_max_depth maximum depth of the block tree stored as delta from last, last is reset to 0 if always_reset||keyframequant_table quantization tableHighlevel bitstream structure:==============================--------------------------------------------|Header|--------------------------------------------|------------------------------------|||Block0||||split?||||yes no||||......... intra?||||:Block01 :yes no||||:Block02 :....... ..........||||:Block03 ::y DC ::ref index:||||:Block04 ::cb DC ::motion x :||||......... :cr DC ::motion y :||||....... ..........|||------------------------------------||------------------------------------|||Block1|||...|--------------------------------------------|------------ ------------ ------------|||Y subbands||Cb subbands||Cr subbands||||--- ---||--- ---||--- ---|||||LL0||HL0||||LL0||HL0||||LL0||HL0|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||LH0||HH0||||LH0||HH0||||LH0||HH0|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||HL1||LH1||||HL1||LH1||||HL1||LH1|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||HH1||HL2||||HH1||HL2||||HH1||HL2|||||...||...||...|||------------ ------------ ------------|--------------------------------------------Decoding process:=================------------|||Subbands|------------||||------------|Intra DC||||LL0 subband prediction ------------|\ Dequantization ------------------- \||Reference frames|\ IDWT|------- -------|Motion \|||Frame 0||Frame 1||Compensation . OBMC v -------|------- -------|--------------. \------> Frame n output Frame Frame<----------------------------------/|...|------------------- Range Coder:============Binary Range Coder:------------------- The implemented range coder is an adapted version based upon "Range encoding: an algorithm for removing redundancy from a digitised message." by G. N. N. Martin. The symbols encoded by the Snow range coder are bits(0|1). The associated probabilities are not fix but change depending on the symbol mix seen so far. bit seen|new state ---------+----------------------------------------------- 0|256 - state_transition_table[256 - old_state];1|state_transition_table[old_state];state_transition_table={ 0, 0, 0, 0, 0, 0, 0, 0, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 190, 191, 192, 194, 194, 195, 196, 197, 198, 199, 200, 201, 202, 202, 204, 205, 206, 207, 208, 209, 209, 210, 211, 212, 213, 215, 215, 216, 217, 218, 219, 220, 220, 222, 223, 224, 225, 226, 227, 227, 229, 229, 230, 231, 232, 234, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 248, 0, 0, 0, 0, 0, 0, 0};FIXME Range Coding of integers:------------------------- FIXME Neighboring Blocks:===================left and top are set to the respective blocks unless they are outside of the image in which case they are set to the Null block top-left is set to the top left block unless it is outside of the image in which case it is set to the left block if this block has no larger parent block or it is at the left side of its parent block and the top right block is not outside of the image then the top right block is used for top-right else the top-left block is used Null block y, cb, cr are 128 level, ref, mx and my are 0 Motion Vector Prediction:=========================1. the motion vectors of all the neighboring blocks are scaled to compensate for the difference of reference frames scaled_mv=(mv *(256 *(current_reference+1)/(mv.reference+1))+128)> the median of the scaled left
static int label_string(AVIOContext *pb, char **label)
AVRational default_mix_gain
Default mix gain value to apply when there are no AVIAMFParamDefinition with output_mix_config's para...
AVRational album_anchored_loudness
The Album loudness information, as defined in ITU-1770-4.
uint64_t av_channel_layout_subset(const AVChannelLayout *channel_layout, uint64_t mask)
Find out what channels from a given set are present in a channel layout, without regard for their pos...
AVRational true_peak
The true peak of the audio signal, as defined in ITU-1770-4.
AVChannelLayout sound_system
Channel layout matching one of Sound Systems A to J of ITU-2051-3, plus 7.1.2ch, 3....
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
static av_const int sign_extend(int val, unsigned bits)
int eof_reached
true if was unable to read due to error or eof
@ AV_IAMF_PARAMETER_DEFINITION_MIX_GAIN
Subblocks are of struct type AVIAMFMixGain.
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
static int mix_presentation_obu(void *s, IAMFContext *c, AVIOContext *pb, int len)
AVIAMFLayer * av_iamf_audio_element_add_layer(AVIAMFAudioElement *audio_element)
Allocate a layer and add it to a given AVIAMFAudioElement.
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
char * av_strdup(const char *s)
Duplicate a string.
AVIAMFParamDefinition * demixing_info
Demixing information used to reconstruct a scalable channel audio representation.
unsigned int dmixp_mode
Pre-defined combination of demixing parameters.
AVIAMFParamDefinition * output_mix_config
Information required for post-processing the mixed audio signal to generate the audio signal for play...
enum AVIAMFAmbisonicsMode ambisonics_mode
Ambisonics mode as defined in section 3.6.3 of IAMF.
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
#define AV_CHANNEL_LAYOUT_BINAURAL
#define AV_CHANNEL_LAYOUT_MONO
@ AV_IAMF_SUBMIX_LAYOUT_TYPE_BINAURAL
The layout is binaural.
unsigned int flags
A bitmask which may contain a combination of AV_IAMF_LAYER_FLAG_* flags.
AVRational output_gain
Output gain as defined in section 3.6.2 of IAMF.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
AVIAMFParamDefinition * element_mix_config
Information required required for applying any processing to the referenced and rendered Audio Elemen...
@ AV_CHAN_AMBISONIC_BASE
Range of channels between AV_CHAN_AMBISONIC_BASE and AV_CHAN_AMBISONIC_END represent Ambisonic compon...
unsigned int parameter_rate
Sample rate for the parameter substream.
Submix element as defined in section 3.7 of IAMF.
@ AV_IAMF_AUDIO_ELEMENT_TYPE_CHANNEL
unsigned int codec_config_id
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int ffio_read_size(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
AVIAMFParamDefinition * recon_gain_info
Recon gain information used to reconstruct a scalable channel audio representation.
AVIAMFMixPresentation * mix
mix backs cmix iff the AVIAMFMixPresentation is owned by this structure.
static int scalable_channel_layout_config(void *s, AVIOContext *pb, IAMFAudioElement *audio_element, const IAMFCodecConfig *codec_config)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_RB24
AVCodecParameters * codecpar
unsigned int mix_presentation_id
static void BS_FUNC() skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
@ AV_IAMF_PARAMETER_DEFINITION_DEMIXING
Subblocks are of struct type AVIAMFDemixingInfo.