Go to the documentation of this file.
30 #define BITSTREAM_READER_LE
39 float ppc_gain,
float *speech,
int len)
42 const float *shape_end = shape +
len;
46 speech[
i] += ppc_gain * *shape++;
51 speech[j + center] += ppc_gain * *shape++;
56 for (j = -
width / 2; j < (
width + 1) / 2 && shape < shape_end; j++)
57 speech[j + center] += ppc_gain * *shape++;
61 const float *shape,
float *speech)
70 float min_period, max_period, period_range,
period;
73 float pgain_base, pgain_step, ppc_gain;
76 min_period =
log2(ratio * 0.2);
77 max_period = min_period +
log2(6);
79 min_period = (
int)(ratio * 0.2 * 400 + 0.5) / 400.0;
80 max_period = (
int)(ratio * 0.2 * 400 * 6 + 0.5) / 400.0;
82 period_range = max_period - min_period;
83 period = min_period + period_coef * period_range /
91 case 8: some_mult = 2.0;
break;
92 case 11: some_mult = 3.0;
break;
93 case 16: some_mult = 3.0;
break;
94 case 22: some_mult = ibps == 32 ? 2.0 : 4.0;
break;
95 case 44: some_mult = 8.0;
break;
96 default: some_mult = 4.0;
100 if (isampf == 22 && ibps == 32)
103 pgain_base =
channels == 2 ? 25000.0 : 20000.0;
104 pgain_step = pgain_base / ((1 << mtab->
pgain_bit) - 1);
105 ppc_gain = 1.0 / 8192 *
113 int ch,
float *
out,
float gain,
119 float val = ((
const float []) { 0.4, 0.35, 0.28 })[
ftype];
127 for (
i = 0;
i < fw_cb_len;
i++)
128 for (j = 0; j < bark_n_coef; j++, idx++) {
135 tmp2 +
val * hist[idx] + 1.0 : tmp2 + 1.0;
137 st = use_hist ? (1.0 -
val) * tmp2 +
val * hist[idx] + 1.0
164 const uint8_t *buf,
int buf_size)
182 if (
bits->window_type > 8) {
197 for (j = 0; j < sub; j++)
199 bits->bark1[
i][j][k] =
203 for (j = 0; j < sub; j++)
212 for (j = 0; j < sub; j++)
213 bits->sub_gain_bits[
i * sub + j] =
250 {
MKTAG(
'V',
'X',
'0',
'3'), 6, 1, 8000 },
251 {
MKTAG(
'V',
'X',
'0',
'4'), 12, 2, 8000 },
253 {
MKTAG(
'V',
'O',
'X',
'i'), 8, 1, 8000 },
254 {
MKTAG(
'V',
'O',
'X',
'j'), 10, 1, 11025 },
255 {
MKTAG(
'V',
'O',
'X',
'k'), 16, 1, 16000 },
256 {
MKTAG(
'V',
'O',
'X',
'L'), 24, 1, 22050 },
257 {
MKTAG(
'V',
'O',
'X',
'q'), 32, 1, 44100 },
258 {
MKTAG(
'V',
'O',
'X',
'r'), 40, 1, 44100 },
259 {
MKTAG(
'V',
'O',
'X',
's'), 48, 1, 44100 },
260 {
MKTAG(
'V',
'O',
'X',
't'), 16, 2, 8000 },
261 {
MKTAG(
'V',
'O',
'X',
'u'), 20, 2, 11025 },
262 {
MKTAG(
'V',
'O',
'X',
'v'), 32, 2, 16000 },
263 {
MKTAG(
'V',
'O',
'X',
'w'), 48, 2, 22050 },
264 {
MKTAG(
'V',
'O',
'X',
'x'), 64, 2, 44100 },
265 {
MKTAG(
'V',
'O',
'X',
'y'), 80, 2, 44100 },
266 {
MKTAG(
'V',
'O',
'X',
'z'), 96, 2, 44100 },
306 switch ((
channels << 16) + (isampf << 8) + ibps) {
307 case (1 << 16) + ( 8 << 8) + 6:
310 case (2 << 16) + ( 8 << 8) + 6:
313 case (1 << 16) + ( 8 << 8) + 8:
316 case (2 << 16) + ( 8 << 8) + 8:
319 case (1 << 16) + (11 << 8) + 10:
322 case (2 << 16) + (11 << 8) + 10:
325 case (1 << 16) + (16 << 8) + 16:
328 case (2 << 16) + (16 << 8) + 16:
331 case (1 << 16) + (22 << 8) + 24:
334 case (2 << 16) + (22 << 8) + 24:
337 case (1 << 16) + (44 << 8) + 32:
338 case (2 << 16) + (44 << 8) + 32:
341 case (1 << 16) + (44 << 8) + 40:
342 case (2 << 16) + (44 << 8) + 40:
345 case (1 << 16) + (44 << 8) + 48:
346 case (2 << 16) + (44 << 8) + 48:
351 "This version does not support %d kHz - %d kbit/s/ch mode.\n",
368 .
p.
name =
"metasound",
@ AV_SAMPLE_FMT_FLTP
float, planar
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
const TwinVQModeTab * mtab
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
uint8_t sub
Number subblocks in each frame.
int sample_rate
samples per second
uint8_t bits_main_spec[2][4][2]
bits for the main codebook
static int get_bits_count(const GetBitContext *s)
TwinVQFrameData bits[TWINVQ_MAX_FRAMES_PER_PACKET]
uint8_t ppc_shape_len
size of PPC shape CB
av_cold int ff_twinvq_decode_init(AVCodecContext *avctx)
Requires the caller to call ff_twinvq_decode_close() upon failure.
uint8_t pgain_bit
bits for PPC gain
int nb_channels
Number of channels in this layout.
static void skip_bits(GetBitContext *s, int n)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define TWINVQ_WINDOW_TYPE_BITS
AVCodec p
The public AVCodec.
AVChannelLayout ch_layout
Audio channel layout.
uint8_t bark_n_coef
number of BSE CB coefficients to read
static double val(void *priv, double ch)
uint16_t size
frame size in samples
static float twinvq_mulawinv(float y, float clip, float mu)
void(* dec_bark_env)(struct TwinVQContext *tctx, const uint8_t *in, int use_hist, int ch, float *out, float gain, enum TwinVQFrameType ftype)
void(* decode_ppc)(struct TwinVQContext *tctx, int period_coef, int g_coef, const float *shape, float *speech)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
#define FF_CODEC_DECODE_CB(func)
int(* init)(AVBSFContext *ctx)
Parameters and tables that are different for every combination of bitrate/sample rate.
const uint16_t * bark_tab
static void twinvq_memset_float(float *buf, float val, int size)
#define CODEC_LONG_NAME(str)
const int16_t * bark_cb
codebook for the bark scale envelope (BSE)
av_cold int ff_twinvq_decode_close(AVCodecContext *avctx)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option keep it simple and lowercase description are in without period
int64_t bit_rate
the average bitrate
#define ROUNDED_DIV(a, b)
static unsigned int get_bits1(GetBitContext *s)
int ff_twinvq_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
@ TWINVQ_FT_LONG
Long frame (single sub-block + PPC)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
uint8_t bark_n_bit
number of bits of the BSE coefs
uint8_t ppc_period_bit
number of the bits for the PPC period value
int bits_main_spec_change[4]
int(* read_bitstream)(AVCodecContext *avctx, struct TwinVQContext *tctx, const uint8_t *buf, int buf_size)
void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels)
Get the default channel layout for a given number of channels.
#define TWINVQ_SUB_GAIN_BITS
#define i(width, name, range_min, range_max)
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
float bark_hist[3][2][40]
BSE coefficients of last frame.
AVSampleFormat
Audio sample formats.
const char * name
Name of the codec implementation.
@ TWINVQ_FT_SHORT
Short frame (divided in n sub-blocks)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
main external API structure.
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define MKTAG(a, b, c, d)
uint8_t lsp_split
number of CB entries for the LSP decoding
enum TwinVQFrameType ff_twinvq_wtype_to_ftype_table[]
struct TwinVQFrameMode fmode[3]
frame type-dependent parameters
uint8_t bark_env_size
number of distinct bark scale envelope values