mirror of
https://github.com/shadps4-emu/ext-ffmpeg-core.git
synced 2026-01-31 00:55:17 +01:00
updated headers
This commit is contained in:
52
include/libavcodec/a64colors.h
Normal file
52
include/libavcodec/a64colors.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* a64 video encoder - c64 colors in rgb (Pepto)
|
||||
* Copyright (c) 2009 Tobias Bindhammer
|
||||
*
|
||||
* 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
|
||||
* a64 video encoder - c64 colors in rgb
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_A64COLORS_H
|
||||
#define AVCODEC_A64COLORS_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* c64 palette in RGB */
|
||||
static const uint8_t a64_palette[16][3] = {
|
||||
{0x00, 0x00, 0x00},
|
||||
{0xff, 0xff, 0xff},
|
||||
{0x68, 0x37, 0x2b},
|
||||
{0x70, 0xa4, 0xb2},
|
||||
{0x6f, 0x3d, 0x86},
|
||||
{0x58, 0x8d, 0x43},
|
||||
{0x35, 0x28, 0x79},
|
||||
{0xb8, 0xc7, 0x6f},
|
||||
{0x6f, 0x4f, 0x25},
|
||||
{0x43, 0x39, 0x00},
|
||||
{0x9a, 0x67, 0x59},
|
||||
{0x44, 0x44, 0x44},
|
||||
{0x6c, 0x6c, 0x6c},
|
||||
{0x9a, 0xd2, 0x84},
|
||||
{0x6c, 0x5e, 0xb5},
|
||||
{0x95, 0x95, 0x95},
|
||||
};
|
||||
|
||||
#endif /* AVCODEC_A64COLORS_H */
|
||||
150
include/libavcodec/a64tables.h
Normal file
150
include/libavcodec/a64tables.h
Normal file
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* a64 video encoder - tables used by a64 encoders
|
||||
* Copyright (c) 2009 Tobias Bindhammer
|
||||
*
|
||||
* 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
|
||||
* a64 video encoder - tables used by a64 encoders
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_A64TABLES_H
|
||||
#define AVCODEC_A64TABLES_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* dither patterns used vor rendering the multicolor charset
|
||||
*/
|
||||
|
||||
static const uint8_t multi_dither_patterns[9][4][4] = {
|
||||
{
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0}
|
||||
},
|
||||
{
|
||||
{1, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 1, 0},
|
||||
{0, 0, 0, 0}
|
||||
},
|
||||
{
|
||||
{1, 0, 0, 0},
|
||||
{0, 0, 1, 0},
|
||||
{0, 1, 0, 0},
|
||||
{0, 0, 0, 1}
|
||||
},
|
||||
{
|
||||
{1, 0, 0, 0},
|
||||
{0, 1, 0, 1},
|
||||
{0, 0, 1, 0},
|
||||
{0, 1, 0, 1}
|
||||
},
|
||||
{
|
||||
{1, 0, 1, 0},
|
||||
{0, 1, 0, 1},
|
||||
{1, 0, 1, 0},
|
||||
{0, 1, 0, 1}
|
||||
},
|
||||
{
|
||||
{1, 1, 1, 0},
|
||||
{0, 1, 0, 1},
|
||||
{1, 0, 1, 1},
|
||||
{0, 1, 0, 1}
|
||||
},
|
||||
{
|
||||
{0, 1, 1, 1},
|
||||
{1, 1, 0, 1},
|
||||
{1, 0, 1, 1},
|
||||
{1, 1, 1, 0}
|
||||
},
|
||||
{
|
||||
{0, 1, 1, 1},
|
||||
{1, 1, 1, 1},
|
||||
{1, 1, 0, 1},
|
||||
{1, 1, 1, 1}
|
||||
},
|
||||
{
|
||||
{1, 1, 1, 1},
|
||||
{1, 1, 1, 1},
|
||||
{1, 1, 1, 1},
|
||||
{1, 1, 1, 1}
|
||||
},
|
||||
};
|
||||
|
||||
static const uint8_t interlaced_dither_patterns[9][8][4] = {
|
||||
{
|
||||
{0, 0, 0, 0}, {0, 0, 0, 0},
|
||||
{0, 0, 0, 0}, {0, 0, 0, 0},
|
||||
{0, 0, 0, 0}, {0, 0, 0, 0},
|
||||
{0, 0, 0, 0}, {0, 0, 0, 0},
|
||||
},
|
||||
{
|
||||
{1, 0, 1, 0}, {0, 0, 0, 0},
|
||||
{0, 0, 0, 0}, {0, 0, 0, 0},
|
||||
{1, 0, 1, 0}, {0, 0, 0, 0},
|
||||
{0, 0, 0, 0}, {0, 0, 0, 0},
|
||||
},
|
||||
{
|
||||
{1, 0, 1, 0}, {0, 0, 0, 0},
|
||||
{0, 0, 0, 0}, {0, 1, 0, 1},
|
||||
{1, 0, 1, 0}, {0, 0, 0, 0},
|
||||
{0, 0, 0, 0}, {0, 1, 0, 1},
|
||||
},
|
||||
{
|
||||
{1, 0, 1, 0}, {0, 1, 0, 1},
|
||||
{0, 1, 0, 1}, {0, 0, 0, 0},
|
||||
{1, 0, 1, 0}, {0, 1, 0, 1},
|
||||
{0, 1, 0, 1}, {0, 0, 0, 0},
|
||||
},
|
||||
{
|
||||
{1, 0, 1, 0}, {0, 1, 0, 1},
|
||||
{0, 1, 0, 1}, {1, 0, 1, 0},
|
||||
{1, 0, 1, 0}, {0, 1, 0, 1},
|
||||
{0, 1, 0, 1}, {1, 0, 1, 0},
|
||||
},
|
||||
{
|
||||
{1, 0, 1, 0}, {0, 1, 0, 1},
|
||||
{1, 1, 1, 1}, {1, 0, 1, 0},
|
||||
{1, 0, 1, 0}, {0, 1, 0, 1},
|
||||
{1, 1, 1, 1}, {1, 0, 1, 0},
|
||||
},
|
||||
{
|
||||
{1, 0, 1, 0}, {1, 1, 1, 1},
|
||||
{1, 1, 1, 1}, {0, 1, 0, 1},
|
||||
{1, 0, 1, 0}, {1, 1, 1, 1},
|
||||
{1, 1, 1, 1}, {0, 1, 0, 1},
|
||||
},
|
||||
{
|
||||
{1, 1, 1, 1}, {1, 1, 1, 1},
|
||||
{1, 1, 1, 1}, {0, 1, 0, 1},
|
||||
{1, 1, 1, 1}, {1, 1, 1, 1},
|
||||
{1, 1, 1, 1}, {0, 1, 0, 1},
|
||||
},
|
||||
{
|
||||
{1, 1, 1, 1}, {1, 1, 1, 1},
|
||||
{1, 1, 1, 1}, {1, 1, 1, 1},
|
||||
{1, 1, 1, 1}, {1, 1, 1, 1},
|
||||
{1, 1, 1, 1}, {1, 1, 1, 1},
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* AVCODEC_A64TABLES_H */
|
||||
122
include/libavcodec/aac.h
Normal file
122
include/libavcodec/aac.h
Normal file
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* AAC definitions and structures
|
||||
* Copyright (c) 2005-2006 Oded Shimon ( ods15 ods15 dyndns org )
|
||||
* Copyright (c) 2006-2007 Maxim Gavrilov ( maxim.gavrilov 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
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* AAC definitions and structures
|
||||
* @author Oded Shimon ( ods15 ods15 dyndns org )
|
||||
* @author Maxim Gavrilov ( maxim.gavrilov gmail com )
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_AAC_H
|
||||
#define AVCODEC_AAC_H
|
||||
|
||||
#define MAX_CHANNELS 64
|
||||
#define MAX_ELEM_ID 64
|
||||
|
||||
#define TNS_MAX_ORDER 20
|
||||
#define MAX_LTP_LONG_SFB 40
|
||||
|
||||
enum RawDataBlockType {
|
||||
TYPE_SCE,
|
||||
TYPE_CPE,
|
||||
TYPE_CCE,
|
||||
TYPE_LFE,
|
||||
TYPE_DSE,
|
||||
TYPE_PCE,
|
||||
TYPE_FIL,
|
||||
TYPE_END,
|
||||
};
|
||||
|
||||
enum ExtensionPayloadID {
|
||||
EXT_FILL,
|
||||
EXT_FILL_DATA,
|
||||
EXT_DATA_ELEMENT,
|
||||
EXT_DYNAMIC_RANGE = 0xb,
|
||||
EXT_SBR_DATA = 0xd,
|
||||
EXT_SBR_DATA_CRC = 0xe,
|
||||
};
|
||||
|
||||
enum WindowSequence {
|
||||
ONLY_LONG_SEQUENCE,
|
||||
LONG_START_SEQUENCE,
|
||||
EIGHT_SHORT_SEQUENCE,
|
||||
LONG_STOP_SEQUENCE,
|
||||
};
|
||||
|
||||
enum BandType {
|
||||
ZERO_BT = 0, ///< Scalefactors and spectral data are all zero.
|
||||
FIRST_PAIR_BT = 5, ///< This and later band types encode two values (rather than four) with one code word.
|
||||
ESC_BT = 11, ///< Spectral data are coded with an escape sequence.
|
||||
RESERVED_BT = 12, ///< Band types following are encoded differently from others.
|
||||
NOISE_BT = 13, ///< Spectral data are scaled white noise not coded in the bitstream.
|
||||
INTENSITY_BT2 = 14, ///< Scalefactor data are intensity stereo positions (out of phase).
|
||||
INTENSITY_BT = 15, ///< Scalefactor data are intensity stereo positions (in phase).
|
||||
};
|
||||
|
||||
enum ChannelPosition {
|
||||
AAC_CHANNEL_OFF = 0,
|
||||
AAC_CHANNEL_FRONT = 1,
|
||||
AAC_CHANNEL_SIDE = 2,
|
||||
AAC_CHANNEL_BACK = 3,
|
||||
AAC_CHANNEL_LFE = 4,
|
||||
AAC_CHANNEL_CC = 5,
|
||||
};
|
||||
|
||||
#define MAX_PREDICTORS 672
|
||||
|
||||
#define SCALE_DIV_512 36 ///< scalefactor difference that corresponds to scale difference in 512 times
|
||||
#define SCALE_ONE_POS 140 ///< scalefactor index that corresponds to scale=1.0
|
||||
#define SCALE_MAX_POS 255 ///< scalefactor index maximum value
|
||||
#define SCALE_MAX_DIFF 60 ///< maximum scalefactor difference allowed by standard
|
||||
#define SCALE_DIFF_ZERO 60 ///< codebook index corresponding to zero scalefactor indices difference
|
||||
|
||||
#define POW_SF2_ZERO 200 ///< ff_aac_pow2sf_tab index corresponding to pow(2, 0);
|
||||
|
||||
#define NOISE_PRE 256 ///< preamble for NOISE_BT, put in bitstream with the first noise band
|
||||
#define NOISE_PRE_BITS 9 ///< length of preamble
|
||||
#define NOISE_OFFSET 90 ///< subtracted from global gain, used as offset for the preamble
|
||||
|
||||
typedef struct Pulse {
|
||||
int num_pulse;
|
||||
int start;
|
||||
int pos[4];
|
||||
int amp[4];
|
||||
} Pulse;
|
||||
|
||||
static inline int ff_aac_sample_rate_idx(int rate)
|
||||
{
|
||||
if (92017 <= rate) return 0;
|
||||
else if (75132 <= rate) return 1;
|
||||
else if (55426 <= rate) return 2;
|
||||
else if (46009 <= rate) return 3;
|
||||
else if (37566 <= rate) return 4;
|
||||
else if (27713 <= rate) return 5;
|
||||
else if (23004 <= rate) return 6;
|
||||
else if (18783 <= rate) return 7;
|
||||
else if (13856 <= rate) return 8;
|
||||
else if (11502 <= rate) return 9;
|
||||
else if (9391 <= rate) return 10;
|
||||
else return 11;
|
||||
}
|
||||
|
||||
#endif /* AVCODEC_AAC_H */
|
||||
49
include/libavcodec/aac_ac3_parser.h
Normal file
49
include/libavcodec/aac_ac3_parser.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Common AAC and AC-3 parser prototypes
|
||||
* Copyright (c) 2003 Fabrice Bellard
|
||||
* Copyright (c) 2003 Michael Niedermayer
|
||||
*
|
||||
* 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_AAC_AC3_PARSER_H
|
||||
#define AVCODEC_AAC_AC3_PARSER_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "libavutil/crc.h"
|
||||
#include "avcodec.h"
|
||||
#include "parser.h"
|
||||
|
||||
typedef struct AACAC3ParseContext {
|
||||
ParseContext pc;
|
||||
int header_size;
|
||||
int (*sync)(uint64_t state, int *need_next_header, int *new_frame_start);
|
||||
|
||||
const AVCRC *crc_ctx;
|
||||
int remaining_size;
|
||||
uint64_t state;
|
||||
|
||||
int need_next_header;
|
||||
int frame_number;
|
||||
} AACAC3ParseContext;
|
||||
|
||||
int ff_aac_ac3_parse(AVCodecParserContext *s1,
|
||||
AVCodecContext *avctx,
|
||||
const uint8_t **poutbuf, int *poutbuf_size,
|
||||
const uint8_t *buf, int buf_size);
|
||||
|
||||
#endif /* AVCODEC_AAC_AC3_PARSER_H */
|
||||
143
include/libavcodec/aac_defines.h
Normal file
143
include/libavcodec/aac_defines.h
Normal file
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* AAC 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 AVCODEC_AAC_DEFINES_H
|
||||
#define AVCODEC_AAC_DEFINES_H
|
||||
|
||||
#ifndef USE_FIXED
|
||||
#define USE_FIXED 0
|
||||
#endif
|
||||
|
||||
#if USE_FIXED
|
||||
|
||||
#include "libavutil/softfloat.h"
|
||||
|
||||
#define AAC_RENAME(x) x ## _fixed
|
||||
#define AAC_RENAME2(x) x ## _fixed
|
||||
typedef int INTFLOAT;
|
||||
typedef unsigned UINTFLOAT; ///< Equivalent to INTFLOAT, Used as temporal cast to avoid undefined sign overflow operations.
|
||||
typedef int64_t INT64FLOAT;
|
||||
typedef int16_t SHORTFLOAT;
|
||||
typedef SoftFloat AAC_FLOAT;
|
||||
typedef int AAC_SIGNE;
|
||||
#define FIXR(a) ((int)((a) * 1 + 0.5))
|
||||
#define FIXR10(a) ((int)((a) * 1024.0 + 0.5))
|
||||
#define Q23(a) (int)((a) * 8388608.0 + 0.5)
|
||||
#define Q30(x) (int)((x)*1073741824.0 + 0.5)
|
||||
#define Q31(x) (int)((x)*2147483648.0 + 0.5)
|
||||
#define GET_GAIN(x, y) (-(y) * (1 << (x))) + 1024
|
||||
#define AAC_MUL16(x, y) (int)(((int64_t)(x) * (y) + 0x8000) >> 16)
|
||||
#define AAC_MUL26(x, y) (int)(((int64_t)(x) * (y) + 0x2000000) >> 26)
|
||||
#define AAC_MUL30(x, y) (int)(((int64_t)(x) * (y) + 0x20000000) >> 30)
|
||||
#define AAC_MUL31(x, y) (int)(((int64_t)(x) * (y) + 0x40000000) >> 31)
|
||||
#define AAC_MADD28(x, y, a, b) (int)((((int64_t)(x) * (y)) + \
|
||||
((int64_t)(a) * (b)) + \
|
||||
0x8000000) >> 28)
|
||||
#define AAC_MADD30(x, y, a, b) (int)((((int64_t)(x) * (y)) + \
|
||||
((int64_t)(a) * (b)) + \
|
||||
0x20000000) >> 30)
|
||||
#define AAC_MADD30_V8(x, y, a, b, c, d, e, f) (int)((((int64_t)(x) * (y)) + \
|
||||
((int64_t)(a) * (b)) + \
|
||||
((int64_t)(c) * (d)) + \
|
||||
((int64_t)(e) * (f)) + \
|
||||
0x20000000) >> 30)
|
||||
#define AAC_MSUB30(x, y, a, b) (int)((((int64_t)(x) * (y)) - \
|
||||
((int64_t)(a) * (b)) + \
|
||||
0x20000000) >> 30)
|
||||
#define AAC_MSUB30_V8(x, y, a, b, c, d, e, f) (int)((((int64_t)(x) * (y)) + \
|
||||
((int64_t)(a) * (b)) - \
|
||||
((int64_t)(c) * (d)) - \
|
||||
((int64_t)(e) * (f)) + \
|
||||
0x20000000) >> 30)
|
||||
#define AAC_MSUB31_V3(x, y, z) (int)((((int64_t)(x) * (z)) - \
|
||||
((int64_t)(y) * (z)) + \
|
||||
0x40000000) >> 31)
|
||||
#define AAC_HALF_SUM(x, y) (((x) >> 1) + ((y) >> 1))
|
||||
|
||||
/**
|
||||
* Predictor State
|
||||
*/
|
||||
typedef struct PredictorStateFixed {
|
||||
SoftFloat cor0;
|
||||
SoftFloat cor1;
|
||||
SoftFloat var0;
|
||||
SoftFloat var1;
|
||||
SoftFloat r0;
|
||||
SoftFloat r1;
|
||||
SoftFloat k1;
|
||||
SoftFloat x_est;
|
||||
} PredictorState;
|
||||
|
||||
#ifdef LPC_USE_FIXED
|
||||
#error aac_defines.h must be included before lpc_functions.h for fixed point decoder
|
||||
#endif
|
||||
|
||||
#define LPC_USE_FIXED 1
|
||||
#define LPC_MUL26(x, y) AAC_MUL26((x), (y))
|
||||
#define LPC_FIXR(x) FIXR(x)
|
||||
#define LPC_SRA_R(x, y) (int)(((x) + (1 << ((y) - 1))) >> (y))
|
||||
|
||||
#else
|
||||
|
||||
#define AAC_RENAME(x) x
|
||||
#define AAC_RENAME2(x) ff_ ## x
|
||||
typedef float INTFLOAT;
|
||||
typedef float UINTFLOAT;
|
||||
typedef float INT64FLOAT;
|
||||
typedef float SHORTFLOAT;
|
||||
typedef float AAC_FLOAT;
|
||||
typedef unsigned AAC_SIGNE;
|
||||
#define FIXR(x) ((float)(x))
|
||||
#define FIXR10(x) ((float)(x))
|
||||
#define Q23(x) ((float)(x))
|
||||
#define Q30(x) ((float)(x))
|
||||
#define Q31(x) ((float)(x))
|
||||
#define GET_GAIN(x, y) powf((x), -(y))
|
||||
#define AAC_MUL16(x, y) ((x) * (y))
|
||||
#define AAC_MUL26(x, y) ((x) * (y))
|
||||
#define AAC_MUL30(x, y) ((x) * (y))
|
||||
#define AAC_MUL31(x, y) ((x) * (y))
|
||||
#define AAC_MADD28(x, y, a, b) ((x) * (y) + (a) * (b))
|
||||
#define AAC_MADD30(x, y, a, b) ((x) * (y) + (a) * (b))
|
||||
#define AAC_MADD30_V8(x, y, a, b, c, d, e, f) ((x) * (y) + (a) * (b) + \
|
||||
(c) * (d) + (e) * (f))
|
||||
#define AAC_MSUB30(x, y, a, b) ((x) * (y) - (a) * (b))
|
||||
#define AAC_MSUB30_V8(x, y, a, b, c, d, e, f) ((x) * (y) + (a) * (b) - \
|
||||
(c) * (d) - (e) * (f))
|
||||
#define AAC_MSUB31_V3(x, y, z) ((x) - (y)) * (z)
|
||||
#define AAC_HALF_SUM(x, y) ((x) + (y)) * 0.5f
|
||||
|
||||
/**
|
||||
* Predictor State
|
||||
*/
|
||||
typedef struct PredictorState {
|
||||
float cor0;
|
||||
float cor1;
|
||||
float var0;
|
||||
float var1;
|
||||
float r0;
|
||||
float r1;
|
||||
float k1;
|
||||
float x_est;
|
||||
} PredictorState;
|
||||
|
||||
#endif /* USE_FIXED */
|
||||
|
||||
#endif /* AVCODEC_AAC_DEFINES_H */
|
||||
192
include/libavcodec/aaccoder_trellis.h
Normal file
192
include/libavcodec/aaccoder_trellis.h
Normal file
@@ -0,0 +1,192 @@
|
||||
/*
|
||||
* AAC encoder trellis codebook selector
|
||||
* Copyright (C) 2008-2009 Konstantin Shishkov
|
||||
*
|
||||
* 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
|
||||
* AAC encoder trellis codebook selector
|
||||
* @author Konstantin Shishkov
|
||||
*/
|
||||
|
||||
/**
|
||||
* This file contains a template for the codebook_trellis_rate selector function.
|
||||
* It needs to be provided, externally, as an already included declaration,
|
||||
* the following functions from aacenc_quantization/util.h. They're not included
|
||||
* explicitly here to make it possible to provide alternative implementations:
|
||||
* - quantize_band_cost_bits
|
||||
* - abs_pow34_v
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_AACCODER_TRELLIS_H
|
||||
#define AVCODEC_AACCODER_TRELLIS_H
|
||||
|
||||
#include <float.h>
|
||||
#include "libavutil/mathematics.h"
|
||||
#include "avcodec.h"
|
||||
#include "put_bits.h"
|
||||
#include "aac.h"
|
||||
#include "aacenc.h"
|
||||
#include "aactab.h"
|
||||
#include "aacenctab.h"
|
||||
|
||||
/**
|
||||
* structure used in optimal codebook search
|
||||
*/
|
||||
typedef struct TrellisBandCodingPath {
|
||||
int prev_idx; ///< pointer to the previous path point
|
||||
float cost; ///< path cost
|
||||
int run;
|
||||
} TrellisBandCodingPath;
|
||||
|
||||
|
||||
static void codebook_trellis_rate(AACEncContext *s, SingleChannelElement *sce,
|
||||
int win, int group_len, const float lambda)
|
||||
{
|
||||
TrellisBandCodingPath path[120][CB_TOT_ALL];
|
||||
int w, swb, cb, start, size;
|
||||
int i, j;
|
||||
const int max_sfb = sce->ics.max_sfb;
|
||||
const int run_bits = sce->ics.num_windows == 1 ? 5 : 3;
|
||||
const int run_esc = (1 << run_bits) - 1;
|
||||
int idx, ppos, count;
|
||||
int stackrun[120], stackcb[120], stack_len;
|
||||
float next_minbits = INFINITY;
|
||||
int next_mincb = 0;
|
||||
|
||||
s->aacdsp.abs_pow34(s->scoefs, sce->coeffs, 1024);
|
||||
start = win*128;
|
||||
for (cb = 0; cb < CB_TOT_ALL; cb++) {
|
||||
path[0][cb].cost = run_bits+4;
|
||||
path[0][cb].prev_idx = -1;
|
||||
path[0][cb].run = 0;
|
||||
}
|
||||
for (swb = 0; swb < max_sfb; swb++) {
|
||||
size = sce->ics.swb_sizes[swb];
|
||||
if (sce->zeroes[win*16 + swb]) {
|
||||
float cost_stay_here = path[swb][0].cost;
|
||||
float cost_get_here = next_minbits + run_bits + 4;
|
||||
if ( run_value_bits[sce->ics.num_windows == 8][path[swb][0].run]
|
||||
!= run_value_bits[sce->ics.num_windows == 8][path[swb][0].run+1])
|
||||
cost_stay_here += run_bits;
|
||||
if (cost_get_here < cost_stay_here) {
|
||||
path[swb+1][0].prev_idx = next_mincb;
|
||||
path[swb+1][0].cost = cost_get_here;
|
||||
path[swb+1][0].run = 1;
|
||||
} else {
|
||||
path[swb+1][0].prev_idx = 0;
|
||||
path[swb+1][0].cost = cost_stay_here;
|
||||
path[swb+1][0].run = path[swb][0].run + 1;
|
||||
}
|
||||
next_minbits = path[swb+1][0].cost;
|
||||
next_mincb = 0;
|
||||
for (cb = 1; cb < CB_TOT_ALL; cb++) {
|
||||
path[swb+1][cb].cost = 61450;
|
||||
path[swb+1][cb].prev_idx = -1;
|
||||
path[swb+1][cb].run = 0;
|
||||
}
|
||||
} else {
|
||||
float minbits = next_minbits;
|
||||
int mincb = next_mincb;
|
||||
int startcb = sce->band_type[win*16+swb];
|
||||
startcb = aac_cb_in_map[startcb];
|
||||
next_minbits = INFINITY;
|
||||
next_mincb = 0;
|
||||
for (cb = 0; cb < startcb; cb++) {
|
||||
path[swb+1][cb].cost = 61450;
|
||||
path[swb+1][cb].prev_idx = -1;
|
||||
path[swb+1][cb].run = 0;
|
||||
}
|
||||
for (cb = startcb; cb < CB_TOT_ALL; cb++) {
|
||||
float cost_stay_here, cost_get_here;
|
||||
float bits = 0.0f;
|
||||
if (cb >= 12 && sce->band_type[win*16+swb] != aac_cb_out_map[cb]) {
|
||||
path[swb+1][cb].cost = 61450;
|
||||
path[swb+1][cb].prev_idx = -1;
|
||||
path[swb+1][cb].run = 0;
|
||||
continue;
|
||||
}
|
||||
for (w = 0; w < group_len; w++) {
|
||||
bits += quantize_band_cost_bits(s, &sce->coeffs[start + w*128],
|
||||
&s->scoefs[start + w*128], size,
|
||||
sce->sf_idx[win*16+swb],
|
||||
aac_cb_out_map[cb],
|
||||
0, INFINITY, NULL, NULL);
|
||||
}
|
||||
cost_stay_here = path[swb][cb].cost + bits;
|
||||
cost_get_here = minbits + bits + run_bits + 4;
|
||||
if ( run_value_bits[sce->ics.num_windows == 8][path[swb][cb].run]
|
||||
!= run_value_bits[sce->ics.num_windows == 8][path[swb][cb].run+1])
|
||||
cost_stay_here += run_bits;
|
||||
if (cost_get_here < cost_stay_here) {
|
||||
path[swb+1][cb].prev_idx = mincb;
|
||||
path[swb+1][cb].cost = cost_get_here;
|
||||
path[swb+1][cb].run = 1;
|
||||
} else {
|
||||
path[swb+1][cb].prev_idx = cb;
|
||||
path[swb+1][cb].cost = cost_stay_here;
|
||||
path[swb+1][cb].run = path[swb][cb].run + 1;
|
||||
}
|
||||
if (path[swb+1][cb].cost < next_minbits) {
|
||||
next_minbits = path[swb+1][cb].cost;
|
||||
next_mincb = cb;
|
||||
}
|
||||
}
|
||||
}
|
||||
start += sce->ics.swb_sizes[swb];
|
||||
}
|
||||
|
||||
//convert resulting path from backward-linked list
|
||||
stack_len = 0;
|
||||
idx = 0;
|
||||
for (cb = 1; cb < CB_TOT_ALL; cb++)
|
||||
if (path[max_sfb][cb].cost < path[max_sfb][idx].cost)
|
||||
idx = cb;
|
||||
ppos = max_sfb;
|
||||
while (ppos > 0) {
|
||||
av_assert1(idx >= 0);
|
||||
cb = idx;
|
||||
stackrun[stack_len] = path[ppos][cb].run;
|
||||
stackcb [stack_len] = cb;
|
||||
idx = path[ppos-path[ppos][cb].run+1][cb].prev_idx;
|
||||
ppos -= path[ppos][cb].run;
|
||||
stack_len++;
|
||||
}
|
||||
//perform actual band info encoding
|
||||
start = 0;
|
||||
for (i = stack_len - 1; i >= 0; i--) {
|
||||
cb = aac_cb_out_map[stackcb[i]];
|
||||
put_bits(&s->pb, 4, cb);
|
||||
count = stackrun[i];
|
||||
memset(sce->zeroes + win*16 + start, !cb, count);
|
||||
//XXX: memset when band_type is also uint8_t
|
||||
for (j = 0; j < count; j++) {
|
||||
sce->band_type[win*16 + start] = cb;
|
||||
start++;
|
||||
}
|
||||
while (count >= run_esc) {
|
||||
put_bits(&s->pb, run_bits, run_esc);
|
||||
count -= run_esc;
|
||||
}
|
||||
put_bits(&s->pb, run_bits, count);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif /* AVCODEC_AACCODER_TRELLIS_H */
|
||||
759
include/libavcodec/aaccoder_twoloop.h
Normal file
759
include/libavcodec/aaccoder_twoloop.h
Normal file
@@ -0,0 +1,759 @@
|
||||
/*
|
||||
* AAC encoder twoloop coder
|
||||
* Copyright (C) 2008-2009 Konstantin Shishkov
|
||||
*
|
||||
* 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
|
||||
* AAC encoder twoloop coder
|
||||
* @author Konstantin Shishkov, Claudio Freire
|
||||
*/
|
||||
|
||||
/**
|
||||
* This file contains a template for the twoloop coder function.
|
||||
* It needs to be provided, externally, as an already included declaration,
|
||||
* the following functions from aacenc_quantization/util.h. They're not included
|
||||
* explicitly here to make it possible to provide alternative implementations:
|
||||
* - quantize_band_cost
|
||||
* - abs_pow34_v
|
||||
* - find_max_val
|
||||
* - find_min_book
|
||||
* - find_form_factor
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_AACCODER_TWOLOOP_H
|
||||
#define AVCODEC_AACCODER_TWOLOOP_H
|
||||
|
||||
#include <float.h>
|
||||
#include "libavutil/mathematics.h"
|
||||
#include "mathops.h"
|
||||
#include "avcodec.h"
|
||||
#include "put_bits.h"
|
||||
#include "aac.h"
|
||||
#include "aacenc.h"
|
||||
#include "aactab.h"
|
||||
#include "aacenctab.h"
|
||||
|
||||
/** Frequency in Hz for lower limit of noise substitution **/
|
||||
#define NOISE_LOW_LIMIT 4000
|
||||
|
||||
/* Reflects the cost to change codebooks */
|
||||
static inline int ff_pns_bits(SingleChannelElement *sce, int w, int g)
|
||||
{
|
||||
return (!g || !sce->zeroes[w*16+g-1] || !sce->can_pns[w*16+g-1]) ? 9 : 5;
|
||||
}
|
||||
|
||||
/**
|
||||
* two-loop quantizers search taken from ISO 13818-7 Appendix C
|
||||
*/
|
||||
static void search_for_quantizers_twoloop(AVCodecContext *avctx,
|
||||
AACEncContext *s,
|
||||
SingleChannelElement *sce,
|
||||
const float lambda)
|
||||
{
|
||||
int start = 0, i, w, w2, g, recomprd;
|
||||
int destbits = avctx->bit_rate * 1024.0 / avctx->sample_rate
|
||||
/ ((avctx->flags & AV_CODEC_FLAG_QSCALE) ? 2.0f : avctx->ch_layout.nb_channels)
|
||||
* (lambda / 120.f);
|
||||
int refbits = destbits;
|
||||
int toomanybits, toofewbits;
|
||||
char nzs[128];
|
||||
uint8_t nextband[128];
|
||||
int maxsf[128], minsf[128];
|
||||
float dists[128] = { 0 }, qenergies[128] = { 0 }, uplims[128], euplims[128], energies[128];
|
||||
float maxvals[128], spread_thr_r[128];
|
||||
float min_spread_thr_r, max_spread_thr_r;
|
||||
|
||||
/**
|
||||
* rdlambda controls the maximum tolerated distortion. Twoloop
|
||||
* will keep iterating until it fails to lower it or it reaches
|
||||
* ulimit * rdlambda. Keeping it low increases quality on difficult
|
||||
* signals, but lower it too much, and bits will be taken from weak
|
||||
* signals, creating "holes". A balance is necessary.
|
||||
* rdmax and rdmin specify the relative deviation from rdlambda
|
||||
* allowed for tonality compensation
|
||||
*/
|
||||
float rdlambda = av_clipf(2.0f * 120.f / lambda, 0.0625f, 16.0f);
|
||||
const float nzslope = 1.5f;
|
||||
float rdmin = 0.03125f;
|
||||
float rdmax = 1.0f;
|
||||
|
||||
/**
|
||||
* sfoffs controls an offset of optmium allocation that will be
|
||||
* applied based on lambda. Keep it real and modest, the loop
|
||||
* will take care of the rest, this just accelerates convergence
|
||||
*/
|
||||
float sfoffs = av_clipf(log2f(120.0f / lambda) * 4.0f, -5, 10);
|
||||
|
||||
int fflag, minscaler, nminscaler;
|
||||
int its = 0;
|
||||
int maxits = 30;
|
||||
int allz = 0;
|
||||
int tbits;
|
||||
int cutoff = 1024;
|
||||
int pns_start_pos;
|
||||
int prev;
|
||||
|
||||
/**
|
||||
* zeroscale controls a multiplier of the threshold, if band energy
|
||||
* is below this, a zero is forced. Keep it lower than 1, unless
|
||||
* low lambda is used, because energy < threshold doesn't mean there's
|
||||
* no audible signal outright, it's just energy. Also make it rise
|
||||
* slower than rdlambda, as rdscale has due compensation with
|
||||
* noisy band depriorization below, whereas zeroing logic is rather dumb
|
||||
*/
|
||||
float zeroscale;
|
||||
if (lambda > 120.f) {
|
||||
zeroscale = av_clipf(powf(120.f / lambda, 0.25f), 0.0625f, 1.0f);
|
||||
} else {
|
||||
zeroscale = 1.f;
|
||||
}
|
||||
|
||||
if (s->psy.bitres.alloc >= 0) {
|
||||
/**
|
||||
* Psy granted us extra bits to use, from the reservoire
|
||||
* adjust for lambda except what psy already did
|
||||
*/
|
||||
destbits = s->psy.bitres.alloc
|
||||
* (lambda / (avctx->global_quality ? avctx->global_quality : 120));
|
||||
}
|
||||
|
||||
if (avctx->flags & AV_CODEC_FLAG_QSCALE) {
|
||||
/**
|
||||
* Constant Q-scale doesn't compensate MS coding on its own
|
||||
* No need to be overly precise, this only controls RD
|
||||
* adjustment CB limits when going overboard
|
||||
*/
|
||||
if (s->options.mid_side && s->cur_type == TYPE_CPE)
|
||||
destbits *= 2;
|
||||
|
||||
/**
|
||||
* When using a constant Q-scale, don't adjust bits, just use RD
|
||||
* Don't let it go overboard, though... 8x psy target is enough
|
||||
*/
|
||||
toomanybits = 5800;
|
||||
toofewbits = destbits / 16;
|
||||
|
||||
/** Don't offset scalers, just RD */
|
||||
sfoffs = sce->ics.num_windows - 1;
|
||||
rdlambda = sqrtf(rdlambda);
|
||||
|
||||
/** search further */
|
||||
maxits *= 2;
|
||||
} else {
|
||||
/* When using ABR, be strict, but a reasonable leeway is
|
||||
* critical to allow RC to smoothly track desired bitrate
|
||||
* without sudden quality drops that cause audible artifacts.
|
||||
* Symmetry is also desirable, to avoid systematic bias.
|
||||
*/
|
||||
toomanybits = destbits + destbits/8;
|
||||
toofewbits = destbits - destbits/8;
|
||||
|
||||
sfoffs = 0;
|
||||
rdlambda = sqrtf(rdlambda);
|
||||
}
|
||||
|
||||
/** and zero out above cutoff frequency */
|
||||
{
|
||||
int wlen = 1024 / sce->ics.num_windows;
|
||||
int bandwidth;
|
||||
|
||||
/**
|
||||
* Scale, psy gives us constant quality, this LP only scales
|
||||
* bitrate by lambda, so we save bits on subjectively unimportant HF
|
||||
* rather than increase quantization noise. Adjust nominal bitrate
|
||||
* to effective bitrate according to encoding parameters,
|
||||
* AAC_CUTOFF_FROM_BITRATE is calibrated for effective bitrate.
|
||||
*/
|
||||
float rate_bandwidth_multiplier = 1.5f;
|
||||
int frame_bit_rate = (avctx->flags & AV_CODEC_FLAG_QSCALE)
|
||||
? (refbits * rate_bandwidth_multiplier * avctx->sample_rate / 1024)
|
||||
: (avctx->bit_rate / avctx->ch_layout.nb_channels);
|
||||
|
||||
/** Compensate for extensions that increase efficiency */
|
||||
if (s->options.pns || s->options.intensity_stereo)
|
||||
frame_bit_rate *= 1.15f;
|
||||
|
||||
if (avctx->cutoff > 0) {
|
||||
bandwidth = avctx->cutoff;
|
||||
} else {
|
||||
bandwidth = FFMAX(3000, AAC_CUTOFF_FROM_BITRATE(frame_bit_rate, 1, avctx->sample_rate));
|
||||
s->psy.cutoff = bandwidth;
|
||||
}
|
||||
|
||||
cutoff = bandwidth * 2 * wlen / avctx->sample_rate;
|
||||
pns_start_pos = NOISE_LOW_LIMIT * 2 * wlen / avctx->sample_rate;
|
||||
}
|
||||
|
||||
/**
|
||||
* for values above this the decoder might end up in an endless loop
|
||||
* due to always having more bits than what can be encoded.
|
||||
*/
|
||||
destbits = FFMIN(destbits, 5800);
|
||||
toomanybits = FFMIN(toomanybits, 5800);
|
||||
toofewbits = FFMIN(toofewbits, 5800);
|
||||
/**
|
||||
* XXX: some heuristic to determine initial quantizers will reduce search time
|
||||
* determine zero bands and upper distortion limits
|
||||
*/
|
||||
min_spread_thr_r = -1;
|
||||
max_spread_thr_r = -1;
|
||||
for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
|
||||
for (g = start = 0; g < sce->ics.num_swb; start += sce->ics.swb_sizes[g++]) {
|
||||
int nz = 0;
|
||||
float uplim = 0.0f, energy = 0.0f, spread = 0.0f;
|
||||
for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
|
||||
FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[(w+w2)*16+g];
|
||||
if (start >= cutoff || band->energy <= (band->threshold * zeroscale) || band->threshold == 0.0f) {
|
||||
sce->zeroes[(w+w2)*16+g] = 1;
|
||||
continue;
|
||||
}
|
||||
nz = 1;
|
||||
}
|
||||
if (!nz) {
|
||||
uplim = 0.0f;
|
||||
} else {
|
||||
nz = 0;
|
||||
for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
|
||||
FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[(w+w2)*16+g];
|
||||
if (band->energy <= (band->threshold * zeroscale) || band->threshold == 0.0f)
|
||||
continue;
|
||||
uplim += band->threshold;
|
||||
energy += band->energy;
|
||||
spread += band->spread;
|
||||
nz++;
|
||||
}
|
||||
}
|
||||
uplims[w*16+g] = uplim;
|
||||
energies[w*16+g] = energy;
|
||||
nzs[w*16+g] = nz;
|
||||
sce->zeroes[w*16+g] = !nz;
|
||||
allz |= nz;
|
||||
if (nz && sce->can_pns[w*16+g]) {
|
||||
spread_thr_r[w*16+g] = energy * nz / (uplim * spread);
|
||||
if (min_spread_thr_r < 0) {
|
||||
min_spread_thr_r = max_spread_thr_r = spread_thr_r[w*16+g];
|
||||
} else {
|
||||
min_spread_thr_r = FFMIN(min_spread_thr_r, spread_thr_r[w*16+g]);
|
||||
max_spread_thr_r = FFMAX(max_spread_thr_r, spread_thr_r[w*16+g]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Compute initial scalers */
|
||||
minscaler = 65535;
|
||||
for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
|
||||
for (g = 0; g < sce->ics.num_swb; g++) {
|
||||
if (sce->zeroes[w*16+g]) {
|
||||
sce->sf_idx[w*16+g] = SCALE_ONE_POS;
|
||||
continue;
|
||||
}
|
||||
/**
|
||||
* log2f-to-distortion ratio is, technically, 2 (1.5db = 4, but it's power vs level so it's 2).
|
||||
* But, as offsets are applied, low-frequency signals are too sensitive to the induced distortion,
|
||||
* so we make scaling more conservative by choosing a lower log2f-to-distortion ratio, and thus
|
||||
* more robust.
|
||||
*/
|
||||
sce->sf_idx[w*16+g] = av_clip(
|
||||
SCALE_ONE_POS
|
||||
+ 1.75*log2f(FFMAX(0.00125f,uplims[w*16+g]) / sce->ics.swb_sizes[g])
|
||||
+ sfoffs,
|
||||
60, SCALE_MAX_POS);
|
||||
minscaler = FFMIN(minscaler, sce->sf_idx[w*16+g]);
|
||||
}
|
||||
}
|
||||
|
||||
/** Clip */
|
||||
minscaler = av_clip(minscaler, SCALE_ONE_POS - SCALE_DIV_512, SCALE_MAX_POS - SCALE_DIV_512);
|
||||
for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w])
|
||||
for (g = 0; g < sce->ics.num_swb; g++)
|
||||
if (!sce->zeroes[w*16+g])
|
||||
sce->sf_idx[w*16+g] = av_clip(sce->sf_idx[w*16+g], minscaler, minscaler + SCALE_MAX_DIFF - 1);
|
||||
|
||||
if (!allz)
|
||||
return;
|
||||
s->aacdsp.abs_pow34(s->scoefs, sce->coeffs, 1024);
|
||||
ff_quantize_band_cost_cache_init(s);
|
||||
|
||||
for (i = 0; i < sizeof(minsf) / sizeof(minsf[0]); ++i)
|
||||
minsf[i] = 0;
|
||||
for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
|
||||
start = w*128;
|
||||
for (g = 0; g < sce->ics.num_swb; g++) {
|
||||
const float *scaled = s->scoefs + start;
|
||||
int minsfidx;
|
||||
maxvals[w*16+g] = find_max_val(sce->ics.group_len[w], sce->ics.swb_sizes[g], scaled);
|
||||
if (maxvals[w*16+g] > 0) {
|
||||
minsfidx = coef2minsf(maxvals[w*16+g]);
|
||||
for (w2 = 0; w2 < sce->ics.group_len[w]; w2++)
|
||||
minsf[(w+w2)*16+g] = minsfidx;
|
||||
}
|
||||
start += sce->ics.swb_sizes[g];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scale uplims to match rate distortion to quality
|
||||
* bu applying noisy band depriorization and tonal band priorization.
|
||||
* Maxval-energy ratio gives us an idea of how noisy/tonal the band is.
|
||||
* If maxval^2 ~ energy, then that band is mostly noise, and we can relax
|
||||
* rate distortion requirements.
|
||||
*/
|
||||
memcpy(euplims, uplims, sizeof(euplims));
|
||||
for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
|
||||
/** psy already priorizes transients to some extent */
|
||||
float de_psy_factor = (sce->ics.num_windows > 1) ? 8.0f / sce->ics.group_len[w] : 1.0f;
|
||||
start = w*128;
|
||||
for (g = 0; g < sce->ics.num_swb; g++) {
|
||||
if (nzs[g] > 0) {
|
||||
float cleanup_factor = ff_sqrf(av_clipf(start / (cutoff * 0.75f), 1.0f, 2.0f));
|
||||
float energy2uplim = find_form_factor(
|
||||
sce->ics.group_len[w], sce->ics.swb_sizes[g],
|
||||
uplims[w*16+g] / (nzs[g] * sce->ics.swb_sizes[w]),
|
||||
sce->coeffs + start,
|
||||
nzslope * cleanup_factor);
|
||||
energy2uplim *= de_psy_factor;
|
||||
if (!(avctx->flags & AV_CODEC_FLAG_QSCALE)) {
|
||||
/** In ABR, we need to priorize less and let rate control do its thing */
|
||||
energy2uplim = sqrtf(energy2uplim);
|
||||
}
|
||||
energy2uplim = FFMAX(0.015625f, FFMIN(1.0f, energy2uplim));
|
||||
uplims[w*16+g] *= av_clipf(rdlambda * energy2uplim, rdmin, rdmax)
|
||||
* sce->ics.group_len[w];
|
||||
|
||||
energy2uplim = find_form_factor(
|
||||
sce->ics.group_len[w], sce->ics.swb_sizes[g],
|
||||
uplims[w*16+g] / (nzs[g] * sce->ics.swb_sizes[w]),
|
||||
sce->coeffs + start,
|
||||
2.0f);
|
||||
energy2uplim *= de_psy_factor;
|
||||
if (!(avctx->flags & AV_CODEC_FLAG_QSCALE)) {
|
||||
/** In ABR, we need to priorize less and let rate control do its thing */
|
||||
energy2uplim = sqrtf(energy2uplim);
|
||||
}
|
||||
energy2uplim = FFMAX(0.015625f, FFMIN(1.0f, energy2uplim));
|
||||
euplims[w*16+g] *= av_clipf(rdlambda * energy2uplim * sce->ics.group_len[w],
|
||||
0.5f, 1.0f);
|
||||
}
|
||||
start += sce->ics.swb_sizes[g];
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < sizeof(maxsf) / sizeof(maxsf[0]); ++i)
|
||||
maxsf[i] = SCALE_MAX_POS;
|
||||
|
||||
//perform two-loop search
|
||||
//outer loop - improve quality
|
||||
do {
|
||||
//inner loop - quantize spectrum to fit into given number of bits
|
||||
int overdist;
|
||||
int qstep = its ? 1 : 32;
|
||||
do {
|
||||
int changed = 0;
|
||||
prev = -1;
|
||||
recomprd = 0;
|
||||
tbits = 0;
|
||||
for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
|
||||
start = w*128;
|
||||
for (g = 0; g < sce->ics.num_swb; g++) {
|
||||
const float *coefs = &sce->coeffs[start];
|
||||
const float *scaled = &s->scoefs[start];
|
||||
int bits = 0;
|
||||
int cb;
|
||||
float dist = 0.0f;
|
||||
float qenergy = 0.0f;
|
||||
|
||||
if (sce->zeroes[w*16+g] || sce->sf_idx[w*16+g] >= 218) {
|
||||
start += sce->ics.swb_sizes[g];
|
||||
if (sce->can_pns[w*16+g]) {
|
||||
/** PNS isn't free */
|
||||
tbits += ff_pns_bits(sce, w, g);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
cb = find_min_book(maxvals[w*16+g], sce->sf_idx[w*16+g]);
|
||||
for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
|
||||
int b;
|
||||
float sqenergy;
|
||||
dist += quantize_band_cost_cached(s, w + w2, g, coefs + w2*128,
|
||||
scaled + w2*128,
|
||||
sce->ics.swb_sizes[g],
|
||||
sce->sf_idx[w*16+g],
|
||||
cb,
|
||||
1.0f,
|
||||
INFINITY,
|
||||
&b, &sqenergy,
|
||||
0);
|
||||
bits += b;
|
||||
qenergy += sqenergy;
|
||||
}
|
||||
dists[w*16+g] = dist - bits;
|
||||
qenergies[w*16+g] = qenergy;
|
||||
if (prev != -1) {
|
||||
int sfdiff = av_clip(sce->sf_idx[w*16+g] - prev + SCALE_DIFF_ZERO, 0, 2*SCALE_MAX_DIFF);
|
||||
bits += ff_aac_scalefactor_bits[sfdiff];
|
||||
}
|
||||
tbits += bits;
|
||||
start += sce->ics.swb_sizes[g];
|
||||
prev = sce->sf_idx[w*16+g];
|
||||
}
|
||||
}
|
||||
if (tbits > toomanybits) {
|
||||
recomprd = 1;
|
||||
for (i = 0; i < 128; i++) {
|
||||
if (sce->sf_idx[i] < (SCALE_MAX_POS - SCALE_DIV_512)) {
|
||||
int maxsf_i = (tbits > 5800) ? SCALE_MAX_POS : maxsf[i];
|
||||
int new_sf = FFMIN(maxsf_i, sce->sf_idx[i] + qstep);
|
||||
if (new_sf != sce->sf_idx[i]) {
|
||||
sce->sf_idx[i] = new_sf;
|
||||
changed = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (tbits < toofewbits) {
|
||||
recomprd = 1;
|
||||
for (i = 0; i < 128; i++) {
|
||||
if (sce->sf_idx[i] > SCALE_ONE_POS) {
|
||||
int new_sf = FFMAX3(minsf[i], SCALE_ONE_POS, sce->sf_idx[i] - qstep);
|
||||
if (new_sf != sce->sf_idx[i]) {
|
||||
sce->sf_idx[i] = new_sf;
|
||||
changed = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
qstep >>= 1;
|
||||
if (!qstep && tbits > toomanybits && sce->sf_idx[0] < 217 && changed)
|
||||
qstep = 1;
|
||||
} while (qstep);
|
||||
|
||||
overdist = 1;
|
||||
fflag = tbits < toofewbits;
|
||||
for (i = 0; i < 2 && (overdist || recomprd); ++i) {
|
||||
if (recomprd) {
|
||||
/** Must recompute distortion */
|
||||
prev = -1;
|
||||
tbits = 0;
|
||||
for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
|
||||
start = w*128;
|
||||
for (g = 0; g < sce->ics.num_swb; g++) {
|
||||
const float *coefs = sce->coeffs + start;
|
||||
const float *scaled = s->scoefs + start;
|
||||
int bits = 0;
|
||||
int cb;
|
||||
float dist = 0.0f;
|
||||
float qenergy = 0.0f;
|
||||
|
||||
if (sce->zeroes[w*16+g] || sce->sf_idx[w*16+g] >= 218) {
|
||||
start += sce->ics.swb_sizes[g];
|
||||
if (sce->can_pns[w*16+g]) {
|
||||
/** PNS isn't free */
|
||||
tbits += ff_pns_bits(sce, w, g);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
cb = find_min_book(maxvals[w*16+g], sce->sf_idx[w*16+g]);
|
||||
for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
|
||||
int b;
|
||||
float sqenergy;
|
||||
dist += quantize_band_cost_cached(s, w + w2, g, coefs + w2*128,
|
||||
scaled + w2*128,
|
||||
sce->ics.swb_sizes[g],
|
||||
sce->sf_idx[w*16+g],
|
||||
cb,
|
||||
1.0f,
|
||||
INFINITY,
|
||||
&b, &sqenergy,
|
||||
0);
|
||||
bits += b;
|
||||
qenergy += sqenergy;
|
||||
}
|
||||
dists[w*16+g] = dist - bits;
|
||||
qenergies[w*16+g] = qenergy;
|
||||
if (prev != -1) {
|
||||
int sfdiff = av_clip(sce->sf_idx[w*16+g] - prev + SCALE_DIFF_ZERO, 0, 2*SCALE_MAX_DIFF);
|
||||
bits += ff_aac_scalefactor_bits[sfdiff];
|
||||
}
|
||||
tbits += bits;
|
||||
start += sce->ics.swb_sizes[g];
|
||||
prev = sce->sf_idx[w*16+g];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!i && s->options.pns && its > maxits/2 && tbits > toofewbits) {
|
||||
float maxoverdist = 0.0f;
|
||||
float ovrfactor = 1.f+(maxits-its)*16.f/maxits;
|
||||
overdist = recomprd = 0;
|
||||
for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
|
||||
for (g = start = 0; g < sce->ics.num_swb; start += sce->ics.swb_sizes[g++]) {
|
||||
if (!sce->zeroes[w*16+g] && sce->sf_idx[w*16+g] > SCALE_ONE_POS && dists[w*16+g] > uplims[w*16+g]*ovrfactor) {
|
||||
float ovrdist = dists[w*16+g] / FFMAX(uplims[w*16+g],euplims[w*16+g]);
|
||||
maxoverdist = FFMAX(maxoverdist, ovrdist);
|
||||
overdist++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (overdist) {
|
||||
/* We have overdistorted bands, trade for zeroes (that can be noise)
|
||||
* Zero the bands in the lowest 1.25% spread-energy-threshold ranking
|
||||
*/
|
||||
float minspread = max_spread_thr_r;
|
||||
float maxspread = min_spread_thr_r;
|
||||
float zspread;
|
||||
int zeroable = 0;
|
||||
int zeroed = 0;
|
||||
int maxzeroed, zloop;
|
||||
for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
|
||||
for (g = start = 0; g < sce->ics.num_swb; start += sce->ics.swb_sizes[g++]) {
|
||||
if (start >= pns_start_pos && !sce->zeroes[w*16+g] && sce->can_pns[w*16+g]) {
|
||||
minspread = FFMIN(minspread, spread_thr_r[w*16+g]);
|
||||
maxspread = FFMAX(maxspread, spread_thr_r[w*16+g]);
|
||||
zeroable++;
|
||||
}
|
||||
}
|
||||
}
|
||||
zspread = (maxspread-minspread) * 0.0125f + minspread;
|
||||
/* Don't PNS everything even if allowed. It suppresses bit starvation signals from RC,
|
||||
* and forced the hand of the later search_for_pns step.
|
||||
* Instead, PNS a fraction of the spread_thr_r range depending on how starved for bits we are,
|
||||
* and leave further PNSing to search_for_pns if worthwhile.
|
||||
*/
|
||||
zspread = FFMIN3(min_spread_thr_r * 8.f, zspread,
|
||||
((toomanybits - tbits) * min_spread_thr_r + (tbits - toofewbits) * max_spread_thr_r) / (toomanybits - toofewbits + 1));
|
||||
maxzeroed = FFMIN(zeroable, FFMAX(1, (zeroable * its + maxits - 1) / (2 * maxits)));
|
||||
for (zloop = 0; zloop < 2; zloop++) {
|
||||
/* Two passes: first distorted stuff - two birds in one shot and all that,
|
||||
* then anything viable. Viable means not zero, but either CB=zero-able
|
||||
* (too high SF), not SF <= 1 (that means we'd be operating at very high
|
||||
* quality, we don't want PNS when doing VHQ), PNS allowed, and within
|
||||
* the lowest ranking percentile.
|
||||
*/
|
||||
float loopovrfactor = (zloop) ? 1.0f : ovrfactor;
|
||||
int loopminsf = (zloop) ? (SCALE_ONE_POS - SCALE_DIV_512) : SCALE_ONE_POS;
|
||||
int mcb;
|
||||
for (g = sce->ics.num_swb-1; g > 0 && zeroed < maxzeroed; g--) {
|
||||
if (sce->ics.swb_offset[g] < pns_start_pos)
|
||||
continue;
|
||||
for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
|
||||
if (!sce->zeroes[w*16+g] && sce->can_pns[w*16+g] && spread_thr_r[w*16+g] <= zspread
|
||||
&& sce->sf_idx[w*16+g] > loopminsf
|
||||
&& (dists[w*16+g] > loopovrfactor*uplims[w*16+g] || !(mcb = find_min_book(maxvals[w*16+g], sce->sf_idx[w*16+g]))
|
||||
|| (mcb <= 1 && dists[w*16+g] > FFMIN(uplims[w*16+g], euplims[w*16+g]))) ) {
|
||||
sce->zeroes[w*16+g] = 1;
|
||||
sce->band_type[w*16+g] = 0;
|
||||
zeroed++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (zeroed)
|
||||
recomprd = fflag = 1;
|
||||
} else {
|
||||
overdist = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
minscaler = SCALE_MAX_POS;
|
||||
for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
|
||||
for (g = 0; g < sce->ics.num_swb; g++) {
|
||||
if (!sce->zeroes[w*16+g]) {
|
||||
minscaler = FFMIN(minscaler, sce->sf_idx[w*16+g]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
minscaler = nminscaler = av_clip(minscaler, SCALE_ONE_POS - SCALE_DIV_512, SCALE_MAX_POS - SCALE_DIV_512);
|
||||
prev = -1;
|
||||
for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
|
||||
/** Start with big steps, end up fine-tunning */
|
||||
int depth = (its > maxits/2) ? ((its > maxits*2/3) ? 1 : 3) : 10;
|
||||
int edepth = depth+2;
|
||||
float uplmax = its / (maxits*0.25f) + 1.0f;
|
||||
uplmax *= (tbits > destbits) ? FFMIN(2.0f, tbits / (float)FFMAX(1,destbits)) : 1.0f;
|
||||
start = w * 128;
|
||||
for (g = 0; g < sce->ics.num_swb; g++) {
|
||||
int prevsc = sce->sf_idx[w*16+g];
|
||||
if (prev < 0 && !sce->zeroes[w*16+g])
|
||||
prev = sce->sf_idx[0];
|
||||
if (!sce->zeroes[w*16+g]) {
|
||||
const float *coefs = sce->coeffs + start;
|
||||
const float *scaled = s->scoefs + start;
|
||||
int cmb = find_min_book(maxvals[w*16+g], sce->sf_idx[w*16+g]);
|
||||
int mindeltasf = FFMAX(0, prev - SCALE_MAX_DIFF);
|
||||
int maxdeltasf = FFMIN(SCALE_MAX_POS - SCALE_DIV_512, prev + SCALE_MAX_DIFF);
|
||||
if ((!cmb || dists[w*16+g] > uplims[w*16+g]) && sce->sf_idx[w*16+g] > FFMAX(mindeltasf, minsf[w*16+g])) {
|
||||
/* Try to make sure there is some energy in every nonzero band
|
||||
* NOTE: This algorithm must be forcibly imbalanced, pushing harder
|
||||
* on holes or more distorted bands at first, otherwise there's
|
||||
* no net gain (since the next iteration will offset all bands
|
||||
* on the opposite direction to compensate for extra bits)
|
||||
*/
|
||||
for (i = 0; i < edepth && sce->sf_idx[w*16+g] > mindeltasf; ++i) {
|
||||
int cb, bits;
|
||||
float dist, qenergy;
|
||||
int mb = find_min_book(maxvals[w*16+g], sce->sf_idx[w*16+g]-1);
|
||||
cb = find_min_book(maxvals[w*16+g], sce->sf_idx[w*16+g]);
|
||||
dist = qenergy = 0.f;
|
||||
bits = 0;
|
||||
if (!cb) {
|
||||
maxsf[w*16+g] = FFMIN(sce->sf_idx[w*16+g]-1, maxsf[w*16+g]);
|
||||
} else if (i >= depth && dists[w*16+g] < euplims[w*16+g]) {
|
||||
break;
|
||||
}
|
||||
/* !g is the DC band, it's important, since quantization error here
|
||||
* applies to less than a cycle, it creates horrible intermodulation
|
||||
* distortion if it doesn't stick to what psy requests
|
||||
*/
|
||||
if (!g && sce->ics.num_windows > 1 && dists[w*16+g] >= euplims[w*16+g])
|
||||
maxsf[w*16+g] = FFMIN(sce->sf_idx[w*16+g], maxsf[w*16+g]);
|
||||
for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
|
||||
int b;
|
||||
float sqenergy;
|
||||
dist += quantize_band_cost_cached(s, w + w2, g, coefs + w2*128,
|
||||
scaled + w2*128,
|
||||
sce->ics.swb_sizes[g],
|
||||
sce->sf_idx[w*16+g]-1,
|
||||
cb,
|
||||
1.0f,
|
||||
INFINITY,
|
||||
&b, &sqenergy,
|
||||
0);
|
||||
bits += b;
|
||||
qenergy += sqenergy;
|
||||
}
|
||||
sce->sf_idx[w*16+g]--;
|
||||
dists[w*16+g] = dist - bits;
|
||||
qenergies[w*16+g] = qenergy;
|
||||
if (mb && (sce->sf_idx[w*16+g] < mindeltasf || (
|
||||
(dists[w*16+g] < FFMIN(uplmax*uplims[w*16+g], euplims[w*16+g]))
|
||||
&& (fabsf(qenergies[w*16+g]-energies[w*16+g]) < euplims[w*16+g])
|
||||
) )) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (tbits > toofewbits && sce->sf_idx[w*16+g] < FFMIN(maxdeltasf, maxsf[w*16+g])
|
||||
&& (dists[w*16+g] < FFMIN(euplims[w*16+g], uplims[w*16+g]))
|
||||
&& (fabsf(qenergies[w*16+g]-energies[w*16+g]) < euplims[w*16+g])
|
||||
) {
|
||||
/** Um... over target. Save bits for more important stuff. */
|
||||
for (i = 0; i < depth && sce->sf_idx[w*16+g] < maxdeltasf; ++i) {
|
||||
int cb, bits;
|
||||
float dist, qenergy;
|
||||
cb = find_min_book(maxvals[w*16+g], sce->sf_idx[w*16+g]+1);
|
||||
if (cb > 0) {
|
||||
dist = qenergy = 0.f;
|
||||
bits = 0;
|
||||
for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
|
||||
int b;
|
||||
float sqenergy;
|
||||
dist += quantize_band_cost_cached(s, w + w2, g, coefs + w2*128,
|
||||
scaled + w2*128,
|
||||
sce->ics.swb_sizes[g],
|
||||
sce->sf_idx[w*16+g]+1,
|
||||
cb,
|
||||
1.0f,
|
||||
INFINITY,
|
||||
&b, &sqenergy,
|
||||
0);
|
||||
bits += b;
|
||||
qenergy += sqenergy;
|
||||
}
|
||||
dist -= bits;
|
||||
if (dist < FFMIN(euplims[w*16+g], uplims[w*16+g])) {
|
||||
sce->sf_idx[w*16+g]++;
|
||||
dists[w*16+g] = dist;
|
||||
qenergies[w*16+g] = qenergy;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
maxsf[w*16+g] = FFMIN(sce->sf_idx[w*16+g], maxsf[w*16+g]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
prev = sce->sf_idx[w*16+g] = av_clip(sce->sf_idx[w*16+g], mindeltasf, maxdeltasf);
|
||||
if (sce->sf_idx[w*16+g] != prevsc)
|
||||
fflag = 1;
|
||||
nminscaler = FFMIN(nminscaler, sce->sf_idx[w*16+g]);
|
||||
sce->band_type[w*16+g] = find_min_book(maxvals[w*16+g], sce->sf_idx[w*16+g]);
|
||||
}
|
||||
start += sce->ics.swb_sizes[g];
|
||||
}
|
||||
}
|
||||
|
||||
/** SF difference limit violation risk. Must re-clamp. */
|
||||
prev = -1;
|
||||
for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
|
||||
for (g = 0; g < sce->ics.num_swb; g++) {
|
||||
if (!sce->zeroes[w*16+g]) {
|
||||
int prevsf = sce->sf_idx[w*16+g];
|
||||
if (prev < 0)
|
||||
prev = prevsf;
|
||||
sce->sf_idx[w*16+g] = av_clip(sce->sf_idx[w*16+g], prev - SCALE_MAX_DIFF, prev + SCALE_MAX_DIFF);
|
||||
sce->band_type[w*16+g] = find_min_book(maxvals[w*16+g], sce->sf_idx[w*16+g]);
|
||||
prev = sce->sf_idx[w*16+g];
|
||||
if (!fflag && prevsf != sce->sf_idx[w*16+g])
|
||||
fflag = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
its++;
|
||||
} while (fflag && its < maxits);
|
||||
|
||||
/** Scout out next nonzero bands */
|
||||
ff_init_nextband_map(sce, nextband);
|
||||
|
||||
prev = -1;
|
||||
for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
|
||||
/** Make sure proper codebooks are set */
|
||||
for (g = 0; g < sce->ics.num_swb; g++) {
|
||||
if (!sce->zeroes[w*16+g]) {
|
||||
sce->band_type[w*16+g] = find_min_book(maxvals[w*16+g], sce->sf_idx[w*16+g]);
|
||||
if (sce->band_type[w*16+g] <= 0) {
|
||||
if (!ff_sfdelta_can_remove_band(sce, nextband, prev, w*16+g)) {
|
||||
/** Cannot zero out, make sure it's not attempted */
|
||||
sce->band_type[w*16+g] = 1;
|
||||
} else {
|
||||
sce->zeroes[w*16+g] = 1;
|
||||
sce->band_type[w*16+g] = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sce->band_type[w*16+g] = 0;
|
||||
}
|
||||
/** Check that there's no SF delta range violations */
|
||||
if (!sce->zeroes[w*16+g]) {
|
||||
if (prev != -1) {
|
||||
av_unused int sfdiff = sce->sf_idx[w*16+g] - prev + SCALE_DIFF_ZERO;
|
||||
av_assert1(sfdiff >= 0 && sfdiff <= 2*SCALE_MAX_DIFF);
|
||||
} else if (sce->zeroes[0]) {
|
||||
/** Set global gain to something useful */
|
||||
sce->sf_idx[0] = sce->sf_idx[w*16+g];
|
||||
}
|
||||
prev = sce->sf_idx[w*16+g];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* AVCODEC_AACCODER_TWOLOOP_H */
|
||||
261
include/libavcodec/aacenc.h
Normal file
261
include/libavcodec/aacenc.h
Normal file
@@ -0,0 +1,261 @@
|
||||
/*
|
||||
* AAC encoder
|
||||
* Copyright (C) 2008 Konstantin Shishkov
|
||||
*
|
||||
* 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_AACENC_H
|
||||
#define AVCODEC_AACENC_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libavutil/channel_layout.h"
|
||||
#include "libavutil/float_dsp.h"
|
||||
#include "libavutil/mem_internal.h"
|
||||
#include "libavutil/tx.h"
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "put_bits.h"
|
||||
|
||||
#include "aac.h"
|
||||
#include "aacencdsp.h"
|
||||
#include "audio_frame_queue.h"
|
||||
#include "psymodel.h"
|
||||
|
||||
#include "lpc.h"
|
||||
|
||||
#define CLIP_AVOIDANCE_FACTOR 0.95f
|
||||
|
||||
typedef enum AACCoder {
|
||||
AAC_CODER_ANMR = 0,
|
||||
AAC_CODER_TWOLOOP,
|
||||
AAC_CODER_FAST,
|
||||
|
||||
AAC_CODER_NB,
|
||||
}AACCoder;
|
||||
|
||||
/**
|
||||
* Predictor State
|
||||
*/
|
||||
typedef struct PredictorState {
|
||||
float cor0;
|
||||
float cor1;
|
||||
float var0;
|
||||
float var1;
|
||||
float r0;
|
||||
float r1;
|
||||
float k1;
|
||||
float x_est;
|
||||
} PredictorState;
|
||||
|
||||
typedef struct AACEncOptions {
|
||||
int coder;
|
||||
int pns;
|
||||
int tns;
|
||||
int ltp;
|
||||
int pce;
|
||||
int pred;
|
||||
int mid_side;
|
||||
int intensity_stereo;
|
||||
} AACEncOptions;
|
||||
|
||||
/**
|
||||
* Long Term Prediction
|
||||
*/
|
||||
typedef struct LongTermPrediction {
|
||||
int8_t present;
|
||||
int16_t lag;
|
||||
int coef_idx;
|
||||
float coef;
|
||||
int8_t used[MAX_LTP_LONG_SFB];
|
||||
} LongTermPrediction;
|
||||
|
||||
/**
|
||||
* Individual Channel Stream
|
||||
*/
|
||||
typedef struct IndividualChannelStream {
|
||||
uint8_t max_sfb; ///< number of scalefactor bands per group
|
||||
enum WindowSequence window_sequence[2];
|
||||
uint8_t use_kb_window[2]; ///< If set, use Kaiser-Bessel window, otherwise use a sine window.
|
||||
uint8_t group_len[8];
|
||||
LongTermPrediction ltp;
|
||||
const uint16_t *swb_offset; ///< table of offsets to the lowest spectral coefficient of a scalefactor band, sfb, for a particular window
|
||||
const uint8_t *swb_sizes; ///< table of scalefactor band sizes for a particular window
|
||||
int num_swb; ///< number of scalefactor window bands
|
||||
int num_windows;
|
||||
int tns_max_bands;
|
||||
int predictor_present;
|
||||
int predictor_initialized;
|
||||
int predictor_reset_group;
|
||||
int predictor_reset_count[31]; ///< used to count prediction resets
|
||||
uint8_t prediction_used[41];
|
||||
uint8_t window_clipping[8]; ///< set if a certain window is near clipping
|
||||
float clip_avoidance_factor; ///< set if any window is near clipping to the necessary atennuation factor to avoid it
|
||||
} IndividualChannelStream;
|
||||
|
||||
/**
|
||||
* Temporal Noise Shaping
|
||||
*/
|
||||
typedef struct TemporalNoiseShaping {
|
||||
int present;
|
||||
int n_filt[8];
|
||||
int length[8][4];
|
||||
int direction[8][4];
|
||||
int order[8][4];
|
||||
int coef_idx[8][4][TNS_MAX_ORDER];
|
||||
float coef[8][4][TNS_MAX_ORDER];
|
||||
} TemporalNoiseShaping;
|
||||
|
||||
/**
|
||||
* Single Channel Element - used for both SCE and LFE elements.
|
||||
*/
|
||||
typedef struct SingleChannelElement {
|
||||
IndividualChannelStream ics;
|
||||
TemporalNoiseShaping tns;
|
||||
Pulse pulse;
|
||||
enum BandType band_type[128]; ///< band types
|
||||
enum BandType band_alt[128]; ///< alternative band type
|
||||
int sf_idx[128]; ///< scalefactor indices
|
||||
uint8_t zeroes[128]; ///< band is not coded
|
||||
uint8_t can_pns[128]; ///< band is allowed to PNS (informative)
|
||||
float is_ener[128]; ///< Intensity stereo pos
|
||||
float pns_ener[128]; ///< Noise energy values
|
||||
DECLARE_ALIGNED(32, float, pcoeffs)[1024]; ///< coefficients for IMDCT, pristine
|
||||
DECLARE_ALIGNED(32, float, coeffs)[1024]; ///< coefficients for IMDCT, maybe processed
|
||||
DECLARE_ALIGNED(32, float, ret_buf)[2048]; ///< PCM output buffer
|
||||
DECLARE_ALIGNED(16, float, ltp_state)[3072]; ///< time signal for LTP
|
||||
DECLARE_ALIGNED(32, float, lcoeffs)[1024]; ///< MDCT of LTP coefficients
|
||||
DECLARE_ALIGNED(32, float, prcoeffs)[1024]; ///< Main prediction coefs
|
||||
PredictorState predictor_state[MAX_PREDICTORS];
|
||||
} SingleChannelElement;
|
||||
|
||||
/**
|
||||
* channel element - generic struct for SCE/CPE/CCE/LFE
|
||||
*/
|
||||
typedef struct ChannelElement {
|
||||
// CPE specific
|
||||
int common_window; ///< Set if channels share a common 'IndividualChannelStream' in bitstream.
|
||||
int ms_mode; ///< Signals mid/side stereo flags coding mode
|
||||
uint8_t is_mode; ///< Set if any bands have been encoded using intensity stereo
|
||||
uint8_t ms_mask[128]; ///< Set if mid/side stereo is used for each scalefactor window band
|
||||
uint8_t is_mask[128]; ///< Set if intensity stereo is used
|
||||
// shared
|
||||
SingleChannelElement ch[2];
|
||||
} ChannelElement;
|
||||
|
||||
struct AACEncContext;
|
||||
|
||||
typedef struct AACCoefficientsEncoder {
|
||||
void (*search_for_quantizers)(AVCodecContext *avctx, struct AACEncContext *s,
|
||||
SingleChannelElement *sce, const float lambda);
|
||||
void (*encode_window_bands_info)(struct AACEncContext *s, SingleChannelElement *sce,
|
||||
int win, int group_len, const float lambda);
|
||||
void (*quantize_and_encode_band)(struct AACEncContext *s, PutBitContext *pb, const float *in, float *out, int size,
|
||||
int scale_idx, int cb, const float lambda, int rtz);
|
||||
void (*encode_tns_info)(struct AACEncContext *s, SingleChannelElement *sce);
|
||||
void (*encode_ltp_info)(struct AACEncContext *s, SingleChannelElement *sce, int common_window);
|
||||
void (*encode_main_pred)(struct AACEncContext *s, SingleChannelElement *sce);
|
||||
void (*adjust_common_pred)(struct AACEncContext *s, ChannelElement *cpe);
|
||||
void (*adjust_common_ltp)(struct AACEncContext *s, ChannelElement *cpe);
|
||||
void (*apply_main_pred)(struct AACEncContext *s, SingleChannelElement *sce);
|
||||
void (*apply_tns_filt)(struct AACEncContext *s, SingleChannelElement *sce);
|
||||
void (*update_ltp)(struct AACEncContext *s, SingleChannelElement *sce);
|
||||
void (*ltp_insert_new_frame)(struct AACEncContext *s);
|
||||
void (*set_special_band_scalefactors)(struct AACEncContext *s, SingleChannelElement *sce);
|
||||
void (*search_for_pns)(struct AACEncContext *s, AVCodecContext *avctx, SingleChannelElement *sce);
|
||||
void (*mark_pns)(struct AACEncContext *s, AVCodecContext *avctx, SingleChannelElement *sce);
|
||||
void (*search_for_tns)(struct AACEncContext *s, SingleChannelElement *sce);
|
||||
void (*search_for_ltp)(struct AACEncContext *s, SingleChannelElement *sce, int common_window);
|
||||
void (*search_for_ms)(struct AACEncContext *s, ChannelElement *cpe);
|
||||
void (*search_for_is)(struct AACEncContext *s, AVCodecContext *avctx, ChannelElement *cpe);
|
||||
void (*search_for_pred)(struct AACEncContext *s, SingleChannelElement *sce);
|
||||
} AACCoefficientsEncoder;
|
||||
|
||||
extern const AACCoefficientsEncoder ff_aac_coders[];
|
||||
|
||||
typedef struct AACQuantizeBandCostCacheEntry {
|
||||
float rd;
|
||||
float energy;
|
||||
int bits;
|
||||
char cb;
|
||||
char rtz;
|
||||
uint16_t generation;
|
||||
} AACQuantizeBandCostCacheEntry;
|
||||
|
||||
typedef struct AACPCEInfo {
|
||||
AVChannelLayout layout;
|
||||
int num_ele[4]; ///< front, side, back, lfe
|
||||
int pairing[3][8]; ///< front, side, back
|
||||
int index[4][8]; ///< front, side, back, lfe
|
||||
uint8_t config_map[16]; ///< configs the encoder's channel specific settings
|
||||
uint8_t reorder_map[16]; ///< maps channels from lavc to aac order
|
||||
} AACPCEInfo;
|
||||
|
||||
/**
|
||||
* AAC encoder context
|
||||
*/
|
||||
typedef struct AACEncContext {
|
||||
AVClass *av_class;
|
||||
AACEncOptions options; ///< encoding options
|
||||
PutBitContext pb;
|
||||
AVTXContext *mdct1024; ///< long (1024 samples) frame transform context
|
||||
av_tx_fn mdct1024_fn;
|
||||
AVTXContext *mdct128; ///< short (128 samples) frame transform context
|
||||
av_tx_fn mdct128_fn;
|
||||
AVFloatDSPContext *fdsp;
|
||||
AACPCEInfo pce; ///< PCE data, if needed
|
||||
float *planar_samples[16]; ///< saved preprocessed input
|
||||
|
||||
int profile; ///< copied from avctx
|
||||
int needs_pce; ///< flag for non-standard layout
|
||||
LPCContext lpc; ///< used by TNS
|
||||
int samplerate_index; ///< MPEG-4 samplerate index
|
||||
int channels; ///< channel count
|
||||
const uint8_t *reorder_map; ///< lavc to aac reorder map
|
||||
const uint8_t *chan_map; ///< channel configuration map
|
||||
|
||||
ChannelElement *cpe; ///< channel elements
|
||||
FFPsyContext psy;
|
||||
struct FFPsyPreprocessContext* psypp;
|
||||
const AACCoefficientsEncoder *coder;
|
||||
int cur_channel; ///< current channel for coder context
|
||||
int random_state;
|
||||
float lambda;
|
||||
int last_frame_pb_count; ///< number of bits for the previous frame
|
||||
float lambda_sum; ///< sum(lambda), for Qvg reporting
|
||||
int lambda_count; ///< count(lambda), for Qvg reporting
|
||||
enum RawDataBlockType cur_type; ///< channel group type cur_channel belongs to
|
||||
|
||||
AudioFrameQueue afq;
|
||||
DECLARE_ALIGNED(32, int, qcoefs)[96]; ///< quantized coefficients
|
||||
DECLARE_ALIGNED(32, float, scoefs)[1024]; ///< scaled coefficients
|
||||
|
||||
uint16_t quantize_band_cost_cache_generation;
|
||||
AACQuantizeBandCostCacheEntry quantize_band_cost_cache[256][128]; ///< memoization area for quantize_band_cost
|
||||
|
||||
AACEncDSPContext aacdsp;
|
||||
|
||||
struct {
|
||||
float *samples;
|
||||
} buffer;
|
||||
} AACEncContext;
|
||||
|
||||
void ff_quantize_band_cost_cache_init(struct AACEncContext *s);
|
||||
|
||||
|
||||
#endif /* AVCODEC_AACENC_H */
|
||||
51
include/libavcodec/aacenc_is.h
Normal file
51
include/libavcodec/aacenc_is.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* AAC encoder intensity stereo
|
||||
* Copyright (C) 2015 Rostislav Pehlivanov
|
||||
*
|
||||
* 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
|
||||
* AAC encoder Intensity Stereo
|
||||
* @author Rostislav Pehlivanov ( atomnuker gmail com )
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_AACENC_IS_H
|
||||
#define AVCODEC_AACENC_IS_H
|
||||
|
||||
#include "aacenc.h"
|
||||
|
||||
/** Frequency in Hz for lower limit of intensity stereo **/
|
||||
#define INT_STEREO_LOW_LIMIT 6100
|
||||
|
||||
struct AACISError {
|
||||
int pass; /* 1 if dist2 <= dist1 */
|
||||
int phase; /* -1 or +1 */
|
||||
float error; /* fabs(dist1 - dist2) */
|
||||
float dist1; /* From original coeffs */
|
||||
float dist2; /* From IS'd coeffs */
|
||||
float ener01;
|
||||
};
|
||||
|
||||
struct AACISError ff_aac_is_encoding_err(AACEncContext *s, ChannelElement *cpe,
|
||||
int start, int w, int g, float ener0,
|
||||
float ener1, float ener01,
|
||||
int use_pcoeffs, int phase);
|
||||
void ff_aac_search_for_is(AACEncContext *s, AVCodecContext *avctx, ChannelElement *cpe);
|
||||
|
||||
#endif /* AVCODEC_AACENC_IS_H */
|
||||
41
include/libavcodec/aacenc_ltp.h
Normal file
41
include/libavcodec/aacenc_ltp.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* AAC encoder long term prediction extension
|
||||
* Copyright (C) 2015 Rostislav Pehlivanov
|
||||
*
|
||||
* 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
|
||||
* AAC encoder long term prediction extension
|
||||
* @author Rostislav Pehlivanov ( atomnuker gmail com )
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_AACENC_LTP_H
|
||||
#define AVCODEC_AACENC_LTP_H
|
||||
|
||||
#include "aacenc.h"
|
||||
|
||||
void ff_aac_encode_ltp_info(AACEncContext *s, SingleChannelElement *sce,
|
||||
int common_window);
|
||||
void ff_aac_update_ltp(AACEncContext *s, SingleChannelElement *sce);
|
||||
void ff_aac_adjust_common_ltp(AACEncContext *s, ChannelElement *cpe);
|
||||
void ff_aac_ltp_insert_new_frame(AACEncContext *s);
|
||||
void ff_aac_search_for_ltp(AACEncContext *s, SingleChannelElement *sce,
|
||||
int common_window);
|
||||
|
||||
#endif /* AVCODEC_AACENC_LTP_H */
|
||||
47
include/libavcodec/aacenc_pred.h
Normal file
47
include/libavcodec/aacenc_pred.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* AAC encoder main-type prediction
|
||||
* Copyright (C) 2015 Rostislav Pehlivanov
|
||||
*
|
||||
* 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
|
||||
* AAC encoder main-type prediction
|
||||
* @author Rostislav Pehlivanov ( atomnuker gmail com )
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_AACENC_PRED_H
|
||||
#define AVCODEC_AACENC_PRED_H
|
||||
|
||||
#include "aacenc.h"
|
||||
|
||||
/* Every predictor group needs to get reset at least once in this many frames */
|
||||
#define PRED_RESET_FRAME_MIN 240
|
||||
|
||||
/* Any frame with less than this amount of frames since last reset is ok */
|
||||
#define PRED_RESET_MIN 64
|
||||
|
||||
/* Raise to filter any low frequency artifacts due to prediction */
|
||||
#define PRED_SFB_START 10
|
||||
|
||||
void ff_aac_apply_main_pred(AACEncContext *s, SingleChannelElement *sce);
|
||||
void ff_aac_adjust_common_pred(AACEncContext *s, ChannelElement *cpe);
|
||||
void ff_aac_search_for_pred(AACEncContext *s, SingleChannelElement *sce);
|
||||
void ff_aac_encode_main_pred(AACEncContext *s, SingleChannelElement *sce);
|
||||
|
||||
#endif /* AVCODEC_AACENC_PRED_H */
|
||||
68
include/libavcodec/aacenc_quantization.h
Normal file
68
include/libavcodec/aacenc_quantization.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* AAC encoder quantizer
|
||||
* Copyright (C) 2015 Rostislav Pehlivanov
|
||||
*
|
||||
* 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
|
||||
* AAC encoder quantizer
|
||||
* @author Rostislav Pehlivanov ( atomnuker gmail com )
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_AACENC_QUANTIZATION_H
|
||||
#define AVCODEC_AACENC_QUANTIZATION_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "aacenc.h"
|
||||
#include "put_bits.h"
|
||||
|
||||
|
||||
float ff_quantize_and_encode_band_cost(AACEncContext *s, PutBitContext *pb,
|
||||
const float *in, float *quant, const float *scaled,
|
||||
int size, int scale_idx, int cb,
|
||||
const float lambda, const float uplim,
|
||||
int *bits, float *energy);
|
||||
|
||||
static inline float quantize_band_cost(struct AACEncContext *s, const float *in,
|
||||
const float *scaled, int size, int scale_idx,
|
||||
int cb, const float lambda, const float uplim,
|
||||
int *bits, float *energy)
|
||||
{
|
||||
return ff_quantize_and_encode_band_cost(s, NULL, in, NULL, scaled, size, scale_idx,
|
||||
cb, lambda, uplim, bits, energy);
|
||||
}
|
||||
|
||||
static inline int quantize_band_cost_bits(struct AACEncContext *s, const float *in,
|
||||
const float *scaled, int size, int scale_idx,
|
||||
int cb, const float lambda, const float uplim,
|
||||
int *bits, float *energy)
|
||||
{
|
||||
int auxbits;
|
||||
ff_quantize_and_encode_band_cost(s, NULL, in, NULL, scaled, size, scale_idx,
|
||||
cb, 0.0f, uplim, &auxbits, energy);
|
||||
if (bits) {
|
||||
*bits = auxbits;
|
||||
}
|
||||
return auxbits;
|
||||
}
|
||||
|
||||
#include "aacenc_quantization_misc.h"
|
||||
|
||||
#endif /* AVCODEC_AACENC_QUANTIZATION_H */
|
||||
53
include/libavcodec/aacenc_quantization_misc.h
Normal file
53
include/libavcodec/aacenc_quantization_misc.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* AAC encoder quantization
|
||||
* Copyright (C) 2015 Claudio Freire
|
||||
*
|
||||
* 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
|
||||
* AAC encoder quantization misc reusable function templates
|
||||
* @author Claudio Freire ( klaussfreire gmail com )
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_AACENC_QUANTIZATION_MISC_H
|
||||
#define AVCODEC_AACENC_QUANTIZATION_MISC_H
|
||||
|
||||
static inline float quantize_band_cost_cached(struct AACEncContext *s, int w, int g, const float *in,
|
||||
const float *scaled, int size, int scale_idx,
|
||||
int cb, const float lambda, const float uplim,
|
||||
int *bits, float *energy, int rtz)
|
||||
{
|
||||
AACQuantizeBandCostCacheEntry *entry;
|
||||
av_assert1(scale_idx >= 0 && scale_idx < 256);
|
||||
entry = &s->quantize_band_cost_cache[scale_idx][w*16+g];
|
||||
if (entry->generation != s->quantize_band_cost_cache_generation || entry->cb != cb || entry->rtz != rtz) {
|
||||
entry->rd = quantize_band_cost(s, in, scaled, size, scale_idx,
|
||||
cb, lambda, uplim, &entry->bits, &entry->energy);
|
||||
entry->cb = cb;
|
||||
entry->rtz = rtz;
|
||||
entry->generation = s->quantize_band_cost_cache_generation;
|
||||
}
|
||||
if (bits)
|
||||
*bits = entry->bits;
|
||||
if (energy)
|
||||
*energy = entry->energy;
|
||||
return entry->rd;
|
||||
}
|
||||
|
||||
#endif /* AVCODEC_AACENC_QUANTIZATION_MISC_H */
|
||||
37
include/libavcodec/aacenc_tns.h
Normal file
37
include/libavcodec/aacenc_tns.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* AAC encoder TNS
|
||||
* Copyright (C) 2015 Rostislav Pehlivanov
|
||||
*
|
||||
* 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
|
||||
* AAC encoder temporal noise shaping
|
||||
* @author Rostislav Pehlivanov ( atomnuker gmail com )
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_AACENC_TNS_H
|
||||
#define AVCODEC_AACENC_TNS_H
|
||||
|
||||
#include "aacenc.h"
|
||||
|
||||
void ff_aac_encode_tns_info(AACEncContext *s, SingleChannelElement *sce);
|
||||
void ff_aac_apply_tns(AACEncContext *s, SingleChannelElement *sce);
|
||||
void ff_aac_search_for_tns(AACEncContext *s, SingleChannelElement *sce);
|
||||
|
||||
#endif /* AVCODEC_AACENC_TNS_H */
|
||||
255
include/libavcodec/aacenc_utils.h
Normal file
255
include/libavcodec/aacenc_utils.h
Normal file
@@ -0,0 +1,255 @@
|
||||
/*
|
||||
* AAC encoder utilities
|
||||
* Copyright (C) 2015 Rostislav Pehlivanov
|
||||
*
|
||||
* 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
|
||||
* AAC encoder utilities
|
||||
* @author Rostislav Pehlivanov ( atomnuker gmail com )
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_AACENC_UTILS_H
|
||||
#define AVCODEC_AACENC_UTILS_H
|
||||
|
||||
#include "libavutil/ffmath.h"
|
||||
#include "aacenc.h"
|
||||
#include "aacenctab.h"
|
||||
#include "aactab.h"
|
||||
|
||||
#define ROUND_STANDARD 0.4054f
|
||||
#define ROUND_TO_ZERO 0.1054f
|
||||
#define C_QUANT 0.4054f
|
||||
|
||||
static inline float pos_pow34(float a)
|
||||
{
|
||||
return sqrtf(a * sqrtf(a));
|
||||
}
|
||||
|
||||
/**
|
||||
* Quantize one coefficient.
|
||||
* @return absolute value of the quantized coefficient
|
||||
* @see 3GPP TS26.403 5.6.2 "Scalefactor determination"
|
||||
*/
|
||||
static inline int quant(float coef, const float Q, const float rounding)
|
||||
{
|
||||
float a = coef * Q;
|
||||
return sqrtf(a * sqrtf(a)) + rounding;
|
||||
}
|
||||
|
||||
static inline float find_max_val(int group_len, int swb_size, const float *scaled)
|
||||
{
|
||||
float maxval = 0.0f;
|
||||
int w2, i;
|
||||
for (w2 = 0; w2 < group_len; w2++) {
|
||||
for (i = 0; i < swb_size; i++) {
|
||||
maxval = FFMAX(maxval, scaled[w2*128+i]);
|
||||
}
|
||||
}
|
||||
return maxval;
|
||||
}
|
||||
|
||||
static inline int find_min_book(float maxval, int sf)
|
||||
{
|
||||
float Q34 = ff_aac_pow34sf_tab[POW_SF2_ZERO - sf + SCALE_ONE_POS - SCALE_DIV_512];
|
||||
int qmaxval, cb;
|
||||
qmaxval = maxval * Q34 + C_QUANT;
|
||||
if (qmaxval >= (FF_ARRAY_ELEMS(aac_maxval_cb)))
|
||||
cb = 11;
|
||||
else
|
||||
cb = aac_maxval_cb[qmaxval];
|
||||
return cb;
|
||||
}
|
||||
|
||||
static inline float find_form_factor(int group_len, int swb_size, float thresh,
|
||||
const float *scaled, float nzslope) {
|
||||
const float iswb_size = 1.0f / swb_size;
|
||||
const float iswb_sizem1 = 1.0f / (swb_size - 1);
|
||||
const float ethresh = thresh;
|
||||
float form = 0.0f, weight = 0.0f;
|
||||
int w2, i;
|
||||
for (w2 = 0; w2 < group_len; w2++) {
|
||||
float e = 0.0f, e2 = 0.0f, var = 0.0f, maxval = 0.0f;
|
||||
float nzl = 0;
|
||||
for (i = 0; i < swb_size; i++) {
|
||||
float s = fabsf(scaled[w2*128+i]);
|
||||
maxval = FFMAX(maxval, s);
|
||||
e += s;
|
||||
e2 += s *= s;
|
||||
/* We really don't want a hard non-zero-line count, since
|
||||
* even below-threshold lines do add up towards band spectral power.
|
||||
* So, fall steeply towards zero, but smoothly
|
||||
*/
|
||||
if (s >= ethresh) {
|
||||
nzl += 1.0f;
|
||||
} else {
|
||||
if (nzslope == 2.f)
|
||||
nzl += (s / ethresh) * (s / ethresh);
|
||||
else
|
||||
nzl += ff_fast_powf(s / ethresh, nzslope);
|
||||
}
|
||||
}
|
||||
if (e2 > thresh) {
|
||||
float frm;
|
||||
e *= iswb_size;
|
||||
|
||||
/** compute variance */
|
||||
for (i = 0; i < swb_size; i++) {
|
||||
float d = fabsf(scaled[w2*128+i]) - e;
|
||||
var += d*d;
|
||||
}
|
||||
var = sqrtf(var * iswb_sizem1);
|
||||
|
||||
e2 *= iswb_size;
|
||||
frm = e / FFMIN(e+4*var,maxval);
|
||||
form += e2 * sqrtf(frm) / FFMAX(0.5f,nzl);
|
||||
weight += e2;
|
||||
}
|
||||
}
|
||||
if (weight > 0) {
|
||||
return form / weight;
|
||||
} else {
|
||||
return 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
/** Return the minimum scalefactor where the quantized coef does not clip. */
|
||||
static inline uint8_t coef2minsf(float coef)
|
||||
{
|
||||
return av_clip_uint8(log2f(coef)*4 - 69 + SCALE_ONE_POS - SCALE_DIV_512);
|
||||
}
|
||||
|
||||
/** Return the maximum scalefactor where the quantized coef is not zero. */
|
||||
static inline uint8_t coef2maxsf(float coef)
|
||||
{
|
||||
return av_clip_uint8(log2f(coef)*4 + 6 + SCALE_ONE_POS - SCALE_DIV_512);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the closest possible index to an array of float values, given a value.
|
||||
*/
|
||||
static inline int quant_array_idx(const float val, const float *arr, const int num)
|
||||
{
|
||||
int i, index = 0;
|
||||
float quant_min_err = INFINITY;
|
||||
for (i = 0; i < num; i++) {
|
||||
float error = (val - arr[i])*(val - arr[i]);
|
||||
if (error < quant_min_err) {
|
||||
quant_min_err = error;
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
/**
|
||||
* approximates exp10f(-3.0f*(0.5f + 0.5f * cosf(FFMIN(b,15.5f) / 15.5f)))
|
||||
*/
|
||||
static av_always_inline float bval2bmax(float b)
|
||||
{
|
||||
return 0.001f + 0.0035f * (b*b*b) / (15.5f*15.5f*15.5f);
|
||||
}
|
||||
|
||||
/*
|
||||
* Compute a nextband map to be used with SF delta constraint utilities.
|
||||
* The nextband array should contain 128 elements, and positions that don't
|
||||
* map to valid, nonzero bands of the form w*16+g (with w being the initial
|
||||
* window of the window group, only) are left indetermined.
|
||||
*/
|
||||
static inline void ff_init_nextband_map(const SingleChannelElement *sce, uint8_t *nextband)
|
||||
{
|
||||
unsigned char prevband = 0;
|
||||
int w, g;
|
||||
/** Just a safe default */
|
||||
for (g = 0; g < 128; g++)
|
||||
nextband[g] = g;
|
||||
|
||||
/** Now really navigate the nonzero band chain */
|
||||
for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
|
||||
for (g = 0; g < sce->ics.num_swb; g++) {
|
||||
if (!sce->zeroes[w*16+g] && sce->band_type[w*16+g] < RESERVED_BT)
|
||||
prevband = nextband[prevband] = w*16+g;
|
||||
}
|
||||
}
|
||||
nextband[prevband] = prevband; /* terminate */
|
||||
}
|
||||
|
||||
/*
|
||||
* Updates nextband to reflect a removed band (equivalent to
|
||||
* calling ff_init_nextband_map after marking a band as zero)
|
||||
*/
|
||||
static inline void ff_nextband_remove(uint8_t *nextband, int prevband, int band)
|
||||
{
|
||||
nextband[prevband] = nextband[band];
|
||||
}
|
||||
|
||||
/*
|
||||
* Checks whether the specified band could be removed without inducing
|
||||
* scalefactor delta that violates SF delta encoding constraints.
|
||||
* prev_sf has to be the scalefactor of the previous nonzero, nonspecial
|
||||
* band, in encoding order, or negative if there was no such band.
|
||||
*/
|
||||
static inline int ff_sfdelta_can_remove_band(const SingleChannelElement *sce,
|
||||
const uint8_t *nextband, int prev_sf, int band)
|
||||
{
|
||||
return prev_sf >= 0
|
||||
&& sce->sf_idx[nextband[band]] >= (prev_sf - SCALE_MAX_DIFF)
|
||||
&& sce->sf_idx[nextband[band]] <= (prev_sf + SCALE_MAX_DIFF);
|
||||
}
|
||||
|
||||
/*
|
||||
* Checks whether the specified band's scalefactor could be replaced
|
||||
* with another one without violating SF delta encoding constraints.
|
||||
* prev_sf has to be the scalefactor of the previous nonzero, nonsepcial
|
||||
* band, in encoding order, or negative if there was no such band.
|
||||
*/
|
||||
static inline int ff_sfdelta_can_replace(const SingleChannelElement *sce,
|
||||
const uint8_t *nextband, int prev_sf, int new_sf, int band)
|
||||
{
|
||||
return new_sf >= (prev_sf - SCALE_MAX_DIFF)
|
||||
&& new_sf <= (prev_sf + SCALE_MAX_DIFF)
|
||||
&& sce->sf_idx[nextband[band]] >= (new_sf - SCALE_MAX_DIFF)
|
||||
&& sce->sf_idx[nextband[band]] <= (new_sf + SCALE_MAX_DIFF);
|
||||
}
|
||||
|
||||
/**
|
||||
* linear congruential pseudorandom number generator
|
||||
*
|
||||
* @param previous_val pointer to the current state of the generator
|
||||
*
|
||||
* @return Returns a 32-bit pseudorandom integer
|
||||
*/
|
||||
static av_always_inline int lcg_random(unsigned previous_val)
|
||||
{
|
||||
union { unsigned u; int s; } v = { previous_val * 1664525u + 1013904223 };
|
||||
return v.s;
|
||||
}
|
||||
|
||||
#define ERROR_IF(cond, ...) \
|
||||
if (cond) { \
|
||||
av_log(avctx, AV_LOG_ERROR, __VA_ARGS__); \
|
||||
return AVERROR(EINVAL); \
|
||||
}
|
||||
|
||||
#define WARN_IF(cond, ...) \
|
||||
if (cond) { \
|
||||
av_log(avctx, AV_LOG_WARNING, __VA_ARGS__); \
|
||||
}
|
||||
|
||||
#endif /* AVCODEC_AACENC_UTILS_H */
|
||||
72
include/libavcodec/aacencdsp.h
Normal file
72
include/libavcodec/aacencdsp.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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_AACENCDSP_H
|
||||
#define AVCODEC_AACENCDSP_H
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "libavutil/macros.h"
|
||||
|
||||
typedef struct AACEncDSPContext {
|
||||
void (*abs_pow34)(float *out, const float *in, const int size);
|
||||
void (*quant_bands)(int *out, const float *in, const float *scaled,
|
||||
int size, int is_signed, int maxval, const float Q34,
|
||||
const float rounding);
|
||||
} AACEncDSPContext;
|
||||
|
||||
void ff_aacenc_dsp_init_riscv(AACEncDSPContext *s);
|
||||
void ff_aacenc_dsp_init_x86(AACEncDSPContext *s);
|
||||
|
||||
static inline void abs_pow34_v(float *out, const float *in, const int size)
|
||||
{
|
||||
for (int i = 0; i < size; i++) {
|
||||
float a = fabsf(in[i]);
|
||||
out[i] = sqrtf(a * sqrtf(a));
|
||||
}
|
||||
}
|
||||
|
||||
static inline void quantize_bands(int *out, const float *in, const float *scaled,
|
||||
int size, int is_signed, int maxval, const float Q34,
|
||||
const float rounding)
|
||||
{
|
||||
for (int i = 0; i < size; i++) {
|
||||
float qc = scaled[i] * Q34;
|
||||
int tmp = (int)FFMIN(qc + rounding, (float)maxval);
|
||||
if (is_signed && in[i] < 0.0f) {
|
||||
tmp = -tmp;
|
||||
}
|
||||
out[i] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void ff_aacenc_dsp_init(AACEncDSPContext *s)
|
||||
{
|
||||
s->abs_pow34 = abs_pow34_v;
|
||||
s->quant_bands = quantize_bands;
|
||||
|
||||
#if ARCH_RISCV
|
||||
ff_aacenc_dsp_init_riscv(s);
|
||||
#elif ARCH_X86
|
||||
ff_aacenc_dsp_init_x86(s);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
134
include/libavcodec/aacenctab.h
Normal file
134
include/libavcodec/aacenctab.h
Normal file
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* AAC encoder data
|
||||
* Copyright (c) 2015 Rostislav Pehlivanov ( atomnuker 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
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* AAC encoder data
|
||||
* @author Rostislav Pehlivanov ( atomnuker gmail com )
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_AACENCTAB_H
|
||||
#define AVCODEC_AACENCTAB_H
|
||||
|
||||
#include "libavutil/channel_layout.h"
|
||||
#include "aac.h"
|
||||
#include "defs.h"
|
||||
|
||||
/** Total number of usable codebooks **/
|
||||
#define CB_TOT 12
|
||||
|
||||
/** Total number of codebooks, including special ones **/
|
||||
#define CB_TOT_ALL 15
|
||||
|
||||
#define AAC_MAX_CHANNELS 16
|
||||
|
||||
extern const uint8_t *const ff_aac_swb_size_1024[];
|
||||
extern const int ff_aac_swb_size_1024_len;
|
||||
extern const uint8_t *const ff_aac_swb_size_128[];
|
||||
extern const int ff_aac_swb_size_128_len;
|
||||
|
||||
/* Supported layouts without using a PCE */
|
||||
static const AVChannelLayout aac_normal_chan_layouts[7] = {
|
||||
AV_CHANNEL_LAYOUT_MONO,
|
||||
AV_CHANNEL_LAYOUT_STEREO,
|
||||
AV_CHANNEL_LAYOUT_SURROUND,
|
||||
AV_CHANNEL_LAYOUT_4POINT0,
|
||||
AV_CHANNEL_LAYOUT_5POINT0_BACK,
|
||||
AV_CHANNEL_LAYOUT_5POINT1_BACK,
|
||||
AV_CHANNEL_LAYOUT_7POINT1,
|
||||
};
|
||||
|
||||
/** default channel configurations */
|
||||
static const uint8_t aac_chan_configs[AAC_MAX_CHANNELS][6] = {
|
||||
{1, TYPE_SCE}, // 1 channel - single channel element
|
||||
{1, TYPE_CPE}, // 2 channels - channel pair
|
||||
{2, TYPE_SCE, TYPE_CPE}, // 3 channels - center + stereo
|
||||
{3, TYPE_SCE, TYPE_CPE, TYPE_SCE}, // 4 channels - front center + stereo + back center
|
||||
{3, TYPE_SCE, TYPE_CPE, TYPE_CPE}, // 5 channels - front center + stereo + back stereo
|
||||
{4, TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_LFE}, // 6 channels - front center + stereo + back stereo + LFE
|
||||
{0}, // 7 channels - invalid without PCE
|
||||
{5, TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_CPE, TYPE_LFE}, // 8 channels - front center + front stereo + side stereo + back stereo + LFE
|
||||
};
|
||||
|
||||
/**
|
||||
* Table to remap channels from libavcodec's default order to AAC order.
|
||||
*/
|
||||
static const uint8_t aac_chan_maps[AAC_MAX_CHANNELS][AAC_MAX_CHANNELS] = {
|
||||
{ 0 },
|
||||
{ 0, 1 },
|
||||
{ 2, 0, 1 },
|
||||
{ 2, 0, 1, 3 },
|
||||
{ 2, 0, 1, 3, 4 },
|
||||
{ 2, 0, 1, 4, 5, 3 },
|
||||
{ 0 },
|
||||
{ 2, 0, 1, 6, 7, 4, 5, 3 },
|
||||
};
|
||||
|
||||
/** bits needed to code codebook run value for long windows */
|
||||
static const uint8_t run_value_bits_long[64] = {
|
||||
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 15
|
||||
};
|
||||
|
||||
/** bits needed to code codebook run value for short windows */
|
||||
static const uint8_t run_value_bits_short[16] = {
|
||||
3, 3, 3, 3, 3, 3, 3, 6, 6, 6, 6, 6, 6, 6, 6, 9
|
||||
};
|
||||
|
||||
/* TNS starting SFBs for long and short windows */
|
||||
static const uint8_t tns_min_sfb_short[16] = {
|
||||
2, 2, 2, 3, 3, 4, 6, 6, 8, 10, 10, 12, 12, 12, 12, 12
|
||||
};
|
||||
|
||||
static const uint8_t tns_min_sfb_long[16] = {
|
||||
12, 13, 15, 16, 17, 20, 25, 26, 24, 28, 30, 31, 31, 31, 31, 31
|
||||
};
|
||||
|
||||
static const uint8_t * const tns_min_sfb[2] = {
|
||||
tns_min_sfb_long, tns_min_sfb_short
|
||||
};
|
||||
|
||||
static const uint8_t * const run_value_bits[2] = {
|
||||
run_value_bits_long, run_value_bits_short
|
||||
};
|
||||
|
||||
/** Map to convert values from BandCodingPath index to a codebook index **/
|
||||
static const uint8_t aac_cb_out_map[CB_TOT_ALL] = {0,1,2,3,4,5,6,7,8,9,10,11,13,14,15};
|
||||
/** Inverse map to convert from codebooks to BandCodingPath indices **/
|
||||
static const uint8_t aac_cb_in_map[CB_TOT_ALL+1] = {0,1,2,3,4,5,6,7,8,9,10,11,0,12,13,14};
|
||||
|
||||
static const uint8_t aac_cb_range [12] = {0, 3, 3, 3, 3, 9, 9, 8, 8, 13, 13, 17};
|
||||
static const uint8_t aac_cb_maxval[12] = {0, 1, 1, 2, 2, 4, 4, 7, 7, 12, 12, 16};
|
||||
|
||||
static const unsigned char aac_maxval_cb[] = {
|
||||
0, 1, 3, 5, 5, 7, 7, 7, 9, 9, 9, 9, 9, 11
|
||||
};
|
||||
|
||||
static const int aacenc_profiles[] = {
|
||||
AV_PROFILE_AAC_MAIN,
|
||||
AV_PROFILE_AAC_LOW,
|
||||
AV_PROFILE_AAC_LTP,
|
||||
AV_PROFILE_MPEG2_AAC_LOW,
|
||||
};
|
||||
|
||||
#endif /* AVCODEC_AACENCTAB_H */
|
||||
106
include/libavcodec/aacps.h
Normal file
106
include/libavcodec/aacps.h
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* MPEG-4 Parametric Stereo definitions and declarations
|
||||
* Copyright (c) 2010 Alex Converse <alex.converse@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 AVCODEC_AACPS_H
|
||||
#define AVCODEC_AACPS_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libavutil/mem_internal.h"
|
||||
|
||||
#include "aacpsdsp.h"
|
||||
#include "get_bits.h"
|
||||
|
||||
#define PS_MAX_NUM_ENV 5
|
||||
#define PS_MAX_NR_IIDICC 34
|
||||
#define PS_MAX_NR_IPDOPD 17
|
||||
#define PS_MAX_SSB 91
|
||||
#define PS_MAX_AP_BANDS 50
|
||||
#define PS_QMF_TIME_SLOTS 32
|
||||
#define PS_MAX_DELAY 14
|
||||
#define PS_AP_LINKS 3
|
||||
#define PS_MAX_AP_DELAY 5
|
||||
#define PS_BASELINE 0 ///< Operate in Baseline PS mode
|
||||
///< Baseline implies 10 or 20 stereo bands,
|
||||
///< mixing mode A, and no ipd/opd
|
||||
|
||||
#define numQMFSlots 32 //numTimeSlots * RATE
|
||||
|
||||
typedef struct PSCommonContext {
|
||||
int start;
|
||||
int enable_iid;
|
||||
int iid_quant;
|
||||
int nr_iid_par;
|
||||
int nr_ipdopd_par;
|
||||
int enable_icc;
|
||||
int icc_mode;
|
||||
int nr_icc_par;
|
||||
int enable_ext;
|
||||
int frame_class;
|
||||
int num_env_old;
|
||||
int num_env;
|
||||
int enable_ipdopd;
|
||||
int border_position[PS_MAX_NUM_ENV+1];
|
||||
int8_t iid_par[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; ///< Inter-channel Intensity Difference Parameters
|
||||
int8_t icc_par[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; ///< Inter-Channel Coherence Parameters
|
||||
/* ipd/opd is iid/icc sized so that the same functions can handle both */
|
||||
int8_t ipd_par[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; ///< Inter-channel Phase Difference Parameters
|
||||
int8_t opd_par[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; ///< Overall Phase Difference Parameters
|
||||
int is34bands;
|
||||
int is34bands_old;
|
||||
} PSCommonContext;
|
||||
|
||||
typedef struct PSContext {
|
||||
PSCommonContext common;
|
||||
|
||||
DECLARE_ALIGNED(16, INTFLOAT, in_buf)[5][44][2];
|
||||
DECLARE_ALIGNED(16, INTFLOAT, delay)[PS_MAX_SSB][PS_QMF_TIME_SLOTS + PS_MAX_DELAY][2];
|
||||
DECLARE_ALIGNED(16, INTFLOAT, ap_delay)[PS_MAX_AP_BANDS][PS_AP_LINKS][PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2];
|
||||
DECLARE_ALIGNED(16, INTFLOAT, peak_decay_nrg)[34];
|
||||
DECLARE_ALIGNED(16, INTFLOAT, power_smooth)[34];
|
||||
DECLARE_ALIGNED(16, INTFLOAT, peak_decay_diff_smooth)[34];
|
||||
DECLARE_ALIGNED(16, INTFLOAT, H11)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC];
|
||||
DECLARE_ALIGNED(16, INTFLOAT, H12)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC];
|
||||
DECLARE_ALIGNED(16, INTFLOAT, H21)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC];
|
||||
DECLARE_ALIGNED(16, INTFLOAT, H22)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC];
|
||||
DECLARE_ALIGNED(16, INTFLOAT, Lbuf)[91][32][2];
|
||||
DECLARE_ALIGNED(16, INTFLOAT, Rbuf)[91][32][2];
|
||||
int8_t opd_hist[PS_MAX_NR_IIDICC];
|
||||
int8_t ipd_hist[PS_MAX_NR_IIDICC];
|
||||
PSDSPContext dsp;
|
||||
} PSContext;
|
||||
|
||||
extern const int8_t ff_k_to_i_20[];
|
||||
extern const int8_t ff_k_to_i_34[];
|
||||
|
||||
void ff_ps_init_common(void);
|
||||
void AAC_RENAME(ff_ps_init)(void);
|
||||
|
||||
static inline void AAC_RENAME(ff_ps_ctx_init)(PSContext *ps)
|
||||
{
|
||||
AAC_RENAME(ff_psdsp_init)(&ps->dsp);
|
||||
}
|
||||
|
||||
int ff_ps_read_data(void *logctx, GetBitContext *gb,
|
||||
PSCommonContext *ps, int bits_left);
|
||||
int AAC_RENAME(ff_ps_apply)(PSContext *ps, INTFLOAT L[2][38][64], INTFLOAT R[2][38][64], int top);
|
||||
|
||||
#endif /* AVCODEC_AACPS_H */
|
||||
408
include/libavcodec/aacps_fixed_tablegen.h
Normal file
408
include/libavcodec/aacps_fixed_tablegen.h
Normal file
@@ -0,0 +1,408 @@
|
||||
/*
|
||||
* Header file for hardcoded Parametric Stereo tables
|
||||
*
|
||||
* Copyright (c) 2010 Alex Converse <alex.converse@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
|
||||
*
|
||||
* Note: Rounding-to-nearest used unless otherwise stated
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_AACPS_FIXED_TABLEGEN_H
|
||||
#define AVCODEC_AACPS_FIXED_TABLEGEN_H
|
||||
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#if CONFIG_HARDCODED_TABLES
|
||||
#define ps_tableinit()
|
||||
#define TABLE_CONST const
|
||||
#include "libavcodec/aacps_fixed_tables.h"
|
||||
#else
|
||||
#include "libavutil/common.h"
|
||||
#include "libavutil/mathematics.h"
|
||||
#ifdef BUILD_TABLES
|
||||
#undef DECLARE_ALIGNED
|
||||
#define DECLARE_ALIGNED(align, type, variable) type variable
|
||||
#else
|
||||
#include "libavutil/mem_internal.h"
|
||||
#endif
|
||||
|
||||
#include "aac_defines.h"
|
||||
#include "libavutil/softfloat.h"
|
||||
#define NR_ALLPASS_BANDS20 30
|
||||
#define NR_ALLPASS_BANDS34 50
|
||||
#define PS_AP_LINKS 3
|
||||
#define TABLE_CONST
|
||||
static int pd_re_smooth[8*8*8];
|
||||
static int pd_im_smooth[8*8*8];
|
||||
static int HA[46][8][4];
|
||||
static int HB[46][8][4];
|
||||
static DECLARE_ALIGNED(16, int, f20_0_8) [ 8][8][2];
|
||||
static DECLARE_ALIGNED(16, int, f34_0_12)[12][8][2];
|
||||
static DECLARE_ALIGNED(16, int, f34_1_8) [ 8][8][2];
|
||||
static DECLARE_ALIGNED(16, int, f34_2_4) [ 4][8][2];
|
||||
static TABLE_CONST DECLARE_ALIGNED(16, int, Q_fract_allpass)[2][50][3][2];
|
||||
static DECLARE_ALIGNED(16, int, phi_fract)[2][50][2];
|
||||
|
||||
static const int g0_Q8[] = {
|
||||
Q31(0.00746082949812f), Q31(0.02270420949825f), Q31(0.04546865930473f), Q31(0.07266113929591f),
|
||||
Q31(0.09885108575264f), Q31(0.11793710567217f), Q31(0.125f)
|
||||
};
|
||||
|
||||
static const int g0_Q12[] = {
|
||||
Q31(0.04081179924692f), Q31(0.03812810994926f), Q31(0.05144908135699f), Q31(0.06399831151592f),
|
||||
Q31(0.07428313801106f), Q31(0.08100347892914f), Q31(0.08333333333333f)
|
||||
};
|
||||
|
||||
static const int g1_Q8[] = {
|
||||
Q31(0.01565675600122f), Q31(0.03752716391991f), Q31(0.05417891378782f), Q31(0.08417044116767f),
|
||||
Q31(0.10307344158036f), Q31(0.12222452249753f), Q31(0.125f)
|
||||
};
|
||||
|
||||
static const int g2_Q4[] = {
|
||||
Q31(-0.05908211155639f), Q31(-0.04871498374946f), Q31(0.0f), Q31(0.07778723915851f),
|
||||
Q31( 0.16486303567403f), Q31( 0.23279856662996f), Q31(0.25f)
|
||||
};
|
||||
|
||||
static const int sintbl_4[4] = { 0, 1073741824, 0, -1073741824 };
|
||||
static const int costbl_4[4] = { 1073741824, 0, -1073741824, 0 };
|
||||
static const int sintbl_8[8] = { 0, 759250125, 1073741824, 759250125,
|
||||
0, -759250125, -1073741824, -759250125 };
|
||||
static const int costbl_8[8] = { 1073741824, 759250125, 0, -759250125,
|
||||
-1073741824, -759250125, 0, 759250125 };
|
||||
static const int sintbl_12[12] = { 0, 536870912, 929887697, 1073741824,
|
||||
929887697, 536870912, 0, -536870912,
|
||||
-929887697, -1073741824, -929887697, -536870912 };
|
||||
static const int costbl_12[12] = { 1073741824, 929887697, 536870912, 0,
|
||||
-536870912, -929887697, -1073741824, -929887697,
|
||||
-536870912, 0, 536870912, 929887697 };
|
||||
|
||||
static void make_filters_from_proto(int (*filter)[8][2], const int *proto, int bands)
|
||||
{
|
||||
|
||||
const int *sinptr, *cosptr;
|
||||
int s, c, sinhalf, coshalf;
|
||||
int q, n;
|
||||
|
||||
if (bands == 4) {
|
||||
sinptr = sintbl_4;
|
||||
cosptr = costbl_4;
|
||||
sinhalf = 759250125;
|
||||
coshalf = 759250125;
|
||||
} else if (bands == 8) {
|
||||
sinptr = sintbl_8;
|
||||
cosptr = costbl_8;
|
||||
sinhalf = 410903207;
|
||||
coshalf = 992008094;
|
||||
} else {
|
||||
sinptr = sintbl_12;
|
||||
cosptr = costbl_12;
|
||||
sinhalf = 277904834;
|
||||
coshalf = 1037154959;
|
||||
}
|
||||
|
||||
for (q = 0; q < bands; q++) {
|
||||
for (n = 0; n < 7; n++) {
|
||||
int theta = (q*(n-6) + (n>>1) - 3) % bands;
|
||||
|
||||
if (theta < 0)
|
||||
theta += bands;
|
||||
s = sinptr[theta];
|
||||
c = cosptr[theta];
|
||||
|
||||
if (n & 1) {
|
||||
theta = (int)(((int64_t)c * coshalf - (int64_t)s * sinhalf + 0x20000000) >> 30);
|
||||
s = (int)(((int64_t)s * coshalf + (int64_t)c * sinhalf + 0x20000000) >> 30);
|
||||
c = theta;
|
||||
}
|
||||
filter[q][n][0] = (int)(((int64_t)proto[n] * c + 0x20000000) >> 30);
|
||||
filter[q][n][1] = -(int)(((int64_t)proto[n] * s + 0x20000000) >> 30);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ps_tableinit(void)
|
||||
{
|
||||
static const int ipdopd_sin[] = { Q30(0), Q30(M_SQRT1_2), Q30(1), Q30( M_SQRT1_2), Q30( 0), Q30(-M_SQRT1_2), Q30(-1), Q30(-M_SQRT1_2) };
|
||||
static const int ipdopd_cos[] = { Q30(1), Q30(M_SQRT1_2), Q30(0), Q30(-M_SQRT1_2), Q30(-1), Q30(-M_SQRT1_2), Q30( 0), Q30( M_SQRT1_2) };
|
||||
int pd0, pd1, pd2;
|
||||
int idx;
|
||||
|
||||
static const int alpha_tab[] =
|
||||
{
|
||||
Q30(1.5146213770f/M_PI), Q30(1.5181334019f/M_PI), Q30(1.5234849453f/M_PI), Q30(1.5369486809f/M_PI), Q30(1.5500687361f/M_PI), Q30(1.5679757595f/M_PI),
|
||||
Q30(1.4455626011f/M_PI), Q30(1.4531552792f/M_PI), Q30(1.4648091793f/M_PI), Q30(1.4945238829f/M_PI), Q30(1.5239057541f/M_PI), Q30(1.5644006729f/M_PI),
|
||||
Q30(1.3738563061f/M_PI), Q30(1.3851221800f/M_PI), Q30(1.4026404619f/M_PI), Q30(1.4484288692f/M_PI), Q30(1.4949874878f/M_PI), Q30(1.5604078770f/M_PI),
|
||||
Q30(1.2645189762f/M_PI), Q30(1.2796478271f/M_PI), Q30(1.3038636446f/M_PI), Q30(1.3710125685f/M_PI), Q30(1.4443849325f/M_PI), Q30(1.5532352924f/M_PI),
|
||||
Q30(1.1507037878f/M_PI), Q30(1.1669205427f/M_PI), Q30(1.1938756704f/M_PI), Q30(1.2754167318f/M_PI), Q30(1.3761177063f/M_PI), Q30(1.5429240465f/M_PI),
|
||||
Q30(1.0079245567f/M_PI), Q30(1.0208238363f/M_PI), Q30(1.0433073044f/M_PI), Q30(1.1208510399f/M_PI), Q30(1.2424604893f/M_PI), Q30(1.5185726881f/M_PI),
|
||||
Q30(0.8995233774f/M_PI), Q30(0.9069069624f/M_PI), Q30(0.9201194048f/M_PI), Q30(0.9698365927f/M_PI), Q30(1.0671583414f/M_PI), Q30(1.4647934437f/M_PI),
|
||||
Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI),
|
||||
Q30(0.6712729335f/M_PI), Q30(0.6638893485f/M_PI), Q30(0.6506769061f/M_PI), Q30(0.6009597182f/M_PI), Q30(0.5036380291f/M_PI), Q30(0.1060028747f/M_PI),
|
||||
Q30(0.5628717542f/M_PI), Q30(0.5499725342f/M_PI), Q30(0.5274890065f/M_PI), Q30(0.4499453008f/M_PI), Q30(0.3283358216f/M_PI), Q30(0.0522236861f/M_PI),
|
||||
Q30(0.4200925827f/M_PI), Q30(0.4038758278f/M_PI), Q30(0.3769206405f/M_PI), Q30(0.2953795493f/M_PI), Q30(0.1946786791f/M_PI), Q30(0.0278722942f/M_PI),
|
||||
Q30(0.3062773645f/M_PI), Q30(0.2911485136f/M_PI), Q30(0.2669326365f/M_PI), Q30(0.1997837722f/M_PI), Q30(0.1264114529f/M_PI), Q30(0.0175609849f/M_PI),
|
||||
Q30(0.1969399750f/M_PI), Q30(0.1856741160f/M_PI), Q30(0.1681558639f/M_PI), Q30(0.1223674342f/M_PI), Q30(0.0758088827f/M_PI), Q30(0.0103884479f/M_PI),
|
||||
Q30(0.1252337098f/M_PI), Q30(0.1176410317f/M_PI), Q30(0.1059871912f/M_PI), Q30(0.0762724727f/M_PI), Q30(0.0468905345f/M_PI), Q30(0.0063956482f/M_PI),
|
||||
Q30(0.0561749674f/M_PI), Q30(0.0526629239f/M_PI), Q30(0.0473113805f/M_PI), Q30(0.0338476151f/M_PI), Q30(0.0207276177f/M_PI), Q30(0.0028205961f/M_PI),
|
||||
Q30(1.5676341057f/M_PI), Q30(1.5678333044f/M_PI), Q30(1.5681363344f/M_PI), Q30(1.5688960552f/M_PI), Q30(1.5696337223f/M_PI), Q30(1.5706381798f/M_PI),
|
||||
Q30(1.5651730299f/M_PI), Q30(1.5655272007f/M_PI), Q30(1.5660660267f/M_PI), Q30(1.5674170256f/M_PI), Q30(1.5687289238f/M_PI), Q30(1.5705151558f/M_PI),
|
||||
Q30(1.5607966185f/M_PI), Q30(1.5614265203f/M_PI), Q30(1.5623844862f/M_PI), Q30(1.5647867918f/M_PI), Q30(1.5671195984f/M_PI), Q30(1.5702962875f/M_PI),
|
||||
Q30(1.5530153513f/M_PI), Q30(1.5541347265f/M_PI), Q30(1.5558375120f/M_PI), Q30(1.5601085424f/M_PI), Q30(1.5642569065f/M_PI), Q30(1.5699069500f/M_PI),
|
||||
Q30(1.5391840935f/M_PI), Q30(1.5411708355f/M_PI), Q30(1.5441943407f/M_PI), Q30(1.5517836809f/M_PI), Q30(1.5591609478f/M_PI), Q30(1.5692136288f/M_PI),
|
||||
Q30(1.5146213770f/M_PI), Q30(1.5181334019f/M_PI), Q30(1.5234849453f/M_PI), Q30(1.5369486809f/M_PI), Q30(1.5500687361f/M_PI), Q30(1.5679757595f/M_PI),
|
||||
Q30(1.4915299416f/M_PI), Q30(1.4964480400f/M_PI), Q30(1.5039558411f/M_PI), Q30(1.5229074955f/M_PI), Q30(1.5414420366f/M_PI), Q30(1.5667995214f/M_PI),
|
||||
Q30(1.4590617418f/M_PI), Q30(1.4658898115f/M_PI), Q30(1.4763505459f/M_PI), Q30(1.5029321909f/M_PI), Q30(1.5291173458f/M_PI), Q30(1.5651149750f/M_PI),
|
||||
Q30(1.4136143923f/M_PI), Q30(1.4229322672f/M_PI), Q30(1.4373078346f/M_PI), Q30(1.4743183851f/M_PI), Q30(1.5113102198f/M_PI), Q30(1.5626684427f/M_PI),
|
||||
Q30(1.3505556583f/M_PI), Q30(1.3628427982f/M_PI), Q30(1.3820509911f/M_PI), Q30(1.4327841997f/M_PI), Q30(1.4850014448f/M_PI), Q30(1.5590143204f/M_PI),
|
||||
Q30(1.2645189762f/M_PI), Q30(1.2796478271f/M_PI), Q30(1.3038636446f/M_PI), Q30(1.3710125685f/M_PI), Q30(1.4443849325f/M_PI), Q30(1.5532352924f/M_PI),
|
||||
Q30(1.1919227839f/M_PI), Q30(1.2081253529f/M_PI), Q30(1.2346779108f/M_PI), Q30(1.3123005629f/M_PI), Q30(1.4034168720f/M_PI), Q30(1.5471596718f/M_PI),
|
||||
Q30(1.1061993837f/M_PI), Q30(1.1219338179f/M_PI), Q30(1.1484941244f/M_PI), Q30(1.2320860624f/M_PI), Q30(1.3421301842f/M_PI), Q30(1.5373806953f/M_PI),
|
||||
Q30(1.0079245567f/M_PI), Q30(1.0208238363f/M_PI), Q30(1.0433073044f/M_PI), Q30(1.1208510399f/M_PI), Q30(1.2424604893f/M_PI), Q30(1.5185726881f/M_PI),
|
||||
Q30(0.8995233774f/M_PI), Q30(0.9069069624f/M_PI), Q30(0.9201194048f/M_PI), Q30(0.9698365927f/M_PI), Q30(1.0671583414f/M_PI), Q30(1.4647934437f/M_PI),
|
||||
Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI),
|
||||
Q30(0.6712729335f/M_PI), Q30(0.6638893485f/M_PI), Q30(0.6506769061f/M_PI), Q30(0.6009597182f/M_PI), Q30(0.5036380291f/M_PI), Q30(0.1060028747f/M_PI),
|
||||
Q30(0.5628717542f/M_PI), Q30(0.5499725342f/M_PI), Q30(0.5274890065f/M_PI), Q30(0.4499453008f/M_PI), Q30(0.3283358216f/M_PI), Q30(0.0522236861f/M_PI),
|
||||
Q30(0.4645969570f/M_PI), Q30(0.4488625824f/M_PI), Q30(0.4223022461f/M_PI), Q30(0.3387103081f/M_PI), Q30(0.2286661267f/M_PI), Q30(0.0334156826f/M_PI),
|
||||
Q30(0.3788735867f/M_PI), Q30(0.3626709878f/M_PI), Q30(0.3361184299f/M_PI), Q30(0.2584958076f/M_PI), Q30(0.1673794836f/M_PI), Q30(0.0236366931f/M_PI),
|
||||
Q30(0.3062773645f/M_PI), Q30(0.2911485136f/M_PI), Q30(0.2669326365f/M_PI), Q30(0.1997837722f/M_PI), Q30(0.1264114529f/M_PI), Q30(0.0175609849f/M_PI),
|
||||
Q30(0.2202406377f/M_PI), Q30(0.2079535723f/M_PI), Q30(0.1887452900f/M_PI), Q30(0.1380121708f/M_PI), Q30(0.0857949182f/M_PI), Q30(0.0117820343f/M_PI),
|
||||
Q30(0.1571819335f/M_PI), Q30(0.1478640437f/M_PI), Q30(0.1334884763f/M_PI), Q30(0.0964778885f/M_PI), Q30(0.0594860613f/M_PI), Q30(0.0081279324f/M_PI),
|
||||
Q30(0.1117345318f/M_PI), Q30(0.1049065739f/M_PI), Q30(0.0944457650f/M_PI), Q30(0.0678641573f/M_PI), Q30(0.0416790098f/M_PI), Q30(0.0056813755f/M_PI),
|
||||
Q30(0.0792663917f/M_PI), Q30(0.0743482932f/M_PI), Q30(0.0668405443f/M_PI), Q30(0.0478888862f/M_PI), Q30(0.0293543357f/M_PI), Q30(0.0039967746f/M_PI),
|
||||
Q30(0.0561749674f/M_PI), Q30(0.0526629239f/M_PI), Q30(0.0473113805f/M_PI), Q30(0.0338476151f/M_PI), Q30(0.0207276177f/M_PI), Q30(0.0028205961f/M_PI),
|
||||
Q30(0.0316122435f/M_PI), Q30(0.0296254847f/M_PI), Q30(0.0266019460f/M_PI), Q30(0.0190126132f/M_PI), Q30(0.0116353342f/M_PI), Q30(0.0015827164f/M_PI),
|
||||
Q30(0.0177809205f/M_PI), Q30(0.0166615788f/M_PI), Q30(0.0149587989f/M_PI), Q30(0.0106877899f/M_PI), Q30(0.0065393616f/M_PI), Q30(0.0008894200f/M_PI),
|
||||
Q30(0.0099996664f/M_PI), Q30(0.0093698399f/M_PI), Q30(0.0084118480f/M_PI), Q30(0.0060095116f/M_PI), Q30(0.0036767013f/M_PI), Q30(0.0005000498f/M_PI),
|
||||
Q30(0.0056233541f/M_PI), Q30(0.0052691097f/M_PI), Q30(0.0047303112f/M_PI), Q30(0.0033792770f/M_PI), Q30(0.0020674451f/M_PI), Q30(0.0002811795f/M_PI),
|
||||
Q30(0.0031622672f/M_PI), Q30(0.0029630491f/M_PI), Q30(0.0026600463f/M_PI), Q30(0.0019002859f/M_PI), Q30(0.0011625893f/M_PI), Q30(0.0001581155f/M_PI)
|
||||
};
|
||||
|
||||
static const int gamma_tab[] =
|
||||
{
|
||||
Q30(0.0000000000f/M_PI), Q30(0.0195873566f/M_PI), Q30(0.0303316917f/M_PI), Q30(0.0448668823f/M_PI), Q30(0.0522258915f/M_PI), Q30(0.0561044961f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.0433459543f/M_PI), Q30(0.0672172382f/M_PI), Q30(0.0997167900f/M_PI), Q30(0.1162951663f/M_PI), Q30(0.1250736862f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.0672341362f/M_PI), Q30(0.1045235619f/M_PI), Q30(0.1558904350f/M_PI), Q30(0.1824723780f/M_PI), Q30(0.1966800541f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.1011129096f/M_PI), Q30(0.1580764502f/M_PI), Q30(0.2387557179f/M_PI), Q30(0.2820728719f/M_PI), Q30(0.3058380187f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.1315985769f/M_PI), Q30(0.2072522491f/M_PI), Q30(0.3188187480f/M_PI), Q30(0.3825501204f/M_PI), Q30(0.4193951190f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.1603866369f/M_PI), Q30(0.2549437582f/M_PI), Q30(0.4029446840f/M_PI), Q30(0.4980689585f/M_PI), Q30(0.5615641475f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.1736015975f/M_PI), Q30(0.2773745656f/M_PI), Q30(0.4461984038f/M_PI), Q30(0.5666890144f/M_PI), Q30(0.6686112881f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.1784276664f/M_PI), Q30(0.2856673002f/M_PI), Q30(0.4630723596f/M_PI), Q30(0.5971632004f/M_PI), Q30(0.7603877187f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.1736015975f/M_PI), Q30(0.2773745656f/M_PI), Q30(0.4461984038f/M_PI), Q30(0.5666890144f/M_PI), Q30(0.6686112881f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.1603866369f/M_PI), Q30(0.2549437582f/M_PI), Q30(0.4029446840f/M_PI), Q30(0.4980689585f/M_PI), Q30(0.5615641475f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.1315985769f/M_PI), Q30(0.2072522491f/M_PI), Q30(0.3188187480f/M_PI), Q30(0.3825501204f/M_PI), Q30(0.4193951190f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.1011129096f/M_PI), Q30(0.1580764502f/M_PI), Q30(0.2387557179f/M_PI), Q30(0.2820728719f/M_PI), Q30(0.3058380187f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.0672341362f/M_PI), Q30(0.1045235619f/M_PI), Q30(0.1558904350f/M_PI), Q30(0.1824723780f/M_PI), Q30(0.1966800541f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.0433459543f/M_PI), Q30(0.0672172382f/M_PI), Q30(0.0997167900f/M_PI), Q30(0.1162951663f/M_PI), Q30(0.1250736862f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.0195873566f/M_PI), Q30(0.0303316917f/M_PI), Q30(0.0448668823f/M_PI), Q30(0.0522258915f/M_PI), Q30(0.0561044961f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.0011053939f/M_PI), Q30(0.0017089852f/M_PI), Q30(0.0025254129f/M_PI), Q30(0.0029398468f/M_PI), Q30(0.0031597170f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.0019607407f/M_PI), Q30(0.0030395309f/M_PI), Q30(0.0044951206f/M_PI), Q30(0.0052305623f/M_PI), Q30(0.0056152637f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.0034913034f/M_PI), Q30(0.0054070661f/M_PI), Q30(0.0079917293f/M_PI), Q30(0.0092999367f/M_PI), Q30(0.0099875759f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.0062100487f/M_PI), Q30(0.0096135242f/M_PI), Q30(0.0142110568f/M_PI), Q30(0.0165348612f/M_PI), Q30(0.0177587029f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.0110366223f/M_PI), Q30(0.0170863140f/M_PI), Q30(0.0252620988f/M_PI), Q30(0.0293955617f/M_PI), Q30(0.0315726399f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.0195873566f/M_PI), Q30(0.0303316917f/M_PI), Q30(0.0448668823f/M_PI), Q30(0.0522258915f/M_PI), Q30(0.0561044961f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.0275881495f/M_PI), Q30(0.0427365713f/M_PI), Q30(0.0632618815f/M_PI), Q30(0.0736731067f/M_PI), Q30(0.0791663304f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.0387469754f/M_PI), Q30(0.0600636788f/M_PI), Q30(0.0890387669f/M_PI), Q30(0.1037906483f/M_PI), Q30(0.1115923747f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.0541138873f/M_PI), Q30(0.0839984417f/M_PI), Q30(0.1248718798f/M_PI), Q30(0.1458375156f/M_PI), Q30(0.1569785923f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.0747506917f/M_PI), Q30(0.1163287833f/M_PI), Q30(0.1738867164f/M_PI), Q30(0.2038587779f/M_PI), Q30(0.2199459076f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.1011129096f/M_PI), Q30(0.1580764502f/M_PI), Q30(0.2387557179f/M_PI), Q30(0.2820728719f/M_PI), Q30(0.3058380187f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.1212290376f/M_PI), Q30(0.1903949380f/M_PI), Q30(0.2907958031f/M_PI), Q30(0.3466993868f/M_PI), Q30(0.3782821596f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.1418247074f/M_PI), Q30(0.2240308374f/M_PI), Q30(0.3474813402f/M_PI), Q30(0.4202919006f/M_PI), Q30(0.4637607038f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.1603866369f/M_PI), Q30(0.2549437582f/M_PI), Q30(0.4029446840f/M_PI), Q30(0.4980689585f/M_PI), Q30(0.5615641475f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.1736015975f/M_PI), Q30(0.2773745656f/M_PI), Q30(0.4461984038f/M_PI), Q30(0.5666890144f/M_PI), Q30(0.6686112881f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.1784276664f/M_PI), Q30(0.2856673002f/M_PI), Q30(0.4630723596f/M_PI), Q30(0.5971632004f/M_PI), Q30(0.7603877187f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.1736015975f/M_PI), Q30(0.2773745656f/M_PI), Q30(0.4461984038f/M_PI), Q30(0.5666890144f/M_PI), Q30(0.6686112881f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.1603866369f/M_PI), Q30(0.2549437582f/M_PI), Q30(0.4029446840f/M_PI), Q30(0.4980689585f/M_PI), Q30(0.5615641475f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.1418247074f/M_PI), Q30(0.2240308374f/M_PI), Q30(0.3474813402f/M_PI), Q30(0.4202919006f/M_PI), Q30(0.4637607038f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.1212290376f/M_PI), Q30(0.1903949380f/M_PI), Q30(0.2907958031f/M_PI), Q30(0.3466993868f/M_PI), Q30(0.3782821596f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.1011129096f/M_PI), Q30(0.1580764502f/M_PI), Q30(0.2387557179f/M_PI), Q30(0.2820728719f/M_PI), Q30(0.3058380187f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.0747506917f/M_PI), Q30(0.1163287833f/M_PI), Q30(0.1738867164f/M_PI), Q30(0.2038587779f/M_PI), Q30(0.2199459076f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.0541138873f/M_PI), Q30(0.0839984417f/M_PI), Q30(0.1248718798f/M_PI), Q30(0.1458375156f/M_PI), Q30(0.1569785923f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.0387469754f/M_PI), Q30(0.0600636788f/M_PI), Q30(0.0890387669f/M_PI), Q30(0.1037906483f/M_PI), Q30(0.1115923747f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.0275881495f/M_PI), Q30(0.0427365713f/M_PI), Q30(0.0632618815f/M_PI), Q30(0.0736731067f/M_PI), Q30(0.0791663304f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.0195873566f/M_PI), Q30(0.0303316917f/M_PI), Q30(0.0448668823f/M_PI), Q30(0.0522258915f/M_PI), Q30(0.0561044961f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.0110366223f/M_PI), Q30(0.0170863140f/M_PI), Q30(0.0252620988f/M_PI), Q30(0.0293955617f/M_PI), Q30(0.0315726399f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.0062100487f/M_PI), Q30(0.0096135242f/M_PI), Q30(0.0142110568f/M_PI), Q30(0.0165348612f/M_PI), Q30(0.0177587029f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.0034913034f/M_PI), Q30(0.0054070661f/M_PI), Q30(0.0079917293f/M_PI), Q30(0.0092999367f/M_PI), Q30(0.0099875759f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.0019607407f/M_PI), Q30(0.0030395309f/M_PI), Q30(0.0044951206f/M_PI), Q30(0.0052305623f/M_PI), Q30(0.0056152637f/M_PI),
|
||||
Q30(0.0000000000f/M_PI), Q30(0.0011053939f/M_PI), Q30(0.0017089852f/M_PI), Q30(0.0025254129f/M_PI), Q30(0.0029398468f/M_PI), Q30(0.0031597170f/M_PI)
|
||||
};
|
||||
|
||||
static const int iid_par_dequant_c1[] = {
|
||||
//iid_par_dequant_default
|
||||
Q30(1.41198278375959f), Q30(1.40313815268360f), Q30(1.38687670404960f), Q30(1.34839972492648f),
|
||||
Q30(1.29124937110028f), Q30(1.19603741667993f), Q30(1.10737240362323f), Q30(1),
|
||||
Q30(0.87961716655242f), Q30(0.75464859232732f), Q30(0.57677990744575f), Q30(0.42640143271122f),
|
||||
Q30(0.27671828230984f), Q30(0.17664462766713f), Q30(0.07940162697653f),
|
||||
//iid_par_dequant_fine
|
||||
Q30(1.41420649135832f), Q30(1.41419120222364f), Q30(1.41414285699784f), Q30(1.41399000859438f),
|
||||
Q30(1.41350698548044f), Q30(1.41198278375959f), Q30(1.40977302262355f), Q30(1.40539479488545f),
|
||||
Q30(1.39677960498402f), Q30(1.38005309967827f), Q30(1.34839972492648f), Q30(1.31392017367631f),
|
||||
Q30(1.26431008149654f), Q30(1.19603741667993f), Q30(1.10737240362323f), Q30(1),
|
||||
Q30(0.87961716655242f), Q30(0.75464859232732f), Q30(0.63365607219232f), Q30(0.52308104267543f),
|
||||
Q30(0.42640143271122f), Q30(0.30895540465965f), Q30(0.22137464873077f), Q30(0.15768788954414f),
|
||||
Q30(0.11198225164225f), Q30(0.07940162697653f), Q30(0.04469901562677f), Q30(0.02514469318284f),
|
||||
Q30(0.01414142856998f), Q30(0.00795258154731f), Q30(0.00447211359449f),
|
||||
};
|
||||
|
||||
static const int acos_icc_invq[] = {
|
||||
Q31(0), Q31(0.178427635f/M_PI), Q31(0.28566733f/M_PI), Q31(0.46307236f/M_PI), Q31(0.59716315f/M_PI), Q31(0.78539816f/M_PI), Q31(1.10030855f/M_PI), Q31(1.57079633f/M_PI)
|
||||
};
|
||||
int iid, icc;
|
||||
|
||||
int k, m;
|
||||
static const int8_t f_center_20[] = {
|
||||
-3, -1, 1, 3, 5, 7, 10, 14, 18, 22,
|
||||
};
|
||||
static const int32_t f_center_34[] = {
|
||||
Q31( 2/768.0),Q31( 6/768.0),Q31(10/768.0),Q31(14/768.0),Q31( 18/768.0),Q31( 22/768.0),Q31( 26/768.0),Q31(30/768.0),
|
||||
Q31( 34/768.0),Q31(-10/768.0),Q31(-6/768.0),Q31(-2/768.0),Q31( 51/768.0),Q31( 57/768.0),Q31( 15/768.0),Q31(21/768.0),
|
||||
Q31( 27/768.0),Q31( 33/768.0),Q31(39/768.0),Q31(45/768.0),Q31( 54/768.0),Q31( 66/768.0),Q31( 78/768.0),Q31(42/768.0),
|
||||
Q31(102/768.0),Q31( 66/768.0),Q31(78/768.0),Q31(90/768.0),Q31(102/768.0),Q31(114/768.0),Q31(126/768.0),Q31(90/768.0)
|
||||
};
|
||||
static const int fractional_delay_links[] = { Q31(0.43f), Q31(0.75f), Q31(0.347f) };
|
||||
const int fractional_delay_gain = Q31(0.39f);
|
||||
|
||||
for (pd0 = 0; pd0 < 8; pd0++) {
|
||||
int pd0_re = (ipdopd_cos[pd0]+2)>>2;
|
||||
int pd0_im = (ipdopd_sin[pd0]+2)>>2;
|
||||
for (pd1 = 0; pd1 < 8; pd1++) {
|
||||
int pd1_re = ipdopd_cos[pd1] >> 1;
|
||||
int pd1_im = ipdopd_sin[pd1] >> 1;
|
||||
for (pd2 = 0; pd2 < 8; pd2++) {
|
||||
int shift, round;
|
||||
int pd2_re = ipdopd_cos[pd2];
|
||||
int pd2_im = ipdopd_sin[pd2];
|
||||
int re_smooth = pd0_re + pd1_re + pd2_re;
|
||||
int im_smooth = pd0_im + pd1_im + pd2_im;
|
||||
|
||||
SoftFloat pd_mag = av_int2sf(((ipdopd_cos[(pd0-pd1)&7]+8)>>4) + ((ipdopd_cos[(pd0-pd2)&7]+4)>>3) +
|
||||
((ipdopd_cos[(pd1-pd2)&7]+2)>>2) + 0x15000000, 28);
|
||||
pd_mag = av_div_sf(FLOAT_1, av_sqrt_sf(pd_mag));
|
||||
shift = 30 - pd_mag.exp;
|
||||
round = 1 << (shift-1);
|
||||
pd_re_smooth[pd0*64+pd1*8+pd2] = (int)(((int64_t)re_smooth * pd_mag.mant + round) >> shift);
|
||||
pd_im_smooth[pd0*64+pd1*8+pd2] = (int)(((int64_t)im_smooth * pd_mag.mant + round) >> shift);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
idx = 0;
|
||||
for (iid = 0; iid < 46; iid++) {
|
||||
int c1, c2;
|
||||
|
||||
c1 = iid_par_dequant_c1[iid];
|
||||
if (iid < 15)
|
||||
c2 = iid_par_dequant_c1[14-iid];
|
||||
else
|
||||
c2 = iid_par_dequant_c1[60-iid];
|
||||
|
||||
for (icc = 0; icc < 8; icc++) {
|
||||
/*if (PS_BASELINE || ps->icc_mode < 3)*/{
|
||||
int alpha, beta;
|
||||
int ca, sa, cb, sb;
|
||||
|
||||
alpha = acos_icc_invq[icc];
|
||||
beta = (int)(((int64_t)alpha * 1518500250 + 0x40000000) >> 31);
|
||||
alpha >>= 1;
|
||||
beta = (int)(((int64_t)beta * (c1 - c2) + 0x40000000) >> 31);
|
||||
av_sincos_sf(beta + alpha, &sa, &ca);
|
||||
av_sincos_sf(beta - alpha, &sb, &cb);
|
||||
|
||||
HA[iid][icc][0] = (int)(((int64_t)c2 * ca + 0x20000000) >> 30);
|
||||
HA[iid][icc][1] = (int)(((int64_t)c1 * cb + 0x20000000) >> 30);
|
||||
HA[iid][icc][2] = (int)(((int64_t)c2 * sa + 0x20000000) >> 30);
|
||||
HA[iid][icc][3] = (int)(((int64_t)c1 * sb + 0x20000000) >> 30);
|
||||
} /* else */ {
|
||||
int alpha_int, gamma_int;
|
||||
int alpha_c_int, alpha_s_int, gamma_c_int, gamma_s_int;
|
||||
|
||||
alpha_int = alpha_tab[idx];
|
||||
gamma_int = gamma_tab[idx];
|
||||
|
||||
av_sincos_sf(alpha_int, &alpha_s_int, &alpha_c_int);
|
||||
av_sincos_sf(gamma_int, &gamma_s_int, &gamma_c_int);
|
||||
|
||||
alpha_c_int = (int)(((int64_t)alpha_c_int * 1518500250 + 0x20000000) >> 30);
|
||||
alpha_s_int = (int)(((int64_t)alpha_s_int * 1518500250 + 0x20000000) >> 30);
|
||||
|
||||
HB[iid][icc][0] = (int)(((int64_t)alpha_c_int * gamma_c_int + 0x20000000) >> 30);
|
||||
HB[iid][icc][1] = (int)(((int64_t)alpha_s_int * gamma_c_int + 0x20000000) >> 30);
|
||||
HB[iid][icc][2] = -(int)(((int64_t)alpha_s_int * gamma_s_int + 0x20000000) >> 30);
|
||||
HB[iid][icc][3] = (int)(((int64_t)alpha_c_int * gamma_s_int + 0x20000000) >> 30);
|
||||
}
|
||||
|
||||
if (icc < 5 || icc > 6)
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
|
||||
for (k = 0; k < NR_ALLPASS_BANDS20; k++) {
|
||||
int theta;
|
||||
int64_t f_center;
|
||||
int c, s;
|
||||
|
||||
if (k < FF_ARRAY_ELEMS(f_center_20))
|
||||
f_center = f_center_20[k];
|
||||
else
|
||||
f_center = (k << 3) - 52;
|
||||
|
||||
for (m = 0; m < PS_AP_LINKS; m++) {
|
||||
theta = (int)(((int64_t)fractional_delay_links[m] * f_center + 8) >> 4);
|
||||
av_sincos_sf(-theta, &s, &c);
|
||||
Q_fract_allpass[0][k][m][0] = c;
|
||||
Q_fract_allpass[0][k][m][1] = s;
|
||||
}
|
||||
|
||||
theta = (int)(((int64_t)fractional_delay_gain * f_center + 8) >> 4);
|
||||
av_sincos_sf(-theta, &s, &c);
|
||||
phi_fract[0][k][0] = c;
|
||||
phi_fract[0][k][1] = s;
|
||||
}
|
||||
|
||||
for (k = 0; k < NR_ALLPASS_BANDS34; k++) {
|
||||
int theta, f_center;
|
||||
int c, s;
|
||||
|
||||
if (k < FF_ARRAY_ELEMS(f_center_34))
|
||||
f_center = f_center_34[k];
|
||||
else
|
||||
f_center = ((int64_t)k << 26) - (53 << 25);
|
||||
|
||||
for (m = 0; m < PS_AP_LINKS; m++) {
|
||||
theta = (int)(((int64_t)fractional_delay_links[m] * f_center + 0x10000000) >> 27);
|
||||
av_sincos_sf(-theta, &s, &c);
|
||||
Q_fract_allpass[1][k][m][0] = c;
|
||||
Q_fract_allpass[1][k][m][1] = s;
|
||||
}
|
||||
|
||||
theta = (int)(((int64_t)fractional_delay_gain * f_center + 0x10000000) >> 27);
|
||||
av_sincos_sf(-theta, &s, &c);
|
||||
phi_fract[1][k][0] = c;
|
||||
phi_fract[1][k][1] = s;
|
||||
}
|
||||
|
||||
make_filters_from_proto(f20_0_8, g0_Q8, 8);
|
||||
make_filters_from_proto(f34_0_12, g0_Q12, 12);
|
||||
make_filters_from_proto(f34_1_8, g1_Q8, 8);
|
||||
make_filters_from_proto(f34_2_4, g2_Q4, 4);
|
||||
}
|
||||
#endif /* CONFIG_HARDCODED_TABLES */
|
||||
|
||||
#endif /* AVCODEC_AACPS_FIXED_TABLEGEN_H */
|
||||
217
include/libavcodec/aacps_tablegen.h
Normal file
217
include/libavcodec/aacps_tablegen.h
Normal file
@@ -0,0 +1,217 @@
|
||||
/*
|
||||
* Header file for hardcoded Parametric Stereo tables
|
||||
*
|
||||
* Copyright (c) 2010 Alex Converse <alex.converse@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 AVCODEC_AACPS_TABLEGEN_H
|
||||
#define AVCODEC_AACPS_TABLEGEN_H
|
||||
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#if CONFIG_HARDCODED_TABLES
|
||||
#define ps_tableinit()
|
||||
#define TABLE_CONST const
|
||||
#include "libavcodec/aacps_tables.h"
|
||||
#else
|
||||
#include "libavutil/common.h"
|
||||
#include "libavutil/libm.h"
|
||||
#include "libavutil/mathematics.h"
|
||||
#include "libavutil/mem_internal.h"
|
||||
#define NR_ALLPASS_BANDS20 30
|
||||
#define NR_ALLPASS_BANDS34 50
|
||||
#define PS_AP_LINKS 3
|
||||
#define TABLE_CONST
|
||||
static float pd_re_smooth[8*8*8];
|
||||
static float pd_im_smooth[8*8*8];
|
||||
static float HA[46][8][4];
|
||||
static float HB[46][8][4];
|
||||
static DECLARE_ALIGNED(16, float, f20_0_8) [ 8][8][2];
|
||||
static DECLARE_ALIGNED(16, float, f34_0_12)[12][8][2];
|
||||
static DECLARE_ALIGNED(16, float, f34_1_8) [ 8][8][2];
|
||||
static DECLARE_ALIGNED(16, float, f34_2_4) [ 4][8][2];
|
||||
static TABLE_CONST DECLARE_ALIGNED(16, float, Q_fract_allpass)[2][50][3][2];
|
||||
static DECLARE_ALIGNED(16, float, phi_fract)[2][50][2];
|
||||
|
||||
static const float g0_Q8[] = {
|
||||
0.00746082949812f, 0.02270420949825f, 0.04546865930473f, 0.07266113929591f,
|
||||
0.09885108575264f, 0.11793710567217f, 0.125f
|
||||
};
|
||||
|
||||
static const float g0_Q12[] = {
|
||||
0.04081179924692f, 0.03812810994926f, 0.05144908135699f, 0.06399831151592f,
|
||||
0.07428313801106f, 0.08100347892914f, 0.08333333333333f
|
||||
};
|
||||
|
||||
static const float g1_Q8[] = {
|
||||
0.01565675600122f, 0.03752716391991f, 0.05417891378782f, 0.08417044116767f,
|
||||
0.10307344158036f, 0.12222452249753f, 0.125f
|
||||
};
|
||||
|
||||
static const float g2_Q4[] = {
|
||||
-0.05908211155639f, -0.04871498374946f, 0.0f, 0.07778723915851f,
|
||||
0.16486303567403f, 0.23279856662996f, 0.25f
|
||||
};
|
||||
|
||||
static av_cold void make_filters_from_proto(float (*filter)[8][2], const float *proto, int bands)
|
||||
{
|
||||
int q, n;
|
||||
for (q = 0; q < bands; q++) {
|
||||
for (n = 0; n < 7; n++) {
|
||||
double theta = 2 * M_PI * (q + 0.5) * (n - 6) / bands;
|
||||
filter[q][n][0] = proto[n] * cos(theta);
|
||||
filter[q][n][1] = proto[n] * -sin(theta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static av_cold void ps_tableinit(void)
|
||||
{
|
||||
static const float ipdopd_sin[] = { 0, M_SQRT1_2, 1, M_SQRT1_2, 0, -M_SQRT1_2, -1, -M_SQRT1_2 };
|
||||
static const float ipdopd_cos[] = { 1, M_SQRT1_2, 0, -M_SQRT1_2, -1, -M_SQRT1_2, 0, M_SQRT1_2 };
|
||||
int pd0, pd1, pd2;
|
||||
|
||||
static const float iid_par_dequant[] = {
|
||||
//iid_par_dequant_default
|
||||
0.05623413251903, 0.12589254117942, 0.19952623149689, 0.31622776601684,
|
||||
0.44668359215096, 0.63095734448019, 0.79432823472428, 1,
|
||||
1.25892541179417, 1.58489319246111, 2.23872113856834, 3.16227766016838,
|
||||
5.01187233627272, 7.94328234724282, 17.7827941003892,
|
||||
//iid_par_dequant_fine
|
||||
0.00316227766017, 0.00562341325190, 0.01, 0.01778279410039,
|
||||
0.03162277660168, 0.05623413251903, 0.07943282347243, 0.11220184543020,
|
||||
0.15848931924611, 0.22387211385683, 0.31622776601684, 0.39810717055350,
|
||||
0.50118723362727, 0.63095734448019, 0.79432823472428, 1,
|
||||
1.25892541179417, 1.58489319246111, 1.99526231496888, 2.51188643150958,
|
||||
3.16227766016838, 4.46683592150963, 6.30957344480193, 8.91250938133745,
|
||||
12.5892541179417, 17.7827941003892, 31.6227766016838, 56.2341325190349,
|
||||
100, 177.827941003892, 316.227766016837,
|
||||
};
|
||||
static const float icc_invq[] = {
|
||||
1, 0.937, 0.84118, 0.60092, 0.36764, 0, -0.589, -1
|
||||
};
|
||||
static const float acos_icc_invq[] = {
|
||||
0, 0.35685527, 0.57133466, 0.92614472, 1.1943263, M_PI/2, 2.2006171, M_PI
|
||||
};
|
||||
int iid, icc;
|
||||
|
||||
int k, m;
|
||||
static const int8_t f_center_20[] = {
|
||||
-3, -1, 1, 3, 5, 7, 10, 14, 18, 22,
|
||||
};
|
||||
static const int8_t f_center_34[] = {
|
||||
2, 6, 10, 14, 18, 22, 26, 30,
|
||||
34,-10, -6, -2, 51, 57, 15, 21,
|
||||
27, 33, 39, 45, 54, 66, 78, 42,
|
||||
102, 66, 78, 90,102,114,126, 90,
|
||||
};
|
||||
static const float fractional_delay_links[] = { 0.43f, 0.75f, 0.347f };
|
||||
const float fractional_delay_gain = 0.39f;
|
||||
|
||||
for (pd0 = 0; pd0 < 8; pd0++) {
|
||||
float pd0_re = ipdopd_cos[pd0];
|
||||
float pd0_im = ipdopd_sin[pd0];
|
||||
for (pd1 = 0; pd1 < 8; pd1++) {
|
||||
float pd1_re = ipdopd_cos[pd1];
|
||||
float pd1_im = ipdopd_sin[pd1];
|
||||
for (pd2 = 0; pd2 < 8; pd2++) {
|
||||
float pd2_re = ipdopd_cos[pd2];
|
||||
float pd2_im = ipdopd_sin[pd2];
|
||||
float re_smooth = 0.25f * pd0_re + 0.5f * pd1_re + pd2_re;
|
||||
float im_smooth = 0.25f * pd0_im + 0.5f * pd1_im + pd2_im;
|
||||
float pd_mag = 1 / hypot(im_smooth, re_smooth);
|
||||
pd_re_smooth[pd0*64+pd1*8+pd2] = re_smooth * pd_mag;
|
||||
pd_im_smooth[pd0*64+pd1*8+pd2] = im_smooth * pd_mag;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (iid = 0; iid < 46; iid++) {
|
||||
float c = iid_par_dequant[iid]; ///< Linear Inter-channel Intensity Difference
|
||||
float c1 = (float)M_SQRT2 / sqrtf(1.0f + c*c);
|
||||
float c2 = c * c1;
|
||||
for (icc = 0; icc < 8; icc++) {
|
||||
/*if (PS_BASELINE || ps->icc_mode < 3)*/ {
|
||||
float alpha = 0.5f * acos_icc_invq[icc];
|
||||
float beta = alpha * (c1 - c2) * (float)M_SQRT1_2;
|
||||
HA[iid][icc][0] = c2 * cosf(beta + alpha);
|
||||
HA[iid][icc][1] = c1 * cosf(beta - alpha);
|
||||
HA[iid][icc][2] = c2 * sinf(beta + alpha);
|
||||
HA[iid][icc][3] = c1 * sinf(beta - alpha);
|
||||
} /* else */ {
|
||||
float alpha, gamma, mu, rho;
|
||||
float alpha_c, alpha_s, gamma_c, gamma_s;
|
||||
rho = FFMAX(icc_invq[icc], 0.05f);
|
||||
alpha = 0.5f * atan2f(2.0f * c * rho, c*c - 1.0f);
|
||||
mu = c + 1.0f / c;
|
||||
mu = sqrtf(1 + (4 * rho * rho - 4)/(mu * mu));
|
||||
gamma = atanf(sqrtf((1.0f - mu)/(1.0f + mu)));
|
||||
if (alpha < 0) alpha += M_PI/2;
|
||||
alpha_c = cosf(alpha);
|
||||
alpha_s = sinf(alpha);
|
||||
gamma_c = cosf(gamma);
|
||||
gamma_s = sinf(gamma);
|
||||
HB[iid][icc][0] = M_SQRT2 * alpha_c * gamma_c;
|
||||
HB[iid][icc][1] = M_SQRT2 * alpha_s * gamma_c;
|
||||
HB[iid][icc][2] = -M_SQRT2 * alpha_s * gamma_s;
|
||||
HB[iid][icc][3] = M_SQRT2 * alpha_c * gamma_s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (k = 0; k < NR_ALLPASS_BANDS20; k++) {
|
||||
double f_center, theta;
|
||||
if (k < FF_ARRAY_ELEMS(f_center_20))
|
||||
f_center = f_center_20[k] * 0.125;
|
||||
else
|
||||
f_center = k - 6.5f;
|
||||
for (m = 0; m < PS_AP_LINKS; m++) {
|
||||
theta = -M_PI * fractional_delay_links[m] * f_center;
|
||||
Q_fract_allpass[0][k][m][0] = cos(theta);
|
||||
Q_fract_allpass[0][k][m][1] = sin(theta);
|
||||
}
|
||||
theta = -M_PI*fractional_delay_gain*f_center;
|
||||
phi_fract[0][k][0] = cos(theta);
|
||||
phi_fract[0][k][1] = sin(theta);
|
||||
}
|
||||
for (k = 0; k < NR_ALLPASS_BANDS34; k++) {
|
||||
double f_center, theta;
|
||||
if (k < FF_ARRAY_ELEMS(f_center_34))
|
||||
f_center = f_center_34[k] / 24.0;
|
||||
else
|
||||
f_center = k - 26.5f;
|
||||
for (m = 0; m < PS_AP_LINKS; m++) {
|
||||
theta = -M_PI * fractional_delay_links[m] * f_center;
|
||||
Q_fract_allpass[1][k][m][0] = cos(theta);
|
||||
Q_fract_allpass[1][k][m][1] = sin(theta);
|
||||
}
|
||||
theta = -M_PI*fractional_delay_gain*f_center;
|
||||
phi_fract[1][k][0] = cos(theta);
|
||||
phi_fract[1][k][1] = sin(theta);
|
||||
}
|
||||
|
||||
make_filters_from_proto(f20_0_8, g0_Q8, 8);
|
||||
make_filters_from_proto(f34_0_12, g0_Q12, 12);
|
||||
make_filters_from_proto(f34_1_8, g1_Q8, 8);
|
||||
make_filters_from_proto(f34_2_4, g2_Q4, 4);
|
||||
}
|
||||
#endif /* CONFIG_HARDCODED_TABLES */
|
||||
|
||||
#endif /* AVCODEC_AACPS_TABLEGEN_H */
|
||||
60
include/libavcodec/aacpsdsp.h
Normal file
60
include/libavcodec/aacpsdsp.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2012 Mans Rullgard
|
||||
*
|
||||
* 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_AACPSDSP_H
|
||||
#define AVCODEC_AACPSDSP_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "aac_defines.h"
|
||||
|
||||
#define PS_QMF_TIME_SLOTS 32
|
||||
#define PS_AP_LINKS 3
|
||||
#define PS_MAX_AP_DELAY 5
|
||||
|
||||
typedef struct PSDSPContext {
|
||||
void (*add_squares)(INTFLOAT *dst, const INTFLOAT (*src)[2], int n);
|
||||
void (*mul_pair_single)(INTFLOAT (*dst)[2], INTFLOAT (*src0)[2], INTFLOAT *src1,
|
||||
int n);
|
||||
void (*hybrid_analysis)(INTFLOAT (*out)[2], INTFLOAT (*in)[2],
|
||||
const INTFLOAT (*filter)[8][2],
|
||||
ptrdiff_t stride, int n);
|
||||
void (*hybrid_analysis_ileave)(INTFLOAT (*out)[32][2], INTFLOAT L[2][38][64],
|
||||
int i, int len);
|
||||
void (*hybrid_synthesis_deint)(INTFLOAT out[2][38][64], INTFLOAT (*in)[32][2],
|
||||
int i, int len);
|
||||
void (*decorrelate)(INTFLOAT (*out)[2], INTFLOAT (*delay)[2],
|
||||
INTFLOAT (*ap_delay)[PS_QMF_TIME_SLOTS+PS_MAX_AP_DELAY][2],
|
||||
const INTFLOAT phi_fract[2], const INTFLOAT (*Q_fract)[2],
|
||||
const INTFLOAT *transient_gain,
|
||||
INTFLOAT g_decay_slope,
|
||||
int len);
|
||||
void (*stereo_interpolate[2])(INTFLOAT (*l)[2], INTFLOAT (*r)[2],
|
||||
INTFLOAT h[2][4], INTFLOAT h_step[2][4],
|
||||
int len);
|
||||
} PSDSPContext;
|
||||
|
||||
void AAC_RENAME(ff_psdsp_init)(PSDSPContext *s);
|
||||
void ff_psdsp_init_arm(PSDSPContext *s);
|
||||
void ff_psdsp_init_aarch64(PSDSPContext *s);
|
||||
void ff_psdsp_init_riscv(PSDSPContext *s);
|
||||
void ff_psdsp_init_x86(PSDSPContext *s);
|
||||
|
||||
#endif /* AVCODEC_AACPSDSP_H */
|
||||
110
include/libavcodec/aacsbr.h
Normal file
110
include/libavcodec/aacsbr.h
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* AAC Spectral Band Replication function declarations
|
||||
* Copyright (c) 2008-2009 Robert Swain ( rob opendot cl )
|
||||
* Copyright (c) 2010 Alex Converse <alex.converse@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
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* AAC Spectral Band Replication function declarations
|
||||
* @author Robert Swain ( rob opendot cl )
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_AACSBR_H
|
||||
#define AVCODEC_AACSBR_H
|
||||
|
||||
#include "get_bits.h"
|
||||
#include "aac/aacdec.h"
|
||||
|
||||
#include "libavutil/attributes_internal.h"
|
||||
|
||||
#define ENVELOPE_ADJUSTMENT_OFFSET 2
|
||||
#define NOISE_FLOOR_OFFSET 6
|
||||
|
||||
/**
|
||||
* SBR VLC tables
|
||||
*/
|
||||
enum {
|
||||
T_HUFFMAN_ENV_1_5DB,
|
||||
F_HUFFMAN_ENV_1_5DB,
|
||||
T_HUFFMAN_ENV_BAL_1_5DB,
|
||||
F_HUFFMAN_ENV_BAL_1_5DB,
|
||||
T_HUFFMAN_ENV_3_0DB,
|
||||
F_HUFFMAN_ENV_3_0DB,
|
||||
T_HUFFMAN_ENV_BAL_3_0DB,
|
||||
F_HUFFMAN_ENV_BAL_3_0DB,
|
||||
T_HUFFMAN_NOISE_3_0DB,
|
||||
T_HUFFMAN_NOISE_BAL_3_0DB,
|
||||
};
|
||||
|
||||
/**
|
||||
* bs_frame_class - frame class of current SBR frame (14496-3 sp04 p98)
|
||||
*/
|
||||
enum {
|
||||
FIXFIX,
|
||||
FIXVAR,
|
||||
VARFIX,
|
||||
VARVAR,
|
||||
};
|
||||
|
||||
enum {
|
||||
EXTENSION_ID_PS = 2,
|
||||
};
|
||||
|
||||
FF_VISIBILITY_PUSH_HIDDEN
|
||||
/** Initialize SBR. */
|
||||
void ff_aac_sbr_init(void);
|
||||
void ff_aac_sbr_init_fixed(void);
|
||||
/**
|
||||
* Allocate an ExtChannelElement (if necessary) and
|
||||
* initialize the SBR context contained in it.
|
||||
*/
|
||||
int ff_aac_sbr_ctx_alloc_init(AACDecContext *ac, ChannelElement **che, int id_aac);
|
||||
int ff_aac_sbr_ctx_alloc_init_fixed(AACDecContext *ac, ChannelElement **che, int id_aac);
|
||||
|
||||
/** Close the SBR context implicitly contained in a ChannelElement. */
|
||||
void ff_aac_sbr_ctx_close(ChannelElement *che);
|
||||
void ff_aac_sbr_ctx_close_fixed(ChannelElement *che);
|
||||
|
||||
/** Decode one SBR element. */
|
||||
int ff_aac_sbr_decode_extension(AACDecContext *ac, ChannelElement *che,
|
||||
GetBitContext *gb, int crc, int cnt, int id_aac);
|
||||
int ff_aac_sbr_decode_extension_fixed(AACDecContext *ac, ChannelElement *che,
|
||||
GetBitContext *gb, int crc, int cnt, int id_aac);
|
||||
|
||||
/** Due to channel allocation not being known upon SBR parameter transmission,
|
||||
* supply the parameters separately.
|
||||
* Functionally identical to ff_aac_sbr_decode_extension() */
|
||||
int ff_aac_sbr_config_usac(AACDecContext *ac, ChannelElement *che,
|
||||
AACUsacElemConfig *ue);
|
||||
|
||||
/** Decode frame SBR data, USAC. */
|
||||
int ff_aac_sbr_decode_usac_data(AACDecContext *ac, ChannelElement *che,
|
||||
AACUsacElemConfig *ue, GetBitContext *gb,
|
||||
int sbr_ch, int indep_flag);
|
||||
|
||||
/** Apply one SBR element to one AAC element. */
|
||||
void ff_aac_sbr_apply(AACDecContext *ac, ChannelElement *che,
|
||||
int id_aac, void /* float */ *L, void /* float */ *R);
|
||||
void ff_aac_sbr_apply_fixed(AACDecContext *ac, ChannelElement *che,
|
||||
int id_aac, void /* int */ *L, void /* int */ *R);
|
||||
|
||||
FF_VISIBILITY_POP_HIDDEN
|
||||
|
||||
#endif /* AVCODEC_AACSBR_H */
|
||||
373
include/libavcodec/aacsbrdata.h
Normal file
373
include/libavcodec/aacsbrdata.h
Normal file
@@ -0,0 +1,373 @@
|
||||
/*
|
||||
* AAC Spectral Band Replication decoding data
|
||||
* Copyright (c) 2008-2009 Robert Swain ( rob opendot cl )
|
||||
*
|
||||
* 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
|
||||
* AAC Spectral Band Replication decoding data
|
||||
* @author Robert Swain ( rob opendot cl )
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_AACSBRDATA_H
|
||||
#define AVCODEC_AACSBRDATA_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "libavutil/mem_internal.h"
|
||||
#include "aac_defines.h"
|
||||
|
||||
static const int8_t sbr_offset[6][16] = {
|
||||
{-8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7}, // fs_sbr = 16000 Hz
|
||||
{-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13}, // fs_sbr = 22050 Hz
|
||||
{-5, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16}, // fs_sbr = 24000 Hz
|
||||
{-6, -4, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16}, // fs_sbr = 32000 Hz
|
||||
{-4, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16, 20}, // 44100 Hz <= fs_sbr <= 64000 Hz
|
||||
{-2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16, 20, 24}, // 64000 Hz < fs_sbr
|
||||
};
|
||||
|
||||
///< window coefficients for analysis/synthesis QMF banks
|
||||
static const DECLARE_ALIGNED(32, INTFLOAT, sbr_qmf_window_ds)[320] = {
|
||||
Q31( 0.0000000000f), Q31(-0.0005617692f),
|
||||
Q31(-0.0004875227f), Q31(-0.0005040714f),
|
||||
Q31(-0.0005466565f), Q31(-0.0005870930f),
|
||||
Q31(-0.0006312493f), Q31(-0.0006777690f),
|
||||
Q31(-0.0007157736f), Q31(-0.0007440941f),
|
||||
Q31(-0.0007681371f), Q31(-0.0007834332f),
|
||||
Q31(-0.0007803664f), Q31(-0.0007757977f),
|
||||
Q31(-0.0007530001f), Q31(-0.0007215391f),
|
||||
Q31(-0.0006650415f), Q31(-0.0005946118f),
|
||||
Q31(-0.0005145572f), Q31(-0.0004095121f),
|
||||
Q31(-0.0002896981f), Q31(-0.0001446380f),
|
||||
Q31( 0.0000134949f), Q31( 0.0002043017f),
|
||||
Q31( 0.0004026540f), Q31( 0.0006239376f),
|
||||
Q31( 0.0008608443f), Q31( 0.0011250155f),
|
||||
Q31( 0.0013902494f), Q31( 0.0016868083f),
|
||||
Q31( 0.0019841140f), Q31( 0.0023017254f),
|
||||
Q31( 0.0026201758f), Q31( 0.0029469447f),
|
||||
Q31( 0.0032739613f), Q31( 0.0036008268f),
|
||||
Q31( 0.0039207432f), Q31( 0.0042264269f),
|
||||
Q31( 0.0045209852f), Q31( 0.0047932560f),
|
||||
Q31( 0.0050393022f), Q31( 0.0052461166f),
|
||||
Q31( 0.0054196775f), Q31( 0.0055475714f),
|
||||
Q31( 0.0056220643f), Q31( 0.0056389199f),
|
||||
Q31( 0.0055917128f), Q31( 0.0054753783f),
|
||||
Q31( 0.0052715758f), Q31( 0.0049839687f),
|
||||
Q31( 0.0046039530f), Q31( 0.0041251642f),
|
||||
Q31( 0.0035401246f), Q31( 0.0028446757f),
|
||||
Q31( 0.0020274176f), Q31( 0.0010902329f),
|
||||
Q31( 0.0000276045f), Q31(-0.0011568135f),
|
||||
Q31(-0.0024826723f), Q31(-0.0039401124f),
|
||||
Q31(-0.0055337211f), Q31(-0.0072615816f),
|
||||
Q31(-0.0091325329f), Q31(-0.0111315548f),
|
||||
Q31( 0.0132718220f), Q31( 0.0155405553f),
|
||||
Q31( 0.0179433381f), Q31( 0.0204531793f),
|
||||
Q31( 0.0230680169f), Q31( 0.0257875847f),
|
||||
Q31( 0.0286072173f), Q31( 0.0315017608f),
|
||||
Q31( 0.0344620948f), Q31( 0.0374812850f),
|
||||
Q31( 0.0405349170f), Q31( 0.0436097542f),
|
||||
Q31( 0.0466843027f), Q31( 0.0497385755f),
|
||||
Q31( 0.0527630746f), Q31( 0.0557173648f),
|
||||
Q31( 0.0585915683f), Q31( 0.0613455171f),
|
||||
Q31( 0.0639715898f), Q31( 0.0664367512f),
|
||||
Q31( 0.0687043828f), Q31( 0.0707628710f),
|
||||
Q31( 0.0725682583f), Q31( 0.0741003642f),
|
||||
Q31( 0.0753137336f), Q31( 0.0761992479f),
|
||||
Q31( 0.0767093490f), Q31( 0.0768230011f),
|
||||
Q31( 0.0765050718f), Q31( 0.0757305756f),
|
||||
Q31( 0.0744664394f), Q31( 0.0726774642f),
|
||||
Q31( 0.0703533073f), Q31( 0.0674525021f),
|
||||
Q31( 0.0639444805f), Q31( 0.0598166570f),
|
||||
Q31( 0.0550460034f), Q31( 0.0495978676f),
|
||||
Q31( 0.0434768782f), Q31( 0.0366418116f),
|
||||
Q31( 0.0290824006f), Q31( 0.0207997072f),
|
||||
Q31( 0.0117623832f), Q31( 0.0019765601f),
|
||||
Q31(-0.0085711749f), Q31(-0.0198834129f),
|
||||
Q31(-0.0319531274f), Q31(-0.0447806821f),
|
||||
Q31(-0.0583705326f), Q31(-0.0726943300f),
|
||||
Q31(-0.0877547536f), Q31(-0.1035329531f),
|
||||
Q31(-0.1200077984f), Q31(-0.1371551761f),
|
||||
Q31(-0.1549607071f), Q31(-0.1733808172f),
|
||||
Q31(-0.1923966745f), Q31(-0.2119735853f),
|
||||
Q31(-0.2320690870f), Q31(-0.2526480309f),
|
||||
Q31(-0.2736634040f), Q31(-0.2950716717f),
|
||||
Q31(-0.3168278913f), Q31(-0.3388722693f),
|
||||
Q31( 0.3611589903f), Q31( 0.3836350013f),
|
||||
Q31( 0.4062317676f), Q31( 0.4289119920f),
|
||||
Q31( 0.4515996535f), Q31( 0.4742453214f),
|
||||
Q31( 0.4967708254f), Q31( 0.5191234970f),
|
||||
Q31( 0.5412553448f), Q31( 0.5630789140f),
|
||||
Q31( 0.5845403235f), Q31( 0.6055783538f),
|
||||
Q31( 0.6261242695f), Q31( 0.6461269695f),
|
||||
Q31( 0.6655139880f), Q31( 0.6842353293f),
|
||||
Q31( 0.7022388719f), Q31( 0.7194462634f),
|
||||
Q31( 0.7358211758f), Q31( 0.7513137456f),
|
||||
Q31( 0.7658674865f), Q31( 0.7794287519f),
|
||||
Q31( 0.7919735841f), Q31( 0.8034485751f),
|
||||
Q31( 0.8138191270f), Q31( 0.8230419890f),
|
||||
Q31( 0.8311038457f), Q31( 0.8379717337f),
|
||||
Q31( 0.8436238281f), Q31( 0.8480315777f),
|
||||
Q31( 0.8511971524f), Q31( 0.8531020949f),
|
||||
Q31( 0.8537385600f), Q31( 0.8531020949f),
|
||||
Q31( 0.8511971524f), Q31( 0.8480315777f),
|
||||
Q31( 0.8436238281f), Q31( 0.8379717337f),
|
||||
Q31( 0.8311038457f), Q31( 0.8230419890f),
|
||||
Q31( 0.8138191270f), Q31( 0.8034485751f),
|
||||
Q31( 0.7919735841f), Q31( 0.7794287519f),
|
||||
Q31( 0.7658674865f), Q31( 0.7513137456f),
|
||||
Q31( 0.7358211758f), Q31( 0.7194462634f),
|
||||
Q31( 0.7022388719f), Q31( 0.6842353293f),
|
||||
Q31( 0.6655139880f), Q31( 0.6461269695f),
|
||||
Q31( 0.6261242695f), Q31( 0.6055783538f),
|
||||
Q31( 0.5845403235f), Q31( 0.5630789140f),
|
||||
Q31( 0.5412553448f), Q31( 0.5191234970f),
|
||||
Q31( 0.4967708254f), Q31( 0.4742453214f),
|
||||
Q31( 0.4515996535f), Q31( 0.4289119920f),
|
||||
Q31( 0.4062317676f), Q31( 0.3836350013f),
|
||||
-Q31( 0.3611589903f), Q31(-0.3388722693f),
|
||||
Q31(-0.3168278913f), Q31(-0.2950716717f),
|
||||
Q31(-0.2736634040f), Q31(-0.2526480309f),
|
||||
Q31(-0.2320690870f), Q31(-0.2119735853f),
|
||||
Q31(-0.1923966745f), Q31(-0.1733808172f),
|
||||
Q31(-0.1549607071f), Q31(-0.1371551761f),
|
||||
Q31(-0.1200077984f), Q31(-0.1035329531f),
|
||||
Q31(-0.0877547536f), Q31(-0.0726943300f),
|
||||
Q31(-0.0583705326f), Q31(-0.0447806821f),
|
||||
Q31(-0.0319531274f), Q31(-0.0198834129f),
|
||||
Q31(-0.0085711749f), Q31( 0.0019765601f),
|
||||
Q31( 0.0117623832f), Q31( 0.0207997072f),
|
||||
Q31( 0.0290824006f), Q31( 0.0366418116f),
|
||||
Q31( 0.0434768782f), Q31( 0.0495978676f),
|
||||
Q31( 0.0550460034f), Q31( 0.0598166570f),
|
||||
Q31( 0.0639444805f), Q31( 0.0674525021f),
|
||||
Q31( 0.0703533073f), Q31( 0.0726774642f),
|
||||
Q31( 0.0744664394f), Q31( 0.0757305756f),
|
||||
Q31( 0.0765050718f), Q31( 0.0768230011f),
|
||||
Q31( 0.0767093490f), Q31( 0.0761992479f),
|
||||
Q31( 0.0753137336f), Q31( 0.0741003642f),
|
||||
Q31( 0.0725682583f), Q31( 0.0707628710f),
|
||||
Q31( 0.0687043828f), Q31( 0.0664367512f),
|
||||
Q31( 0.0639715898f), Q31( 0.0613455171f),
|
||||
Q31( 0.0585915683f), Q31( 0.0557173648f),
|
||||
Q31( 0.0527630746f), Q31( 0.0497385755f),
|
||||
Q31( 0.0466843027f), Q31( 0.0436097542f),
|
||||
Q31( 0.0405349170f), Q31( 0.0374812850f),
|
||||
Q31( 0.0344620948f), Q31( 0.0315017608f),
|
||||
Q31( 0.0286072173f), Q31( 0.0257875847f),
|
||||
Q31( 0.0230680169f), Q31( 0.0204531793f),
|
||||
Q31( 0.0179433381f), Q31( 0.0155405553f),
|
||||
-Q31( 0.0132718220f), Q31(-0.0111315548f),
|
||||
Q31(-0.0091325329f), Q31(-0.0072615816f),
|
||||
Q31(-0.0055337211f), Q31(-0.0039401124f),
|
||||
Q31(-0.0024826723f), Q31(-0.0011568135f),
|
||||
Q31( 0.0000276045f), Q31( 0.0010902329f),
|
||||
Q31( 0.0020274176f), Q31( 0.0028446757f),
|
||||
Q31( 0.0035401246f), Q31( 0.0041251642f),
|
||||
Q31( 0.0046039530f), Q31( 0.0049839687f),
|
||||
Q31( 0.0052715758f), Q31( 0.0054753783f),
|
||||
Q31( 0.0055917128f), Q31( 0.0056389199f),
|
||||
Q31( 0.0056220643f), Q31( 0.0055475714f),
|
||||
Q31( 0.0054196775f), Q31( 0.0052461166f),
|
||||
Q31( 0.0050393022f), Q31( 0.0047932560f),
|
||||
Q31( 0.0045209852f), Q31( 0.0042264269f),
|
||||
Q31( 0.0039207432f), Q31( 0.0036008268f),
|
||||
Q31( 0.0032739613f), Q31( 0.0029469447f),
|
||||
Q31( 0.0026201758f), Q31( 0.0023017254f),
|
||||
Q31( 0.0019841140f), Q31( 0.0016868083f),
|
||||
Q31( 0.0013902494f), Q31( 0.0011250155f),
|
||||
Q31( 0.0008608443f), Q31( 0.0006239376f),
|
||||
Q31( 0.0004026540f), Q31( 0.0002043017f),
|
||||
Q31( 0.0000134949f), Q31(-0.0001446380f),
|
||||
Q31(-0.0002896981f), Q31(-0.0004095121f),
|
||||
Q31(-0.0005145572f), Q31(-0.0005946118f),
|
||||
Q31(-0.0006650415f), Q31(-0.0007215391f),
|
||||
Q31(-0.0007530001f), Q31(-0.0007757977f),
|
||||
Q31(-0.0007803664f), Q31(-0.0007834332f),
|
||||
Q31(-0.0007681371f), Q31(-0.0007440941f),
|
||||
Q31(-0.0007157736f), Q31(-0.0006777690f),
|
||||
Q31(-0.0006312493f), Q31(-0.0005870930f),
|
||||
Q31(-0.0005466565f), Q31(-0.0005040714f),
|
||||
Q31(-0.0004875227f), Q31(-0.0005617692f),
|
||||
};
|
||||
|
||||
/* This table contains redundancy: It is symmetric about the entry #320
|
||||
* with the exception of entries 384 and 512 which are negated. */
|
||||
static const DECLARE_ALIGNED(32, INTFLOAT, sbr_qmf_window_us)[640] = {
|
||||
Q31( 0.0000000000f), Q31(-0.0005525286f), Q31(-0.0005617692f), Q31(-0.0004947518f),
|
||||
Q31(-0.0004875227f), Q31(-0.0004893791f), Q31(-0.0005040714f), Q31(-0.0005226564f),
|
||||
Q31(-0.0005466565f), Q31(-0.0005677802f), Q31(-0.0005870930f), Q31(-0.0006132747f),
|
||||
Q31(-0.0006312493f), Q31(-0.0006540333f), Q31(-0.0006777690f), Q31(-0.0006941614f),
|
||||
Q31(-0.0007157736f), Q31(-0.0007255043f), Q31(-0.0007440941f), Q31(-0.0007490598f),
|
||||
Q31(-0.0007681371f), Q31(-0.0007724848f), Q31(-0.0007834332f), Q31(-0.0007779869f),
|
||||
Q31(-0.0007803664f), Q31(-0.0007801449f), Q31(-0.0007757977f), Q31(-0.0007630793f),
|
||||
Q31(-0.0007530001f), Q31(-0.0007319357f), Q31(-0.0007215391f), Q31(-0.0006917937f),
|
||||
Q31(-0.0006650415f), Q31(-0.0006341594f), Q31(-0.0005946118f), Q31(-0.0005564576f),
|
||||
Q31(-0.0005145572f), Q31(-0.0004606325f), Q31(-0.0004095121f), Q31(-0.0003501175f),
|
||||
Q31(-0.0002896981f), Q31(-0.0002098337f), Q31(-0.0001446380f), Q31(-0.0000617334f),
|
||||
Q31( 0.0000134949f), Q31( 0.0001094383f), Q31( 0.0002043017f), Q31( 0.0002949531f),
|
||||
Q31( 0.0004026540f), Q31( 0.0005107388f), Q31( 0.0006239376f), Q31( 0.0007458025f),
|
||||
Q31( 0.0008608443f), Q31( 0.0009885988f), Q31( 0.0011250155f), Q31( 0.0012577884f),
|
||||
Q31( 0.0013902494f), Q31( 0.0015443219f), Q31( 0.0016868083f), Q31( 0.0018348265f),
|
||||
Q31( 0.0019841140f), Q31( 0.0021461583f), Q31( 0.0023017254f), Q31( 0.0024625616f),
|
||||
Q31( 0.0026201758f), Q31( 0.0027870464f), Q31( 0.0029469447f), Q31( 0.0031125420f),
|
||||
Q31( 0.0032739613f), Q31( 0.0034418874f), Q31( 0.0036008268f), Q31( 0.0037603922f),
|
||||
Q31( 0.0039207432f), Q31( 0.0040819753f), Q31( 0.0042264269f), Q31( 0.0043730719f),
|
||||
Q31( 0.0045209852f), Q31( 0.0046606460f), Q31( 0.0047932560f), Q31( 0.0049137603f),
|
||||
Q31( 0.0050393022f), Q31( 0.0051407353f), Q31( 0.0052461166f), Q31( 0.0053471681f),
|
||||
Q31( 0.0054196775f), Q31( 0.0054876040f), Q31( 0.0055475714f), Q31( 0.0055938023f),
|
||||
Q31( 0.0056220643f), Q31( 0.0056455196f), Q31( 0.0056389199f), Q31( 0.0056266114f),
|
||||
Q31( 0.0055917128f), Q31( 0.0055404363f), Q31( 0.0054753783f), Q31( 0.0053838975f),
|
||||
Q31( 0.0052715758f), Q31( 0.0051382275f), Q31( 0.0049839687f), Q31( 0.0048109469f),
|
||||
Q31( 0.0046039530f), Q31( 0.0043801861f), Q31( 0.0041251642f), Q31( 0.0038456408f),
|
||||
Q31( 0.0035401246f), Q31( 0.0032091885f), Q31( 0.0028446757f), Q31( 0.0024508540f),
|
||||
Q31( 0.0020274176f), Q31( 0.0015784682f), Q31( 0.0010902329f), Q31( 0.0005832264f),
|
||||
Q31( 0.0000276045f), Q31(-0.0005464280f), Q31(-0.0011568135f), Q31(-0.0018039472f),
|
||||
Q31(-0.0024826723f), Q31(-0.0031933778f), Q31(-0.0039401124f), Q31(-0.0047222596f),
|
||||
Q31(-0.0055337211f), Q31(-0.0063792293f), Q31(-0.0072615816f), Q31(-0.0081798233f),
|
||||
Q31(-0.0091325329f), Q31(-0.0101150215f), Q31(-0.0111315548f), Q31(-0.0121849995f),
|
||||
Q31( 0.0132718220f), Q31( 0.0143904666f), Q31( 0.0155405553f), Q31( 0.0167324712f),
|
||||
Q31( 0.0179433381f), Q31( 0.0191872431f), Q31( 0.0204531793f), Q31( 0.0217467550f),
|
||||
Q31( 0.0230680169f), Q31( 0.0244160992f), Q31( 0.0257875847f), Q31( 0.0271859429f),
|
||||
Q31( 0.0286072173f), Q31( 0.0300502657f), Q31( 0.0315017608f), Q31( 0.0329754081f),
|
||||
Q31( 0.0344620948f), Q31( 0.0359697560f), Q31( 0.0374812850f), Q31( 0.0390053679f),
|
||||
Q31( 0.0405349170f), Q31( 0.0420649094f), Q31( 0.0436097542f), Q31( 0.0451488405f),
|
||||
Q31( 0.0466843027f), Q31( 0.0482165720f), Q31( 0.0497385755f), Q31( 0.0512556155f),
|
||||
Q31( 0.0527630746f), Q31( 0.0542452768f), Q31( 0.0557173648f), Q31( 0.0571616450f),
|
||||
Q31( 0.0585915683f), Q31( 0.0599837480f), Q31( 0.0613455171f), Q31( 0.0626857808f),
|
||||
Q31( 0.0639715898f), Q31( 0.0652247106f), Q31( 0.0664367512f), Q31( 0.0676075985f),
|
||||
Q31( 0.0687043828f), Q31( 0.0697630244f), Q31( 0.0707628710f), Q31( 0.0717002673f),
|
||||
Q31( 0.0725682583f), Q31( 0.0733620255f), Q31( 0.0741003642f), Q31( 0.0747452558f),
|
||||
Q31( 0.0753137336f), Q31( 0.0758008358f), Q31( 0.0761992479f), Q31( 0.0764992170f),
|
||||
Q31( 0.0767093490f), Q31( 0.0768173975f), Q31( 0.0768230011f), Q31( 0.0767204924f),
|
||||
Q31( 0.0765050718f), Q31( 0.0761748321f), Q31( 0.0757305756f), Q31( 0.0751576255f),
|
||||
Q31( 0.0744664394f), Q31( 0.0736406005f), Q31( 0.0726774642f), Q31( 0.0715826364f),
|
||||
Q31( 0.0703533073f), Q31( 0.0689664013f), Q31( 0.0674525021f), Q31( 0.0657690668f),
|
||||
Q31( 0.0639444805f), Q31( 0.0619602779f), Q31( 0.0598166570f), Q31( 0.0575152691f),
|
||||
Q31( 0.0550460034f), Q31( 0.0524093821f), Q31( 0.0495978676f), Q31( 0.0466303305f),
|
||||
Q31( 0.0434768782f), Q31( 0.0401458278f), Q31( 0.0366418116f), Q31( 0.0329583930f),
|
||||
Q31( 0.0290824006f), Q31( 0.0250307561f), Q31( 0.0207997072f), Q31( 0.0163701258f),
|
||||
Q31( 0.0117623832f), Q31( 0.0069636862f), Q31( 0.0019765601f), Q31(-0.0032086896f),
|
||||
Q31(-0.0085711749f), Q31(-0.0141288827f), Q31(-0.0198834129f), Q31(-0.0258227288f),
|
||||
Q31(-0.0319531274f), Q31(-0.0382776572f), Q31(-0.0447806821f), Q31(-0.0514804176f),
|
||||
Q31(-0.0583705326f), Q31(-0.0654409853f), Q31(-0.0726943300f), Q31(-0.0801372934f),
|
||||
Q31(-0.0877547536f), Q31(-0.0955533352f), Q31(-0.1035329531f), Q31(-0.1116826931f),
|
||||
Q31(-0.1200077984f), Q31(-0.1285002850f), Q31(-0.1371551761f), Q31(-0.1459766491f),
|
||||
Q31(-0.1549607071f), Q31(-0.1640958855f), Q31(-0.1733808172f), Q31(-0.1828172548f),
|
||||
Q31(-0.1923966745f), Q31(-0.2021250176f), Q31(-0.2119735853f), Q31(-0.2219652696f),
|
||||
Q31(-0.2320690870f), Q31(-0.2423016884f), Q31(-0.2526480309f), Q31(-0.2631053299f),
|
||||
Q31(-0.2736634040f), Q31(-0.2843214189f), Q31(-0.2950716717f), Q31(-0.3059098575f),
|
||||
Q31(-0.3168278913f), Q31(-0.3278113727f), Q31(-0.3388722693f), Q31(-0.3499914122f),
|
||||
Q31( 0.3611589903f), Q31( 0.3723795546f), Q31( 0.3836350013f), Q31( 0.3949211761f),
|
||||
Q31( 0.4062317676f), Q31( 0.4175696896f), Q31( 0.4289119920f), Q31( 0.4402553754f),
|
||||
Q31( 0.4515996535f), Q31( 0.4629308085f), Q31( 0.4742453214f), Q31( 0.4855253091f),
|
||||
Q31( 0.4967708254f), Q31( 0.5079817500f), Q31( 0.5191234970f), Q31( 0.5302240895f),
|
||||
Q31( 0.5412553448f), Q31( 0.5522051258f), Q31( 0.5630789140f), Q31( 0.5738524131f),
|
||||
Q31( 0.5845403235f), Q31( 0.5951123086f), Q31( 0.6055783538f), Q31( 0.6159109932f),
|
||||
Q31( 0.6261242695f), Q31( 0.6361980107f), Q31( 0.6461269695f), Q31( 0.6559016302f),
|
||||
Q31( 0.6655139880f), Q31( 0.6749663190f), Q31( 0.6842353293f), Q31( 0.6933282376f),
|
||||
Q31( 0.7022388719f), Q31( 0.7109410426f), Q31( 0.7194462634f), Q31( 0.7277448900f),
|
||||
Q31( 0.7358211758f), Q31( 0.7436827863f), Q31( 0.7513137456f), Q31( 0.7587080760f),
|
||||
Q31( 0.7658674865f), Q31( 0.7727780881f), Q31( 0.7794287519f), Q31( 0.7858353120f),
|
||||
Q31( 0.7919735841f), Q31( 0.7978466413f), Q31( 0.8034485751f), Q31( 0.8087695004f),
|
||||
Q31( 0.8138191270f), Q31( 0.8185776004f), Q31( 0.8230419890f), Q31( 0.8272275347f),
|
||||
Q31( 0.8311038457f), Q31( 0.8346937361f), Q31( 0.8379717337f), Q31( 0.8409541392f),
|
||||
Q31( 0.8436238281f), Q31( 0.8459818469f), Q31( 0.8480315777f), Q31( 0.8497805198f),
|
||||
Q31( 0.8511971524f), Q31( 0.8523047035f), Q31( 0.8531020949f), Q31( 0.8535720573f),
|
||||
Q31( 0.8537385600f), Q31( 0.8535720573f), Q31( 0.8531020949f), Q31( 0.8523047035f),
|
||||
Q31( 0.8511971524f), Q31( 0.8497805198f), Q31( 0.8480315777f), Q31( 0.8459818469f),
|
||||
Q31( 0.8436238281f), Q31( 0.8409541392f), Q31( 0.8379717337f), Q31( 0.8346937361f),
|
||||
Q31( 0.8311038457f), Q31( 0.8272275347f), Q31( 0.8230419890f), Q31( 0.8185776004f),
|
||||
Q31( 0.8138191270f), Q31( 0.8087695004f), Q31( 0.8034485751f), Q31( 0.7978466413f),
|
||||
Q31( 0.7919735841f), Q31( 0.7858353120f), Q31( 0.7794287519f), Q31( 0.7727780881f),
|
||||
Q31( 0.7658674865f), Q31( 0.7587080760f), Q31( 0.7513137456f), Q31( 0.7436827863f),
|
||||
Q31( 0.7358211758f), Q31( 0.7277448900f), Q31( 0.7194462634f), Q31( 0.7109410426f),
|
||||
Q31( 0.7022388719f), Q31( 0.6933282376f), Q31( 0.6842353293f), Q31( 0.6749663190f),
|
||||
Q31( 0.6655139880f), Q31( 0.6559016302f), Q31( 0.6461269695f), Q31( 0.6361980107f),
|
||||
Q31( 0.6261242695f), Q31( 0.6159109932f), Q31( 0.6055783538f), Q31( 0.5951123086f),
|
||||
Q31( 0.5845403235f), Q31( 0.5738524131f), Q31( 0.5630789140f), Q31( 0.5522051258f),
|
||||
Q31( 0.5412553448f), Q31( 0.5302240895f), Q31( 0.5191234970f), Q31( 0.5079817500f),
|
||||
Q31( 0.4967708254f), Q31( 0.4855253091f), Q31( 0.4742453214f), Q31( 0.4629308085f),
|
||||
Q31( 0.4515996535f), Q31( 0.4402553754f), Q31( 0.4289119920f), Q31( 0.4175696896f),
|
||||
Q31( 0.4062317676f), Q31( 0.3949211761f), Q31( 0.3836350013f), Q31( 0.3723795546f),
|
||||
-Q31( 0.3611589903f), Q31(-0.3499914122f), Q31(-0.3388722693f), Q31(-0.3278113727f),
|
||||
Q31(-0.3168278913f), Q31(-0.3059098575f), Q31(-0.2950716717f), Q31(-0.2843214189f),
|
||||
Q31(-0.2736634040f), Q31(-0.2631053299f), Q31(-0.2526480309f), Q31(-0.2423016884f),
|
||||
Q31(-0.2320690870f), Q31(-0.2219652696f), Q31(-0.2119735853f), Q31(-0.2021250176f),
|
||||
Q31(-0.1923966745f), Q31(-0.1828172548f), Q31(-0.1733808172f), Q31(-0.1640958855f),
|
||||
Q31(-0.1549607071f), Q31(-0.1459766491f), Q31(-0.1371551761f), Q31(-0.1285002850f),
|
||||
Q31(-0.1200077984f), Q31(-0.1116826931f), Q31(-0.1035329531f), Q31(-0.0955533352f),
|
||||
Q31(-0.0877547536f), Q31(-0.0801372934f), Q31(-0.0726943300f), Q31(-0.0654409853f),
|
||||
Q31(-0.0583705326f), Q31(-0.0514804176f), Q31(-0.0447806821f), Q31(-0.0382776572f),
|
||||
Q31(-0.0319531274f), Q31(-0.0258227288f), Q31(-0.0198834129f), Q31(-0.0141288827f),
|
||||
Q31(-0.0085711749f), Q31(-0.0032086896f), Q31( 0.0019765601f), Q31( 0.0069636862f),
|
||||
Q31( 0.0117623832f), Q31( 0.0163701258f), Q31( 0.0207997072f), Q31( 0.0250307561f),
|
||||
Q31( 0.0290824006f), Q31( 0.0329583930f), Q31( 0.0366418116f), Q31( 0.0401458278f),
|
||||
Q31( 0.0434768782f), Q31( 0.0466303305f), Q31( 0.0495978676f), Q31( 0.0524093821f),
|
||||
Q31( 0.0550460034f), Q31( 0.0575152691f), Q31( 0.0598166570f), Q31( 0.0619602779f),
|
||||
Q31( 0.0639444805f), Q31( 0.0657690668f), Q31( 0.0674525021f), Q31( 0.0689664013f),
|
||||
Q31( 0.0703533073f), Q31( 0.0715826364f), Q31( 0.0726774642f), Q31( 0.0736406005f),
|
||||
Q31( 0.0744664394f), Q31( 0.0751576255f), Q31( 0.0757305756f), Q31( 0.0761748321f),
|
||||
Q31( 0.0765050718f), Q31( 0.0767204924f), Q31( 0.0768230011f), Q31( 0.0768173975f),
|
||||
Q31( 0.0767093490f), Q31( 0.0764992170f), Q31( 0.0761992479f), Q31( 0.0758008358f),
|
||||
Q31( 0.0753137336f), Q31( 0.0747452558f), Q31( 0.0741003642f), Q31( 0.0733620255f),
|
||||
Q31( 0.0725682583f), Q31( 0.0717002673f), Q31( 0.0707628710f), Q31( 0.0697630244f),
|
||||
Q31( 0.0687043828f), Q31( 0.0676075985f), Q31( 0.0664367512f), Q31( 0.0652247106f),
|
||||
Q31( 0.0639715898f), Q31( 0.0626857808f), Q31( 0.0613455171f), Q31( 0.0599837480f),
|
||||
Q31( 0.0585915683f), Q31( 0.0571616450f), Q31( 0.0557173648f), Q31( 0.0542452768f),
|
||||
Q31( 0.0527630746f), Q31( 0.0512556155f), Q31( 0.0497385755f), Q31( 0.0482165720f),
|
||||
Q31( 0.0466843027f), Q31( 0.0451488405f), Q31( 0.0436097542f), Q31( 0.0420649094f),
|
||||
Q31( 0.0405349170f), Q31( 0.0390053679f), Q31( 0.0374812850f), Q31( 0.0359697560f),
|
||||
Q31( 0.0344620948f), Q31( 0.0329754081f), Q31( 0.0315017608f), Q31( 0.0300502657f),
|
||||
Q31( 0.0286072173f), Q31( 0.0271859429f), Q31( 0.0257875847f), Q31( 0.0244160992f),
|
||||
Q31( 0.0230680169f), Q31( 0.0217467550f), Q31( 0.0204531793f), Q31( 0.0191872431f),
|
||||
Q31( 0.0179433381f), Q31( 0.0167324712f), Q31( 0.0155405553f), Q31( 0.0143904666f),
|
||||
-Q31( 0.0132718220f), Q31(-0.0121849995f), Q31(-0.0111315548f), Q31(-0.0101150215f),
|
||||
Q31(-0.0091325329f), Q31(-0.0081798233f), Q31(-0.0072615816f), Q31(-0.0063792293f),
|
||||
Q31(-0.0055337211f), Q31(-0.0047222596f), Q31(-0.0039401124f), Q31(-0.0031933778f),
|
||||
Q31(-0.0024826723f), Q31(-0.0018039472f), Q31(-0.0011568135f), Q31(-0.0005464280f),
|
||||
Q31( 0.0000276045f), Q31( 0.0005832264f), Q31( 0.0010902329f), Q31( 0.0015784682f),
|
||||
Q31( 0.0020274176f), Q31( 0.0024508540f), Q31( 0.0028446757f), Q31( 0.0032091885f),
|
||||
Q31( 0.0035401246f), Q31( 0.0038456408f), Q31( 0.0041251642f), Q31( 0.0043801861f),
|
||||
Q31( 0.0046039530f), Q31( 0.0048109469f), Q31( 0.0049839687f), Q31( 0.0051382275f),
|
||||
Q31( 0.0052715758f), Q31( 0.0053838975f), Q31( 0.0054753783f), Q31( 0.0055404363f),
|
||||
Q31( 0.0055917128f), Q31( 0.0056266114f), Q31( 0.0056389199f), Q31( 0.0056455196f),
|
||||
Q31( 0.0056220643f), Q31( 0.0055938023f), Q31( 0.0055475714f), Q31( 0.0054876040f),
|
||||
Q31( 0.0054196775f), Q31( 0.0053471681f), Q31( 0.0052461166f), Q31( 0.0051407353f),
|
||||
Q31( 0.0050393022f), Q31( 0.0049137603f), Q31( 0.0047932560f), Q31( 0.0046606460f),
|
||||
Q31( 0.0045209852f), Q31( 0.0043730719f), Q31( 0.0042264269f), Q31( 0.0040819753f),
|
||||
Q31( 0.0039207432f), Q31( 0.0037603922f), Q31( 0.0036008268f), Q31( 0.0034418874f),
|
||||
Q31( 0.0032739613f), Q31( 0.0031125420f), Q31( 0.0029469447f), Q31( 0.0027870464f),
|
||||
Q31( 0.0026201758f), Q31( 0.0024625616f), Q31( 0.0023017254f), Q31( 0.0021461583f),
|
||||
Q31( 0.0019841140f), Q31( 0.0018348265f), Q31( 0.0016868083f), Q31( 0.0015443219f),
|
||||
Q31( 0.0013902494f), Q31( 0.0012577884f), Q31( 0.0011250155f), Q31( 0.0009885988f),
|
||||
Q31( 0.0008608443f), Q31( 0.0007458025f), Q31( 0.0006239376f), Q31( 0.0005107388f),
|
||||
Q31( 0.0004026540f), Q31( 0.0002949531f), Q31( 0.0002043017f), Q31( 0.0001094383f),
|
||||
Q31( 0.0000134949f), Q31(-0.0000617334f), Q31(-0.0001446380f), Q31(-0.0002098337f),
|
||||
Q31(-0.0002896981f), Q31(-0.0003501175f), Q31(-0.0004095121f), Q31(-0.0004606325f),
|
||||
Q31(-0.0005145572f), Q31(-0.0005564576f), Q31(-0.0005946118f), Q31(-0.0006341594f),
|
||||
Q31(-0.0006650415f), Q31(-0.0006917937f), Q31(-0.0007215391f), Q31(-0.0007319357f),
|
||||
Q31(-0.0007530001f), Q31(-0.0007630793f), Q31(-0.0007757977f), Q31(-0.0007801449f),
|
||||
Q31(-0.0007803664f), Q31(-0.0007779869f), Q31(-0.0007834332f), Q31(-0.0007724848f),
|
||||
Q31(-0.0007681371f), Q31(-0.0007490598f), Q31(-0.0007440941f), Q31(-0.0007255043f),
|
||||
Q31(-0.0007157736f), Q31(-0.0006941614f), Q31(-0.0006777690f), Q31(-0.0006540333f),
|
||||
Q31(-0.0006312493f), Q31(-0.0006132747f), Q31(-0.0005870930f), Q31(-0.0005677802f),
|
||||
Q31(-0.0005466565f), Q31(-0.0005226564f), Q31(-0.0005040714f), Q31(-0.0004893791f),
|
||||
Q31(-0.0004875227f), Q31(-0.0004947518f), Q31(-0.0005617692f), Q31(-0.0005525286f),
|
||||
};
|
||||
|
||||
#endif /* AVCODEC_AACSBRDATA_H */
|
||||
131
include/libavcodec/aactab.h
Normal file
131
include/libavcodec/aactab.h
Normal file
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* AAC data declarations
|
||||
* Copyright (c) 2005-2006 Oded Shimon ( ods15 ods15 dyndns org )
|
||||
* Copyright (c) 2006-2007 Maxim Gavrilov ( maxim.gavrilov 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
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* AAC data declarations
|
||||
* @author Oded Shimon ( ods15 ods15 dyndns org )
|
||||
* @author Maxim Gavrilov ( maxim.gavrilov gmail com )
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_AACTAB_H
|
||||
#define AVCODEC_AACTAB_H
|
||||
|
||||
#include "libavutil/mem_internal.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* NOTE:
|
||||
* Tables in this file are shared by the AAC decoders and encoder
|
||||
*/
|
||||
|
||||
extern float ff_aac_pow2sf_tab[428];
|
||||
extern float ff_aac_pow34sf_tab[428];
|
||||
|
||||
/* @name ltp_coef
|
||||
* Table of the LTP coefficients
|
||||
*/
|
||||
extern const float ff_ltp_coef[8];
|
||||
|
||||
/* @name tns_tmp2_map
|
||||
* Tables of the tmp2[] arrays of LPC coefficients used for TNS.
|
||||
* @{
|
||||
*/
|
||||
extern const float *const ff_tns_tmp2_map[4];
|
||||
// @}
|
||||
|
||||
/* @name window coefficients
|
||||
* @{
|
||||
*/
|
||||
DECLARE_ALIGNED(32, extern float, ff_aac_kbd_long_1024)[1024];
|
||||
DECLARE_ALIGNED(32, extern float, ff_aac_kbd_short_128)[128];
|
||||
DECLARE_ALIGNED(32, extern const float, ff_aac_eld_window_512)[1920];
|
||||
DECLARE_ALIGNED(32, extern const int, ff_aac_eld_window_512_fixed)[1920];
|
||||
DECLARE_ALIGNED(32, extern const float, ff_aac_eld_window_480)[1800];
|
||||
DECLARE_ALIGNED(32, extern const int, ff_aac_eld_window_480_fixed)[1800];
|
||||
// @}
|
||||
|
||||
extern const float ff_aac_deemph_weights[16];
|
||||
|
||||
/* Initializes data shared between float decoder and encoder. */
|
||||
void ff_aac_float_common_init(void);
|
||||
|
||||
/* @name number of scalefactor window bands for long and short transform windows respectively
|
||||
* @{
|
||||
*/
|
||||
extern const uint8_t ff_aac_num_swb_1024[];
|
||||
extern const uint8_t ff_aac_num_swb_960 [];
|
||||
extern const uint8_t ff_aac_num_swb_768 [];
|
||||
extern const uint8_t ff_aac_num_swb_512 [];
|
||||
extern const uint8_t ff_aac_num_swb_480 [];
|
||||
extern const uint8_t ff_aac_num_swb_128 [];
|
||||
extern const uint8_t ff_aac_num_swb_120 [];
|
||||
extern const uint8_t ff_aac_num_swb_96 [];
|
||||
// @}
|
||||
|
||||
extern const uint8_t ff_aac_pred_sfb_max [];
|
||||
|
||||
extern const uint32_t ff_aac_scalefactor_code[121];
|
||||
extern const uint8_t ff_aac_scalefactor_bits[121];
|
||||
|
||||
extern const uint16_t * const ff_aac_spectral_codes[11];
|
||||
extern const uint8_t * const ff_aac_spectral_bits [11];
|
||||
extern const uint16_t ff_aac_spectral_sizes[11];
|
||||
|
||||
extern const float *const ff_aac_codebook_vectors[];
|
||||
extern const float *const ff_aac_codebook_vector_vals[];
|
||||
extern const uint16_t *const ff_aac_codebook_vector_idx[];
|
||||
|
||||
extern const uint16_t ff_aac_ac_msb_cdfs[64][17];
|
||||
extern const uint16_t ff_aac_ac_lsb_cdfs[3][4];
|
||||
extern const uint8_t ff_aac_ac_lookup_m[742];
|
||||
extern const uint32_t ff_aac_ac_hash_m[742];
|
||||
extern const uint16_t ff_aac_ac_cf_m[64][17];
|
||||
|
||||
extern const uint16_t * const ff_swb_offset_1024[13];
|
||||
extern const uint16_t * const ff_swb_offset_960 [13];
|
||||
extern const uint16_t * const ff_swb_offset_768 [13];
|
||||
extern const uint16_t * const ff_swb_offset_512 [13];
|
||||
extern const uint16_t * const ff_swb_offset_480 [13];
|
||||
extern const uint16_t * const ff_swb_offset_128 [13];
|
||||
extern const uint16_t * const ff_swb_offset_120 [13];
|
||||
extern const uint16_t * const ff_swb_offset_96 [13];
|
||||
|
||||
extern const uint8_t ff_tns_max_bands_1024[13];
|
||||
extern const uint8_t ff_tns_max_bands_512 [13];
|
||||
extern const uint8_t ff_tns_max_bands_480 [13];
|
||||
extern const uint8_t ff_tns_max_bands_128 [13];
|
||||
|
||||
extern const uint8_t ff_tns_max_bands_usac_1024[13];
|
||||
extern const uint8_t ff_tns_max_bands_usac_128[13];
|
||||
|
||||
/* [x][y], x == 1 -> frame len is 768 frames, y == 1 -> is eight_short */
|
||||
extern const uint8_t ff_usac_noise_fill_start_offset[2][2];
|
||||
|
||||
extern const int ff_aac_usac_samplerate[32];
|
||||
|
||||
/* Window type (only long+eight, start/stop/stopstart), sine+sine, kbd+kbd, sine+kbd, kbd+sine */
|
||||
extern const float ff_aac_usac_mdst_filt_cur[4 /* Window */][4 /* Shape */][7];
|
||||
/* Window type (everything/longstop+stopstart), sine or kbd */
|
||||
extern const float ff_aac_usac_mdst_filt_prev[2 /* Window */][2 /* sine/kbd */][7];
|
||||
|
||||
#endif /* AVCODEC_AACTAB_H */
|
||||
32
include/libavcodec/aandcttab.h
Normal file
32
include/libavcodec/aandcttab.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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
|
||||
* AAN (Arai, Agui and Nakajima) (I)DCT tables
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_AANDCTTAB_H
|
||||
#define AVCODEC_AANDCTTAB_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
extern const uint16_t ff_aanscales[64];
|
||||
extern const uint16_t ff_inv_aanscales[64];
|
||||
|
||||
#endif /* AVCODEC_AANDCTTAB_H */
|
||||
147
include/libavcodec/ac3.h
Normal file
147
include/libavcodec/ac3.h
Normal file
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* Common code between the AC-3 encoder and decoder
|
||||
* Copyright (c) 2000, 2001, 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
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Common code between the AC-3 encoder and decoder.
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_AC3_H
|
||||
#define AVCODEC_AC3_H
|
||||
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "ac3tab.h"
|
||||
|
||||
#ifndef USE_FIXED
|
||||
#define USE_FIXED 0
|
||||
#endif
|
||||
|
||||
#if USE_FIXED
|
||||
|
||||
#define FIXR(a) ((int)((a) * 0 + 0.5))
|
||||
#define FIXR12(a) ((int)((a) * 4096 + 0.5))
|
||||
#define FIXR15(a) ((int)((a) * 32768 + 0.5))
|
||||
#define ROUND15(x) ((x) + 16384) >> 15
|
||||
|
||||
#define AC3_RENAME(x) x ## _fixed
|
||||
#define AC3_NORM(norm) (1<<24)/(norm)
|
||||
#define AC3_MUL(a,b) ((((int64_t) (a)) * (b))>>12)
|
||||
#define AC3_RANGE(x) ((x)|(((x)&128)<<1))
|
||||
#define AC3_HEAVY_RANGE(x) ((x)<<1)
|
||||
#define AC3_DYNAMIC_RANGE(x) (x)
|
||||
#define AC3_SPX_BLEND(x) (x)
|
||||
#define AC3_DYNAMIC_RANGE1 0
|
||||
|
||||
typedef int INTFLOAT;
|
||||
typedef unsigned int UINTFLOAT;
|
||||
typedef int16_t SHORTFLOAT;
|
||||
|
||||
#else /* USE_FIXED */
|
||||
#include "libavutil/libm.h"
|
||||
|
||||
#define FIXR(x) ((float)(x))
|
||||
#define FIXR12(x) ((float)(x))
|
||||
#define FIXR15(x) ((float)(x))
|
||||
#define ROUND15(x) (x)
|
||||
|
||||
#define AC3_RENAME(x) x
|
||||
#define AC3_NORM(norm) (1.0f/(norm))
|
||||
#define AC3_MUL(a,b) ((a) * (b))
|
||||
#define AC3_RANGE(x) (dynamic_range_tab[(x)])
|
||||
#define AC3_HEAVY_RANGE(x) (ff_ac3_heavy_dynamic_range_tab[(x)])
|
||||
#define AC3_DYNAMIC_RANGE(x) (powf(x, s->drc_scale))
|
||||
#define AC3_SPX_BLEND(x) (x)* (1.0f/32)
|
||||
#define AC3_DYNAMIC_RANGE1 1.0f
|
||||
|
||||
typedef float INTFLOAT;
|
||||
typedef float UINTFLOAT;
|
||||
typedef float SHORTFLOAT;
|
||||
|
||||
#endif /* USE_FIXED */
|
||||
|
||||
#define AC3_LEVEL(x) ROUND15((x) * FIXR15(M_SQRT1_2))
|
||||
|
||||
/* pre-defined gain values */
|
||||
#define LEVEL_PLUS_3DB M_SQRT2
|
||||
#define LEVEL_PLUS_1POINT5DB 1.1892071150027209
|
||||
#define LEVEL_MINUS_1POINT5DB 0.8408964152537145
|
||||
#define LEVEL_MINUS_3DB M_SQRT1_2
|
||||
#define LEVEL_MINUS_4POINT5DB 0.5946035575013605
|
||||
#define LEVEL_MINUS_6DB 0.5000000000000000
|
||||
#define LEVEL_MINUS_9DB 0.3535533905932738
|
||||
#define LEVEL_ZERO 0.0000000000000000
|
||||
#define LEVEL_ONE 1.0000000000000000
|
||||
|
||||
typedef struct AC3BitAllocParameters {
|
||||
int sr_code;
|
||||
int sr_shift;
|
||||
int slow_gain, slow_decay, fast_decay, db_per_bit, floor;
|
||||
int cpl_fast_leak, cpl_slow_leak;
|
||||
} AC3BitAllocParameters;
|
||||
|
||||
/**
|
||||
* Calculate the log power-spectral density of the input signal.
|
||||
* This gives a rough estimate of signal power in the frequency domain by using
|
||||
* the spectral envelope (exponents). The psd is also separately grouped
|
||||
* into critical bands for use in the calculating the masking curve.
|
||||
* 128 units in psd = -6 dB. The dbknee parameter in AC3BitAllocParameters
|
||||
* determines the reference level.
|
||||
*
|
||||
* @param[in] exp frequency coefficient exponents
|
||||
* @param[in] start starting bin location
|
||||
* @param[in] end ending bin location
|
||||
* @param[out] psd signal power for each frequency bin
|
||||
* @param[out] band_psd signal power for each critical band
|
||||
*/
|
||||
void ff_ac3_bit_alloc_calc_psd(int8_t *exp, int start, int end, int16_t *psd,
|
||||
int16_t *band_psd);
|
||||
|
||||
/**
|
||||
* Calculate the masking curve.
|
||||
* First, the excitation is calculated using parameters in s and the signal
|
||||
* power in each critical band. The excitation is compared with a predefined
|
||||
* hearing threshold table to produce the masking curve. If delta bit
|
||||
* allocation information is provided, it is used for adjusting the masking
|
||||
* curve, usually to give a closer match to a better psychoacoustic model.
|
||||
*
|
||||
* @param[in] s adjustable bit allocation parameters
|
||||
* @param[in] band_psd signal power for each critical band
|
||||
* @param[in] start starting bin location
|
||||
* @param[in] end ending bin location
|
||||
* @param[in] fast_gain fast gain (estimated signal-to-mask ratio)
|
||||
* @param[in] is_lfe whether or not the channel being processed is the LFE
|
||||
* @param[in] dba_mode delta bit allocation mode (none, reuse, or new)
|
||||
* @param[in] dba_nsegs number of delta segments
|
||||
* @param[in] dba_offsets location offsets for each segment
|
||||
* @param[in] dba_lengths length of each segment
|
||||
* @param[in] dba_values delta bit allocation for each segment
|
||||
* @param[out] mask calculated masking curve
|
||||
* @return returns 0 for success, non-zero for error
|
||||
*/
|
||||
int ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *band_psd,
|
||||
int start, int end, int fast_gain, int is_lfe,
|
||||
int dba_mode, int dba_nsegs, uint8_t *dba_offsets,
|
||||
uint8_t *dba_lengths, uint8_t *dba_values,
|
||||
int16_t *mask);
|
||||
|
||||
#endif /* AVCODEC_AC3_H */
|
||||
41
include/libavcodec/ac3_channel_layout_tab.h
Normal file
41
include/libavcodec/ac3_channel_layout_tab.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* AC-3 channel layout table
|
||||
* copyright (c) 2001 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 AVCODEC_AC3_CHANNEL_LAYOUT_TAB_H
|
||||
#define AVCODEC_AC3_CHANNEL_LAYOUT_TAB_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "libavutil/channel_layout.h"
|
||||
|
||||
/**
|
||||
* Map audio coding mode (acmod) to channel layout mask.
|
||||
*/
|
||||
const uint16_t ff_ac3_channel_layout_tab[8] = {
|
||||
AV_CH_LAYOUT_STEREO,
|
||||
AV_CH_LAYOUT_MONO,
|
||||
AV_CH_LAYOUT_STEREO,
|
||||
AV_CH_LAYOUT_SURROUND,
|
||||
AV_CH_LAYOUT_2_1,
|
||||
AV_CH_LAYOUT_4POINT0,
|
||||
AV_CH_LAYOUT_2_2,
|
||||
AV_CH_LAYOUT_5POINT0
|
||||
};
|
||||
#endif
|
||||
91
include/libavcodec/ac3_parser_internal.h
Normal file
91
include/libavcodec/ac3_parser_internal.h
Normal file
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* AC-3 parser internal code
|
||||
*
|
||||
* 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_AC3_PARSER_INTERNAL_H
|
||||
#define AVCODEC_AC3_PARSER_INTERNAL_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "ac3defs.h"
|
||||
#include "get_bits.h"
|
||||
|
||||
/**
|
||||
* @struct AC3HeaderInfo
|
||||
* Coded AC-3 header values up to the lfeon element, plus derived values.
|
||||
*/
|
||||
typedef struct AC3HeaderInfo {
|
||||
/** @name Coded elements
|
||||
* @{
|
||||
*/
|
||||
uint16_t sync_word;
|
||||
uint16_t crc1;
|
||||
uint8_t sr_code;
|
||||
uint8_t bitstream_id;
|
||||
uint8_t bitstream_mode;
|
||||
uint8_t channel_mode;
|
||||
uint8_t lfe_on;
|
||||
uint8_t frame_type;
|
||||
int substreamid; ///< substream identification
|
||||
int center_mix_level; ///< Center mix level index
|
||||
int surround_mix_level; ///< Surround mix level index
|
||||
uint16_t channel_map;
|
||||
int num_blocks; ///< number of audio blocks
|
||||
int dolby_surround_mode;
|
||||
/** @} */
|
||||
|
||||
/** @name Derived values
|
||||
* @{
|
||||
*/
|
||||
uint8_t sr_shift;
|
||||
uint16_t sample_rate;
|
||||
uint32_t bit_rate;
|
||||
uint8_t channels;
|
||||
uint16_t frame_size;
|
||||
uint64_t channel_layout;
|
||||
int8_t ac3_bit_rate_code;
|
||||
/** @} */
|
||||
} AC3HeaderInfo;
|
||||
|
||||
typedef enum {
|
||||
AC3_PARSE_ERROR_SYNC = -0x1030c0a,
|
||||
AC3_PARSE_ERROR_BSID = -0x2030c0a,
|
||||
AC3_PARSE_ERROR_SAMPLE_RATE = -0x3030c0a,
|
||||
AC3_PARSE_ERROR_FRAME_SIZE = -0x4030c0a,
|
||||
AC3_PARSE_ERROR_FRAME_TYPE = -0x5030c0a,
|
||||
AC3_PARSE_ERROR_CRC = -0x6030c0a,
|
||||
} AC3ParseError;
|
||||
|
||||
/**
|
||||
* Parse AC-3 frame header.
|
||||
* Parse the header up to the lfeon element, which is the first 52 or 54 bits
|
||||
* depending on the audio coding mode.
|
||||
* @param[in] gbc BitContext containing the first 54 bits of the frame.
|
||||
* @param[out] hdr Pointer to struct where header info is written.
|
||||
* @return 0 on success and AC3_PARSE_ERROR_* values otherwise.
|
||||
*/
|
||||
int ff_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr);
|
||||
|
||||
int avpriv_ac3_parse_header(AC3HeaderInfo **hdr, const uint8_t *buf,
|
||||
size_t size);
|
||||
|
||||
int ff_ac3_find_syncword(const uint8_t *buf, int buf_size);
|
||||
|
||||
#endif /* AVCODEC_AC3_PARSER_INTERNAL_H */
|
||||
281
include/libavcodec/ac3dec.h
Normal file
281
include/libavcodec/ac3dec.h
Normal file
@@ -0,0 +1,281 @@
|
||||
/*
|
||||
* Common code between the AC-3 and E-AC-3 decoders
|
||||
* Copyright (c) 2007 Bartlomiej Wolowiec <bartek.wolowiec@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
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Common code between the AC-3 and E-AC-3 decoders.
|
||||
*
|
||||
* Summary of MDCT Coefficient Grouping:
|
||||
* The individual MDCT coefficient indices are often referred to in the
|
||||
* (E-)AC-3 specification as frequency bins. These bins are grouped together
|
||||
* into subbands of 12 coefficients each. The subbands are grouped together
|
||||
* into bands as defined in the bitstream by the band structures, which
|
||||
* determine the number of bands and the size of each band. The full spectrum
|
||||
* of 256 frequency bins is divided into 1 DC bin + 21 subbands = 253 bins.
|
||||
* This system of grouping coefficients is used for channel bandwidth, stereo
|
||||
* rematrixing, channel coupling, enhanced coupling, and spectral extension.
|
||||
*
|
||||
* +-+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-+
|
||||
* |1| |12| | [12|12|12|12] | | | | | | | | | | | | |3|
|
||||
* +-+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-+
|
||||
* ~~~ ~~~~ ~~~~~~~~~~~~~ ~~~
|
||||
* | | | |
|
||||
* | | | 3 unused frequency bins--+
|
||||
* | | |
|
||||
* | | +--1 band containing 4 subbands
|
||||
* | |
|
||||
* | +--1 subband of 12 frequency bins
|
||||
* |
|
||||
* +--DC frequency bin
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_AC3DEC_H
|
||||
#define AVCODEC_AC3DEC_H
|
||||
|
||||
#include "libavutil/tx.h"
|
||||
#include "libavutil/float_dsp.h"
|
||||
#include "libavutil/fixed_dsp.h"
|
||||
#include "libavutil/lfg.h"
|
||||
#include "libavutil/mem_internal.h"
|
||||
|
||||
#include "ac3.h"
|
||||
#include "ac3dsp.h"
|
||||
#include "avcodec.h"
|
||||
#include "bswapdsp.h"
|
||||
#include "get_bits.h"
|
||||
#include "fmtconvert.h"
|
||||
|
||||
#define AC3_OUTPUT_LFEON 8
|
||||
|
||||
#define SPX_MAX_BANDS 17
|
||||
|
||||
/** Large enough for maximum possible frame size when the specification limit is ignored */
|
||||
#define AC3_FRAME_BUFFER_SIZE 32768
|
||||
|
||||
typedef struct AC3DecodeContext {
|
||||
AVClass *class; ///< class for AVOptions
|
||||
AVCodecContext *avctx; ///< parent context
|
||||
GetBitContext gbc; ///< bitstream reader
|
||||
|
||||
///@name Bit stream information
|
||||
///@{
|
||||
int frame_type; ///< frame type (strmtyp)
|
||||
int substreamid; ///< substream identification
|
||||
int superframe_size; ///< current superframe size, in bytes
|
||||
int frame_size; ///< current frame size, in bytes
|
||||
int bit_rate; ///< stream bit rate, in bits-per-second
|
||||
int sample_rate; ///< sample frequency, in Hz
|
||||
int num_blocks; ///< number of audio blocks
|
||||
int bitstream_id; ///< bitstream id (bsid)
|
||||
int bitstream_mode; ///< bitstream mode (bsmod)
|
||||
int channel_mode; ///< channel mode (acmod)
|
||||
int lfe_on; ///< lfe channel in use
|
||||
int dialog_normalization[2]; ///< dialog level in dBFS (dialnorm)
|
||||
int compression_exists[2]; ///< compression field is valid for frame (compre)
|
||||
int channel_map; ///< custom channel map (chanmap)
|
||||
int preferred_downmix; ///< Preferred 2-channel downmix mode (dmixmod)
|
||||
int center_mix_level; ///< Center mix level index
|
||||
int center_mix_level_ltrt; ///< Center mix level index for Lt/Rt (ltrtcmixlev)
|
||||
int surround_mix_level; ///< Surround mix level index
|
||||
int surround_mix_level_ltrt; ///< Surround mix level index for Lt/Rt (ltrtsurmixlev)
|
||||
int lfe_mix_level_exists; ///< indicates if lfemixlevcod is specified (lfemixlevcode)
|
||||
int lfe_mix_level; ///< LFE mix level index (lfemixlevcod)
|
||||
int eac3; ///< indicates if current frame is E-AC-3
|
||||
int eac3_subsbtreamid_found; ///< bitstream has E-AC-3 additional substream(s)
|
||||
int eac3_extension_type_a; ///< bitstream has E-AC-3 extension type A enabled frame(s)
|
||||
int dolby_surround_mode; ///< dolby surround mode (dsurmod)
|
||||
int dolby_surround_ex_mode; ///< dolby surround ex mode (dsurexmod)
|
||||
int dolby_headphone_mode; ///< dolby headphone mode (dheadphonmod)
|
||||
///@}
|
||||
|
||||
int preferred_stereo_downmix;
|
||||
float ltrt_center_mix_level;
|
||||
float ltrt_surround_mix_level;
|
||||
float loro_center_mix_level;
|
||||
float loro_surround_mix_level;
|
||||
int target_level; ///< target level in dBFS
|
||||
float level_gain[2];
|
||||
|
||||
///@name Frame syntax parameters
|
||||
int snr_offset_strategy; ///< SNR offset strategy (snroffststr)
|
||||
int block_switch_syntax; ///< block switch syntax enabled (blkswe)
|
||||
int dither_flag_syntax; ///< dither flag syntax enabled (dithflage)
|
||||
int bit_allocation_syntax; ///< bit allocation model syntax enabled (bamode)
|
||||
int fast_gain_syntax; ///< fast gain codes enabled (frmfgaincode)
|
||||
int dba_syntax; ///< delta bit allocation syntax enabled (dbaflde)
|
||||
int skip_syntax; ///< skip field syntax enabled (skipflde)
|
||||
///@}
|
||||
|
||||
///@name Standard coupling
|
||||
int cpl_in_use[AC3_MAX_BLOCKS]; ///< coupling in use (cplinu)
|
||||
int cpl_strategy_exists[AC3_MAX_BLOCKS];///< coupling strategy exists (cplstre)
|
||||
int channel_in_cpl[AC3_MAX_CHANNELS]; ///< channel in coupling (chincpl)
|
||||
int phase_flags_in_use; ///< phase flags in use (phsflginu)
|
||||
int phase_flags[AC3_MAX_CPL_BANDS]; ///< phase flags (phsflg)
|
||||
int num_cpl_bands; ///< number of coupling bands (ncplbnd)
|
||||
uint8_t cpl_band_struct[AC3_MAX_CPL_BANDS];
|
||||
uint8_t cpl_band_sizes[AC3_MAX_CPL_BANDS]; ///< number of coeffs in each coupling band
|
||||
int firstchincpl; ///< first channel in coupling
|
||||
int first_cpl_coords[AC3_MAX_CHANNELS]; ///< first coupling coordinates states (firstcplcos)
|
||||
int cpl_coords[AC3_MAX_CHANNELS][AC3_MAX_CPL_BANDS]; ///< coupling coordinates (cplco)
|
||||
///@}
|
||||
|
||||
///@name Spectral extension
|
||||
///@{
|
||||
int spx_in_use; ///< spectral extension in use (spxinu)
|
||||
uint8_t channel_uses_spx[AC3_MAX_CHANNELS]; ///< channel uses spectral extension (chinspx)
|
||||
int8_t spx_atten_code[AC3_MAX_CHANNELS]; ///< spx attenuation code (spxattencod)
|
||||
int spx_src_start_freq; ///< spx start frequency bin
|
||||
int spx_dst_end_freq; ///< spx end frequency bin
|
||||
int spx_dst_start_freq; ///< spx starting frequency bin for copying (copystartmant)
|
||||
///< the copy region ends at the start of the spx region.
|
||||
int num_spx_bands; ///< number of spx bands (nspxbnds)
|
||||
uint8_t spx_band_struct[SPX_MAX_BANDS];
|
||||
uint8_t spx_band_sizes[SPX_MAX_BANDS]; ///< number of bins in each spx band
|
||||
uint8_t first_spx_coords[AC3_MAX_CHANNELS]; ///< first spx coordinates states (firstspxcos)
|
||||
INTFLOAT spx_noise_blend[AC3_MAX_CHANNELS][SPX_MAX_BANDS]; ///< spx noise blending factor (nblendfact)
|
||||
INTFLOAT spx_signal_blend[AC3_MAX_CHANNELS][SPX_MAX_BANDS];///< spx signal blending factor (sblendfact)
|
||||
///@}
|
||||
|
||||
///@name Adaptive hybrid transform
|
||||
int channel_uses_aht[AC3_MAX_CHANNELS]; ///< channel AHT in use (chahtinu)
|
||||
int pre_mantissa[AC3_MAX_CHANNELS][AC3_MAX_COEFS][AC3_MAX_BLOCKS]; ///< pre-IDCT mantissas
|
||||
///@}
|
||||
|
||||
///@name Channel
|
||||
int fbw_channels; ///< number of full-bandwidth channels
|
||||
int channels; ///< number of total channels
|
||||
int lfe_ch; ///< index of LFE channel
|
||||
SHORTFLOAT *downmix_coeffs[2]; ///< stereo downmix coefficients
|
||||
int downmixed; ///< indicates if coeffs are currently downmixed
|
||||
int output_mode; ///< output channel configuration
|
||||
int prev_output_mode; ///< output channel configuration for previous frame
|
||||
int out_channels; ///< number of output channels
|
||||
int prev_bit_rate; ///< stream bit rate, in bits-per-second for previous frame
|
||||
///@}
|
||||
|
||||
///@name Dynamic range
|
||||
INTFLOAT dynamic_range[2]; ///< dynamic range
|
||||
INTFLOAT drc_scale; ///< percentage of dynamic range compression to be applied
|
||||
int heavy_compression; ///< apply heavy compression
|
||||
INTFLOAT heavy_dynamic_range[2]; ///< heavy dynamic range compression
|
||||
///@}
|
||||
|
||||
///@name Bandwidth
|
||||
int start_freq[AC3_MAX_CHANNELS]; ///< start frequency bin (strtmant)
|
||||
int end_freq[AC3_MAX_CHANNELS]; ///< end frequency bin (endmant)
|
||||
///@}
|
||||
|
||||
///@name Consistent noise generation
|
||||
int consistent_noise_generation; ///< seed noise generation with AC-3 frame on decode
|
||||
///@}
|
||||
|
||||
///@name Rematrixing
|
||||
int num_rematrixing_bands; ///< number of rematrixing bands (nrematbnd)
|
||||
int rematrixing_flags[4]; ///< rematrixing flags (rematflg)
|
||||
///@}
|
||||
|
||||
///@name Exponents
|
||||
int num_exp_groups[AC3_MAX_CHANNELS]; ///< Number of exponent groups (nexpgrp)
|
||||
int8_t dexps[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; ///< decoded exponents
|
||||
int exp_strategy[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS]; ///< exponent strategies (expstr)
|
||||
///@}
|
||||
|
||||
///@name Bit allocation
|
||||
AC3BitAllocParameters bit_alloc_params; ///< bit allocation parameters
|
||||
int first_cpl_leak; ///< first coupling leak state (firstcplleak)
|
||||
int snr_offset[AC3_MAX_CHANNELS]; ///< signal-to-noise ratio offsets (snroffst)
|
||||
int fast_gain[AC3_MAX_CHANNELS]; ///< fast gain values/SMR's (fgain)
|
||||
uint8_t bap[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; ///< bit allocation pointers
|
||||
int16_t psd[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; ///< scaled exponents
|
||||
int16_t band_psd[AC3_MAX_CHANNELS][AC3_CRITICAL_BANDS]; ///< interpolated exponents
|
||||
int16_t mask[AC3_MAX_CHANNELS][AC3_CRITICAL_BANDS]; ///< masking curve values
|
||||
int dba_mode[AC3_MAX_CHANNELS]; ///< delta bit allocation mode
|
||||
int dba_nsegs[AC3_MAX_CHANNELS]; ///< number of delta segments
|
||||
uint8_t dba_offsets[AC3_MAX_CHANNELS][8]; ///< delta segment offsets
|
||||
uint8_t dba_lengths[AC3_MAX_CHANNELS][8]; ///< delta segment lengths
|
||||
uint8_t dba_values[AC3_MAX_CHANNELS][8]; ///< delta values for each segment
|
||||
///@}
|
||||
|
||||
///@name Zero-mantissa dithering
|
||||
int dither_flag[AC3_MAX_CHANNELS]; ///< dither flags (dithflg)
|
||||
AVLFG dith_state; ///< for dither generation
|
||||
///@}
|
||||
|
||||
///@name IMDCT
|
||||
int block_switch[AC3_MAX_CHANNELS]; ///< block switch flags (blksw)
|
||||
AVTXContext *tx_128, *tx_256;
|
||||
av_tx_fn tx_fn_128, tx_fn_256;
|
||||
///@}
|
||||
|
||||
///@name Optimization
|
||||
BswapDSPContext bdsp;
|
||||
#if USE_FIXED
|
||||
AVFixedDSPContext *fdsp;
|
||||
#else
|
||||
AVFloatDSPContext *fdsp;
|
||||
#endif
|
||||
AC3DSPContext ac3dsp;
|
||||
FmtConvertContext fmt_conv; ///< optimized conversion functions
|
||||
///@}
|
||||
|
||||
SHORTFLOAT *outptr[AC3_MAX_CHANNELS];
|
||||
INTFLOAT *xcfptr[AC3_MAX_CHANNELS];
|
||||
INTFLOAT *dlyptr[AC3_MAX_CHANNELS];
|
||||
|
||||
///@name Aligned arrays
|
||||
DECLARE_ALIGNED(16, int, fixed_coeffs)[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; ///< fixed-point transform coefficients
|
||||
DECLARE_ALIGNED(32, INTFLOAT, transform_coeffs)[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; ///< transform coefficients
|
||||
DECLARE_ALIGNED(32, INTFLOAT, delay)[EAC3_MAX_CHANNELS][AC3_BLOCK_SIZE]; ///< delay - added to the next block
|
||||
DECLARE_ALIGNED(32, INTFLOAT, window)[AC3_BLOCK_SIZE]; ///< window coefficients
|
||||
DECLARE_ALIGNED(32, INTFLOAT, tmp_output)[AC3_BLOCK_SIZE]; ///< temporary storage for output before windowing
|
||||
DECLARE_ALIGNED(32, SHORTFLOAT, output)[EAC3_MAX_CHANNELS][AC3_BLOCK_SIZE]; ///< output after imdct transform and windowing
|
||||
DECLARE_ALIGNED(32, uint8_t, input_buffer)[AC3_FRAME_BUFFER_SIZE + AV_INPUT_BUFFER_PADDING_SIZE]; ///< temp buffer to prevent overread
|
||||
DECLARE_ALIGNED(32, SHORTFLOAT, output_buffer)[EAC3_MAX_CHANNELS][AC3_BLOCK_SIZE * 6]; ///< final output buffer
|
||||
///@}
|
||||
|
||||
AVChannelLayout downmix_layout;
|
||||
} AC3DecodeContext;
|
||||
|
||||
/**
|
||||
* Parse the E-AC-3 frame header.
|
||||
* This parses both the bit stream info and audio frame header.
|
||||
*/
|
||||
static int ff_eac3_parse_header(AC3DecodeContext *s);
|
||||
|
||||
/**
|
||||
* Decode mantissas in a single channel for the entire frame.
|
||||
* This is used when AHT mode is enabled.
|
||||
*/
|
||||
static void ff_eac3_decode_transform_coeffs_aht_ch(AC3DecodeContext *s, int ch);
|
||||
|
||||
/**
|
||||
* Apply spectral extension to each channel by copying lower frequency
|
||||
* coefficients to higher frequency bins and applying side information to
|
||||
* approximate the original high frequency signal.
|
||||
*/
|
||||
static void ff_eac3_apply_spectral_extension(AC3DecodeContext *s);
|
||||
|
||||
#if (!USE_FIXED)
|
||||
extern float ff_ac3_heavy_dynamic_range_tab[256];
|
||||
#endif
|
||||
|
||||
#endif /* AVCODEC_AC3DEC_H */
|
||||
32
include/libavcodec/ac3dec_data.h
Normal file
32
include/libavcodec/ac3dec_data.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* AC-3 and E-AC-3 decoder tables
|
||||
* Copyright (c) 2007 Bartlomiej Wolowiec <bartek.wolowiec@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 AVCODEC_AC3DEC_DATA_H
|
||||
#define AVCODEC_AC3DEC_DATA_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
extern const uint8_t ff_ac3_ungroup_3_in_5_bits_tab[32][3];
|
||||
|
||||
extern const uint8_t ff_eac3_hebap_tab[64];
|
||||
extern const uint8_t ff_eac3_default_spx_band_struct[17];
|
||||
|
||||
#endif /* AVCODEC_AC3DEC_DATA_H */
|
||||
104
include/libavcodec/ac3defs.h
Normal file
104
include/libavcodec/ac3defs.h
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Common AC-3 definitions
|
||||
* Copyright (c) 2000, 2001, 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 AVCODEC_AC3DEFS_H
|
||||
#define AVCODEC_AC3DEFS_H
|
||||
|
||||
#define EAC3_MAX_CHANNELS 16 /**< maximum number of channels in EAC3 */
|
||||
#define AC3_MAX_CHANNELS 7 /**< maximum number of channels, including coupling channel */
|
||||
#define CPL_CH 0 /**< coupling channel index */
|
||||
|
||||
#define AC3_MAX_COEFS 256
|
||||
#define AC3_BLOCK_SIZE 256
|
||||
#define AC3_MAX_BLOCKS 6
|
||||
#define AC3_FRAME_SIZE (AC3_MAX_BLOCKS * 256)
|
||||
#define AC3_WINDOW_SIZE (AC3_BLOCK_SIZE * 2)
|
||||
#define AC3_CRITICAL_BANDS 50
|
||||
#define AC3_MAX_CPL_BANDS 18
|
||||
|
||||
/* exponent encoding strategy */
|
||||
#define EXP_REUSE 0
|
||||
#define EXP_NEW 1
|
||||
|
||||
#define EXP_D15 1
|
||||
#define EXP_D25 2
|
||||
#define EXP_D45 3
|
||||
|
||||
/** Delta bit allocation strategy */
|
||||
typedef enum {
|
||||
DBA_REUSE = 0,
|
||||
DBA_NEW,
|
||||
DBA_NONE,
|
||||
DBA_RESERVED
|
||||
} AC3DeltaStrategy;
|
||||
|
||||
/** Channel mode (audio coding mode) */
|
||||
typedef enum {
|
||||
AC3_CHMODE_DUALMONO = 0,
|
||||
AC3_CHMODE_MONO,
|
||||
AC3_CHMODE_STEREO,
|
||||
AC3_CHMODE_3F,
|
||||
AC3_CHMODE_2F1R,
|
||||
AC3_CHMODE_3F1R,
|
||||
AC3_CHMODE_2F2R,
|
||||
AC3_CHMODE_3F2R
|
||||
} AC3ChannelMode;
|
||||
|
||||
/** Dolby Surround mode */
|
||||
typedef enum AC3DolbySurroundMode {
|
||||
AC3_DSURMOD_NOTINDICATED = 0,
|
||||
AC3_DSURMOD_OFF,
|
||||
AC3_DSURMOD_ON,
|
||||
AC3_DSURMOD_RESERVED
|
||||
} AC3DolbySurroundMode;
|
||||
|
||||
/** Dolby Surround EX mode */
|
||||
typedef enum AC3DolbySurroundEXMode {
|
||||
AC3_DSUREXMOD_NOTINDICATED = 0,
|
||||
AC3_DSUREXMOD_OFF,
|
||||
AC3_DSUREXMOD_ON,
|
||||
AC3_DSUREXMOD_PLIIZ
|
||||
} AC3DolbySurroundEXMode;
|
||||
|
||||
/** Dolby Headphone mode */
|
||||
typedef enum AC3DolbyHeadphoneMode {
|
||||
AC3_DHEADPHONMOD_NOTINDICATED = 0,
|
||||
AC3_DHEADPHONMOD_OFF,
|
||||
AC3_DHEADPHONMOD_ON,
|
||||
AC3_DHEADPHONMOD_RESERVED
|
||||
} AC3DolbyHeadphoneMode;
|
||||
|
||||
/** Preferred Stereo Downmix mode */
|
||||
typedef enum AC3PreferredStereoDownmixMode {
|
||||
AC3_DMIXMOD_NOTINDICATED = 0,
|
||||
AC3_DMIXMOD_LTRT,
|
||||
AC3_DMIXMOD_LORO,
|
||||
AC3_DMIXMOD_DPLII // reserved value in A/52, but used by encoders to indicate DPL2
|
||||
} AC3PreferredStereoDownmixMode;
|
||||
|
||||
typedef enum {
|
||||
EAC3_FRAME_TYPE_INDEPENDENT = 0,
|
||||
EAC3_FRAME_TYPE_DEPENDENT,
|
||||
EAC3_FRAME_TYPE_AC3_CONVERT,
|
||||
EAC3_FRAME_TYPE_RESERVED
|
||||
} EAC3FrameType;
|
||||
|
||||
#endif /* AVCODEC_AC3DEFS_H */
|
||||
123
include/libavcodec/ac3dsp.h
Normal file
123
include/libavcodec/ac3dsp.h
Normal file
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* AC-3 DSP functions
|
||||
* Copyright (c) 2011 Justin Ruggles
|
||||
*
|
||||
* 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_AC3DSP_H
|
||||
#define AVCODEC_AC3DSP_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* Number of mantissa bits written for each bap value.
|
||||
* bap values with fractional bits are set to 0 and are calculated separately.
|
||||
*/
|
||||
extern const uint16_t ff_ac3_bap_bits[16];
|
||||
|
||||
typedef struct AC3DSPContext {
|
||||
/**
|
||||
* Set each encoded exponent in a block to the minimum of itself and the
|
||||
* exponents in the same frequency bin of up to 5 following blocks.
|
||||
* @param exp pointer to the start of the current block of exponents.
|
||||
* constraints: align 16
|
||||
* @param num_reuse_blocks number of blocks that will reuse exponents from the current block.
|
||||
* constraints: range 0 to 5
|
||||
* @param nb_coefs number of frequency coefficients.
|
||||
*/
|
||||
void (*ac3_exponent_min)(uint8_t *exp, int num_reuse_blocks, int nb_coefs);
|
||||
|
||||
/**
|
||||
* Convert an array of float in range [-1.0,1.0] to int32_t with range
|
||||
* [-(1<<24),(1<<24)]
|
||||
*
|
||||
* @param dst destination array of int32_t.
|
||||
* constraints: 32-byte aligned
|
||||
* @param src source array of float.
|
||||
* constraints: 32-byte aligned
|
||||
* @param len number of elements to convert.
|
||||
* constraints: multiple of 32 greater than zero
|
||||
*/
|
||||
void (*float_to_fixed24)(int32_t *dst, const float *src, size_t len);
|
||||
|
||||
/**
|
||||
* Calculate bit allocation pointers.
|
||||
* The SNR is the difference between the masking curve and the signal. AC-3
|
||||
* uses this value for each frequency bin to allocate bits. The snroffset
|
||||
* parameter is a global adjustment to the SNR for all bins.
|
||||
*
|
||||
* @param[in] mask masking curve
|
||||
* @param[in] psd signal power for each frequency bin
|
||||
* @param[in] start starting bin location
|
||||
* @param[in] end ending bin location
|
||||
* @param[in] snr_offset SNR adjustment
|
||||
* @param[in] floor noise floor
|
||||
* @param[in] bap_tab look-up table for bit allocation pointers
|
||||
* @param[out] bap bit allocation pointers
|
||||
*/
|
||||
void (*bit_alloc_calc_bap)(int16_t *mask, int16_t *psd, int start, int end,
|
||||
int snr_offset, int floor,
|
||||
const uint8_t *bap_tab, uint8_t *bap);
|
||||
|
||||
/**
|
||||
* Update bap counts using the supplied array of bap.
|
||||
*
|
||||
* @param[out] mant_cnt bap counts for 1 block
|
||||
* @param[in] bap array of bap, pointing to start coef bin
|
||||
* @param[in] len number of elements to process
|
||||
*/
|
||||
void (*update_bap_counts)(uint16_t mant_cnt[16], uint8_t *bap, int len);
|
||||
|
||||
/**
|
||||
* Calculate the number of bits needed to encode a set of mantissas.
|
||||
*
|
||||
* @param[in] mant_cnt bap counts for all blocks
|
||||
* @return mantissa bit count
|
||||
*/
|
||||
int (*compute_mantissa_size)(uint16_t mant_cnt[6][16]);
|
||||
|
||||
void (*extract_exponents)(uint8_t *exp, int32_t *coef, int nb_coefs);
|
||||
|
||||
void (*sum_square_butterfly_int32)(int64_t sum[4], const int32_t *coef0,
|
||||
const int32_t *coef1, int len);
|
||||
|
||||
void (*sum_square_butterfly_float)(float sum[4], const float *coef0,
|
||||
const float *coef1, int len);
|
||||
|
||||
int out_channels;
|
||||
int in_channels;
|
||||
void (*downmix)(float **samples, float **matrix, int len);
|
||||
void (*downmix_fixed)(int32_t **samples, int16_t **matrix, int len);
|
||||
} AC3DSPContext;
|
||||
|
||||
void ff_ac3dsp_init(AC3DSPContext *c);
|
||||
void ff_ac3dsp_init_aarch64(AC3DSPContext *c);
|
||||
void ff_ac3dsp_init_arm(AC3DSPContext *c);
|
||||
void ff_ac3dsp_init_x86(AC3DSPContext *c);
|
||||
void ff_ac3dsp_init_mips(AC3DSPContext *c);
|
||||
void ff_ac3dsp_init_riscv(AC3DSPContext *c);
|
||||
|
||||
void ff_ac3dsp_downmix(AC3DSPContext *c, float **samples, float **matrix,
|
||||
int out_ch, int in_ch, int len);
|
||||
void ff_ac3dsp_downmix_fixed(AC3DSPContext *c, int32_t **samples, int16_t **matrix,
|
||||
int out_ch, int in_ch, int len);
|
||||
|
||||
void ff_ac3dsp_set_downmix_x86(AC3DSPContext *c);
|
||||
|
||||
#endif /* AVCODEC_AC3DSP_H */
|
||||
287
include/libavcodec/ac3enc.h
Normal file
287
include/libavcodec/ac3enc.h
Normal file
@@ -0,0 +1,287 @@
|
||||
/*
|
||||
* AC-3 encoder & E-AC-3 encoder common header
|
||||
* Copyright (c) 2000 Fabrice Bellard
|
||||
* Copyright (c) 2006-2010 Justin Ruggles <justin.ruggles@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
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* AC-3 encoder & E-AC-3 encoder common header
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_AC3ENC_H
|
||||
#define AVCODEC_AC3ENC_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libavutil/mem_internal.h"
|
||||
#include "libavutil/opt.h"
|
||||
#include "libavutil/tx.h"
|
||||
|
||||
#include "ac3.h"
|
||||
#include "ac3defs.h"
|
||||
#include "ac3dsp.h"
|
||||
#include "avcodec.h"
|
||||
#include "codec_internal.h"
|
||||
#include "mathops.h"
|
||||
#include "me_cmp.h"
|
||||
#include "audiodsp.h"
|
||||
|
||||
#ifndef AC3ENC_FLOAT
|
||||
#define AC3ENC_FLOAT 0
|
||||
#endif
|
||||
|
||||
#if AC3ENC_FLOAT
|
||||
#include "libavutil/float_dsp.h"
|
||||
#define MAC_COEF(d,a,b) ((d)+=(a)*(b))
|
||||
#define COEF_MIN (-16777215.0/16777216.0)
|
||||
#define COEF_MAX ( 16777215.0/16777216.0)
|
||||
#define NEW_CPL_COORD_THRESHOLD 0.03
|
||||
typedef float SampleType;
|
||||
typedef float CoefType;
|
||||
typedef float CoefSumType;
|
||||
#else
|
||||
#include "libavutil/fixed_dsp.h"
|
||||
#define MAC_COEF(d,a,b) MAC64(d,a,b)
|
||||
#define COEF_MIN -16777215
|
||||
#define COEF_MAX 16777215
|
||||
#define NEW_CPL_COORD_THRESHOLD 503317
|
||||
typedef int32_t SampleType;
|
||||
typedef int32_t CoefType;
|
||||
typedef int64_t CoefSumType;
|
||||
#endif
|
||||
|
||||
/* common option values */
|
||||
#define AC3ENC_OPT_NONE -1
|
||||
#define AC3ENC_OPT_AUTO -1
|
||||
#define AC3ENC_OPT_OFF 0
|
||||
#define AC3ENC_OPT_ON 1
|
||||
#define AC3ENC_OPT_NOT_INDICATED 0
|
||||
#define AC3ENC_OPT_MODE_ON 2
|
||||
#define AC3ENC_OPT_MODE_OFF 1
|
||||
#define AC3ENC_OPT_DSUREX_DPLIIZ 3
|
||||
|
||||
/* specific option values */
|
||||
#define AC3ENC_OPT_LARGE_ROOM 1
|
||||
#define AC3ENC_OPT_SMALL_ROOM 2
|
||||
#define AC3ENC_OPT_DOWNMIX_LTRT 1
|
||||
#define AC3ENC_OPT_DOWNMIX_LORO 2
|
||||
#define AC3ENC_OPT_DOWNMIX_DPLII 3 // reserved value in A/52, but used by encoders to indicate DPL2
|
||||
#define AC3ENC_OPT_ADCONV_STANDARD 0
|
||||
#define AC3ENC_OPT_ADCONV_HDCD 1
|
||||
|
||||
|
||||
/**
|
||||
* Encoding Options used by AVOption.
|
||||
*/
|
||||
typedef struct AC3EncOptions {
|
||||
/* AC-3 metadata options*/
|
||||
int dialogue_level;
|
||||
int bitstream_mode;
|
||||
float center_mix_level;
|
||||
float surround_mix_level;
|
||||
int dolby_surround_mode;
|
||||
int audio_production_info;
|
||||
int mixing_level;
|
||||
int room_type;
|
||||
int copyright;
|
||||
int original;
|
||||
int extended_bsi_1;
|
||||
int preferred_stereo_downmix;
|
||||
float ltrt_center_mix_level;
|
||||
float ltrt_surround_mix_level;
|
||||
float loro_center_mix_level;
|
||||
float loro_surround_mix_level;
|
||||
int extended_bsi_2;
|
||||
int dolby_surround_ex_mode;
|
||||
int dolby_headphone_mode;
|
||||
int ad_converter_type;
|
||||
int eac3_mixing_metadata;
|
||||
int eac3_info_metadata;
|
||||
|
||||
/* other encoding options */
|
||||
int allow_per_frame_metadata;
|
||||
int stereo_rematrixing;
|
||||
int channel_coupling;
|
||||
int cpl_start;
|
||||
} AC3EncOptions;
|
||||
|
||||
/**
|
||||
* Data for a single audio block.
|
||||
*/
|
||||
typedef struct AC3Block {
|
||||
CoefType *mdct_coef[AC3_MAX_CHANNELS]; ///< MDCT coefficients
|
||||
int32_t *fixed_coef[AC3_MAX_CHANNELS]; ///< fixed-point MDCT coefficients
|
||||
uint8_t *exp[AC3_MAX_CHANNELS]; ///< original exponents
|
||||
uint8_t *grouped_exp[AC3_MAX_CHANNELS]; ///< grouped exponents
|
||||
int16_t *psd[AC3_MAX_CHANNELS]; ///< psd per frequency bin
|
||||
int16_t *band_psd[AC3_MAX_CHANNELS]; ///< psd per critical band
|
||||
int16_t *mask[AC3_MAX_CHANNELS]; ///< masking curve
|
||||
uint16_t *qmant[AC3_MAX_CHANNELS]; ///< quantized mantissas
|
||||
uint8_t *cpl_coord_exp[AC3_MAX_CHANNELS]; ///< coupling coord exponents (cplcoexp)
|
||||
uint8_t *cpl_coord_mant[AC3_MAX_CHANNELS]; ///< coupling coord mantissas (cplcomant)
|
||||
uint8_t new_rematrixing_strategy; ///< send new rematrixing flags in this block
|
||||
int num_rematrixing_bands; ///< number of rematrixing bands
|
||||
uint8_t rematrixing_flags[4]; ///< rematrixing flags
|
||||
int new_cpl_strategy; ///< send new coupling strategy
|
||||
int cpl_in_use; ///< coupling in use for this block (cplinu)
|
||||
uint8_t channel_in_cpl[AC3_MAX_CHANNELS]; ///< channel in coupling (chincpl)
|
||||
int num_cpl_channels; ///< number of channels in coupling
|
||||
uint8_t new_cpl_coords[AC3_MAX_CHANNELS]; ///< send new coupling coordinates (cplcoe)
|
||||
uint8_t cpl_master_exp[AC3_MAX_CHANNELS]; ///< coupling coord master exponents (mstrcplco)
|
||||
int new_snr_offsets; ///< send new SNR offsets
|
||||
int new_cpl_leak; ///< send new coupling leak info
|
||||
int end_freq[AC3_MAX_CHANNELS]; ///< end frequency bin (endmant)
|
||||
} AC3Block;
|
||||
|
||||
struct PutBitContext;
|
||||
|
||||
/**
|
||||
* AC-3 encoder private context.
|
||||
*/
|
||||
typedef struct AC3EncodeContext {
|
||||
AVClass *av_class; ///< AVClass used for AVOption
|
||||
AC3EncOptions options; ///< encoding options
|
||||
AVCodecContext *avctx; ///< parent AVCodecContext
|
||||
AudioDSPContext adsp;
|
||||
#if AC3ENC_FLOAT
|
||||
AVFloatDSPContext *fdsp;
|
||||
#else
|
||||
AVFixedDSPContext *fdsp;
|
||||
#endif
|
||||
MECmpContext mecc;
|
||||
AC3DSPContext ac3dsp; ///< AC-3 optimized functions
|
||||
AVTXContext *tx; ///< FFT context for MDCT calculation
|
||||
av_tx_fn tx_fn;
|
||||
|
||||
AC3Block blocks[AC3_MAX_BLOCKS]; ///< per-block info
|
||||
|
||||
int fixed_point; ///< indicates if fixed-point encoder is being used
|
||||
int eac3; ///< indicates if this is E-AC-3 vs. AC-3
|
||||
int bitstream_id; ///< bitstream id (bsid)
|
||||
int bitstream_mode; ///< bitstream mode (bsmod)
|
||||
|
||||
int bit_rate; ///< target bit rate, in bits-per-second
|
||||
int sample_rate; ///< sampling frequency, in Hz
|
||||
|
||||
int num_blks_code; ///< number of blocks code (numblkscod)
|
||||
int num_blocks; ///< number of blocks per frame
|
||||
int frame_size_min; ///< minimum frame size in case rounding is necessary
|
||||
int frame_size; ///< current frame size in bytes
|
||||
int frame_size_code; ///< frame size code (frmsizecod)
|
||||
uint16_t crc_inv[2];
|
||||
int64_t bits_written; ///< bit count (used to avg. bitrate)
|
||||
int64_t samples_written; ///< sample count (used to avg. bitrate)
|
||||
|
||||
int fbw_channels; ///< number of full-bandwidth channels (nfchans)
|
||||
int channels; ///< total number of channels (nchans)
|
||||
int lfe_on; ///< indicates if there is an LFE channel (lfeon)
|
||||
int lfe_channel; ///< channel index of the LFE channel
|
||||
int has_center; ///< indicates if there is a center channel
|
||||
int has_surround; ///< indicates if there are one or more surround channels
|
||||
int channel_mode; ///< channel mode (acmod)
|
||||
const uint8_t *channel_map; ///< channel map used to reorder channels
|
||||
|
||||
int center_mix_level; ///< center mix level code
|
||||
int surround_mix_level; ///< surround mix level code
|
||||
int ltrt_center_mix_level; ///< Lt/Rt center mix level code
|
||||
int ltrt_surround_mix_level; ///< Lt/Rt surround mix level code
|
||||
int loro_center_mix_level; ///< Lo/Ro center mix level code
|
||||
int loro_surround_mix_level; ///< Lo/Ro surround mix level code
|
||||
|
||||
int cutoff; ///< user-specified cutoff frequency, in Hz
|
||||
int bandwidth_code; ///< bandwidth code (0 to 60) (chbwcod)
|
||||
int start_freq[AC3_MAX_CHANNELS]; ///< start frequency bin (strtmant)
|
||||
int cpl_end_freq; ///< coupling channel end frequency bin
|
||||
|
||||
int cpl_on; ///< coupling turned on for this frame
|
||||
int cpl_enabled; ///< coupling enabled for all frames
|
||||
int num_cpl_subbands; ///< number of coupling subbands (ncplsubnd)
|
||||
int num_cpl_bands; ///< number of coupling bands (ncplbnd)
|
||||
uint8_t cpl_band_sizes[AC3_MAX_CPL_BANDS]; ///< number of coeffs in each coupling band
|
||||
|
||||
int rematrixing_enabled; ///< stereo rematrixing enabled
|
||||
|
||||
/* bitrate allocation control */
|
||||
int slow_gain_code; ///< slow gain code (sgaincod)
|
||||
int slow_decay_code; ///< slow decay code (sdcycod)
|
||||
int fast_decay_code; ///< fast decay code (fdcycod)
|
||||
int db_per_bit_code; ///< dB/bit code (dbpbcod)
|
||||
int floor_code; ///< floor code (floorcod)
|
||||
AC3BitAllocParameters bit_alloc; ///< bit allocation parameters
|
||||
int coarse_snr_offset; ///< coarse SNR offsets (csnroffst)
|
||||
int fast_gain_code[AC3_MAX_CHANNELS]; ///< fast gain codes (signal-to-mask ratio) (fgaincod)
|
||||
int fine_snr_offset[AC3_MAX_CHANNELS]; ///< fine SNR offsets (fsnroffst)
|
||||
int frame_bits_fixed; ///< number of non-coefficient bits for fixed parameters
|
||||
int frame_bits; ///< all frame bits except exponents and mantissas
|
||||
int exponent_bits; ///< number of bits used for exponents
|
||||
|
||||
uint8_t *planar_samples[AC3_MAX_CHANNELS - 1];
|
||||
uint8_t *bap_buffer;
|
||||
uint8_t *bap1_buffer;
|
||||
CoefType *mdct_coef_buffer;
|
||||
int32_t *fixed_coef_buffer;
|
||||
uint8_t *exp_buffer;
|
||||
uint8_t *grouped_exp_buffer;
|
||||
int16_t *psd_buffer;
|
||||
int16_t *band_psd_buffer;
|
||||
int16_t *mask_buffer;
|
||||
int16_t *qmant_buffer;
|
||||
uint8_t *cpl_coord_buffer;
|
||||
|
||||
uint8_t exp_strategy[AC3_MAX_CHANNELS][AC3_MAX_BLOCKS]; ///< exponent strategies
|
||||
uint8_t frame_exp_strategy[AC3_MAX_CHANNELS]; ///< frame exp strategy index
|
||||
int use_frame_exp_strategy; ///< indicates use of frame exp strategy
|
||||
uint8_t exp_ref_block[AC3_MAX_CHANNELS][AC3_MAX_BLOCKS]; ///< reference blocks for EXP_REUSE
|
||||
uint8_t *ref_bap [AC3_MAX_CHANNELS][AC3_MAX_BLOCKS]; ///< bit allocation pointers (bap)
|
||||
int ref_bap_set; ///< indicates if ref_bap pointers have been set
|
||||
|
||||
/** fixed vs. float function pointers */
|
||||
void (*encode_frame)(struct AC3EncodeContext *s, uint8_t * const *samples);
|
||||
|
||||
/* AC-3 vs. E-AC-3 function pointers */
|
||||
void (*output_frame_header)(struct AC3EncodeContext *s, struct PutBitContext *pb);
|
||||
|
||||
union {
|
||||
DECLARE_ALIGNED(32, float, mdct_window_float)[AC3_BLOCK_SIZE];
|
||||
DECLARE_ALIGNED(32, int32_t, mdct_window_fixed)[AC3_BLOCK_SIZE];
|
||||
};
|
||||
union {
|
||||
DECLARE_ALIGNED(32, float, windowed_samples_float)[AC3_WINDOW_SIZE];
|
||||
DECLARE_ALIGNED(32, int32_t, windowed_samples_fixed)[AC3_WINDOW_SIZE];
|
||||
};
|
||||
} AC3EncodeContext;
|
||||
|
||||
extern const AVChannelLayout ff_ac3_ch_layouts[19];
|
||||
extern const AVOption ff_ac3_enc_options[];
|
||||
extern const AVClass ff_ac3enc_class;
|
||||
extern const FFCodecDefault ff_ac3_enc_defaults[];
|
||||
|
||||
int ff_ac3_encode_init(AVCodecContext *avctx);
|
||||
int ff_ac3_float_encode_init(AVCodecContext *avctx);
|
||||
|
||||
int ff_ac3_encode_close(AVCodecContext *avctx);
|
||||
|
||||
|
||||
void ff_ac3_compute_coupling_strategy(AC3EncodeContext *s);
|
||||
|
||||
int ff_ac3_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
|
||||
const AVFrame *frame, int *got_packet_ptr);
|
||||
|
||||
#endif /* AVCODEC_AC3ENC_H */
|
||||
56
include/libavcodec/ac3tab.h
Normal file
56
include/libavcodec/ac3tab.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* AC-3 tables
|
||||
* Copyright (c) 2000, 2001, 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 AVCODEC_AC3TAB_H
|
||||
#define AVCODEC_AC3TAB_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "ac3defs.h"
|
||||
|
||||
extern const uint16_t ff_ac3_frame_size_tab[38][3];
|
||||
extern const uint8_t ff_ac3_channels_tab[8];
|
||||
extern const uint16_t ff_ac3_channel_layout_tab[8];
|
||||
extern const uint8_t ff_ac3_dec_channel_map[8][2][6];
|
||||
extern const int ff_ac3_sample_rate_tab[];
|
||||
extern const uint16_t ff_ac3_bitrate_tab[19];
|
||||
extern const uint8_t ff_ac3_rematrix_band_tab[5];
|
||||
extern const uint8_t ff_eac3_default_cpl_band_struct[18];
|
||||
extern const uint8_t ff_ac3_bap_tab[64];
|
||||
extern const uint8_t ff_ac3_slow_decay_tab[4];
|
||||
extern const uint8_t ff_ac3_fast_decay_tab[4];
|
||||
extern const uint16_t ff_ac3_slow_gain_tab[4];
|
||||
extern const uint16_t ff_ac3_db_per_bit_tab[4];
|
||||
extern const int16_t ff_ac3_floor_tab[8];
|
||||
extern const uint16_t ff_ac3_fast_gain_tab[8];
|
||||
extern const uint8_t ff_ac3_band_start_tab[AC3_CRITICAL_BANDS+1];
|
||||
extern const uint8_t ff_ac3_bin_to_band_tab[253];
|
||||
extern const uint64_t ff_eac3_custom_channel_map_locations[16][2];
|
||||
|
||||
#define COMMON_CHANNEL_MAP \
|
||||
{ { 0, 1, }, { 0, 1, 2, } },\
|
||||
{ { 0, }, { 0, 1, } },\
|
||||
{ { 0, 1, }, { 0, 1, 2, } },\
|
||||
{ { 0, 2, 1, }, { 0, 2, 1, 3, } },\
|
||||
{ { 0, 1, 2, }, { 0, 1, 3, 2, } },\
|
||||
{ { 0, 2, 1, 3, }, { 0, 2, 1, 4, 3, } },
|
||||
|
||||
#endif /* AVCODEC_AC3TAB_H */
|
||||
152
include/libavcodec/acelp_filters.h
Normal file
152
include/libavcodec/acelp_filters.h
Normal file
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
* various filters for ACELP-based codecs
|
||||
*
|
||||
* Copyright (c) 2008 Vladimir Voroshilov
|
||||
*
|
||||
* 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_ACELP_FILTERS_H
|
||||
#define AVCODEC_ACELP_FILTERS_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct ACELPFContext {
|
||||
/**
|
||||
* Floating point version of ff_acelp_interpolate()
|
||||
*/
|
||||
void (*acelp_interpolatef)(float *out, const float *in,
|
||||
const float *filter_coeffs, int precision,
|
||||
int frac_pos, int filter_length, int length);
|
||||
|
||||
/**
|
||||
* Apply an order 2 rational transfer function in-place.
|
||||
*
|
||||
* @param out output buffer for filtered speech samples
|
||||
* @param in input buffer containing speech data (may be the same as out)
|
||||
* @param zero_coeffs z^-1 and z^-2 coefficients of the numerator
|
||||
* @param pole_coeffs z^-1 and z^-2 coefficients of the denominator
|
||||
* @param gain scale factor for final output
|
||||
* @param mem intermediate values used by filter (should be 0 initially)
|
||||
* @param n number of samples (should be a multiple of eight)
|
||||
*/
|
||||
void (*acelp_apply_order_2_transfer_function)(float *out, const float *in,
|
||||
const float zero_coeffs[2],
|
||||
const float pole_coeffs[2],
|
||||
float gain,
|
||||
float mem[2], int n);
|
||||
|
||||
}ACELPFContext;
|
||||
|
||||
/**
|
||||
* Initialize ACELPFContext.
|
||||
*/
|
||||
void ff_acelp_filter_init(ACELPFContext *c);
|
||||
void ff_acelp_filter_init_mips(ACELPFContext *c);
|
||||
|
||||
/**
|
||||
* low-pass Finite Impulse Response filter coefficients.
|
||||
*
|
||||
* Hamming windowed sinc filter with cutoff freq 3/40 of the sampling freq,
|
||||
* the coefficients are scaled by 2^15.
|
||||
* This array only contains the right half of the filter.
|
||||
* This filter is likely identical to the one used in G.729, though this
|
||||
* could not be determined from the original comments with certainty.
|
||||
*/
|
||||
extern const int16_t ff_acelp_interp_filter[61];
|
||||
|
||||
/**
|
||||
* Generic FIR interpolation routine.
|
||||
* @param[out] out buffer for interpolated data
|
||||
* @param in input data
|
||||
* @param filter_coeffs interpolation filter coefficients (0.15)
|
||||
* @param precision sub sample factor, that is the precision of the position
|
||||
* @param frac_pos fractional part of position [0..precision-1]
|
||||
* @param filter_length filter length
|
||||
* @param length length of output
|
||||
*
|
||||
* filter_coeffs contains coefficients of the right half of the symmetric
|
||||
* interpolation filter. filter_coeffs[0] should the central (unpaired) coefficient.
|
||||
* See ff_acelp_interp_filter for an example.
|
||||
*/
|
||||
void ff_acelp_interpolate(int16_t* out, const int16_t* in,
|
||||
const int16_t* filter_coeffs, int precision,
|
||||
int frac_pos, int filter_length, int length);
|
||||
|
||||
/**
|
||||
* Floating point version of ff_acelp_interpolate()
|
||||
*/
|
||||
void ff_acelp_interpolatef(float *out, const float *in,
|
||||
const float *filter_coeffs, int precision,
|
||||
int frac_pos, int filter_length, int length);
|
||||
|
||||
|
||||
/**
|
||||
* high-pass filtering and upscaling (4.2.5 of G.729).
|
||||
* @param[out] out output buffer for filtered speech data
|
||||
* @param[in,out] hpf_f past filtered data from previous (2 items long)
|
||||
* frames (-0x20000000 <= (14.13) < 0x20000000)
|
||||
* @param in speech data to process
|
||||
* @param length input data size
|
||||
*
|
||||
* out[i] = 0.93980581 * in[i] - 1.8795834 * in[i-1] + 0.93980581 * in[i-2] +
|
||||
* 1.9330735 * out[i-1] - 0.93589199 * out[i-2]
|
||||
*
|
||||
* The filter has a cut-off frequency of 1/80 of the sampling freq
|
||||
*
|
||||
* @note Two items before the top of the in buffer must contain two items from the
|
||||
* tail of the previous subframe.
|
||||
*
|
||||
* @remark It is safe to pass the same array in in and out parameters.
|
||||
*
|
||||
* @remark AMR uses mostly the same filter (cut-off frequency 60Hz, same formula,
|
||||
* but constants differs in 5th sign after comma). Fortunately in
|
||||
* fixed-point all coefficients are the same as in G.729. Thus this
|
||||
* routine can be used for the fixed-point AMR decoder, too.
|
||||
*/
|
||||
void ff_acelp_high_pass_filter(int16_t* out, int hpf_f[2],
|
||||
const int16_t* in, int length);
|
||||
|
||||
/**
|
||||
* Apply an order 2 rational transfer function in-place.
|
||||
*
|
||||
* @param out output buffer for filtered speech samples
|
||||
* @param in input buffer containing speech data (may be the same as out)
|
||||
* @param zero_coeffs z^-1 and z^-2 coefficients of the numerator
|
||||
* @param pole_coeffs z^-1 and z^-2 coefficients of the denominator
|
||||
* @param gain scale factor for final output
|
||||
* @param mem intermediate values used by filter (should be 0 initially)
|
||||
* @param n number of samples
|
||||
*/
|
||||
void ff_acelp_apply_order_2_transfer_function(float *out, const float *in,
|
||||
const float zero_coeffs[2],
|
||||
const float pole_coeffs[2],
|
||||
float gain,
|
||||
float mem[2], int n);
|
||||
|
||||
/**
|
||||
* Apply tilt compensation filter, 1 - tilt * z-1.
|
||||
*
|
||||
* @param mem pointer to the filter's state (one single float)
|
||||
* @param tilt tilt factor
|
||||
* @param samples array where the filter is applied
|
||||
* @param size the size of the samples array
|
||||
*/
|
||||
void ff_tilt_compensation(float *mem, float tilt, float *samples, int size);
|
||||
|
||||
|
||||
#endif /* AVCODEC_ACELP_FILTERS_H */
|
||||
276
include/libavcodec/acelp_pitch_delay.h
Normal file
276
include/libavcodec/acelp_pitch_delay.h
Normal file
@@ -0,0 +1,276 @@
|
||||
/*
|
||||
* gain code, gain pitch and pitch delay decoding
|
||||
*
|
||||
* Copyright (c) 2008 Vladimir Voroshilov
|
||||
*
|
||||
* 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_ACELP_PITCH_DELAY_H
|
||||
#define AVCODEC_ACELP_PITCH_DELAY_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "audiodsp.h"
|
||||
|
||||
#define PITCH_DELAY_MIN 20
|
||||
#define PITCH_DELAY_MAX 143
|
||||
|
||||
/**
|
||||
* @brief Decode pitch delay of the first subframe encoded by 8 bits with 1/3
|
||||
* resolution.
|
||||
* @param ac_index adaptive codebook index (8 bits)
|
||||
*
|
||||
* @return pitch delay in 1/3 units
|
||||
*
|
||||
* Pitch delay is coded:
|
||||
* with 1/3 resolution, 19 < pitch_delay < 85
|
||||
* integers only, 85 <= pitch_delay <= 143
|
||||
*/
|
||||
static inline int ff_acelp_decode_8bit_to_1st_delay3(int ac_index)
|
||||
{
|
||||
ac_index += 58;
|
||||
if (ac_index > 254)
|
||||
ac_index = 3 * ac_index - 510;
|
||||
return ac_index;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decode pitch delay of the second subframe encoded by 5 or 6 bits
|
||||
* with 1/3 precision.
|
||||
* @param ac_index adaptive codebook index (5 or 6 bits)
|
||||
* @param pitch_delay_min lower bound (integer) of pitch delay interval
|
||||
* for second subframe
|
||||
*
|
||||
* @return pitch delay in 1/3 units
|
||||
*
|
||||
* Pitch delay is coded:
|
||||
* with 1/3 resolution, -6 < pitch_delay - int(prev_pitch_delay) < 5
|
||||
*
|
||||
* @remark The routine is used in G.729 @@8k, AMR @@10.2k, AMR @@7.95k,
|
||||
* AMR @@7.4k for the second subframe.
|
||||
*/
|
||||
static inline int ff_acelp_decode_5_6_bit_to_2nd_delay3(int ac_index,
|
||||
int pitch_delay_min)
|
||||
{
|
||||
return 3 * pitch_delay_min + ac_index - 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decode pitch delay with 1/3 precision.
|
||||
* @param ac_index adaptive codebook index (4 bits)
|
||||
* @param pitch_delay_min lower bound (integer) of pitch delay interval for
|
||||
* second subframe
|
||||
*
|
||||
* @return pitch delay in 1/3 units
|
||||
*
|
||||
* Pitch delay is coded:
|
||||
* integers only, -6 < pitch_delay - int(prev_pitch_delay) <= -2
|
||||
* with 1/3 resolution, -2 < pitch_delay - int(prev_pitch_delay) < 1
|
||||
* integers only, 1 <= pitch_delay - int(prev_pitch_delay) < 5
|
||||
*
|
||||
* @remark The routine is used in G.729 @@6.4k, AMR @@6.7k, AMR @@5.9k,
|
||||
* AMR @@5.15k, AMR @@4.75k for the second subframe.
|
||||
*/
|
||||
static inline int ff_acelp_decode_4bit_to_2nd_delay3(int ac_index,
|
||||
int pitch_delay_min)
|
||||
{
|
||||
if (ac_index < 4)
|
||||
return 3 * (ac_index + pitch_delay_min);
|
||||
else if (ac_index < 12)
|
||||
return 3 * pitch_delay_min + ac_index + 6;
|
||||
else
|
||||
return 3 * (ac_index + pitch_delay_min) - 18;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decode pitch delay of the first subframe encoded by 9 bits
|
||||
* with 1/6 precision.
|
||||
* @param ac_index adaptive codebook index (9 bits)
|
||||
*
|
||||
* @return pitch delay in 1/6 units
|
||||
*
|
||||
* Pitch delay is coded:
|
||||
* with 1/6 resolution, 17 < pitch_delay < 95
|
||||
* integers only, 95 <= pitch_delay <= 143
|
||||
*
|
||||
* @remark The routine is used in AMR @@12.2k for the first and third subframes.
|
||||
*/
|
||||
static inline int ff_acelp_decode_9bit_to_1st_delay6(int ac_index)
|
||||
{
|
||||
if (ac_index < 463)
|
||||
return ac_index + 105;
|
||||
else
|
||||
return 6 * (ac_index - 368);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decode pitch delay of the second subframe encoded by 6 bits
|
||||
* with 1/6 precision.
|
||||
* @param ac_index adaptive codebook index (6 bits)
|
||||
* @param pitch_delay_min lower bound (integer) of pitch delay interval for
|
||||
* second subframe
|
||||
*
|
||||
* @return pitch delay in 1/6 units
|
||||
*
|
||||
* Pitch delay is coded:
|
||||
* with 1/6 resolution, -6 < pitch_delay - int(prev_pitch_delay) < 5
|
||||
*
|
||||
* @remark The routine is used in AMR @@12.2k for the second and fourth subframes.
|
||||
*/
|
||||
static inline int ff_acelp_decode_6bit_to_2nd_delay6(int ac_index,
|
||||
int pitch_delay_min)
|
||||
{
|
||||
return 6 * pitch_delay_min + ac_index - 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Update past quantized energies
|
||||
* @param[in,out] quant_energy past quantized energies (5.10)
|
||||
* @param gain_corr_factor gain correction factor
|
||||
* @param log2_ma_pred_order log2() of MA prediction order
|
||||
* @param erasure frame erasure flag
|
||||
*
|
||||
* If frame erasure flag is not equal to zero, memory is updated with
|
||||
* averaged energy, attenuated by 4dB:
|
||||
* max(avg(quant_energy[i])-4, -14), i=0,ma_pred_order
|
||||
*
|
||||
* In normal mode memory is updated with
|
||||
* Er - Ep = 20 * log10(gain_corr_factor)
|
||||
*
|
||||
* @remark The routine is used in G.729 and AMR (all modes).
|
||||
*/
|
||||
void ff_acelp_update_past_gain(
|
||||
int16_t* quant_energy,
|
||||
int gain_corr_factor,
|
||||
int log2_ma_pred_order,
|
||||
int erasure);
|
||||
|
||||
/**
|
||||
* @brief Decode the adaptive codebook gain and add
|
||||
* correction (4.1.5 and 3.9.1 of G.729).
|
||||
* @param adsp initialized audio DSP context
|
||||
* @param gain_corr_factor gain correction factor (2.13)
|
||||
* @param fc_v fixed-codebook vector (2.13)
|
||||
* @param mr_energy mean innovation energy and fixed-point correction (7.13)
|
||||
* @param[in,out] quant_energy past quantized energies (5.10)
|
||||
* @param subframe_size length of subframe
|
||||
*
|
||||
* @return quantized fixed-codebook gain (14.1)
|
||||
*
|
||||
* The routine implements equations 69, 66 and 71 of the G.729 specification (3.9.1)
|
||||
*
|
||||
* Em - mean innovation energy (dB, constant, depends on decoding algorithm)
|
||||
* Ep - mean-removed predicted energy (dB)
|
||||
* Er - mean-removed innovation energy (dB)
|
||||
* Ei - mean energy of the fixed-codebook contribution (dB)
|
||||
* N - subframe_size
|
||||
* M - MA (Moving Average) prediction order
|
||||
* gc - fixed-codebook gain
|
||||
* gc_p - predicted fixed-codebook gain
|
||||
*
|
||||
* Fixed codebook gain is computed using predicted gain gc_p and
|
||||
* correction factor gain_corr_factor as shown below:
|
||||
*
|
||||
* gc = gc_p * gain_corr_factor
|
||||
*
|
||||
* The predicted fixed codebook gain gc_p is found by predicting
|
||||
* the energy of the fixed-codebook contribution from the energy
|
||||
* of previous fixed-codebook contributions.
|
||||
*
|
||||
* mean = 1/N * sum(i,0,N){ fc_v[i] * fc_v[i] }
|
||||
*
|
||||
* Ei = 10log(mean)
|
||||
*
|
||||
* Er = 10log(1/N * gc^2 * mean) - Em = 20log(gc) + Ei - Em
|
||||
*
|
||||
* Replacing Er with Ep and gc with gc_p we will receive:
|
||||
*
|
||||
* Ep = 10log(1/N * gc_p^2 * mean) - Em = 20log(gc_p) + Ei - Em
|
||||
*
|
||||
* and from above:
|
||||
*
|
||||
* gc_p = 10^((Ep - Ei + Em) / 20)
|
||||
*
|
||||
* Ep is predicted using past energies and prediction coefficients:
|
||||
*
|
||||
* Ep = sum(i,0,M){ ma_prediction_coeff[i] * quant_energy[i] }
|
||||
*
|
||||
* gc_p in fixed-point arithmetic is calculated as following:
|
||||
*
|
||||
* mean = 1/N * sum(i,0,N){ (fc_v[i] / 2^13) * (fc_v[i] / 2^13) } =
|
||||
* = 1/N * sum(i,0,N) { fc_v[i] * fc_v[i] } / 2^26
|
||||
*
|
||||
* Ei = 10log(mean) = -10log(N) - 10log(2^26) +
|
||||
* + 10log(sum(i,0,N) { fc_v[i] * fc_v[i] })
|
||||
*
|
||||
* Ep - Ei + Em = Ep + Em + 10log(N) + 10log(2^26) -
|
||||
* - 10log(sum(i,0,N) { fc_v[i] * fc_v[i] }) =
|
||||
* = Ep + mr_energy - 10log(sum(i,0,N) { fc_v[i] * fc_v[i] })
|
||||
*
|
||||
* gc_p = 10 ^ ((Ep - Ei + Em) / 20) =
|
||||
* = 2 ^ (3.3219 * (Ep - Ei + Em) / 20) = 2 ^ (0.166 * (Ep - Ei + Em))
|
||||
*
|
||||
* where
|
||||
*
|
||||
* mr_energy = Em + 10log(N) + 10log(2^26)
|
||||
*
|
||||
* @remark The routine is used in G.729 and AMR (all modes).
|
||||
*/
|
||||
int16_t ff_acelp_decode_gain_code(
|
||||
AudioDSPContext *adsp,
|
||||
int gain_corr_factor,
|
||||
const int16_t* fc_v,
|
||||
int mr_energy,
|
||||
const int16_t* quant_energy,
|
||||
const int16_t* ma_prediction_coeff,
|
||||
int subframe_size,
|
||||
int max_pred_order);
|
||||
|
||||
/**
|
||||
* Calculate fixed gain (part of section 6.1.3 of AMR spec)
|
||||
*
|
||||
* @param fixed_gain_factor gain correction factor
|
||||
* @param fixed_mean_energy mean decoded algebraic codebook vector energy
|
||||
* @param prediction_error vector of the quantified predictor errors of
|
||||
* the four previous subframes. It is updated by this function.
|
||||
* @param energy_mean desired mean innovation energy
|
||||
* @param pred_table table of four moving average coefficients
|
||||
*/
|
||||
float ff_amr_set_fixed_gain(float fixed_gain_factor, float fixed_mean_energy,
|
||||
float *prediction_error, float energy_mean,
|
||||
const float *pred_table);
|
||||
|
||||
|
||||
/**
|
||||
* Decode the adaptive codebook index to the integer and fractional parts
|
||||
* of the pitch lag for one subframe at 1/3 fractional precision.
|
||||
*
|
||||
* The choice of pitch lag is described in 3GPP TS 26.090 section 5.6.1.
|
||||
*
|
||||
* @param lag_int integer part of pitch lag of the current subframe
|
||||
* @param lag_frac fractional part of pitch lag of the current subframe
|
||||
* @param pitch_index parsed adaptive codebook (pitch) index
|
||||
* @param prev_lag_int integer part of pitch lag for the previous subframe
|
||||
* @param subframe current subframe number
|
||||
* @param third_as_first treat the third frame the same way as the first
|
||||
*/
|
||||
void ff_decode_pitch_lag(int *lag_int, int *lag_frac, int pitch_index,
|
||||
const int prev_lag_int, const int subframe,
|
||||
int third_as_first, int resolution);
|
||||
|
||||
#endif /* AVCODEC_ACELP_PITCH_DELAY_H */
|
||||
287
include/libavcodec/acelp_vectors.h
Normal file
287
include/libavcodec/acelp_vectors.h
Normal file
@@ -0,0 +1,287 @@
|
||||
/*
|
||||
* adaptive and fixed codebook vector operations for ACELP-based codecs
|
||||
*
|
||||
* Copyright (c) 2008 Vladimir Voroshilov
|
||||
*
|
||||
* 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_ACELP_VECTORS_H
|
||||
#define AVCODEC_ACELP_VECTORS_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct ACELPVContext {
|
||||
/**
|
||||
* float implementation of weighted sum of two vectors.
|
||||
* @param[out] out result of addition
|
||||
* @param in_a first vector
|
||||
* @param in_b second vector
|
||||
* @param weight_coeff_a first vector weight coefficient
|
||||
* @param weight_coeff_a second vector weight coefficient
|
||||
* @param length vectors length (should be a multiple of two)
|
||||
*
|
||||
* @note It is safe to pass the same buffer for out and in_a or in_b.
|
||||
*/
|
||||
void (*weighted_vector_sumf)(float *out, const float *in_a, const float *in_b,
|
||||
float weight_coeff_a, float weight_coeff_b,
|
||||
int length);
|
||||
|
||||
}ACELPVContext;
|
||||
|
||||
/**
|
||||
* Initialize ACELPVContext.
|
||||
*/
|
||||
void ff_acelp_vectors_init(ACELPVContext *c);
|
||||
void ff_acelp_vectors_init_mips(ACELPVContext *c);
|
||||
|
||||
/** Sparse representation for the algebraic codebook (fixed) vector */
|
||||
typedef struct AMRFixed {
|
||||
int n;
|
||||
int x[10];
|
||||
float y[10];
|
||||
int no_repeat_mask;
|
||||
int pitch_lag;
|
||||
float pitch_fac;
|
||||
} AMRFixed;
|
||||
|
||||
/**
|
||||
* Track|Pulse| Positions
|
||||
* -------------------------------------------------------------------------
|
||||
* 1 | 0 | 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75
|
||||
* -------------------------------------------------------------------------
|
||||
* 2 | 1 | 1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56, 61, 66, 71, 76
|
||||
* -------------------------------------------------------------------------
|
||||
* 3 | 2 | 2, 7, 12, 17, 22, 27, 32, 37, 42, 47, 52, 57, 62, 67, 72, 77
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Table contains only first the pulse indexes.
|
||||
*
|
||||
* Used in G.729 @@8k, G.729 @@4.4k, AMR @@7.95k, AMR @@7.40k
|
||||
*/
|
||||
extern const uint8_t ff_fc_4pulses_8bits_tracks_13[16];
|
||||
|
||||
/**
|
||||
* Track|Pulse| Positions
|
||||
* -------------------------------------------------------------------------
|
||||
* 4 | 3 | 3, 8, 13, 18, 23, 28, 33, 38, 43, 48, 53, 58, 63, 68, 73, 78
|
||||
* | | 4, 9, 14, 19, 24, 29, 34, 39, 44, 49, 54, 59, 64, 69, 74, 79
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* @remark Track in the table should be read top-to-bottom, left-to-right.
|
||||
*
|
||||
* Used in G.729 @@8k, G.729 @@4.4k, AMR @@7.95k, AMR @@7.40k
|
||||
*/
|
||||
extern const uint8_t ff_fc_4pulses_8bits_track_4[32];
|
||||
|
||||
/**
|
||||
* Track|Pulse| Positions
|
||||
* -----------------------------------------
|
||||
* 1 | 0 | 1, 6, 11, 16, 21, 26, 31, 36
|
||||
* | | 3, 8, 13, 18, 23, 28, 33, 38
|
||||
* -----------------------------------------
|
||||
*
|
||||
* @remark Track in the table should be read top-to-bottom, left-to-right.
|
||||
*
|
||||
* @note (EE) Reference G.729D code also uses gray decoding for each
|
||||
* pulse index before looking up the value in the table.
|
||||
*
|
||||
* Used in G.729 @@6.4k (with gray coding), AMR @@5.9k (without gray coding)
|
||||
*/
|
||||
extern const uint8_t ff_fc_2pulses_9bits_track1_gray[16];
|
||||
|
||||
/**
|
||||
* Track|Pulse| Positions
|
||||
* -----------------------------------------
|
||||
* 2 | 1 | 0, 7, 14, 20, 27, 34, 1, 21
|
||||
* | | 2, 9, 15, 22, 29, 35, 6, 26
|
||||
* | | 4,10, 17, 24, 30, 37, 11, 31
|
||||
* | | 5,12, 19, 25, 32, 39, 16, 36
|
||||
* -----------------------------------------
|
||||
*
|
||||
* @remark Track in the table should be read top-to-bottom, left-to-right.
|
||||
*
|
||||
* @note (EE.1) This table (from the reference code) does not comply with
|
||||
* the specification.
|
||||
* The specification contains the following table:
|
||||
*
|
||||
* Track|Pulse| Positions
|
||||
* -----------------------------------------
|
||||
* 2 | 1 | 0, 5, 10, 15, 20, 25, 30, 35
|
||||
* | | 1, 6, 11, 16, 21, 26, 31, 36
|
||||
* | | 2, 7, 12, 17, 22, 27, 32, 37
|
||||
* | | 4, 9, 14, 19, 24, 29, 34, 39
|
||||
*
|
||||
* -----------------------------------------
|
||||
*
|
||||
* @note (EE.2) Reference G.729D code also uses gray decoding for each
|
||||
* pulse index before looking up the value in the table.
|
||||
*
|
||||
* Used in G.729 @@6.4k (with gray coding)
|
||||
*/
|
||||
extern const uint8_t ff_fc_2pulses_9bits_track2_gray[32];
|
||||
|
||||
/**
|
||||
* b60 hamming windowed sinc function coefficients
|
||||
*/
|
||||
extern const float ff_b60_sinc[61];
|
||||
|
||||
/**
|
||||
* Table of pow(0.7,n)
|
||||
*/
|
||||
extern const float ff_pow_0_7[10];
|
||||
|
||||
/**
|
||||
* Table of pow(0.75,n)
|
||||
*/
|
||||
extern const float ff_pow_0_75[10];
|
||||
|
||||
/**
|
||||
* Table of pow(0.55,n)
|
||||
*/
|
||||
extern const float ff_pow_0_55[10];
|
||||
|
||||
/**
|
||||
* Decode fixed-codebook vector (3.8 and D.5.8 of G.729, 5.7.1 of AMR).
|
||||
* @param[out] fc_v decoded fixed codebook vector (2.13)
|
||||
* @param tab1 table used for first pulse_count pulses
|
||||
* @param tab2 table used for last pulse
|
||||
* @param pulse_indexes fixed codebook indexes
|
||||
* @param pulse_signs signs of the excitation pulses (0 bit value
|
||||
* means negative sign)
|
||||
* @param bits number of bits per one pulse index
|
||||
* @param pulse_count number of pulses decoded using first table
|
||||
* @param bits length of one pulse index in bits
|
||||
*
|
||||
* Used in G.729 @@8k, G.729 @@4.4k, G.729 @@6.4k, AMR @@7.95k, AMR @@7.40k
|
||||
*/
|
||||
void ff_acelp_fc_pulse_per_track(int16_t* fc_v,
|
||||
const uint8_t *tab1,
|
||||
const uint8_t *tab2,
|
||||
int pulse_indexes,
|
||||
int pulse_signs,
|
||||
int pulse_count,
|
||||
int bits);
|
||||
|
||||
/**
|
||||
* Decode the algebraic codebook index to pulse positions and signs and
|
||||
* construct the algebraic codebook vector for MODE_12k2.
|
||||
*
|
||||
* @note: The positions and signs are explicitly coded in MODE_12k2.
|
||||
*
|
||||
* @param fixed_index positions of the ten pulses
|
||||
* @param fixed_sparse pointer to the algebraic codebook vector
|
||||
* @param gray_decode gray decoding table
|
||||
* @param half_pulse_count number of couples of pulses
|
||||
* @param bits length of one pulse index in bits
|
||||
*/
|
||||
void ff_decode_10_pulses_35bits(const int16_t *fixed_index,
|
||||
AMRFixed *fixed_sparse,
|
||||
const uint8_t *gray_decode,
|
||||
int half_pulse_count, int bits);
|
||||
|
||||
|
||||
/**
|
||||
* weighted sum of two vectors with rounding.
|
||||
* @param[out] out result of addition
|
||||
* @param in_a first vector
|
||||
* @param in_b second vector
|
||||
* @param weight_coeff_a first vector weight coefficient
|
||||
* @param weight_coeff_a second vector weight coefficient
|
||||
* @param rounder this value will be added to the sum of the two vectors
|
||||
* @param shift result will be shifted to right by this value
|
||||
* @param length vectors length
|
||||
*
|
||||
* @note It is safe to pass the same buffer for out and in_a or in_b.
|
||||
*
|
||||
* out[i] = (in_a[i]*weight_a + in_b[i]*weight_b + rounder) >> shift
|
||||
*/
|
||||
void ff_acelp_weighted_vector_sum(int16_t* out,
|
||||
const int16_t *in_a,
|
||||
const int16_t *in_b,
|
||||
int16_t weight_coeff_a,
|
||||
int16_t weight_coeff_b,
|
||||
int16_t rounder,
|
||||
int shift,
|
||||
int length);
|
||||
|
||||
/**
|
||||
* float implementation of weighted sum of two vectors.
|
||||
* @param[out] out result of addition
|
||||
* @param in_a first vector
|
||||
* @param in_b second vector
|
||||
* @param weight_coeff_a first vector weight coefficient
|
||||
* @param weight_coeff_a second vector weight coefficient
|
||||
* @param length vectors length
|
||||
*
|
||||
* @note It is safe to pass the same buffer for out and in_a or in_b.
|
||||
*/
|
||||
void ff_weighted_vector_sumf(float *out, const float *in_a, const float *in_b,
|
||||
float weight_coeff_a, float weight_coeff_b,
|
||||
int length);
|
||||
|
||||
/**
|
||||
* Adaptive gain control (as used in AMR postfiltering)
|
||||
*
|
||||
* @param out output buffer for filtered speech data
|
||||
* @param in the input speech buffer (may be the same as out)
|
||||
* @param speech_energ input energy
|
||||
* @param size the input buffer size
|
||||
* @param alpha exponential filter factor
|
||||
* @param gain_mem a pointer to the filter memory (single float of size)
|
||||
*/
|
||||
void ff_adaptive_gain_control(float *out, const float *in, float speech_energ,
|
||||
int size, float alpha, float *gain_mem);
|
||||
|
||||
/**
|
||||
* Set the sum of squares of a signal by scaling
|
||||
*
|
||||
* @param out output samples
|
||||
* @param in input samples
|
||||
* @param sum_of_squares new sum of squares
|
||||
* @param n number of samples
|
||||
*
|
||||
* @note If the input is zero (or its energy underflows), the output is zero.
|
||||
* This is the behavior of AGC in the AMR reference decoder. The QCELP
|
||||
* reference decoder seems to have undefined behavior.
|
||||
*
|
||||
* TIA/EIA/IS-733 2.4.8.3-2/3/4/5, 2.4.8.6
|
||||
* 3GPP TS 26.090 6.1 (6)
|
||||
*/
|
||||
void ff_scale_vector_to_given_sum_of_squares(float *out, const float *in,
|
||||
float sum_of_squares, const int n);
|
||||
|
||||
/**
|
||||
* Add fixed vector to an array from a sparse representation
|
||||
*
|
||||
* @param out fixed vector with pitch sharpening
|
||||
* @param in sparse fixed vector
|
||||
* @param scale number to multiply the fixed vector by
|
||||
* @param size the output vector size
|
||||
*/
|
||||
void ff_set_fixed_vector(float *out, const AMRFixed *in, float scale, int size);
|
||||
|
||||
/**
|
||||
* Clear array values set by set_fixed_vector
|
||||
*
|
||||
* @param out fixed vector to be cleared
|
||||
* @param in sparse fixed vector
|
||||
* @param size the output vector size
|
||||
*/
|
||||
void ff_clear_fixed_vector(float *out, const AMRFixed *in, int size);
|
||||
|
||||
#endif /* AVCODEC_ACELP_VECTORS_H */
|
||||
48
include/libavcodec/adpcm.h
Normal file
48
include/libavcodec/adpcm.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 The FFmpeg project
|
||||
*
|
||||
* 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
|
||||
* ADPCM encoder/decoder common header.
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_ADPCM_H
|
||||
#define AVCODEC_ADPCM_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct ADPCMChannelStatus {
|
||||
int predictor;
|
||||
int16_t step_index;
|
||||
int step;
|
||||
/* for encoding */
|
||||
int prev_sample;
|
||||
|
||||
/* MS version */
|
||||
int sample1;
|
||||
int sample2;
|
||||
int coeff1;
|
||||
int coeff2;
|
||||
int idelta;
|
||||
} ADPCMChannelStatus;
|
||||
|
||||
int16_t ff_adpcm_argo_expand_nibble(ADPCMChannelStatus *cs, int nibble, int shift, int flag);
|
||||
|
||||
#endif /* AVCODEC_ADPCM_H */
|
||||
42
include/libavcodec/adpcm_data.h
Normal file
42
include/libavcodec/adpcm_data.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 The FFmpeg project
|
||||
*
|
||||
* 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
|
||||
* ADPCM tables
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_ADPCM_DATA_H
|
||||
#define AVCODEC_ADPCM_DATA_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
static const uint8_t ff_adpcm_ima_block_sizes[4] = { 4, 12, 4, 20 };
|
||||
static const uint8_t ff_adpcm_ima_block_samples[4] = { 16, 32, 8, 32 };
|
||||
|
||||
extern const int8_t ff_adpcm_index_table[16];
|
||||
extern const int16_t ff_adpcm_step_table[89];
|
||||
extern const int16_t ff_adpcm_AdaptationTable[];
|
||||
extern const uint8_t ff_adpcm_AdaptCoeff1[];
|
||||
extern const int8_t ff_adpcm_AdaptCoeff2[];
|
||||
extern const int16_t ff_adpcm_yamaha_indexscale[];
|
||||
extern const int8_t ff_adpcm_yamaha_difflookup[];
|
||||
|
||||
#endif /* AVCODEC_ADPCM_DATA_H */
|
||||
79
include/libavcodec/adts_header.h
Normal file
79
include/libavcodec/adts_header.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* AAC ADTS header decoding prototypes and structures
|
||||
* Copyright (c) 2003 Fabrice Bellard
|
||||
* Copyright (c) 2003 Michael Niedermayer
|
||||
*
|
||||
* 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_ADTS_HEADER_H
|
||||
#define AVCODEC_ADTS_HEADER_H
|
||||
|
||||
#include "adts_parser.h"
|
||||
#include "defs.h"
|
||||
|
||||
typedef enum {
|
||||
AAC_PARSE_ERROR_SYNC = -0x1030c0a,
|
||||
AAC_PARSE_ERROR_SAMPLE_RATE = -0x3030c0a,
|
||||
AAC_PARSE_ERROR_FRAME_SIZE = -0x4030c0a,
|
||||
} AACParseError;
|
||||
|
||||
typedef struct AACADTSHeaderInfo {
|
||||
uint32_t sample_rate;
|
||||
uint32_t samples;
|
||||
uint32_t bit_rate;
|
||||
uint8_t crc_absent;
|
||||
uint8_t object_type;
|
||||
uint8_t sampling_index;
|
||||
uint8_t chan_config;
|
||||
uint8_t num_aac_frames;
|
||||
uint32_t frame_length;
|
||||
} AACADTSHeaderInfo;
|
||||
|
||||
struct GetBitContext;
|
||||
|
||||
/**
|
||||
* Parse the ADTS frame header to the end of the variable header, which is
|
||||
* the first 54 bits.
|
||||
* @param[in] gbc BitContext containing the first 54 bits of the frame.
|
||||
* @param[out] hdr Pointer to struct where header info is written.
|
||||
* @return the size in bytes of the header parsed on success and
|
||||
* AAC_PARSE_ERROR_* values otherwise.
|
||||
*/
|
||||
int ff_adts_header_parse(struct GetBitContext *gbc, AACADTSHeaderInfo *hdr);
|
||||
|
||||
/**
|
||||
* Wrapper around ff_adts_header_parse() for users that don't already have
|
||||
* a suitable GetBitContext.
|
||||
*/
|
||||
int ff_adts_header_parse_buf(const uint8_t buf[AV_AAC_ADTS_HEADER_SIZE + AV_INPUT_BUFFER_PADDING_SIZE],
|
||||
AACADTSHeaderInfo *hdr);
|
||||
|
||||
/**
|
||||
* Parse the ADTS frame header contained in the buffer, which is
|
||||
* the first 54 bits.
|
||||
* @param[in] buf Pointer to buffer containing the first 54 bits of the frame.
|
||||
* @param[in] size Size of buffer containing the first 54 bits of the frame.
|
||||
* @param[out] phdr Pointer to pointer to struct AACADTSHeaderInfo for which
|
||||
* memory is allocated and header info is written into it. After using the header
|
||||
* information, the allocated memory must be freed by using av_free.
|
||||
* @return 0 on success, AAC_PARSE_ERROR_* values on invalid input and
|
||||
* ordinary AVERROR codes otherwise.
|
||||
*/
|
||||
int avpriv_adts_header_parse(AACADTSHeaderInfo **phdr, const uint8_t *buf, size_t size);
|
||||
|
||||
#endif /* AVCODEC_ADTS_HEADER_H */
|
||||
64
include/libavcodec/adx.h
Normal file
64
include/libavcodec/adx.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* ADX ADPCM codecs
|
||||
* Copyright (c) 2001,2003 BERO
|
||||
*
|
||||
* 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
|
||||
* SEGA CRI adx codecs.
|
||||
*
|
||||
* Reference documents:
|
||||
* http://ku-www.ss.titech.ac.jp/~yatsushi/adx.html
|
||||
* adx2wav & wav2adx http://www.geocities.co.jp/Playtown/2004/
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_ADX_H
|
||||
#define AVCODEC_ADX_H
|
||||
|
||||
typedef struct ADXChannelState {
|
||||
int s1,s2;
|
||||
} ADXChannelState;
|
||||
|
||||
#define MAX_CHANNELS 6
|
||||
|
||||
typedef struct ADXContext {
|
||||
int channels;
|
||||
ADXChannelState prev[MAX_CHANNELS];
|
||||
int header_parsed;
|
||||
int eof;
|
||||
int cutoff;
|
||||
int coeff[2];
|
||||
} ADXContext;
|
||||
|
||||
#define COEFF_BITS 12
|
||||
|
||||
#define BLOCK_SIZE 18
|
||||
#define BLOCK_SAMPLES 32
|
||||
|
||||
/**
|
||||
* Calculate LPC coefficients based on cutoff frequency and sample rate.
|
||||
*
|
||||
* @param cutoff cutoff frequency
|
||||
* @param sample_rate sample rate
|
||||
* @param bits number of bits used to quantize coefficients
|
||||
* @param[out] coeff 2 quantized LPC coefficients
|
||||
*/
|
||||
void ff_adx_calculate_coeffs(int cutoff, int sample_rate, int bits, int *coeff);
|
||||
|
||||
#endif /* AVCODEC_ADX_H */
|
||||
48
include/libavcodec/alac_data.h
Normal file
48
include/libavcodec/alac_data.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* ALAC encoder and decoder common data
|
||||
*
|
||||
* 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_ALAC_DATA_H
|
||||
#define AVCODEC_ALAC_DATA_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libavutil/channel_layout.h"
|
||||
|
||||
enum AlacRawDataBlockType {
|
||||
/* At the moment, only SCE, CPE, LFE, and END are recognized. */
|
||||
TYPE_SCE,
|
||||
TYPE_CPE,
|
||||
TYPE_CCE,
|
||||
TYPE_LFE,
|
||||
TYPE_DSE,
|
||||
TYPE_PCE,
|
||||
TYPE_FIL,
|
||||
TYPE_END
|
||||
};
|
||||
|
||||
#define ALAC_MAX_CHANNELS 8
|
||||
|
||||
extern const uint8_t ff_alac_channel_layout_offsets[ALAC_MAX_CHANNELS][ALAC_MAX_CHANNELS];
|
||||
|
||||
extern const AVChannelLayout ff_alac_ch_layouts[ALAC_MAX_CHANNELS + 1];
|
||||
|
||||
extern const enum AlacRawDataBlockType ff_alac_channel_elements[ALAC_MAX_CHANNELS][5];
|
||||
|
||||
#endif /* AVCODEC_ALAC_DATA_H */
|
||||
35
include/libavcodec/alacdsp.h
Normal file
35
include/libavcodec/alacdsp.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_ALACDSP_H
|
||||
#define AVCODEC_ALACDSP_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct ALACDSPContext {
|
||||
void (*decorrelate_stereo)(int32_t *buffer[2], int nb_samples,
|
||||
int decorr_shift, int decorr_left_weight);
|
||||
void (*append_extra_bits[2])(int32_t *buffer[2], int32_t *extra_bits_buffer[2],
|
||||
int extra_bits, int channels, int nb_samples);
|
||||
} ALACDSPContext;
|
||||
|
||||
void ff_alacdsp_init(ALACDSPContext *c);
|
||||
void ff_alacdsp_init_riscv(ALACDSPContext *c);
|
||||
void ff_alacdsp_init_x86(ALACDSPContext *c);
|
||||
|
||||
#endif /* AVCODEC_ALACDSP_H */
|
||||
187
include/libavcodec/amfenc.h
Normal file
187
include/libavcodec/amfenc.h
Normal file
@@ -0,0 +1,187 @@
|
||||
/*
|
||||
* 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_AMFENC_H
|
||||
#define AVCODEC_AMFENC_H
|
||||
|
||||
#include <AMF/core/Factory.h>
|
||||
|
||||
#include <AMF/components/ColorSpace.h>
|
||||
#include <AMF/components/VideoEncoderVCE.h>
|
||||
#include <AMF/components/VideoEncoderHEVC.h>
|
||||
#include <AMF/components/VideoEncoderAV1.h>
|
||||
|
||||
#include "libavutil/fifo.h"
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "hwconfig.h"
|
||||
|
||||
#define MAX_LOOKAHEAD_DEPTH 41
|
||||
|
||||
/**
|
||||
* AMF trace writer callback class
|
||||
* Used to capture all AMF logging
|
||||
*/
|
||||
|
||||
typedef struct AmfTraceWriter {
|
||||
AMFTraceWriterVtbl *vtbl;
|
||||
AVCodecContext *avctx;
|
||||
} AmfTraceWriter;
|
||||
|
||||
/**
|
||||
* AMF encoder context
|
||||
*/
|
||||
|
||||
typedef struct AmfContext {
|
||||
AVClass *avclass;
|
||||
// access to AMF runtime
|
||||
amf_handle library; ///< handle to DLL library
|
||||
AMFFactory *factory; ///< pointer to AMF factory
|
||||
AMFDebug *debug; ///< pointer to AMF debug interface
|
||||
AMFTrace *trace; ///< pointer to AMF trace interface
|
||||
|
||||
amf_uint64 version; ///< version of AMF runtime
|
||||
AmfTraceWriter tracer; ///< AMF writer registered with AMF
|
||||
AMFContext *context; ///< AMF context
|
||||
//encoder
|
||||
AMFComponent *encoder; ///< AMF encoder object
|
||||
amf_bool eof; ///< flag indicating EOF happened
|
||||
AMF_SURFACE_FORMAT format; ///< AMF surface format
|
||||
|
||||
AVBufferRef *hw_device_ctx; ///< pointer to HW accelerator (decoder)
|
||||
AVBufferRef *hw_frames_ctx; ///< pointer to HW accelerator (frame allocator)
|
||||
|
||||
int hwsurfaces_in_queue;
|
||||
int hwsurfaces_in_queue_max;
|
||||
|
||||
// helpers to handle async calls
|
||||
int delayed_drain;
|
||||
AMFSurface *delayed_surface;
|
||||
AVFrame *delayed_frame;
|
||||
|
||||
// shift dts back by max_b_frames in timing
|
||||
AVFifo *timestamp_list;
|
||||
int64_t dts_delay;
|
||||
|
||||
// common encoder option options
|
||||
|
||||
int log_to_dbg;
|
||||
|
||||
// Static options, have to be set before Init() call
|
||||
int usage;
|
||||
int profile;
|
||||
int level;
|
||||
int latency;
|
||||
int preencode;
|
||||
int quality;
|
||||
int b_frame_delta_qp;
|
||||
int ref_b_frame_delta_qp;
|
||||
|
||||
// Dynamic options, can be set after Init() call
|
||||
|
||||
int rate_control_mode;
|
||||
int enforce_hrd;
|
||||
int filler_data;
|
||||
int enable_vbaq;
|
||||
int skip_frame;
|
||||
int qp_i;
|
||||
int qp_p;
|
||||
int qp_b;
|
||||
int max_au_size;
|
||||
int header_spacing;
|
||||
int b_frame_ref;
|
||||
int intra_refresh_mb;
|
||||
int coding_mode;
|
||||
int me_half_pel;
|
||||
int me_quarter_pel;
|
||||
int aud;
|
||||
int max_consecutive_b_frames;
|
||||
int max_b_frames;
|
||||
int qvbr_quality_level;
|
||||
int hw_high_motion_quality_boost;
|
||||
|
||||
// HEVC - specific options
|
||||
|
||||
int gops_per_idr;
|
||||
int header_insertion_mode;
|
||||
int min_qp_i;
|
||||
int max_qp_i;
|
||||
int min_qp_p;
|
||||
int max_qp_p;
|
||||
int tier;
|
||||
|
||||
// AV1 - specific options
|
||||
|
||||
enum AMF_VIDEO_ENCODER_AV1_ALIGNMENT_MODE_ENUM align;
|
||||
enum AMF_VIDEO_ENCODER_AV1_AQ_MODE_ENUM aq_mode;
|
||||
|
||||
// Preanalysis - specific options
|
||||
|
||||
int preanalysis;
|
||||
int pa_activity_type;
|
||||
int pa_scene_change_detection;
|
||||
int pa_scene_change_detection_sensitivity;
|
||||
int pa_static_scene_detection;
|
||||
int pa_static_scene_detection_sensitivity;
|
||||
int pa_initial_qp;
|
||||
int pa_max_qp;
|
||||
int pa_caq_strength;
|
||||
int pa_frame_sad;
|
||||
int pa_ltr;
|
||||
int pa_lookahead_buffer_depth;
|
||||
int pa_paq_mode;
|
||||
int pa_taq_mode;
|
||||
int pa_high_motion_quality_boost_mode;
|
||||
int pa_adaptive_mini_gop;
|
||||
|
||||
|
||||
} AmfContext;
|
||||
|
||||
extern const AVCodecHWConfigInternal *const ff_amfenc_hw_configs[];
|
||||
|
||||
/**
|
||||
* Common encoder initization function
|
||||
*/
|
||||
int ff_amf_encode_init(AVCodecContext *avctx);
|
||||
/**
|
||||
* Common encoder termination function
|
||||
*/
|
||||
int ff_amf_encode_close(AVCodecContext *avctx);
|
||||
|
||||
/**
|
||||
* Ecoding one frame - common function for all AMF encoders
|
||||
*/
|
||||
int ff_amf_receive_packet(AVCodecContext *avctx, AVPacket *avpkt);
|
||||
|
||||
/**
|
||||
* Supported formats
|
||||
*/
|
||||
extern const enum AVPixelFormat ff_amf_pix_fmts[];
|
||||
|
||||
int ff_amf_get_color_profile(AVCodecContext *avctx);
|
||||
|
||||
/**
|
||||
* Error handling helper
|
||||
*/
|
||||
#define AMF_RETURN_IF_FALSE(avctx, exp, ret_value, /*message,*/ ...) \
|
||||
if (!(exp)) { \
|
||||
av_log(avctx, AV_LOG_ERROR, __VA_ARGS__); \
|
||||
return ret_value; \
|
||||
}
|
||||
|
||||
#endif //AVCODEC_AMFENC_H
|
||||
70
include/libavcodec/amr.h
Normal file
70
include/libavcodec/amr.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Shared functions between AMR codecs
|
||||
*
|
||||
* Copyright (c) 2010 Marcelo Galvao Povoa
|
||||
*
|
||||
* 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_AMR_H
|
||||
#define AVCODEC_AMR_H
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "avcodec.h"
|
||||
|
||||
#ifdef AMR_USE_16BIT_TABLES
|
||||
typedef uint16_t R_TABLE_TYPE;
|
||||
#else
|
||||
typedef uint8_t R_TABLE_TYPE;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Fill the frame structure variables from bitstream by parsing the
|
||||
* given reordering table that uses the following format:
|
||||
*
|
||||
* Each field (16 bits) in the AMR Frame is stored as:
|
||||
* - one byte for the number of bits in the field
|
||||
* - one byte for the field index
|
||||
* - then, one byte for each bit of the field (from most-significant to least)
|
||||
* of the position of that bit in the AMR frame.
|
||||
*
|
||||
* @param out pointer to the frame struct
|
||||
* @param size the size in bytes of the frame struct
|
||||
* @param data input bitstream after the frame header
|
||||
* @param ord_table the reordering table as above
|
||||
*/
|
||||
static inline void ff_amr_bit_reorder(uint16_t *out, int size,
|
||||
const uint8_t *data,
|
||||
const R_TABLE_TYPE *ord_table)
|
||||
{
|
||||
int field_size;
|
||||
|
||||
memset(out, 0, size);
|
||||
while ((field_size = *ord_table++)) {
|
||||
int field = 0;
|
||||
int field_offset = *ord_table++;
|
||||
while (field_size--) {
|
||||
int bit = *ord_table++;
|
||||
field <<= 1;
|
||||
field |= data[bit >> 3] >> (bit & 7) & 1;
|
||||
}
|
||||
out[field_offset >> 1] = field;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* AVCODEC_AMR_H */
|
||||
1666
include/libavcodec/amrnbdata.h
Normal file
1666
include/libavcodec/amrnbdata.h
Normal file
File diff suppressed because it is too large
Load Diff
1890
include/libavcodec/amrwbdata.h
Normal file
1890
include/libavcodec/amrwbdata.h
Normal file
File diff suppressed because it is too large
Load Diff
55
include/libavcodec/aom_film_grain.h
Normal file
55
include/libavcodec/aom_film_grain.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* AOM film grain synthesis
|
||||
* Copyright (c) 2021 Niklas Haas <ffmpeg@haasn.xyz>
|
||||
*
|
||||
* 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
|
||||
* AOM film grain synthesis.
|
||||
* @author Niklas Haas <ffmpeg@haasn.xyz>
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_AOM_FILM_GRAIN_H
|
||||
#define AVCODEC_AOM_FILM_GRAIN_H
|
||||
|
||||
#include "libavutil/buffer.h"
|
||||
#include "libavutil/film_grain_params.h"
|
||||
|
||||
typedef struct AVFilmGrainAFGS1Params {
|
||||
int enable;
|
||||
AVBufferRef *sets[8];
|
||||
} AVFilmGrainAFGS1Params;
|
||||
|
||||
// Synthesizes film grain on top of `in` and stores the result to `out`. `out`
|
||||
// must already have been allocated and set to the same size and format as `in`.
|
||||
int ff_aom_apply_film_grain(AVFrame *out, const AVFrame *in,
|
||||
const AVFilmGrainParams *params);
|
||||
|
||||
// Parse AFGS1 parameter sets from an ITU-T T.35 payload. Returns 0 on success,
|
||||
// or a negative error code.
|
||||
int ff_aom_parse_film_grain_sets(AVFilmGrainAFGS1Params *s,
|
||||
const uint8_t *payload, int payload_size);
|
||||
|
||||
// Attach all valid film grain param sets to `frame`.
|
||||
int ff_aom_attach_film_grain_sets(const AVFilmGrainAFGS1Params *s, AVFrame *frame);
|
||||
|
||||
// Free all allocations in `s` and zero the entire struct.
|
||||
void ff_aom_uninit_film_grain_params(AVFilmGrainAFGS1Params *s);
|
||||
|
||||
#endif /* AVCODEC_AOM_FILM_GRAIN_H */
|
||||
44
include/libavcodec/apng.h
Normal file
44
include/libavcodec/apng.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* APNG common header
|
||||
* Copyright (c) 2014 Benoit Fouet
|
||||
*
|
||||
* 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
|
||||
* APNG common header
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_APNG_H
|
||||
#define AVCODEC_APNG_H
|
||||
|
||||
enum {
|
||||
APNG_DISPOSE_OP_NONE = 0,
|
||||
APNG_DISPOSE_OP_BACKGROUND = 1,
|
||||
APNG_DISPOSE_OP_PREVIOUS = 2,
|
||||
};
|
||||
|
||||
enum {
|
||||
APNG_BLEND_OP_SOURCE = 0,
|
||||
APNG_BLEND_OP_OVER = 1,
|
||||
};
|
||||
|
||||
/* Only the payload data, not including length, fourcc and CRC-32. */
|
||||
#define APNG_FCTL_CHUNK_SIZE 26
|
||||
|
||||
#endif /* AVCODEC_APNG_H */
|
||||
217
include/libavcodec/aptx.h
Normal file
217
include/libavcodec/aptx.h
Normal file
@@ -0,0 +1,217 @@
|
||||
/*
|
||||
* Audio Processing Technology codec for Bluetooth (aptX)
|
||||
*
|
||||
* Copyright (C) 2017 Aurelien Jacobs <aurel@gnuage.org>
|
||||
*
|
||||
* 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_APTX_H
|
||||
#define AVCODEC_APTX_H
|
||||
|
||||
#include "libavutil/intreadwrite.h"
|
||||
#include "avcodec.h"
|
||||
#include "mathops.h"
|
||||
|
||||
|
||||
enum channels {
|
||||
LEFT,
|
||||
RIGHT,
|
||||
NB_CHANNELS
|
||||
};
|
||||
|
||||
enum subbands {
|
||||
LF, // Low Frequency (0-5.5 kHz)
|
||||
MLF, // Medium-Low Frequency (5.5-11kHz)
|
||||
MHF, // Medium-High Frequency (11-16.5kHz)
|
||||
HF, // High Frequency (16.5-22kHz)
|
||||
NB_SUBBANDS
|
||||
};
|
||||
|
||||
#define NB_FILTERS 2
|
||||
#define FILTER_TAPS 16
|
||||
|
||||
typedef struct {
|
||||
int pos;
|
||||
int32_t buffer[2*FILTER_TAPS];
|
||||
} FilterSignal;
|
||||
|
||||
typedef struct {
|
||||
FilterSignal outer_filter_signal[NB_FILTERS];
|
||||
FilterSignal inner_filter_signal[NB_FILTERS][NB_FILTERS];
|
||||
} QMFAnalysis;
|
||||
|
||||
typedef struct {
|
||||
int32_t quantized_sample;
|
||||
int32_t quantized_sample_parity_change;
|
||||
int32_t error;
|
||||
} Quantize;
|
||||
|
||||
typedef struct {
|
||||
int32_t quantization_factor;
|
||||
int32_t factor_select;
|
||||
int32_t reconstructed_difference;
|
||||
} InvertQuantize;
|
||||
|
||||
typedef struct {
|
||||
int32_t prev_sign[2];
|
||||
int32_t s_weight[2];
|
||||
int32_t d_weight[24];
|
||||
int32_t pos;
|
||||
int32_t reconstructed_differences[48];
|
||||
int32_t previous_reconstructed_sample;
|
||||
int32_t predicted_difference;
|
||||
int32_t predicted_sample;
|
||||
} Prediction;
|
||||
|
||||
typedef struct {
|
||||
int32_t codeword_history;
|
||||
int32_t dither_parity;
|
||||
int32_t dither[NB_SUBBANDS];
|
||||
|
||||
QMFAnalysis qmf;
|
||||
Quantize quantize[NB_SUBBANDS];
|
||||
InvertQuantize invert_quantize[NB_SUBBANDS];
|
||||
Prediction prediction[NB_SUBBANDS];
|
||||
} Channel;
|
||||
|
||||
typedef struct {
|
||||
int hd;
|
||||
int block_size;
|
||||
int32_t sync_idx;
|
||||
Channel channels[NB_CHANNELS];
|
||||
} AptXContext;
|
||||
|
||||
typedef const struct {
|
||||
const int32_t *quantize_intervals;
|
||||
const int32_t *invert_quantize_dither_factors;
|
||||
const int32_t *quantize_dither_factors;
|
||||
const int16_t *quantize_factor_select_offset;
|
||||
int tables_size;
|
||||
int32_t factor_max;
|
||||
int32_t prediction_order;
|
||||
} ConstTables;
|
||||
|
||||
extern ConstTables ff_aptx_quant_tables[2][NB_SUBBANDS];
|
||||
|
||||
/* Rounded right shift with optionnal clipping */
|
||||
#define RSHIFT_SIZE(size) \
|
||||
av_always_inline \
|
||||
static int##size##_t rshift##size(int##size##_t value, int shift) \
|
||||
{ \
|
||||
int##size##_t rounding = (int##size##_t)1 << (shift - 1); \
|
||||
int##size##_t mask = ((int##size##_t)1 << (shift + 1)) - 1; \
|
||||
return ((value + rounding) >> shift) - ((value & mask) == rounding); \
|
||||
} \
|
||||
av_always_inline \
|
||||
static int##size##_t rshift##size##_clip24(int##size##_t value, int shift) \
|
||||
{ \
|
||||
return av_clip_intp2(rshift##size(value, shift), 23); \
|
||||
}
|
||||
RSHIFT_SIZE(32)
|
||||
RSHIFT_SIZE(64)
|
||||
|
||||
/*
|
||||
* Convolution filter coefficients for the outer QMF of the QMF tree.
|
||||
* The 2 sets are a mirror of each other.
|
||||
*/
|
||||
static const int32_t aptx_qmf_outer_coeffs[NB_FILTERS][FILTER_TAPS] = {
|
||||
{
|
||||
730, -413, -9611, 43626, -121026, 269973, -585547, 2801966,
|
||||
697128, -160481, 27611, 8478, -10043, 3511, 688, -897,
|
||||
},
|
||||
{
|
||||
-897, 688, 3511, -10043, 8478, 27611, -160481, 697128,
|
||||
2801966, -585547, 269973, -121026, 43626, -9611, -413, 730,
|
||||
},
|
||||
};
|
||||
|
||||
/*
|
||||
* Convolution filter coefficients for the inner QMF of the QMF tree.
|
||||
* The 2 sets are a mirror of each other.
|
||||
*/
|
||||
static const int32_t aptx_qmf_inner_coeffs[NB_FILTERS][FILTER_TAPS] = {
|
||||
{
|
||||
1033, -584, -13592, 61697, -171156, 381799, -828088, 3962579,
|
||||
985888, -226954, 39048, 11990, -14203, 4966, 973, -1268,
|
||||
},
|
||||
{
|
||||
-1268, 973, 4966, -14203, 11990, 39048, -226954, 985888,
|
||||
3962579, -828088, 381799, -171156, 61697, -13592, -584, 1033,
|
||||
},
|
||||
};
|
||||
|
||||
/*
|
||||
* Push one sample into a circular signal buffer.
|
||||
*/
|
||||
av_always_inline
|
||||
static void aptx_qmf_filter_signal_push(FilterSignal *signal, int32_t sample)
|
||||
{
|
||||
signal->buffer[signal->pos ] = sample;
|
||||
signal->buffer[signal->pos+FILTER_TAPS] = sample;
|
||||
signal->pos = (signal->pos + 1) & (FILTER_TAPS - 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Compute the convolution of the signal with the coefficients, and reduce
|
||||
* to 24 bits by applying the specified right shifting.
|
||||
*/
|
||||
av_always_inline
|
||||
static int32_t aptx_qmf_convolution(FilterSignal *signal,
|
||||
const int32_t coeffs[FILTER_TAPS],
|
||||
int shift)
|
||||
{
|
||||
int32_t *sig = &signal->buffer[signal->pos];
|
||||
int64_t e = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < FILTER_TAPS; i++)
|
||||
e += MUL64(sig[i], coeffs[i]);
|
||||
|
||||
return rshift64_clip24(e, shift);
|
||||
}
|
||||
|
||||
static inline int32_t aptx_quantized_parity(Channel *channel)
|
||||
{
|
||||
int32_t parity = channel->dither_parity;
|
||||
int subband;
|
||||
|
||||
for (subband = 0; subband < NB_SUBBANDS; subband++)
|
||||
parity ^= channel->quantize[subband].quantized_sample;
|
||||
|
||||
return parity & 1;
|
||||
}
|
||||
|
||||
/* For each sample, ensure that the parity of all subbands of all channels
|
||||
* is 0 except once every 8 samples where the parity is forced to 1. */
|
||||
static inline int aptx_check_parity(Channel channels[NB_CHANNELS], int32_t *idx)
|
||||
{
|
||||
int32_t parity = aptx_quantized_parity(&channels[LEFT])
|
||||
^ aptx_quantized_parity(&channels[RIGHT]);
|
||||
|
||||
int eighth = *idx == 7;
|
||||
*idx = (*idx + 1) & 7;
|
||||
|
||||
return parity ^ eighth;
|
||||
}
|
||||
|
||||
void ff_aptx_invert_quantize_and_prediction(Channel *channel, int hd);
|
||||
void ff_aptx_generate_dither(Channel *channel);
|
||||
|
||||
int ff_aptx_init(AVCodecContext *avctx);
|
||||
|
||||
#endif /* AVCODEC_APTX_H */
|
||||
146
include/libavcodec/ass.h
Normal file
146
include/libavcodec/ass.h
Normal file
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
* SSA/ASS common functions
|
||||
* Copyright (c) 2010 Aurelien Jacobs <aurel@gnuage.org>
|
||||
*
|
||||
* 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_ASS_H
|
||||
#define AVCODEC_ASS_H
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "libavutil/bprint.h"
|
||||
|
||||
#define ASS_DEFAULT_PLAYRESX 384
|
||||
#define ASS_DEFAULT_PLAYRESY 288
|
||||
|
||||
/**
|
||||
* @name Default values for ASS style
|
||||
* @{
|
||||
*/
|
||||
#define ASS_DEFAULT_FONT "Arial"
|
||||
#define ASS_DEFAULT_FONT_SIZE 16
|
||||
#define ASS_DEFAULT_COLOR 0xffffff
|
||||
#define ASS_DEFAULT_BACK_COLOR 0
|
||||
#define ASS_DEFAULT_BOLD 0
|
||||
#define ASS_DEFAULT_ITALIC 0
|
||||
#define ASS_DEFAULT_UNDERLINE 0
|
||||
#define ASS_DEFAULT_ALIGNMENT 2
|
||||
#define ASS_DEFAULT_BORDERSTYLE 1
|
||||
/** @} */
|
||||
|
||||
typedef struct FFASSDecoderContext {
|
||||
int readorder;
|
||||
} FFASSDecoderContext;
|
||||
|
||||
/**
|
||||
* Generate a suitable AVCodecContext.subtitle_header for SUBTITLE_ASS.
|
||||
* Can specify all fields explicitly
|
||||
*
|
||||
* @param avctx pointer to the AVCodecContext
|
||||
* @param play_res_x subtitle frame width
|
||||
* @param play_res_y subtitle frame height
|
||||
* @param font name of the default font face to use
|
||||
* @param font_size default font size to use
|
||||
* @param primary_color default text color to use (ABGR)
|
||||
* @param secondary_color default secondary text color to use (ABGR)
|
||||
* @param outline_color default outline color to use (ABGR)
|
||||
* @param back_color default background color to use (ABGR)
|
||||
* @param bold 1 for bold text, 0 for normal text
|
||||
* @param italic 1 for italic text, 0 for normal text
|
||||
* @param underline 1 for underline text, 0 for normal text
|
||||
* @param border_style 1 for outline, 3 for opaque box
|
||||
* @param alignment position of the text (left, center, top...), defined after
|
||||
* the layout of the numpad (1-3 sub, 4-6 mid, 7-9 top)
|
||||
* @return >= 0 on success otherwise an error code <0
|
||||
*/
|
||||
int ff_ass_subtitle_header_full(AVCodecContext *avctx,
|
||||
int play_res_x, int play_res_y,
|
||||
const char *font, int font_size,
|
||||
int primary_color, int secondary_color,
|
||||
int outline_color, int back_color,
|
||||
int bold, int italic, int underline,
|
||||
int border_style, int alignment);
|
||||
/**
|
||||
* Generate a suitable AVCodecContext.subtitle_header for SUBTITLE_ASS.
|
||||
*
|
||||
* @param avctx pointer to the AVCodecContext
|
||||
* @param font name of the default font face to use
|
||||
* @param font_size default font size to use
|
||||
* @param color default text color to use (ABGR)
|
||||
* @param back_color default background color to use (ABGR)
|
||||
* @param bold 1 for bold text, 0 for normal text
|
||||
* @param italic 1 for italic text, 0 for normal text
|
||||
* @param underline 1 for underline text, 0 for normal text
|
||||
* @param alignment position of the text (left, center, top...), defined after
|
||||
* the layout of the numpad (1-3 sub, 4-6 mid, 7-9 top)
|
||||
* @return >= 0 on success otherwise an error code <0
|
||||
*/
|
||||
int ff_ass_subtitle_header(AVCodecContext *avctx,
|
||||
const char *font, int font_size,
|
||||
int color, int back_color,
|
||||
int bold, int italic, int underline,
|
||||
int border_style, int alignment);
|
||||
|
||||
/**
|
||||
* Generate a suitable AVCodecContext.subtitle_header for SUBTITLE_ASS
|
||||
* with default style.
|
||||
*
|
||||
* @param avctx pointer to the AVCodecContext
|
||||
* @return >= 0 on success otherwise an error code <0
|
||||
*/
|
||||
int ff_ass_subtitle_header_default(AVCodecContext *avctx);
|
||||
|
||||
/**
|
||||
* Craft an ASS dialog string.
|
||||
*/
|
||||
char *ff_ass_get_dialog(int readorder, int layer, const char *style,
|
||||
const char *speaker, const char *text);
|
||||
|
||||
/**
|
||||
* Add an ASS dialog to a subtitle.
|
||||
*/
|
||||
int ff_ass_add_rect(AVSubtitle *sub, const char *dialog,
|
||||
int readorder, int layer, const char *style,
|
||||
const char *speaker);
|
||||
|
||||
/**
|
||||
* Add an ASS dialog to a subtitle.
|
||||
*/
|
||||
int ff_ass_add_rect2(AVSubtitle *sub, const char *dialog,
|
||||
int readorder, int layer, const char *style,
|
||||
const char *speaker, unsigned *nb_rect_allocated);
|
||||
|
||||
/**
|
||||
* Helper to flush a text subtitles decoder making use of the
|
||||
* FFASSDecoderContext.
|
||||
*/
|
||||
void ff_ass_decoder_flush(AVCodecContext *avctx);
|
||||
|
||||
/**
|
||||
* Escape a text subtitle using ASS syntax into an AVBPrint buffer.
|
||||
* Newline characters will be escaped to \N.
|
||||
*
|
||||
* @param buf pointer to an initialized AVBPrint buffer
|
||||
* @param p source text
|
||||
* @param size size of the source text
|
||||
* @param linebreaks additional newline chars, which will be escaped to \N
|
||||
* @param keep_ass_markup braces and backslash will not be escaped if set
|
||||
*/
|
||||
void ff_ass_bprint_text_event(AVBPrint *buf, const char *p, int size,
|
||||
const char *linebreaks, int keep_ass_markup);
|
||||
#endif /* AVCODEC_ASS_H */
|
||||
191
include/libavcodec/ass_split.h
Normal file
191
include/libavcodec/ass_split.h
Normal file
@@ -0,0 +1,191 @@
|
||||
/*
|
||||
* SSA/ASS spliting functions
|
||||
* Copyright (c) 2010 Aurelien Jacobs <aurel@gnuage.org>
|
||||
*
|
||||
* 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_ASS_SPLIT_H
|
||||
#define AVCODEC_ASS_SPLIT_H
|
||||
|
||||
/**
|
||||
* fields extracted from the [Script Info] section
|
||||
*/
|
||||
typedef struct {
|
||||
char *script_type; /**< SSA script format version (eg. v4.00) */
|
||||
char *collisions; /**< how subtitles are moved to prevent collisions */
|
||||
int play_res_x; /**< video width that ASS coords are referring to */
|
||||
int play_res_y; /**< video height that ASS coords are referring to */
|
||||
float timer; /**< time multiplier to apply to SSA clock (in %) */
|
||||
} ASSScriptInfo;
|
||||
|
||||
/**
|
||||
* fields extracted from the [V4(+) Styles] section
|
||||
*/
|
||||
typedef struct {
|
||||
char *name; /**< name of the tyle (case sensitive) */
|
||||
char *font_name; /**< font face (case sensitive) */
|
||||
int font_size; /**< font height */
|
||||
int primary_color; /**< color that a subtitle will normally appear in */
|
||||
int secondary_color;
|
||||
int outline_color; /**< color for outline in ASS, called tertiary in SSA */
|
||||
int back_color; /**< color of the subtitle outline or shadow */
|
||||
int bold; /**< whether text is bold (1) or not (0) */
|
||||
int italic; /**< whether text is italic (1) or not (0) */
|
||||
int underline; /**< whether text is underlined (1) or not (0) */
|
||||
int strikeout;
|
||||
float scalex;
|
||||
float scaley;
|
||||
float spacing;
|
||||
float angle;
|
||||
int border_style;
|
||||
float outline;
|
||||
float shadow;
|
||||
int alignment; /**< position of the text (left, center, top...),
|
||||
defined after the layout of the numpad
|
||||
(1-3 sub, 4-6 mid, 7-9 top) */
|
||||
int margin_l;
|
||||
int margin_r;
|
||||
int margin_v;
|
||||
int alpha_level;
|
||||
int encoding;
|
||||
} ASSStyle;
|
||||
|
||||
/**
|
||||
* fields extracted from the [Events] section
|
||||
*/
|
||||
typedef struct {
|
||||
int readorder;
|
||||
int layer; /**< higher numbered layers are drawn over lower numbered */
|
||||
int start; /**< start time of the dialog in centiseconds */
|
||||
int end; /**< end time of the dialog in centiseconds */
|
||||
char *style; /**< name of the ASSStyle to use with this dialog */
|
||||
char *name;
|
||||
int margin_l;
|
||||
int margin_r;
|
||||
int margin_v;
|
||||
char *effect;
|
||||
char *text; /**< actual text which will be displayed as a subtitle,
|
||||
can include style override control codes (see
|
||||
ff_ass_split_override_codes()) */
|
||||
} ASSDialog;
|
||||
|
||||
/**
|
||||
* structure containing the whole split ASS data
|
||||
*/
|
||||
typedef struct {
|
||||
ASSScriptInfo script_info; /**< general information about the SSA script*/
|
||||
ASSStyle *styles; /**< array of split out styles */
|
||||
int styles_count; /**< number of ASSStyle in the styles array */
|
||||
ASSDialog *dialogs; /**< array of split out dialogs */
|
||||
int dialogs_count; /**< number of ASSDialog in the dialogs array*/
|
||||
} ASS;
|
||||
|
||||
/**
|
||||
* This struct can be casted to ASS to access to the split data.
|
||||
*/
|
||||
typedef struct ASSSplitContext ASSSplitContext;
|
||||
|
||||
/**
|
||||
* Split a full ASS file or a ASS header from a string buffer and store
|
||||
* the split structure in a newly allocated context.
|
||||
*
|
||||
* @param buf String containing the ASS formatted data.
|
||||
* @return Newly allocated struct containing split data.
|
||||
*/
|
||||
ASSSplitContext *ff_ass_split(const char *buf);
|
||||
|
||||
/**
|
||||
* Free a dialogue obtained from ff_ass_split_dialog().
|
||||
*/
|
||||
void ff_ass_free_dialog(ASSDialog **dialogp);
|
||||
|
||||
/**
|
||||
* Split one ASS Dialogue line from a string buffer.
|
||||
*
|
||||
* @param ctx Context previously initialized by ff_ass_split().
|
||||
* @param buf String containing the ASS "Dialogue" line.
|
||||
* @return Pointer to the split ASSDialog. Must be freed with ff_ass_free_dialog()
|
||||
*/
|
||||
ASSDialog *ff_ass_split_dialog(ASSSplitContext *ctx, const char *buf);
|
||||
|
||||
/**
|
||||
* Free all the memory allocated for an ASSSplitContext.
|
||||
*
|
||||
* @param ctx Context previously initialized by ff_ass_split().
|
||||
*/
|
||||
void ff_ass_split_free(ASSSplitContext *ctx);
|
||||
|
||||
|
||||
/**
|
||||
* Set of callback functions corresponding to each override codes that can
|
||||
* be encountered in a "Dialogue" Text field.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* @defgroup ass_styles ASS styles
|
||||
* @{
|
||||
*/
|
||||
void (*text)(void *priv, const char *text, int len);
|
||||
void (*new_line)(void *priv, int forced);
|
||||
void (*style)(void *priv, char style, int close);
|
||||
void (*color)(void *priv, unsigned int /* color */, unsigned int color_id);
|
||||
void (*alpha)(void *priv, int alpha, int alpha_id);
|
||||
void (*font_name)(void *priv, const char *name);
|
||||
void (*font_size)(void *priv, int size);
|
||||
void (*alignment)(void *priv, int alignment);
|
||||
void (*cancel_overrides)(void *priv, const char *style);
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @defgroup ass_functions ASS functions
|
||||
* @{
|
||||
*/
|
||||
void (*move)(void *priv, int x1, int y1, int x2, int y2, int t1, int t2);
|
||||
void (*origin)(void *priv, int x, int y);
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @defgroup ass_end end of Dialogue Event
|
||||
* @{
|
||||
*/
|
||||
void (*end)(void *priv);
|
||||
/** @} */
|
||||
} ASSCodesCallbacks;
|
||||
|
||||
/**
|
||||
* Split override codes out of a ASS "Dialogue" Text field.
|
||||
*
|
||||
* @param callbacks Set of callback functions called for each override code
|
||||
* encountered.
|
||||
* @param priv Opaque pointer passed to the callback functions.
|
||||
* @param buf The ASS "Dialogue" Text field to split.
|
||||
* @return >= 0 on success otherwise an error code <0
|
||||
*/
|
||||
int ff_ass_split_override_codes(const ASSCodesCallbacks *callbacks, void *priv,
|
||||
const char *buf);
|
||||
|
||||
/**
|
||||
* Find an ASSStyle structure by its name.
|
||||
*
|
||||
* @param ctx Context previously initialized by ff_ass_split().
|
||||
* @param style name of the style to search for.
|
||||
* @return the ASSStyle corresponding to style, or NULL if style can't be found
|
||||
*/
|
||||
ASSStyle *ff_ass_style_get(ASSSplitContext *ctx, const char *style);
|
||||
|
||||
#endif /* AVCODEC_ASS_SPLIT_H */
|
||||
52
include/libavcodec/asv.h
Normal file
52
include/libavcodec/asv.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2003 Michael Niedermayer
|
||||
*
|
||||
* 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
|
||||
* ASUS V1/V2 encoder/decoder common data.
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_ASV_H
|
||||
#define AVCODEC_ASV_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "bswapdsp.h"
|
||||
|
||||
typedef struct ASVCommonContext {
|
||||
AVCodecContext *avctx;
|
||||
BswapDSPContext bbdsp;
|
||||
int mb_width;
|
||||
int mb_height;
|
||||
int mb_width2;
|
||||
int mb_height2;
|
||||
} ASVCommonContext;
|
||||
|
||||
extern const uint8_t ff_asv_scantab[64];
|
||||
extern const uint8_t ff_asv_ccp_tab[17][2];
|
||||
extern const uint8_t ff_asv_level_tab[7][2];
|
||||
extern const uint8_t ff_asv_dc_ccp_tab[8][2];
|
||||
extern const uint8_t ff_asv_ac_ccp_tab[16][2];
|
||||
extern const uint16_t ff_asv2_level_tab[63][2];
|
||||
|
||||
void ff_asv_common_init(AVCodecContext *avctx);
|
||||
|
||||
#endif /* AVCODEC_ASV_H */
|
||||
97
include/libavcodec/atrac.h
Normal file
97
include/libavcodec/atrac.h
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* common functions for the ATRAC family of decoders
|
||||
*
|
||||
* Copyright (c) 2009-2013 Maxim Poliakovski
|
||||
* Copyright (c) 2009 Benjamin Larsson
|
||||
*
|
||||
* 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
|
||||
* ATRAC common header
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_ATRAC_H
|
||||
#define AVCODEC_ATRAC_H
|
||||
|
||||
/**
|
||||
* Gain control parameters for one subband.
|
||||
*/
|
||||
typedef struct AtracGainInfo {
|
||||
int num_points; ///< number of gain control points
|
||||
int lev_code[7]; ///< level at corresponding control point
|
||||
int loc_code[7]; ///< location of gain control points
|
||||
} AtracGainInfo;
|
||||
|
||||
/**
|
||||
* Gain compensation context structure.
|
||||
*/
|
||||
typedef struct AtracGCContext {
|
||||
float gain_tab1[16]; ///< gain compensation level table
|
||||
float gain_tab2[31]; ///< gain compensation interpolation table
|
||||
int id2exp_offset; ///< offset for converting level index into level exponent
|
||||
int loc_scale; ///< scale of location code = 2^loc_scale samples
|
||||
int loc_size; ///< size of location code in samples
|
||||
} AtracGCContext;
|
||||
|
||||
extern float ff_atrac_sf_table[64];
|
||||
|
||||
/**
|
||||
* Generate common tables.
|
||||
*/
|
||||
void ff_atrac_generate_tables(void);
|
||||
|
||||
/**
|
||||
* Initialize gain compensation context.
|
||||
*
|
||||
* @param gctx pointer to gain compensation context to initialize
|
||||
* @param id2exp_offset offset for converting level index into level exponent
|
||||
* @param loc_scale location size factor
|
||||
*/
|
||||
void ff_atrac_init_gain_compensation(AtracGCContext *gctx, int id2exp_offset,
|
||||
int loc_scale);
|
||||
|
||||
/**
|
||||
* Apply gain compensation and perform the MDCT overlapping part.
|
||||
*
|
||||
* @param gctx pointer to gain compensation context
|
||||
* @param in input buffer
|
||||
* @param prev previous buffer to perform overlap against
|
||||
* @param gc_now gain control information for current frame
|
||||
* @param gc_next gain control information for next frame
|
||||
* @param num_samples number of samples to process
|
||||
* @param out output data goes here
|
||||
*/
|
||||
void ff_atrac_gain_compensation(AtracGCContext *gctx, float *in, float *prev,
|
||||
AtracGainInfo *gc_now, AtracGainInfo *gc_next,
|
||||
int num_samples, float *out);
|
||||
|
||||
/**
|
||||
* Quadrature mirror synthesis filter.
|
||||
*
|
||||
* @param inlo lower part of spectrum
|
||||
* @param inhi higher part of spectrum
|
||||
* @param nIn size of spectrum buffer
|
||||
* @param pOut out buffer
|
||||
* @param delayBuf delayBuf buffer
|
||||
* @param temp temp buffer
|
||||
*/
|
||||
void ff_atrac_iqmf(float *inlo, float *inhi, unsigned int nIn, float *pOut,
|
||||
float *delayBuf, float *temp);
|
||||
|
||||
#endif /* AVCODEC_ATRAC_H */
|
||||
64
include/libavcodec/atrac1data.h
Normal file
64
include/libavcodec/atrac1data.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* ATRAC 1 compatible decoder data
|
||||
* Copyright (c) 2009 Maxim Poliakovski
|
||||
* Copyright (c) 2009 Benjamin Larsson
|
||||
*
|
||||
* 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
|
||||
* ATRAC1 compatible decoder data
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_ATRAC1DATA_H
|
||||
#define AVCODEC_ATRAC1DATA_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
static const uint8_t bfu_amount_tab1[8] = {20, 28, 32, 36, 40, 44, 48, 52};
|
||||
static const uint8_t bfu_amount_tab2[4] = { 0, 112, 176, 208};
|
||||
static const uint8_t bfu_amount_tab3[8] = { 0, 24, 36, 48, 72, 108, 132, 156};
|
||||
|
||||
/** number of BFUs in each QMF band */
|
||||
static const uint8_t bfu_bands_t[4] = {0, 20, 36, 52};
|
||||
|
||||
/** number of spectral lines in each BFU
|
||||
* block floating unit = group of spectral frequencies having the
|
||||
* same quantization parameters like word length and scale factor
|
||||
*/
|
||||
static const uint8_t specs_per_bfu[52] = {
|
||||
8, 8, 8, 8, 4, 4, 4, 4, 8, 8, 8, 8, 6, 6, 6, 6, 6, 6, 6, 6, // low band
|
||||
6, 6, 6, 6, 7, 7, 7, 7, 9, 9, 9, 9, 10, 10, 10, 10, // middle band
|
||||
12, 12, 12, 12, 12, 12, 12, 12, 20, 20, 20, 20, 20, 20, 20, 20 // high band
|
||||
};
|
||||
|
||||
/** start position of each BFU in the MDCT spectrum for the long mode */
|
||||
static const uint16_t bfu_start_long[52] = {
|
||||
0, 8, 16, 24, 32, 36, 40, 44, 48, 56, 64, 72, 80, 86, 92, 98, 104, 110, 116, 122,
|
||||
128, 134, 140, 146, 152, 159, 166, 173, 180, 189, 198, 207, 216, 226, 236, 246,
|
||||
256, 268, 280, 292, 304, 316, 328, 340, 352, 372, 392, 412, 432, 452, 472, 492,
|
||||
};
|
||||
|
||||
/** start position of each BFU in the MDCT spectrum for the short mode */
|
||||
static const uint16_t bfu_start_short[52] = {
|
||||
0, 32, 64, 96, 8, 40, 72, 104, 12, 44, 76, 108, 20, 52, 84, 116, 26, 58, 90, 122,
|
||||
128, 160, 192, 224, 134, 166, 198, 230, 141, 173, 205, 237, 150, 182, 214, 246,
|
||||
256, 288, 320, 352, 384, 416, 448, 480, 268, 300, 332, 364, 396, 428, 460, 492
|
||||
};
|
||||
|
||||
#endif /* AVCODEC_ATRAC1DATA_H */
|
||||
107
include/libavcodec/atrac3data.h
Normal file
107
include/libavcodec/atrac3data.h
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* ATRAC3 compatible decoder data
|
||||
* Copyright (c) 2006-2007 Maxim Poliakovski
|
||||
* Copyright (c) 2006-2007 Benjamin Larsson
|
||||
*
|
||||
* 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
|
||||
* ATRAC3 AKA RealAudio 8 compatible decoder data
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_ATRAC3DATA_H
|
||||
#define AVCODEC_ATRAC3DATA_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* VLC tables */
|
||||
|
||||
static const uint8_t atrac3_hufftabs[][2] = {
|
||||
/* Spectral coefficient 1 - 9 entries */
|
||||
{ 31, 1 }, { 32, 3 }, { 33, 3 }, { 34, 4 }, { 35, 4 },
|
||||
{ 36, 5 }, { 37, 5 }, { 38, 5 }, { 39, 5 },
|
||||
/* Spectral coefficient 2 - 5 entries */
|
||||
{ 31, 1 }, { 32, 3 }, { 30, 3 }, { 33, 3 }, { 29, 3 },
|
||||
/* Spectral coefficient 3 - 7 entries */
|
||||
{ 31, 1 }, { 32, 3 }, { 30, 3 }, { 33, 4 },
|
||||
{ 29, 4 }, { 34, 4 }, { 28, 4 },
|
||||
/* Spectral coefficient 4 - 9 entries */
|
||||
{ 31, 1 }, { 32, 3 }, { 30, 3 }, { 33, 4 }, { 29, 4 },
|
||||
{ 34, 5 }, { 28, 5 }, { 35, 5 }, { 27, 5 },
|
||||
/* Spectral coefficient 5 - 15 entries */
|
||||
{ 31, 2 }, { 32, 3 }, { 30, 3 }, { 33, 4 }, { 29, 4 },
|
||||
{ 34, 4 }, { 28, 4 }, { 38, 4 }, { 24, 4 }, { 35, 5 },
|
||||
{ 27, 5 }, { 36, 6 }, { 26, 6 }, { 37, 6 }, { 25, 6 },
|
||||
/* Spectral coefficient 6 - 31 entries */
|
||||
{ 31, 3 }, { 32, 4 }, { 30, 4 }, { 33, 4 }, { 29, 4 }, { 34, 4 },
|
||||
{ 28, 4 }, { 46, 4 }, { 16, 4 }, { 35, 5 }, { 27, 5 }, { 36, 5 },
|
||||
{ 26, 5 }, { 37, 5 }, { 25, 5 }, { 38, 6 }, { 24, 6 }, { 39, 6 },
|
||||
{ 23, 6 }, { 40, 6 }, { 22, 6 }, { 41, 6 }, { 21, 6 }, { 42, 7 },
|
||||
{ 20, 7 }, { 43, 7 }, { 19, 7 }, { 44, 7 }, { 18, 7 }, { 45, 7 },
|
||||
{ 17, 7 },
|
||||
/* Spectral coefficient 7 - 63 entries */
|
||||
{ 31, 3 }, { 62, 4 }, { 0, 4 }, { 32, 5 }, { 30, 5 }, { 33, 5 },
|
||||
{ 29, 5 }, { 34, 5 }, { 28, 5 }, { 35, 5 }, { 27, 5 }, { 36, 5 },
|
||||
{ 26, 5 }, { 37, 6 }, { 25, 6 }, { 38, 6 }, { 24, 6 }, { 39, 6 },
|
||||
{ 23, 6 }, { 40, 6 }, { 22, 6 }, { 41, 6 }, { 21, 6 }, { 42, 6 },
|
||||
{ 20, 6 }, { 43, 6 }, { 19, 6 }, { 44, 6 }, { 18, 6 }, { 45, 7 },
|
||||
{ 17, 7 }, { 46, 7 }, { 16, 7 }, { 47, 7 }, { 15, 7 }, { 48, 7 },
|
||||
{ 14, 7 }, { 49, 7 }, { 13, 7 }, { 50, 7 }, { 12, 7 }, { 51, 7 },
|
||||
{ 11, 7 }, { 52, 8 }, { 10, 8 }, { 53, 8 }, { 9, 8 }, { 54, 8 },
|
||||
{ 8, 8 }, { 55, 8 }, { 7, 8 }, { 56, 8 }, { 6, 8 }, { 57, 8 },
|
||||
{ 5, 8 }, { 58, 8 }, { 4, 8 }, { 59, 8 }, { 3, 8 }, { 60, 8 },
|
||||
{ 2, 8 }, { 61, 8 }, { 1, 8 },
|
||||
};
|
||||
|
||||
static const uint8_t huff_tab_sizes[7] = {
|
||||
9, 5, 7, 9, 15, 31, 63,
|
||||
};
|
||||
|
||||
/* selector tables */
|
||||
|
||||
static const uint8_t clc_length_tab[8] = { 0, 4, 3, 3, 4, 4, 5, 6 };
|
||||
|
||||
static const int8_t mantissa_clc_tab[4] = { 0, 1, -2, -1 };
|
||||
|
||||
static const int8_t mantissa_vlc_tab[18] = {
|
||||
0, 0, 0, 1, 0, -1, 1, 0, -1, 0, 1, 1, 1, -1, -1, 1, -1, -1
|
||||
};
|
||||
|
||||
|
||||
/* tables for the scalefactor decoding */
|
||||
|
||||
static const float inv_max_quant[8] = {
|
||||
0.0, 1.0 / 1.5, 1.0 / 2.5, 1.0 / 3.5,
|
||||
1.0 / 4.5, 1.0 / 7.5, 1.0 / 15.5, 1.0 / 31.5
|
||||
};
|
||||
|
||||
static const uint16_t subband_tab[33] = {
|
||||
0, 8, 16, 24, 32, 40, 48, 56,
|
||||
64, 80, 96, 112, 128, 144, 160, 176,
|
||||
192, 224, 256, 288, 320, 352, 384, 416,
|
||||
448, 480, 512, 576, 640, 704, 768, 896,
|
||||
1024
|
||||
};
|
||||
|
||||
/* joint stereo related tables */
|
||||
static const float matrix_coeffs[8] = {
|
||||
0.0, 2.0, 2.0, 2.0, 0.0, 0.0, 1.0, 1.0
|
||||
};
|
||||
|
||||
#endif /* AVCODEC_ATRAC3DATA_H */
|
||||
236
include/libavcodec/atrac3plus.h
Normal file
236
include/libavcodec/atrac3plus.h
Normal file
@@ -0,0 +1,236 @@
|
||||
/*
|
||||
* ATRAC3+ compatible decoder
|
||||
*
|
||||
* Copyright (c) 2010-2013 Maxim Poliakovski
|
||||
*
|
||||
* 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
|
||||
* Global structures, constants and data for ATRAC3+ decoder.
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_ATRAC3PLUS_H
|
||||
#define AVCODEC_ATRAC3PLUS_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libavutil/float_dsp.h"
|
||||
#include "libavutil/mem_internal.h"
|
||||
#include "libavutil/tx.h"
|
||||
|
||||
#include "atrac.h"
|
||||
#include "avcodec.h"
|
||||
#include "get_bits.h"
|
||||
|
||||
/** Global unit sizes */
|
||||
#define ATRAC3P_SUBBANDS 16 ///< number of PQF subbands
|
||||
#define ATRAC3P_SUBBAND_SAMPLES 128 ///< number of samples per subband
|
||||
#define ATRAC3P_FRAME_SAMPLES (ATRAC3P_SUBBAND_SAMPLES * ATRAC3P_SUBBANDS)
|
||||
|
||||
#define ATRAC3P_PQF_FIR_LEN 12 ///< length of the prototype FIR of the PQF
|
||||
|
||||
/** Global constants */
|
||||
#define ATRAC3P_POWER_COMP_OFF 15 ///< disable power compensation
|
||||
|
||||
/** ATRAC3+ channel unit types */
|
||||
enum Atrac3pChannelUnitTypes {
|
||||
CH_UNIT_MONO = 0, ///< unit containing one coded channel
|
||||
CH_UNIT_STEREO = 1, ///< unit containing two jointly-coded channels
|
||||
CH_UNIT_EXTENSION = 2, ///< unit containing extension information
|
||||
CH_UNIT_TERMINATOR = 3 ///< unit sequence terminator
|
||||
};
|
||||
|
||||
/** Per-channel IPQF history */
|
||||
typedef struct Atrac3pIPQFChannelCtx {
|
||||
DECLARE_ALIGNED(32, float, buf1)[ATRAC3P_PQF_FIR_LEN * 2][8];
|
||||
DECLARE_ALIGNED(32, float, buf2)[ATRAC3P_PQF_FIR_LEN * 2][8];
|
||||
int pos;
|
||||
} Atrac3pIPQFChannelCtx;
|
||||
|
||||
/** Amplitude envelope of a group of sine waves */
|
||||
typedef struct Atrac3pWaveEnvelope {
|
||||
int has_start_point; ///< indicates start point within the GHA window
|
||||
int has_stop_point; ///< indicates stop point within the GHA window
|
||||
int start_pos; ///< start position expressed in n*4 samples
|
||||
int stop_pos; ///< stop position expressed in n*4 samples
|
||||
} Atrac3pWaveEnvelope;
|
||||
|
||||
/** Parameters of a group of sine waves */
|
||||
typedef struct Atrac3pWavesData {
|
||||
Atrac3pWaveEnvelope pend_env; ///< pending envelope from the previous frame
|
||||
Atrac3pWaveEnvelope curr_env; ///< group envelope from the current frame
|
||||
int num_wavs; ///< number of sine waves in the group
|
||||
int start_index; ///< start index into global tones table for that subband
|
||||
} Atrac3pWavesData;
|
||||
|
||||
/** Parameters of a single sine wave */
|
||||
typedef struct Atrac3pWaveParam {
|
||||
int freq_index; ///< wave frequency index
|
||||
int amp_sf; ///< quantized amplitude scale factor
|
||||
int amp_index; ///< quantized amplitude index
|
||||
int phase_index; ///< quantized phase index
|
||||
} Atrac3pWaveParam;
|
||||
|
||||
/** Sound channel parameters */
|
||||
typedef struct Atrac3pChanParams {
|
||||
int ch_num;
|
||||
int num_coded_vals; ///< number of transmitted quant unit values
|
||||
int fill_mode;
|
||||
int split_point;
|
||||
int table_type; ///< table type: 0 - tone?, 1- noise?
|
||||
int qu_wordlen[32]; ///< array of word lengths for each quant unit
|
||||
int qu_sf_idx[32]; ///< array of scale factor indexes for each quant unit
|
||||
int qu_tab_idx[32]; ///< array of code table indexes for each quant unit
|
||||
int16_t spectrum[2048]; ///< decoded IMDCT spectrum
|
||||
uint8_t power_levs[5]; ///< power compensation levels
|
||||
|
||||
/* imdct window shape history (2 frames) for overlapping. */
|
||||
uint8_t wnd_shape_hist[2][ATRAC3P_SUBBANDS]; ///< IMDCT window shape, 0=sine/1=steep
|
||||
uint8_t *wnd_shape; ///< IMDCT window shape for current frame
|
||||
uint8_t *wnd_shape_prev; ///< IMDCT window shape for previous frame
|
||||
|
||||
/* gain control data history (2 frames) for overlapping. */
|
||||
AtracGainInfo gain_data_hist[2][ATRAC3P_SUBBANDS]; ///< gain control data for all subbands
|
||||
AtracGainInfo *gain_data; ///< gain control data for next frame
|
||||
AtracGainInfo *gain_data_prev; ///< gain control data for previous frame
|
||||
int num_gain_subbands; ///< number of subbands with gain control data
|
||||
|
||||
/* tones data history (2 frames) for overlapping. */
|
||||
Atrac3pWavesData tones_info_hist[2][ATRAC3P_SUBBANDS];
|
||||
Atrac3pWavesData *tones_info;
|
||||
Atrac3pWavesData *tones_info_prev;
|
||||
} Atrac3pChanParams;
|
||||
|
||||
/* Per-unit sine wave parameters */
|
||||
typedef struct Atrac3pWaveSynthParams {
|
||||
int tones_present; ///< 1 - tones info present
|
||||
int amplitude_mode; ///< 1 - low range, 0 - high range
|
||||
int num_tone_bands; ///< number of PQF bands with tones
|
||||
uint8_t tone_sharing[ATRAC3P_SUBBANDS]; ///< 1 - subband-wise tone sharing flags
|
||||
uint8_t tone_master[ATRAC3P_SUBBANDS]; ///< 1 - subband-wise tone channel swapping
|
||||
uint8_t invert_phase[ATRAC3P_SUBBANDS]; ///< 1 - subband-wise phase inversion
|
||||
int tones_index; ///< total sum of tones in this unit
|
||||
Atrac3pWaveParam waves[48];
|
||||
} Atrac3pWaveSynthParams;
|
||||
|
||||
/** Channel unit parameters */
|
||||
typedef struct Atrac3pChanUnitCtx {
|
||||
/* channel unit variables */
|
||||
int unit_type; ///< unit type (mono/stereo)
|
||||
int num_quant_units;
|
||||
int num_subbands;
|
||||
int used_quant_units; ///< number of quant units with coded spectrum
|
||||
int num_coded_subbands; ///< number of subbands with coded spectrum
|
||||
int mute_flag; ///< mute flag
|
||||
int use_full_table; ///< 1 - full table list, 0 - restricted one
|
||||
int noise_present; ///< 1 - global noise info present
|
||||
int noise_level_index; ///< global noise level index
|
||||
int noise_table_index; ///< global noise RNG table index
|
||||
uint8_t swap_channels[ATRAC3P_SUBBANDS]; ///< 1 - perform subband-wise channel swapping
|
||||
uint8_t negate_coeffs[ATRAC3P_SUBBANDS]; ///< 1 - subband-wise IMDCT coefficients negation
|
||||
Atrac3pChanParams channels[2];
|
||||
|
||||
/* Variables related to GHA tones */
|
||||
Atrac3pWaveSynthParams wave_synth_hist[2]; ///< waves synth history for two frames
|
||||
Atrac3pWaveSynthParams *waves_info;
|
||||
Atrac3pWaveSynthParams *waves_info_prev;
|
||||
|
||||
Atrac3pIPQFChannelCtx ipqf_ctx[2];
|
||||
DECLARE_ALIGNED(32, float, prev_buf)[2][ATRAC3P_FRAME_SAMPLES]; ///< overlapping buffer
|
||||
} Atrac3pChanUnitCtx;
|
||||
|
||||
/**
|
||||
* Initialize VLC tables for bitstream parsing.
|
||||
*/
|
||||
void ff_atrac3p_init_vlcs(void);
|
||||
|
||||
/**
|
||||
* Decode bitstream data of a channel unit.
|
||||
*
|
||||
* @param[in] gb the GetBit context
|
||||
* @param[in,out] ctx ptr to the channel unit context
|
||||
* @param[in] num_channels number of channels to process
|
||||
* @param[in] avctx ptr to the AVCodecContext
|
||||
* @return result code: 0 = OK, otherwise - error code
|
||||
*/
|
||||
int ff_atrac3p_decode_channel_unit(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
|
||||
int num_channels, AVCodecContext *avctx);
|
||||
|
||||
/**
|
||||
* Initialize sine waves synthesizer and ff_sine_* tables.
|
||||
*/
|
||||
void ff_atrac3p_init_dsp_static(void);
|
||||
|
||||
/**
|
||||
* Synthesize sine waves for a particular subband.
|
||||
*
|
||||
* @param[in] ch_unit pointer to the channel unit context
|
||||
* @param[in] fdsp pointer to float DSP context
|
||||
* @param[in] ch_num which channel to process
|
||||
* @param[in] sb which subband to process
|
||||
* @param[out] out receives processed data
|
||||
*/
|
||||
void ff_atrac3p_generate_tones(Atrac3pChanUnitCtx *ch_unit, AVFloatDSPContext *fdsp,
|
||||
int ch_num, int sb, float *out);
|
||||
|
||||
/**
|
||||
* Perform power compensation aka noise dithering.
|
||||
*
|
||||
* @param[in] ctx ptr to the channel context
|
||||
* @param[in] fdsp pointer to float DSP context
|
||||
* @param[in] ch_index which channel to process
|
||||
* @param[in,out] sp ptr to channel spectrum to process
|
||||
* @param[in] rng_index indicates which RNG table to use
|
||||
* @param[in] sb_num which subband to process
|
||||
*/
|
||||
void ff_atrac3p_power_compensation(Atrac3pChanUnitCtx *ctx, AVFloatDSPContext *fdsp,
|
||||
int ch_index, float *sp, int rng_index, int sb_num);
|
||||
|
||||
/**
|
||||
* Regular IMDCT and windowing without overlapping,
|
||||
* with spectrum reversal in the odd subbands.
|
||||
*
|
||||
* @param[in] fdsp pointer to float DSP context
|
||||
* @param[in] mdct_ctx pointer to MDCT transform context
|
||||
* @param[in] pIn float input
|
||||
* @param[out] pOut float output
|
||||
* @param[in] wind_id which MDCT window to apply
|
||||
* @param[in] sb subband number
|
||||
*/
|
||||
void ff_atrac3p_imdct(AVFloatDSPContext *fdsp, AVTXContext *mdct_ctx,
|
||||
av_tx_fn mdct_fn, float *pIn, float *pOut,
|
||||
int wind_id, int sb);
|
||||
|
||||
/**
|
||||
* Subband synthesis filter based on the polyphase quadrature (pseudo-QMF)
|
||||
* filter bank.
|
||||
*
|
||||
* @param[in] dct_ctx ptr to the pre-initialized IDCT context
|
||||
* @param[in,out] hist ptr to the filter history
|
||||
* @param[in] in input data to process
|
||||
* @param[out] out receives processed data
|
||||
*/
|
||||
void ff_atrac3p_ipqf(AVTXContext *dct_ctx, av_tx_fn dct_fn,
|
||||
Atrac3pIPQFChannelCtx *hist, const float *in, float *out);
|
||||
|
||||
extern const uint16_t ff_atrac3p_qu_to_spec_pos[33];
|
||||
extern const float ff_atrac3p_sf_tab[64];
|
||||
extern const float ff_atrac3p_mant_tab[8];
|
||||
|
||||
#endif /* AVCODEC_ATRAC3PLUS_H */
|
||||
1659
include/libavcodec/atrac3plus_data.h
Normal file
1659
include/libavcodec/atrac3plus_data.h
Normal file
File diff suppressed because it is too large
Load Diff
1376
include/libavcodec/atrac9tab.h
Normal file
1376
include/libavcodec/atrac9tab.h
Normal file
File diff suppressed because it is too large
Load Diff
56
include/libavcodec/atsc_a53.h
Normal file
56
include/libavcodec/atsc_a53.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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_ATSC_A53_H
|
||||
#define AVCODEC_ATSC_A53_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libavutil/buffer.h"
|
||||
#include "libavutil/frame.h"
|
||||
|
||||
/**
|
||||
* Check AVFrame for A53 side data and allocate and fill SEI message with A53 info
|
||||
*
|
||||
* @param frame Raw frame to get A53 side data from
|
||||
* @param prefix_len Number of bytes to allocate before SEI message
|
||||
* @param data Pointer to a variable to store allocated memory
|
||||
* Upon return the variable will hold NULL on error or if frame has no A53 info.
|
||||
* Otherwise it will point to prefix_len uninitialized bytes followed by
|
||||
* *sei_size SEI message
|
||||
* @param sei_size Pointer to a variable to store generated SEI message length
|
||||
* @return Zero on success, negative error code on failure
|
||||
*/
|
||||
int ff_alloc_a53_sei(const AVFrame *frame, size_t prefix_len,
|
||||
void **data, size_t *sei_size);
|
||||
|
||||
/**
|
||||
* Parse a data array for ATSC A53 Part 4 Closed Captions and store them in an AVBufferRef.
|
||||
*
|
||||
* @param pbuf Pointer to an AVBufferRef to append the closed captions. *pbuf may be NULL, in
|
||||
* which case a new buffer will be allocated and put in it.
|
||||
* @param data The data array containing the raw A53 data.
|
||||
* @param size Size of the data array in bytes.
|
||||
*
|
||||
* @return Number of closed captions parsed on success, negative error code on failure.
|
||||
* If no Closed Captions are parsed, *pbuf is untouched.
|
||||
*/
|
||||
int ff_parse_a53_cc(AVBufferRef **pbuf, const uint8_t *data, int size);
|
||||
|
||||
#endif /* AVCODEC_ATSC_A53_H */
|
||||
83
include/libavcodec/audio_frame_queue.h
Normal file
83
include/libavcodec/audio_frame_queue.h
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Audio Frame Queue
|
||||
* Copyright (c) 2012 Justin Ruggles
|
||||
*
|
||||
* 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_AUDIO_FRAME_QUEUE_H
|
||||
#define AVCODEC_AUDIO_FRAME_QUEUE_H
|
||||
|
||||
#include "avcodec.h"
|
||||
|
||||
typedef struct AudioFrame {
|
||||
int64_t pts;
|
||||
int duration;
|
||||
} AudioFrame;
|
||||
|
||||
typedef struct AudioFrameQueue {
|
||||
AVCodecContext *avctx;
|
||||
int remaining_delay;
|
||||
int remaining_samples;
|
||||
AudioFrame *frames;
|
||||
unsigned frame_count;
|
||||
unsigned frame_alloc;
|
||||
} AudioFrameQueue;
|
||||
|
||||
/**
|
||||
* Initialize AudioFrameQueue.
|
||||
*
|
||||
* @param avctx context to use for time_base and av_log
|
||||
* @param afq queue context
|
||||
*/
|
||||
void ff_af_queue_init(AVCodecContext *avctx, AudioFrameQueue *afq);
|
||||
|
||||
/**
|
||||
* Close AudioFrameQueue.
|
||||
*
|
||||
* Frees memory if needed.
|
||||
*
|
||||
* @param afq queue context
|
||||
*/
|
||||
void ff_af_queue_close(AudioFrameQueue *afq);
|
||||
|
||||
/**
|
||||
* Add a frame to the queue.
|
||||
*
|
||||
* @param afq queue context
|
||||
* @param f frame to add to the queue
|
||||
*/
|
||||
int ff_af_queue_add(AudioFrameQueue *afq, const AVFrame *f);
|
||||
|
||||
/**
|
||||
* Remove frame(s) from the queue.
|
||||
*
|
||||
* Retrieves the pts of the next available frame, or a generated pts based on
|
||||
* the last frame duration if there are no frames left in the queue. The number
|
||||
* of requested samples should be the full number of samples represented by the
|
||||
* packet that will be output by the encoder. If fewer samples are available
|
||||
* in the queue, a smaller value will be used for the output duration.
|
||||
*
|
||||
* @param afq queue context
|
||||
* @param nb_samples number of samples to remove from the queue
|
||||
* @param[out] pts output packet pts
|
||||
* @param[out] duration output packet duration
|
||||
*/
|
||||
void ff_af_queue_remove(AudioFrameQueue *afq, int nb_samples, int64_t *pts,
|
||||
int64_t *duration);
|
||||
|
||||
#endif /* AVCODEC_AUDIO_FRAME_QUEUE_H */
|
||||
61
include/libavcodec/audiodsp.h
Normal file
61
include/libavcodec/audiodsp.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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_AUDIODSP_H
|
||||
#define AVCODEC_AUDIODSP_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct AudioDSPContext {
|
||||
/**
|
||||
* Calculate scalar product of two vectors.
|
||||
* @param len length of vectors, should be multiple of 16
|
||||
*/
|
||||
int32_t (*scalarproduct_int16)(const int16_t *v1,
|
||||
const int16_t *v2 /* align 16 */, int len);
|
||||
|
||||
/**
|
||||
* Clip each element in an array of int32_t to a given minimum and
|
||||
* maximum value.
|
||||
* @param dst destination array
|
||||
* constraints: 16-byte aligned
|
||||
* @param src source array
|
||||
* constraints: 16-byte aligned
|
||||
* @param min minimum value
|
||||
* constraints: must be in the range [-(1 << 24), 1 << 24]
|
||||
* @param max maximum value
|
||||
* constraints: must be in the range [-(1 << 24), 1 << 24]
|
||||
* @param len number of elements in the array
|
||||
* constraints: multiple of 32 greater than zero
|
||||
*/
|
||||
void (*vector_clip_int32)(int32_t *dst, const int32_t *src, int32_t min,
|
||||
int32_t max, unsigned int len);
|
||||
/* assume len is a multiple of 16, and arrays are 16-byte aligned */
|
||||
void (*vector_clipf)(float *dst /* align 16 */,
|
||||
const float *src /* align 16 */,
|
||||
int len /* align 16 */,
|
||||
float min, float max);
|
||||
} AudioDSPContext;
|
||||
|
||||
void ff_audiodsp_init(AudioDSPContext *c);
|
||||
void ff_audiodsp_init_arm(AudioDSPContext *c);
|
||||
void ff_audiodsp_init_ppc(AudioDSPContext *c);
|
||||
void ff_audiodsp_init_riscv(AudioDSPContext *c);
|
||||
void ff_audiodsp_init_x86(AudioDSPContext *c);
|
||||
|
||||
#endif /* AVCODEC_AUDIODSP_H */
|
||||
192
include/libavcodec/av1.h
Normal file
192
include/libavcodec/av1.h
Normal file
@@ -0,0 +1,192 @@
|
||||
/*
|
||||
* 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
|
||||
* AV1 common definitions
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_AV1_H
|
||||
#define AVCODEC_AV1_H
|
||||
|
||||
// OBU types (section 6.2.2).
|
||||
typedef enum {
|
||||
// 0 reserved.
|
||||
AV1_OBU_SEQUENCE_HEADER = 1,
|
||||
AV1_OBU_TEMPORAL_DELIMITER = 2,
|
||||
AV1_OBU_FRAME_HEADER = 3,
|
||||
AV1_OBU_TILE_GROUP = 4,
|
||||
AV1_OBU_METADATA = 5,
|
||||
AV1_OBU_FRAME = 6,
|
||||
AV1_OBU_REDUNDANT_FRAME_HEADER = 7,
|
||||
AV1_OBU_TILE_LIST = 8,
|
||||
// 9-14 reserved.
|
||||
AV1_OBU_PADDING = 15,
|
||||
} AV1_OBU_Type;
|
||||
|
||||
// Metadata types (section 6.7.1).
|
||||
enum {
|
||||
AV1_METADATA_TYPE_HDR_CLL = 1,
|
||||
AV1_METADATA_TYPE_HDR_MDCV = 2,
|
||||
AV1_METADATA_TYPE_SCALABILITY = 3,
|
||||
AV1_METADATA_TYPE_ITUT_T35 = 4,
|
||||
AV1_METADATA_TYPE_TIMECODE = 5,
|
||||
};
|
||||
|
||||
// Frame types (section 6.8.2).
|
||||
enum {
|
||||
AV1_FRAME_KEY = 0,
|
||||
AV1_FRAME_INTER = 1,
|
||||
AV1_FRAME_INTRA_ONLY = 2,
|
||||
AV1_FRAME_SWITCH = 3,
|
||||
};
|
||||
|
||||
// Reference frames (section 6.10.24).
|
||||
enum {
|
||||
AV1_REF_FRAME_NONE = -1,
|
||||
AV1_REF_FRAME_INTRA = 0,
|
||||
AV1_REF_FRAME_LAST = 1,
|
||||
AV1_REF_FRAME_LAST2 = 2,
|
||||
AV1_REF_FRAME_LAST3 = 3,
|
||||
AV1_REF_FRAME_GOLDEN = 4,
|
||||
AV1_REF_FRAME_BWDREF = 5,
|
||||
AV1_REF_FRAME_ALTREF2 = 6,
|
||||
AV1_REF_FRAME_ALTREF = 7,
|
||||
};
|
||||
|
||||
// Constants (section 3).
|
||||
enum {
|
||||
AV1_MAX_OPERATING_POINTS = 32,
|
||||
|
||||
AV1_MAX_SB_SIZE = 128,
|
||||
AV1_MI_SIZE = 4,
|
||||
|
||||
AV1_MAX_TILE_WIDTH = 4096,
|
||||
AV1_MAX_TILE_AREA = 4096 * 2304,
|
||||
AV1_MAX_TILE_ROWS = 64,
|
||||
AV1_MAX_TILE_COLS = 64,
|
||||
|
||||
AV1_NUM_REF_FRAMES = 8,
|
||||
AV1_REFS_PER_FRAME = 7,
|
||||
AV1_TOTAL_REFS_PER_FRAME = 8,
|
||||
AV1_PRIMARY_REF_NONE = 7,
|
||||
|
||||
AV1_MAX_SEGMENTS = 8,
|
||||
AV1_SEG_LVL_MAX = 8,
|
||||
|
||||
AV1_SEG_LVL_ALT_Q = 0,
|
||||
AV1_SEG_LVL_ALT_LF_Y_V = 1,
|
||||
AV1_SEG_LVL_REF_FRAME = 5,
|
||||
AV1_SEG_LVL_SKIP = 6,
|
||||
AV1_SEG_LVL_GLOBAL_MV = 7,
|
||||
|
||||
AV1_SELECT_SCREEN_CONTENT_TOOLS = 2,
|
||||
AV1_SELECT_INTEGER_MV = 2,
|
||||
|
||||
AV1_SUPERRES_NUM = 8,
|
||||
AV1_SUPERRES_DENOM_MIN = 9,
|
||||
|
||||
AV1_INTERPOLATION_FILTER_SWITCHABLE = 4,
|
||||
|
||||
AV1_GM_ABS_ALPHA_BITS = 12,
|
||||
AV1_GM_ALPHA_PREC_BITS = 15,
|
||||
AV1_GM_ABS_TRANS_ONLY_BITS = 9,
|
||||
AV1_GM_TRANS_ONLY_PREC_BITS = 3,
|
||||
AV1_GM_ABS_TRANS_BITS = 12,
|
||||
AV1_GM_TRANS_PREC_BITS = 6,
|
||||
AV1_WARPEDMODEL_PREC_BITS = 16,
|
||||
|
||||
AV1_WARP_MODEL_IDENTITY = 0,
|
||||
AV1_WARP_MODEL_TRANSLATION = 1,
|
||||
AV1_WARP_MODEL_ROTZOOM = 2,
|
||||
AV1_WARP_MODEL_AFFINE = 3,
|
||||
AV1_WARP_PARAM_REDUCE_BITS = 6,
|
||||
|
||||
AV1_DIV_LUT_BITS = 8,
|
||||
AV1_DIV_LUT_PREC_BITS = 14,
|
||||
AV1_DIV_LUT_NUM = 257,
|
||||
|
||||
AV1_MAX_LOOP_FILTER = 63,
|
||||
};
|
||||
|
||||
|
||||
// The main colour configuration information uses the same ISO/IEC 23001-8
|
||||
// (H.273) enums as FFmpeg does, so separate definitions are not required.
|
||||
|
||||
// Chroma sample position.
|
||||
enum {
|
||||
AV1_CSP_UNKNOWN = 0,
|
||||
AV1_CSP_VERTICAL = 1, // -> AVCHROMA_LOC_LEFT.
|
||||
AV1_CSP_COLOCATED = 2, // -> AVCHROMA_LOC_TOPLEFT.
|
||||
};
|
||||
|
||||
// Scalability modes (section 6.7.5)
|
||||
enum {
|
||||
AV1_SCALABILITY_L1T2 = 0,
|
||||
AV1_SCALABILITY_L1T3 = 1,
|
||||
AV1_SCALABILITY_L2T1 = 2,
|
||||
AV1_SCALABILITY_L2T2 = 3,
|
||||
AV1_SCALABILITY_L2T3 = 4,
|
||||
AV1_SCALABILITY_S2T1 = 5,
|
||||
AV1_SCALABILITY_S2T2 = 6,
|
||||
AV1_SCALABILITY_S2T3 = 7,
|
||||
AV1_SCALABILITY_L2T1h = 8,
|
||||
AV1_SCALABILITY_L2T2h = 9,
|
||||
AV1_SCALABILITY_L2T3h = 10,
|
||||
AV1_SCALABILITY_S2T1h = 11,
|
||||
AV1_SCALABILITY_S2T2h = 12,
|
||||
AV1_SCALABILITY_S2T3h = 13,
|
||||
AV1_SCALABILITY_SS = 14,
|
||||
AV1_SCALABILITY_L3T1 = 15,
|
||||
AV1_SCALABILITY_L3T2 = 16,
|
||||
AV1_SCALABILITY_L3T3 = 17,
|
||||
AV1_SCALABILITY_S3T1 = 18,
|
||||
AV1_SCALABILITY_S3T2 = 19,
|
||||
AV1_SCALABILITY_S3T3 = 20,
|
||||
AV1_SCALABILITY_L3T2_KEY = 21,
|
||||
AV1_SCALABILITY_L3T3_KEY = 22,
|
||||
AV1_SCALABILITY_L4T5_KEY = 23,
|
||||
AV1_SCALABILITY_L4T7_KEY = 24,
|
||||
AV1_SCALABILITY_L3T2_KEY_SHIFT = 25,
|
||||
AV1_SCALABILITY_L3T3_KEY_SHIFT = 26,
|
||||
AV1_SCALABILITY_L4T5_KEY_SHIFT = 27,
|
||||
AV1_SCALABILITY_L4T7_KEY_SHIFT = 28,
|
||||
};
|
||||
|
||||
// Frame Restoration types (section 6.10.15)
|
||||
enum {
|
||||
AV1_RESTORE_NONE = 0,
|
||||
AV1_RESTORE_WIENER = 1,
|
||||
AV1_RESTORE_SGRPROJ = 2,
|
||||
AV1_RESTORE_SWITCHABLE = 3,
|
||||
};
|
||||
|
||||
// TX mode (section 6.8.21)
|
||||
enum {
|
||||
AV1_ONLY_4X4 = 0,
|
||||
AV1_TX_MODE_LARGEST = 1,
|
||||
AV1_TX_MODE_SELECT = 2,
|
||||
};
|
||||
|
||||
// Sequence Headers are actually unbounded because one can use
|
||||
// an arbitrary number of leading zeroes when encoding via uvlc.
|
||||
// The following estimate is based around using the lowest number
|
||||
// of bits for uvlc encoding.
|
||||
#define AV1_SANE_SEQUENCE_HEADER_MAX_BITS 3138
|
||||
|
||||
#endif /* AVCODEC_AV1_H */
|
||||
58
include/libavcodec/av1_levels.h
Normal file
58
include/libavcodec/av1_levels.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Intel Corporation
|
||||
*
|
||||
* 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_AV1_LEVELS_H
|
||||
#define AVCODEC_AV1_LEVELS_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct AV1LevelDescriptor {
|
||||
char name[4];
|
||||
uint8_t level_idx;
|
||||
|
||||
uint32_t max_pic_size;
|
||||
uint32_t max_h_size;
|
||||
uint32_t max_v_size;
|
||||
uint64_t max_display_rate;
|
||||
uint64_t max_decode_rate;
|
||||
|
||||
uint32_t max_header_rate;
|
||||
float main_mbps;
|
||||
float high_mbps;
|
||||
uint32_t main_cr;
|
||||
uint32_t high_cr;
|
||||
uint32_t max_tiles;
|
||||
uint32_t max_tile_cols;
|
||||
} AV1LevelDescriptor;
|
||||
|
||||
/**
|
||||
* Guess the level of a stream from some parameters.
|
||||
*
|
||||
* Unknown parameters may be zero, in which case they will be ignored.
|
||||
*/
|
||||
const AV1LevelDescriptor *ff_av1_guess_level(int64_t bitrate,
|
||||
int tier,
|
||||
int width,
|
||||
int height,
|
||||
int tile_rows,
|
||||
int tile_cols,
|
||||
float fps);
|
||||
|
||||
#endif /* AVCODEC_AV1_LEVELS_H */
|
||||
172
include/libavcodec/av1_parse.h
Normal file
172
include/libavcodec/av1_parse.h
Normal file
@@ -0,0 +1,172 @@
|
||||
/*
|
||||
* AV1 common parsing code
|
||||
*
|
||||
* 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_AV1_PARSE_H
|
||||
#define AVCODEC_AV1_PARSE_H
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libavutil/error.h"
|
||||
#include "libavutil/intmath.h"
|
||||
#include "libavutil/macros.h"
|
||||
|
||||
#include "av1.h"
|
||||
#include "get_bits.h"
|
||||
#include "leb.h"
|
||||
|
||||
// OBU header fields + max leb128 length
|
||||
#define MAX_OBU_HEADER_SIZE (2 + 8)
|
||||
|
||||
typedef struct AV1OBU {
|
||||
/** Size of payload */
|
||||
int size;
|
||||
const uint8_t *data;
|
||||
|
||||
/**
|
||||
* Size, in bits, of just the data, excluding the trailing_one_bit and
|
||||
* any trailing padding.
|
||||
*/
|
||||
int size_bits;
|
||||
|
||||
/** Size of entire OBU, including header */
|
||||
int raw_size;
|
||||
const uint8_t *raw_data;
|
||||
|
||||
int type;
|
||||
|
||||
int temporal_id;
|
||||
int spatial_id;
|
||||
} AV1OBU;
|
||||
|
||||
/** An input packet split into OBUs */
|
||||
typedef struct AV1Packet {
|
||||
AV1OBU *obus;
|
||||
int nb_obus;
|
||||
int obus_allocated;
|
||||
unsigned obus_allocated_size;
|
||||
} AV1Packet;
|
||||
|
||||
/**
|
||||
* Extract an OBU from a raw bitstream.
|
||||
*
|
||||
* @note This function does not copy or store any bitstream data. All
|
||||
* the pointers in the AV1OBU structure will be valid as long
|
||||
* as the input buffer also is.
|
||||
*/
|
||||
int ff_av1_extract_obu(AV1OBU *obu, const uint8_t *buf, int length,
|
||||
void *logctx);
|
||||
|
||||
/**
|
||||
* Split an input packet into OBUs.
|
||||
*
|
||||
* @note This function does not copy or store any bitstream data. All
|
||||
* the pointers in the AV1Packet structure will be valid as
|
||||
* long as the input buffer also is.
|
||||
*/
|
||||
int ff_av1_packet_split(AV1Packet *pkt, const uint8_t *buf, int length,
|
||||
void *logctx);
|
||||
|
||||
/**
|
||||
* Free all the allocated memory in the packet.
|
||||
*/
|
||||
void ff_av1_packet_uninit(AV1Packet *pkt);
|
||||
|
||||
static inline int parse_obu_header(const uint8_t *buf, int buf_size,
|
||||
int64_t *obu_size, int *start_pos, int *type,
|
||||
int *temporal_id, int *spatial_id)
|
||||
{
|
||||
GetBitContext gb;
|
||||
int ret, extension_flag, has_size_flag;
|
||||
int64_t size;
|
||||
|
||||
ret = init_get_bits8(&gb, buf, FFMIN(buf_size, MAX_OBU_HEADER_SIZE));
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (get_bits1(&gb) != 0) // obu_forbidden_bit
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
*type = get_bits(&gb, 4);
|
||||
extension_flag = get_bits1(&gb);
|
||||
has_size_flag = get_bits1(&gb);
|
||||
skip_bits1(&gb); // obu_reserved_1bit
|
||||
|
||||
if (extension_flag) {
|
||||
*temporal_id = get_bits(&gb, 3);
|
||||
*spatial_id = get_bits(&gb, 2);
|
||||
skip_bits(&gb, 3); // extension_header_reserved_3bits
|
||||
} else {
|
||||
*temporal_id = *spatial_id = 0;
|
||||
}
|
||||
|
||||
*obu_size = has_size_flag ? get_leb128(&gb)
|
||||
: buf_size - 1 - extension_flag;
|
||||
|
||||
if (get_bits_left(&gb) < 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
*start_pos = get_bits_count(&gb) / 8;
|
||||
|
||||
size = *obu_size + *start_pos;
|
||||
|
||||
if (size > buf_size)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
static inline int get_obu_bit_length(const uint8_t *buf, int size, int type)
|
||||
{
|
||||
int v;
|
||||
|
||||
/* There are no trailing bits on these */
|
||||
if (type == AV1_OBU_TILE_GROUP ||
|
||||
type == AV1_OBU_TILE_LIST ||
|
||||
type == AV1_OBU_FRAME) {
|
||||
if (size > INT_MAX / 8)
|
||||
return AVERROR(ERANGE);
|
||||
else
|
||||
return size * 8;
|
||||
}
|
||||
|
||||
while (size > 0 && buf[size - 1] == 0)
|
||||
size--;
|
||||
|
||||
if (!size)
|
||||
return 0;
|
||||
|
||||
v = buf[size - 1];
|
||||
|
||||
if (size > INT_MAX / 8)
|
||||
return AVERROR(ERANGE);
|
||||
size *= 8;
|
||||
|
||||
/* Remove the trailing_one_bit and following trailing zeros */
|
||||
if (v)
|
||||
size -= ff_ctz(v) + 1;
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
AVRational ff_av1_framerate(int64_t ticks_per_frame, int64_t units_per_tick,
|
||||
int64_t time_scale);
|
||||
|
||||
#endif /* AVCODEC_AV1_PARSE_H */
|
||||
123
include/libavcodec/av1dec.h
Normal file
123
include/libavcodec/av1dec.h
Normal file
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* AV1 video decoder
|
||||
* *
|
||||
* 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_AV1DEC_H
|
||||
#define AVCODEC_AV1DEC_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libavutil/buffer.h"
|
||||
#include "libavutil/fifo.h"
|
||||
#include "libavutil/frame.h"
|
||||
#include "libavutil/pixfmt.h"
|
||||
#include "avcodec.h"
|
||||
#include "packet.h"
|
||||
#include "cbs.h"
|
||||
#include "cbs_av1.h"
|
||||
#include "dovi_rpu.h"
|
||||
#include "progressframe.h"
|
||||
|
||||
typedef struct AV1Frame {
|
||||
union {
|
||||
struct {
|
||||
struct AVFrame *f;
|
||||
};
|
||||
ProgressFrame pf;
|
||||
};
|
||||
|
||||
void *hwaccel_picture_private; ///< RefStruct reference
|
||||
|
||||
AV1RawOBU *header_ref; ///< RefStruct reference backing raw_frame_header.
|
||||
AV1RawFrameHeader *raw_frame_header;
|
||||
|
||||
int temporal_id;
|
||||
int spatial_id;
|
||||
|
||||
uint8_t gm_invalid[AV1_NUM_REF_FRAMES];
|
||||
uint8_t gm_type[AV1_NUM_REF_FRAMES];
|
||||
int32_t gm_params[AV1_NUM_REF_FRAMES][6];
|
||||
|
||||
uint8_t skip_mode_frame_idx[2];
|
||||
|
||||
AV1RawFilmGrainParams film_grain;
|
||||
|
||||
uint8_t coded_lossless;
|
||||
|
||||
// OrderHint for this frame.
|
||||
uint8_t order_hint;
|
||||
// RefFrameSignBias[] used when decoding this frame.
|
||||
uint8_t ref_frame_sign_bias[AV1_TOTAL_REFS_PER_FRAME];
|
||||
// OrderHints[] when this is the current frame, otherwise
|
||||
// SavedOrderHints[s][] when is the reference frame in slot s.
|
||||
uint8_t order_hints[AV1_TOTAL_REFS_PER_FRAME];
|
||||
|
||||
// force_integer_mv value at the end of the frame header parsing.
|
||||
// This is not the same as the syntax element value in
|
||||
// raw_frame_header because the specification parsing tables
|
||||
// override the value on intra frames.
|
||||
uint8_t force_integer_mv;
|
||||
} AV1Frame;
|
||||
|
||||
typedef struct TileGroupInfo {
|
||||
uint32_t tile_offset;
|
||||
uint32_t tile_size;
|
||||
uint16_t tile_row;
|
||||
uint16_t tile_column;
|
||||
} TileGroupInfo;
|
||||
|
||||
typedef struct AV1DecContext {
|
||||
const AVClass *class;
|
||||
AVCodecContext *avctx;
|
||||
|
||||
enum AVPixelFormat pix_fmt;
|
||||
CodedBitstreamContext *cbc;
|
||||
CodedBitstreamFragment current_obu;
|
||||
AVPacket *pkt;
|
||||
|
||||
AVBufferRef *seq_data_ref;
|
||||
AV1RawOBU *seq_ref; ///< RefStruct reference backing raw_seq
|
||||
AV1RawSequenceHeader *raw_seq;
|
||||
AV1RawOBU *header_ref; ///< RefStruct reference backing raw_frame_header
|
||||
AV1RawFrameHeader *raw_frame_header;
|
||||
TileGroupInfo *tile_group_info;
|
||||
|
||||
AV1RawOBU *cll_ref; ///< RefStruct reference backing cll
|
||||
AV1RawMetadataHDRCLL *cll;
|
||||
AV1RawOBU *mdcv_ref; ///< RefStruct reference backing mdcv
|
||||
AV1RawMetadataHDRMDCV *mdcv;
|
||||
DOVIContext dovi;
|
||||
AVFifo *itut_t35_fifo;
|
||||
|
||||
uint16_t tile_num;
|
||||
uint16_t tg_start;
|
||||
uint16_t tg_end;
|
||||
|
||||
int operating_point_idc;
|
||||
|
||||
AV1Frame ref[AV1_NUM_REF_FRAMES];
|
||||
AV1Frame cur_frame;
|
||||
|
||||
int nb_unit;
|
||||
|
||||
// AVOptions
|
||||
int operating_point;
|
||||
} AV1DecContext;
|
||||
|
||||
#endif /* AVCODEC_AV1DEC_H */
|
||||
File diff suppressed because it is too large
Load Diff
110
include/libavcodec/avcodec_internal.h
Normal file
110
include/libavcodec/avcodec_internal.h
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/*
|
||||
* APIs internal to the generic codec layer.
|
||||
*
|
||||
* MUST NOT be included by individual encoders or decoders.
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_AVCODEC_INTERNAL_H
|
||||
#define AVCODEC_AVCODEC_INTERNAL_H
|
||||
|
||||
#include "libavutil/frame.h"
|
||||
|
||||
#include "packet.h"
|
||||
|
||||
struct AVCodecContext;
|
||||
|
||||
typedef struct SideDataMap {
|
||||
enum AVPacketSideDataType packet;
|
||||
enum AVFrameSideDataType frame;
|
||||
} SideDataMap;
|
||||
|
||||
/**
|
||||
* A map between packet and frame side data types.
|
||||
* Terminated with an entry where packet=AV_PKT_DATA_NB.
|
||||
*/
|
||||
extern const SideDataMap ff_sd_global_map[];
|
||||
|
||||
/**
|
||||
* avcodec_receive_frame() implementation for decoders.
|
||||
*/
|
||||
int ff_decode_receive_frame(struct AVCodecContext *avctx, struct AVFrame *frame);
|
||||
|
||||
/**
|
||||
* avcodec_receive_frame() implementation for encoders.
|
||||
*/
|
||||
int ff_encode_receive_frame(struct AVCodecContext *avctx, struct AVFrame *frame);
|
||||
|
||||
/*
|
||||
* Perform encoder initialization and validation.
|
||||
* Called when opening the encoder, before the FFCodec.init() call.
|
||||
*/
|
||||
int ff_encode_preinit(struct AVCodecContext *avctx);
|
||||
|
||||
/**
|
||||
* Perform decoder initialization and validation.
|
||||
* Called when opening the decoder, before the FFCodec.init() call.
|
||||
*/
|
||||
int ff_decode_preinit(struct AVCodecContext *avctx);
|
||||
|
||||
void ff_decode_flush_buffers(struct AVCodecContext *avctx);
|
||||
void ff_encode_flush_buffers(struct AVCodecContext *avctx);
|
||||
|
||||
struct AVCodecInternal *ff_decode_internal_alloc(void);
|
||||
void ff_decode_internal_sync(struct AVCodecContext *dst,
|
||||
const struct AVCodecContext *src);
|
||||
void ff_decode_internal_uninit(struct AVCodecContext *avctx);
|
||||
|
||||
struct AVCodecInternal *ff_encode_internal_alloc(void);
|
||||
|
||||
void ff_codec_close(struct AVCodecContext *avctx);
|
||||
|
||||
int ff_thread_init(struct AVCodecContext *s);
|
||||
void ff_thread_free(struct AVCodecContext *s);
|
||||
|
||||
/**
|
||||
* Wait for decoding threads to finish and reset internal state.
|
||||
* Called by avcodec_flush_buffers().
|
||||
*
|
||||
* @param avctx The context.
|
||||
*/
|
||||
void ff_thread_flush(struct AVCodecContext *avctx);
|
||||
|
||||
/**
|
||||
* Submit available packets for decoding to worker threads, return a
|
||||
* decoded frame if available. Returns AVERROR(EAGAIN) if none is available.
|
||||
*
|
||||
* Parameters are the same as FFCodec.receive_frame.
|
||||
*/
|
||||
int ff_thread_receive_frame(struct AVCodecContext *avctx, AVFrame *frame);
|
||||
|
||||
/**
|
||||
* Do the actual decoding and obtain a decoded frame from the decoder, if
|
||||
* available. When frame threading is used, this is invoked by the worker
|
||||
* threads, otherwise by the top layer directly.
|
||||
*/
|
||||
int ff_decode_receive_frame_internal(struct AVCodecContext *avctx, AVFrame *frame);
|
||||
|
||||
/**
|
||||
* Get a packet for decoding. This gets invoked by the worker threads.
|
||||
*/
|
||||
int ff_thread_get_packet(struct AVCodecContext *avctx, AVPacket *pkt);
|
||||
|
||||
#endif // AVCODEC_AVCODEC_INTERNAL_H
|
||||
@@ -19,6 +19,10 @@
|
||||
#ifndef AVCODEC_AVFFT_H
|
||||
#define AVCODEC_AVFFT_H
|
||||
|
||||
#include "libavutil/attributes.h"
|
||||
#include "version_major.h"
|
||||
#if FF_API_AVFFT
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavc_fft
|
||||
@@ -44,26 +48,42 @@ typedef struct FFTContext FFTContext;
|
||||
* Set up a complex FFT.
|
||||
* @param nbits log2 of the length of the input array
|
||||
* @param inverse if 0 perform the forward transform, if 1 perform the inverse
|
||||
* @deprecated use av_tx_init from libavutil/tx.h with a type of AV_TX_FLOAT_FFT
|
||||
*/
|
||||
attribute_deprecated
|
||||
FFTContext *av_fft_init(int nbits, int inverse);
|
||||
|
||||
/**
|
||||
* Do the permutation needed BEFORE calling ff_fft_calc().
|
||||
* @deprecated without replacement
|
||||
*/
|
||||
attribute_deprecated
|
||||
void av_fft_permute(FFTContext *s, FFTComplex *z);
|
||||
|
||||
/**
|
||||
* Do a complex FFT with the parameters defined in av_fft_init(). The
|
||||
* input data must be permuted before. No 1.0/sqrt(n) normalization is done.
|
||||
* @deprecated use the av_tx_fn value returned by av_tx_init, which also does permutation
|
||||
*/
|
||||
attribute_deprecated
|
||||
void av_fft_calc(FFTContext *s, FFTComplex *z);
|
||||
|
||||
attribute_deprecated
|
||||
void av_fft_end(FFTContext *s);
|
||||
|
||||
/**
|
||||
* @deprecated use av_tx_init from libavutil/tx.h with a type of AV_TX_FLOAT_MDCT,
|
||||
* with a flag of AV_TX_FULL_IMDCT for a replacement to av_imdct_calc.
|
||||
*/
|
||||
attribute_deprecated
|
||||
FFTContext *av_mdct_init(int nbits, int inverse, double scale);
|
||||
attribute_deprecated
|
||||
void av_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input);
|
||||
attribute_deprecated
|
||||
void av_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input);
|
||||
attribute_deprecated
|
||||
void av_mdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input);
|
||||
attribute_deprecated
|
||||
void av_mdct_end(FFTContext *s);
|
||||
|
||||
/* Real Discrete Fourier Transform */
|
||||
@@ -81,9 +101,14 @@ typedef struct RDFTContext RDFTContext;
|
||||
* Set up a real FFT.
|
||||
* @param nbits log2 of the length of the input array
|
||||
* @param trans the type of transform
|
||||
*
|
||||
* @deprecated use av_tx_init from libavutil/tx.h with a type of AV_TX_FLOAT_RDFT
|
||||
*/
|
||||
attribute_deprecated
|
||||
RDFTContext *av_rdft_init(int nbits, enum RDFTransformType trans);
|
||||
attribute_deprecated
|
||||
void av_rdft_calc(RDFTContext *s, FFTSample *data);
|
||||
attribute_deprecated
|
||||
void av_rdft_end(RDFTContext *s);
|
||||
|
||||
/* Discrete Cosine Transform */
|
||||
@@ -106,13 +131,19 @@ enum DCTTransformType {
|
||||
* @param type the type of transform
|
||||
*
|
||||
* @note the first element of the input of DST-I is ignored
|
||||
*
|
||||
* @deprecated use av_tx_init from libavutil/tx.h with an appropriate type of AV_TX_FLOAT_DCT
|
||||
*/
|
||||
attribute_deprecated
|
||||
DCTContext *av_dct_init(int nbits, enum DCTTransformType type);
|
||||
attribute_deprecated
|
||||
void av_dct_calc(DCTContext *s, FFTSample *data);
|
||||
attribute_deprecated
|
||||
void av_dct_end (DCTContext *s);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* FF_API_AVFFT */
|
||||
#endif /* AVCODEC_AVFFT_H */
|
||||
|
||||
51
include/libavcodec/avs2.h
Normal file
51
include/libavcodec/avs2.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* AVS2 related definitions
|
||||
*
|
||||
* Copyright (C) 2022 Zhao Zhili, <zhilizhao@tencent.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 AVCODEC_AVS2_H
|
||||
#define AVCODEC_AVS2_H
|
||||
|
||||
#include "libavutil/rational.h"
|
||||
|
||||
#define AVS2_SLICE_MAX_START_CODE 0x000001AF
|
||||
|
||||
enum {
|
||||
AVS2_SEQ_START_CODE = 0xB0,
|
||||
AVS2_SEQ_END_CODE = 0xB1,
|
||||
AVS2_USER_DATA_START_CODE = 0xB2,
|
||||
AVS2_INTRA_PIC_START_CODE = 0xB3,
|
||||
// reserved = 0xB4,
|
||||
AVS2_EXTENSION_START_CODE = 0xB5,
|
||||
AVS2_INTER_PIC_START_CODE = 0xB6,
|
||||
};
|
||||
|
||||
#define AVS2_ISPIC(x) ((x) == AVS2_INTRA_PIC_START_CODE || (x) == AVS2_INTER_PIC_START_CODE)
|
||||
#define AVS2_ISUNIT(x) ((x) == AVS2_SEQ_START_CODE || AVS2_ISPIC(x))
|
||||
|
||||
enum AVS2Profile {
|
||||
AVS2_PROFILE_MAIN_PIC = 0x12,
|
||||
AVS2_PROFILE_MAIN = 0x20,
|
||||
AVS2_PROFILE_MAIN10 = 0x22,
|
||||
};
|
||||
|
||||
extern const AVRational ff_avs2_frame_rate_tab[16];
|
||||
|
||||
#endif
|
||||
118
include/libavcodec/avs3.h
Normal file
118
include/libavcodec/avs3.h
Normal file
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* AVS3 related definitions
|
||||
*
|
||||
* Copyright (C) 2020 Huiwen Ren, <hwrenx@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 AVCODEC_AVS3_H
|
||||
#define AVCODEC_AVS3_H
|
||||
|
||||
#define AVS3_NAL_START_CODE 0x010000
|
||||
#define AVS3_SEQ_START_CODE 0xB0
|
||||
#define AVS3_SEQ_END_CODE 0xB1
|
||||
#define AVS3_USER_DATA_START_CODE 0xB2
|
||||
#define AVS3_INTRA_PIC_START_CODE 0xB3
|
||||
#define AVS3_UNDEF_START_CODE 0xB4
|
||||
#define AVS3_EXTENSION_START_CODE 0xB5
|
||||
#define AVS3_INTER_PIC_START_CODE 0xB6
|
||||
#define AVS3_VIDEO_EDIT_CODE 0xB7
|
||||
#define AVS3_FIRST_SLICE_START_CODE 0x00
|
||||
#define AVS3_PROFILE_BASELINE_MAIN 0x20
|
||||
#define AVS3_PROFILE_BASELINE_MAIN10 0x22
|
||||
|
||||
#define AVS3_ISPIC(x) ((x) == AVS3_INTRA_PIC_START_CODE || (x) == AVS3_INTER_PIC_START_CODE)
|
||||
#define AVS3_ISUNIT(x) ((x) == AVS3_SEQ_START_CODE || AVS3_ISPIC(x))
|
||||
|
||||
#include "libavutil/avutil.h"
|
||||
#include "libavutil/pixfmt.h"
|
||||
#include "libavutil/rational.h"
|
||||
|
||||
static const AVRational ff_avs3_frame_rate_tab[16] = {
|
||||
{ 0 , 0 }, // forbid
|
||||
{ 24000, 1001},
|
||||
{ 24 , 1 },
|
||||
{ 25 , 1 },
|
||||
{ 30000, 1001},
|
||||
{ 30 , 1 },
|
||||
{ 50 , 1 },
|
||||
{ 60000, 1001},
|
||||
{ 60 , 1 },
|
||||
{ 100 , 1 },
|
||||
{ 120 , 1 },
|
||||
{ 200 , 1 },
|
||||
{ 240 , 1 },
|
||||
{ 300 , 1 },
|
||||
{ 0 , 0 }, // reserved
|
||||
{ 0 , 0 } // reserved
|
||||
};
|
||||
|
||||
static const int ff_avs3_color_primaries_tab[10] = {
|
||||
AVCOL_PRI_RESERVED0 , // 0
|
||||
AVCOL_PRI_BT709 , // 1
|
||||
AVCOL_PRI_UNSPECIFIED , // 2
|
||||
AVCOL_PRI_RESERVED , // 3
|
||||
AVCOL_PRI_BT470M , // 4
|
||||
AVCOL_PRI_BT470BG , // 5
|
||||
AVCOL_PRI_SMPTE170M , // 6
|
||||
AVCOL_PRI_SMPTE240M , // 7
|
||||
AVCOL_PRI_FILM , // 8
|
||||
AVCOL_PRI_BT2020 // 9
|
||||
};
|
||||
|
||||
static const int ff_avs3_color_transfer_tab[15] = {
|
||||
AVCOL_TRC_RESERVED0 , // 0
|
||||
AVCOL_TRC_BT709 , // 1
|
||||
AVCOL_TRC_UNSPECIFIED , // 2
|
||||
AVCOL_TRC_RESERVED , // 3
|
||||
AVCOL_TRC_GAMMA22 , // 4
|
||||
AVCOL_TRC_GAMMA28 , // 5
|
||||
AVCOL_TRC_SMPTE170M , // 6
|
||||
AVCOL_TRC_SMPTE240M , // 7
|
||||
AVCOL_TRC_LINEAR , // 8
|
||||
AVCOL_TRC_LOG , // 9
|
||||
AVCOL_TRC_LOG_SQRT , // 10
|
||||
AVCOL_TRC_BT2020_12 , // 11
|
||||
AVCOL_TRC_SMPTE2084 , // 12
|
||||
AVCOL_TRC_UNSPECIFIED , // 13
|
||||
AVCOL_TRC_ARIB_STD_B67 // 14
|
||||
};
|
||||
|
||||
static const int ff_avs3_color_matrix_tab[12] = {
|
||||
AVCOL_SPC_RESERVED , // 0
|
||||
AVCOL_SPC_BT709 , // 1
|
||||
AVCOL_SPC_UNSPECIFIED , // 2
|
||||
AVCOL_SPC_RESERVED , // 3
|
||||
AVCOL_SPC_FCC , // 4
|
||||
AVCOL_SPC_BT470BG , // 5
|
||||
AVCOL_SPC_SMPTE170M , // 6
|
||||
AVCOL_SPC_SMPTE240M , // 7
|
||||
AVCOL_SPC_BT2020_NCL , // 8
|
||||
AVCOL_SPC_BT2020_CL , // 9
|
||||
AVCOL_SPC_UNSPECIFIED , // 10
|
||||
AVCOL_SPC_UNSPECIFIED // 11
|
||||
};
|
||||
|
||||
static const enum AVPictureType ff_avs3_image_type[4] = {
|
||||
AV_PICTURE_TYPE_NONE,
|
||||
AV_PICTURE_TYPE_I,
|
||||
AV_PICTURE_TYPE_P,
|
||||
AV_PICTURE_TYPE_B
|
||||
};
|
||||
|
||||
#endif /* AVCODEC_AVS3_H */
|
||||
36
include/libavcodec/bethsoftvideo.h
Normal file
36
include/libavcodec/bethsoftvideo.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Bethesda VID video decoder
|
||||
* Copyright (C) 2007 Nicholas Tung
|
||||
*
|
||||
* 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_BETHSOFTVIDEO_H
|
||||
#define AVCODEC_BETHSOFTVIDEO_H
|
||||
|
||||
enum BethsoftVidBlockType
|
||||
{
|
||||
PALETTE_BLOCK = 0x02,
|
||||
FIRST_AUDIO_BLOCK = 0x7c,
|
||||
AUDIO_BLOCK = 0x7d,
|
||||
VIDEO_I_FRAME = 0x03,
|
||||
VIDEO_P_FRAME = 0x01,
|
||||
VIDEO_YOFF_P_FRAME = 0x04,
|
||||
EOF_BLOCK = 0x14,
|
||||
};
|
||||
|
||||
#endif /* AVCODEC_BETHSOFTVIDEO_H */
|
||||
55
include/libavcodec/bgmc.h
Normal file
55
include/libavcodec/bgmc.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Block Gilbert-Moore decoder
|
||||
* Copyright (c) 2010 Thilo Borgmann <thilo.borgmann _at_ mail.de>
|
||||
*
|
||||
* 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
|
||||
* Block Gilbert-Moore decoder header
|
||||
* @author Thilo Borgmann <thilo.borgmann _at_ mail.de>
|
||||
*/
|
||||
|
||||
|
||||
#ifndef AVCODEC_BGMC_H
|
||||
#define AVCODEC_BGMC_H
|
||||
|
||||
|
||||
#include "get_bits.h"
|
||||
|
||||
|
||||
int ff_bgmc_init(void *logctx, uint8_t **cf_lut, int **cf_lut_status);
|
||||
|
||||
|
||||
void ff_bgmc_end(uint8_t **cf_lut, int **cf_lut_status);
|
||||
|
||||
|
||||
int ff_bgmc_decode_init(GetBitContext *gb,
|
||||
unsigned int *h, unsigned int *l, unsigned int *v);
|
||||
|
||||
|
||||
void ff_bgmc_decode_end(GetBitContext *gb);
|
||||
|
||||
|
||||
void ff_bgmc_decode(GetBitContext *gb, unsigned int num, int32_t *dst,
|
||||
int delta, unsigned int sx,
|
||||
unsigned int *h, unsigned int *l, unsigned int *v,
|
||||
uint8_t *cf_lut, int *cf_lut_status);
|
||||
|
||||
|
||||
#endif /* AVCODEC_BGMC_H */
|
||||
655
include/libavcodec/binkdata.h
Normal file
655
include/libavcodec/binkdata.h
Normal file
@@ -0,0 +1,655 @@
|
||||
/*
|
||||
* Bink video decoder
|
||||
* Copyright (C) 2009 Konstantin Shishkov
|
||||
*
|
||||
* 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_BINKDATA_H
|
||||
#define AVCODEC_BINKDATA_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/** Bink DCT and residue 8x8 block scan order */
|
||||
static const uint8_t bink_scan[64] = {
|
||||
0, 1, 8, 9, 2, 3, 10, 11,
|
||||
4, 5, 12, 13, 6, 7, 14, 15,
|
||||
20, 21, 28, 29, 22, 23, 30, 31,
|
||||
16, 17, 24, 25, 32, 33, 40, 41,
|
||||
34, 35, 42, 43, 48, 49, 56, 57,
|
||||
50, 51, 58, 59, 18, 19, 26, 27,
|
||||
36, 37, 44, 45, 38, 39, 46, 47,
|
||||
52, 53, 60, 61, 54, 55, 62, 63
|
||||
};
|
||||
|
||||
static const uint8_t bink_tree_bits[16][16] = {
|
||||
{
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
|
||||
},
|
||||
{
|
||||
0x00, 0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D,
|
||||
0x0F, 0x13, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F,
|
||||
},
|
||||
{
|
||||
0x00, 0x02, 0x01, 0x09, 0x05, 0x15, 0x0D, 0x1D,
|
||||
0x03, 0x13, 0x0B, 0x1B, 0x07, 0x17, 0x0F, 0x1F,
|
||||
},
|
||||
{
|
||||
0x00, 0x02, 0x06, 0x01, 0x09, 0x05, 0x0D, 0x1D,
|
||||
0x03, 0x13, 0x0B, 0x1B, 0x07, 0x17, 0x0F, 0x1F,
|
||||
},
|
||||
{
|
||||
0x00, 0x04, 0x02, 0x06, 0x01, 0x09, 0x05, 0x0D,
|
||||
0x03, 0x13, 0x0B, 0x1B, 0x07, 0x17, 0x0F, 0x1F,
|
||||
},
|
||||
{
|
||||
0x00, 0x04, 0x02, 0x0A, 0x06, 0x0E, 0x01, 0x09,
|
||||
0x05, 0x0D, 0x03, 0x0B, 0x07, 0x17, 0x0F, 0x1F,
|
||||
},
|
||||
{
|
||||
0x00, 0x02, 0x0A, 0x06, 0x0E, 0x01, 0x09, 0x05,
|
||||
0x0D, 0x03, 0x0B, 0x1B, 0x07, 0x17, 0x0F, 0x1F,
|
||||
},
|
||||
{
|
||||
0x00, 0x01, 0x05, 0x03, 0x13, 0x0B, 0x1B, 0x3B,
|
||||
0x07, 0x27, 0x17, 0x37, 0x0F, 0x2F, 0x1F, 0x3F,
|
||||
},
|
||||
{
|
||||
0x00, 0x01, 0x03, 0x13, 0x0B, 0x2B, 0x1B, 0x3B,
|
||||
0x07, 0x27, 0x17, 0x37, 0x0F, 0x2F, 0x1F, 0x3F,
|
||||
},
|
||||
{
|
||||
0x00, 0x01, 0x05, 0x0D, 0x03, 0x13, 0x0B, 0x1B,
|
||||
0x07, 0x27, 0x17, 0x37, 0x0F, 0x2F, 0x1F, 0x3F,
|
||||
},
|
||||
{
|
||||
0x00, 0x02, 0x01, 0x05, 0x0D, 0x03, 0x13, 0x0B,
|
||||
0x1B, 0x07, 0x17, 0x37, 0x0F, 0x2F, 0x1F, 0x3F,
|
||||
},
|
||||
{
|
||||
0x00, 0x01, 0x09, 0x05, 0x0D, 0x03, 0x13, 0x0B,
|
||||
0x1B, 0x07, 0x17, 0x37, 0x0F, 0x2F, 0x1F, 0x3F,
|
||||
},
|
||||
{
|
||||
0x00, 0x02, 0x01, 0x03, 0x13, 0x0B, 0x1B, 0x3B,
|
||||
0x07, 0x27, 0x17, 0x37, 0x0F, 0x2F, 0x1F, 0x3F,
|
||||
},
|
||||
{
|
||||
0x00, 0x01, 0x05, 0x03, 0x07, 0x27, 0x17, 0x37,
|
||||
0x0F, 0x4F, 0x2F, 0x6F, 0x1F, 0x5F, 0x3F, 0x7F,
|
||||
},
|
||||
{
|
||||
0x00, 0x01, 0x05, 0x03, 0x07, 0x17, 0x37, 0x77,
|
||||
0x0F, 0x4F, 0x2F, 0x6F, 0x1F, 0x5F, 0x3F, 0x7F,
|
||||
},
|
||||
{
|
||||
0x00, 0x02, 0x01, 0x05, 0x03, 0x07, 0x27, 0x17,
|
||||
0x37, 0x0F, 0x2F, 0x6F, 0x1F, 0x5F, 0x3F, 0x7F,
|
||||
},
|
||||
};
|
||||
|
||||
static const uint8_t bink_tree_lens[16][16] = {
|
||||
{ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 },
|
||||
{ 1, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 },
|
||||
{ 2, 2, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 },
|
||||
{ 2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 },
|
||||
{ 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5 },
|
||||
{ 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5 },
|
||||
{ 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5 },
|
||||
{ 1, 3, 3, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 },
|
||||
{ 1, 2, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 },
|
||||
{ 1, 3, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6 },
|
||||
{ 2, 2, 3, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6 },
|
||||
{ 1, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6 },
|
||||
{ 2, 2, 2, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 },
|
||||
{ 1, 3, 3, 3, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7 },
|
||||
{ 1, 3, 3, 3, 5, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 },
|
||||
{ 2, 2, 3, 3, 3, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7 },
|
||||
};
|
||||
|
||||
static const uint8_t bink_patterns[16][64] = {
|
||||
{
|
||||
0x00, 0x08, 0x10, 0x18, 0x20, 0x28, 0x30, 0x38,
|
||||
0x39, 0x31, 0x29, 0x21, 0x19, 0x11, 0x09, 0x01,
|
||||
0x02, 0x0A, 0x12, 0x1A, 0x22, 0x2A, 0x32, 0x3A,
|
||||
0x3B, 0x33, 0x2B, 0x23, 0x1B, 0x13, 0x0B, 0x03,
|
||||
0x04, 0x0C, 0x14, 0x1C, 0x24, 0x2C, 0x34, 0x3C,
|
||||
0x3D, 0x35, 0x2D, 0x25, 0x1D, 0x15, 0x0D, 0x05,
|
||||
0x06, 0x0E, 0x16, 0x1E, 0x26, 0x2E, 0x36, 0x3E,
|
||||
0x3F, 0x37, 0x2F, 0x27, 0x1F, 0x17, 0x0F, 0x07,
|
||||
},
|
||||
{
|
||||
0x3B, 0x3A, 0x39, 0x38, 0x30, 0x31, 0x32, 0x33,
|
||||
0x2B, 0x2A, 0x29, 0x28, 0x20, 0x21, 0x22, 0x23,
|
||||
0x1B, 0x1A, 0x19, 0x18, 0x10, 0x11, 0x12, 0x13,
|
||||
0x0B, 0x0A, 0x09, 0x08, 0x00, 0x01, 0x02, 0x03,
|
||||
0x04, 0x05, 0x06, 0x07, 0x0F, 0x0E, 0x0D, 0x0C,
|
||||
0x14, 0x15, 0x16, 0x17, 0x1F, 0x1E, 0x1D, 0x1C,
|
||||
0x24, 0x25, 0x26, 0x27, 0x2F, 0x2E, 0x2D, 0x2C,
|
||||
0x34, 0x35, 0x36, 0x37, 0x3F, 0x3E, 0x3D, 0x3C,
|
||||
},
|
||||
{
|
||||
0x19, 0x11, 0x12, 0x1A, 0x1B, 0x13, 0x0B, 0x03,
|
||||
0x02, 0x0A, 0x09, 0x01, 0x00, 0x08, 0x10, 0x18,
|
||||
0x20, 0x28, 0x30, 0x38, 0x39, 0x31, 0x29, 0x2A,
|
||||
0x32, 0x3A, 0x3B, 0x33, 0x2B, 0x23, 0x22, 0x21,
|
||||
0x1D, 0x15, 0x16, 0x1E, 0x1F, 0x17, 0x0F, 0x07,
|
||||
0x06, 0x0E, 0x0D, 0x05, 0x04, 0x0C, 0x14, 0x1C,
|
||||
0x24, 0x2C, 0x34, 0x3C, 0x3D, 0x35, 0x2D, 0x2E,
|
||||
0x36, 0x3E, 0x3F, 0x37, 0x2F, 0x27, 0x26, 0x25,
|
||||
},
|
||||
{
|
||||
0x03, 0x0B, 0x02, 0x0A, 0x01, 0x09, 0x00, 0x08,
|
||||
0x10, 0x18, 0x11, 0x19, 0x12, 0x1A, 0x13, 0x1B,
|
||||
0x23, 0x2B, 0x22, 0x2A, 0x21, 0x29, 0x20, 0x28,
|
||||
0x30, 0x38, 0x31, 0x39, 0x32, 0x3A, 0x33, 0x3B,
|
||||
0x3C, 0x34, 0x3D, 0x35, 0x3E, 0x36, 0x3F, 0x37,
|
||||
0x2F, 0x27, 0x2E, 0x26, 0x2D, 0x25, 0x2C, 0x24,
|
||||
0x1C, 0x14, 0x1D, 0x15, 0x1E, 0x16, 0x1F, 0x17,
|
||||
0x0F, 0x07, 0x0E, 0x06, 0x0D, 0x05, 0x0C, 0x04,
|
||||
},
|
||||
{
|
||||
0x18, 0x19, 0x10, 0x11, 0x08, 0x09, 0x00, 0x01,
|
||||
0x02, 0x03, 0x0A, 0x0B, 0x12, 0x13, 0x1A, 0x1B,
|
||||
0x1C, 0x1D, 0x14, 0x15, 0x0C, 0x0D, 0x04, 0x05,
|
||||
0x06, 0x07, 0x0E, 0x0F, 0x16, 0x17, 0x1E, 0x1F,
|
||||
0x27, 0x26, 0x2F, 0x2E, 0x37, 0x36, 0x3F, 0x3E,
|
||||
0x3D, 0x3C, 0x35, 0x34, 0x2D, 0x2C, 0x25, 0x24,
|
||||
0x23, 0x22, 0x2B, 0x2A, 0x33, 0x32, 0x3B, 0x3A,
|
||||
0x39, 0x38, 0x31, 0x30, 0x29, 0x28, 0x21, 0x20,
|
||||
},
|
||||
{
|
||||
0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0A, 0x0B,
|
||||
0x10, 0x11, 0x12, 0x13, 0x18, 0x19, 0x1A, 0x1B,
|
||||
0x20, 0x21, 0x22, 0x23, 0x28, 0x29, 0x2A, 0x2B,
|
||||
0x30, 0x31, 0x32, 0x33, 0x38, 0x39, 0x3A, 0x3B,
|
||||
0x04, 0x05, 0x06, 0x07, 0x0C, 0x0D, 0x0E, 0x0F,
|
||||
0x14, 0x15, 0x16, 0x17, 0x1C, 0x1D, 0x1E, 0x1F,
|
||||
0x24, 0x25, 0x26, 0x27, 0x2C, 0x2D, 0x2E, 0x2F,
|
||||
0x34, 0x35, 0x36, 0x37, 0x3C, 0x3D, 0x3E, 0x3F,
|
||||
},
|
||||
{
|
||||
0x06, 0x07, 0x0F, 0x0E, 0x0D, 0x05, 0x0C, 0x04,
|
||||
0x03, 0x0B, 0x02, 0x0A, 0x09, 0x01, 0x00, 0x08,
|
||||
0x10, 0x18, 0x11, 0x19, 0x12, 0x1A, 0x13, 0x1B,
|
||||
0x14, 0x1C, 0x15, 0x1D, 0x16, 0x1E, 0x17, 0x1F,
|
||||
0x27, 0x2F, 0x26, 0x2E, 0x25, 0x2D, 0x24, 0x2C,
|
||||
0x23, 0x2B, 0x22, 0x2A, 0x21, 0x29, 0x20, 0x28,
|
||||
0x31, 0x30, 0x38, 0x39, 0x3A, 0x32, 0x3B, 0x33,
|
||||
0x3C, 0x34, 0x3D, 0x35, 0x36, 0x37, 0x3F, 0x3E,
|
||||
},
|
||||
{
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x08,
|
||||
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
|
||||
0x1F, 0x1E, 0x1D, 0x1C, 0x1B, 0x1A, 0x19, 0x18,
|
||||
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
|
||||
0x2F, 0x2E, 0x2D, 0x2C, 0x2B, 0x2A, 0x29, 0x28,
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
|
||||
0x3F, 0x3E, 0x3D, 0x3C, 0x3B, 0x3A, 0x39, 0x38,
|
||||
},
|
||||
{
|
||||
0x00, 0x08, 0x09, 0x01, 0x02, 0x03, 0x0B, 0x0A,
|
||||
0x12, 0x13, 0x1B, 0x1A, 0x19, 0x11, 0x10, 0x18,
|
||||
0x20, 0x28, 0x29, 0x21, 0x22, 0x23, 0x2B, 0x2A,
|
||||
0x32, 0x31, 0x30, 0x38, 0x39, 0x3A, 0x3B, 0x33,
|
||||
0x34, 0x3C, 0x3D, 0x3E, 0x3F, 0x37, 0x36, 0x35,
|
||||
0x2D, 0x2C, 0x24, 0x25, 0x26, 0x2E, 0x2F, 0x27,
|
||||
0x1F, 0x17, 0x16, 0x1E, 0x1D, 0x1C, 0x14, 0x15,
|
||||
0x0D, 0x0C, 0x04, 0x05, 0x06, 0x0E, 0x0F, 0x07,
|
||||
},
|
||||
{
|
||||
0x18, 0x19, 0x10, 0x11, 0x08, 0x09, 0x00, 0x01,
|
||||
0x02, 0x03, 0x0A, 0x0B, 0x12, 0x13, 0x1A, 0x1B,
|
||||
0x1C, 0x1D, 0x14, 0x15, 0x0C, 0x0D, 0x04, 0x05,
|
||||
0x06, 0x07, 0x0E, 0x0F, 0x16, 0x17, 0x1E, 0x1F,
|
||||
0x26, 0x27, 0x2E, 0x2F, 0x36, 0x37, 0x3E, 0x3F,
|
||||
0x3C, 0x3D, 0x34, 0x35, 0x2C, 0x2D, 0x24, 0x25,
|
||||
0x22, 0x23, 0x2A, 0x2B, 0x32, 0x33, 0x3A, 0x3B,
|
||||
0x38, 0x39, 0x30, 0x31, 0x28, 0x29, 0x20, 0x21,
|
||||
},
|
||||
{
|
||||
0x00, 0x08, 0x01, 0x09, 0x02, 0x0A, 0x03, 0x0B,
|
||||
0x13, 0x1B, 0x12, 0x1A, 0x11, 0x19, 0x10, 0x18,
|
||||
0x20, 0x28, 0x21, 0x29, 0x22, 0x2A, 0x23, 0x2B,
|
||||
0x33, 0x3B, 0x32, 0x3A, 0x31, 0x39, 0x30, 0x38,
|
||||
0x3C, 0x34, 0x3D, 0x35, 0x3E, 0x36, 0x3F, 0x37,
|
||||
0x2F, 0x27, 0x2E, 0x26, 0x2D, 0x25, 0x2C, 0x24,
|
||||
0x1F, 0x17, 0x1E, 0x16, 0x1D, 0x15, 0x1C, 0x14,
|
||||
0x0C, 0x04, 0x0D, 0x05, 0x0E, 0x06, 0x0F, 0x07,
|
||||
},
|
||||
{
|
||||
0x00, 0x08, 0x10, 0x18, 0x19, 0x1A, 0x1B, 0x13,
|
||||
0x0B, 0x03, 0x02, 0x01, 0x09, 0x11, 0x12, 0x0A,
|
||||
0x04, 0x0C, 0x14, 0x1C, 0x1D, 0x1E, 0x1F, 0x17,
|
||||
0x0F, 0x07, 0x06, 0x05, 0x0D, 0x15, 0x16, 0x0E,
|
||||
0x24, 0x2C, 0x34, 0x3C, 0x3D, 0x3E, 0x3F, 0x37,
|
||||
0x2F, 0x27, 0x26, 0x25, 0x2D, 0x35, 0x36, 0x2E,
|
||||
0x20, 0x28, 0x30, 0x38, 0x39, 0x3A, 0x3B, 0x33,
|
||||
0x2B, 0x23, 0x22, 0x21, 0x29, 0x31, 0x32, 0x2A,
|
||||
},
|
||||
{
|
||||
0x00, 0x08, 0x09, 0x01, 0x02, 0x03, 0x0B, 0x0A,
|
||||
0x13, 0x1B, 0x1A, 0x12, 0x11, 0x10, 0x18, 0x19,
|
||||
0x21, 0x20, 0x28, 0x29, 0x2A, 0x22, 0x23, 0x2B,
|
||||
0x33, 0x3B, 0x3A, 0x32, 0x31, 0x39, 0x38, 0x30,
|
||||
0x34, 0x3C, 0x3D, 0x35, 0x36, 0x3E, 0x3F, 0x37,
|
||||
0x2F, 0x27, 0x26, 0x2E, 0x2D, 0x2C, 0x24, 0x25,
|
||||
0x1D, 0x1C, 0x14, 0x15, 0x16, 0x1E, 0x1F, 0x17,
|
||||
0x0E, 0x0F, 0x07, 0x06, 0x05, 0x0D, 0x0C, 0x04,
|
||||
},
|
||||
{
|
||||
0x18, 0x10, 0x08, 0x00, 0x01, 0x02, 0x03, 0x0B,
|
||||
0x13, 0x1B, 0x1A, 0x19, 0x11, 0x0A, 0x09, 0x12,
|
||||
0x1C, 0x14, 0x0C, 0x04, 0x05, 0x06, 0x07, 0x0F,
|
||||
0x17, 0x1F, 0x1E, 0x1D, 0x15, 0x0E, 0x0D, 0x16,
|
||||
0x3C, 0x34, 0x2C, 0x24, 0x25, 0x26, 0x27, 0x2F,
|
||||
0x37, 0x3F, 0x3E, 0x3D, 0x35, 0x2E, 0x2D, 0x36,
|
||||
0x38, 0x30, 0x28, 0x20, 0x21, 0x22, 0x23, 0x2B,
|
||||
0x33, 0x3B, 0x3A, 0x39, 0x31, 0x2A, 0x29, 0x32,
|
||||
},
|
||||
{
|
||||
0x00, 0x08, 0x09, 0x01, 0x02, 0x0A, 0x12, 0x11,
|
||||
0x10, 0x18, 0x19, 0x1A, 0x1B, 0x13, 0x0B, 0x03,
|
||||
0x07, 0x06, 0x0E, 0x0F, 0x17, 0x16, 0x15, 0x0D,
|
||||
0x05, 0x04, 0x0C, 0x14, 0x1C, 0x1D, 0x1E, 0x1F,
|
||||
0x3F, 0x3E, 0x36, 0x37, 0x2F, 0x2E, 0x2D, 0x35,
|
||||
0x3D, 0x3C, 0x34, 0x2C, 0x24, 0x25, 0x26, 0x27,
|
||||
0x38, 0x30, 0x31, 0x39, 0x3A, 0x32, 0x2A, 0x29,
|
||||
0x28, 0x20, 0x21, 0x22, 0x23, 0x2B, 0x33, 0x3B,
|
||||
},
|
||||
{
|
||||
0x00, 0x01, 0x08, 0x09, 0x10, 0x11, 0x18, 0x19,
|
||||
0x20, 0x21, 0x28, 0x29, 0x30, 0x31, 0x38, 0x39,
|
||||
0x3A, 0x3B, 0x32, 0x33, 0x2A, 0x2B, 0x22, 0x23,
|
||||
0x1A, 0x1B, 0x12, 0x13, 0x0A, 0x0B, 0x02, 0x03,
|
||||
0x04, 0x05, 0x0C, 0x0D, 0x14, 0x15, 0x1C, 0x1D,
|
||||
0x24, 0x25, 0x2C, 0x2D, 0x34, 0x35, 0x3C, 0x3D,
|
||||
0x3E, 0x3F, 0x36, 0x37, 0x2E, 0x2F, 0x26, 0x27,
|
||||
0x1E, 0x1F, 0x16, 0x17, 0x0E, 0x0F, 0x06, 0x07,
|
||||
}
|
||||
};
|
||||
|
||||
static const int32_t bink_intra_quant[16][64] = {
|
||||
{
|
||||
0x010000, 0x016315, 0x01E83D, 0x02A535, 0x014E7B, 0x016577, 0x02F1E6, 0x02724C,
|
||||
0x010000, 0x00EEDA, 0x024102, 0x017F9B, 0x00BE80, 0x00611E, 0x01083C, 0x00A552,
|
||||
0x021F88, 0x01DC53, 0x027FAD, 0x01F697, 0x014819, 0x00A743, 0x015A31, 0x009688,
|
||||
0x02346F, 0x030EE5, 0x01FBFA, 0x02C096, 0x01D000, 0x028396, 0x019247, 0x01F9AA,
|
||||
0x02346F, 0x01FBFA, 0x01DC53, 0x0231B8, 0x012F12, 0x01E06C, 0x00CB10, 0x0119A8,
|
||||
0x01C48C, 0x019748, 0x014E86, 0x0122AF, 0x02C628, 0x027F20, 0x0297B5, 0x023F32,
|
||||
0x025000, 0x01AB6B, 0x01D122, 0x0159B3, 0x012669, 0x008D43, 0x00EE1F, 0x0075ED,
|
||||
0x01490C, 0x010288, 0x00F735, 0x00EF51, 0x00E0F1, 0x0072AD, 0x00A4D8, 0x006517,
|
||||
},
|
||||
{
|
||||
0x015555, 0x01D971, 0x028AFC, 0x0386F1, 0x01BDF9, 0x01DC9F, 0x03ED33, 0x034311,
|
||||
0x015555, 0x013E78, 0x030158, 0x01FF7A, 0x00FE00, 0x00817D, 0x01604F, 0x00DC6D,
|
||||
0x02D4B5, 0x027B19, 0x0354E7, 0x029E1F, 0x01B577, 0x00DF04, 0x01CD96, 0x00C8B6,
|
||||
0x02F095, 0x0413DC, 0x02A54E, 0x03AB73, 0x026AAB, 0x035A1E, 0x02185E, 0x02A238,
|
||||
0x02F095, 0x02A54E, 0x027B19, 0x02ECF5, 0x019418, 0x028090, 0x010EC0, 0x01778A,
|
||||
0x025B66, 0x021F0B, 0x01BE09, 0x018394, 0x03B2E0, 0x03542A, 0x0374F1, 0x02FEEE,
|
||||
0x031555, 0x0239E4, 0x026C2D, 0x01CCEE, 0x01888C, 0x00BC59, 0x013D7E, 0x009D3C,
|
||||
0x01B6BB, 0x0158B5, 0x01499C, 0x013F17, 0x012BEC, 0x0098E6, 0x00DBCB, 0x0086C9,
|
||||
},
|
||||
{
|
||||
0x01AAAB, 0x024FCE, 0x032DBB, 0x0468AD, 0x022D78, 0x0253C7, 0x04E87F, 0x0413D5,
|
||||
0x01AAAB, 0x018E16, 0x03C1AE, 0x027F58, 0x013D80, 0x00A1DC, 0x01B863, 0x011388,
|
||||
0x0389E2, 0x0319DF, 0x042A21, 0x0345A7, 0x0222D4, 0x0116C5, 0x0240FC, 0x00FAE3,
|
||||
0x03ACBA, 0x0518D3, 0x034EA1, 0x04964F, 0x030555, 0x0430A5, 0x029E76, 0x034AC5,
|
||||
0x03ACBA, 0x034EA1, 0x0319DF, 0x03A833, 0x01F91E, 0x0320B4, 0x015270, 0x01D56D,
|
||||
0x02F23F, 0x02A6CE, 0x022D8B, 0x01E479, 0x049F98, 0x042935, 0x04522D, 0x03BEA9,
|
||||
0x03DAAB, 0x02C85D, 0x030738, 0x02402A, 0x01EAAF, 0x00EB6F, 0x018CDE, 0x00C48A,
|
||||
0x022469, 0x01AEE2, 0x019C02, 0x018EDD, 0x0176E7, 0x00BF20, 0x0112BE, 0x00A87B,
|
||||
},
|
||||
{
|
||||
0x020000, 0x02C62A, 0x03D07A, 0x054A69, 0x029CF6, 0x02CAEF, 0x05E3CC, 0x04E499,
|
||||
0x020000, 0x01DDB4, 0x048204, 0x02FF36, 0x017D01, 0x00C23C, 0x021077, 0x014AA3,
|
||||
0x043F0F, 0x03B8A6, 0x04FF5A, 0x03ED2E, 0x029032, 0x014E86, 0x02B461, 0x012D11,
|
||||
0x0468DF, 0x061DCA, 0x03F7F5, 0x05812C, 0x03A000, 0x05072C, 0x03248D, 0x03F353,
|
||||
0x0468DF, 0x03F7F5, 0x03B8A6, 0x046370, 0x025E24, 0x03C0D8, 0x019620, 0x02334F,
|
||||
0x038919, 0x032E91, 0x029D0D, 0x02455E, 0x058C50, 0x04FE3F, 0x052F69, 0x047E65,
|
||||
0x04A000, 0x0356D6, 0x03A243, 0x02B365, 0x024CD2, 0x011A85, 0x01DC3E, 0x00EBD9,
|
||||
0x029218, 0x020510, 0x01EE69, 0x01DEA2, 0x01C1E2, 0x00E559, 0x0149B0, 0x00CA2D,
|
||||
},
|
||||
{
|
||||
0x02AAAB, 0x03B2E3, 0x0515F8, 0x070DE2, 0x037BF2, 0x03B93E, 0x07DA65, 0x068621,
|
||||
0x02AAAB, 0x027CF0, 0x0602B1, 0x03FEF3, 0x01FC01, 0x0102FA, 0x02C09F, 0x01B8DA,
|
||||
0x05A96A, 0x04F632, 0x06A9CE, 0x053C3E, 0x036AED, 0x01BE09, 0x039B2D, 0x01916B,
|
||||
0x05E129, 0x0827B8, 0x054A9C, 0x0756E5, 0x04D555, 0x06B43B, 0x0430BC, 0x05446F,
|
||||
0x05E129, 0x054A9C, 0x04F632, 0x05D9EB, 0x032830, 0x050121, 0x021D80, 0x02EF14,
|
||||
0x04B6CC, 0x043E16, 0x037C11, 0x030728, 0x0765C0, 0x06A855, 0x06E9E2, 0x05FDDB,
|
||||
0x062AAB, 0x0473C8, 0x04D85A, 0x0399DC, 0x031118, 0x0178B2, 0x027AFD, 0x013A77,
|
||||
0x036D76, 0x02B16A, 0x029337, 0x027E2E, 0x0257D8, 0x0131CC, 0x01B796, 0x010D91,
|
||||
},
|
||||
{
|
||||
0x038000, 0x04DACA, 0x06ACD5, 0x094238, 0x0492AE, 0x04E322, 0x0A4EA5, 0x08900C,
|
||||
0x038000, 0x0343FB, 0x07E388, 0x053E9F, 0x029AC1, 0x0153E8, 0x039CD0, 0x02429E,
|
||||
0x076E5B, 0x068322, 0x08BEDE, 0x06DF11, 0x047C57, 0x02496B, 0x04BBAB, 0x020EDD,
|
||||
0x07B786, 0x0AB421, 0x06F1ED, 0x09A20D, 0x065800, 0x08CC8E, 0x057FF7, 0x06E9D2,
|
||||
0x07B786, 0x06F1ED, 0x068322, 0x07AE04, 0x0424BF, 0x06917B, 0x02C6B8, 0x03D9CB,
|
||||
0x062FEB, 0x05917D, 0x0492D7, 0x03F964, 0x09B58C, 0x08BCEF, 0x0912F8, 0x07DD30,
|
||||
0x081800, 0x05D7F7, 0x065BF6, 0x04B9F1, 0x040670, 0x01EE69, 0x03416C, 0x019CBC,
|
||||
0x047FAA, 0x0388DC, 0x036138, 0x03459C, 0x03134C, 0x01915C, 0x0240F5, 0x0161CF,
|
||||
},
|
||||
{
|
||||
0x040000, 0x058C54, 0x07A0F4, 0x0A94D3, 0x0539EC, 0x0595DD, 0x0BC798, 0x09C932,
|
||||
0x040000, 0x03BB68, 0x090409, 0x05FE6D, 0x02FA01, 0x018477, 0x0420EE, 0x029547,
|
||||
0x087E1F, 0x07714C, 0x09FEB5, 0x07DA5D, 0x052064, 0x029D0D, 0x0568C3, 0x025A21,
|
||||
0x08D1BE, 0x0C3B94, 0x07EFEA, 0x0B0258, 0x074000, 0x0A0E59, 0x06491A, 0x07E6A7,
|
||||
0x08D1BE, 0x07EFEA, 0x07714C, 0x08C6E0, 0x04BC48, 0x0781B1, 0x032C3F, 0x04669F,
|
||||
0x071232, 0x065D22, 0x053A1A, 0x048ABC, 0x0B18A0, 0x09FC7F, 0x0A5ED3, 0x08FCC9,
|
||||
0x094000, 0x06ADAC, 0x074487, 0x0566CA, 0x0499A5, 0x02350B, 0x03B87B, 0x01D7B3,
|
||||
0x052430, 0x040A20, 0x03DCD3, 0x03BD45, 0x0383C5, 0x01CAB3, 0x029361, 0x01945A,
|
||||
},
|
||||
{
|
||||
0x050000, 0x06EF69, 0x098931, 0x0D3A07, 0x068867, 0x06FB55, 0x0EB97E, 0x0C3B7E,
|
||||
0x050000, 0x04AA42, 0x0B450B, 0x077E08, 0x03B881, 0x01E595, 0x05292A, 0x033A99,
|
||||
0x0A9DA7, 0x094D9F, 0x0C7E62, 0x09D0F4, 0x06687D, 0x034450, 0x06C2F4, 0x02F0AA,
|
||||
0x0B062D, 0x0F4A78, 0x09EBE4, 0x0DC2EE, 0x091000, 0x0C91EF, 0x07DB61, 0x09E050,
|
||||
0x0B062D, 0x09EBE4, 0x094D9F, 0x0AF898, 0x05EB59, 0x09621D, 0x03F74F, 0x058046,
|
||||
0x08D6BE, 0x07F46A, 0x0688A0, 0x05AD6B, 0x0DDEC8, 0x0C7B9F, 0x0CF687, 0x0B3BFB,
|
||||
0x0B9000, 0x085917, 0x0915A8, 0x06C07D, 0x05C00E, 0x02C24D, 0x04A69A, 0x024D9F,
|
||||
0x066D3C, 0x050CA7, 0x04D407, 0x04AC96, 0x0464B6, 0x023D5F, 0x033839, 0x01F971,
|
||||
},
|
||||
{
|
||||
0x060000, 0x08527E, 0x0B716E, 0x0FDF3C, 0x07D6E1, 0x0860CC, 0x11AB63, 0x0EADCB,
|
||||
0x060000, 0x05991C, 0x0D860D, 0x08FDA3, 0x047702, 0x0246B3, 0x063165, 0x03DFEA,
|
||||
0x0CBD2E, 0x0B29F1, 0x0EFE0F, 0x0BC78B, 0x07B096, 0x03EB93, 0x081D24, 0x038732,
|
||||
0x0D3A9C, 0x12595D, 0x0BE7DF, 0x108384, 0x0AE000, 0x0F1585, 0x096DA8, 0x0BD9FA,
|
||||
0x0D3A9C, 0x0BE7DF, 0x0B29F1, 0x0D2A50, 0x071A6B, 0x0B4289, 0x04C25F, 0x0699EE,
|
||||
0x0A9B4A, 0x098BB2, 0x07D727, 0x06D01A, 0x10A4F0, 0x0EFABE, 0x0F8E3C, 0x0D7B2E,
|
||||
0x0DE000, 0x0A0482, 0x0AE6CA, 0x081A2F, 0x06E677, 0x034F90, 0x0594B9, 0x02C38C,
|
||||
0x07B649, 0x060F2F, 0x05CB3C, 0x059BE7, 0x0545A7, 0x02B00C, 0x03DD11, 0x025E87,
|
||||
},
|
||||
{
|
||||
0x080000, 0x0B18A8, 0x0F41E8, 0x1529A5, 0x0A73D7, 0x0B2BBB, 0x178F2F, 0x139264,
|
||||
0x080000, 0x0776CF, 0x120812, 0x0BFCD9, 0x05F402, 0x0308EF, 0x0841DC, 0x052A8E,
|
||||
0x10FC3E, 0x0EE297, 0x13FD69, 0x0FB4B9, 0x0A40C8, 0x053A1A, 0x0AD186, 0x04B442,
|
||||
0x11A37B, 0x187727, 0x0FDFD4, 0x1604B0, 0x0E8000, 0x141CB1, 0x0C9235, 0x0FCD4D,
|
||||
0x11A37B, 0x0FDFD4, 0x0EE297, 0x118DC0, 0x09788F, 0x0F0362, 0x06587F, 0x08CD3D,
|
||||
0x0E2463, 0x0CBA43, 0x0A7434, 0x091577, 0x163140, 0x13F8FE, 0x14BDA5, 0x11F992,
|
||||
0x128000, 0x0D5B58, 0x0E890D, 0x0ACD94, 0x093349, 0x046A15, 0x0770F7, 0x03AF65,
|
||||
0x0A4861, 0x08143F, 0x07B9A6, 0x077A89, 0x070789, 0x039565, 0x0526C2, 0x0328B4,
|
||||
},
|
||||
{
|
||||
0x0C0000, 0x10A4FD, 0x16E2DB, 0x1FBE78, 0x0FADC3, 0x10C198, 0x2356C7, 0x1D5B96,
|
||||
0x0C0000, 0x0B3237, 0x1B0C1A, 0x11FB46, 0x08EE03, 0x048D66, 0x0C62CA, 0x07BFD5,
|
||||
0x197A5D, 0x1653E3, 0x1DFC1E, 0x178F16, 0x0F612C, 0x07D727, 0x103A49, 0x070E64,
|
||||
0x1A7539, 0x24B2BB, 0x17CFBD, 0x210709, 0x15C000, 0x1E2B0A, 0x12DB4F, 0x17B3F4,
|
||||
0x1A7539, 0x17CFBD, 0x1653E3, 0x1A54A0, 0x0E34D7, 0x168513, 0x0984BE, 0x0D33DC,
|
||||
0x153695, 0x131765, 0x0FAE4E, 0x0DA033, 0x2149E1, 0x1DF57D, 0x1F1C78, 0x1AF65B,
|
||||
0x1BC000, 0x140904, 0x15CD94, 0x10345E, 0x0DCCEE, 0x069F20, 0x0B2972, 0x058718,
|
||||
0x0F6C91, 0x0C1E5E, 0x0B9678, 0x0B37CE, 0x0A8B4E, 0x056018, 0x07BA22, 0x04BD0E,
|
||||
},
|
||||
{
|
||||
0x110000, 0x179466, 0x206C0C, 0x2CF87F, 0x16362A, 0x17BCED, 0x321044, 0x299714,
|
||||
0x110000, 0x0FDC79, 0x265125, 0x19794E, 0x0CA685, 0x0672FB, 0x118BF4, 0x0AFA6D,
|
||||
0x241804, 0x1FA181, 0x2A7A80, 0x21600A, 0x15C9A9, 0x0B1B77, 0x16FD3C, 0x09FF0D,
|
||||
0x257B66, 0x33FD33, 0x21BBA2, 0x2EC9F7, 0x1ED000, 0x2ABCF9, 0x1AB6B0, 0x219444,
|
||||
0x257B66, 0x21BBA2, 0x1FA181, 0x254D38, 0x142030, 0x1FE730, 0x0D7C0E, 0x12B423,
|
||||
0x1E0D52, 0x1B0BCF, 0x1636EE, 0x134D9E, 0x2F28A9, 0x2A711B, 0x2C12FF, 0x263256,
|
||||
0x275000, 0x1C621B, 0x1EE33C, 0x16F4DB, 0x138CFB, 0x09616E, 0x0FD00C, 0x07D4B7,
|
||||
0x15D9CE, 0x112B06, 0x106A80, 0x0FE464, 0x0EF004, 0x079D77, 0x0AF25B, 0x06B67F,
|
||||
},
|
||||
{
|
||||
0x160000, 0x1E83CF, 0x29F53D, 0x3A3286, 0x1CBE90, 0x1EB842, 0x40C9C2, 0x35D293,
|
||||
0x160000, 0x1486BA, 0x319630, 0x20F756, 0x105F06, 0x085891, 0x16B51E, 0x0E3506,
|
||||
0x2EB5AA, 0x28EF20, 0x36F8E1, 0x2B30FE, 0x1C3225, 0x0E5FC7, 0x1DC030, 0x0CEFB7,
|
||||
0x308193, 0x4347AC, 0x2BA786, 0x3C8CE5, 0x27E000, 0x374EE7, 0x229212, 0x2B7494,
|
||||
0x308193, 0x2BA786, 0x28EF20, 0x3045D0, 0x1A0B89, 0x29494D, 0x11735D, 0x183469,
|
||||
0x26E410, 0x230039, 0x1CBF8F, 0x18FB09, 0x3D0771, 0x36ECBA, 0x390986, 0x316E52,
|
||||
0x32E000, 0x24BB33, 0x27F8E4, 0x1DB557, 0x194D09, 0x0C23BB, 0x1476A6, 0x0A2256,
|
||||
0x1C470A, 0x1637AD, 0x153E87, 0x1490FA, 0x1354B9, 0x09DAD6, 0x0E2A94, 0x08AFF0,
|
||||
},
|
||||
{
|
||||
0x1C0000, 0x26D64D, 0x3566AA, 0x4A11C2, 0x249572, 0x27190E, 0x527525, 0x44805E,
|
||||
0x1C0000, 0x1A1FD6, 0x3F1C3E, 0x29F4F9, 0x14D607, 0x0A9F44, 0x1CE683, 0x1214F0,
|
||||
0x3B72D9, 0x341911, 0x45F6F0, 0x36F889, 0x23E2BB, 0x124B5B, 0x25DD54, 0x1076E9,
|
||||
0x3DBC30, 0x55A109, 0x378F64, 0x4D1069, 0x32C000, 0x46646C, 0x2BFFB9, 0x374E8E,
|
||||
0x3DBC30, 0x378F64, 0x341911, 0x3D7020, 0x2125F5, 0x348BD6, 0x1635BC, 0x1ECE57,
|
||||
0x317F5B, 0x2C8BEB, 0x2496B6, 0x1FCB22, 0x4DAC61, 0x45E778, 0x4897C2, 0x3EE97F,
|
||||
0x40C000, 0x2EBFB5, 0x32DFAE, 0x25CF86, 0x203380, 0x0F734B, 0x1A0B5F, 0x0CE5E2,
|
||||
0x23FD53, 0x1C46DC, 0x1B09C4, 0x1A2CE1, 0x189A60, 0x0C8AE2, 0x1207A5, 0x0B0E77,
|
||||
},
|
||||
{
|
||||
0x220000, 0x2F28CC, 0x40D818, 0x59F0FE, 0x2C6C53, 0x2F79DA, 0x642089, 0x532E29,
|
||||
0x220000, 0x1FB8F1, 0x4CA24B, 0x32F29C, 0x194D09, 0x0CE5F7, 0x2317E8, 0x15F4DB,
|
||||
0x483007, 0x3F4303, 0x54F4FF, 0x42C014, 0x2B9351, 0x1636EE, 0x2DFA79, 0x13FE1A,
|
||||
0x4AF6CC, 0x67FA67, 0x437743, 0x5D93EE, 0x3DA000, 0x5579F1, 0x356D61, 0x432888,
|
||||
0x4AF6CC, 0x437743, 0x3F4303, 0x4A9A70, 0x284060, 0x3FCE60, 0x1AF81B, 0x256845,
|
||||
0x3C1AA5, 0x36179D, 0x2C6DDD, 0x269B3C, 0x5E5152, 0x54E237, 0x5825FE, 0x4C64AD,
|
||||
0x4EA000, 0x38C437, 0x3DC678, 0x2DE9B5, 0x2719F7, 0x12C2DB, 0x1FA018, 0x0FA96E,
|
||||
0x2BB39B, 0x22560C, 0x20D500, 0x1FC8C8, 0x1DE007, 0x0F3AEE, 0x15E4B7, 0x0D6CFE,
|
||||
},
|
||||
{
|
||||
0x2C0000, 0x3D079E, 0x53EA79, 0x74650C, 0x397D20, 0x3D7083, 0x819383, 0x6BA525,
|
||||
0x2C0000, 0x290D75, 0x632C61, 0x41EEAC, 0x20BE0C, 0x10B121, 0x2D6A3B, 0x1C6A0C,
|
||||
0x5D6B54, 0x51DE40, 0x6DF1C2, 0x5661FB, 0x38644B, 0x1CBF8F, 0x3B8060, 0x19DF6D,
|
||||
0x610326, 0x868F57, 0x574F0B, 0x7919CA, 0x4FC000, 0x6E9DCE, 0x452423, 0x56E928,
|
||||
0x610326, 0x574F0B, 0x51DE40, 0x608BA0, 0x341713, 0x52929A, 0x22E6BA, 0x3068D2,
|
||||
0x4DC821, 0x460071, 0x397F1E, 0x31F611, 0x7A0EE2, 0x6DD974, 0x72130C, 0x62DCA3,
|
||||
0x65C000, 0x497665, 0x4FF1C9, 0x3B6AAE, 0x329A12, 0x184776, 0x28ED4D, 0x1444AC,
|
||||
0x388E14, 0x2C6F5A, 0x2A7D0F, 0x2921F4, 0x26A973, 0x13B5AD, 0x1C5528, 0x115FDF,
|
||||
},
|
||||
};
|
||||
|
||||
static const int32_t bink_inter_quant[16][64] = {
|
||||
{
|
||||
0x010000, 0x017946, 0x01A5A9, 0x0248DC, 0x016363, 0x0152A7, 0x0243EC, 0x0209EA,
|
||||
0x012000, 0x00E248, 0x01BBDA, 0x015CBC, 0x00A486, 0x0053E0, 0x00F036, 0x008095,
|
||||
0x01B701, 0x016959, 0x01B0B9, 0x0153FD, 0x00F8E7, 0x007EE4, 0x00EA30, 0x007763,
|
||||
0x01B701, 0x0260EB, 0x019DE9, 0x023E1B, 0x017000, 0x01FE6E, 0x012DB5, 0x01A27B,
|
||||
0x01E0D1, 0x01B0B9, 0x018A33, 0x01718D, 0x00D87A, 0x014449, 0x007B9A, 0x00AB71,
|
||||
0x013178, 0x0112EA, 0x00AD08, 0x009BB9, 0x023D97, 0x020437, 0x021CCC, 0x01E6B4,
|
||||
0x018000, 0x012DB5, 0x0146D9, 0x0100CE, 0x00CFD2, 0x006E5C, 0x00B0E4, 0x005A2D,
|
||||
0x00E9CC, 0x00B7B1, 0x00846F, 0x006B85, 0x008337, 0x0042E5, 0x004A10, 0x002831,
|
||||
},
|
||||
{
|
||||
0x015555, 0x01F708, 0x023237, 0x030BD0, 0x01D9D9, 0x01C389, 0x03053B, 0x02B7E3,
|
||||
0x018000, 0x012DB5, 0x024FCE, 0x01D0FA, 0x00DB5D, 0x006FD5, 0x014048, 0x00AB71,
|
||||
0x024957, 0x01E1CC, 0x0240F7, 0x01C551, 0x014BDE, 0x00A92F, 0x013840, 0x009F2F,
|
||||
0x024957, 0x032BE4, 0x0227E1, 0x02FD7A, 0x01EAAB, 0x02A893, 0x019247, 0x022DF9,
|
||||
0x028116, 0x0240F7, 0x020D99, 0x01ECBC, 0x0120A3, 0x01B061, 0x00A4CE, 0x00E497,
|
||||
0x01974B, 0x016E8E, 0x00E6B5, 0x00CFA2, 0x02FCC9, 0x02B04A, 0x02D110, 0x0288F1,
|
||||
0x020000, 0x019247, 0x01B3CC, 0x015668, 0x011518, 0x009325, 0x00EBDA, 0x00783D,
|
||||
0x0137BB, 0x00F4ED, 0x00B093, 0x008F5C, 0x00AEF4, 0x005931, 0x0062BF, 0x003597,
|
||||
},
|
||||
{
|
||||
0x01AAAB, 0x0274CB, 0x02BEC4, 0x03CEC4, 0x02504F, 0x02346C, 0x03C689, 0x0365DC,
|
||||
0x01E000, 0x017922, 0x02E3C1, 0x024539, 0x011235, 0x008BCA, 0x01905A, 0x00D64D,
|
||||
0x02DBAD, 0x025A40, 0x02D134, 0x0236A5, 0x019ED6, 0x00D37B, 0x018650, 0x00C6FB,
|
||||
0x02DBAD, 0x03F6DD, 0x02B1D9, 0x03BCD8, 0x026555, 0x0352B8, 0x01F6D8, 0x02B977,
|
||||
0x03215C, 0x02D134, 0x029100, 0x0267EB, 0x0168CC, 0x021C7A, 0x00CE01, 0x011DBD,
|
||||
0x01FD1E, 0x01CA31, 0x012062, 0x01038A, 0x03BBFB, 0x035C5C, 0x038554, 0x032B2D,
|
||||
0x028000, 0x01F6D8, 0x0220C0, 0x01AC02, 0x015A5E, 0x00B7EF, 0x0126D1, 0x00964C,
|
||||
0x0185A9, 0x013228, 0x00DCB8, 0x00B333, 0x00DAB2, 0x006F7D, 0x007B6F, 0x0042FC,
|
||||
},
|
||||
{
|
||||
0x020000, 0x02F28D, 0x034B52, 0x0491B8, 0x02C6C5, 0x02A54E, 0x0487D8, 0x0413D5,
|
||||
0x024000, 0x01C48F, 0x0377B5, 0x02B977, 0x01490C, 0x00A7BF, 0x01E06C, 0x01012A,
|
||||
0x036E03, 0x02D2B3, 0x036172, 0x02A7FA, 0x01F1CE, 0x00FDC7, 0x01D460, 0x00EEC7,
|
||||
0x036E03, 0x04C1D6, 0x033BD1, 0x047C37, 0x02E000, 0x03FCDD, 0x025B6A, 0x0344F5,
|
||||
0x03C1A1, 0x036172, 0x031466, 0x02E31B, 0x01B0F5, 0x028892, 0x00F735, 0x0156E2,
|
||||
0x0262F1, 0x0225D5, 0x015A10, 0x013772, 0x047B2D, 0x04086E, 0x043998, 0x03CD69,
|
||||
0x030000, 0x025B6A, 0x028DB3, 0x02019B, 0x019FA3, 0x00DCB8, 0x0161C7, 0x00B45B,
|
||||
0x01D398, 0x016F63, 0x0108DD, 0x00D70A, 0x01066F, 0x0085C9, 0x00941F, 0x005062,
|
||||
},
|
||||
{
|
||||
0x02AAAB, 0x03EE11, 0x04646D, 0x0617A0, 0x03B3B2, 0x038713, 0x060A75, 0x056FC6,
|
||||
0x030000, 0x025B6A, 0x049F9B, 0x03A1F4, 0x01B6BB, 0x00DFAA, 0x028090, 0x0156E2,
|
||||
0x0492AE, 0x03C399, 0x0481ED, 0x038AA2, 0x0297BD, 0x01525F, 0x027080, 0x013E5E,
|
||||
0x0492AE, 0x0657C8, 0x044FC1, 0x05FAF4, 0x03D555, 0x055126, 0x03248D, 0x045BF2,
|
||||
0x05022D, 0x0481ED, 0x041B33, 0x03D979, 0x024147, 0x0360C3, 0x01499C, 0x01C92E,
|
||||
0x032E96, 0x02DD1C, 0x01CD6A, 0x019F43, 0x05F991, 0x056093, 0x05A220, 0x0511E1,
|
||||
0x040000, 0x03248D, 0x036799, 0x02ACCF, 0x022A2F, 0x01264B, 0x01D7B5, 0x00F079,
|
||||
0x026F75, 0x01E9D9, 0x016127, 0x011EB8, 0x015DE9, 0x00B262, 0x00C57F, 0x006B2D,
|
||||
},
|
||||
{
|
||||
0x038000, 0x052876, 0x05C3CF, 0x07FF02, 0x04DBD9, 0x04A148, 0x07EDBA, 0x0722B4,
|
||||
0x03F000, 0x0317FB, 0x06117C, 0x04C491, 0x023FD5, 0x01258F, 0x0348BD, 0x01C209,
|
||||
0x060085, 0x04F0B9, 0x05EA87, 0x04A5F5, 0x036728, 0x01BC1C, 0x0333A8, 0x01A1DB,
|
||||
0x060085, 0x085336, 0x05A8AE, 0x07D960, 0x050800, 0x06FA82, 0x041FF9, 0x05B8AE,
|
||||
0x0692DA, 0x05EA87, 0x0563B2, 0x050D6E, 0x02F5AD, 0x046F00, 0x01B09C, 0x02580C,
|
||||
0x042D25, 0x03C235, 0x025D9B, 0x022108, 0x07D78F, 0x070EC1, 0x0764CA, 0x06A777,
|
||||
0x054000, 0x041FF9, 0x0477F9, 0x0382D0, 0x02D75E, 0x018242, 0x026B1D, 0x013B9F,
|
||||
0x03324A, 0x0282ED, 0x01CF83, 0x017851, 0x01CB42, 0x00EA21, 0x010336, 0x008CAC,
|
||||
},
|
||||
{
|
||||
0x040000, 0x05E519, 0x0696A4, 0x092370, 0x058D8A, 0x054A9C, 0x090FB0, 0x0827AA,
|
||||
0x048000, 0x03891F, 0x06EF69, 0x0572EE, 0x029218, 0x014F7E, 0x03C0D8, 0x020254,
|
||||
0x06DC05, 0x05A565, 0x06C2E4, 0x054FF3, 0x03E39B, 0x01FB8E, 0x03A8C0, 0x01DD8D,
|
||||
0x06DC05, 0x0983AC, 0x0677A2, 0x08F86E, 0x05C000, 0x07F9B9, 0x04B6D4, 0x0689EB,
|
||||
0x078343, 0x06C2E4, 0x0628CC, 0x05C635, 0x0361EA, 0x051124, 0x01EE69, 0x02ADC5,
|
||||
0x04C5E1, 0x044BAA, 0x02B41F, 0x026EE5, 0x08F65A, 0x0810DD, 0x087330, 0x079AD1,
|
||||
0x060000, 0x04B6D4, 0x051B65, 0x040337, 0x033F47, 0x01B970, 0x02C38F, 0x0168B6,
|
||||
0x03A730, 0x02DEC6, 0x0211BA, 0x01AE14, 0x020CDD, 0x010B93, 0x01283E, 0x00A0C4,
|
||||
},
|
||||
{
|
||||
0x050000, 0x075E60, 0x083C4D, 0x0B6C4C, 0x06F0ED, 0x069D43, 0x0B539C, 0x0A3194,
|
||||
0x05A000, 0x046B67, 0x08AB44, 0x06CFAA, 0x03369E, 0x01A35E, 0x04B10F, 0x0282E8,
|
||||
0x089307, 0x070EBF, 0x08739C, 0x06A3F0, 0x04DC82, 0x027A72, 0x0492F0, 0x0254F0,
|
||||
0x089307, 0x0BE497, 0x08158B, 0x0B3689, 0x073000, 0x09F827, 0x05E489, 0x082C66,
|
||||
0x096413, 0x08739C, 0x07B2FF, 0x0737C2, 0x043A64, 0x06556D, 0x026A04, 0x035936,
|
||||
0x05F75A, 0x055E94, 0x036127, 0x030A9E, 0x0B33F1, 0x0A1514, 0x0A8FFC, 0x098186,
|
||||
0x078000, 0x05E489, 0x06623F, 0x050405, 0x040F19, 0x0227CC, 0x037473, 0x01C2E3,
|
||||
0x0490FC, 0x039677, 0x029629, 0x021999, 0x029015, 0x014E78, 0x01724E, 0x00C8F5,
|
||||
},
|
||||
{
|
||||
0x060000, 0x08D7A6, 0x09E1F6, 0x0DB528, 0x085450, 0x07EFEA, 0x0D9788, 0x0C3B7E,
|
||||
0x06C000, 0x054DAE, 0x0A671E, 0x082C66, 0x03DB24, 0x01F73E, 0x05A145, 0x03037D,
|
||||
0x0A4A08, 0x087818, 0x0A2455, 0x07F7ED, 0x05D569, 0x02F955, 0x057D20, 0x02CC54,
|
||||
0x0A4A08, 0x0E4582, 0x09B373, 0x0D74A5, 0x08A000, 0x0BF696, 0x07123E, 0x09CEE0,
|
||||
0x0B44E4, 0x0A2455, 0x093D32, 0x08A950, 0x0512DF, 0x0799B6, 0x02E59E, 0x0404A7,
|
||||
0x0728D2, 0x06717F, 0x040E2F, 0x03A657, 0x0D7187, 0x0C194B, 0x0CACC8, 0x0B683A,
|
||||
0x090000, 0x07123E, 0x07A918, 0x0604D2, 0x04DEEA, 0x029629, 0x042556, 0x021D11,
|
||||
0x057AC8, 0x044E28, 0x031A97, 0x02851E, 0x03134C, 0x01915C, 0x01BC5D, 0x00F126,
|
||||
},
|
||||
{
|
||||
0x080000, 0x0BCA33, 0x0D2D48, 0x1246E0, 0x0B1B15, 0x0A9538, 0x121F5F, 0x104F53,
|
||||
0x090000, 0x07123E, 0x0DDED2, 0x0AE5DD, 0x052430, 0x029EFD, 0x0781B1, 0x0404A7,
|
||||
0x0DB80B, 0x0B4ACB, 0x0D85C7, 0x0A9FE7, 0x07C736, 0x03F71D, 0x075180, 0x03BB1A,
|
||||
0x0DB80B, 0x130757, 0x0CEF44, 0x11F0DC, 0x0B8000, 0x0FF372, 0x096DA8, 0x0D13D6,
|
||||
0x0F0686, 0x0D85C7, 0x0C5198, 0x0B8C6A, 0x06C3D4, 0x0A2248, 0x03DCD3, 0x055B8A,
|
||||
0x098BC3, 0x089754, 0x05683E, 0x04DDC9, 0x11ECB4, 0x1021B9, 0x10E661, 0x0F35A3,
|
||||
0x0C0000, 0x096DA8, 0x0A36CB, 0x08066E, 0x067E8E, 0x0372E1, 0x05871E, 0x02D16B,
|
||||
0x074E60, 0x05BD8B, 0x042374, 0x035C28, 0x0419BB, 0x021726, 0x02507C, 0x014188,
|
||||
},
|
||||
{
|
||||
0x0C0000, 0x11AF4C, 0x13C3EC, 0x1B6A50, 0x10A89F, 0x0FDFD4, 0x1B2F0F, 0x1876FD,
|
||||
0x0D8000, 0x0A9B5D, 0x14CE3C, 0x1058CB, 0x07B649, 0x03EE7B, 0x0B4289, 0x0606FB,
|
||||
0x149410, 0x10F030, 0x1448AB, 0x0FEFDA, 0x0BAAD2, 0x05F2AB, 0x0AFA40, 0x0598A7,
|
||||
0x149410, 0x1C8B03, 0x1366E6, 0x1AE949, 0x114000, 0x17ED2B, 0x0E247C, 0x139DC1,
|
||||
0x1689C8, 0x1448AB, 0x127A63, 0x11529F, 0x0A25BE, 0x0F336D, 0x05CB3C, 0x08094E,
|
||||
0x0E51A4, 0x0CE2FE, 0x081C5D, 0x074CAE, 0x1AE30E, 0x183296, 0x195991, 0x16D074,
|
||||
0x120000, 0x0E247C, 0x0F5230, 0x0C09A5, 0x09BDD5, 0x052C51, 0x084AAC, 0x043A21,
|
||||
0x0AF590, 0x089C51, 0x06352E, 0x050A3B, 0x062698, 0x0322B9, 0x0378BA, 0x01E24D,
|
||||
},
|
||||
{
|
||||
0x110000, 0x190DAC, 0x1C0039, 0x26D69C, 0x17998C, 0x167D16, 0x2682AB, 0x22A891,
|
||||
0x132000, 0x0F06C3, 0x1D797F, 0x172876, 0x0AECE7, 0x0591D9, 0x0FF398, 0x0889E3,
|
||||
0x1D2717, 0x17FEEF, 0x1CBC47, 0x1693CA, 0x108754, 0x086D1D, 0x0F8D30, 0x07ED98,
|
||||
0x1D2717, 0x286F9A, 0x1B7C71, 0x261FD3, 0x187000, 0x21E552, 0x140904, 0x1BCA27,
|
||||
0x1FEDDC, 0x1CBC47, 0x1A2D62, 0x188A62, 0x0E6022, 0x1588DA, 0x083540, 0x0B6284,
|
||||
0x1448FE, 0x124192, 0x0B7D84, 0x0A574B, 0x2616FF, 0x2247AA, 0x23E98D, 0x2051FA,
|
||||
0x198000, 0x140904, 0x15B46F, 0x110DAA, 0x0DCCEE, 0x07541E, 0x0BBF1F, 0x05FD04,
|
||||
0x0F868B, 0x0C32C8, 0x08CB57, 0x0723D4, 0x08B6AD, 0x047130, 0x04EB08, 0x02AB42,
|
||||
},
|
||||
{
|
||||
0x160000, 0x206C0C, 0x243C86, 0x3242E8, 0x1E8A79, 0x1D1A59, 0x31D646, 0x2CDA25,
|
||||
0x18C000, 0x13722A, 0x2624C3, 0x1DF820, 0x0E2385, 0x073537, 0x14A4A7, 0x0B0CCC,
|
||||
0x25BA1D, 0x1F0DAE, 0x252FE4, 0x1D37BB, 0x1563D6, 0x0AE78E, 0x142021, 0x0A4288,
|
||||
0x25BA1D, 0x345430, 0x2391FB, 0x31565C, 0x1FA000, 0x2BDD7A, 0x19ED8D, 0x23F68C,
|
||||
0x2951EF, 0x252FE4, 0x21E061, 0x1FC224, 0x129A87, 0x1BDE47, 0x0A9F44, 0x0EBBBA,
|
||||
0x1A4058, 0x17A026, 0x0EDEAB, 0x0D61E9, 0x314AEF, 0x2C5CBE, 0x2E798A, 0x29D380,
|
||||
0x210000, 0x19ED8D, 0x1C16AE, 0x1611AE, 0x11DC06, 0x097BEA, 0x0F3391, 0x07BFE7,
|
||||
0x141787, 0x0FC93E, 0x0B617F, 0x093D6D, 0x0B46C1, 0x05BFA8, 0x065D55, 0x037437,
|
||||
},
|
||||
{
|
||||
0x1C0000, 0x2943B2, 0x2E1E7C, 0x3FF810, 0x26DEC9, 0x250A43, 0x3F6DCE, 0x3915A3,
|
||||
0x1F8000, 0x18BFD8, 0x308BE1, 0x262485, 0x11FEA9, 0x092C75, 0x1A45EB, 0x0E1049,
|
||||
0x300425, 0x2785C6, 0x2F5439, 0x252FA8, 0x1B393F, 0x0DE0E4, 0x199D41, 0x0D0EDC,
|
||||
0x300425, 0x4299B2, 0x2D456E, 0x3ECB00, 0x284000, 0x37D40F, 0x20FFCB, 0x2DC56D,
|
||||
0x3496D3, 0x2F5439, 0x2B1D93, 0x286B74, 0x17AD66, 0x2377FE, 0x0D84E2, 0x12C062,
|
||||
0x21692A, 0x1E11A5, 0x12ECDA, 0x110840, 0x3EBC76, 0x387608, 0x3B2652, 0x353BBA,
|
||||
0x2A0000, 0x20FFCB, 0x23BFC6, 0x1C1681, 0x16BAF1, 0x0C1213, 0x1358E8, 0x09DCF8,
|
||||
0x19924F, 0x141767, 0x0E7C16, 0x0BC28A, 0x0E5A0D, 0x075104, 0x0819B2, 0x04655D,
|
||||
},
|
||||
{
|
||||
0x220000, 0x321B58, 0x380072, 0x4DAD38, 0x2F3318, 0x2CFA2D, 0x4D0556, 0x455122,
|
||||
0x264000, 0x1E0D86, 0x3AF2FE, 0x2E50EB, 0x15D9CE, 0x0B23B2, 0x1FE730, 0x1113C7,
|
||||
0x3A4E2D, 0x2FFDDF, 0x39788E, 0x2D2795, 0x210EA8, 0x10DA39, 0x1F1A61, 0x0FDB2F,
|
||||
0x3A4E2D, 0x50DF33, 0x36F8E1, 0x4C3FA5, 0x30E000, 0x43CAA5, 0x281209, 0x37944D,
|
||||
0x3FDBB7, 0x39788E, 0x345AC4, 0x3114C3, 0x1CC044, 0x2B11B4, 0x106A80, 0x16C509,
|
||||
0x2891FC, 0x248324, 0x16FB08, 0x14AE97, 0x4C2DFD, 0x448F54, 0x47D31B, 0x40A3F5,
|
||||
0x330000, 0x281209, 0x2B68DF, 0x221B53, 0x1B99DB, 0x0EA83B, 0x177E3E, 0x0BFA09,
|
||||
0x1F0D17, 0x18658F, 0x1196AE, 0x0E47A8, 0x116D5A, 0x08E260, 0x09D60F, 0x055684,
|
||||
},
|
||||
{
|
||||
0x2C0000, 0x40D818, 0x48790C, 0x6485D0, 0x3D14F2, 0x3A34B2, 0x63AC8D, 0x59B44A,
|
||||
0x318000, 0x26E454, 0x4C4986, 0x3BF03F, 0x1C470A, 0x0E6A6E, 0x29494D, 0x161998,
|
||||
0x4B743A, 0x3E1B5C, 0x4A5FC7, 0x3A6F75, 0x2AC7AC, 0x15CF1D, 0x284041, 0x148510,
|
||||
0x4B743A, 0x68A861, 0x4723F6, 0x62ACB8, 0x3F4000, 0x57BAF3, 0x33DB1A, 0x47ED19,
|
||||
0x52A3DE, 0x4A5FC7, 0x43C0C2, 0x3F8448, 0x25350D, 0x37BC8E, 0x153E87, 0x1D7775,
|
||||
0x3480B0, 0x2F404C, 0x1DBD56, 0x1AC3D2, 0x6295DE, 0x58B97B, 0x5CF313, 0x53A701,
|
||||
0x420000, 0x33DB1A, 0x382D5C, 0x2C235D, 0x23B80D, 0x12F7D4, 0x1E6723, 0x0F7FCF,
|
||||
0x282F0E, 0x1F927D, 0x16C2FF, 0x127AD9, 0x168D83, 0x0B7F50, 0x0CBAAA, 0x06E86E,
|
||||
},
|
||||
};
|
||||
|
||||
static const uint8_t binkb_runbits[64] = {
|
||||
6, 6, 6, 6, 6, 6, 6, 6,
|
||||
6, 6, 6, 6, 6, 6, 6, 6,
|
||||
6, 6, 6, 6, 6, 6, 6, 6,
|
||||
6, 6, 6, 6, 6, 6, 6, 6,
|
||||
5, 5, 5, 5, 5, 5, 5, 5,
|
||||
5, 5, 5, 5, 5, 5, 5, 5,
|
||||
4, 4, 4, 4, 4, 4, 4, 4,
|
||||
3, 3, 3, 3, 2, 2, 1, 0,
|
||||
};
|
||||
|
||||
static const uint8_t binkb_intra_seed[64] = {
|
||||
16, 16, 16, 19, 16, 19, 22, 22,
|
||||
22, 22, 26, 24, 26, 22, 22, 27,
|
||||
27, 27, 26, 26, 26, 29, 29, 29,
|
||||
27, 27, 27, 26, 34, 34, 34, 29,
|
||||
29, 29, 27, 27, 37, 34, 34, 32,
|
||||
32, 29, 29, 38, 37, 35, 35, 34,
|
||||
35, 40, 40, 40, 38, 38, 48, 48,
|
||||
46, 46, 58, 56, 56, 69, 69, 83,
|
||||
};
|
||||
|
||||
static const uint8_t binkb_inter_seed[64] = {
|
||||
16, 17, 17, 18, 18, 18, 19, 19,
|
||||
19, 19, 20, 20, 20, 20, 20, 21,
|
||||
21, 21, 21, 21, 21, 22, 22, 22,
|
||||
22, 22, 22, 22, 23, 23, 23, 23,
|
||||
23, 23, 23, 23, 24, 24, 24, 25,
|
||||
24, 24, 24, 25, 26, 26, 26, 26,
|
||||
25, 27, 27, 27, 27, 27, 28, 28,
|
||||
28, 28, 30, 30, 30, 31, 31, 33,
|
||||
};
|
||||
|
||||
static const uint8_t binkb_num[16] = {
|
||||
1, 4, 5, 2, 7, 8, 3, 7, 4, 9, 5, 6, 7, 8, 9, 10
|
||||
};
|
||||
|
||||
static const uint8_t binkb_den[16] = {
|
||||
1, 3, 3, 1, 3, 3, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1
|
||||
};
|
||||
|
||||
#endif /* AVCODEC_BINKDATA_H */
|
||||
41
include/libavcodec/binkdsp.h
Normal file
41
include/libavcodec/binkdsp.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Bink DSP routines
|
||||
* Copyright (c) 2009 Konstantin Shishkov
|
||||
*
|
||||
* 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
|
||||
* Bink DSP routines
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_BINKDSP_H
|
||||
#define AVCODEC_BINKDSP_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct BinkDSPContext {
|
||||
void (*idct_put)(uint8_t *dest/*align 8*/, int line_size, int32_t *block/*align 16*/);
|
||||
void (*idct_add)(uint8_t *dest/*align 8*/, int line_size, int32_t *block/*align 16*/);
|
||||
void (*scale_block)(const uint8_t src[64]/*align 8*/, uint8_t *dst/*align 8*/, int linesize);
|
||||
void (*add_pixels8)(uint8_t *restrict pixels, int16_t *block, int line_size);
|
||||
} BinkDSPContext;
|
||||
|
||||
void ff_binkdsp_init(BinkDSPContext *c);
|
||||
|
||||
#endif /* AVCODEC_BINKDSP_H */
|
||||
37
include/libavcodec/bintext.h
Normal file
37
include/libavcodec/bintext.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Binary text decoder
|
||||
* Copyright (c) 2010 Peter Ross (pross@xvid.org)
|
||||
*
|
||||
* 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
|
||||
* Binary text decoder
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_BINTEXT_H
|
||||
#define AVCODEC_BINTEXT_H
|
||||
|
||||
/* flag values passed between avformat and avcodec;
|
||||
* while these are identical to the XBIN flags, they are also used
|
||||
* for the BINTEXT and IDF decoders.
|
||||
*/
|
||||
#define BINTEXT_PALETTE 0x1
|
||||
#define BINTEXT_FONT 0x2
|
||||
|
||||
#endif /* AVCODEC_BINTEXT_H */
|
||||
198
include/libavcodec/bitstream.h
Normal file
198
include/libavcodec/bitstream.h
Normal file
@@ -0,0 +1,198 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Alexandra Hájková
|
||||
*
|
||||
* 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
|
||||
* bitstream reader API header.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Bit order (endianness) is controlled by #defining BITSTREAM_BE and/or
|
||||
* BITSTREAM_LE before #including this header. The corresponding bitreading
|
||||
* functions are provided as bits_*_be()/bits_*_le() respectively.
|
||||
*
|
||||
* If neither or only BITSTREAM_BE is defined, then the default (unsuffixed)
|
||||
* bits_*() will resolve to the big-endian implementation. If only BITSTREAM_LE
|
||||
* is defined, little-endian will be the default.
|
||||
*
|
||||
* If both are defined, then the default can be controlled by defining at most
|
||||
* one of BITSTREAM_DEFAULT_LE/BE. When BITSTREAM_DEFAULT_* is not defined, no
|
||||
* default is provided and you must always explicitly use the _be() or _le()
|
||||
* variants.
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_BITSTREAM_H
|
||||
#define AVCODEC_BITSTREAM_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "libavutil/avassert.h"
|
||||
#include "libavutil/common.h"
|
||||
#include "libavutil/intreadwrite.h"
|
||||
#include "libavutil/log.h"
|
||||
|
||||
#include "mathops.h"
|
||||
#include "vlc.h"
|
||||
|
||||
#ifndef UNCHECKED_BITSTREAM_READER
|
||||
#define UNCHECKED_BITSTREAM_READER !CONFIG_SAFE_BITSTREAM_READER
|
||||
#endif
|
||||
|
||||
// select the default endianness, if any
|
||||
#if defined(BITSTREAM_LE) && defined(BITSTREAM_BE)
|
||||
|
||||
# if defined(BITSTREAM_DEFAULT_BE) && defined(BITSTREAM_DEFAULT_LE)
|
||||
# error "At most one of BITSTREAM_DEFAULT_BE/LE must be defined"
|
||||
# elif defined(BITSTREAM_DEFAULT_BE)
|
||||
# define BITS_DEFAULT_BE
|
||||
# elif defined(BITSTREAM_DEFAULT_LE)
|
||||
# define BITS_DEFAULT_LE
|
||||
# endif
|
||||
|
||||
#elif defined(BITSTREAM_LE)
|
||||
# define BITS_DEFAULT_LE
|
||||
#else // select BE if nothing is requested explicitly
|
||||
# define BITS_DEFAULT_BE
|
||||
# define BITSTREAM_WANT_BE
|
||||
#endif
|
||||
|
||||
#if defined(BITS_DEFAULT_LE)
|
||||
|
||||
# define BitstreamContext BitstreamContextLE
|
||||
# define bits_init bits_init_le
|
||||
# define bits_init8 bits_init8_le
|
||||
# define bits_tell bits_tell_le
|
||||
# define bits_size bits_size_le
|
||||
# define bits_left bits_left_le
|
||||
# define bits_read_bit bits_read_bit_le
|
||||
# define bits_read_nz bits_read_nz_le
|
||||
# define bits_read bits_read_le
|
||||
# define bits_read_63 bits_read_63_le
|
||||
# define bits_read_64 bits_read_64_le
|
||||
# define bits_read_signed bits_read_signed_le
|
||||
# define bits_read_signed_nz bits_read_signed_nz_le
|
||||
# define bits_peek_nz bits_peek_nz_le
|
||||
# define bits_peek bits_peek_le
|
||||
# define bits_peek_signed bits_peek_signed_le
|
||||
# define bits_peek_signed_nz bits_peek_signed_nz_le
|
||||
# define bits_skip bits_skip_le
|
||||
# define bits_seek bits_seek_le
|
||||
# define bits_align bits_align_le
|
||||
# define bits_read_xbits bits_read_xbits_le
|
||||
# define bits_decode012 bits_decode012_le
|
||||
# define bits_decode210 bits_decode210_le
|
||||
# define bits_apply_sign bits_apply_sign_le
|
||||
# define bits_read_vlc bits_read_vlc_le
|
||||
# define bits_read_vlc_multi bits_read_vlc_multi_le
|
||||
|
||||
#elif defined(BITS_DEFAULT_BE)
|
||||
|
||||
# define BitstreamContext BitstreamContextBE
|
||||
# define bits_init bits_init_be
|
||||
# define bits_init8 bits_init8_be
|
||||
# define bits_tell bits_tell_be
|
||||
# define bits_size bits_size_be
|
||||
# define bits_left bits_left_be
|
||||
# define bits_read_bit bits_read_bit_be
|
||||
# define bits_read_nz bits_read_nz_be
|
||||
# define bits_read bits_read_be
|
||||
# define bits_read_63 bits_read_63_be
|
||||
# define bits_read_64 bits_read_64_be
|
||||
# define bits_read_signed bits_read_signed_be
|
||||
# define bits_read_signed_nz bits_read_signed_nz_be
|
||||
# define bits_peek_nz bits_peek_nz_be
|
||||
# define bits_peek bits_peek_be
|
||||
# define bits_peek_signed bits_peek_signed_be
|
||||
# define bits_peek_signed_nz bits_peek_signed_nz_be
|
||||
# define bits_skip bits_skip_be
|
||||
# define bits_seek bits_seek_be
|
||||
# define bits_align bits_align_be
|
||||
# define bits_read_xbits bits_read_xbits_be
|
||||
# define bits_decode012 bits_decode012_be
|
||||
# define bits_decode210 bits_decode210_be
|
||||
# define bits_apply_sign bits_apply_sign_be
|
||||
# define bits_read_vlc bits_read_vlc_be
|
||||
# define bits_read_vlc_multi bits_read_vlc_multi_be
|
||||
|
||||
#endif
|
||||
|
||||
#undef BITS_DEFAULT_LE
|
||||
#undef BITS_DEFAULT_BE
|
||||
|
||||
#define BITS_RL_VLC(level, run, bc, table, bits, max_depth) \
|
||||
do { \
|
||||
int n, nb_bits; \
|
||||
unsigned int index = bits_peek(bc, bits); \
|
||||
level = table[index].level; \
|
||||
n = table[index].len; \
|
||||
\
|
||||
if (max_depth > 1 && n < 0) { \
|
||||
bits_skip(bc, bits); \
|
||||
\
|
||||
nb_bits = -n; \
|
||||
\
|
||||
index = bits_peek(bc, nb_bits) + level; \
|
||||
level = table[index].level; \
|
||||
n = table[index].len; \
|
||||
if (max_depth > 2 && n < 0) { \
|
||||
bits_skip(bc, nb_bits); \
|
||||
nb_bits = -n; \
|
||||
\
|
||||
index = bits_peek(bc, nb_bits) + level; \
|
||||
level = table[index].level; \
|
||||
n = table[index].len; \
|
||||
} \
|
||||
} \
|
||||
run = table[index].run; \
|
||||
bits_skip(bc, n); \
|
||||
} while (0)
|
||||
|
||||
#endif /* AVCODEC_BITSTREAM_H */
|
||||
|
||||
// the following is deliberately outside of the standard #include guards
|
||||
|
||||
#if defined(BITSTREAM_LE) && !defined(BITSTREAM_WANT_LE)
|
||||
# define BITSTREAM_WANT_LE
|
||||
#endif
|
||||
|
||||
#if defined(BITSTREAM_BE) && !defined(BITSTREAM_WANT_BE)
|
||||
# define BITSTREAM_WANT_BE
|
||||
#endif
|
||||
|
||||
#if defined(BITSTREAM_WANT_LE) && !defined(AVCODEC_BITSTREAM_LE)
|
||||
#define AVCODEC_BITSTREAM_LE
|
||||
|
||||
#define BITSTREAM_TEMPLATE_LE
|
||||
#include "bitstream_template.h"
|
||||
#undef BITSTREAM_TEMPLATE_LE
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(BITSTREAM_WANT_BE) && !defined(AVCODEC_BITSTREAM_BE)
|
||||
#define AVCODEC_BITSTREAM_BE
|
||||
|
||||
#include "bitstream_template.h"
|
||||
|
||||
#endif
|
||||
|
||||
#undef BITSTREAM_WANT_LE
|
||||
#undef BITSTREAM_WANT_BE
|
||||
574
include/libavcodec/bitstream_template.h
Normal file
574
include/libavcodec/bitstream_template.h
Normal file
@@ -0,0 +1,574 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Alexandra Hájková
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifdef BITSTREAM_TEMPLATE_LE
|
||||
# define BS_SUFFIX_LOWER _le
|
||||
# define BS_SUFFIX_UPPER LE
|
||||
#else
|
||||
# define BS_SUFFIX_LOWER _be
|
||||
# define BS_SUFFIX_UPPER BE
|
||||
#endif
|
||||
|
||||
#define BS_JOIN(x, y, z) x ## y ## z
|
||||
#define BS_JOIN3(x, y, z) BS_JOIN(x, y, z)
|
||||
#define BS_FUNC(x) BS_JOIN3(bits_, x, BS_SUFFIX_LOWER)
|
||||
|
||||
#define BSCTX BS_JOIN3(Bitstream, Context, BS_SUFFIX_UPPER)
|
||||
|
||||
typedef struct BSCTX {
|
||||
uint64_t bits; // stores bits read from the buffer
|
||||
const uint8_t *buffer, *buffer_end;
|
||||
const uint8_t *ptr; // pointer to the position inside a buffer
|
||||
unsigned bits_valid; // number of bits left in bits field
|
||||
unsigned size_in_bits;
|
||||
} BSCTX;
|
||||
|
||||
/**
|
||||
* @return
|
||||
* - 0 on successful refill
|
||||
* - a negative number when bitstream end is hit
|
||||
*
|
||||
* Always succeeds when UNCHECKED_BITSTREAM_READER is enabled.
|
||||
*/
|
||||
static inline int BS_FUNC(priv_refill_64)(BSCTX *bc)
|
||||
{
|
||||
#if !UNCHECKED_BITSTREAM_READER
|
||||
if (bc->ptr >= bc->buffer_end)
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
#ifdef BITSTREAM_TEMPLATE_LE
|
||||
bc->bits = AV_RL64(bc->ptr);
|
||||
#else
|
||||
bc->bits = AV_RB64(bc->ptr);
|
||||
#endif
|
||||
bc->ptr += 8;
|
||||
bc->bits_valid = 64;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* - 0 on successful refill
|
||||
* - a negative number when bitstream end is hit
|
||||
*
|
||||
* Always succeeds when UNCHECKED_BITSTREAM_READER is enabled.
|
||||
*/
|
||||
static inline int BS_FUNC(priv_refill_32)(BSCTX *bc)
|
||||
{
|
||||
#if !UNCHECKED_BITSTREAM_READER
|
||||
if (bc->ptr >= bc->buffer_end)
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
#ifdef BITSTREAM_TEMPLATE_LE
|
||||
bc->bits |= (uint64_t)AV_RL32(bc->ptr) << bc->bits_valid;
|
||||
#else
|
||||
bc->bits |= (uint64_t)AV_RB32(bc->ptr) << (32 - bc->bits_valid);
|
||||
#endif
|
||||
bc->ptr += 4;
|
||||
bc->bits_valid += 32;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize BitstreamContext.
|
||||
* @param buffer bitstream buffer, must be AV_INPUT_BUFFER_PADDING_SIZE bytes
|
||||
* larger than the actual read bits because some optimized bitstream
|
||||
* readers read 32 or 64 bits at once and could read over the end
|
||||
* @param bit_size the size of the buffer in bits
|
||||
* @return 0 on success, AVERROR_INVALIDDATA if the buffer_size would overflow.
|
||||
*/
|
||||
static inline int BS_FUNC(init)(BSCTX *bc, const uint8_t *buffer,
|
||||
unsigned int bit_size)
|
||||
{
|
||||
unsigned int buffer_size;
|
||||
|
||||
if (bit_size > INT_MAX - 7 || !buffer) {
|
||||
bc->buffer = NULL;
|
||||
bc->ptr = NULL;
|
||||
bc->bits_valid = 0;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
buffer_size = (bit_size + 7) >> 3;
|
||||
|
||||
bc->buffer = buffer;
|
||||
bc->buffer_end = buffer + buffer_size;
|
||||
bc->ptr = bc->buffer;
|
||||
bc->size_in_bits = bit_size;
|
||||
bc->bits_valid = 0;
|
||||
bc->bits = 0;
|
||||
|
||||
BS_FUNC(priv_refill_64)(bc);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize BitstreamContext.
|
||||
* @param buffer bitstream buffer, must be AV_INPUT_BUFFER_PADDING_SIZE bytes
|
||||
* larger than the actual read bits because some optimized bitstream
|
||||
* readers read 32 or 64 bits at once and could read over the end
|
||||
* @param byte_size the size of the buffer in bytes
|
||||
* @return 0 on success, AVERROR_INVALIDDATA if the buffer_size would overflow
|
||||
*/
|
||||
static inline int BS_FUNC(init8)(BSCTX *bc, const uint8_t *buffer,
|
||||
unsigned int byte_size)
|
||||
{
|
||||
if (byte_size > INT_MAX / 8)
|
||||
return AVERROR_INVALIDDATA;
|
||||
return BS_FUNC(init)(bc, buffer, byte_size * 8);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return number of bits already read.
|
||||
*/
|
||||
static inline int BS_FUNC(tell)(const BSCTX *bc)
|
||||
{
|
||||
return (bc->ptr - bc->buffer) * 8 - bc->bits_valid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return buffer size in bits.
|
||||
*/
|
||||
static inline int BS_FUNC(size)(const BSCTX *bc)
|
||||
{
|
||||
return bc->size_in_bits;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of the bits left in a buffer.
|
||||
*/
|
||||
static inline int BS_FUNC(left)(const BSCTX *bc)
|
||||
{
|
||||
return (bc->buffer - bc->ptr) * 8 + bc->size_in_bits + bc->bits_valid;
|
||||
}
|
||||
|
||||
static inline uint64_t BS_FUNC(priv_val_show)(BSCTX *bc, unsigned int n)
|
||||
{
|
||||
av_assert2(n > 0 && n <= 64);
|
||||
|
||||
#ifdef BITSTREAM_TEMPLATE_LE
|
||||
return bc->bits & (UINT64_MAX >> (64 - n));
|
||||
#else
|
||||
return bc->bits >> (64 - n);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void BS_FUNC(priv_skip_remaining)(BSCTX *bc, unsigned int n)
|
||||
{
|
||||
#ifdef BITSTREAM_TEMPLATE_LE
|
||||
bc->bits >>= n;
|
||||
#else
|
||||
bc->bits <<= n;
|
||||
#endif
|
||||
bc->bits_valid -= n;
|
||||
}
|
||||
|
||||
static inline uint64_t BS_FUNC(priv_val_get)(BSCTX *bc, unsigned int n)
|
||||
{
|
||||
uint64_t ret;
|
||||
|
||||
av_assert2(n > 0 && n < 64);
|
||||
|
||||
ret = BS_FUNC(priv_val_show)(bc, n);
|
||||
BS_FUNC(priv_skip_remaining)(bc, n);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return one bit from the buffer.
|
||||
*/
|
||||
static inline unsigned int BS_FUNC(read_bit)(BSCTX *bc)
|
||||
{
|
||||
if (!bc->bits_valid && BS_FUNC(priv_refill_64)(bc) < 0)
|
||||
return 0;
|
||||
|
||||
return BS_FUNC(priv_val_get)(bc, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return n bits from the buffer, n has to be in the 1-32 range.
|
||||
* May be faster than bits_read() when n is not a compile-time constant and is
|
||||
* known to be non-zero;
|
||||
*/
|
||||
static inline uint32_t BS_FUNC(read_nz)(BSCTX *bc, unsigned int n)
|
||||
{
|
||||
av_assert2(n > 0 && n <= 32);
|
||||
|
||||
if (n > bc->bits_valid) {
|
||||
if (BS_FUNC(priv_refill_32)(bc) < 0)
|
||||
bc->bits_valid = n;
|
||||
}
|
||||
|
||||
return BS_FUNC(priv_val_get)(bc, n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return n bits from the buffer, n has to be in the 0-32 range.
|
||||
*/
|
||||
static inline uint32_t BS_FUNC(read)(BSCTX *bc, unsigned int n)
|
||||
{
|
||||
av_assert2(n <= 32);
|
||||
|
||||
if (!n)
|
||||
return 0;
|
||||
|
||||
return BS_FUNC(read_nz)(bc, n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return n bits from the buffer, n has to be in the 0-63 range.
|
||||
*/
|
||||
static inline uint64_t BS_FUNC(read_63)(BSCTX *bc, unsigned int n)
|
||||
{
|
||||
uint64_t ret = 0;
|
||||
unsigned left = 0;
|
||||
|
||||
av_assert2(n <= 63);
|
||||
|
||||
if (!n)
|
||||
return 0;
|
||||
|
||||
if (n > bc->bits_valid) {
|
||||
left = bc->bits_valid;
|
||||
n -= left;
|
||||
|
||||
if (left)
|
||||
ret = BS_FUNC(priv_val_get)(bc, left);
|
||||
|
||||
if (BS_FUNC(priv_refill_64)(bc) < 0)
|
||||
bc->bits_valid = n;
|
||||
|
||||
}
|
||||
|
||||
#ifdef BITSTREAM_TEMPLATE_LE
|
||||
ret = BS_FUNC(priv_val_get)(bc, n) << left | ret;
|
||||
#else
|
||||
ret = BS_FUNC(priv_val_get)(bc, n) | ret << n;
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return n bits from the buffer, n has to be in the 0-64 range.
|
||||
*/
|
||||
static inline uint64_t BS_FUNC(read_64)(BSCTX *bc, unsigned int n)
|
||||
{
|
||||
av_assert2(n <= 64);
|
||||
|
||||
if (n == 64) {
|
||||
uint64_t ret = BS_FUNC(read_63)(bc, 63);
|
||||
#ifdef BITSTREAM_TEMPLATE_LE
|
||||
return ret | ((uint64_t)BS_FUNC(read_bit)(bc) << 63);
|
||||
#else
|
||||
return (ret << 1) | (uint64_t)BS_FUNC(read_bit)(bc);
|
||||
#endif
|
||||
}
|
||||
return BS_FUNC(read_63)(bc, n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return n bits from the buffer as a signed integer, n has to be in the 1-32
|
||||
* range. May be faster than bits_read_signed() when n is not a compile-time
|
||||
* constant and is known to be non-zero;
|
||||
*/
|
||||
static inline int32_t BS_FUNC(read_signed_nz)(BSCTX *bc, unsigned int n)
|
||||
{
|
||||
av_assert2(n > 0 && n <= 32);
|
||||
return sign_extend(BS_FUNC(read_nz)(bc, n), n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return n bits from the buffer as a signed integer.
|
||||
* n has to be in the 0-32 range.
|
||||
*/
|
||||
static inline int32_t BS_FUNC(read_signed)(BSCTX *bc, unsigned int n)
|
||||
{
|
||||
av_assert2(n <= 32);
|
||||
|
||||
if (!n)
|
||||
return 0;
|
||||
|
||||
return BS_FUNC(read_signed_nz)(bc, n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return n bits from the buffer but do not change the buffer state.
|
||||
* n has to be in the 1-32 range. May
|
||||
*/
|
||||
static inline uint32_t BS_FUNC(peek_nz)(BSCTX *bc, unsigned int n)
|
||||
{
|
||||
av_assert2(n > 0 && n <= 32);
|
||||
|
||||
if (n > bc->bits_valid)
|
||||
BS_FUNC(priv_refill_32)(bc);
|
||||
|
||||
return BS_FUNC(priv_val_show)(bc, n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return n bits from the buffer but do not change the buffer state.
|
||||
* n has to be in the 0-32 range.
|
||||
*/
|
||||
static inline uint32_t BS_FUNC(peek)(BSCTX *bc, unsigned int n)
|
||||
{
|
||||
av_assert2(n <= 32);
|
||||
|
||||
if (!n)
|
||||
return 0;
|
||||
|
||||
return BS_FUNC(peek_nz)(bc, n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return n bits from the buffer as a signed integer, do not change the buffer
|
||||
* state. n has to be in the 1-32 range. May be faster than bits_peek_signed()
|
||||
* when n is not a compile-time constant and is known to be non-zero;
|
||||
*/
|
||||
static inline int BS_FUNC(peek_signed_nz)(BSCTX *bc, unsigned int n)
|
||||
{
|
||||
av_assert2(n > 0 && n <= 32);
|
||||
return sign_extend(BS_FUNC(peek_nz)(bc, n), n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return n bits from the buffer as a signed integer,
|
||||
* do not change the buffer state.
|
||||
* n has to be in the 0-32 range.
|
||||
*/
|
||||
static inline int BS_FUNC(peek_signed)(BSCTX *bc, unsigned int n)
|
||||
{
|
||||
av_assert2(n <= 32);
|
||||
|
||||
if (!n)
|
||||
return 0;
|
||||
|
||||
return BS_FUNC(peek_signed_nz)(bc, n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Skip n bits in the buffer.
|
||||
*/
|
||||
static inline void BS_FUNC(skip)(BSCTX *bc, unsigned int n)
|
||||
{
|
||||
if (n < bc->bits_valid)
|
||||
BS_FUNC(priv_skip_remaining)(bc, n);
|
||||
else {
|
||||
n -= bc->bits_valid;
|
||||
bc->bits = 0;
|
||||
bc->bits_valid = 0;
|
||||
|
||||
if (n >= 64) {
|
||||
unsigned int skip = n / 8;
|
||||
|
||||
n -= skip * 8;
|
||||
bc->ptr += skip;
|
||||
}
|
||||
BS_FUNC(priv_refill_64)(bc);
|
||||
if (n)
|
||||
BS_FUNC(priv_skip_remaining)(bc, n);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Seek to the given bit position.
|
||||
*/
|
||||
static inline void BS_FUNC(seek)(BSCTX *bc, unsigned pos)
|
||||
{
|
||||
bc->ptr = bc->buffer;
|
||||
bc->bits = 0;
|
||||
bc->bits_valid = 0;
|
||||
|
||||
BS_FUNC(skip)(bc, pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Skip bits to a byte boundary.
|
||||
*/
|
||||
static inline const uint8_t *BS_FUNC(align)(BSCTX *bc)
|
||||
{
|
||||
unsigned int n = -BS_FUNC(tell)(bc) & 7;
|
||||
if (n)
|
||||
BS_FUNC(skip)(bc, n);
|
||||
return bc->buffer + (BS_FUNC(tell)(bc) >> 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read MPEG-1 dc-style VLC (sign bit + mantissa with no MSB).
|
||||
* If MSB not set it is negative.
|
||||
* @param n length in bits
|
||||
*/
|
||||
static inline int BS_FUNC(read_xbits)(BSCTX *bc, unsigned int n)
|
||||
{
|
||||
int32_t cache = BS_FUNC(peek)(bc, 32);
|
||||
int sign = ~cache >> 31;
|
||||
BS_FUNC(priv_skip_remaining)(bc, n);
|
||||
|
||||
return ((((uint32_t)(sign ^ cache)) >> (32 - n)) ^ sign) - sign;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return decoded truncated unary code for the values 0, 1, 2.
|
||||
*/
|
||||
static inline int BS_FUNC(decode012)(BSCTX *bc)
|
||||
{
|
||||
if (!BS_FUNC(read_bit)(bc))
|
||||
return 0;
|
||||
else
|
||||
return BS_FUNC(read_bit)(bc) + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return decoded truncated unary code for the values 2, 1, 0.
|
||||
*/
|
||||
static inline int BS_FUNC(decode210)(BSCTX *bc)
|
||||
{
|
||||
if (BS_FUNC(read_bit)(bc))
|
||||
return 0;
|
||||
else
|
||||
return 2 - BS_FUNC(read_bit)(bc);
|
||||
}
|
||||
|
||||
/* Read sign bit and flip the sign of the provided value accordingly. */
|
||||
static inline int BS_FUNC(apply_sign)(BSCTX *bc, int val)
|
||||
{
|
||||
int sign = BS_FUNC(read_signed)(bc, 1);
|
||||
return (val ^ sign) - sign;
|
||||
}
|
||||
|
||||
static inline int BS_FUNC(skip_1stop_8data)(BSCTX *s)
|
||||
{
|
||||
if (BS_FUNC(left)(s) <= 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
while (BS_FUNC(read_bit)(s)) {
|
||||
BS_FUNC(skip)(s, 8);
|
||||
if (BS_FUNC(left)(s) <= 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the LUT element for the given bitstream configuration.
|
||||
*/
|
||||
static inline int BS_FUNC(priv_set_idx)(BSCTX *bc, int code, int *n,
|
||||
int *nb_bits, const VLCElem *table)
|
||||
{
|
||||
unsigned idx;
|
||||
|
||||
*nb_bits = -*n;
|
||||
idx = BS_FUNC(peek)(bc, *nb_bits) + code;
|
||||
*n = table[idx].len;
|
||||
|
||||
return table[idx].sym;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a vlc code.
|
||||
* @param bits is the number of bits which will be read at once, must be
|
||||
* identical to nb_bits in vlc_init()
|
||||
* @param max_depth is the number of times bits bits must be read to completely
|
||||
* read the longest vlc code
|
||||
* = (max_vlc_length + bits - 1) / bits
|
||||
* If the vlc code is invalid and max_depth=1, then no bits will be removed.
|
||||
* If the vlc code is invalid and max_depth>1, then the number of bits removed
|
||||
* is undefined.
|
||||
*/
|
||||
static inline int BS_FUNC(read_vlc)(BSCTX *bc, const VLCElem *table,
|
||||
int bits, int max_depth)
|
||||
{
|
||||
int nb_bits;
|
||||
unsigned idx = BS_FUNC(peek)(bc, bits);
|
||||
int code = table[idx].sym;
|
||||
int n = table[idx].len;
|
||||
|
||||
if (max_depth > 1 && n < 0) {
|
||||
BS_FUNC(priv_skip_remaining)(bc, bits);
|
||||
code = BS_FUNC(priv_set_idx)(bc, code, &n, &nb_bits, table);
|
||||
if (max_depth > 2 && n < 0) {
|
||||
BS_FUNC(priv_skip_remaining)(bc, nb_bits);
|
||||
code = BS_FUNC(priv_set_idx)(bc, code, &n, &nb_bits, table);
|
||||
}
|
||||
}
|
||||
BS_FUNC(priv_skip_remaining)(bc, n);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a vlc / vlc_multi code.
|
||||
* @param bits is the number of bits which will be read at once, must be
|
||||
* identical to nb_bits in vlc_init()
|
||||
* @param max_depth is the number of times bits bits must be read to completely
|
||||
* read the longest vlc code
|
||||
* = (max_vlc_length + bits - 1) / bits
|
||||
* @param dst the parsed symbol(s) will be stored here. Up to 8 bytes are written
|
||||
* @returns number of symbols parsed
|
||||
* If the vlc code is invalid and max_depth=1, then no bits will be removed.
|
||||
* If the vlc code is invalid and max_depth>1, then the number of bits removed
|
||||
* is undefined.
|
||||
*/
|
||||
static inline int BS_FUNC(read_vlc_multi)(BSCTX *bc, uint8_t dst[8],
|
||||
const VLC_MULTI_ELEM *const Jtable,
|
||||
const VLCElem *const table,
|
||||
const int bits, const int max_depth,
|
||||
const int symbols_size)
|
||||
{
|
||||
unsigned idx = BS_FUNC(peek)(bc, bits);
|
||||
int ret, nb_bits, code, n = Jtable[idx].len;
|
||||
if (Jtable[idx].num) {
|
||||
AV_COPY64U(dst, Jtable[idx].val8);
|
||||
ret = Jtable[idx].num;
|
||||
} else {
|
||||
code = table[idx].sym;
|
||||
n = table[idx].len;
|
||||
if (max_depth > 1 && n < 0) {
|
||||
BS_FUNC(priv_skip_remaining)(bc, bits);
|
||||
code = BS_FUNC(priv_set_idx)(bc, code, &n, &nb_bits, table);
|
||||
if (max_depth > 2 && n < 0) {
|
||||
BS_FUNC(priv_skip_remaining)(bc, nb_bits);
|
||||
code = BS_FUNC(priv_set_idx)(bc, code, &n, &nb_bits, table);
|
||||
}
|
||||
}
|
||||
if (symbols_size == 1)
|
||||
*dst = code;
|
||||
else
|
||||
AV_WN16(dst, code);
|
||||
ret = n > 0;
|
||||
}
|
||||
BS_FUNC(priv_skip_remaining)(bc, n);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef BSCTX
|
||||
#undef BS_FUNC
|
||||
#undef BS_JOIN3
|
||||
#undef BS_JOIN
|
||||
#undef BS_SUFFIX_UPPER
|
||||
#undef BS_SUFFIX_LOWER
|
||||
48
include/libavcodec/blockdsp.h
Normal file
48
include/libavcodec/blockdsp.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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_BLOCKDSP_H
|
||||
#define AVCODEC_BLOCKDSP_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/* add and put pixel (decoding)
|
||||
* Block sizes for op_pixels_func are 8x4,8x8 16x8 16x16.
|
||||
* h for op_pixels_func is limited to { width / 2, width },
|
||||
* but never larger than 16 and never smaller than 4. */
|
||||
typedef void (*op_fill_func)(uint8_t *block /* align width (8 or 16) */,
|
||||
uint8_t value, ptrdiff_t line_size, int h);
|
||||
|
||||
typedef struct BlockDSPContext {
|
||||
void (*clear_block)(int16_t *block /* align 32 */);
|
||||
void (*clear_blocks)(int16_t *blocks /* align 32 */);
|
||||
|
||||
op_fill_func fill_block_tab[2];
|
||||
} BlockDSPContext;
|
||||
|
||||
void ff_blockdsp_init(BlockDSPContext *c);
|
||||
|
||||
void ff_blockdsp_init_alpha(BlockDSPContext *c);
|
||||
void ff_blockdsp_init_arm(BlockDSPContext *c);
|
||||
void ff_blockdsp_init_ppc(BlockDSPContext *c);
|
||||
void ff_blockdsp_init_riscv(BlockDSPContext *c);
|
||||
void ff_blockdsp_init_x86(BlockDSPContext *c);
|
||||
void ff_blockdsp_init_mips(BlockDSPContext *c);
|
||||
|
||||
#endif /* AVCODEC_BLOCKDSP_H */
|
||||
32
include/libavcodec/bmp.h
Normal file
32
include/libavcodec/bmp.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* internals for BMP codecs
|
||||
* Copyright (c) 2005 Mans Rullgard
|
||||
*
|
||||
* 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_BMP_H
|
||||
#define AVCODEC_BMP_H
|
||||
|
||||
typedef enum {
|
||||
BMP_RGB =0,
|
||||
BMP_RLE8 =1,
|
||||
BMP_RLE4 =2,
|
||||
BMP_BITFIELDS =3,
|
||||
} BiCompression;
|
||||
|
||||
#endif /* AVCODEC_BMP_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.
|
||||
|
||||
60
include/libavcodec/bsf_internal.h
Normal file
60
include/libavcodec/bsf_internal.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_BSF_INTERNAL_H
|
||||
#define AVCODEC_BSF_INTERNAL_H
|
||||
|
||||
#include "libavutil/log.h"
|
||||
|
||||
#include "bsf.h"
|
||||
#include "packet.h"
|
||||
|
||||
typedef struct FFBitStreamFilter {
|
||||
/**
|
||||
* The public AVBitStreamFilter. See bsf.h for it.
|
||||
*/
|
||||
AVBitStreamFilter p;
|
||||
|
||||
int priv_data_size;
|
||||
int (*init)(AVBSFContext *ctx);
|
||||
int (*filter)(AVBSFContext *ctx, AVPacket *pkt);
|
||||
void (*close)(AVBSFContext *ctx);
|
||||
void (*flush)(AVBSFContext *ctx);
|
||||
} FFBitStreamFilter;
|
||||
|
||||
/**
|
||||
* Called by the bitstream filters to get the next packet for filtering.
|
||||
* The filter is responsible for either freeing the packet or passing it to the
|
||||
* caller.
|
||||
*/
|
||||
int ff_bsf_get_packet(AVBSFContext *ctx, AVPacket **pkt);
|
||||
|
||||
/**
|
||||
* Called by bitstream filters to get packet for filtering.
|
||||
* The reference to packet is moved to provided packet structure.
|
||||
*
|
||||
* @param ctx pointer to AVBSFContext of filter
|
||||
* @param pkt pointer to packet to move reference to
|
||||
*
|
||||
* @return 0 on success, negative AVERROR in case of failure
|
||||
*/
|
||||
int ff_bsf_get_packet_ref(AVBSFContext *ctx, AVPacket *pkt);
|
||||
|
||||
const AVClass *ff_bsf_child_class_iterate(void **opaque);
|
||||
|
||||
#endif /* AVCODEC_BSF_INTERNAL_H */
|
||||
33
include/libavcodec/bswapdsp.h
Normal file
33
include/libavcodec/bswapdsp.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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_BSWAPDSP_H
|
||||
#define AVCODEC_BSWAPDSP_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct BswapDSPContext {
|
||||
void (*bswap_buf)(uint32_t *dst, const uint32_t *src, int w);
|
||||
void (*bswap16_buf)(uint16_t *dst, const uint16_t *src, int len);
|
||||
} BswapDSPContext;
|
||||
|
||||
void ff_bswapdsp_init(BswapDSPContext *c);
|
||||
void ff_bswapdsp_init_riscv(BswapDSPContext *c);
|
||||
void ff_bswapdsp_init_x86(BswapDSPContext *c);
|
||||
|
||||
#endif /* AVCODEC_BSWAPDSP_H */
|
||||
380
include/libavcodec/bytestream.h
Normal file
380
include/libavcodec/bytestream.h
Normal file
@@ -0,0 +1,380 @@
|
||||
/*
|
||||
* Bytestream functions
|
||||
* copyright (c) 2006 Baptiste Coudurier <baptiste.coudurier@free.fr>
|
||||
* Copyright (c) 2012 Aneesh Dogra (lionaneesh) <lionaneesh@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 AVCODEC_BYTESTREAM_H
|
||||
#define AVCODEC_BYTESTREAM_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "libavutil/avassert.h"
|
||||
#include "libavutil/common.h"
|
||||
#include "libavutil/intreadwrite.h"
|
||||
|
||||
typedef struct GetByteContext {
|
||||
const uint8_t *buffer, *buffer_end, *buffer_start;
|
||||
} GetByteContext;
|
||||
|
||||
typedef struct PutByteContext {
|
||||
uint8_t *buffer, *buffer_end, *buffer_start;
|
||||
int eof;
|
||||
} PutByteContext;
|
||||
|
||||
#define DEF(type, name, bytes, read, write) \
|
||||
static av_always_inline type bytestream_get_ ## name(const uint8_t **b) \
|
||||
{ \
|
||||
(*b) += bytes; \
|
||||
return read(*b - bytes); \
|
||||
} \
|
||||
static av_always_inline void bytestream_put_ ## name(uint8_t **b, \
|
||||
const type value) \
|
||||
{ \
|
||||
write(*b, value); \
|
||||
(*b) += bytes; \
|
||||
} \
|
||||
static av_always_inline void bytestream2_put_ ## name ## u(PutByteContext *p, \
|
||||
const type value) \
|
||||
{ \
|
||||
bytestream_put_ ## name(&p->buffer, value); \
|
||||
} \
|
||||
static av_always_inline void bytestream2_put_ ## name(PutByteContext *p, \
|
||||
const type value) \
|
||||
{ \
|
||||
if (!p->eof && (p->buffer_end - p->buffer >= bytes)) { \
|
||||
write(p->buffer, value); \
|
||||
p->buffer += bytes; \
|
||||
} else \
|
||||
p->eof = 1; \
|
||||
} \
|
||||
static av_always_inline type bytestream2_get_ ## name ## u(GetByteContext *g) \
|
||||
{ \
|
||||
return bytestream_get_ ## name(&g->buffer); \
|
||||
} \
|
||||
static av_always_inline type bytestream2_get_ ## name(GetByteContext *g) \
|
||||
{ \
|
||||
if (g->buffer_end - g->buffer < bytes) { \
|
||||
g->buffer = g->buffer_end; \
|
||||
return 0; \
|
||||
} \
|
||||
return bytestream2_get_ ## name ## u(g); \
|
||||
} \
|
||||
static av_always_inline type bytestream2_peek_ ## name ## u(GetByteContext *g) \
|
||||
{ \
|
||||
return read(g->buffer); \
|
||||
} \
|
||||
static av_always_inline type bytestream2_peek_ ## name(GetByteContext *g) \
|
||||
{ \
|
||||
if (g->buffer_end - g->buffer < bytes) \
|
||||
return 0; \
|
||||
return bytestream2_peek_ ## name ## u(g); \
|
||||
}
|
||||
|
||||
DEF(uint64_t, le64, 8, AV_RL64, AV_WL64)
|
||||
DEF(unsigned int, le32, 4, AV_RL32, AV_WL32)
|
||||
DEF(unsigned int, le24, 3, AV_RL24, AV_WL24)
|
||||
DEF(unsigned int, le16, 2, AV_RL16, AV_WL16)
|
||||
DEF(uint64_t, be64, 8, AV_RB64, AV_WB64)
|
||||
DEF(unsigned int, be32, 4, AV_RB32, AV_WB32)
|
||||
DEF(unsigned int, be24, 3, AV_RB24, AV_WB24)
|
||||
DEF(unsigned int, be16, 2, AV_RB16, AV_WB16)
|
||||
DEF(unsigned int, byte, 1, AV_RB8 , AV_WB8)
|
||||
|
||||
#if AV_HAVE_BIGENDIAN
|
||||
# define bytestream2_get_ne16 bytestream2_get_be16
|
||||
# define bytestream2_get_ne24 bytestream2_get_be24
|
||||
# define bytestream2_get_ne32 bytestream2_get_be32
|
||||
# define bytestream2_get_ne64 bytestream2_get_be64
|
||||
# define bytestream2_get_ne16u bytestream2_get_be16u
|
||||
# define bytestream2_get_ne24u bytestream2_get_be24u
|
||||
# define bytestream2_get_ne32u bytestream2_get_be32u
|
||||
# define bytestream2_get_ne64u bytestream2_get_be64u
|
||||
# define bytestream2_put_ne16 bytestream2_put_be16
|
||||
# define bytestream2_put_ne24 bytestream2_put_be24
|
||||
# define bytestream2_put_ne32 bytestream2_put_be32
|
||||
# define bytestream2_put_ne64 bytestream2_put_be64
|
||||
# define bytestream2_peek_ne16 bytestream2_peek_be16
|
||||
# define bytestream2_peek_ne24 bytestream2_peek_be24
|
||||
# define bytestream2_peek_ne32 bytestream2_peek_be32
|
||||
# define bytestream2_peek_ne64 bytestream2_peek_be64
|
||||
#else
|
||||
# define bytestream2_get_ne16 bytestream2_get_le16
|
||||
# define bytestream2_get_ne24 bytestream2_get_le24
|
||||
# define bytestream2_get_ne32 bytestream2_get_le32
|
||||
# define bytestream2_get_ne64 bytestream2_get_le64
|
||||
# define bytestream2_get_ne16u bytestream2_get_le16u
|
||||
# define bytestream2_get_ne24u bytestream2_get_le24u
|
||||
# define bytestream2_get_ne32u bytestream2_get_le32u
|
||||
# define bytestream2_get_ne64u bytestream2_get_le64u
|
||||
# define bytestream2_put_ne16 bytestream2_put_le16
|
||||
# define bytestream2_put_ne24 bytestream2_put_le24
|
||||
# define bytestream2_put_ne32 bytestream2_put_le32
|
||||
# define bytestream2_put_ne64 bytestream2_put_le64
|
||||
# define bytestream2_peek_ne16 bytestream2_peek_le16
|
||||
# define bytestream2_peek_ne24 bytestream2_peek_le24
|
||||
# define bytestream2_peek_ne32 bytestream2_peek_le32
|
||||
# define bytestream2_peek_ne64 bytestream2_peek_le64
|
||||
#endif
|
||||
|
||||
static av_always_inline void bytestream2_init(GetByteContext *g,
|
||||
const uint8_t *buf,
|
||||
int buf_size)
|
||||
{
|
||||
av_assert0(buf_size >= 0);
|
||||
g->buffer = buf;
|
||||
g->buffer_start = buf;
|
||||
g->buffer_end = buf + buf_size;
|
||||
}
|
||||
|
||||
static av_always_inline void bytestream2_init_writer(PutByteContext *p,
|
||||
uint8_t *buf,
|
||||
int buf_size)
|
||||
{
|
||||
av_assert0(buf_size >= 0);
|
||||
p->buffer = buf;
|
||||
p->buffer_start = buf;
|
||||
p->buffer_end = buf + buf_size;
|
||||
p->eof = 0;
|
||||
}
|
||||
|
||||
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
|
||||
{
|
||||
return g->buffer_end - g->buffer;
|
||||
}
|
||||
|
||||
static av_always_inline int bytestream2_get_bytes_left_p(PutByteContext *p)
|
||||
{
|
||||
return p->buffer_end - p->buffer;
|
||||
}
|
||||
|
||||
static av_always_inline void bytestream2_skip(GetByteContext *g,
|
||||
unsigned int size)
|
||||
{
|
||||
g->buffer += FFMIN(g->buffer_end - g->buffer, size);
|
||||
}
|
||||
|
||||
static av_always_inline void bytestream2_skipu(GetByteContext *g,
|
||||
unsigned int size)
|
||||
{
|
||||
g->buffer += size;
|
||||
}
|
||||
|
||||
static av_always_inline void bytestream2_skip_p(PutByteContext *p,
|
||||
unsigned int size)
|
||||
{
|
||||
unsigned int size2;
|
||||
if (p->eof)
|
||||
return;
|
||||
size2 = FFMIN(p->buffer_end - p->buffer, size);
|
||||
if (size2 != size)
|
||||
p->eof = 1;
|
||||
p->buffer += size2;
|
||||
}
|
||||
|
||||
static av_always_inline int bytestream2_tell(GetByteContext *g)
|
||||
{
|
||||
return (int)(g->buffer - g->buffer_start);
|
||||
}
|
||||
|
||||
static av_always_inline int bytestream2_tell_p(PutByteContext *p)
|
||||
{
|
||||
return (int)(p->buffer - p->buffer_start);
|
||||
}
|
||||
|
||||
static av_always_inline int bytestream2_size(GetByteContext *g)
|
||||
{
|
||||
return (int)(g->buffer_end - g->buffer_start);
|
||||
}
|
||||
|
||||
static av_always_inline int bytestream2_size_p(PutByteContext *p)
|
||||
{
|
||||
return (int)(p->buffer_end - p->buffer_start);
|
||||
}
|
||||
|
||||
static av_always_inline int bytestream2_seek(GetByteContext *g,
|
||||
int offset,
|
||||
int whence)
|
||||
{
|
||||
switch (whence) {
|
||||
case SEEK_CUR:
|
||||
offset = av_clip(offset, -(g->buffer - g->buffer_start),
|
||||
g->buffer_end - g->buffer);
|
||||
g->buffer += offset;
|
||||
break;
|
||||
case SEEK_END:
|
||||
offset = av_clip(offset, -(g->buffer_end - g->buffer_start), 0);
|
||||
g->buffer = g->buffer_end + offset;
|
||||
break;
|
||||
case SEEK_SET:
|
||||
offset = av_clip(offset, 0, g->buffer_end - g->buffer_start);
|
||||
g->buffer = g->buffer_start + offset;
|
||||
break;
|
||||
default:
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
return bytestream2_tell(g);
|
||||
}
|
||||
|
||||
static av_always_inline int bytestream2_seek_p(PutByteContext *p,
|
||||
int offset,
|
||||
int whence)
|
||||
{
|
||||
p->eof = 0;
|
||||
switch (whence) {
|
||||
case SEEK_CUR:
|
||||
if (p->buffer_end - p->buffer < offset)
|
||||
p->eof = 1;
|
||||
offset = av_clip(offset, -(p->buffer - p->buffer_start),
|
||||
p->buffer_end - p->buffer);
|
||||
p->buffer += offset;
|
||||
break;
|
||||
case SEEK_END:
|
||||
if (offset > 0)
|
||||
p->eof = 1;
|
||||
offset = av_clip(offset, -(p->buffer_end - p->buffer_start), 0);
|
||||
p->buffer = p->buffer_end + offset;
|
||||
break;
|
||||
case SEEK_SET:
|
||||
if (p->buffer_end - p->buffer_start < offset)
|
||||
p->eof = 1;
|
||||
offset = av_clip(offset, 0, p->buffer_end - p->buffer_start);
|
||||
p->buffer = p->buffer_start + offset;
|
||||
break;
|
||||
default:
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
return bytestream2_tell_p(p);
|
||||
}
|
||||
|
||||
static av_always_inline unsigned int bytestream2_get_buffer(GetByteContext *g,
|
||||
uint8_t *dst,
|
||||
unsigned int size)
|
||||
{
|
||||
unsigned int size2 = FFMIN(g->buffer_end - g->buffer, size);
|
||||
memcpy(dst, g->buffer, size2);
|
||||
g->buffer += size2;
|
||||
return size2;
|
||||
}
|
||||
|
||||
static av_always_inline unsigned int bytestream2_get_bufferu(GetByteContext *g,
|
||||
uint8_t *dst,
|
||||
unsigned int size)
|
||||
{
|
||||
memcpy(dst, g->buffer, size);
|
||||
g->buffer += size;
|
||||
return size;
|
||||
}
|
||||
|
||||
static av_always_inline unsigned int bytestream2_put_buffer(PutByteContext *p,
|
||||
const uint8_t *src,
|
||||
unsigned int size)
|
||||
{
|
||||
unsigned int size2;
|
||||
if (p->eof)
|
||||
return 0;
|
||||
size2 = FFMIN(p->buffer_end - p->buffer, size);
|
||||
if (size2 != size)
|
||||
p->eof = 1;
|
||||
memcpy(p->buffer, src, size2);
|
||||
p->buffer += size2;
|
||||
return size2;
|
||||
}
|
||||
|
||||
static av_always_inline unsigned int bytestream2_put_bufferu(PutByteContext *p,
|
||||
const uint8_t *src,
|
||||
unsigned int size)
|
||||
{
|
||||
memcpy(p->buffer, src, size);
|
||||
p->buffer += size;
|
||||
return size;
|
||||
}
|
||||
|
||||
static av_always_inline void bytestream2_set_buffer(PutByteContext *p,
|
||||
const uint8_t c,
|
||||
unsigned int size)
|
||||
{
|
||||
unsigned int size2;
|
||||
if (p->eof)
|
||||
return;
|
||||
size2 = FFMIN(p->buffer_end - p->buffer, size);
|
||||
if (size2 != size)
|
||||
p->eof = 1;
|
||||
memset(p->buffer, c, size2);
|
||||
p->buffer += size2;
|
||||
}
|
||||
|
||||
static av_always_inline void bytestream2_set_bufferu(PutByteContext *p,
|
||||
const uint8_t c,
|
||||
unsigned int size)
|
||||
{
|
||||
memset(p->buffer, c, size);
|
||||
p->buffer += size;
|
||||
}
|
||||
|
||||
static av_always_inline unsigned int bytestream2_get_eof(PutByteContext *p)
|
||||
{
|
||||
return p->eof;
|
||||
}
|
||||
|
||||
static av_always_inline unsigned int bytestream2_copy_bufferu(PutByteContext *p,
|
||||
GetByteContext *g,
|
||||
unsigned int size)
|
||||
{
|
||||
memcpy(p->buffer, g->buffer, size);
|
||||
p->buffer += size;
|
||||
g->buffer += size;
|
||||
return size;
|
||||
}
|
||||
|
||||
static av_always_inline unsigned int bytestream2_copy_buffer(PutByteContext *p,
|
||||
GetByteContext *g,
|
||||
unsigned int size)
|
||||
{
|
||||
unsigned int size2;
|
||||
|
||||
if (p->eof)
|
||||
return 0;
|
||||
size = FFMIN(g->buffer_end - g->buffer, size);
|
||||
size2 = FFMIN(p->buffer_end - p->buffer, size);
|
||||
if (size2 != size)
|
||||
p->eof = 1;
|
||||
|
||||
return bytestream2_copy_bufferu(p, g, size2);
|
||||
}
|
||||
|
||||
static av_always_inline unsigned int bytestream_get_buffer(const uint8_t **b,
|
||||
uint8_t *dst,
|
||||
unsigned int size)
|
||||
{
|
||||
memcpy(dst, *b, size);
|
||||
(*b) += size;
|
||||
return size;
|
||||
}
|
||||
|
||||
static av_always_inline void bytestream_put_buffer(uint8_t **b,
|
||||
const uint8_t *src,
|
||||
unsigned int size)
|
||||
{
|
||||
memcpy(*b, src, size);
|
||||
(*b) += size;
|
||||
}
|
||||
|
||||
#endif /* AVCODEC_BYTESTREAM_H */
|
||||
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 */
|
||||
221
include/libavcodec/cabac_functions.h
Normal file
221
include/libavcodec/cabac_functions.h
Normal file
@@ -0,0 +1,221 @@
|
||||
/*
|
||||
* 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 inline functions
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_CABAC_FUNCTIONS_H
|
||||
#define AVCODEC_CABAC_FUNCTIONS_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libavutil/attributes.h"
|
||||
#include "libavutil/intmath.h"
|
||||
#include "cabac.h"
|
||||
#include "config.h"
|
||||
|
||||
#ifndef UNCHECKED_BITSTREAM_READER
|
||||
#define UNCHECKED_BITSTREAM_READER !CONFIG_SAFE_BITSTREAM_READER
|
||||
#endif
|
||||
|
||||
#if ARCH_AARCH64
|
||||
# include "aarch64/cabac.h"
|
||||
#endif
|
||||
#if ARCH_ARM
|
||||
# include "arm/cabac.h"
|
||||
#endif
|
||||
#if ARCH_X86
|
||||
# include "x86/cabac.h"
|
||||
#endif
|
||||
#if ARCH_MIPS
|
||||
# include "mips/cabac.h"
|
||||
#endif
|
||||
#if ARCH_LOONGARCH64
|
||||
# include "loongarch/cabac.h"
|
||||
#endif
|
||||
|
||||
static const uint8_t * const ff_h264_norm_shift = ff_h264_cabac_tables + H264_NORM_SHIFT_OFFSET;
|
||||
static const uint8_t * const ff_h264_lps_range = ff_h264_cabac_tables + H264_LPS_RANGE_OFFSET;
|
||||
static const uint8_t * const ff_h264_mlps_state = ff_h264_cabac_tables + H264_MLPS_STATE_OFFSET;
|
||||
static const uint8_t * const ff_h264_last_coeff_flag_offset_8x8 = ff_h264_cabac_tables + H264_LAST_COEFF_FLAG_OFFSET_8x8_OFFSET;
|
||||
|
||||
#if !defined(get_cabac_bypass) || !defined(get_cabac_terminate)
|
||||
static void refill(CABACContext *c){
|
||||
#if CABAC_BITS == 16
|
||||
c->low+= (c->bytestream[0]<<9) + (c->bytestream[1]<<1);
|
||||
#else
|
||||
c->low+= c->bytestream[0]<<1;
|
||||
#endif
|
||||
c->low -= CABAC_MASK;
|
||||
#if !UNCHECKED_BITSTREAM_READER
|
||||
if (c->bytestream < c->bytestream_end)
|
||||
#endif
|
||||
c->bytestream += CABAC_BITS / 8;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef get_cabac_terminate
|
||||
static inline void renorm_cabac_decoder_once(CABACContext *c){
|
||||
int shift= (uint32_t)(c->range - 0x100)>>31;
|
||||
c->range<<= shift;
|
||||
c->low <<= shift;
|
||||
if(!(c->low & CABAC_MASK))
|
||||
refill(c);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef get_cabac_inline
|
||||
static void refill2(CABACContext *c){
|
||||
int i;
|
||||
unsigned x;
|
||||
#if !HAVE_FAST_CLZ
|
||||
x= c->low ^ (c->low-1);
|
||||
i= 7 - ff_h264_norm_shift[x>>(CABAC_BITS-1)];
|
||||
#else
|
||||
i = ff_ctz(c->low) - CABAC_BITS;
|
||||
#endif
|
||||
|
||||
x= -CABAC_MASK;
|
||||
|
||||
#if CABAC_BITS == 16
|
||||
x+= (c->bytestream[0]<<9) + (c->bytestream[1]<<1);
|
||||
#else
|
||||
x+= c->bytestream[0]<<1;
|
||||
#endif
|
||||
|
||||
c->low += x<<i;
|
||||
#if !UNCHECKED_BITSTREAM_READER
|
||||
if (c->bytestream < c->bytestream_end)
|
||||
#endif
|
||||
c->bytestream += CABAC_BITS/8;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef get_cabac_inline
|
||||
static av_always_inline int get_cabac_inline(CABACContext *c, uint8_t * const state){
|
||||
int s = *state;
|
||||
int RangeLPS= ff_h264_lps_range[2*(c->range&0xC0) + s];
|
||||
int bit, lps_mask;
|
||||
|
||||
c->range -= RangeLPS;
|
||||
lps_mask= ((c->range<<(CABAC_BITS+1)) - c->low)>>31;
|
||||
|
||||
c->low -= (c->range<<(CABAC_BITS+1)) & lps_mask;
|
||||
c->range += (RangeLPS - c->range) & lps_mask;
|
||||
|
||||
s^=lps_mask;
|
||||
*state= (ff_h264_mlps_state+128)[s];
|
||||
bit= s&1;
|
||||
|
||||
lps_mask= ff_h264_norm_shift[c->range];
|
||||
c->range<<= lps_mask;
|
||||
c->low <<= lps_mask;
|
||||
if(!(c->low & CABAC_MASK))
|
||||
refill2(c);
|
||||
return bit;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int av_noinline av_unused get_cabac_noinline(CABACContext *c, uint8_t * const state){
|
||||
return get_cabac_inline(c,state);
|
||||
}
|
||||
|
||||
static int av_unused get_cabac(CABACContext *c, uint8_t * const state){
|
||||
return get_cabac_inline(c,state);
|
||||
}
|
||||
|
||||
#ifndef get_cabac_bypass
|
||||
static int av_unused get_cabac_bypass(CABACContext *c){
|
||||
int range;
|
||||
c->low += c->low;
|
||||
|
||||
if(!(c->low & CABAC_MASK))
|
||||
refill(c);
|
||||
|
||||
range= c->range<<(CABAC_BITS+1);
|
||||
if(c->low < range){
|
||||
return 0;
|
||||
}else{
|
||||
c->low -= range;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef get_cabac_bypass_sign
|
||||
static av_always_inline int get_cabac_bypass_sign(CABACContext *c, int val){
|
||||
int range, mask;
|
||||
c->low += c->low;
|
||||
|
||||
if(!(c->low & CABAC_MASK))
|
||||
refill(c);
|
||||
|
||||
range= c->range<<(CABAC_BITS+1);
|
||||
c->low -= range;
|
||||
mask= c->low >> 31;
|
||||
range &= mask;
|
||||
c->low += range;
|
||||
return (val^mask)-mask;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @return the number of bytes read or 0 if no end
|
||||
*/
|
||||
#ifndef get_cabac_terminate
|
||||
static int av_unused get_cabac_terminate(CABACContext *c){
|
||||
c->range -= 2;
|
||||
if(c->low < c->range<<(CABAC_BITS+1)){
|
||||
renorm_cabac_decoder_once(c);
|
||||
return 0;
|
||||
}else{
|
||||
return c->bytestream - c->bytestream_start;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Skip @p n bytes and reset the decoder.
|
||||
* @return the address of the first skipped byte or NULL if there's less than @p n bytes left
|
||||
*/
|
||||
#ifndef skip_bytes
|
||||
static av_unused const uint8_t* skip_bytes(CABACContext *c, int n) {
|
||||
const uint8_t *ptr = c->bytestream;
|
||||
|
||||
if (c->low & 0x1)
|
||||
ptr--;
|
||||
#if CABAC_BITS == 16
|
||||
if (c->low & 0x1FF)
|
||||
ptr--;
|
||||
#endif
|
||||
if ((int) (c->bytestream_end - ptr) < n)
|
||||
return NULL;
|
||||
if (ff_init_cabac_decoder(c, ptr + n, c->bytestream_end - ptr - n) < 0)
|
||||
return NULL;
|
||||
|
||||
return ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* AVCODEC_CABAC_FUNCTIONS_H */
|
||||
32
include/libavcodec/canopus.h
Normal file
32
include/libavcodec/canopus.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Canopus common routines
|
||||
* Copyright (c) 2015 Vittorio Giovara <vittorio.giovara@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 AVCODEC_CANOPUS_H
|
||||
#define AVCODEC_CANOPUS_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "avcodec.h"
|
||||
|
||||
int ff_canopus_parse_info_tag(AVCodecContext *avctx,
|
||||
const uint8_t *src, size_t size);
|
||||
|
||||
#endif /* AVCODEC_CANOPUS_H */
|
||||
284
include/libavcodec/cavs.h
Normal file
284
include/libavcodec/cavs.h
Normal file
@@ -0,0 +1,284 @@
|
||||
/*
|
||||
* Chinese AVS video (AVS1-P2, JiZhun profile) decoder.
|
||||
* Copyright (c) 2006 Stefan Gehrer <stefan.gehrer@gmx.de>
|
||||
*
|
||||
* 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_CAVS_H
|
||||
#define AVCODEC_CAVS_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libavutil/frame.h"
|
||||
#include "libavutil/mem_internal.h"
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "cavsdsp.h"
|
||||
#include "blockdsp.h"
|
||||
#include "h264chroma.h"
|
||||
#include "get_bits.h"
|
||||
#include "videodsp.h"
|
||||
|
||||
#define SLICE_MAX_START_CODE 0x000001af
|
||||
#define EXT_START_CODE 0x000001b5
|
||||
#define USER_START_CODE 0x000001b2
|
||||
#define CAVS_START_CODE 0x000001b0
|
||||
#define PIC_I_START_CODE 0x000001b3
|
||||
#define PIC_PB_START_CODE 0x000001b6
|
||||
|
||||
#define A_AVAIL 1
|
||||
#define B_AVAIL 2
|
||||
#define C_AVAIL 4
|
||||
#define D_AVAIL 8
|
||||
#define NOT_AVAIL -1
|
||||
#define REF_INTRA -2
|
||||
#define REF_DIR -3
|
||||
|
||||
#define ESCAPE_CODE 59
|
||||
|
||||
#define FWD0 0x01
|
||||
#define FWD1 0x02
|
||||
#define BWD0 0x04
|
||||
#define BWD1 0x08
|
||||
#define SYM0 0x10
|
||||
#define SYM1 0x20
|
||||
#define SPLITH 0x40
|
||||
#define SPLITV 0x80
|
||||
|
||||
#define MV_BWD_OFFS 12
|
||||
#define MV_STRIDE 4
|
||||
|
||||
enum cavs_mb {
|
||||
I_8X8 = 0,
|
||||
P_SKIP,
|
||||
P_16X16,
|
||||
P_16X8,
|
||||
P_8X16,
|
||||
P_8X8,
|
||||
B_SKIP,
|
||||
B_DIRECT,
|
||||
B_FWD_16X16,
|
||||
B_BWD_16X16,
|
||||
B_SYM_16X16,
|
||||
B_8X8 = 29
|
||||
};
|
||||
|
||||
enum cavs_sub_mb {
|
||||
B_SUB_DIRECT,
|
||||
B_SUB_FWD,
|
||||
B_SUB_BWD,
|
||||
B_SUB_SYM
|
||||
};
|
||||
|
||||
enum cavs_intra_luma {
|
||||
INTRA_L_VERT,
|
||||
INTRA_L_HORIZ,
|
||||
INTRA_L_LP,
|
||||
INTRA_L_DOWN_LEFT,
|
||||
INTRA_L_DOWN_RIGHT,
|
||||
INTRA_L_LP_LEFT,
|
||||
INTRA_L_LP_TOP,
|
||||
INTRA_L_DC_128
|
||||
};
|
||||
|
||||
enum cavs_intra_chroma {
|
||||
INTRA_C_LP,
|
||||
INTRA_C_HORIZ,
|
||||
INTRA_C_VERT,
|
||||
INTRA_C_PLANE,
|
||||
INTRA_C_LP_LEFT,
|
||||
INTRA_C_LP_TOP,
|
||||
INTRA_C_DC_128,
|
||||
};
|
||||
|
||||
enum cavs_mv_pred {
|
||||
MV_PRED_MEDIAN,
|
||||
MV_PRED_LEFT,
|
||||
MV_PRED_TOP,
|
||||
MV_PRED_TOPRIGHT,
|
||||
MV_PRED_PSKIP,
|
||||
MV_PRED_BSKIP
|
||||
};
|
||||
|
||||
enum cavs_block {
|
||||
BLK_16X16,
|
||||
BLK_16X8,
|
||||
BLK_8X16,
|
||||
BLK_8X8
|
||||
};
|
||||
|
||||
enum cavs_mv_loc {
|
||||
MV_FWD_D3 = 0,
|
||||
MV_FWD_B2,
|
||||
MV_FWD_B3,
|
||||
MV_FWD_C2,
|
||||
MV_FWD_A1,
|
||||
MV_FWD_X0,
|
||||
MV_FWD_X1,
|
||||
MV_FWD_A3 = 8,
|
||||
MV_FWD_X2,
|
||||
MV_FWD_X3,
|
||||
MV_BWD_D3 = MV_BWD_OFFS,
|
||||
MV_BWD_B2,
|
||||
MV_BWD_B3,
|
||||
MV_BWD_C2,
|
||||
MV_BWD_A1,
|
||||
MV_BWD_X0,
|
||||
MV_BWD_X1,
|
||||
MV_BWD_A3 = MV_BWD_OFFS+8,
|
||||
MV_BWD_X2,
|
||||
MV_BWD_X3
|
||||
};
|
||||
|
||||
DECLARE_ALIGNED(8, typedef, struct) {
|
||||
int16_t x;
|
||||
int16_t y;
|
||||
int16_t dist;
|
||||
int16_t ref;
|
||||
} cavs_vector;
|
||||
|
||||
struct dec_2dvlc {
|
||||
int8_t rltab[59][3];
|
||||
int8_t level_add[27];
|
||||
int8_t golomb_order;
|
||||
int inc_limit;
|
||||
int8_t max_run;
|
||||
};
|
||||
|
||||
typedef struct AVSFrame {
|
||||
AVFrame *f;
|
||||
int poc;
|
||||
} AVSFrame;
|
||||
|
||||
typedef struct AVSContext {
|
||||
AVCodecContext *avctx;
|
||||
BlockDSPContext bdsp;
|
||||
H264ChromaContext h264chroma;
|
||||
VideoDSPContext vdsp;
|
||||
CAVSDSPContext cdsp;
|
||||
GetBitContext gb;
|
||||
AVSFrame cur; ///< currently decoded frame
|
||||
AVSFrame DPB[2]; ///< reference frames
|
||||
int dist[2]; ///< temporal distances from current frame to ref frames
|
||||
int low_delay;
|
||||
int profile, level;
|
||||
int aspect_ratio;
|
||||
int mb_width, mb_height;
|
||||
int width, height;
|
||||
int stream_revision; ///<0 for samples from 2006, 1 for rm52j encoder
|
||||
int progressive;
|
||||
int pic_structure;
|
||||
int skip_mode_flag; ///< select between skip_count or one skip_flag per MB
|
||||
int loop_filter_disable;
|
||||
int alpha_offset, beta_offset;
|
||||
int ref_flag;
|
||||
int mbx, mby, mbidx; ///< macroblock coordinates
|
||||
int flags; ///< availability flags of neighbouring macroblocks
|
||||
int stc; ///< last start code
|
||||
uint8_t *cy, *cu, *cv; ///< current MB sample pointers
|
||||
int left_qp;
|
||||
uint8_t *top_qp;
|
||||
|
||||
/** mv motion vector cache
|
||||
0: D3 B2 B3 C2
|
||||
4: A1 X0 X1 -
|
||||
8: A3 X2 X3 -
|
||||
|
||||
X are the vectors in the current macroblock (5,6,9,10)
|
||||
A is the macroblock to the left (4,8)
|
||||
B is the macroblock to the top (1,2)
|
||||
C is the macroblock to the top-right (3)
|
||||
D is the macroblock to the top-left (0)
|
||||
|
||||
the same is repeated for backward motion vectors */
|
||||
cavs_vector mv[2*4*3];
|
||||
cavs_vector *top_mv[2];
|
||||
cavs_vector *col_mv;
|
||||
|
||||
/** luma pred mode cache
|
||||
0: -- B2 B3
|
||||
3: A1 X0 X1
|
||||
6: A3 X2 X3 */
|
||||
int pred_mode_Y[3*3];
|
||||
int *top_pred_Y;
|
||||
ptrdiff_t l_stride, c_stride;
|
||||
int luma_scan[4];
|
||||
int qp;
|
||||
int qp_fixed;
|
||||
int pic_qp_fixed;
|
||||
int cbp;
|
||||
uint8_t permutated_scantable[64];
|
||||
|
||||
/** intra prediction is done with un-deblocked samples
|
||||
they are saved here before deblocking the MB */
|
||||
uint8_t *top_border_y, *top_border_u, *top_border_v;
|
||||
uint8_t left_border_y[26], left_border_u[10], left_border_v[10];
|
||||
uint8_t intern_border_y[26];
|
||||
uint8_t topleft_border_y, topleft_border_u, topleft_border_v;
|
||||
|
||||
void (*intra_pred_l[8])(uint8_t *d, uint8_t *top, uint8_t *left, ptrdiff_t stride);
|
||||
void (*intra_pred_c[7])(uint8_t *d, uint8_t *top, uint8_t *left, ptrdiff_t stride);
|
||||
uint8_t *col_type_base;
|
||||
|
||||
/* scaling factors for MV prediction */
|
||||
int sym_factor; ///< for scaling in symmetrical B block
|
||||
int direct_den[2]; ///< for scaling in direct B block
|
||||
int scale_den[2]; ///< for scaling neighbouring MVs
|
||||
|
||||
uint8_t *edge_emu_buffer;
|
||||
|
||||
int got_keyframe;
|
||||
int16_t *block;
|
||||
} AVSContext;
|
||||
|
||||
extern const uint8_t ff_cavs_chroma_qp[64];
|
||||
extern const uint8_t ff_cavs_partition_flags[30];
|
||||
extern const cavs_vector ff_cavs_intra_mv;
|
||||
extern const cavs_vector ff_cavs_dir_mv;
|
||||
|
||||
static inline void set_mvs(cavs_vector *mv, enum cavs_block size) {
|
||||
switch(size) {
|
||||
case BLK_16X16:
|
||||
mv[MV_STRIDE ] = mv[0];
|
||||
mv[MV_STRIDE+1] = mv[0];
|
||||
case BLK_16X8:
|
||||
mv[1] = mv[0];
|
||||
break;
|
||||
case BLK_8X16:
|
||||
mv[MV_STRIDE] = mv[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ff_cavs_filter(AVSContext *h, enum cavs_mb mb_type);
|
||||
void ff_cavs_load_intra_pred_luma(AVSContext *h, uint8_t *top, uint8_t **left,
|
||||
int block);
|
||||
void ff_cavs_load_intra_pred_chroma(AVSContext *h);
|
||||
void ff_cavs_modify_mb_i(AVSContext *h, int *pred_mode_uv);
|
||||
void ff_cavs_inter(AVSContext *h, enum cavs_mb mb_type);
|
||||
void ff_cavs_mv(AVSContext *h, enum cavs_mv_loc nP, enum cavs_mv_loc nC,
|
||||
enum cavs_mv_pred mode, enum cavs_block size, int ref);
|
||||
void ff_cavs_init_mb(AVSContext *h);
|
||||
int ff_cavs_next_mb(AVSContext *h);
|
||||
int ff_cavs_init_pic(AVSContext *h);
|
||||
int ff_cavs_init_top_lines(AVSContext *h);
|
||||
int ff_cavs_init(AVCodecContext *avctx);
|
||||
int ff_cavs_end (AVCodecContext *avctx);
|
||||
|
||||
#endif /* AVCODEC_CAVS_H */
|
||||
44
include/libavcodec/cavsdsp.h
Normal file
44
include/libavcodec/cavsdsp.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Chinese AVS video (AVS1-P2, JiZhun profile) decoder.
|
||||
* Copyright (c) 2006 Stefan Gehrer <stefan.gehrer@gmx.de>
|
||||
*
|
||||
* 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_CAVSDSP_H
|
||||
#define AVCODEC_CAVSDSP_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "qpeldsp.h"
|
||||
|
||||
typedef struct CAVSDSPContext {
|
||||
qpel_mc_func put_cavs_qpel_pixels_tab[2][16];
|
||||
qpel_mc_func avg_cavs_qpel_pixels_tab[2][16];
|
||||
void (*cavs_filter_lv)(uint8_t *pix, ptrdiff_t stride, int alpha, int beta, int tc, int bs1, int bs2);
|
||||
void (*cavs_filter_lh)(uint8_t *pix, ptrdiff_t stride, int alpha, int beta, int tc, int bs1, int bs2);
|
||||
void (*cavs_filter_cv)(uint8_t *pix, ptrdiff_t stride, int alpha, int beta, int tc, int bs1, int bs2);
|
||||
void (*cavs_filter_ch)(uint8_t *pix, ptrdiff_t stride, int alpha, int beta, int tc, int bs1, int bs2);
|
||||
void (*cavs_idct8_add)(uint8_t *dst, int16_t *block, ptrdiff_t stride);
|
||||
int idct_perm;
|
||||
} CAVSDSPContext;
|
||||
|
||||
void ff_cavsdsp_init(CAVSDSPContext* c);
|
||||
void ff_cavsdsp_init_x86(CAVSDSPContext* c);
|
||||
|
||||
#endif /* AVCODEC_CAVSDSP_H */
|
||||
40
include/libavcodec/cbrt_data.h
Normal file
40
include/libavcodec/cbrt_data.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
|
||||
*
|
||||
* 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_CBRT_DATA_H
|
||||
#define AVCODEC_CBRT_DATA_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if CONFIG_HARDCODED_TABLES
|
||||
#define ff_cbrt_tableinit_fixed()
|
||||
#define ff_cbrt_tableinit()
|
||||
extern const uint32_t ff_cbrt_tab[1 << 13];
|
||||
extern const uint32_t ff_cbrt_tab_fixed[1 << 13];
|
||||
#else
|
||||
void ff_cbrt_tableinit(void);
|
||||
void ff_cbrt_tableinit_fixed(void);
|
||||
extern uint32_t ff_cbrt_tab[1 << 13];
|
||||
extern uint32_t ff_cbrt_tab_fixed[1 << 13];
|
||||
#endif
|
||||
|
||||
#endif
|
||||
73
include/libavcodec/cbrt_tablegen.h
Normal file
73
include/libavcodec/cbrt_tablegen.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Header file for hardcoded AAC cube-root table
|
||||
*
|
||||
* Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
|
||||
*
|
||||
* 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_CBRT_TABLEGEN_H
|
||||
#define AVCODEC_CBRT_TABLEGEN_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <math.h>
|
||||
#include "libavutil/attributes.h"
|
||||
#include "libavutil/intfloat.h"
|
||||
#include "libavcodec/aac_defines.h"
|
||||
|
||||
#if USE_FIXED
|
||||
#define CBRT(x) lrint((x) * 8192)
|
||||
#else
|
||||
#define CBRT(x) av_float2int((float)(x))
|
||||
#endif
|
||||
|
||||
uint32_t AAC_RENAME(ff_cbrt_tab)[1 << 13];
|
||||
|
||||
av_cold void AAC_RENAME(ff_cbrt_tableinit)(void)
|
||||
{
|
||||
static double cbrt_tab_dbl[1 << 13];
|
||||
if (!AAC_RENAME(ff_cbrt_tab)[(1<<13) - 1]) {
|
||||
int i, j, k;
|
||||
double cbrt_val;
|
||||
|
||||
for (i = 1; i < 1<<13; i++)
|
||||
cbrt_tab_dbl[i] = 1;
|
||||
|
||||
/* have to take care of non-squarefree numbers */
|
||||
for (i = 2; i < 90; i++) {
|
||||
if (cbrt_tab_dbl[i] == 1) {
|
||||
cbrt_val = i * cbrt(i);
|
||||
for (k = i; k < 1<<13; k *= i)
|
||||
for (j = k; j < 1<<13; j += k)
|
||||
cbrt_tab_dbl[j] *= cbrt_val;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 91; i <= 8191; i+= 2) {
|
||||
if (cbrt_tab_dbl[i] == 1) {
|
||||
cbrt_val = i * cbrt(i);
|
||||
for (j = i; j < 1<<13; j += i)
|
||||
cbrt_tab_dbl[j] *= cbrt_val;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 1<<13; i++)
|
||||
AAC_RENAME(ff_cbrt_tab)[i] = CBRT(cbrt_tab_dbl[i]);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* AVCODEC_CBRT_TABLEGEN_H */
|
||||
541
include/libavcodec/cbs.h
Normal file
541
include/libavcodec/cbs.h
Normal file
@@ -0,0 +1,541 @@
|
||||
/*
|
||||
* 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_CBS_H
|
||||
#define AVCODEC_CBS_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libavutil/buffer.h"
|
||||
|
||||
#include "codec_id.h"
|
||||
#include "codec_par.h"
|
||||
#include "defs.h"
|
||||
#include "packet.h"
|
||||
|
||||
|
||||
/*
|
||||
* This defines a framework for converting between a coded bitstream
|
||||
* and structures defining all individual syntax elements found in
|
||||
* such a stream.
|
||||
*
|
||||
* Conversion in both directions is possible. Given a coded bitstream
|
||||
* (any meaningful fragment), it can be parsed and decomposed into
|
||||
* syntax elements stored in a set of codec-specific structures.
|
||||
* Similarly, given a set of those same codec-specific structures the
|
||||
* syntax elements can be serialised and combined to create a coded
|
||||
* bitstream.
|
||||
*/
|
||||
|
||||
struct AVCodecContext;
|
||||
struct CodedBitstreamType;
|
||||
|
||||
/**
|
||||
* The codec-specific type of a bitstream unit.
|
||||
*
|
||||
* AV1: obu_type
|
||||
* H.264 / AVC: nal_unit_type
|
||||
* H.265 / HEVC: nal_unit_type
|
||||
* JPEG: marker value (without 0xff prefix)
|
||||
* MPEG-2: start code value (without prefix)
|
||||
* VP9: unused, set to zero (every unit is a frame)
|
||||
*/
|
||||
typedef uint32_t CodedBitstreamUnitType;
|
||||
|
||||
/**
|
||||
* Coded bitstream unit structure.
|
||||
*
|
||||
* A bitstream unit the smallest element of a bitstream which
|
||||
* is meaningful on its own. For example, an H.264 NAL unit.
|
||||
*
|
||||
* See the codec-specific header for the meaning of this for any
|
||||
* particular codec.
|
||||
*/
|
||||
typedef struct CodedBitstreamUnit {
|
||||
/**
|
||||
* Codec-specific type of this unit.
|
||||
*/
|
||||
CodedBitstreamUnitType type;
|
||||
|
||||
/**
|
||||
* Pointer to the directly-parsable bitstream form of this unit.
|
||||
*
|
||||
* May be NULL if the unit currently only exists in decomposed form.
|
||||
*/
|
||||
uint8_t *data;
|
||||
/**
|
||||
* The number of bytes in the bitstream (including any padding bits
|
||||
* in the final byte).
|
||||
*/
|
||||
size_t data_size;
|
||||
/**
|
||||
* The number of bits which should be ignored in the final byte.
|
||||
*
|
||||
* This supports non-byte-aligned bitstreams.
|
||||
*/
|
||||
size_t data_bit_padding;
|
||||
/**
|
||||
* A reference to the buffer containing data.
|
||||
*
|
||||
* Must be set if data is not NULL.
|
||||
*/
|
||||
AVBufferRef *data_ref;
|
||||
|
||||
/**
|
||||
* Pointer to the decomposed form of this unit.
|
||||
*
|
||||
* The type of this structure depends on both the codec and the
|
||||
* type of this unit. May be NULL if the unit only exists in
|
||||
* bitstream form.
|
||||
*/
|
||||
void *content;
|
||||
/**
|
||||
* If content is reference counted, a RefStruct reference backing content.
|
||||
* NULL if content is not reference counted.
|
||||
*/
|
||||
void *content_ref;
|
||||
} CodedBitstreamUnit;
|
||||
|
||||
/**
|
||||
* Coded bitstream fragment structure, combining one or more units.
|
||||
*
|
||||
* This is any sequence of units. It need not form some greater whole,
|
||||
* though in many cases it will. For example, an H.264 access unit,
|
||||
* which is composed of a sequence of H.264 NAL units.
|
||||
*/
|
||||
typedef struct CodedBitstreamFragment {
|
||||
/**
|
||||
* Pointer to the bitstream form of this fragment.
|
||||
*
|
||||
* May be NULL if the fragment only exists as component units.
|
||||
*/
|
||||
uint8_t *data;
|
||||
/**
|
||||
* The number of bytes in the bitstream.
|
||||
*
|
||||
* The number of bytes in the bitstream (including any padding bits
|
||||
* in the final byte).
|
||||
*/
|
||||
size_t data_size;
|
||||
/**
|
||||
* The number of bits which should be ignored in the final byte.
|
||||
*/
|
||||
size_t data_bit_padding;
|
||||
/**
|
||||
* A reference to the buffer containing data.
|
||||
*
|
||||
* Must be set if data is not NULL.
|
||||
*/
|
||||
AVBufferRef *data_ref;
|
||||
|
||||
/**
|
||||
* Number of units in this fragment.
|
||||
*
|
||||
* This may be zero if the fragment only exists in bitstream form
|
||||
* and has not been decomposed.
|
||||
*/
|
||||
int nb_units;
|
||||
|
||||
/**
|
||||
* Number of allocated units.
|
||||
*
|
||||
* Must always be >= nb_units; designed for internal use by cbs.
|
||||
*/
|
||||
int nb_units_allocated;
|
||||
|
||||
/**
|
||||
* Pointer to an array of units of length nb_units_allocated.
|
||||
* Only the first nb_units are valid.
|
||||
*
|
||||
* Must be NULL if nb_units_allocated is zero.
|
||||
*/
|
||||
CodedBitstreamUnit *units;
|
||||
} CodedBitstreamFragment;
|
||||
|
||||
|
||||
struct CodedBitstreamContext;
|
||||
struct GetBitContext;
|
||||
struct PutBitContext;
|
||||
|
||||
/**
|
||||
* Callback type for read tracing.
|
||||
*
|
||||
* @param ctx User-set trace context.
|
||||
* @param gbc A GetBitContext set at the start of the syntax
|
||||
* element. This is a copy, the callee does not
|
||||
* need to preserve it.
|
||||
* @param length Length in bits of the syntax element.
|
||||
* @param name String name of the syntax elements.
|
||||
* @param subscripts If the syntax element is an array, a pointer to
|
||||
* an array of subscripts into the array.
|
||||
* @param value Parsed value of the syntax element.
|
||||
*/
|
||||
typedef void (*CBSTraceReadCallback)(void *trace_context,
|
||||
struct GetBitContext *gbc,
|
||||
int start_position,
|
||||
const char *name,
|
||||
const int *subscripts,
|
||||
int64_t value);
|
||||
|
||||
/**
|
||||
* Callback type for write tracing.
|
||||
*
|
||||
* @param ctx User-set trace context.
|
||||
* @param pbc A PutBitContext set at the end of the syntax
|
||||
* element. The user must not modify this, but may
|
||||
* inspect it to determine state.
|
||||
* @param length Length in bits of the syntax element.
|
||||
* @param name String name of the syntax elements.
|
||||
* @param subscripts If the syntax element is an array, a pointer to
|
||||
* an array of subscripts into the array.
|
||||
* @param value Written value of the syntax element.
|
||||
*/
|
||||
typedef void (*CBSTraceWriteCallback)(void *trace_context,
|
||||
struct PutBitContext *pbc,
|
||||
int start_position,
|
||||
const char *name,
|
||||
const int *subscripts,
|
||||
int64_t value);
|
||||
|
||||
/**
|
||||
* Context structure for coded bitstream operations.
|
||||
*/
|
||||
typedef struct CodedBitstreamContext {
|
||||
/**
|
||||
* Logging context to be passed to all av_log() calls associated
|
||||
* with this context.
|
||||
*/
|
||||
void *log_ctx;
|
||||
|
||||
/**
|
||||
* Internal codec-specific hooks.
|
||||
*/
|
||||
const struct CodedBitstreamType *codec;
|
||||
|
||||
/**
|
||||
* Internal codec-specific data.
|
||||
*
|
||||
* This contains any information needed when reading/writing
|
||||
* bitsteams which will not necessarily be present in a fragment.
|
||||
* For example, for H.264 it contains all currently visible
|
||||
* parameter sets - they are required to determine the bitstream
|
||||
* syntax but need not be present in every access unit.
|
||||
*/
|
||||
void *priv_data;
|
||||
|
||||
/**
|
||||
* Array of unit types which should be decomposed when reading.
|
||||
*
|
||||
* Types not in this list will be available in bitstream form only.
|
||||
* If NULL, all supported types will be decomposed.
|
||||
*/
|
||||
const CodedBitstreamUnitType *decompose_unit_types;
|
||||
/**
|
||||
* Length of the decompose_unit_types array.
|
||||
*/
|
||||
int nb_decompose_unit_types;
|
||||
|
||||
/**
|
||||
* Enable trace output during read/write operations.
|
||||
*/
|
||||
int trace_enable;
|
||||
/**
|
||||
* Log level to use for default trace output.
|
||||
*
|
||||
* From AV_LOG_*; defaults to AV_LOG_TRACE.
|
||||
*/
|
||||
int trace_level;
|
||||
/**
|
||||
* User context pointer to pass to trace callbacks.
|
||||
*/
|
||||
void *trace_context;
|
||||
/**
|
||||
* Callback for read tracing.
|
||||
*
|
||||
* If tracing is enabled then this is called once for each syntax
|
||||
* element parsed.
|
||||
*/
|
||||
CBSTraceReadCallback trace_read_callback;
|
||||
/**
|
||||
* Callback for write tracing.
|
||||
*
|
||||
* If tracing is enabled then this is called once for each syntax
|
||||
* element written.
|
||||
*/
|
||||
CBSTraceWriteCallback trace_write_callback;
|
||||
|
||||
/**
|
||||
* Write buffer. Used as intermediate buffer when writing units.
|
||||
* For internal use of cbs only.
|
||||
*/
|
||||
uint8_t *write_buffer;
|
||||
size_t write_buffer_size;
|
||||
} CodedBitstreamContext;
|
||||
|
||||
|
||||
/**
|
||||
* Table of all supported codec IDs.
|
||||
*
|
||||
* Terminated by AV_CODEC_ID_NONE.
|
||||
*/
|
||||
extern const enum AVCodecID ff_cbs_all_codec_ids[];
|
||||
|
||||
|
||||
/**
|
||||
* Create and initialise a new context for the given codec.
|
||||
*/
|
||||
int ff_cbs_init(CodedBitstreamContext **ctx,
|
||||
enum AVCodecID codec_id, void *log_ctx);
|
||||
|
||||
/**
|
||||
* Reset all internal state in a context.
|
||||
*/
|
||||
void ff_cbs_flush(CodedBitstreamContext *ctx);
|
||||
|
||||
/**
|
||||
* Close a context and free all internal state.
|
||||
*/
|
||||
void ff_cbs_close(CodedBitstreamContext **ctx);
|
||||
|
||||
|
||||
/**
|
||||
* Read the extradata bitstream found in codec parameters into a
|
||||
* fragment, then split into units and decompose.
|
||||
*
|
||||
* This also updates the internal state, so will need to be called for
|
||||
* codecs with extradata to read parameter sets necessary for further
|
||||
* parsing even if the fragment itself is not desired.
|
||||
*
|
||||
* The fragment must have been zeroed or reset via ff_cbs_fragment_reset
|
||||
* before use.
|
||||
*/
|
||||
int ff_cbs_read_extradata(CodedBitstreamContext *ctx,
|
||||
CodedBitstreamFragment *frag,
|
||||
const AVCodecParameters *par);
|
||||
|
||||
/**
|
||||
* Read the extradata bitstream found in a codec context into a
|
||||
* fragment, then split into units and decompose.
|
||||
*
|
||||
* This acts identical to ff_cbs_read_extradata() for the case where
|
||||
* you already have a codec context.
|
||||
*/
|
||||
int ff_cbs_read_extradata_from_codec(CodedBitstreamContext *ctx,
|
||||
CodedBitstreamFragment *frag,
|
||||
const struct AVCodecContext *avctx);
|
||||
|
||||
int ff_cbs_read_packet_side_data(CodedBitstreamContext *ctx,
|
||||
CodedBitstreamFragment *frag,
|
||||
const AVPacket *pkt);
|
||||
|
||||
/**
|
||||
* Read the data bitstream from a packet into a fragment, then
|
||||
* split into units and decompose.
|
||||
*
|
||||
* This also updates the internal state of the coded bitstream context
|
||||
* with any persistent data from the fragment which may be required to
|
||||
* read following fragments (e.g. parameter sets).
|
||||
*
|
||||
* The fragment must have been zeroed or reset via ff_cbs_fragment_reset
|
||||
* before use.
|
||||
*/
|
||||
int ff_cbs_read_packet(CodedBitstreamContext *ctx,
|
||||
CodedBitstreamFragment *frag,
|
||||
const AVPacket *pkt);
|
||||
|
||||
/**
|
||||
* Read a bitstream from a memory region into a fragment, then
|
||||
* split into units and decompose.
|
||||
*
|
||||
* This also updates the internal state of the coded bitstream context
|
||||
* with any persistent data from the fragment which may be required to
|
||||
* read following fragments (e.g. parameter sets).
|
||||
*
|
||||
* The fragment must have been zeroed or reset via ff_cbs_fragment_reset
|
||||
* before use.
|
||||
*/
|
||||
int ff_cbs_read(CodedBitstreamContext *ctx,
|
||||
CodedBitstreamFragment *frag,
|
||||
const uint8_t *data, size_t size);
|
||||
|
||||
|
||||
/**
|
||||
* Write the content of the fragment to its own internal buffer.
|
||||
*
|
||||
* Writes the content of all units and then assembles them into a new
|
||||
* data buffer. When modifying the content of decomposed units, this
|
||||
* can be used to regenerate the bitstream form of units or the whole
|
||||
* fragment so that it can be extracted for other use.
|
||||
*
|
||||
* This also updates the internal state of the coded bitstream context
|
||||
* with any persistent data from the fragment which may be required to
|
||||
* write following fragments (e.g. parameter sets).
|
||||
*/
|
||||
int ff_cbs_write_fragment_data(CodedBitstreamContext *ctx,
|
||||
CodedBitstreamFragment *frag);
|
||||
|
||||
/**
|
||||
* Write the bitstream of a fragment to the extradata in codec parameters.
|
||||
*
|
||||
* Modifies context and fragment as ff_cbs_write_fragment_data does and
|
||||
* replaces any existing extradata in the structure.
|
||||
*/
|
||||
int ff_cbs_write_extradata(CodedBitstreamContext *ctx,
|
||||
AVCodecParameters *par,
|
||||
CodedBitstreamFragment *frag);
|
||||
|
||||
/**
|
||||
* Write the bitstream of a fragment to a packet.
|
||||
*
|
||||
* Modifies context and fragment as ff_cbs_write_fragment_data does.
|
||||
*
|
||||
* On success, the packet's buf is unreferenced and its buf, data and
|
||||
* size fields are set to the corresponding values from the newly updated
|
||||
* fragment; other fields are not touched. On failure, the packet is not
|
||||
* touched at all.
|
||||
*/
|
||||
int ff_cbs_write_packet(CodedBitstreamContext *ctx,
|
||||
AVPacket *pkt,
|
||||
CodedBitstreamFragment *frag);
|
||||
|
||||
|
||||
/**
|
||||
* Free the units contained in a fragment as well as the fragment's
|
||||
* own data buffer, but not the units array itself.
|
||||
*/
|
||||
void ff_cbs_fragment_reset(CodedBitstreamFragment *frag);
|
||||
|
||||
/**
|
||||
* Free the units array of a fragment in addition to what
|
||||
* ff_cbs_fragment_reset does.
|
||||
*/
|
||||
void ff_cbs_fragment_free(CodedBitstreamFragment *frag);
|
||||
|
||||
/**
|
||||
* Allocate a new internal content buffer matching the type of the unit.
|
||||
*
|
||||
* The content will be zeroed.
|
||||
*/
|
||||
int ff_cbs_alloc_unit_content(CodedBitstreamContext *ctx,
|
||||
CodedBitstreamUnit *unit);
|
||||
|
||||
/**
|
||||
* Insert a new unit into a fragment with the given content.
|
||||
*
|
||||
* If content_ref is supplied, it has to be a RefStruct reference
|
||||
* backing content; the user keeps ownership of the supplied reference.
|
||||
* The content structure continues to be owned by the caller if
|
||||
* content_ref is not supplied.
|
||||
*/
|
||||
int ff_cbs_insert_unit_content(CodedBitstreamFragment *frag,
|
||||
int position,
|
||||
CodedBitstreamUnitType type,
|
||||
void *content,
|
||||
void *content_ref);
|
||||
|
||||
/**
|
||||
* Add a new unit to a fragment with the given data bitstream.
|
||||
*
|
||||
* If data_buf is not supplied then data must have been allocated with
|
||||
* av_malloc() and will on success become owned by the unit after this
|
||||
* call or freed on error.
|
||||
*/
|
||||
int ff_cbs_append_unit_data(CodedBitstreamFragment *frag,
|
||||
CodedBitstreamUnitType type,
|
||||
uint8_t *data, size_t data_size,
|
||||
AVBufferRef *data_buf);
|
||||
|
||||
/**
|
||||
* Delete a unit from a fragment and free all memory it uses.
|
||||
*
|
||||
* Requires position to be >= 0 and < frag->nb_units.
|
||||
*/
|
||||
void ff_cbs_delete_unit(CodedBitstreamFragment *frag,
|
||||
int position);
|
||||
|
||||
|
||||
/**
|
||||
* Make the content of a unit refcounted.
|
||||
*
|
||||
* If the unit is not refcounted, this will do a deep copy of the unit
|
||||
* content to new refcounted buffers.
|
||||
*
|
||||
* It is not valid to call this function on a unit which does not have
|
||||
* decomposed content.
|
||||
*/
|
||||
int ff_cbs_make_unit_refcounted(CodedBitstreamContext *ctx,
|
||||
CodedBitstreamUnit *unit);
|
||||
|
||||
/**
|
||||
* Make the content of a unit writable so that internal fields can be
|
||||
* modified.
|
||||
*
|
||||
* If it is known that there are no other references to the content of
|
||||
* the unit, does nothing and returns success. Otherwise (including the
|
||||
* case where the unit content is not refcounted), it does a full clone
|
||||
* of the content (including any internal buffers) to make a new copy,
|
||||
* and replaces the existing references inside the unit with that.
|
||||
*
|
||||
* It is not valid to call this function on a unit which does not have
|
||||
* decomposed content.
|
||||
*/
|
||||
int ff_cbs_make_unit_writable(CodedBitstreamContext *ctx,
|
||||
CodedBitstreamUnit *unit);
|
||||
|
||||
enum CbsDiscardFlags {
|
||||
DISCARD_FLAG_NONE = 0,
|
||||
|
||||
/**
|
||||
* keep non-vcl units even if the picture has been dropped.
|
||||
*/
|
||||
DISCARD_FLAG_KEEP_NON_VCL = 0x01,
|
||||
};
|
||||
|
||||
/**
|
||||
* Discard units accroding to 'skip'.
|
||||
*/
|
||||
void ff_cbs_discard_units(CodedBitstreamContext *ctx,
|
||||
CodedBitstreamFragment *frag,
|
||||
enum AVDiscard skip,
|
||||
int flags);
|
||||
|
||||
|
||||
/**
|
||||
* Helper function for read tracing which formats the syntax element
|
||||
* and logs the result.
|
||||
*
|
||||
* Trace context should be set to the CodedBitstreamContext.
|
||||
*/
|
||||
void ff_cbs_trace_read_log(void *trace_context,
|
||||
struct GetBitContext *gbc, int length,
|
||||
const char *str, const int *subscripts,
|
||||
int64_t value);
|
||||
|
||||
/**
|
||||
* Helper function for write tracing which formats the syntax element
|
||||
* and logs the result.
|
||||
*
|
||||
* Trace context should be set to the CodedBitstreamContext.
|
||||
*/
|
||||
void ff_cbs_trace_write_log(void *trace_context,
|
||||
struct PutBitContext *pbc, int length,
|
||||
const char *str, const int *subscripts,
|
||||
int64_t value);
|
||||
|
||||
#endif /* AVCODEC_CBS_H */
|
||||
488
include/libavcodec/cbs_av1.h
Normal file
488
include/libavcodec/cbs_av1.h
Normal file
@@ -0,0 +1,488 @@
|
||||
/*
|
||||
* 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_CBS_AV1_H
|
||||
#define AVCODEC_CBS_AV1_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "av1.h"
|
||||
#include "cbs.h"
|
||||
|
||||
|
||||
typedef struct AV1RawOBUHeader {
|
||||
uint8_t obu_forbidden_bit;
|
||||
uint8_t obu_type;
|
||||
uint8_t obu_extension_flag;
|
||||
uint8_t obu_has_size_field;
|
||||
uint8_t obu_reserved_1bit;
|
||||
|
||||
uint8_t temporal_id;
|
||||
uint8_t spatial_id;
|
||||
uint8_t extension_header_reserved_3bits;
|
||||
} AV1RawOBUHeader;
|
||||
|
||||
typedef struct AV1RawColorConfig {
|
||||
uint8_t high_bitdepth;
|
||||
uint8_t twelve_bit;
|
||||
uint8_t mono_chrome;
|
||||
|
||||
uint8_t color_description_present_flag;
|
||||
uint8_t color_primaries;
|
||||
uint8_t transfer_characteristics;
|
||||
uint8_t matrix_coefficients;
|
||||
|
||||
uint8_t color_range;
|
||||
uint8_t subsampling_x;
|
||||
uint8_t subsampling_y;
|
||||
uint8_t chroma_sample_position;
|
||||
uint8_t separate_uv_delta_q;
|
||||
} AV1RawColorConfig;
|
||||
|
||||
typedef struct AV1RawTimingInfo {
|
||||
uint32_t num_units_in_display_tick;
|
||||
uint32_t time_scale;
|
||||
|
||||
uint8_t equal_picture_interval;
|
||||
uint32_t num_ticks_per_picture_minus_1;
|
||||
} AV1RawTimingInfo;
|
||||
|
||||
typedef struct AV1RawDecoderModelInfo {
|
||||
uint8_t buffer_delay_length_minus_1;
|
||||
uint32_t num_units_in_decoding_tick;
|
||||
uint8_t buffer_removal_time_length_minus_1;
|
||||
uint8_t frame_presentation_time_length_minus_1;
|
||||
} AV1RawDecoderModelInfo;
|
||||
|
||||
typedef struct AV1RawSequenceHeader {
|
||||
uint8_t seq_profile;
|
||||
uint8_t still_picture;
|
||||
uint8_t reduced_still_picture_header;
|
||||
|
||||
uint8_t timing_info_present_flag;
|
||||
uint8_t decoder_model_info_present_flag;
|
||||
uint8_t initial_display_delay_present_flag;
|
||||
uint8_t operating_points_cnt_minus_1;
|
||||
|
||||
AV1RawTimingInfo timing_info;
|
||||
AV1RawDecoderModelInfo decoder_model_info;
|
||||
|
||||
uint16_t operating_point_idc[AV1_MAX_OPERATING_POINTS];
|
||||
uint8_t seq_level_idx[AV1_MAX_OPERATING_POINTS];
|
||||
uint8_t seq_tier[AV1_MAX_OPERATING_POINTS];
|
||||
uint8_t decoder_model_present_for_this_op[AV1_MAX_OPERATING_POINTS];
|
||||
uint32_t decoder_buffer_delay[AV1_MAX_OPERATING_POINTS];
|
||||
uint32_t encoder_buffer_delay[AV1_MAX_OPERATING_POINTS];
|
||||
uint8_t low_delay_mode_flag[AV1_MAX_OPERATING_POINTS];
|
||||
uint8_t initial_display_delay_present_for_this_op[AV1_MAX_OPERATING_POINTS];
|
||||
uint8_t initial_display_delay_minus_1[AV1_MAX_OPERATING_POINTS];
|
||||
|
||||
uint8_t frame_width_bits_minus_1;
|
||||
uint8_t frame_height_bits_minus_1;
|
||||
uint16_t max_frame_width_minus_1;
|
||||
uint16_t max_frame_height_minus_1;
|
||||
|
||||
uint8_t frame_id_numbers_present_flag;
|
||||
uint8_t delta_frame_id_length_minus_2;
|
||||
uint8_t additional_frame_id_length_minus_1;
|
||||
|
||||
uint8_t use_128x128_superblock;
|
||||
uint8_t enable_filter_intra;
|
||||
uint8_t enable_intra_edge_filter;
|
||||
uint8_t enable_interintra_compound;
|
||||
uint8_t enable_masked_compound;
|
||||
uint8_t enable_warped_motion;
|
||||
uint8_t enable_dual_filter;
|
||||
|
||||
uint8_t enable_order_hint;
|
||||
uint8_t enable_jnt_comp;
|
||||
uint8_t enable_ref_frame_mvs;
|
||||
|
||||
uint8_t seq_choose_screen_content_tools;
|
||||
uint8_t seq_force_screen_content_tools;
|
||||
uint8_t seq_choose_integer_mv;
|
||||
uint8_t seq_force_integer_mv;
|
||||
|
||||
uint8_t order_hint_bits_minus_1;
|
||||
|
||||
uint8_t enable_superres;
|
||||
uint8_t enable_cdef;
|
||||
uint8_t enable_restoration;
|
||||
|
||||
AV1RawColorConfig color_config;
|
||||
|
||||
uint8_t film_grain_params_present;
|
||||
} AV1RawSequenceHeader;
|
||||
|
||||
typedef struct AV1RawFilmGrainParams {
|
||||
uint8_t apply_grain;
|
||||
uint16_t grain_seed;
|
||||
uint8_t update_grain;
|
||||
uint8_t film_grain_params_ref_idx;
|
||||
uint8_t num_y_points;
|
||||
uint8_t point_y_value[14];
|
||||
uint8_t point_y_scaling[14];
|
||||
uint8_t chroma_scaling_from_luma;
|
||||
uint8_t num_cb_points;
|
||||
uint8_t point_cb_value[10];
|
||||
uint8_t point_cb_scaling[10];
|
||||
uint8_t num_cr_points;
|
||||
uint8_t point_cr_value[10];
|
||||
uint8_t point_cr_scaling[10];
|
||||
uint8_t grain_scaling_minus_8;
|
||||
uint8_t ar_coeff_lag;
|
||||
uint8_t ar_coeffs_y_plus_128[24];
|
||||
uint8_t ar_coeffs_cb_plus_128[25];
|
||||
uint8_t ar_coeffs_cr_plus_128[25];
|
||||
uint8_t ar_coeff_shift_minus_6;
|
||||
uint8_t grain_scale_shift;
|
||||
uint8_t cb_mult;
|
||||
uint8_t cb_luma_mult;
|
||||
uint16_t cb_offset;
|
||||
uint8_t cr_mult;
|
||||
uint8_t cr_luma_mult;
|
||||
uint16_t cr_offset;
|
||||
uint8_t overlap_flag;
|
||||
uint8_t clip_to_restricted_range;
|
||||
} AV1RawFilmGrainParams;
|
||||
|
||||
typedef struct AV1RawFrameHeader {
|
||||
uint8_t show_existing_frame;
|
||||
uint8_t frame_to_show_map_idx;
|
||||
uint32_t frame_presentation_time;
|
||||
uint32_t display_frame_id;
|
||||
|
||||
uint8_t frame_type;
|
||||
uint8_t show_frame;
|
||||
uint8_t showable_frame;
|
||||
|
||||
uint8_t error_resilient_mode;
|
||||
uint8_t disable_cdf_update;
|
||||
uint8_t allow_screen_content_tools;
|
||||
uint8_t force_integer_mv;
|
||||
|
||||
uint32_t current_frame_id;
|
||||
uint8_t frame_size_override_flag;
|
||||
uint8_t order_hint;
|
||||
|
||||
uint8_t buffer_removal_time_present_flag;
|
||||
uint32_t buffer_removal_time[AV1_MAX_OPERATING_POINTS];
|
||||
|
||||
uint8_t primary_ref_frame;
|
||||
uint16_t frame_width_minus_1;
|
||||
uint16_t frame_height_minus_1;
|
||||
uint8_t use_superres;
|
||||
uint8_t coded_denom;
|
||||
uint8_t render_and_frame_size_different;
|
||||
uint16_t render_width_minus_1;
|
||||
uint16_t render_height_minus_1;
|
||||
|
||||
uint8_t found_ref[AV1_REFS_PER_FRAME];
|
||||
|
||||
uint8_t refresh_frame_flags;
|
||||
uint8_t allow_intrabc;
|
||||
uint8_t ref_order_hint[AV1_NUM_REF_FRAMES];
|
||||
uint8_t frame_refs_short_signaling;
|
||||
uint8_t last_frame_idx;
|
||||
uint8_t golden_frame_idx;
|
||||
int8_t ref_frame_idx[AV1_REFS_PER_FRAME];
|
||||
uint32_t delta_frame_id_minus1[AV1_REFS_PER_FRAME];
|
||||
|
||||
uint8_t allow_high_precision_mv;
|
||||
uint8_t is_filter_switchable;
|
||||
uint8_t interpolation_filter;
|
||||
uint8_t is_motion_mode_switchable;
|
||||
uint8_t use_ref_frame_mvs;
|
||||
|
||||
uint8_t disable_frame_end_update_cdf;
|
||||
|
||||
uint8_t uniform_tile_spacing_flag;
|
||||
uint8_t tile_cols_log2;
|
||||
uint8_t tile_rows_log2;
|
||||
uint8_t tile_start_col_sb[AV1_MAX_TILE_COLS];
|
||||
uint8_t tile_start_row_sb[AV1_MAX_TILE_COLS];
|
||||
uint8_t width_in_sbs_minus_1[AV1_MAX_TILE_COLS];
|
||||
uint8_t height_in_sbs_minus_1[AV1_MAX_TILE_ROWS];
|
||||
uint16_t context_update_tile_id;
|
||||
uint8_t tile_size_bytes_minus1;
|
||||
|
||||
// These are derived values, but it's very unhelpful to have to
|
||||
// recalculate them all the time so we store them here.
|
||||
uint16_t tile_cols;
|
||||
uint16_t tile_rows;
|
||||
|
||||
uint8_t base_q_idx;
|
||||
int8_t delta_q_y_dc;
|
||||
uint8_t diff_uv_delta;
|
||||
int8_t delta_q_u_dc;
|
||||
int8_t delta_q_u_ac;
|
||||
int8_t delta_q_v_dc;
|
||||
int8_t delta_q_v_ac;
|
||||
uint8_t using_qmatrix;
|
||||
uint8_t qm_y;
|
||||
uint8_t qm_u;
|
||||
uint8_t qm_v;
|
||||
|
||||
uint8_t segmentation_enabled;
|
||||
uint8_t segmentation_update_map;
|
||||
uint8_t segmentation_temporal_update;
|
||||
uint8_t segmentation_update_data;
|
||||
uint8_t feature_enabled[AV1_MAX_SEGMENTS][AV1_SEG_LVL_MAX];
|
||||
int16_t feature_value[AV1_MAX_SEGMENTS][AV1_SEG_LVL_MAX];
|
||||
|
||||
uint8_t delta_q_present;
|
||||
uint8_t delta_q_res;
|
||||
uint8_t delta_lf_present;
|
||||
uint8_t delta_lf_res;
|
||||
uint8_t delta_lf_multi;
|
||||
|
||||
uint8_t loop_filter_level[4];
|
||||
uint8_t loop_filter_sharpness;
|
||||
uint8_t loop_filter_delta_enabled;
|
||||
uint8_t loop_filter_delta_update;
|
||||
uint8_t update_ref_delta[AV1_TOTAL_REFS_PER_FRAME];
|
||||
int8_t loop_filter_ref_deltas[AV1_TOTAL_REFS_PER_FRAME];
|
||||
uint8_t update_mode_delta[2];
|
||||
int8_t loop_filter_mode_deltas[2];
|
||||
|
||||
uint8_t cdef_damping_minus_3;
|
||||
uint8_t cdef_bits;
|
||||
uint8_t cdef_y_pri_strength[8];
|
||||
uint8_t cdef_y_sec_strength[8];
|
||||
uint8_t cdef_uv_pri_strength[8];
|
||||
uint8_t cdef_uv_sec_strength[8];
|
||||
|
||||
uint8_t lr_type[3];
|
||||
uint8_t lr_unit_shift;
|
||||
uint8_t lr_uv_shift;
|
||||
|
||||
uint8_t tx_mode;
|
||||
uint8_t reference_select;
|
||||
uint8_t skip_mode_present;
|
||||
|
||||
uint8_t allow_warped_motion;
|
||||
uint8_t reduced_tx_set;
|
||||
|
||||
uint8_t is_global[AV1_TOTAL_REFS_PER_FRAME];
|
||||
uint8_t is_rot_zoom[AV1_TOTAL_REFS_PER_FRAME];
|
||||
uint8_t is_translation[AV1_TOTAL_REFS_PER_FRAME];
|
||||
//AV1RawSubexp gm_params[AV1_TOTAL_REFS_PER_FRAME][6];
|
||||
uint32_t gm_params[AV1_TOTAL_REFS_PER_FRAME][6];
|
||||
|
||||
AV1RawFilmGrainParams film_grain;
|
||||
} AV1RawFrameHeader;
|
||||
|
||||
typedef struct AV1RawTileData {
|
||||
uint8_t *data;
|
||||
AVBufferRef *data_ref;
|
||||
size_t data_size;
|
||||
} AV1RawTileData;
|
||||
|
||||
typedef struct AV1RawTileGroup {
|
||||
uint8_t tile_start_and_end_present_flag;
|
||||
uint16_t tg_start;
|
||||
uint16_t tg_end;
|
||||
|
||||
AV1RawTileData tile_data;
|
||||
} AV1RawTileGroup;
|
||||
|
||||
typedef struct AV1RawFrame {
|
||||
AV1RawFrameHeader header;
|
||||
AV1RawTileGroup tile_group;
|
||||
} AV1RawFrame;
|
||||
|
||||
typedef struct AV1RawTileList {
|
||||
uint8_t output_frame_width_in_tiles_minus_1;
|
||||
uint8_t output_frame_height_in_tiles_minus_1;
|
||||
uint16_t tile_count_minus_1;
|
||||
|
||||
AV1RawTileData tile_data;
|
||||
} AV1RawTileList;
|
||||
|
||||
typedef struct AV1RawMetadataHDRCLL {
|
||||
uint16_t max_cll;
|
||||
uint16_t max_fall;
|
||||
} AV1RawMetadataHDRCLL;
|
||||
|
||||
typedef struct AV1RawMetadataHDRMDCV {
|
||||
uint16_t primary_chromaticity_x[3];
|
||||
uint16_t primary_chromaticity_y[3];
|
||||
uint16_t white_point_chromaticity_x;
|
||||
uint16_t white_point_chromaticity_y;
|
||||
uint32_t luminance_max;
|
||||
uint32_t luminance_min;
|
||||
} AV1RawMetadataHDRMDCV;
|
||||
|
||||
typedef struct AV1RawMetadataScalability {
|
||||
uint8_t scalability_mode_idc;
|
||||
uint8_t spatial_layers_cnt_minus_1;
|
||||
uint8_t spatial_layer_dimensions_present_flag;
|
||||
uint8_t spatial_layer_description_present_flag;
|
||||
uint8_t temporal_group_description_present_flag;
|
||||
uint8_t scalability_structure_reserved_3bits;
|
||||
uint16_t spatial_layer_max_width[4];
|
||||
uint16_t spatial_layer_max_height[4];
|
||||
uint8_t spatial_layer_ref_id[4];
|
||||
uint8_t temporal_group_size;
|
||||
uint8_t temporal_group_temporal_id[255];
|
||||
uint8_t temporal_group_temporal_switching_up_point_flag[255];
|
||||
uint8_t temporal_group_spatial_switching_up_point_flag[255];
|
||||
uint8_t temporal_group_ref_cnt[255];
|
||||
uint8_t temporal_group_ref_pic_diff[255][7];
|
||||
} AV1RawMetadataScalability;
|
||||
|
||||
typedef struct AV1RawMetadataITUTT35 {
|
||||
uint8_t itu_t_t35_country_code;
|
||||
uint8_t itu_t_t35_country_code_extension_byte;
|
||||
|
||||
uint8_t *payload;
|
||||
AVBufferRef *payload_ref;
|
||||
size_t payload_size;
|
||||
} AV1RawMetadataITUTT35;
|
||||
|
||||
typedef struct AV1RawMetadataTimecode {
|
||||
uint8_t counting_type;
|
||||
uint8_t full_timestamp_flag;
|
||||
uint8_t discontinuity_flag;
|
||||
uint8_t cnt_dropped_flag;
|
||||
uint16_t n_frames;
|
||||
uint8_t seconds_value;
|
||||
uint8_t minutes_value;
|
||||
uint8_t hours_value;
|
||||
uint8_t seconds_flag;
|
||||
uint8_t minutes_flag;
|
||||
uint8_t hours_flag;
|
||||
uint8_t time_offset_length;
|
||||
uint32_t time_offset_value;
|
||||
} AV1RawMetadataTimecode;
|
||||
|
||||
typedef struct AV1RawMetadataUnknown {
|
||||
uint8_t *payload;
|
||||
AVBufferRef *payload_ref;
|
||||
size_t payload_size;
|
||||
} AV1RawMetadataUnknown;
|
||||
|
||||
typedef struct AV1RawMetadata {
|
||||
uint64_t metadata_type;
|
||||
union {
|
||||
AV1RawMetadataHDRCLL hdr_cll;
|
||||
AV1RawMetadataHDRMDCV hdr_mdcv;
|
||||
AV1RawMetadataScalability scalability;
|
||||
AV1RawMetadataITUTT35 itut_t35;
|
||||
AV1RawMetadataTimecode timecode;
|
||||
AV1RawMetadataUnknown unknown;
|
||||
} metadata;
|
||||
} AV1RawMetadata;
|
||||
|
||||
typedef struct AV1RawPadding {
|
||||
uint8_t *payload;
|
||||
AVBufferRef *payload_ref;
|
||||
size_t payload_size;
|
||||
} AV1RawPadding;
|
||||
|
||||
|
||||
typedef struct AV1RawOBU {
|
||||
AV1RawOBUHeader header;
|
||||
|
||||
size_t obu_size;
|
||||
|
||||
union {
|
||||
AV1RawSequenceHeader sequence_header;
|
||||
AV1RawFrameHeader frame_header;
|
||||
AV1RawFrame frame;
|
||||
AV1RawTileGroup tile_group;
|
||||
AV1RawTileList tile_list;
|
||||
AV1RawMetadata metadata;
|
||||
AV1RawPadding padding;
|
||||
} obu;
|
||||
} AV1RawOBU;
|
||||
|
||||
typedef struct AV1ReferenceFrameState {
|
||||
int valid; // RefValid
|
||||
int frame_id; // RefFrameId
|
||||
int upscaled_width; // RefUpscaledWidth
|
||||
int frame_width; // RefFrameWidth
|
||||
int frame_height; // RefFrameHeight
|
||||
int render_width; // RefRenderWidth
|
||||
int render_height; // RefRenderHeight
|
||||
int frame_type; // RefFrameType
|
||||
int subsampling_x; // RefSubsamplingX
|
||||
int subsampling_y; // RefSubsamplingY
|
||||
int bit_depth; // RefBitDepth
|
||||
int order_hint; // RefOrderHint
|
||||
|
||||
int saved_order_hints[AV1_TOTAL_REFS_PER_FRAME]; // SavedOrderHints[ref]
|
||||
|
||||
int8_t loop_filter_ref_deltas[AV1_TOTAL_REFS_PER_FRAME];
|
||||
int8_t loop_filter_mode_deltas[2];
|
||||
uint8_t feature_enabled[AV1_MAX_SEGMENTS][AV1_SEG_LVL_MAX];
|
||||
int16_t feature_value[AV1_MAX_SEGMENTS][AV1_SEG_LVL_MAX];
|
||||
} AV1ReferenceFrameState;
|
||||
|
||||
typedef struct CodedBitstreamAV1Context {
|
||||
const AVClass *class;
|
||||
|
||||
AV1RawSequenceHeader *sequence_header;
|
||||
/** A RefStruct reference backing sequence_header. */
|
||||
AV1RawOBU *sequence_header_ref;
|
||||
|
||||
int seen_frame_header;
|
||||
AVBufferRef *frame_header_ref;
|
||||
uint8_t *frame_header;
|
||||
size_t frame_header_size;
|
||||
|
||||
int temporal_id;
|
||||
int spatial_id;
|
||||
int operating_point_idc;
|
||||
|
||||
int bit_depth;
|
||||
int order_hint;
|
||||
int frame_width;
|
||||
int frame_height;
|
||||
int upscaled_width;
|
||||
int render_width;
|
||||
int render_height;
|
||||
|
||||
int num_planes;
|
||||
int coded_lossless;
|
||||
int all_lossless;
|
||||
int tile_cols;
|
||||
int tile_rows;
|
||||
int tile_num;
|
||||
|
||||
int order_hints[AV1_TOTAL_REFS_PER_FRAME]; // OrderHints
|
||||
int ref_frame_sign_bias[AV1_TOTAL_REFS_PER_FRAME]; // RefFrameSignBias
|
||||
|
||||
AV1ReferenceFrameState ref[AV1_NUM_REF_FRAMES];
|
||||
|
||||
// AVOptions
|
||||
int operating_point;
|
||||
// When writing, fix the length in bytes of the obu_size field.
|
||||
// Writing will fail with an error if an OBU larger than can be
|
||||
// represented by the fixed size is encountered.
|
||||
int fixed_obu_size_length;
|
||||
|
||||
int8_t loop_filter_ref_deltas[AV1_TOTAL_REFS_PER_FRAME];
|
||||
int8_t loop_filter_mode_deltas[2];
|
||||
uint8_t feature_enabled[AV1_MAX_SEGMENTS][AV1_SEG_LVL_MAX];
|
||||
int16_t feature_value[AV1_MAX_SEGMENTS][AV1_SEG_LVL_MAX];
|
||||
} CodedBitstreamAV1Context;
|
||||
|
||||
|
||||
#endif /* AVCODEC_CBS_AV1_H */
|
||||
137
include/libavcodec/cbs_bsf.h
Normal file
137
include/libavcodec/cbs_bsf.h
Normal file
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* 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_CBS_BSF_H
|
||||
#define AVCODEC_CBS_BSF_H
|
||||
|
||||
#include "libavutil/log.h"
|
||||
#include "libavutil/opt.h"
|
||||
|
||||
#include "bsf.h"
|
||||
#include "codec_id.h"
|
||||
#include "cbs.h"
|
||||
#include "packet.h"
|
||||
|
||||
|
||||
typedef struct CBSBSFType {
|
||||
enum AVCodecID codec_id;
|
||||
|
||||
// Name of a frame fragment in this codec (e.g. "access unit",
|
||||
// "temporal unit").
|
||||
const char *fragment_name;
|
||||
|
||||
// Name of a unit for this BSF, for use in error messages (e.g.
|
||||
// "NAL unit", "OBU").
|
||||
const char *unit_name;
|
||||
|
||||
// Update the content of a fragment with whatever metadata changes
|
||||
// are desired. The associated AVPacket is provided so that any side
|
||||
// data associated with the fragment can be inspected or edited. If
|
||||
// pkt is NULL, then an extradata header fragment is being updated.
|
||||
int (*update_fragment)(AVBSFContext *bsf, AVPacket *pkt,
|
||||
CodedBitstreamFragment *frag);
|
||||
} CBSBSFType;
|
||||
|
||||
// Common structure for all generic CBS BSF users. An instance of this
|
||||
// structure must be the first member of the BSF private context (to be
|
||||
// pointed to by AVBSFContext.priv_data).
|
||||
typedef struct CBSBSFContext {
|
||||
const AVClass *class;
|
||||
const CBSBSFType *type;
|
||||
|
||||
CodedBitstreamContext *input;
|
||||
CodedBitstreamContext *output;
|
||||
CodedBitstreamFragment fragment;
|
||||
} CBSBSFContext;
|
||||
|
||||
/**
|
||||
* Initialise generic CBS BSF setup.
|
||||
*
|
||||
* Creates the input and output CBS instances, and applies the filter to
|
||||
* the extradata on the input codecpar if any is present.
|
||||
*
|
||||
* Since it calls the update_fragment() function immediately to deal with
|
||||
* extradata, this should be called after any codec-specific setup is done
|
||||
* (probably at the end of the FFBitStreamFilter.init function).
|
||||
*/
|
||||
int ff_cbs_bsf_generic_init(AVBSFContext *bsf, const CBSBSFType *type);
|
||||
|
||||
/**
|
||||
* Close a generic CBS BSF instance.
|
||||
*
|
||||
* If no other deinitialisation is required then this function can be used
|
||||
* directly as FFBitStreamFilter.close.
|
||||
*/
|
||||
void ff_cbs_bsf_generic_close(AVBSFContext *bsf);
|
||||
|
||||
/**
|
||||
* Filter operation for CBS BSF.
|
||||
*
|
||||
* Reads the input packet into a CBS fragment, calls update_fragment() on
|
||||
* it, then writes the result to an output packet. If the input packet
|
||||
* has AV_PKT_DATA_NEW_EXTRADATA side-data associated with it then it does
|
||||
* the same thing to that new extradata to form the output side-data first.
|
||||
*
|
||||
* If the BSF does not do anything else then this function can be used
|
||||
* directly as FFBitStreamFilter.filter.
|
||||
*/
|
||||
int ff_cbs_bsf_generic_filter(AVBSFContext *bsf, AVPacket *pkt);
|
||||
|
||||
|
||||
// Options for element manipulation.
|
||||
enum {
|
||||
// Pass this element through unchanged.
|
||||
BSF_ELEMENT_PASS,
|
||||
// Insert this element, replacing any existing instances of it.
|
||||
// Associated values may be provided explicitly (as additional options)
|
||||
// or implicitly (either as side data or deduced from other parts of
|
||||
// the stream).
|
||||
BSF_ELEMENT_INSERT,
|
||||
// Remove this element if it appears in the stream.
|
||||
BSF_ELEMENT_REMOVE,
|
||||
// Extract this element to side data, so that further manipulation
|
||||
// can happen elsewhere.
|
||||
BSF_ELEMENT_EXTRACT,
|
||||
};
|
||||
|
||||
#define BSF_ELEMENT_OPTIONS_PIR(name, help, field, opt_flags) \
|
||||
{ name, help, OFFSET(field), AV_OPT_TYPE_INT, \
|
||||
{ .i64 = BSF_ELEMENT_PASS }, \
|
||||
BSF_ELEMENT_PASS, BSF_ELEMENT_REMOVE, opt_flags, .unit = name }, \
|
||||
{ "pass", NULL, 0, AV_OPT_TYPE_CONST, \
|
||||
{ .i64 = BSF_ELEMENT_PASS }, .flags = opt_flags, .unit = name }, \
|
||||
{ "insert", NULL, 0, AV_OPT_TYPE_CONST, \
|
||||
{ .i64 = BSF_ELEMENT_INSERT }, .flags = opt_flags, .unit = name }, \
|
||||
{ "remove", NULL, 0, AV_OPT_TYPE_CONST, \
|
||||
{ .i64 = BSF_ELEMENT_REMOVE }, .flags = opt_flags, .unit = name }
|
||||
|
||||
#define BSF_ELEMENT_OPTIONS_PIRE(name, help, field, opt_flags) \
|
||||
{ name, help, OFFSET(field), AV_OPT_TYPE_INT, \
|
||||
{ .i64 = BSF_ELEMENT_PASS }, \
|
||||
BSF_ELEMENT_PASS, BSF_ELEMENT_EXTRACT, opt_flags, .unit = name }, \
|
||||
{ "pass", NULL, 0, AV_OPT_TYPE_CONST, \
|
||||
{ .i64 = BSF_ELEMENT_PASS }, .flags = opt_flags, .unit = name }, \
|
||||
{ "insert", NULL, 0, AV_OPT_TYPE_CONST, \
|
||||
{ .i64 = BSF_ELEMENT_INSERT }, .flags = opt_flags, .unit = name }, \
|
||||
{ "remove", NULL, 0, AV_OPT_TYPE_CONST, \
|
||||
{ .i64 = BSF_ELEMENT_REMOVE }, .flags = opt_flags, .unit = name }, \
|
||||
{ "extract", NULL, 0, AV_OPT_TYPE_CONST, \
|
||||
{ .i64 = BSF_ELEMENT_EXTRACT }, .flags = opt_flags, .unit = name } \
|
||||
|
||||
|
||||
#endif /* AVCODEC_CBS_BSF_H */
|
||||
445
include/libavcodec/cbs_h264.h
Normal file
445
include/libavcodec/cbs_h264.h
Normal file
@@ -0,0 +1,445 @@
|
||||
/*
|
||||
* 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_CBS_H264_H
|
||||
#define AVCODEC_CBS_H264_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "cbs.h"
|
||||
#include "cbs_h2645.h"
|
||||
#include "cbs_sei.h"
|
||||
#include "h264.h"
|
||||
|
||||
|
||||
typedef struct H264RawNALUnitHeader {
|
||||
uint8_t nal_ref_idc;
|
||||
uint8_t nal_unit_type;
|
||||
|
||||
uint8_t svc_extension_flag;
|
||||
uint8_t avc_3d_extension_flag;
|
||||
} H264RawNALUnitHeader;
|
||||
|
||||
typedef struct H264RawScalingList {
|
||||
int8_t delta_scale[64];
|
||||
} H264RawScalingList;
|
||||
|
||||
typedef struct H264RawHRD {
|
||||
uint8_t cpb_cnt_minus1;
|
||||
uint8_t bit_rate_scale;
|
||||
uint8_t cpb_size_scale;
|
||||
|
||||
uint32_t bit_rate_value_minus1[H264_MAX_CPB_CNT];
|
||||
uint32_t cpb_size_value_minus1[H264_MAX_CPB_CNT];
|
||||
uint8_t cbr_flag[H264_MAX_CPB_CNT];
|
||||
|
||||
uint8_t initial_cpb_removal_delay_length_minus1;
|
||||
uint8_t cpb_removal_delay_length_minus1;
|
||||
uint8_t dpb_output_delay_length_minus1;
|
||||
uint8_t time_offset_length;
|
||||
} H264RawHRD;
|
||||
|
||||
typedef struct H264RawVUI {
|
||||
uint8_t aspect_ratio_info_present_flag;
|
||||
uint8_t aspect_ratio_idc;
|
||||
uint16_t sar_width;
|
||||
uint16_t sar_height;
|
||||
|
||||
uint8_t overscan_info_present_flag;
|
||||
uint8_t overscan_appropriate_flag;
|
||||
|
||||
uint8_t video_signal_type_present_flag;
|
||||
uint8_t video_format;
|
||||
uint8_t video_full_range_flag;
|
||||
uint8_t colour_description_present_flag;
|
||||
uint8_t colour_primaries;
|
||||
uint8_t transfer_characteristics;
|
||||
uint8_t matrix_coefficients;
|
||||
|
||||
uint8_t chroma_loc_info_present_flag;
|
||||
uint8_t chroma_sample_loc_type_top_field;
|
||||
uint8_t chroma_sample_loc_type_bottom_field;
|
||||
|
||||
uint8_t timing_info_present_flag;
|
||||
uint32_t num_units_in_tick;
|
||||
uint32_t time_scale;
|
||||
uint8_t fixed_frame_rate_flag;
|
||||
|
||||
uint8_t nal_hrd_parameters_present_flag;
|
||||
H264RawHRD nal_hrd_parameters;
|
||||
uint8_t vcl_hrd_parameters_present_flag;
|
||||
H264RawHRD vcl_hrd_parameters;
|
||||
uint8_t low_delay_hrd_flag;
|
||||
|
||||
uint8_t pic_struct_present_flag;
|
||||
|
||||
uint8_t bitstream_restriction_flag;
|
||||
uint8_t motion_vectors_over_pic_boundaries_flag;
|
||||
uint8_t max_bytes_per_pic_denom;
|
||||
uint8_t max_bits_per_mb_denom;
|
||||
uint8_t log2_max_mv_length_horizontal;
|
||||
uint8_t log2_max_mv_length_vertical;
|
||||
uint8_t max_num_reorder_frames;
|
||||
uint8_t max_dec_frame_buffering;
|
||||
} H264RawVUI;
|
||||
|
||||
typedef struct H264RawSPS {
|
||||
H264RawNALUnitHeader nal_unit_header;
|
||||
|
||||
uint8_t profile_idc;
|
||||
uint8_t constraint_set0_flag;
|
||||
uint8_t constraint_set1_flag;
|
||||
uint8_t constraint_set2_flag;
|
||||
uint8_t constraint_set3_flag;
|
||||
uint8_t constraint_set4_flag;
|
||||
uint8_t constraint_set5_flag;
|
||||
uint8_t reserved_zero_2bits;
|
||||
uint8_t level_idc;
|
||||
|
||||
uint8_t seq_parameter_set_id;
|
||||
|
||||
uint8_t chroma_format_idc;
|
||||
uint8_t separate_colour_plane_flag;
|
||||
uint8_t bit_depth_luma_minus8;
|
||||
uint8_t bit_depth_chroma_minus8;
|
||||
uint8_t qpprime_y_zero_transform_bypass_flag;
|
||||
|
||||
uint8_t seq_scaling_matrix_present_flag;
|
||||
uint8_t seq_scaling_list_present_flag[12];
|
||||
H264RawScalingList scaling_list_4x4[6];
|
||||
H264RawScalingList scaling_list_8x8[6];
|
||||
|
||||
uint8_t log2_max_frame_num_minus4;
|
||||
uint8_t pic_order_cnt_type;
|
||||
uint8_t log2_max_pic_order_cnt_lsb_minus4;
|
||||
uint8_t delta_pic_order_always_zero_flag;
|
||||
int32_t offset_for_non_ref_pic;
|
||||
int32_t offset_for_top_to_bottom_field;
|
||||
uint8_t num_ref_frames_in_pic_order_cnt_cycle;
|
||||
int32_t offset_for_ref_frame[256];
|
||||
|
||||
uint8_t max_num_ref_frames;
|
||||
uint8_t gaps_in_frame_num_allowed_flag;
|
||||
|
||||
uint16_t pic_width_in_mbs_minus1;
|
||||
uint16_t pic_height_in_map_units_minus1;
|
||||
|
||||
uint8_t frame_mbs_only_flag;
|
||||
uint8_t mb_adaptive_frame_field_flag;
|
||||
uint8_t direct_8x8_inference_flag;
|
||||
|
||||
uint8_t frame_cropping_flag;
|
||||
uint16_t frame_crop_left_offset;
|
||||
uint16_t frame_crop_right_offset;
|
||||
uint16_t frame_crop_top_offset;
|
||||
uint16_t frame_crop_bottom_offset;
|
||||
|
||||
uint8_t vui_parameters_present_flag;
|
||||
H264RawVUI vui;
|
||||
} H264RawSPS;
|
||||
|
||||
typedef struct H264RawSPSExtension {
|
||||
H264RawNALUnitHeader nal_unit_header;
|
||||
|
||||
uint8_t seq_parameter_set_id;
|
||||
|
||||
uint8_t aux_format_idc;
|
||||
uint8_t bit_depth_aux_minus8;
|
||||
uint8_t alpha_incr_flag;
|
||||
uint16_t alpha_opaque_value;
|
||||
uint16_t alpha_transparent_value;
|
||||
|
||||
uint8_t additional_extension_flag;
|
||||
} H264RawSPSExtension;
|
||||
|
||||
typedef struct H264RawPPS {
|
||||
H264RawNALUnitHeader nal_unit_header;
|
||||
|
||||
uint8_t pic_parameter_set_id;
|
||||
uint8_t seq_parameter_set_id;
|
||||
|
||||
uint8_t entropy_coding_mode_flag;
|
||||
uint8_t bottom_field_pic_order_in_frame_present_flag;
|
||||
|
||||
uint8_t num_slice_groups_minus1;
|
||||
uint8_t slice_group_map_type;
|
||||
uint16_t run_length_minus1[H264_MAX_SLICE_GROUPS];
|
||||
uint16_t top_left[H264_MAX_SLICE_GROUPS];
|
||||
uint16_t bottom_right[H264_MAX_SLICE_GROUPS];
|
||||
uint8_t slice_group_change_direction_flag;
|
||||
uint16_t slice_group_change_rate_minus1;
|
||||
uint16_t pic_size_in_map_units_minus1;
|
||||
|
||||
uint8_t *slice_group_id;
|
||||
AVBufferRef *slice_group_id_ref;
|
||||
|
||||
uint8_t num_ref_idx_l0_default_active_minus1;
|
||||
uint8_t num_ref_idx_l1_default_active_minus1;
|
||||
|
||||
uint8_t weighted_pred_flag;
|
||||
uint8_t weighted_bipred_idc;
|
||||
|
||||
int8_t pic_init_qp_minus26;
|
||||
int8_t pic_init_qs_minus26;
|
||||
int8_t chroma_qp_index_offset;
|
||||
|
||||
uint8_t deblocking_filter_control_present_flag;
|
||||
uint8_t constrained_intra_pred_flag;
|
||||
|
||||
uint8_t more_rbsp_data;
|
||||
|
||||
uint8_t redundant_pic_cnt_present_flag;
|
||||
uint8_t transform_8x8_mode_flag;
|
||||
|
||||
uint8_t pic_scaling_matrix_present_flag;
|
||||
uint8_t pic_scaling_list_present_flag[12];
|
||||
H264RawScalingList scaling_list_4x4[6];
|
||||
H264RawScalingList scaling_list_8x8[6];
|
||||
|
||||
int8_t second_chroma_qp_index_offset;
|
||||
} H264RawPPS;
|
||||
|
||||
typedef struct H264RawAUD {
|
||||
H264RawNALUnitHeader nal_unit_header;
|
||||
|
||||
uint8_t primary_pic_type;
|
||||
} H264RawAUD;
|
||||
|
||||
typedef struct H264RawSEIBufferingPeriod {
|
||||
uint8_t seq_parameter_set_id;
|
||||
struct {
|
||||
uint32_t initial_cpb_removal_delay[H264_MAX_CPB_CNT];
|
||||
uint32_t initial_cpb_removal_delay_offset[H264_MAX_CPB_CNT];
|
||||
} nal, vcl;
|
||||
} H264RawSEIBufferingPeriod;
|
||||
|
||||
typedef struct H264RawSEIPicTimestamp {
|
||||
uint8_t ct_type;
|
||||
uint8_t nuit_field_based_flag;
|
||||
uint8_t counting_type;
|
||||
uint8_t full_timestamp_flag;
|
||||
uint8_t discontinuity_flag;
|
||||
uint8_t cnt_dropped_flag;
|
||||
uint8_t n_frames;
|
||||
uint8_t seconds_flag;
|
||||
uint8_t seconds_value;
|
||||
uint8_t minutes_flag;
|
||||
uint8_t minutes_value;
|
||||
uint8_t hours_flag;
|
||||
uint8_t hours_value;
|
||||
int32_t time_offset;
|
||||
} H264RawSEIPicTimestamp;
|
||||
|
||||
typedef struct H264RawSEIPicTiming {
|
||||
uint32_t cpb_removal_delay;
|
||||
uint32_t dpb_output_delay;
|
||||
uint8_t pic_struct;
|
||||
uint8_t clock_timestamp_flag[3];
|
||||
H264RawSEIPicTimestamp timestamp[3];
|
||||
} H264RawSEIPicTiming;
|
||||
|
||||
typedef struct H264RawSEIPanScanRect {
|
||||
uint32_t pan_scan_rect_id;
|
||||
uint8_t pan_scan_rect_cancel_flag;
|
||||
uint8_t pan_scan_cnt_minus1;
|
||||
int32_t pan_scan_rect_left_offset[3];
|
||||
int32_t pan_scan_rect_right_offset[3];
|
||||
int32_t pan_scan_rect_top_offset[3];
|
||||
int32_t pan_scan_rect_bottom_offset[3];
|
||||
uint16_t pan_scan_rect_repetition_period;
|
||||
} H264RawSEIPanScanRect;
|
||||
|
||||
typedef struct H264RawSEIRecoveryPoint {
|
||||
uint16_t recovery_frame_cnt;
|
||||
uint8_t exact_match_flag;
|
||||
uint8_t broken_link_flag;
|
||||
uint8_t changing_slice_group_idc;
|
||||
} H264RawSEIRecoveryPoint;
|
||||
|
||||
typedef struct H264RawFilmGrainCharacteristics {
|
||||
uint8_t film_grain_characteristics_cancel_flag;
|
||||
uint8_t film_grain_model_id;
|
||||
uint8_t separate_colour_description_present_flag;
|
||||
uint8_t film_grain_bit_depth_luma_minus8;
|
||||
uint8_t film_grain_bit_depth_chroma_minus8;
|
||||
uint8_t film_grain_full_range_flag;
|
||||
uint8_t film_grain_colour_primaries;
|
||||
uint8_t film_grain_transfer_characteristics;
|
||||
uint8_t film_grain_matrix_coefficients;
|
||||
uint8_t blending_mode_id;
|
||||
uint8_t log2_scale_factor;
|
||||
uint8_t comp_model_present_flag[3];
|
||||
uint8_t num_intensity_intervals_minus1[3];
|
||||
uint8_t num_model_values_minus1[3];
|
||||
uint8_t intensity_interval_lower_bound[3][256];
|
||||
uint8_t intensity_interval_upper_bound[3][256];
|
||||
int16_t comp_model_value[3][256][6];
|
||||
uint8_t film_grain_characteristics_repetition_period;
|
||||
} H264RawFilmGrainCharacteristics;
|
||||
|
||||
typedef struct H264RawSEIFramePackingArrangement {
|
||||
uint32_t frame_packing_arrangement_id;
|
||||
uint8_t frame_packing_arrangement_cancel_flag;
|
||||
uint8_t frame_packing_arrangement_type;
|
||||
uint8_t quincunx_sampling_flag;
|
||||
uint8_t content_interpretation_type;
|
||||
uint8_t spatial_flipping_flag;
|
||||
uint8_t frame0_flipped_flag;
|
||||
uint8_t field_views_flag;
|
||||
uint8_t current_frame_is_frame0_flag;
|
||||
uint8_t frame0_self_contained_flag;
|
||||
uint8_t frame1_self_contained_flag;
|
||||
uint8_t frame0_grid_position_x;
|
||||
uint8_t frame0_grid_position_y;
|
||||
uint8_t frame1_grid_position_x;
|
||||
uint8_t frame1_grid_position_y;
|
||||
uint16_t frame_packing_arrangement_repetition_period;
|
||||
uint8_t frame_packing_arrangement_extension_flag;
|
||||
} H264RawSEIFramePackingArrangement;
|
||||
|
||||
typedef struct H264RawSEIDisplayOrientation {
|
||||
uint8_t display_orientation_cancel_flag;
|
||||
uint8_t hor_flip;
|
||||
uint8_t ver_flip;
|
||||
uint16_t anticlockwise_rotation;
|
||||
uint16_t display_orientation_repetition_period;
|
||||
uint8_t display_orientation_extension_flag;
|
||||
} H264RawSEIDisplayOrientation;
|
||||
|
||||
typedef struct H264RawSEI {
|
||||
H264RawNALUnitHeader nal_unit_header;
|
||||
SEIRawMessageList message_list;
|
||||
} H264RawSEI;
|
||||
|
||||
typedef struct H264RawSliceHeader {
|
||||
H264RawNALUnitHeader nal_unit_header;
|
||||
|
||||
uint32_t first_mb_in_slice;
|
||||
uint8_t slice_type;
|
||||
|
||||
uint8_t pic_parameter_set_id;
|
||||
|
||||
uint8_t colour_plane_id;
|
||||
|
||||
uint16_t frame_num;
|
||||
uint8_t field_pic_flag;
|
||||
uint8_t bottom_field_flag;
|
||||
|
||||
uint16_t idr_pic_id;
|
||||
|
||||
uint16_t pic_order_cnt_lsb;
|
||||
int32_t delta_pic_order_cnt_bottom;
|
||||
int32_t delta_pic_order_cnt[2];
|
||||
|
||||
uint8_t redundant_pic_cnt;
|
||||
uint8_t direct_spatial_mv_pred_flag;
|
||||
|
||||
uint8_t num_ref_idx_active_override_flag;
|
||||
uint8_t num_ref_idx_l0_active_minus1;
|
||||
uint8_t num_ref_idx_l1_active_minus1;
|
||||
|
||||
uint8_t ref_pic_list_modification_flag_l0;
|
||||
uint8_t ref_pic_list_modification_flag_l1;
|
||||
struct {
|
||||
uint8_t modification_of_pic_nums_idc;
|
||||
int32_t abs_diff_pic_num_minus1;
|
||||
uint8_t long_term_pic_num;
|
||||
} rplm_l0[H264_MAX_RPLM_COUNT], rplm_l1[H264_MAX_RPLM_COUNT];
|
||||
|
||||
uint8_t luma_log2_weight_denom;
|
||||
uint8_t chroma_log2_weight_denom;
|
||||
|
||||
uint8_t luma_weight_l0_flag[H264_MAX_REFS];
|
||||
int8_t luma_weight_l0[H264_MAX_REFS];
|
||||
int8_t luma_offset_l0[H264_MAX_REFS];
|
||||
uint8_t chroma_weight_l0_flag[H264_MAX_REFS];
|
||||
int8_t chroma_weight_l0[H264_MAX_REFS][2];
|
||||
int8_t chroma_offset_l0[H264_MAX_REFS][2];
|
||||
|
||||
uint8_t luma_weight_l1_flag[H264_MAX_REFS];
|
||||
int8_t luma_weight_l1[H264_MAX_REFS];
|
||||
int8_t luma_offset_l1[H264_MAX_REFS];
|
||||
uint8_t chroma_weight_l1_flag[H264_MAX_REFS];
|
||||
int8_t chroma_weight_l1[H264_MAX_REFS][2];
|
||||
int8_t chroma_offset_l1[H264_MAX_REFS][2];
|
||||
|
||||
uint8_t no_output_of_prior_pics_flag;
|
||||
uint8_t long_term_reference_flag;
|
||||
|
||||
uint8_t adaptive_ref_pic_marking_mode_flag;
|
||||
struct {
|
||||
uint8_t memory_management_control_operation;
|
||||
int32_t difference_of_pic_nums_minus1;
|
||||
uint8_t long_term_pic_num;
|
||||
uint8_t long_term_frame_idx;
|
||||
uint8_t max_long_term_frame_idx_plus1;
|
||||
} mmco[H264_MAX_MMCO_COUNT];
|
||||
|
||||
uint8_t cabac_init_idc;
|
||||
|
||||
int8_t slice_qp_delta;
|
||||
|
||||
uint8_t sp_for_switch_flag;
|
||||
int8_t slice_qs_delta;
|
||||
|
||||
uint8_t disable_deblocking_filter_idc;
|
||||
int8_t slice_alpha_c0_offset_div2;
|
||||
int8_t slice_beta_offset_div2;
|
||||
|
||||
uint16_t slice_group_change_cycle;
|
||||
} H264RawSliceHeader;
|
||||
|
||||
typedef struct H264RawSlice {
|
||||
H264RawSliceHeader header;
|
||||
|
||||
uint8_t *data;
|
||||
AVBufferRef *data_ref;
|
||||
size_t data_size;
|
||||
int data_bit_start;
|
||||
} H264RawSlice;
|
||||
|
||||
typedef struct H264RawFiller {
|
||||
H264RawNALUnitHeader nal_unit_header;
|
||||
|
||||
uint32_t filler_size;
|
||||
} H264RawFiller;
|
||||
|
||||
|
||||
typedef struct CodedBitstreamH264Context {
|
||||
// Reader/writer context in common with the H.265 implementation.
|
||||
CodedBitstreamH2645Context common;
|
||||
|
||||
// All currently available parameter sets. These are updated when
|
||||
// any parameter set NAL unit is read/written with this context.
|
||||
H264RawSPS *sps[H264_MAX_SPS_COUNT]; ///< RefStruct references
|
||||
H264RawPPS *pps[H264_MAX_PPS_COUNT]; ///< RefStruct references
|
||||
|
||||
// The currently active parameter sets. These are updated when any
|
||||
// NAL unit refers to the relevant parameter set. These pointers
|
||||
// must also be present in the arrays above.
|
||||
const H264RawSPS *active_sps;
|
||||
const H264RawPPS *active_pps;
|
||||
|
||||
// The NAL unit type of the most recent normal slice. This is required
|
||||
// to be able to read/write auxiliary slices, because IdrPicFlag is
|
||||
// otherwise unknown.
|
||||
uint8_t last_slice_nal_unit_type;
|
||||
} CodedBitstreamH264Context;
|
||||
|
||||
#endif /* AVCODEC_CBS_H264_H */
|
||||
36
include/libavcodec/cbs_h2645.h
Normal file
36
include/libavcodec/cbs_h2645.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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_CBS_H2645_H
|
||||
#define AVCODEC_CBS_H2645_H
|
||||
|
||||
#include "h2645_parse.h"
|
||||
|
||||
|
||||
typedef struct CodedBitstreamH2645Context {
|
||||
// If set, the stream being read is in MP4 (AVCC/HVCC) format. If not
|
||||
// set, the stream is assumed to be in annex B format.
|
||||
int mp4;
|
||||
// Size in bytes of the NAL length field for MP4 format.
|
||||
int nal_length_size;
|
||||
// Packet reader.
|
||||
H2645Packet read_packet;
|
||||
} CodedBitstreamH2645Context;
|
||||
|
||||
|
||||
#endif /* AVCODEC_CBS_H2645_H */
|
||||
769
include/libavcodec/cbs_h265.h
Normal file
769
include/libavcodec/cbs_h265.h
Normal file
@@ -0,0 +1,769 @@
|
||||
/*
|
||||
* 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_CBS_H265_H
|
||||
#define AVCODEC_CBS_H265_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "cbs_h2645.h"
|
||||
#include "cbs_sei.h"
|
||||
|
||||
#include "hevc/hevc.h"
|
||||
|
||||
typedef struct H265RawNALUnitHeader {
|
||||
uint8_t nal_unit_type;
|
||||
uint8_t nuh_layer_id;
|
||||
uint8_t nuh_temporal_id_plus1;
|
||||
} H265RawNALUnitHeader;
|
||||
|
||||
typedef struct H265RawProfileTierLevel {
|
||||
uint8_t general_profile_space;
|
||||
uint8_t general_tier_flag;
|
||||
uint8_t general_profile_idc;
|
||||
|
||||
uint8_t general_profile_compatibility_flag[32];
|
||||
|
||||
uint8_t general_progressive_source_flag;
|
||||
uint8_t general_interlaced_source_flag;
|
||||
uint8_t general_non_packed_constraint_flag;
|
||||
uint8_t general_frame_only_constraint_flag;
|
||||
|
||||
uint8_t general_max_12bit_constraint_flag;
|
||||
uint8_t general_max_10bit_constraint_flag;
|
||||
uint8_t general_max_8bit_constraint_flag;
|
||||
uint8_t general_max_422chroma_constraint_flag;
|
||||
uint8_t general_max_420chroma_constraint_flag;
|
||||
uint8_t general_max_monochrome_constraint_flag;
|
||||
uint8_t general_intra_constraint_flag;
|
||||
uint8_t general_one_picture_only_constraint_flag;
|
||||
uint8_t general_lower_bit_rate_constraint_flag;
|
||||
uint8_t general_max_14bit_constraint_flag;
|
||||
|
||||
uint8_t general_inbld_flag;
|
||||
|
||||
uint8_t general_level_idc;
|
||||
|
||||
uint8_t sub_layer_profile_present_flag[HEVC_MAX_SUB_LAYERS];
|
||||
uint8_t sub_layer_level_present_flag[HEVC_MAX_SUB_LAYERS];
|
||||
|
||||
uint8_t sub_layer_profile_space[HEVC_MAX_SUB_LAYERS];
|
||||
uint8_t sub_layer_tier_flag[HEVC_MAX_SUB_LAYERS];
|
||||
uint8_t sub_layer_profile_idc[HEVC_MAX_SUB_LAYERS];
|
||||
|
||||
uint8_t sub_layer_profile_compatibility_flag[HEVC_MAX_SUB_LAYERS][32];
|
||||
|
||||
uint8_t sub_layer_progressive_source_flag[HEVC_MAX_SUB_LAYERS];
|
||||
uint8_t sub_layer_interlaced_source_flag[HEVC_MAX_SUB_LAYERS];
|
||||
uint8_t sub_layer_non_packed_constraint_flag[HEVC_MAX_SUB_LAYERS];
|
||||
uint8_t sub_layer_frame_only_constraint_flag[HEVC_MAX_SUB_LAYERS];
|
||||
|
||||
uint8_t sub_layer_max_12bit_constraint_flag[HEVC_MAX_SUB_LAYERS];
|
||||
uint8_t sub_layer_max_10bit_constraint_flag[HEVC_MAX_SUB_LAYERS];
|
||||
uint8_t sub_layer_max_8bit_constraint_flag[HEVC_MAX_SUB_LAYERS];
|
||||
uint8_t sub_layer_max_422chroma_constraint_flag[HEVC_MAX_SUB_LAYERS];
|
||||
uint8_t sub_layer_max_420chroma_constraint_flag[HEVC_MAX_SUB_LAYERS];
|
||||
uint8_t sub_layer_max_monochrome_constraint_flag[HEVC_MAX_SUB_LAYERS];
|
||||
uint8_t sub_layer_intra_constraint_flag[HEVC_MAX_SUB_LAYERS];
|
||||
uint8_t sub_layer_one_picture_only_constraint_flag[HEVC_MAX_SUB_LAYERS];
|
||||
uint8_t sub_layer_lower_bit_rate_constraint_flag[HEVC_MAX_SUB_LAYERS];
|
||||
uint8_t sub_layer_max_14bit_constraint_flag[HEVC_MAX_SUB_LAYERS];
|
||||
|
||||
uint8_t sub_layer_inbld_flag[HEVC_MAX_SUB_LAYERS];
|
||||
|
||||
uint8_t sub_layer_level_idc[HEVC_MAX_SUB_LAYERS];
|
||||
} H265RawProfileTierLevel;
|
||||
|
||||
typedef struct H265RawSubLayerHRDParameters {
|
||||
uint32_t bit_rate_value_minus1[HEVC_MAX_CPB_CNT];
|
||||
uint32_t cpb_size_value_minus1[HEVC_MAX_CPB_CNT];
|
||||
uint32_t cpb_size_du_value_minus1[HEVC_MAX_CPB_CNT];
|
||||
uint32_t bit_rate_du_value_minus1[HEVC_MAX_CPB_CNT];
|
||||
uint8_t cbr_flag[HEVC_MAX_CPB_CNT];
|
||||
} H265RawSubLayerHRDParameters;
|
||||
|
||||
typedef struct H265RawHRDParameters {
|
||||
uint8_t nal_hrd_parameters_present_flag;
|
||||
uint8_t vcl_hrd_parameters_present_flag;
|
||||
|
||||
uint8_t sub_pic_hrd_params_present_flag;
|
||||
uint8_t tick_divisor_minus2;
|
||||
uint8_t du_cpb_removal_delay_increment_length_minus1;
|
||||
uint8_t sub_pic_cpb_params_in_pic_timing_sei_flag;
|
||||
uint8_t dpb_output_delay_du_length_minus1;
|
||||
|
||||
uint8_t bit_rate_scale;
|
||||
uint8_t cpb_size_scale;
|
||||
uint8_t cpb_size_du_scale;
|
||||
|
||||
uint8_t initial_cpb_removal_delay_length_minus1;
|
||||
uint8_t au_cpb_removal_delay_length_minus1;
|
||||
uint8_t dpb_output_delay_length_minus1;
|
||||
|
||||
uint8_t fixed_pic_rate_general_flag[HEVC_MAX_SUB_LAYERS];
|
||||
uint8_t fixed_pic_rate_within_cvs_flag[HEVC_MAX_SUB_LAYERS];
|
||||
uint16_t elemental_duration_in_tc_minus1[HEVC_MAX_SUB_LAYERS];
|
||||
uint8_t low_delay_hrd_flag[HEVC_MAX_SUB_LAYERS];
|
||||
uint8_t cpb_cnt_minus1[HEVC_MAX_SUB_LAYERS];
|
||||
H265RawSubLayerHRDParameters nal_sub_layer_hrd_parameters[HEVC_MAX_SUB_LAYERS];
|
||||
H265RawSubLayerHRDParameters vcl_sub_layer_hrd_parameters[HEVC_MAX_SUB_LAYERS];
|
||||
} H265RawHRDParameters;
|
||||
|
||||
typedef struct H265RawVUI {
|
||||
uint8_t aspect_ratio_info_present_flag;
|
||||
uint8_t aspect_ratio_idc;
|
||||
uint16_t sar_width;
|
||||
uint16_t sar_height;
|
||||
|
||||
uint8_t overscan_info_present_flag;
|
||||
uint8_t overscan_appropriate_flag;
|
||||
|
||||
uint8_t video_signal_type_present_flag;
|
||||
uint8_t video_format;
|
||||
uint8_t video_full_range_flag;
|
||||
uint8_t colour_description_present_flag;
|
||||
uint8_t colour_primaries;
|
||||
uint8_t transfer_characteristics;
|
||||
uint8_t matrix_coefficients;
|
||||
|
||||
uint8_t chroma_loc_info_present_flag;
|
||||
uint8_t chroma_sample_loc_type_top_field;
|
||||
uint8_t chroma_sample_loc_type_bottom_field;
|
||||
|
||||
uint8_t neutral_chroma_indication_flag;
|
||||
uint8_t field_seq_flag;
|
||||
uint8_t frame_field_info_present_flag;
|
||||
|
||||
uint8_t default_display_window_flag;
|
||||
uint16_t def_disp_win_left_offset;
|
||||
uint16_t def_disp_win_right_offset;
|
||||
uint16_t def_disp_win_top_offset;
|
||||
uint16_t def_disp_win_bottom_offset;
|
||||
|
||||
uint8_t vui_timing_info_present_flag;
|
||||
uint32_t vui_num_units_in_tick;
|
||||
uint32_t vui_time_scale;
|
||||
uint8_t vui_poc_proportional_to_timing_flag;
|
||||
uint32_t vui_num_ticks_poc_diff_one_minus1;
|
||||
uint8_t vui_hrd_parameters_present_flag;
|
||||
H265RawHRDParameters hrd_parameters;
|
||||
|
||||
uint8_t bitstream_restriction_flag;
|
||||
uint8_t tiles_fixed_structure_flag;
|
||||
uint8_t motion_vectors_over_pic_boundaries_flag;
|
||||
uint8_t restricted_ref_pic_lists_flag;
|
||||
uint16_t min_spatial_segmentation_idc;
|
||||
uint8_t max_bytes_per_pic_denom;
|
||||
uint8_t max_bits_per_min_cu_denom;
|
||||
uint8_t log2_max_mv_length_horizontal;
|
||||
uint8_t log2_max_mv_length_vertical;
|
||||
} H265RawVUI;
|
||||
|
||||
typedef struct H265RawExtensionData {
|
||||
uint8_t *data;
|
||||
AVBufferRef *data_ref;
|
||||
size_t bit_length;
|
||||
} H265RawExtensionData;
|
||||
|
||||
typedef struct H265RawVPS {
|
||||
H265RawNALUnitHeader nal_unit_header;
|
||||
|
||||
uint8_t vps_video_parameter_set_id;
|
||||
|
||||
uint8_t vps_base_layer_internal_flag;
|
||||
uint8_t vps_base_layer_available_flag;
|
||||
uint8_t vps_max_layers_minus1;
|
||||
uint8_t vps_max_sub_layers_minus1;
|
||||
uint8_t vps_temporal_id_nesting_flag;
|
||||
|
||||
H265RawProfileTierLevel profile_tier_level;
|
||||
|
||||
uint8_t vps_sub_layer_ordering_info_present_flag;
|
||||
uint8_t vps_max_dec_pic_buffering_minus1[HEVC_MAX_SUB_LAYERS];
|
||||
uint8_t vps_max_num_reorder_pics[HEVC_MAX_SUB_LAYERS];
|
||||
uint32_t vps_max_latency_increase_plus1[HEVC_MAX_SUB_LAYERS];
|
||||
|
||||
uint8_t vps_max_layer_id;
|
||||
uint16_t vps_num_layer_sets_minus1;
|
||||
uint8_t layer_id_included_flag[HEVC_MAX_LAYER_SETS][HEVC_MAX_LAYERS];
|
||||
|
||||
uint8_t vps_timing_info_present_flag;
|
||||
uint32_t vps_num_units_in_tick;
|
||||
uint32_t vps_time_scale;
|
||||
uint8_t vps_poc_proportional_to_timing_flag;
|
||||
uint32_t vps_num_ticks_poc_diff_one_minus1;
|
||||
uint16_t vps_num_hrd_parameters;
|
||||
uint16_t hrd_layer_set_idx[HEVC_MAX_LAYER_SETS];
|
||||
uint8_t cprms_present_flag[HEVC_MAX_LAYER_SETS];
|
||||
H265RawHRDParameters hrd_parameters[HEVC_MAX_LAYER_SETS];
|
||||
|
||||
uint8_t vps_extension_flag;
|
||||
H265RawExtensionData extension_data;
|
||||
} H265RawVPS;
|
||||
|
||||
typedef struct H265RawSTRefPicSet {
|
||||
uint8_t inter_ref_pic_set_prediction_flag;
|
||||
|
||||
uint8_t delta_idx_minus1;
|
||||
uint8_t delta_rps_sign;
|
||||
uint16_t abs_delta_rps_minus1;
|
||||
|
||||
uint8_t used_by_curr_pic_flag[HEVC_MAX_REFS];
|
||||
uint8_t use_delta_flag[HEVC_MAX_REFS];
|
||||
|
||||
uint8_t num_negative_pics;
|
||||
uint8_t num_positive_pics;
|
||||
uint16_t delta_poc_s0_minus1[HEVC_MAX_REFS];
|
||||
uint8_t used_by_curr_pic_s0_flag[HEVC_MAX_REFS];
|
||||
uint16_t delta_poc_s1_minus1[HEVC_MAX_REFS];
|
||||
uint8_t used_by_curr_pic_s1_flag[HEVC_MAX_REFS];
|
||||
} H265RawSTRefPicSet;
|
||||
|
||||
typedef struct H265RawScalingList {
|
||||
uint8_t scaling_list_pred_mode_flag[4][6];
|
||||
uint8_t scaling_list_pred_matrix_id_delta[4][6];
|
||||
int16_t scaling_list_dc_coef_minus8[4][6];
|
||||
int8_t scaling_list_delta_coeff[4][6][64];
|
||||
} H265RawScalingList;
|
||||
|
||||
typedef struct H265RawSPS {
|
||||
H265RawNALUnitHeader nal_unit_header;
|
||||
|
||||
uint8_t sps_video_parameter_set_id;
|
||||
|
||||
uint8_t sps_max_sub_layers_minus1;
|
||||
uint8_t sps_ext_or_max_sub_layers_minus1;
|
||||
uint8_t sps_temporal_id_nesting_flag;
|
||||
|
||||
H265RawProfileTierLevel profile_tier_level;
|
||||
|
||||
uint8_t sps_seq_parameter_set_id;
|
||||
|
||||
uint8_t update_rep_format_flag;
|
||||
uint8_t sps_rep_format_idx;
|
||||
|
||||
uint8_t chroma_format_idc;
|
||||
uint8_t separate_colour_plane_flag;
|
||||
|
||||
uint16_t pic_width_in_luma_samples;
|
||||
uint16_t pic_height_in_luma_samples;
|
||||
|
||||
uint8_t conformance_window_flag;
|
||||
uint16_t conf_win_left_offset;
|
||||
uint16_t conf_win_right_offset;
|
||||
uint16_t conf_win_top_offset;
|
||||
uint16_t conf_win_bottom_offset;
|
||||
|
||||
uint8_t bit_depth_luma_minus8;
|
||||
uint8_t bit_depth_chroma_minus8;
|
||||
|
||||
uint8_t log2_max_pic_order_cnt_lsb_minus4;
|
||||
|
||||
uint8_t sps_sub_layer_ordering_info_present_flag;
|
||||
uint8_t sps_max_dec_pic_buffering_minus1[HEVC_MAX_SUB_LAYERS];
|
||||
uint8_t sps_max_num_reorder_pics[HEVC_MAX_SUB_LAYERS];
|
||||
uint32_t sps_max_latency_increase_plus1[HEVC_MAX_SUB_LAYERS];
|
||||
|
||||
uint8_t log2_min_luma_coding_block_size_minus3;
|
||||
uint8_t log2_diff_max_min_luma_coding_block_size;
|
||||
uint8_t log2_min_luma_transform_block_size_minus2;
|
||||
uint8_t log2_diff_max_min_luma_transform_block_size;
|
||||
uint8_t max_transform_hierarchy_depth_inter;
|
||||
uint8_t max_transform_hierarchy_depth_intra;
|
||||
|
||||
uint8_t scaling_list_enabled_flag;
|
||||
uint8_t sps_infer_scaling_list_flag;
|
||||
uint8_t sps_scaling_list_ref_layer_id;
|
||||
uint8_t sps_scaling_list_data_present_flag;
|
||||
H265RawScalingList scaling_list;
|
||||
|
||||
uint8_t amp_enabled_flag;
|
||||
uint8_t sample_adaptive_offset_enabled_flag;
|
||||
|
||||
uint8_t pcm_enabled_flag;
|
||||
uint8_t pcm_sample_bit_depth_luma_minus1;
|
||||
uint8_t pcm_sample_bit_depth_chroma_minus1;
|
||||
uint8_t log2_min_pcm_luma_coding_block_size_minus3;
|
||||
uint8_t log2_diff_max_min_pcm_luma_coding_block_size;
|
||||
uint8_t pcm_loop_filter_disabled_flag;
|
||||
|
||||
uint8_t num_short_term_ref_pic_sets;
|
||||
H265RawSTRefPicSet st_ref_pic_set[HEVC_MAX_SHORT_TERM_REF_PIC_SETS];
|
||||
|
||||
uint8_t long_term_ref_pics_present_flag;
|
||||
uint8_t num_long_term_ref_pics_sps;
|
||||
uint16_t lt_ref_pic_poc_lsb_sps[HEVC_MAX_LONG_TERM_REF_PICS];
|
||||
uint8_t used_by_curr_pic_lt_sps_flag[HEVC_MAX_LONG_TERM_REF_PICS];
|
||||
|
||||
uint8_t sps_temporal_mvp_enabled_flag;
|
||||
uint8_t strong_intra_smoothing_enabled_flag;
|
||||
|
||||
uint8_t vui_parameters_present_flag;
|
||||
H265RawVUI vui;
|
||||
|
||||
uint8_t sps_extension_present_flag;
|
||||
uint8_t sps_range_extension_flag;
|
||||
uint8_t sps_multilayer_extension_flag;
|
||||
uint8_t sps_3d_extension_flag;
|
||||
uint8_t sps_scc_extension_flag;
|
||||
uint8_t sps_extension_4bits;
|
||||
|
||||
H265RawExtensionData extension_data;
|
||||
|
||||
// Range extension.
|
||||
uint8_t transform_skip_rotation_enabled_flag;
|
||||
uint8_t transform_skip_context_enabled_flag;
|
||||
uint8_t implicit_rdpcm_enabled_flag;
|
||||
uint8_t explicit_rdpcm_enabled_flag;
|
||||
uint8_t extended_precision_processing_flag;
|
||||
uint8_t intra_smoothing_disabled_flag;
|
||||
uint8_t high_precision_offsets_enabled_flag;
|
||||
uint8_t persistent_rice_adaptation_enabled_flag;
|
||||
uint8_t cabac_bypass_alignment_enabled_flag;
|
||||
|
||||
// Screen content coding extension.
|
||||
uint8_t sps_curr_pic_ref_enabled_flag;
|
||||
uint8_t palette_mode_enabled_flag;
|
||||
uint8_t palette_max_size;
|
||||
uint8_t delta_palette_max_predictor_size;
|
||||
uint8_t sps_palette_predictor_initializer_present_flag;
|
||||
uint8_t sps_num_palette_predictor_initializer_minus1;
|
||||
uint16_t sps_palette_predictor_initializers[3][128];
|
||||
|
||||
uint8_t motion_vector_resolution_control_idc;
|
||||
uint8_t intra_boundary_filtering_disable_flag;
|
||||
|
||||
// Multilayer extension.
|
||||
uint8_t inter_view_mv_vert_constraint_flag;
|
||||
} H265RawSPS;
|
||||
|
||||
typedef struct H265RawPPS {
|
||||
H265RawNALUnitHeader nal_unit_header;
|
||||
|
||||
uint8_t pps_pic_parameter_set_id;
|
||||
uint8_t pps_seq_parameter_set_id;
|
||||
|
||||
uint8_t dependent_slice_segments_enabled_flag;
|
||||
uint8_t output_flag_present_flag;
|
||||
uint8_t num_extra_slice_header_bits;
|
||||
uint8_t sign_data_hiding_enabled_flag;
|
||||
uint8_t cabac_init_present_flag;
|
||||
|
||||
uint8_t num_ref_idx_l0_default_active_minus1;
|
||||
uint8_t num_ref_idx_l1_default_active_minus1;
|
||||
|
||||
int8_t init_qp_minus26;
|
||||
|
||||
uint8_t constrained_intra_pred_flag;
|
||||
uint8_t transform_skip_enabled_flag;
|
||||
uint8_t cu_qp_delta_enabled_flag;
|
||||
uint8_t diff_cu_qp_delta_depth;
|
||||
|
||||
int8_t pps_cb_qp_offset;
|
||||
int8_t pps_cr_qp_offset;
|
||||
uint8_t pps_slice_chroma_qp_offsets_present_flag;
|
||||
|
||||
uint8_t weighted_pred_flag;
|
||||
uint8_t weighted_bipred_flag;
|
||||
|
||||
uint8_t transquant_bypass_enabled_flag;
|
||||
uint8_t tiles_enabled_flag;
|
||||
uint8_t entropy_coding_sync_enabled_flag;
|
||||
|
||||
uint8_t num_tile_columns_minus1;
|
||||
uint8_t num_tile_rows_minus1;
|
||||
uint8_t uniform_spacing_flag;
|
||||
uint16_t column_width_minus1[HEVC_MAX_TILE_COLUMNS];
|
||||
uint16_t row_height_minus1[HEVC_MAX_TILE_ROWS];
|
||||
uint8_t loop_filter_across_tiles_enabled_flag;
|
||||
|
||||
uint8_t pps_loop_filter_across_slices_enabled_flag;
|
||||
uint8_t deblocking_filter_control_present_flag;
|
||||
uint8_t deblocking_filter_override_enabled_flag;
|
||||
uint8_t pps_deblocking_filter_disabled_flag;
|
||||
int8_t pps_beta_offset_div2;
|
||||
int8_t pps_tc_offset_div2;
|
||||
|
||||
uint8_t pps_scaling_list_data_present_flag;
|
||||
H265RawScalingList scaling_list;
|
||||
|
||||
uint8_t lists_modification_present_flag;
|
||||
uint8_t log2_parallel_merge_level_minus2;
|
||||
|
||||
uint8_t slice_segment_header_extension_present_flag;
|
||||
|
||||
uint8_t pps_extension_present_flag;
|
||||
uint8_t pps_range_extension_flag;
|
||||
uint8_t pps_multilayer_extension_flag;
|
||||
uint8_t pps_3d_extension_flag;
|
||||
uint8_t pps_scc_extension_flag;
|
||||
uint8_t pps_extension_4bits;
|
||||
|
||||
H265RawExtensionData extension_data;
|
||||
|
||||
// Range extension.
|
||||
uint8_t log2_max_transform_skip_block_size_minus2;
|
||||
uint8_t cross_component_prediction_enabled_flag;
|
||||
uint8_t chroma_qp_offset_list_enabled_flag;
|
||||
uint8_t diff_cu_chroma_qp_offset_depth;
|
||||
uint8_t chroma_qp_offset_list_len_minus1;
|
||||
int8_t cb_qp_offset_list[6];
|
||||
int8_t cr_qp_offset_list[6];
|
||||
uint8_t log2_sao_offset_scale_luma;
|
||||
uint8_t log2_sao_offset_scale_chroma;
|
||||
|
||||
// Screen content coding extension.
|
||||
uint8_t pps_curr_pic_ref_enabled_flag;
|
||||
uint8_t residual_adaptive_colour_transform_enabled_flag;
|
||||
uint8_t pps_slice_act_qp_offsets_present_flag;
|
||||
int8_t pps_act_y_qp_offset_plus5;
|
||||
int8_t pps_act_cb_qp_offset_plus5;
|
||||
int8_t pps_act_cr_qp_offset_plus3;
|
||||
|
||||
uint8_t pps_palette_predictor_initializer_present_flag;
|
||||
uint8_t pps_num_palette_predictor_initializer;
|
||||
uint8_t monochrome_palette_flag;
|
||||
uint8_t luma_bit_depth_entry_minus8;
|
||||
uint8_t chroma_bit_depth_entry_minus8;
|
||||
uint16_t pps_palette_predictor_initializers[3][128];
|
||||
|
||||
// Multilayer extension.
|
||||
uint8_t poc_reset_info_present_flag;
|
||||
uint8_t pps_infer_scaling_list_flag;
|
||||
uint8_t pps_scaling_list_ref_layer_id;
|
||||
uint8_t num_ref_loc_offsets;
|
||||
uint8_t ref_loc_offset_layer_id[64];
|
||||
uint8_t scaled_ref_layer_offset_present_flag[64];
|
||||
int16_t scaled_ref_layer_left_offset[64];
|
||||
int16_t scaled_ref_layer_top_offset[64];
|
||||
int16_t scaled_ref_layer_right_offset[64];
|
||||
int16_t scaled_ref_layer_bottom_offset[64];
|
||||
uint8_t ref_region_offset_present_flag[64];
|
||||
int16_t ref_region_left_offset[64];
|
||||
int16_t ref_region_top_offset[64];
|
||||
int16_t ref_region_right_offset[64];
|
||||
int16_t ref_region_bottom_offset[64];
|
||||
uint8_t resample_phase_set_present_flag[64];
|
||||
uint8_t phase_hor_luma[64];
|
||||
uint8_t phase_ver_luma[64];
|
||||
uint8_t phase_hor_chroma_plus8[64];
|
||||
uint8_t phase_ver_chroma_plus8[64];
|
||||
uint8_t colour_mapping_enabled_flag;
|
||||
uint8_t num_cm_ref_layers_minus1;
|
||||
uint8_t cm_ref_layer_id[62];
|
||||
uint8_t cm_octant_depth;
|
||||
uint8_t cm_y_part_num_log2;
|
||||
uint8_t luma_bit_depth_cm_input_minus8;
|
||||
uint8_t chroma_bit_depth_cm_input_minus8;
|
||||
uint8_t luma_bit_depth_cm_output_minus8;
|
||||
uint8_t chroma_bit_depth_cm_output_minus8;
|
||||
uint8_t cm_res_quant_bits;
|
||||
uint8_t cm_delta_flc_bits_minus1;
|
||||
int16_t cm_adapt_threshold_u_delta;
|
||||
int16_t cm_adapt_threshold_v_delta;
|
||||
uint8_t split_octant_flag[2];
|
||||
uint8_t coded_res_flag[12][2][2][4];
|
||||
uint8_t res_coeff_q[12][2][2][4][3];
|
||||
uint32_t res_coeff_s[12][2][2][4][3];
|
||||
uint8_t res_coeff_r[12][2][2][4][3];
|
||||
} H265RawPPS;
|
||||
|
||||
typedef struct H265RawAUD {
|
||||
H265RawNALUnitHeader nal_unit_header;
|
||||
|
||||
uint8_t pic_type;
|
||||
} H265RawAUD;
|
||||
|
||||
typedef struct H265RawSliceHeader {
|
||||
H265RawNALUnitHeader nal_unit_header;
|
||||
|
||||
uint8_t first_slice_segment_in_pic_flag;
|
||||
uint8_t no_output_of_prior_pics_flag;
|
||||
uint8_t slice_pic_parameter_set_id;
|
||||
|
||||
uint8_t dependent_slice_segment_flag;
|
||||
uint16_t slice_segment_address;
|
||||
|
||||
uint8_t slice_reserved_flag[8];
|
||||
uint8_t slice_type;
|
||||
|
||||
uint8_t pic_output_flag;
|
||||
uint8_t colour_plane_id;
|
||||
|
||||
uint16_t slice_pic_order_cnt_lsb;
|
||||
|
||||
uint8_t short_term_ref_pic_set_sps_flag;
|
||||
H265RawSTRefPicSet short_term_ref_pic_set;
|
||||
uint8_t short_term_ref_pic_set_idx;
|
||||
|
||||
uint8_t num_long_term_sps;
|
||||
uint8_t num_long_term_pics;
|
||||
uint8_t lt_idx_sps[HEVC_MAX_REFS];
|
||||
uint8_t poc_lsb_lt[HEVC_MAX_REFS];
|
||||
uint8_t used_by_curr_pic_lt_flag[HEVC_MAX_REFS];
|
||||
uint8_t delta_poc_msb_present_flag[HEVC_MAX_REFS];
|
||||
uint32_t delta_poc_msb_cycle_lt[HEVC_MAX_REFS];
|
||||
|
||||
uint8_t slice_temporal_mvp_enabled_flag;
|
||||
|
||||
uint8_t slice_sao_luma_flag;
|
||||
uint8_t slice_sao_chroma_flag;
|
||||
|
||||
uint8_t num_ref_idx_active_override_flag;
|
||||
uint8_t num_ref_idx_l0_active_minus1;
|
||||
uint8_t num_ref_idx_l1_active_minus1;
|
||||
|
||||
uint8_t ref_pic_list_modification_flag_l0;
|
||||
uint8_t list_entry_l0[HEVC_MAX_REFS];
|
||||
uint8_t ref_pic_list_modification_flag_l1;
|
||||
uint8_t list_entry_l1[HEVC_MAX_REFS];
|
||||
|
||||
uint8_t mvd_l1_zero_flag;
|
||||
uint8_t cabac_init_flag;
|
||||
uint8_t collocated_from_l0_flag;
|
||||
uint8_t collocated_ref_idx;
|
||||
|
||||
uint8_t luma_log2_weight_denom;
|
||||
int8_t delta_chroma_log2_weight_denom;
|
||||
uint8_t luma_weight_l0_flag[HEVC_MAX_REFS];
|
||||
uint8_t chroma_weight_l0_flag[HEVC_MAX_REFS];
|
||||
int8_t delta_luma_weight_l0[HEVC_MAX_REFS];
|
||||
int16_t luma_offset_l0[HEVC_MAX_REFS];
|
||||
int8_t delta_chroma_weight_l0[HEVC_MAX_REFS][2];
|
||||
int16_t chroma_offset_l0[HEVC_MAX_REFS][2];
|
||||
uint8_t luma_weight_l1_flag[HEVC_MAX_REFS];
|
||||
uint8_t chroma_weight_l1_flag[HEVC_MAX_REFS];
|
||||
int8_t delta_luma_weight_l1[HEVC_MAX_REFS];
|
||||
int16_t luma_offset_l1[HEVC_MAX_REFS];
|
||||
int8_t delta_chroma_weight_l1[HEVC_MAX_REFS][2];
|
||||
int16_t chroma_offset_l1[HEVC_MAX_REFS][2];
|
||||
|
||||
uint8_t five_minus_max_num_merge_cand;
|
||||
uint8_t use_integer_mv_flag;
|
||||
|
||||
int8_t slice_qp_delta;
|
||||
int8_t slice_cb_qp_offset;
|
||||
int8_t slice_cr_qp_offset;
|
||||
int8_t slice_act_y_qp_offset;
|
||||
int8_t slice_act_cb_qp_offset;
|
||||
int8_t slice_act_cr_qp_offset;
|
||||
uint8_t cu_chroma_qp_offset_enabled_flag;
|
||||
|
||||
uint8_t deblocking_filter_override_flag;
|
||||
uint8_t slice_deblocking_filter_disabled_flag;
|
||||
int8_t slice_beta_offset_div2;
|
||||
int8_t slice_tc_offset_div2;
|
||||
uint8_t slice_loop_filter_across_slices_enabled_flag;
|
||||
|
||||
uint16_t num_entry_point_offsets;
|
||||
uint8_t offset_len_minus1;
|
||||
uint32_t entry_point_offset_minus1[HEVC_MAX_ENTRY_POINT_OFFSETS];
|
||||
|
||||
uint16_t slice_segment_header_extension_length;
|
||||
uint8_t slice_segment_header_extension_data_byte[256];
|
||||
} H265RawSliceHeader;
|
||||
|
||||
|
||||
typedef struct H265RawSlice {
|
||||
H265RawSliceHeader header;
|
||||
|
||||
uint8_t *data;
|
||||
AVBufferRef *data_ref;
|
||||
size_t data_size;
|
||||
int data_bit_start;
|
||||
} H265RawSlice;
|
||||
|
||||
|
||||
typedef struct H265RawSEIBufferingPeriod {
|
||||
uint8_t bp_seq_parameter_set_id;
|
||||
uint8_t irap_cpb_params_present_flag;
|
||||
uint32_t cpb_delay_offset;
|
||||
uint32_t dpb_delay_offset;
|
||||
uint8_t concatenation_flag;
|
||||
uint32_t au_cpb_removal_delay_delta_minus1;
|
||||
|
||||
uint32_t nal_initial_cpb_removal_delay[HEVC_MAX_CPB_CNT];
|
||||
uint32_t nal_initial_cpb_removal_offset[HEVC_MAX_CPB_CNT];
|
||||
uint32_t nal_initial_alt_cpb_removal_delay[HEVC_MAX_CPB_CNT];
|
||||
uint32_t nal_initial_alt_cpb_removal_offset[HEVC_MAX_CPB_CNT];
|
||||
|
||||
uint32_t vcl_initial_cpb_removal_delay[HEVC_MAX_CPB_CNT];
|
||||
uint32_t vcl_initial_cpb_removal_offset[HEVC_MAX_CPB_CNT];
|
||||
uint32_t vcl_initial_alt_cpb_removal_delay[HEVC_MAX_CPB_CNT];
|
||||
uint32_t vcl_initial_alt_cpb_removal_offset[HEVC_MAX_CPB_CNT];
|
||||
|
||||
uint8_t use_alt_cpb_params_flag;
|
||||
} H265RawSEIBufferingPeriod;
|
||||
|
||||
typedef struct H265RawSEIPicTiming {
|
||||
uint8_t pic_struct;
|
||||
uint8_t source_scan_type;
|
||||
uint8_t duplicate_flag;
|
||||
|
||||
uint32_t au_cpb_removal_delay_minus1;
|
||||
uint32_t pic_dpb_output_delay;
|
||||
uint32_t pic_dpb_output_du_delay;
|
||||
|
||||
uint16_t num_decoding_units_minus1;
|
||||
uint8_t du_common_cpb_removal_delay_flag;
|
||||
uint32_t du_common_cpb_removal_delay_increment_minus1;
|
||||
uint16_t num_nalus_in_du_minus1[HEVC_MAX_SLICE_SEGMENTS];
|
||||
uint32_t du_cpb_removal_delay_increment_minus1[HEVC_MAX_SLICE_SEGMENTS];
|
||||
} H265RawSEIPicTiming;
|
||||
|
||||
typedef struct H265RawSEIPanScanRect {
|
||||
uint32_t pan_scan_rect_id;
|
||||
uint8_t pan_scan_rect_cancel_flag;
|
||||
uint8_t pan_scan_cnt_minus1;
|
||||
int32_t pan_scan_rect_left_offset[3];
|
||||
int32_t pan_scan_rect_right_offset[3];
|
||||
int32_t pan_scan_rect_top_offset[3];
|
||||
int32_t pan_scan_rect_bottom_offset[3];
|
||||
uint16_t pan_scan_rect_persistence_flag;
|
||||
} H265RawSEIPanScanRect;
|
||||
|
||||
typedef struct H265RawSEIRecoveryPoint {
|
||||
int16_t recovery_poc_cnt;
|
||||
uint8_t exact_match_flag;
|
||||
uint8_t broken_link_flag;
|
||||
} H265RawSEIRecoveryPoint;
|
||||
|
||||
typedef struct H265RawFilmGrainCharacteristics {
|
||||
uint8_t film_grain_characteristics_cancel_flag;
|
||||
uint8_t film_grain_model_id;
|
||||
uint8_t separate_colour_description_present_flag;
|
||||
uint8_t film_grain_bit_depth_luma_minus8;
|
||||
uint8_t film_grain_bit_depth_chroma_minus8;
|
||||
uint8_t film_grain_full_range_flag;
|
||||
uint8_t film_grain_colour_primaries;
|
||||
uint8_t film_grain_transfer_characteristics;
|
||||
uint8_t film_grain_matrix_coeffs;
|
||||
uint8_t blending_mode_id;
|
||||
uint8_t log2_scale_factor;
|
||||
uint8_t comp_model_present_flag[3];
|
||||
uint8_t num_intensity_intervals_minus1[3];
|
||||
uint8_t num_model_values_minus1[3];
|
||||
uint8_t intensity_interval_lower_bound[3][256];
|
||||
uint8_t intensity_interval_upper_bound[3][256];
|
||||
int16_t comp_model_value[3][256][6];
|
||||
uint8_t film_grain_characteristics_persistence_flag;
|
||||
} H265RawFilmGrainCharacteristics;
|
||||
|
||||
typedef struct H265RawSEIDisplayOrientation {
|
||||
uint8_t display_orientation_cancel_flag;
|
||||
uint8_t hor_flip;
|
||||
uint8_t ver_flip;
|
||||
uint16_t anticlockwise_rotation;
|
||||
uint16_t display_orientation_repetition_period;
|
||||
uint8_t display_orientation_persistence_flag;
|
||||
} H265RawSEIDisplayOrientation;
|
||||
|
||||
typedef struct H265RawSEIActiveParameterSets {
|
||||
uint8_t active_video_parameter_set_id;
|
||||
uint8_t self_contained_cvs_flag;
|
||||
uint8_t no_parameter_set_update_flag;
|
||||
uint8_t num_sps_ids_minus1;
|
||||
uint8_t active_seq_parameter_set_id[HEVC_MAX_SPS_COUNT];
|
||||
uint8_t layer_sps_idx[HEVC_MAX_LAYERS];
|
||||
} H265RawSEIActiveParameterSets;
|
||||
|
||||
typedef struct H265RawSEIDecodedPictureHash {
|
||||
uint8_t hash_type;
|
||||
uint8_t picture_md5[3][16];
|
||||
uint16_t picture_crc[3];
|
||||
uint32_t picture_checksum[3];
|
||||
} H265RawSEIDecodedPictureHash;
|
||||
|
||||
typedef struct H265RawSEITimeCode {
|
||||
uint8_t num_clock_ts;
|
||||
uint8_t clock_timestamp_flag[3];
|
||||
uint8_t units_field_based_flag[3];
|
||||
uint8_t counting_type[3];
|
||||
uint8_t full_timestamp_flag[3];
|
||||
uint8_t discontinuity_flag[3];
|
||||
uint8_t cnt_dropped_flag[3];
|
||||
uint16_t n_frames[3];
|
||||
uint8_t seconds_value[3];
|
||||
uint8_t minutes_value[3];
|
||||
uint8_t hours_value[3];
|
||||
uint8_t seconds_flag[3];
|
||||
uint8_t minutes_flag[3];
|
||||
uint8_t hours_flag[3];
|
||||
uint8_t time_offset_length[3];
|
||||
int32_t time_offset_value[3];
|
||||
} H265RawSEITimeCode;
|
||||
|
||||
typedef struct H265RawSEIAlphaChannelInfo {
|
||||
uint8_t alpha_channel_cancel_flag;
|
||||
uint8_t alpha_channel_use_idc;
|
||||
uint8_t alpha_channel_bit_depth_minus8;
|
||||
uint16_t alpha_transparent_value;
|
||||
uint16_t alpha_opaque_value;
|
||||
uint8_t alpha_channel_incr_flag;
|
||||
uint8_t alpha_channel_clip_flag;
|
||||
uint8_t alpha_channel_clip_type_flag;
|
||||
} H265RawSEIAlphaChannelInfo;
|
||||
|
||||
typedef struct H265RawSEI3DReferenceDisplaysInfo {
|
||||
uint8_t prec_ref_display_width;
|
||||
uint8_t ref_viewing_distance_flag;
|
||||
uint8_t prec_ref_viewing_dist;
|
||||
uint8_t num_ref_displays_minus1;
|
||||
uint16_t left_view_id[32];
|
||||
uint16_t right_view_id[32];
|
||||
uint8_t exponent_ref_display_width[32];
|
||||
uint8_t mantissa_ref_display_width[32];
|
||||
uint8_t exponent_ref_viewing_distance[32];
|
||||
uint8_t mantissa_ref_viewing_distance[32];
|
||||
uint8_t additional_shift_present_flag[32];
|
||||
uint16_t num_sample_shift_plus512[32];
|
||||
uint8_t three_dimensional_reference_displays_extension_flag;
|
||||
} H265RawSEI3DReferenceDisplaysInfo;
|
||||
|
||||
typedef struct H265RawSEI {
|
||||
H265RawNALUnitHeader nal_unit_header;
|
||||
SEIRawMessageList message_list;
|
||||
} H265RawSEI;
|
||||
|
||||
typedef struct H265RawFiller {
|
||||
H265RawNALUnitHeader nal_unit_header;
|
||||
|
||||
uint32_t filler_size;
|
||||
} H265RawFiller;
|
||||
|
||||
typedef struct CodedBitstreamH265Context {
|
||||
// Reader/writer context in common with the H.264 implementation.
|
||||
CodedBitstreamH2645Context common;
|
||||
|
||||
// All currently available parameter sets. These are updated when
|
||||
// any parameter set NAL unit is read/written with this context.
|
||||
H265RawVPS *vps[HEVC_MAX_VPS_COUNT]; ///< RefStruct references
|
||||
H265RawSPS *sps[HEVC_MAX_SPS_COUNT]; ///< RefStruct references
|
||||
H265RawPPS *pps[HEVC_MAX_PPS_COUNT]; ///< RefStruct references
|
||||
|
||||
// The currently active parameter sets. These are updated when any
|
||||
// NAL unit refers to the relevant parameter set. These pointers
|
||||
// must also be present in the arrays above.
|
||||
const H265RawVPS *active_vps;
|
||||
const H265RawSPS *active_sps;
|
||||
const H265RawPPS *active_pps;
|
||||
} CodedBitstreamH265Context;
|
||||
|
||||
|
||||
#endif /* AVCODEC_CBS_H265_H */
|
||||
869
include/libavcodec/cbs_h266.h
Normal file
869
include/libavcodec/cbs_h266.h
Normal file
@@ -0,0 +1,869 @@
|
||||
/*
|
||||
* 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_CBS_H266_H
|
||||
#define AVCODEC_CBS_H266_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "cbs_h2645.h"
|
||||
#include "cbs_sei.h"
|
||||
#include "vvc.h"
|
||||
|
||||
typedef struct H266RawNALUnitHeader {
|
||||
uint8_t nuh_layer_id;
|
||||
uint8_t nal_unit_type;
|
||||
uint8_t nuh_temporal_id_plus1;
|
||||
uint8_t nuh_reserved_zero_bit;
|
||||
} H266RawNALUnitHeader;
|
||||
|
||||
typedef struct H266GeneralConstraintsInfo {
|
||||
uint8_t gci_present_flag;
|
||||
/* general */
|
||||
uint8_t gci_intra_only_constraint_flag;
|
||||
uint8_t gci_all_layers_independent_constraint_flag;
|
||||
uint8_t gci_one_au_only_constraint_flag;
|
||||
|
||||
/* picture format */
|
||||
uint8_t gci_sixteen_minus_max_bitdepth_constraint_idc;
|
||||
uint8_t gci_three_minus_max_chroma_format_constraint_idc;
|
||||
|
||||
/* NAL unit type related */
|
||||
uint8_t gci_no_mixed_nalu_types_in_pic_constraint_flag;
|
||||
uint8_t gci_no_trail_constraint_flag;
|
||||
uint8_t gci_no_stsa_constraint_flag;
|
||||
uint8_t gci_no_rasl_constraint_flag;
|
||||
uint8_t gci_no_radl_constraint_flag;
|
||||
uint8_t gci_no_idr_constraint_flag;
|
||||
uint8_t gci_no_cra_constraint_flag;
|
||||
uint8_t gci_no_gdr_constraint_flag;
|
||||
uint8_t gci_no_aps_constraint_flag;
|
||||
uint8_t gci_no_idr_rpl_constraint_flag;
|
||||
|
||||
/* tile, slice, subpicture partitioning */
|
||||
uint8_t gci_one_tile_per_pic_constraint_flag;
|
||||
uint8_t gci_pic_header_in_slice_header_constraint_flag;
|
||||
uint8_t gci_one_slice_per_pic_constraint_flag;
|
||||
uint8_t gci_no_rectangular_slice_constraint_flag;
|
||||
uint8_t gci_one_slice_per_subpic_constraint_flag;
|
||||
uint8_t gci_no_subpic_info_constraint_flag;
|
||||
|
||||
/* CTU and block partitioning */
|
||||
uint8_t gci_three_minus_max_log2_ctu_size_constraint_idc;
|
||||
uint8_t gci_no_partition_constraints_override_constraint_flag;
|
||||
uint8_t gci_no_mtt_constraint_flag;
|
||||
uint8_t gci_no_qtbtt_dual_tree_intra_constraint_flag;
|
||||
|
||||
/* intra */
|
||||
uint8_t gci_no_palette_constraint_flag;
|
||||
uint8_t gci_no_ibc_constraint_flag;
|
||||
uint8_t gci_no_isp_constraint_flag;
|
||||
uint8_t gci_no_mrl_constraint_flag;
|
||||
uint8_t gci_no_mip_constraint_flag;
|
||||
uint8_t gci_no_cclm_constraint_flag;
|
||||
|
||||
/* inter */
|
||||
uint8_t gci_no_ref_pic_resampling_constraint_flag;
|
||||
uint8_t gci_no_res_change_in_clvs_constraint_flag;
|
||||
uint8_t gci_no_weighted_prediction_constraint_flag;
|
||||
uint8_t gci_no_ref_wraparound_constraint_flag;
|
||||
uint8_t gci_no_temporal_mvp_constraint_flag;
|
||||
uint8_t gci_no_sbtmvp_constraint_flag;
|
||||
uint8_t gci_no_amvr_constraint_flag;
|
||||
uint8_t gci_no_bdof_constraint_flag;
|
||||
uint8_t gci_no_smvd_constraint_flag;
|
||||
uint8_t gci_no_dmvr_constraint_flag;
|
||||
uint8_t gci_no_mmvd_constraint_flag;
|
||||
uint8_t gci_no_affine_motion_constraint_flag;
|
||||
uint8_t gci_no_prof_constraint_flag;
|
||||
uint8_t gci_no_bcw_constraint_flag;
|
||||
uint8_t gci_no_ciip_constraint_flag;
|
||||
uint8_t gci_no_gpm_constraint_flag;
|
||||
|
||||
/* transform, quantization, residual */
|
||||
uint8_t gci_no_luma_transform_size_64_constraint_flag;
|
||||
uint8_t gci_no_transform_skip_constraint_flag;
|
||||
uint8_t gci_no_bdpcm_constraint_flag;
|
||||
uint8_t gci_no_mts_constraint_flag;
|
||||
uint8_t gci_no_lfnst_constraint_flag;
|
||||
uint8_t gci_no_joint_cbcr_constraint_flag;
|
||||
uint8_t gci_no_sbt_constraint_flag;
|
||||
uint8_t gci_no_act_constraint_flag;
|
||||
uint8_t gci_no_explicit_scaling_list_constraint_flag;
|
||||
uint8_t gci_no_dep_quant_constraint_flag;
|
||||
uint8_t gci_no_sign_data_hiding_constraint_flag;
|
||||
uint8_t gci_no_cu_qp_delta_constraint_flag;
|
||||
uint8_t gci_no_chroma_qp_offset_constraint_flag;
|
||||
|
||||
/* loop filter */
|
||||
uint8_t gci_no_sao_constraint_flag;
|
||||
uint8_t gci_no_alf_constraint_flag;
|
||||
uint8_t gci_no_ccalf_constraint_flag;
|
||||
uint8_t gci_no_lmcs_constraint_flag;
|
||||
uint8_t gci_no_ladf_constraint_flag;
|
||||
uint8_t gci_no_virtual_boundaries_constraint_flag;
|
||||
|
||||
uint8_t gci_num_additional_bits;
|
||||
uint8_t gci_reserved_bit[255];
|
||||
|
||||
uint8_t gci_all_rap_pictures_constraint_flag;
|
||||
uint8_t gci_no_extended_precision_processing_constraint_flag;
|
||||
uint8_t gci_no_ts_residual_coding_rice_constraint_flag;
|
||||
uint8_t gci_no_rrc_rice_extension_constraint_flag;
|
||||
uint8_t gci_no_persistent_rice_adaptation_constraint_flag;
|
||||
uint8_t gci_no_reverse_last_sig_coeff_constraint_flag;
|
||||
} H266GeneralConstraintsInfo;
|
||||
|
||||
typedef struct H266RawProfileTierLevel {
|
||||
uint8_t general_profile_idc;
|
||||
uint8_t general_tier_flag;
|
||||
uint8_t general_level_idc;
|
||||
uint8_t ptl_frame_only_constraint_flag;
|
||||
uint8_t ptl_multilayer_enabled_flag;
|
||||
H266GeneralConstraintsInfo general_constraints_info;
|
||||
uint8_t ptl_sublayer_level_present_flag[VVC_MAX_SUBLAYERS - 1];
|
||||
uint8_t sublayer_level_idc[VVC_MAX_SUBLAYERS - 1];
|
||||
uint8_t ptl_num_sub_profiles;
|
||||
uint32_t general_sub_profile_idc[VVC_MAX_SUB_PROFILES];
|
||||
|
||||
uint8_t ptl_reserved_zero_bit;
|
||||
} H266RawProfileTierLevel;
|
||||
|
||||
typedef struct H266RawExtensionData {
|
||||
uint8_t *data;
|
||||
AVBufferRef *data_ref;
|
||||
size_t bit_length;
|
||||
} H266RawExtensionData;
|
||||
|
||||
typedef struct H266DpbParameters {
|
||||
uint8_t dpb_max_dec_pic_buffering_minus1[VVC_MAX_SUBLAYERS];
|
||||
uint8_t dpb_max_num_reorder_pics[VVC_MAX_SUBLAYERS];
|
||||
uint8_t dpb_max_latency_increase_plus1[VVC_MAX_SUBLAYERS];
|
||||
} H266DpbParameters;
|
||||
|
||||
typedef struct H266RefPicListStruct {
|
||||
uint8_t num_ref_entries;
|
||||
uint8_t ltrp_in_header_flag;
|
||||
uint8_t inter_layer_ref_pic_flag[VVC_MAX_REF_ENTRIES];
|
||||
uint8_t st_ref_pic_flag[VVC_MAX_REF_ENTRIES];
|
||||
uint8_t abs_delta_poc_st[VVC_MAX_REF_ENTRIES];
|
||||
uint8_t strp_entry_sign_flag[VVC_MAX_REF_ENTRIES];
|
||||
uint8_t rpls_poc_lsb_lt[VVC_MAX_REF_ENTRIES];
|
||||
uint8_t ilrp_idx[VVC_MAX_REF_ENTRIES];
|
||||
} H266RefPicListStruct;
|
||||
|
||||
typedef struct H266RefPicLists {
|
||||
uint8_t rpl_sps_flag[2];
|
||||
uint8_t rpl_idx[2];
|
||||
H266RefPicListStruct rpl_ref_list[2];
|
||||
uint16_t poc_lsb_lt[2][VVC_MAX_REF_ENTRIES];
|
||||
uint8_t delta_poc_msb_cycle_present_flag[2][VVC_MAX_REF_ENTRIES];
|
||||
uint16_t delta_poc_msb_cycle_lt[2][VVC_MAX_REF_ENTRIES];
|
||||
} H266RefPicLists;
|
||||
|
||||
typedef struct H266RawGeneralTimingHrdParameters {
|
||||
uint32_t num_units_in_tick;
|
||||
uint32_t time_scale;
|
||||
uint8_t general_nal_hrd_params_present_flag;
|
||||
uint8_t general_vcl_hrd_params_present_flag;
|
||||
uint8_t general_same_pic_timing_in_all_ols_flag;
|
||||
uint8_t general_du_hrd_params_present_flag;
|
||||
uint8_t tick_divisor_minus2;
|
||||
uint8_t bit_rate_scale;
|
||||
uint8_t cpb_size_scale;
|
||||
uint8_t cpb_size_du_scale;
|
||||
uint8_t hrd_cpb_cnt_minus1;
|
||||
} H266RawGeneralTimingHrdParameters;
|
||||
|
||||
typedef struct H266RawSubLayerHRDParameters {
|
||||
uint32_t bit_rate_value_minus1[VVC_MAX_SUBLAYERS][VVC_MAX_CPB_CNT];
|
||||
uint32_t cpb_size_value_minus1[VVC_MAX_SUBLAYERS][VVC_MAX_CPB_CNT];
|
||||
uint32_t cpb_size_du_value_minus1[VVC_MAX_SUBLAYERS][VVC_MAX_CPB_CNT];
|
||||
uint32_t bit_rate_du_value_minus1[VVC_MAX_SUBLAYERS][VVC_MAX_CPB_CNT];
|
||||
uint8_t cbr_flag[VVC_MAX_SUBLAYERS][VVC_MAX_CPB_CNT];
|
||||
} H266RawSubLayerHRDParameters;
|
||||
|
||||
typedef struct H266RawOlsTimingHrdParameters {
|
||||
uint8_t fixed_pic_rate_general_flag[VVC_MAX_SUBLAYERS];
|
||||
uint8_t fixed_pic_rate_within_cvs_flag[VVC_MAX_SUBLAYERS];
|
||||
uint16_t elemental_duration_in_tc_minus1[VVC_MAX_SUBLAYERS];
|
||||
uint8_t low_delay_hrd_flag[VVC_MAX_SUBLAYERS];
|
||||
H266RawSubLayerHRDParameters nal_sub_layer_hrd_parameters;
|
||||
H266RawSubLayerHRDParameters vcl_sub_layer_hrd_parameters;
|
||||
} H266RawOlsTimingHrdParameters;
|
||||
|
||||
typedef struct H266RawVUI {
|
||||
uint8_t vui_progressive_source_flag;
|
||||
uint8_t vui_interlaced_source_flag;
|
||||
uint8_t vui_non_packed_constraint_flag;
|
||||
uint8_t vui_non_projected_constraint_flag;
|
||||
|
||||
uint8_t vui_aspect_ratio_info_present_flag;
|
||||
uint8_t vui_aspect_ratio_constant_flag;
|
||||
uint8_t vui_aspect_ratio_idc;
|
||||
|
||||
uint16_t vui_sar_width;
|
||||
uint16_t vui_sar_height;
|
||||
|
||||
uint8_t vui_overscan_info_present_flag;
|
||||
uint8_t vui_overscan_appropriate_flag;
|
||||
|
||||
uint8_t vui_colour_description_present_flag;
|
||||
uint8_t vui_colour_primaries;
|
||||
|
||||
uint8_t vui_transfer_characteristics;
|
||||
uint8_t vui_matrix_coeffs;
|
||||
uint8_t vui_full_range_flag;
|
||||
|
||||
uint8_t vui_chroma_loc_info_present_flag;
|
||||
uint8_t vui_chroma_sample_loc_type_frame;
|
||||
uint8_t vui_chroma_sample_loc_type_top_field;
|
||||
uint8_t vui_chroma_sample_loc_type_bottom_field;
|
||||
H266RawExtensionData extension_data;
|
||||
} H266RawVUI;
|
||||
|
||||
typedef struct H266RawOPI {
|
||||
H266RawNALUnitHeader nal_unit_header;
|
||||
|
||||
uint8_t opi_ols_info_present_flag;
|
||||
uint8_t opi_htid_info_present_flag;
|
||||
uint16_t opi_ols_idx;
|
||||
uint8_t opi_htid_plus1;
|
||||
uint8_t opi_extension_flag;
|
||||
H266RawExtensionData extension_data;
|
||||
} H266RawOPI;
|
||||
|
||||
typedef struct H266RawDCI {
|
||||
H266RawNALUnitHeader nal_unit_header;
|
||||
|
||||
uint8_t dci_reserved_zero_4bits;
|
||||
uint8_t dci_num_ptls_minus1;
|
||||
H266RawProfileTierLevel dci_profile_tier_level[VVC_MAX_DCI_PTLS];
|
||||
uint8_t dci_extension_flag;
|
||||
H266RawExtensionData extension_data;
|
||||
} H266RawDCI;
|
||||
|
||||
typedef struct H266RawVPS {
|
||||
H266RawNALUnitHeader nal_unit_header;
|
||||
|
||||
uint8_t vps_video_parameter_set_id;
|
||||
uint8_t vps_max_layers_minus1;
|
||||
uint8_t vps_max_sublayers_minus1;
|
||||
uint8_t vps_default_ptl_dpb_hrd_max_tid_flag;
|
||||
uint8_t vps_all_independent_layers_flag;
|
||||
uint8_t vps_layer_id[VVC_MAX_LAYERS];
|
||||
uint8_t vps_independent_layer_flag[VVC_MAX_LAYERS];
|
||||
uint8_t vps_max_tid_ref_present_flag[VVC_MAX_LAYERS];
|
||||
uint8_t vps_direct_ref_layer_flag[VVC_MAX_LAYERS][VVC_MAX_LAYERS - 1];
|
||||
uint8_t vps_max_tid_il_ref_pics_plus1[VVC_MAX_LAYERS][VVC_MAX_LAYERS - 1];
|
||||
uint8_t vps_each_layer_is_an_ols_flag;
|
||||
uint8_t vps_ols_mode_idc;
|
||||
uint8_t vps_num_output_layer_sets_minus2;
|
||||
uint8_t vps_ols_output_layer_flag[VVC_MAX_TOTAL_NUM_OLSS][VVC_MAX_LAYERS];
|
||||
|
||||
uint8_t vps_num_ptls_minus1;
|
||||
uint8_t vps_pt_present_flag[VVC_MAX_PTLS];
|
||||
uint8_t vps_ptl_max_tid[VVC_MAX_PTLS];
|
||||
H266RawProfileTierLevel vps_profile_tier_level[VVC_MAX_PTLS];
|
||||
uint8_t vps_ols_ptl_idx[VVC_MAX_TOTAL_NUM_OLSS];
|
||||
|
||||
uint16_t vps_num_dpb_params_minus1;
|
||||
uint8_t vps_sublayer_dpb_params_present_flag;
|
||||
uint8_t vps_dpb_max_tid[VVC_MAX_TOTAL_NUM_OLSS];
|
||||
H266DpbParameters vps_dpb_params[VVC_MAX_TOTAL_NUM_OLSS];
|
||||
uint16_t vps_ols_dpb_pic_width[VVC_MAX_TOTAL_NUM_OLSS];
|
||||
uint16_t vps_ols_dpb_pic_height[VVC_MAX_TOTAL_NUM_OLSS];
|
||||
uint8_t vps_ols_dpb_chroma_format[VVC_MAX_TOTAL_NUM_OLSS];
|
||||
uint8_t vps_ols_dpb_bitdepth_minus8[VVC_MAX_TOTAL_NUM_OLSS];
|
||||
uint16_t vps_ols_dpb_params_idx[VVC_MAX_TOTAL_NUM_OLSS];
|
||||
|
||||
uint8_t vps_timing_hrd_params_present_flag;
|
||||
H266RawGeneralTimingHrdParameters vps_general_timing_hrd_parameters;
|
||||
uint8_t vps_sublayer_cpb_params_present_flag;
|
||||
uint16_t vps_num_ols_timing_hrd_params_minus1;
|
||||
uint8_t vps_hrd_max_tid[VVC_MAX_TOTAL_NUM_OLSS];
|
||||
H266RawOlsTimingHrdParameters vps_ols_timing_hrd_parameters;
|
||||
uint8_t vps_ols_timing_hrd_idx[VVC_MAX_TOTAL_NUM_OLSS];
|
||||
|
||||
uint8_t vps_extension_flag;
|
||||
H266RawExtensionData extension_data;
|
||||
} H266RawVPS;
|
||||
|
||||
typedef struct H266RawSPS {
|
||||
H266RawNALUnitHeader nal_unit_header;
|
||||
|
||||
uint8_t sps_seq_parameter_set_id;
|
||||
uint8_t sps_video_parameter_set_id;
|
||||
uint8_t sps_max_sublayers_minus1;
|
||||
uint8_t sps_chroma_format_idc;
|
||||
uint8_t sps_log2_ctu_size_minus5;
|
||||
uint8_t sps_ptl_dpb_hrd_params_present_flag;
|
||||
H266RawProfileTierLevel profile_tier_level;
|
||||
uint8_t sps_gdr_enabled_flag;
|
||||
uint8_t sps_ref_pic_resampling_enabled_flag;
|
||||
uint8_t sps_res_change_in_clvs_allowed_flag;
|
||||
|
||||
uint16_t sps_pic_width_max_in_luma_samples;
|
||||
uint16_t sps_pic_height_max_in_luma_samples;
|
||||
|
||||
uint8_t sps_conformance_window_flag;
|
||||
uint16_t sps_conf_win_left_offset;
|
||||
uint16_t sps_conf_win_right_offset;
|
||||
uint16_t sps_conf_win_top_offset;
|
||||
uint16_t sps_conf_win_bottom_offset;
|
||||
|
||||
uint8_t sps_subpic_info_present_flag;
|
||||
uint16_t sps_num_subpics_minus1;
|
||||
uint8_t sps_independent_subpics_flag;
|
||||
uint8_t sps_subpic_same_size_flag;
|
||||
uint16_t sps_subpic_ctu_top_left_x[VVC_MAX_SLICES];
|
||||
uint16_t sps_subpic_ctu_top_left_y[VVC_MAX_SLICES];
|
||||
uint16_t sps_subpic_width_minus1[VVC_MAX_SLICES];
|
||||
uint16_t sps_subpic_height_minus1[VVC_MAX_SLICES];
|
||||
uint8_t sps_subpic_treated_as_pic_flag[VVC_MAX_SLICES];
|
||||
uint8_t sps_loop_filter_across_subpic_enabled_flag[VVC_MAX_SLICES];
|
||||
uint8_t sps_subpic_id_len_minus1;
|
||||
uint8_t sps_subpic_id_mapping_explicitly_signalled_flag;
|
||||
uint8_t sps_subpic_id_mapping_present_flag;
|
||||
uint32_t sps_subpic_id[VVC_MAX_SLICES];
|
||||
|
||||
|
||||
uint8_t sps_bitdepth_minus8;
|
||||
uint8_t sps_entropy_coding_sync_enabled_flag;
|
||||
uint8_t sps_entry_point_offsets_present_flag;
|
||||
|
||||
uint8_t sps_log2_max_pic_order_cnt_lsb_minus4;
|
||||
uint8_t sps_poc_msb_cycle_flag;
|
||||
uint8_t sps_poc_msb_cycle_len_minus1;
|
||||
|
||||
uint8_t sps_num_extra_ph_bytes;
|
||||
uint8_t sps_extra_ph_bit_present_flag[16];
|
||||
|
||||
uint8_t sps_num_extra_sh_bytes;
|
||||
uint8_t sps_extra_sh_bit_present_flag[16];
|
||||
|
||||
uint8_t sps_sublayer_dpb_params_flag;
|
||||
H266DpbParameters sps_dpb_params;
|
||||
|
||||
uint8_t sps_log2_min_luma_coding_block_size_minus2;
|
||||
uint8_t sps_partition_constraints_override_enabled_flag;
|
||||
uint8_t sps_log2_diff_min_qt_min_cb_intra_slice_luma;
|
||||
uint8_t sps_max_mtt_hierarchy_depth_intra_slice_luma;
|
||||
uint8_t sps_log2_diff_max_bt_min_qt_intra_slice_luma;
|
||||
uint8_t sps_log2_diff_max_tt_min_qt_intra_slice_luma;
|
||||
|
||||
uint8_t sps_qtbtt_dual_tree_intra_flag;
|
||||
uint8_t sps_log2_diff_min_qt_min_cb_intra_slice_chroma;
|
||||
uint8_t sps_max_mtt_hierarchy_depth_intra_slice_chroma;
|
||||
uint8_t sps_log2_diff_max_bt_min_qt_intra_slice_chroma;
|
||||
uint8_t sps_log2_diff_max_tt_min_qt_intra_slice_chroma;
|
||||
|
||||
uint8_t sps_log2_diff_min_qt_min_cb_inter_slice;
|
||||
uint8_t sps_max_mtt_hierarchy_depth_inter_slice;
|
||||
uint8_t sps_log2_diff_max_bt_min_qt_inter_slice;
|
||||
uint8_t sps_log2_diff_max_tt_min_qt_inter_slice;
|
||||
|
||||
uint8_t sps_max_luma_transform_size_64_flag;
|
||||
|
||||
uint8_t sps_transform_skip_enabled_flag;
|
||||
uint8_t sps_log2_transform_skip_max_size_minus2;
|
||||
uint8_t sps_bdpcm_enabled_flag;
|
||||
|
||||
uint8_t sps_mts_enabled_flag;
|
||||
uint8_t sps_explicit_mts_intra_enabled_flag;
|
||||
uint8_t sps_explicit_mts_inter_enabled_flag;
|
||||
|
||||
uint8_t sps_lfnst_enabled_flag;
|
||||
|
||||
uint8_t sps_joint_cbcr_enabled_flag;
|
||||
uint8_t sps_same_qp_table_for_chroma_flag;
|
||||
|
||||
int8_t sps_qp_table_start_minus26[VVC_MAX_SAMPLE_ARRAYS];
|
||||
uint8_t sps_num_points_in_qp_table_minus1[VVC_MAX_SAMPLE_ARRAYS];
|
||||
uint8_t sps_delta_qp_in_val_minus1[VVC_MAX_SAMPLE_ARRAYS][VVC_MAX_POINTS_IN_QP_TABLE];
|
||||
uint8_t sps_delta_qp_diff_val[VVC_MAX_SAMPLE_ARRAYS][VVC_MAX_POINTS_IN_QP_TABLE];
|
||||
|
||||
uint8_t sps_sao_enabled_flag;
|
||||
uint8_t sps_alf_enabled_flag;
|
||||
uint8_t sps_ccalf_enabled_flag;
|
||||
uint8_t sps_lmcs_enabled_flag;
|
||||
uint8_t sps_weighted_pred_flag;
|
||||
uint8_t sps_weighted_bipred_flag;
|
||||
uint8_t sps_long_term_ref_pics_flag;
|
||||
uint8_t sps_inter_layer_prediction_enabled_flag;
|
||||
uint8_t sps_idr_rpl_present_flag;
|
||||
uint8_t sps_rpl1_same_as_rpl0_flag;
|
||||
|
||||
uint8_t sps_num_ref_pic_lists[2];
|
||||
H266RefPicListStruct sps_ref_pic_list_struct[2][VVC_MAX_REF_PIC_LISTS];
|
||||
|
||||
uint8_t sps_ref_wraparound_enabled_flag;
|
||||
uint8_t sps_temporal_mvp_enabled_flag;
|
||||
uint8_t sps_sbtmvp_enabled_flag;
|
||||
uint8_t sps_amvr_enabled_flag;
|
||||
uint8_t sps_bdof_enabled_flag;
|
||||
uint8_t sps_bdof_control_present_in_ph_flag;
|
||||
uint8_t sps_smvd_enabled_flag;
|
||||
uint8_t sps_dmvr_enabled_flag;
|
||||
uint8_t sps_dmvr_control_present_in_ph_flag;
|
||||
uint8_t sps_mmvd_enabled_flag;
|
||||
uint8_t sps_mmvd_fullpel_only_enabled_flag;
|
||||
uint8_t sps_six_minus_max_num_merge_cand;
|
||||
uint8_t sps_sbt_enabled_flag;
|
||||
uint8_t sps_affine_enabled_flag;
|
||||
uint8_t sps_five_minus_max_num_subblock_merge_cand;
|
||||
uint8_t sps_6param_affine_enabled_flag;
|
||||
uint8_t sps_affine_amvr_enabled_flag;
|
||||
uint8_t sps_affine_prof_enabled_flag;
|
||||
uint8_t sps_prof_control_present_in_ph_flag;
|
||||
uint8_t sps_bcw_enabled_flag;
|
||||
uint8_t sps_ciip_enabled_flag;
|
||||
uint8_t sps_gpm_enabled_flag;
|
||||
uint8_t sps_max_num_merge_cand_minus_max_num_gpm_cand;
|
||||
uint8_t sps_log2_parallel_merge_level_minus2;
|
||||
uint8_t sps_isp_enabled_flag;
|
||||
uint8_t sps_mrl_enabled_flag;
|
||||
uint8_t sps_mip_enabled_flag;
|
||||
uint8_t sps_cclm_enabled_flag;
|
||||
uint8_t sps_chroma_horizontal_collocated_flag;
|
||||
uint8_t sps_chroma_vertical_collocated_flag;
|
||||
uint8_t sps_palette_enabled_flag;
|
||||
uint8_t sps_act_enabled_flag;
|
||||
uint8_t sps_min_qp_prime_ts;
|
||||
uint8_t sps_ibc_enabled_flag;
|
||||
uint8_t sps_six_minus_max_num_ibc_merge_cand;
|
||||
uint8_t sps_ladf_enabled_flag;
|
||||
uint8_t sps_num_ladf_intervals_minus2;
|
||||
int8_t sps_ladf_lowest_interval_qp_offset;
|
||||
int8_t sps_ladf_qp_offset[4];
|
||||
uint16_t sps_ladf_delta_threshold_minus1[4];
|
||||
|
||||
uint8_t sps_explicit_scaling_list_enabled_flag;
|
||||
uint8_t sps_scaling_matrix_for_lfnst_disabled_flag;
|
||||
uint8_t sps_scaling_matrix_for_alternative_colour_space_disabled_flag;
|
||||
uint8_t sps_scaling_matrix_designated_colour_space_flag;
|
||||
uint8_t sps_dep_quant_enabled_flag;
|
||||
uint8_t sps_sign_data_hiding_enabled_flag;
|
||||
|
||||
uint8_t sps_virtual_boundaries_enabled_flag;
|
||||
uint8_t sps_virtual_boundaries_present_flag;
|
||||
uint8_t sps_num_ver_virtual_boundaries;
|
||||
uint16_t sps_virtual_boundary_pos_x_minus1[VVC_MAX_VBS];
|
||||
uint8_t sps_num_hor_virtual_boundaries;
|
||||
uint16_t sps_virtual_boundary_pos_y_minus1[VVC_MAX_VBS];
|
||||
|
||||
uint8_t sps_timing_hrd_params_present_flag;
|
||||
uint8_t sps_sublayer_cpb_params_present_flag;
|
||||
H266RawGeneralTimingHrdParameters sps_general_timing_hrd_parameters;
|
||||
H266RawOlsTimingHrdParameters sps_ols_timing_hrd_parameters;
|
||||
|
||||
uint8_t sps_field_seq_flag;
|
||||
uint8_t sps_vui_parameters_present_flag;
|
||||
uint16_t sps_vui_payload_size_minus1;
|
||||
H266RawVUI vui;
|
||||
|
||||
uint8_t sps_extension_flag;
|
||||
|
||||
uint8_t sps_range_extension_flag;
|
||||
uint8_t sps_extension_7bits;
|
||||
|
||||
uint8_t sps_extended_precision_flag;
|
||||
uint8_t sps_ts_residual_coding_rice_present_in_sh_flag;
|
||||
uint8_t sps_rrc_rice_extension_flag;
|
||||
uint8_t sps_persistent_rice_adaptation_enabled_flag;
|
||||
uint8_t sps_reverse_last_sig_coeff_enabled_flag;
|
||||
|
||||
H266RawExtensionData extension_data;
|
||||
|
||||
} H266RawSPS;
|
||||
|
||||
typedef struct H266RawPPS {
|
||||
H266RawNALUnitHeader nal_unit_header;
|
||||
|
||||
uint8_t pps_pic_parameter_set_id;
|
||||
uint8_t pps_seq_parameter_set_id;
|
||||
uint8_t pps_mixed_nalu_types_in_pic_flag;
|
||||
uint16_t pps_pic_width_in_luma_samples;
|
||||
uint16_t pps_pic_height_in_luma_samples;
|
||||
|
||||
uint8_t pps_conformance_window_flag;
|
||||
uint16_t pps_conf_win_left_offset;
|
||||
uint16_t pps_conf_win_right_offset;
|
||||
uint16_t pps_conf_win_top_offset;
|
||||
uint16_t pps_conf_win_bottom_offset;
|
||||
|
||||
uint8_t pps_scaling_window_explicit_signalling_flag;
|
||||
int16_t pps_scaling_win_left_offset;
|
||||
int16_t pps_scaling_win_right_offset;
|
||||
int16_t pps_scaling_win_top_offset;
|
||||
int16_t pps_scaling_win_bottom_offset;
|
||||
|
||||
uint8_t pps_output_flag_present_flag;
|
||||
uint8_t pps_no_pic_partition_flag;
|
||||
|
||||
uint8_t pps_subpic_id_mapping_present_flag;
|
||||
uint16_t pps_num_subpics_minus1;
|
||||
uint8_t pps_subpic_id_len_minus1;
|
||||
uint16_t pps_subpic_id[VVC_MAX_SLICES];
|
||||
|
||||
uint8_t pps_log2_ctu_size_minus5;
|
||||
uint8_t pps_num_exp_tile_columns_minus1;
|
||||
uint8_t pps_num_exp_tile_rows_minus1;
|
||||
uint16_t pps_tile_column_width_minus1[VVC_MAX_TILE_COLUMNS];
|
||||
uint16_t pps_tile_row_height_minus1[VVC_MAX_TILE_ROWS];
|
||||
|
||||
uint8_t pps_loop_filter_across_tiles_enabled_flag;
|
||||
uint8_t pps_rect_slice_flag;
|
||||
uint8_t pps_single_slice_per_subpic_flag;
|
||||
|
||||
uint16_t pps_num_slices_in_pic_minus1;
|
||||
uint8_t pps_tile_idx_delta_present_flag;
|
||||
uint16_t pps_slice_width_in_tiles_minus1[VVC_MAX_SLICES];
|
||||
uint16_t pps_slice_height_in_tiles_minus1[VVC_MAX_SLICES];
|
||||
uint16_t pps_num_exp_slices_in_tile[VVC_MAX_SLICES];
|
||||
uint16_t pps_exp_slice_height_in_ctus_minus1[VVC_MAX_SLICES][VVC_MAX_TILE_ROWS];
|
||||
int16_t pps_tile_idx_delta_val[VVC_MAX_SLICES];
|
||||
|
||||
uint8_t pps_loop_filter_across_slices_enabled_flag;
|
||||
uint8_t pps_cabac_init_present_flag;
|
||||
uint8_t pps_num_ref_idx_default_active_minus1[2];
|
||||
uint8_t pps_rpl1_idx_present_flag;
|
||||
uint8_t pps_weighted_pred_flag;
|
||||
uint8_t pps_weighted_bipred_flag;
|
||||
uint8_t pps_ref_wraparound_enabled_flag;
|
||||
uint16_t pps_pic_width_minus_wraparound_offset;
|
||||
int8_t pps_init_qp_minus26;
|
||||
uint8_t pps_cu_qp_delta_enabled_flag;
|
||||
uint8_t pps_chroma_tool_offsets_present_flag;
|
||||
int8_t pps_cb_qp_offset;
|
||||
int8_t pps_cr_qp_offset;
|
||||
uint8_t pps_joint_cbcr_qp_offset_present_flag;
|
||||
int8_t pps_joint_cbcr_qp_offset_value;
|
||||
uint8_t pps_slice_chroma_qp_offsets_present_flag;
|
||||
uint8_t pps_cu_chroma_qp_offset_list_enabled_flag;
|
||||
uint8_t pps_chroma_qp_offset_list_len_minus1;
|
||||
int8_t pps_cb_qp_offset_list[6];
|
||||
int8_t pps_cr_qp_offset_list[6];
|
||||
int8_t pps_joint_cbcr_qp_offset_list[6];
|
||||
uint8_t pps_deblocking_filter_control_present_flag;
|
||||
uint8_t pps_deblocking_filter_override_enabled_flag;
|
||||
uint8_t pps_deblocking_filter_disabled_flag;
|
||||
uint8_t pps_dbf_info_in_ph_flag;
|
||||
|
||||
int8_t pps_luma_beta_offset_div2;
|
||||
int8_t pps_luma_tc_offset_div2;
|
||||
int8_t pps_cb_beta_offset_div2;
|
||||
int8_t pps_cb_tc_offset_div2;
|
||||
int8_t pps_cr_beta_offset_div2;
|
||||
int8_t pps_cr_tc_offset_div2;
|
||||
|
||||
uint8_t pps_rpl_info_in_ph_flag;
|
||||
uint8_t pps_sao_info_in_ph_flag;
|
||||
uint8_t pps_alf_info_in_ph_flag;
|
||||
uint8_t pps_wp_info_in_ph_flag;
|
||||
uint8_t pps_qp_delta_info_in_ph_flag;
|
||||
|
||||
uint8_t pps_picture_header_extension_present_flag;
|
||||
uint8_t pps_slice_header_extension_present_flag;
|
||||
uint8_t pps_extension_flag;
|
||||
H266RawExtensionData extension_data;
|
||||
|
||||
//calculated value;
|
||||
uint16_t num_tile_columns;
|
||||
uint16_t num_tile_rows;
|
||||
uint16_t num_tiles_in_pic;
|
||||
uint16_t slice_height_in_ctus[VVC_MAX_SLICES]; ///< sliceHeightInCtus
|
||||
uint16_t num_slices_in_subpic[VVC_MAX_SLICES]; ///< NumSlicesInSubpic
|
||||
uint16_t sub_pic_id_val[VVC_MAX_SLICES]; ///< SubpicIdVal
|
||||
uint16_t col_width_val[VVC_MAX_TILE_COLUMNS]; ///< ColWidthVal
|
||||
uint16_t row_height_val[VVC_MAX_TILE_ROWS]; ///< RowHeightVal
|
||||
} H266RawPPS;
|
||||
|
||||
typedef struct H266RawAPS {
|
||||
H266RawNALUnitHeader nal_unit_header;
|
||||
uint8_t aps_params_type;
|
||||
uint8_t aps_adaptation_parameter_set_id;
|
||||
uint8_t aps_chroma_present_flag;
|
||||
|
||||
uint8_t alf_luma_filter_signal_flag;
|
||||
uint8_t alf_chroma_filter_signal_flag;
|
||||
uint8_t alf_cc_cb_filter_signal_flag;
|
||||
uint8_t alf_cc_cr_filter_signal_flag;
|
||||
uint8_t alf_luma_clip_flag;
|
||||
uint8_t alf_luma_num_filters_signalled_minus1;
|
||||
uint8_t alf_luma_coeff_delta_idx[VVC_NUM_ALF_FILTERS];
|
||||
uint8_t alf_luma_coeff_abs[VVC_NUM_ALF_FILTERS][12];
|
||||
uint8_t alf_luma_coeff_sign[VVC_NUM_ALF_FILTERS][12];
|
||||
uint8_t alf_luma_clip_idx[VVC_NUM_ALF_FILTERS][12];
|
||||
uint8_t alf_chroma_clip_flag;
|
||||
uint8_t alf_chroma_num_alt_filters_minus1;
|
||||
uint8_t alf_chroma_coeff_abs[8][6];
|
||||
uint8_t alf_chroma_coeff_sign[8][6];
|
||||
uint8_t alf_chroma_clip_idx[8][6];
|
||||
uint8_t alf_cc_cb_filters_signalled_minus1;
|
||||
uint8_t alf_cc_cb_mapped_coeff_abs[4][7];
|
||||
uint8_t alf_cc_cb_coeff_sign[4][7];
|
||||
uint8_t alf_cc_cr_filters_signalled_minus1;
|
||||
uint8_t alf_cc_cr_mapped_coeff_abs[4][7];
|
||||
uint8_t alf_cc_cr_coeff_sign[4][7];
|
||||
|
||||
uint8_t scaling_list_copy_mode_flag[28];
|
||||
uint8_t scaling_list_pred_mode_flag[28];
|
||||
uint8_t scaling_list_pred_id_delta[28];
|
||||
int8_t scaling_list_dc_coef[14];
|
||||
int8_t scaling_list_delta_coef[28][64];
|
||||
|
||||
uint8_t lmcs_min_bin_idx;
|
||||
uint8_t lmcs_delta_max_bin_idx;
|
||||
uint8_t lmcs_delta_cw_prec_minus1;
|
||||
uint16_t lmcs_delta_abs_cw[16];
|
||||
uint8_t lmcs_delta_sign_cw_flag[16];
|
||||
uint8_t lmcs_delta_abs_crs;
|
||||
uint8_t lmcs_delta_sign_crs_flag;
|
||||
|
||||
uint8_t aps_extension_flag;
|
||||
H266RawExtensionData extension_data;
|
||||
} H266RawAPS;
|
||||
|
||||
typedef struct H266RawAUD {
|
||||
H266RawNALUnitHeader nal_unit_header;
|
||||
uint8_t aud_irap_or_gdr_flag;
|
||||
uint8_t aud_pic_type;
|
||||
} H266RawAUD;
|
||||
|
||||
typedef struct H266RawPredWeightTable {
|
||||
uint8_t luma_log2_weight_denom;
|
||||
int8_t delta_chroma_log2_weight_denom;
|
||||
|
||||
uint8_t num_l0_weights;
|
||||
uint8_t luma_weight_l0_flag[15];
|
||||
uint8_t chroma_weight_l0_flag[15];
|
||||
int8_t delta_luma_weight_l0[15];
|
||||
int8_t luma_offset_l0[15];
|
||||
int8_t delta_chroma_weight_l0[15][2];
|
||||
int16_t delta_chroma_offset_l0[15][2];
|
||||
|
||||
uint8_t num_l1_weights;
|
||||
uint8_t luma_weight_l1_flag[15];
|
||||
uint8_t chroma_weight_l1_flag[15];
|
||||
int8_t delta_luma_weight_l1[15];
|
||||
int8_t luma_offset_l1[15];
|
||||
int8_t delta_chroma_weight_l1[15][2];
|
||||
int16_t delta_chroma_offset_l1[15][2];
|
||||
|
||||
uint8_t num_weights_l0; ///< NumWeightsL0
|
||||
uint8_t num_weights_l1; ///< NumWeightsL1
|
||||
} H266RawPredWeightTable;
|
||||
|
||||
typedef struct H266RawPictureHeader {
|
||||
uint8_t ph_gdr_or_irap_pic_flag;
|
||||
uint8_t ph_non_ref_pic_flag;
|
||||
uint8_t ph_gdr_pic_flag;
|
||||
uint8_t ph_inter_slice_allowed_flag;
|
||||
uint8_t ph_intra_slice_allowed_flag;
|
||||
uint8_t ph_pic_parameter_set_id;
|
||||
uint16_t ph_pic_order_cnt_lsb;
|
||||
uint8_t ph_recovery_poc_cnt;
|
||||
uint8_t ph_extra_bit[16];
|
||||
uint8_t ph_poc_msb_cycle_present_flag;
|
||||
uint8_t ph_poc_msb_cycle_val;
|
||||
|
||||
uint8_t ph_alf_enabled_flag;
|
||||
uint8_t ph_num_alf_aps_ids_luma;
|
||||
uint8_t ph_alf_aps_id_luma[8];
|
||||
uint8_t ph_alf_cb_enabled_flag;
|
||||
uint8_t ph_alf_cr_enabled_flag;
|
||||
uint8_t ph_alf_aps_id_chroma;
|
||||
uint8_t ph_alf_cc_cb_enabled_flag;
|
||||
uint8_t ph_alf_cc_cb_aps_id;
|
||||
uint8_t ph_alf_cc_cr_enabled_flag;
|
||||
uint8_t ph_alf_cc_cr_aps_id;
|
||||
|
||||
uint8_t ph_lmcs_enabled_flag;
|
||||
uint8_t ph_lmcs_aps_id;
|
||||
uint8_t ph_chroma_residual_scale_flag;
|
||||
uint8_t ph_explicit_scaling_list_enabled_flag;
|
||||
uint8_t ph_scaling_list_aps_id;
|
||||
|
||||
uint8_t ph_virtual_boundaries_present_flag;
|
||||
uint8_t ph_num_ver_virtual_boundaries;
|
||||
uint16_t ph_virtual_boundary_pos_x_minus1[VVC_MAX_VBS];
|
||||
uint8_t ph_num_hor_virtual_boundaries;
|
||||
uint16_t ph_virtual_boundary_pos_y_minus1[VVC_MAX_VBS];
|
||||
|
||||
uint8_t ph_pic_output_flag;
|
||||
H266RefPicLists ph_ref_pic_lists;
|
||||
|
||||
uint8_t ph_partition_constraints_override_flag;
|
||||
|
||||
uint8_t ph_log2_diff_min_qt_min_cb_intra_slice_luma;
|
||||
uint8_t ph_max_mtt_hierarchy_depth_intra_slice_luma;
|
||||
uint8_t ph_log2_diff_max_bt_min_qt_intra_slice_luma;
|
||||
uint8_t ph_log2_diff_max_tt_min_qt_intra_slice_luma;
|
||||
uint8_t ph_log2_diff_min_qt_min_cb_intra_slice_chroma;
|
||||
|
||||
uint8_t ph_max_mtt_hierarchy_depth_intra_slice_chroma;
|
||||
uint8_t ph_log2_diff_max_bt_min_qt_intra_slice_chroma;
|
||||
uint8_t ph_log2_diff_max_tt_min_qt_intra_slice_chroma;
|
||||
|
||||
uint8_t ph_cu_qp_delta_subdiv_intra_slice;
|
||||
uint8_t ph_cu_chroma_qp_offset_subdiv_intra_slice;
|
||||
|
||||
uint8_t ph_log2_diff_min_qt_min_cb_inter_slice;
|
||||
uint8_t ph_max_mtt_hierarchy_depth_inter_slice;
|
||||
uint8_t ph_log2_diff_max_bt_min_qt_inter_slice;
|
||||
uint8_t ph_log2_diff_max_tt_min_qt_inter_slice;
|
||||
uint8_t ph_cu_qp_delta_subdiv_inter_slice;
|
||||
uint8_t ph_cu_chroma_qp_offset_subdiv_inter_slice;
|
||||
|
||||
uint8_t ph_temporal_mvp_enabled_flag;
|
||||
uint8_t ph_collocated_from_l0_flag;
|
||||
uint8_t ph_collocated_ref_idx;
|
||||
uint8_t ph_mmvd_fullpel_only_flag;
|
||||
uint8_t ph_mvd_l1_zero_flag;
|
||||
uint8_t ph_bdof_disabled_flag;
|
||||
uint8_t ph_dmvr_disabled_flag;
|
||||
uint8_t ph_prof_disabled_flag;
|
||||
|
||||
H266RawPredWeightTable ph_pred_weight_table;
|
||||
|
||||
int8_t ph_qp_delta;
|
||||
uint8_t ph_joint_cbcr_sign_flag;
|
||||
uint8_t ph_sao_luma_enabled_flag;
|
||||
uint8_t ph_sao_chroma_enabled_flag;
|
||||
|
||||
uint8_t ph_deblocking_params_present_flag;
|
||||
uint8_t ph_deblocking_filter_disabled_flag;
|
||||
int8_t ph_luma_beta_offset_div2;
|
||||
int8_t ph_luma_tc_offset_div2;
|
||||
int8_t ph_cb_beta_offset_div2;
|
||||
int8_t ph_cb_tc_offset_div2;
|
||||
int8_t ph_cr_beta_offset_div2;
|
||||
int8_t ph_cr_tc_offset_div2;
|
||||
|
||||
uint8_t ph_extension_length;
|
||||
uint8_t ph_extension_data_byte[256];
|
||||
} H266RawPictureHeader;
|
||||
|
||||
typedef struct H266RawPH {
|
||||
H266RawNALUnitHeader nal_unit_header;
|
||||
H266RawPictureHeader ph_picture_header;
|
||||
} H266RawPH;
|
||||
|
||||
typedef struct H266RawSliceHeader {
|
||||
H266RawNALUnitHeader nal_unit_header;
|
||||
uint8_t sh_picture_header_in_slice_header_flag;
|
||||
H266RawPictureHeader sh_picture_header;
|
||||
|
||||
uint16_t sh_subpic_id;
|
||||
uint16_t sh_slice_address;
|
||||
uint8_t sh_extra_bit[16];
|
||||
uint8_t sh_num_tiles_in_slice_minus1;
|
||||
uint8_t sh_slice_type;
|
||||
uint8_t sh_no_output_of_prior_pics_flag;
|
||||
|
||||
uint8_t sh_alf_enabled_flag;
|
||||
uint8_t sh_num_alf_aps_ids_luma;
|
||||
uint8_t sh_alf_aps_id_luma[8];
|
||||
uint8_t sh_alf_cb_enabled_flag;
|
||||
uint8_t sh_alf_cr_enabled_flag;
|
||||
uint8_t sh_alf_aps_id_chroma;
|
||||
uint8_t sh_alf_cc_cb_enabled_flag;
|
||||
uint8_t sh_alf_cc_cb_aps_id;
|
||||
uint8_t sh_alf_cc_cr_enabled_flag;
|
||||
uint8_t sh_alf_cc_cr_aps_id;
|
||||
|
||||
uint8_t sh_lmcs_used_flag;
|
||||
uint8_t sh_explicit_scaling_list_used_flag;
|
||||
|
||||
H266RefPicLists sh_ref_pic_lists;
|
||||
|
||||
uint8_t sh_num_ref_idx_active_override_flag;
|
||||
uint8_t sh_num_ref_idx_active_minus1[2];
|
||||
uint8_t sh_cabac_init_flag;
|
||||
uint8_t sh_collocated_from_l0_flag;
|
||||
uint8_t sh_collocated_ref_idx;
|
||||
|
||||
H266RawPredWeightTable sh_pred_weight_table;
|
||||
|
||||
int8_t sh_qp_delta;
|
||||
int8_t sh_cb_qp_offset;
|
||||
int8_t sh_cr_qp_offset;
|
||||
int8_t sh_joint_cbcr_qp_offset;
|
||||
uint8_t sh_cu_chroma_qp_offset_enabled_flag;
|
||||
|
||||
uint8_t sh_sao_luma_used_flag;
|
||||
uint8_t sh_sao_chroma_used_flag;
|
||||
|
||||
uint8_t sh_deblocking_params_present_flag;
|
||||
uint8_t sh_deblocking_filter_disabled_flag;
|
||||
int8_t sh_luma_beta_offset_div2;
|
||||
int8_t sh_luma_tc_offset_div2;
|
||||
int8_t sh_cb_beta_offset_div2;
|
||||
int8_t sh_cb_tc_offset_div2;
|
||||
int8_t sh_cr_beta_offset_div2;
|
||||
int8_t sh_cr_tc_offset_div2;
|
||||
uint8_t sh_dep_quant_used_flag;
|
||||
|
||||
uint8_t sh_sign_data_hiding_used_flag;
|
||||
uint8_t sh_ts_residual_coding_disabled_flag;
|
||||
uint8_t sh_ts_residual_coding_rice_idx_minus1;
|
||||
uint8_t sh_reverse_last_sig_coeff_flag;
|
||||
uint16_t sh_slice_header_extension_length;
|
||||
uint8_t sh_slice_header_extension_data_byte[256];
|
||||
|
||||
uint8_t sh_entry_offset_len_minus1;
|
||||
uint32_t sh_entry_point_offset_minus1[VVC_MAX_ENTRY_POINTS];
|
||||
|
||||
// derived values
|
||||
uint16_t curr_subpic_idx; ///< CurrSubpicIdx
|
||||
uint32_t num_entry_points; ///< NumEntryPoints
|
||||
uint8_t num_ref_idx_active[2]; ///< NumRefIdxActive[]
|
||||
|
||||
} H266RawSliceHeader;
|
||||
|
||||
typedef struct H266RawSlice {
|
||||
H266RawSliceHeader header;
|
||||
|
||||
uint8_t *data;
|
||||
AVBufferRef *data_ref;
|
||||
size_t header_size;
|
||||
size_t data_size;
|
||||
int data_bit_start;
|
||||
} H266RawSlice;
|
||||
|
||||
typedef struct H266RawSEI {
|
||||
H266RawNALUnitHeader nal_unit_header;
|
||||
SEIRawMessageList message_list;
|
||||
} H266RawSEI;
|
||||
|
||||
typedef struct CodedBitstreamH266Context {
|
||||
// Reader/writer context in common with the H.264 implementation.
|
||||
CodedBitstreamH2645Context common;
|
||||
|
||||
// All currently available parameter sets. These are updated when
|
||||
// any parameter set NAL unit is read/written with this context.
|
||||
H266RawVPS *vps[VVC_MAX_VPS_COUNT]; ///< RefStruct references
|
||||
H266RawSPS *sps[VVC_MAX_SPS_COUNT]; ///< RefStruct references
|
||||
H266RawPPS *pps[VVC_MAX_PPS_COUNT]; ///< RefStruct references
|
||||
H266RawPictureHeader *ph;
|
||||
void *ph_ref; ///< RefStruct reference backing ph above
|
||||
} CodedBitstreamH266Context;
|
||||
|
||||
#endif /* AVCODEC_CBS_H266_H */
|
||||
348
include/libavcodec/cbs_internal.h
Normal file
348
include/libavcodec/cbs_internal.h
Normal file
@@ -0,0 +1,348 @@
|
||||
/*
|
||||
* 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_CBS_INTERNAL_H
|
||||
#define AVCODEC_CBS_INTERNAL_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libavutil/log.h"
|
||||
|
||||
#include "cbs.h"
|
||||
#include "codec_id.h"
|
||||
#include "get_bits.h"
|
||||
#include "put_bits.h"
|
||||
#include "refstruct.h"
|
||||
|
||||
|
||||
enum CBSContentType {
|
||||
// Unit content may contain some references to other structures, but all
|
||||
// managed via buffer reference counting. The descriptor defines the
|
||||
// structure offsets of every buffer reference.
|
||||
CBS_CONTENT_TYPE_INTERNAL_REFS,
|
||||
// Unit content is something more complex. The descriptor defines
|
||||
// special functions to manage the content.
|
||||
CBS_CONTENT_TYPE_COMPLEX,
|
||||
};
|
||||
|
||||
enum {
|
||||
// Maximum number of unit types described by the same non-range
|
||||
// unit type descriptor.
|
||||
CBS_MAX_LIST_UNIT_TYPES = 3,
|
||||
// Maximum number of reference buffer offsets in any one unit.
|
||||
CBS_MAX_REF_OFFSETS = 2,
|
||||
// Special value used in a unit type descriptor to indicate that it
|
||||
// applies to a large range of types rather than a set of discrete
|
||||
// values.
|
||||
CBS_UNIT_TYPE_RANGE = -1,
|
||||
};
|
||||
|
||||
typedef const struct CodedBitstreamUnitTypeDescriptor {
|
||||
// Number of entries in the unit_types array, or the special value
|
||||
// CBS_UNIT_TYPE_RANGE to indicate that the range fields should be
|
||||
// used instead.
|
||||
int nb_unit_types;
|
||||
|
||||
union {
|
||||
// Array of unit types that this entry describes.
|
||||
CodedBitstreamUnitType list[CBS_MAX_LIST_UNIT_TYPES];
|
||||
// Start and end of unit type range, used if nb_unit_types is
|
||||
// CBS_UNIT_TYPE_RANGE.
|
||||
struct {
|
||||
CodedBitstreamUnitType start;
|
||||
CodedBitstreamUnitType end;
|
||||
} range;
|
||||
} unit_type;
|
||||
|
||||
// The type of content described.
|
||||
enum CBSContentType content_type;
|
||||
// The size of the structure which should be allocated to contain
|
||||
// the decomposed content of this type of unit.
|
||||
size_t content_size;
|
||||
|
||||
union {
|
||||
// This union's state is determined by content_type:
|
||||
// ref for CBS_CONTENT_TYPE_INTERNAL_REFS,
|
||||
// complex for CBS_CONTENT_TYPE_COMPLEX.
|
||||
struct {
|
||||
// Number of entries in the ref_offsets array.
|
||||
// May be zero, then the structure is POD-like.
|
||||
int nb_offsets;
|
||||
// The structure must contain two adjacent elements:
|
||||
// type *field;
|
||||
// AVBufferRef *field_ref;
|
||||
// where field points to something in the buffer referred to by
|
||||
// field_ref. This offset is then set to offsetof(struct, field).
|
||||
size_t offsets[CBS_MAX_REF_OFFSETS];
|
||||
} ref;
|
||||
|
||||
struct {
|
||||
void (*content_free)(FFRefStructOpaque opaque, void *content);
|
||||
int (*content_clone)(void **new_content, CodedBitstreamUnit *unit);
|
||||
} complex;
|
||||
} type;
|
||||
} CodedBitstreamUnitTypeDescriptor;
|
||||
|
||||
typedef struct CodedBitstreamType {
|
||||
enum AVCodecID codec_id;
|
||||
|
||||
// A class for the private data, used to declare private AVOptions.
|
||||
// This field is NULL for types that do not declare any options.
|
||||
// If this field is non-NULL, the first member of the filter private data
|
||||
// must be a pointer to AVClass.
|
||||
const AVClass *priv_class;
|
||||
|
||||
size_t priv_data_size;
|
||||
|
||||
// List of unit type descriptors for this codec.
|
||||
// Terminated by a descriptor with nb_unit_types equal to zero.
|
||||
const CodedBitstreamUnitTypeDescriptor *unit_types;
|
||||
|
||||
// Split frag->data into coded bitstream units, creating the
|
||||
// frag->units array. Fill data but not content on each unit.
|
||||
// The header argument should be set if the fragment came from
|
||||
// a header block, which may require different parsing for some
|
||||
// codecs (e.g. the AVCC header in H.264).
|
||||
int (*split_fragment)(CodedBitstreamContext *ctx,
|
||||
CodedBitstreamFragment *frag,
|
||||
int header);
|
||||
|
||||
// Read the unit->data bitstream and decompose it, creating
|
||||
// unit->content.
|
||||
int (*read_unit)(CodedBitstreamContext *ctx,
|
||||
CodedBitstreamUnit *unit);
|
||||
|
||||
// Write the data bitstream from unit->content into pbc.
|
||||
// Return value AVERROR(ENOSPC) indicates that pbc was too small.
|
||||
int (*write_unit)(CodedBitstreamContext *ctx,
|
||||
CodedBitstreamUnit *unit,
|
||||
PutBitContext *pbc);
|
||||
|
||||
// Return 1 when the unit should be dropped according to 'skip',
|
||||
// 0 otherwise.
|
||||
int (*discarded_unit)(CodedBitstreamContext *ctx,
|
||||
const CodedBitstreamUnit *unit,
|
||||
enum AVDiscard skip);
|
||||
|
||||
// Read the data from all of frag->units and assemble it into
|
||||
// a bitstream for the whole fragment.
|
||||
int (*assemble_fragment)(CodedBitstreamContext *ctx,
|
||||
CodedBitstreamFragment *frag);
|
||||
|
||||
// Reset the codec internal state.
|
||||
void (*flush)(CodedBitstreamContext *ctx);
|
||||
|
||||
// Free the codec internal state.
|
||||
void (*close)(CodedBitstreamContext *ctx);
|
||||
} CodedBitstreamType;
|
||||
|
||||
|
||||
// Helper functions for trace output.
|
||||
|
||||
void ff_cbs_trace_header(CodedBitstreamContext *ctx,
|
||||
const char *name);
|
||||
|
||||
|
||||
// Helper functions for read/write of common bitstream elements, including
|
||||
// generation of trace output. The simple functions are equivalent to
|
||||
// their non-simple counterparts except that their range is unrestricted
|
||||
// (i.e. only limited by the amount of bits used) and they lack
|
||||
// the ability to use subscripts.
|
||||
|
||||
int ff_cbs_read_unsigned(CodedBitstreamContext *ctx, GetBitContext *gbc,
|
||||
int width, const char *name,
|
||||
const int *subscripts, uint32_t *write_to,
|
||||
uint32_t range_min, uint32_t range_max);
|
||||
|
||||
int ff_cbs_read_simple_unsigned(CodedBitstreamContext *ctx, GetBitContext *gbc,
|
||||
int width, const char *name, uint32_t *write_to);
|
||||
|
||||
int ff_cbs_write_unsigned(CodedBitstreamContext *ctx, PutBitContext *pbc,
|
||||
int width, const char *name,
|
||||
const int *subscripts, uint32_t value,
|
||||
uint32_t range_min, uint32_t range_max);
|
||||
|
||||
int ff_cbs_write_simple_unsigned(CodedBitstreamContext *ctx, PutBitContext *pbc,
|
||||
int width, const char *name, uint32_t value);
|
||||
|
||||
int ff_cbs_read_signed(CodedBitstreamContext *ctx, GetBitContext *gbc,
|
||||
int width, const char *name,
|
||||
const int *subscripts, int32_t *write_to,
|
||||
int32_t range_min, int32_t range_max);
|
||||
|
||||
int ff_cbs_write_signed(CodedBitstreamContext *ctx, PutBitContext *pbc,
|
||||
int width, const char *name,
|
||||
const int *subscripts, int32_t value,
|
||||
int32_t range_min, int32_t range_max);
|
||||
|
||||
// The largest unsigned value representable in N bits, suitable for use as
|
||||
// range_max in the above functions.
|
||||
#define MAX_UINT_BITS(length) ((UINT64_C(1) << (length)) - 1)
|
||||
|
||||
// The largest signed value representable in N bits, suitable for use as
|
||||
// range_max in the above functions.
|
||||
#define MAX_INT_BITS(length) ((INT64_C(1) << ((length) - 1)) - 1)
|
||||
|
||||
// The smallest signed value representable in N bits, suitable for use as
|
||||
// range_min in the above functions.
|
||||
#define MIN_INT_BITS(length) (-(INT64_C(1) << ((length) - 1)))
|
||||
|
||||
|
||||
// Start of a syntax element during read tracing.
|
||||
#define CBS_TRACE_READ_START() \
|
||||
GetBitContext trace_start; \
|
||||
do { \
|
||||
if (ctx->trace_enable) \
|
||||
trace_start = *gbc; \
|
||||
} while (0)
|
||||
|
||||
// End of a syntax element for tracing, make callback.
|
||||
#define CBS_TRACE_READ_END() \
|
||||
do { \
|
||||
if (ctx->trace_enable) { \
|
||||
int start_position = get_bits_count(&trace_start); \
|
||||
int end_position = get_bits_count(gbc); \
|
||||
av_assert0(start_position <= end_position); \
|
||||
ctx->trace_read_callback(ctx->trace_context, &trace_start, \
|
||||
end_position - start_position, \
|
||||
name, subscripts, value); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
// End of a syntax element with no subscript entries.
|
||||
#define CBS_TRACE_READ_END_NO_SUBSCRIPTS() \
|
||||
do { \
|
||||
const int *subscripts = NULL; \
|
||||
CBS_TRACE_READ_END(); \
|
||||
} while (0)
|
||||
|
||||
// End of a syntax element which is made up of subelements which
|
||||
// are aleady traced, so we are only showing the value.
|
||||
#define CBS_TRACE_READ_END_VALUE_ONLY() \
|
||||
do { \
|
||||
if (ctx->trace_enable) { \
|
||||
ctx->trace_read_callback(ctx->trace_context, &trace_start, 0, \
|
||||
name, subscripts, value); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
// Start of a syntax element during write tracing.
|
||||
#define CBS_TRACE_WRITE_START() \
|
||||
int start_position; \
|
||||
do { \
|
||||
if (ctx->trace_enable) \
|
||||
start_position = put_bits_count(pbc);; \
|
||||
} while (0)
|
||||
|
||||
// End of a syntax element for tracing, make callback.
|
||||
#define CBS_TRACE_WRITE_END() \
|
||||
do { \
|
||||
if (ctx->trace_enable) { \
|
||||
int end_position = put_bits_count(pbc); \
|
||||
av_assert0(start_position <= end_position); \
|
||||
ctx->trace_write_callback(ctx->trace_context, pbc, \
|
||||
end_position - start_position, \
|
||||
name, subscripts, value); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
// End of a syntax element with no subscript entries.
|
||||
#define CBS_TRACE_WRITE_END_NO_SUBSCRIPTS() \
|
||||
do { \
|
||||
const int *subscripts = NULL; \
|
||||
CBS_TRACE_WRITE_END(); \
|
||||
} while (0)
|
||||
|
||||
// End of a syntax element which is made up of subelements which are
|
||||
// aleady traced, so we are only showing the value. This forges a
|
||||
// PutBitContext to point to the position of the start of the syntax
|
||||
// element, but the other state doesn't matter because length is zero.
|
||||
#define CBS_TRACE_WRITE_END_VALUE_ONLY() \
|
||||
do { \
|
||||
if (ctx->trace_enable) { \
|
||||
PutBitContext tmp; \
|
||||
init_put_bits(&tmp, pbc->buf, start_position); \
|
||||
skip_put_bits(&tmp, start_position); \
|
||||
ctx->trace_write_callback(ctx->trace_context, &tmp, 0, \
|
||||
name, subscripts, value); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define TYPE_LIST(...) { __VA_ARGS__ }
|
||||
#define CBS_UNIT_TYPE_POD(type_, structure) { \
|
||||
.nb_unit_types = 1, \
|
||||
.unit_type.list = { type_ }, \
|
||||
.content_type = CBS_CONTENT_TYPE_INTERNAL_REFS, \
|
||||
.content_size = sizeof(structure), \
|
||||
.type.ref = { .nb_offsets = 0 }, \
|
||||
}
|
||||
#define CBS_UNIT_RANGE_POD(range_start, range_end, structure) { \
|
||||
.nb_unit_types = CBS_UNIT_TYPE_RANGE, \
|
||||
.unit_type.range.start = range_start, \
|
||||
.unit_type.range.end = range_end, \
|
||||
.content_type = CBS_CONTENT_TYPE_INTERNAL_REFS, \
|
||||
.content_size = sizeof(structure), \
|
||||
.type.ref = { .nb_offsets = 0 }, \
|
||||
}
|
||||
|
||||
#define CBS_UNIT_TYPES_INTERNAL_REF(types, structure, ref_field) { \
|
||||
.nb_unit_types = FF_ARRAY_ELEMS((CodedBitstreamUnitType[])TYPE_LIST types), \
|
||||
.unit_type.list = TYPE_LIST types, \
|
||||
.content_type = CBS_CONTENT_TYPE_INTERNAL_REFS, \
|
||||
.content_size = sizeof(structure), \
|
||||
.type.ref = { .nb_offsets = 1, \
|
||||
.offsets = { offsetof(structure, ref_field) } }, \
|
||||
}
|
||||
#define CBS_UNIT_TYPE_INTERNAL_REF(type, structure, ref_field) \
|
||||
CBS_UNIT_TYPES_INTERNAL_REF((type), structure, ref_field)
|
||||
|
||||
#define CBS_UNIT_RANGE_INTERNAL_REF(range_start, range_end, structure, ref_field) { \
|
||||
.nb_unit_types = CBS_UNIT_TYPE_RANGE, \
|
||||
.unit_type.range.start = range_start, \
|
||||
.unit_type.range.end = range_end, \
|
||||
.content_type = CBS_CONTENT_TYPE_INTERNAL_REFS, \
|
||||
.content_size = sizeof(structure), \
|
||||
.type.ref = { .nb_offsets = 1, \
|
||||
.offsets = { offsetof(structure, ref_field) } }, \
|
||||
}
|
||||
|
||||
#define CBS_UNIT_TYPES_COMPLEX(types, structure, free_func) { \
|
||||
.nb_unit_types = FF_ARRAY_ELEMS((CodedBitstreamUnitType[])TYPE_LIST types), \
|
||||
.unit_type.list = TYPE_LIST types, \
|
||||
.content_type = CBS_CONTENT_TYPE_COMPLEX, \
|
||||
.content_size = sizeof(structure), \
|
||||
.type.complex = { .content_free = free_func }, \
|
||||
}
|
||||
#define CBS_UNIT_TYPE_COMPLEX(type, structure, free_func) \
|
||||
CBS_UNIT_TYPES_COMPLEX((type), structure, free_func)
|
||||
|
||||
#define CBS_UNIT_TYPE_END_OF_LIST { .nb_unit_types = 0 }
|
||||
|
||||
|
||||
extern const CodedBitstreamType ff_cbs_type_av1;
|
||||
extern const CodedBitstreamType ff_cbs_type_h264;
|
||||
extern const CodedBitstreamType ff_cbs_type_h265;
|
||||
extern const CodedBitstreamType ff_cbs_type_h266;
|
||||
extern const CodedBitstreamType ff_cbs_type_jpeg;
|
||||
extern const CodedBitstreamType ff_cbs_type_mpeg2;
|
||||
extern const CodedBitstreamType ff_cbs_type_vp8;
|
||||
extern const CodedBitstreamType ff_cbs_type_vp9;
|
||||
|
||||
|
||||
#endif /* AVCODEC_CBS_INTERNAL_H */
|
||||
123
include/libavcodec/cbs_jpeg.h
Normal file
123
include/libavcodec/cbs_jpeg.h
Normal file
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* 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_CBS_JPEG_H
|
||||
#define AVCODEC_CBS_JPEG_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libavutil/buffer.h"
|
||||
|
||||
|
||||
enum {
|
||||
JPEG_MARKER_SOF0 = 0xc0,
|
||||
JPEG_MARKER_SOF1 = 0xc1,
|
||||
JPEG_MARKER_SOF2 = 0xc2,
|
||||
JPEG_MARKER_SOF3 = 0xc3,
|
||||
|
||||
JPEG_MARKER_DHT = 0xc4,
|
||||
JPEG_MARKER_SOI = 0xd8,
|
||||
JPEG_MARKER_EOI = 0xd9,
|
||||
JPEG_MARKER_SOS = 0xda,
|
||||
JPEG_MARKER_DQT = 0xdb,
|
||||
|
||||
JPEG_MARKER_APPN = 0xe0,
|
||||
JPEG_MARKER_JPGN = 0xf0,
|
||||
JPEG_MARKER_COM = 0xfe,
|
||||
};
|
||||
|
||||
enum {
|
||||
JPEG_MAX_COMPONENTS = 255,
|
||||
|
||||
JPEG_MAX_HEIGHT = 65535,
|
||||
JPEG_MAX_WIDTH = 65535,
|
||||
};
|
||||
|
||||
|
||||
typedef struct JPEGRawFrameHeader {
|
||||
uint16_t Lf;
|
||||
uint8_t P;
|
||||
uint16_t Y;
|
||||
uint16_t X;
|
||||
uint16_t Nf;
|
||||
|
||||
uint8_t C [JPEG_MAX_COMPONENTS];
|
||||
uint8_t H [JPEG_MAX_COMPONENTS];
|
||||
uint8_t V [JPEG_MAX_COMPONENTS];
|
||||
uint8_t Tq[JPEG_MAX_COMPONENTS];
|
||||
} JPEGRawFrameHeader;
|
||||
|
||||
typedef struct JPEGRawScanHeader {
|
||||
uint16_t Ls;
|
||||
uint8_t Ns;
|
||||
|
||||
uint8_t Cs[JPEG_MAX_COMPONENTS];
|
||||
uint8_t Td[JPEG_MAX_COMPONENTS];
|
||||
uint8_t Ta[JPEG_MAX_COMPONENTS];
|
||||
|
||||
uint8_t Ss;
|
||||
uint8_t Se;
|
||||
uint8_t Ah;
|
||||
uint8_t Al;
|
||||
} JPEGRawScanHeader;
|
||||
|
||||
typedef struct JPEGRawScan {
|
||||
JPEGRawScanHeader header;
|
||||
uint8_t *data;
|
||||
AVBufferRef *data_ref;
|
||||
size_t data_size;
|
||||
} JPEGRawScan;
|
||||
|
||||
typedef struct JPEGRawQuantisationTable {
|
||||
uint8_t Pq;
|
||||
uint8_t Tq;
|
||||
uint16_t Q[64];
|
||||
} JPEGRawQuantisationTable;
|
||||
|
||||
typedef struct JPEGRawQuantisationTableSpecification {
|
||||
uint16_t Lq;
|
||||
JPEGRawQuantisationTable table[4];
|
||||
} JPEGRawQuantisationTableSpecification;
|
||||
|
||||
typedef struct JPEGRawHuffmanTable {
|
||||
uint8_t Tc;
|
||||
uint8_t Th;
|
||||
uint8_t L[16];
|
||||
uint8_t V[256];
|
||||
} JPEGRawHuffmanTable;
|
||||
|
||||
typedef struct JPEGRawHuffmanTableSpecification {
|
||||
uint16_t Lh;
|
||||
JPEGRawHuffmanTable table[8];
|
||||
} JPEGRawHuffmanTableSpecification;
|
||||
|
||||
typedef struct JPEGRawApplicationData {
|
||||
uint16_t Lp;
|
||||
uint8_t *Ap;
|
||||
AVBufferRef *Ap_ref;
|
||||
} JPEGRawApplicationData;
|
||||
|
||||
typedef struct JPEGRawComment {
|
||||
uint16_t Lc;
|
||||
uint8_t *Cm;
|
||||
AVBufferRef *Cm_ref;
|
||||
} JPEGRawComment;
|
||||
|
||||
|
||||
#endif /* AVCODEC_CBS_JPEG_H */
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user