25 #include "libavutil/channel_layout.h"
51 float two_cos_w = 2.0f * cos_val;
53 for (j = 0; j + 1 < order; j += 2 * 2) {
55 q *= lsp[j] - two_cos_w;
56 p *= lsp[j + 1] - two_cos_w;
58 q *= lsp[j + 2] - two_cos_w;
59 p *= lsp[j + 3] - two_cos_w;
62 p *= p * (2.0f - two_cos_w);
63 q *= q * (2.0f + two_cos_w);
77 for (i = 0; i < size_s / 2; i++) {
87 float step = (v1 - v2) / (size + 1);
89 for (i = 0; i <
size; i++) {
97 return part ? -cos_tab[size - idx - 1]
117 float *
out,
const float *
in,
118 int size,
int step,
int part)
125 for (i = 0; i <
size; i += step)
128 get_cos(i, part, cos_tab, size),
132 for (i = step; i <= size - 2 * step; i += step) {
133 if (out[i + step] + out[i - step] > 1.95 * out[i] ||
134 out[i + step] >= out[i - step]) {
135 interpolate(out + i - step + 1, out[i], out[i - step], step - 1);
139 get_cos(i - step / 2, part, cos_tab, size),
142 out[i - step], step / 2 - 1);
144 out[i - step / 2], step / 2 - 1);
148 interpolate(out + size - 2 * step + 1, out[size - step],
149 out[size - 2 * step], step - 1);
153 const float *
buf,
float *lpc,
160 interpolate(lpc + size / 2 - step + 1, lpc[size / 2],
161 lpc[size / 2 - step], step);
174 const int16_t *cb0,
const int16_t *cb1,
int cb_len)
179 for (i = 0; i < tctx->
n_div[ftype]; i++) {
183 const int16_t *tab0, *
tab1;
203 tab0 = cb0 + tmp0 * cb_len;
204 tab1 = cb1 + tmp1 * cb_len;
206 for (j = 0; j <
length; j++)
207 out[tctx->
permut[ftype][pos + j]] = sign0 * tab0[j] +
226 out[i] = (1.0 / (1 << 13)) *
231 float val = (1.0 / (1 << 23)) *
235 for (j = 0; j < sub; j++)
253 float min_dist2 = min_dist * 0.5;
254 for (i = 1; i < order; i++)
255 if (lsp[i] - lsp[i - 1] < min_dist) {
256 float avg = (lsp[i] + lsp[i - 1]) * 0.5;
258 lsp[i - 1] = avg - min_dist2;
259 lsp[i] = avg + min_dist2;
264 int lpc_hist_idx,
float *lsp,
float *hist)
271 const float *cb3 = cb2 + (1 << mtab->
lsp_bit2) * mtab->
n_lsp;
273 const int8_t funny_rounding[4] = {
282 int chunk_end = ((i + 1) * mtab->
n_lsp + funny_rounding[i]) /
284 for (; j < chunk_end; j++)
285 lsp[j] = cb[lpc_idx1 * mtab->
n_lsp + j] +
286 cb2[lpc_idx2[i] * mtab->
n_lsp + j];
291 for (i = 0; i < mtab->
n_lsp; i++) {
292 float tmp1 = 1.0 - cb3[lpc_hist_idx * mtab->
n_lsp + i];
293 float tmp2 = hist[i] * cb3[lpc_hist_idx * mtab->
n_lsp + i];
295 lsp[i] = lsp[i] * tmp1 + tmp2;
310 lsp[i] = 2 * cos(lsp[i]);
328 int wtype,
float *
in,
float *prev,
int ch)
335 int j, first_wsize, wsize;
339 int types_sizes[] = {
347 prev_buf = prev + (size - bsize) / 2;
349 for (j = 0; j < mtab->
fmode[ftype].
sub; j++) {
352 if (!j && wtype == 4)
354 else if (j == mtab->
fmode[ftype].
sub - 1 && wtype == 7)
357 wsize = types_sizes[wtype_to_wsize[sub_wtype]];
359 mdct->
imdct_half(mdct, buf1 + bsize * j, in + bsize * j);
367 memcpy(out2, buf1 + bsize * j + wsize / 2,
368 (bsize - wsize / 2) *
sizeof(
float));
372 prev_buf = buf1 + bsize * j + bsize / 2;
379 int wtype,
float **out)
388 prev_buf + 2 * i * mtab->
size,
395 size1 = mtab->
size - size2;
397 memcpy(&out[0][0], prev_buf, size1 *
sizeof(out[0][0]));
398 memcpy(&out[0][size1], tctx->
curr_frame, size2 *
sizeof(out[0][0]));
401 memcpy(&out[1][0], &prev_buf[2 * mtab->
size],
402 size1 *
sizeof(out[1][0]));
404 size2 *
sizeof(out[1][0]));
416 int block_size = mtab->
size / sub;
437 for (i = 0; i < channels; i++) {
438 float *chunk = out + mtab->
size * i;
441 for (j = 0; j < sub; j++) {
444 tctx->
tmp_buf, gain[sub * i + j], ftype);
447 chunk + block_size * j,
460 for (j = 0; j < mtab->
fmode[ftype].
sub; j++) {
474 int *got_frame_ptr,
AVPacket *avpkt)
478 int buf_size = avpkt->
size;
492 if (buf_size < avctx->block_align) {
494 "Frame too small (%d bytes). Truncated file?\n", buf_size);
528 float norm = channels == 1 ? 2.0 : 1.0;
530 for (i = 0; i < 3; i++) {
533 -sqrt(norm / bsize) / (1 << 15))))
550 for (i = 0; i < 3; i++) {
552 double freq = 2 *
M_PI /
m;
554 (m / 4) *
sizeof(*tctx->
cos_tabs[i]), alloc_fail);
556 for (j = 0; j <= m / 8; j++)
557 tctx->
cos_tabs[i][j] = cos((2 * j + 1) * freq);
558 for (j = 1; j < m / 8; j++)
580 const uint8_t line_len[2],
int length_div,
585 for (i = 0; i < line_len[0]; i++) {
588 if (num_blocks == 1 ||
598 for (j = 0; j < num_vect && (j + num_vect * i < block_size * num_blocks); j++)
599 tab[i * num_vect + j] = i * num_vect + (j + shift) % num_vect;
619 const uint8_t line_len[2],
int length_div)
624 for (i = 0; i < num_vect; i++)
625 for (j = 0; j < line_len[i >= length_div]; j++)
626 out[cont++] = in[j * num_vect + i];
629 static void linear_perm(int16_t *out, int16_t *in,
int n_blocks,
int size)
631 int block_size = size / n_blocks;
634 for (i = 0; i <
size; i++)
635 out[i] = block_size * (in[i] % n_blocks) + in[i] / n_blocks;
641 int block_size,
size;
643 int16_t *tmp_perm = (int16_t *)tctx->
tmp_buf;
654 block_size, tctx->
length[ftype],
677 int bsize_no_main_cb[3], bse_bits[3], i;
680 for (i = 0; i < 3; i++)
686 bsize_no_main_cb[2] = bse_bits[2] + lsp_bits_per_block + ppc_bits +
689 for (i = 0; i < 2; i++)
690 bsize_no_main_cb[i] =
691 lsp_bits_per_block + n_ch * TWINVQ_GAIN_BITS +
696 bsize_no_main_cb[1] += 2;
697 bsize_no_main_cb[2] += 2;
701 for (i = 0; i < 4; i++) {
702 int bit_size, vect_size;
703 int rounded_up, rounded_down, num_rounded_down, num_rounded_up;
708 bit_size = total_fr_bits - bsize_no_main_cb[i];
709 vect_size = n_ch * mtab->
size;
712 tctx->
n_div[i] = (bit_size + 13) / 14;
714 rounded_up = (bit_size + tctx->
n_div[i] - 1) /
716 rounded_down = (bit_size) / tctx->
n_div[i];
717 num_rounded_down = rounded_up * tctx->
n_div[i] - bit_size;
718 num_rounded_up = tctx->
n_div[i] - num_rounded_down;
725 rounded_up = (vect_size + tctx->
n_div[i] - 1) /
727 rounded_down = (vect_size) / tctx->
n_div[i];
728 num_rounded_down = rounded_up * tctx->
n_div[i] - vect_size;
729 num_rounded_up = tctx->
n_div[i] - num_rounded_down;
730 tctx->
length[i][0] = rounded_up;
731 tctx->
length[i][1] = rounded_down;
744 for (i = 0; i < 3; i++) {
const char const char void * val
uint8_t bark_n_bit
number of bits of the BSE coefs
static int shift(int a, int b)
static void linear_perm(int16_t *out, int16_t *in, int n_blocks, int size)
This structure describes decoded (raw) audio or video data.
uint8_t ppc_coeffs[TWINVQ_PPC_SHAPE_LEN_MAX]
int bits_main_spec_change[4]
const TwinVQModeTab * mtab
int p_coef[TWINVQ_CHANNELS_MAX]
uint8_t cb_len_read
number of spectrum coefficients to read
Medium frame (divided in m<n sub-blocks)
uint8_t bark_n_coef
number of BSE CB coefficients to read
static void imdct_output(TwinVQContext *tctx, enum TwinVQFrameType ftype, int wtype, float **out)
uint8_t ** extended_data
pointers to the data planes/channels.
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
uint16_t size
frame size in samples
uint8_t bark_use_hist[TWINVQ_CHANNELS_MAX][TWINVQ_SUBBLOCKS_MAX]
uint8_t lpc_idx1[TWINVQ_CHANNELS_MAX]
static const uint8_t wtype_to_wsize[]
enum TwinVQFrameType ff_twinvq_wtype_to_ftype_table[]
uint8_t sub_gain_bits[TWINVQ_CHANNELS_MAX *TWINVQ_SUBBLOCKS_MAX]
if((e=av_dict_get(options,"", NULL, AV_DICT_IGNORE_SUFFIX)))
Short frame (divided in n sub-blocks)
static double cb(void *priv, double x, double y)
void(* vector_fmul_window)(float *dst, const float *src0, const float *src1, const float *win, int len)
Overlap/add with window function.
uint8_t lpc_idx2[TWINVQ_CHANNELS_MAX][TWINVQ_LSP_SPLIT_MAX]
enum AVSampleFormat sample_fmt
audio sample format
const int16_t * ppc_shape_cb
PPC shape CB.
int g_coef[TWINVQ_CHANNELS_MAX]
uint8_t ppc_period_bit
number of the bits for the PPC period value
av_cold int ff_twinvq_decode_close(AVCodecContext *avctx)
uint8_t gain_bits[TWINVQ_CHANNELS_MAX]
#define TWINVQ_SUBBLOCKS_MAX
static void interpolate(float *out, float v1, float v2, int size)
#define TWINVQ_WINDOW_TYPE_BITS
Parameters and tables that are different for every combination of bitrate/sample rate.
uint8_t lpc_hist_idx[TWINVQ_CHANNELS_MAX]
#define CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
static void dequant(TwinVQContext *tctx, const uint8_t *cb_bits, float *out, enum TwinVQFrameType ftype, const int16_t *cb0, const int16_t *cb1, int cb_len)
Inverse quantization.
#define FFSWAP(type, a, b)
Long frame (single sub-block + PPC)
static const int16_t cos_tab[COS_TBL_SIZE+1]
Cosine table scaled by 2^14.
static float twinvq_mulawinv(float y, float clip, float mu)
static av_cold void init_bitstream_params(TwinVQContext *tctx)
uint8_t main_coeffs[1024]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=av_sample_fmt_is_planar(in_fmt);out_planar=av_sample_fmt_is_planar(out_fmt);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);ff_audio_convert_init_arm(ac);ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_dlog(ac->avr,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
void(* vector_fmul)(float *dst, const float *src0, const float *src1, int len)
Calculate the product of two vectors of floats and store the result in a vector of floats...
void(* butterflies_float)(float *av_restrict v1, float *av_restrict v2, int len)
Calculate the sum and difference of two vectors of floats.
#define TWINVQ_PPC_SHAPE_CB_SIZE
static void decode_lsp(TwinVQContext *tctx, int lpc_idx1, uint8_t *lpc_idx2, int lpc_hist_idx, float *lsp, float *hist)
static void eval_lpcenv_2parts(TwinVQContext *tctx, enum TwinVQFrameType ftype, const float *buf, float *lpc, int size, int step)
int(* read_bitstream)(AVCodecContext *avctx, struct TwinVQContext *tctx, const uint8_t *buf, int buf_size)
Libavcodec external API header.
void(* decode_ppc)(struct TwinVQContext *tctx, int period_coef, int g_coef, const float *shape, float *speech)
void(* dec_bark_env)(struct TwinVQContext *tctx, const uint8_t *in, int use_hist, int ch, float *out, float gain, enum TwinVQFrameType ftype)
#define FF_ARRAY_ELEMS(a)
const int16_t * cb0
main codebooks for spectrum data
static void dec_lpc_spectrum_inv(TwinVQContext *tctx, float *lsp, enum TwinVQFrameType ftype, float *lpc)
int bit_rate
the average bitrate
uint8_t sub
Number subblocks in each frame.
uint8_t bits_main_spec[2][4][2]
bits for the main codebook
static void twinvq_memset_float(float *buf, float val, int size)
uint8_t n_lsp
number of lsp coefficients
int ff_twinvq_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
static void rearrange_lsp(int order, float *lsp, float min_dist)
Rearrange the LSP coefficients so that they have a minimum distance of min_dist.
uint8_t ppc_shape_bit
number of bits of the PPC shape CB coeffs
float bark_hist[3][2][40]
BSE coefficients of last frame.
static void permutate_in_line(int16_t *tab, int num_vect, int num_blocks, int block_size, const uint8_t line_len[2], int length_div, enum TwinVQFrameType ftype)
Interpret the data as if it were a num_blocks x line_len[0] matrix and for each line do a cyclic perm...
static void eval_lpcenv(TwinVQContext *tctx, const float *cos_vals, float *lpc)
Evaluate the LPC amplitude spectrum envelope from the line spectrum pairs.
int sample_rate
samples per second
Periodic Peak Component (part of the long frame)
main external API structure.
enum TwinVQFrameType ftype
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
void(* imdct_half)(struct FFTContext *s, FFTSample *output, const FFTSample *input)
struct TwinVQFrameMode fmode[3]
frame type-dependant parameters
SINETABLE_CONST float *const ff_sine_windows[14]
static void read_and_decode_spectrum(TwinVQContext *tctx, float *out, enum TwinVQFrameType ftype)
#define TWINVQ_PPC_SHAPE_LEN_MAX
float * prev_frame
non-interleaved previous frame
uint8_t pgain_bit
bits for PPC gain
static float eval_lpc_spectrum(const float *lsp, float cos_val, int order)
Evaluate a single LPC amplitude spectrum envelope coefficient from the line spectrum pairs...
static void imdct_and_window(TwinVQContext *tctx, enum TwinVQFrameType ftype, int wtype, float *in, float *prev, int ch)
av_cold void avpriv_float_dsp_init(AVFloatDSPContext *fdsp, int bit_exact)
Initialize a float DSP context.
const float * lspcodebook
static av_cold int init_mdct_win(TwinVQContext *tctx)
Init IMDCT and windowing tables.
float lsp_hist[2][20]
LSP coefficients of the last frame.
#define TWINVQ_LSP_COEFS_MAX
common internal api header.
#define FF_ALLOC_OR_GOTO(ctx, p, size, label)
uint8_t ppc_shape_len
size of PPC shape CB
#define TWINVQ_SUB_GAIN_BITS
void ff_sort_nearly_sorted_floats(float *vals, int len)
Sort values in ascending order.
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=av_sample_fmt_is_planar(in_fmt);out_planar=av_sample_fmt_is_planar(out_fmt);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);ff_audio_convert_init_arm(ac);ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_dlog(ac->avr,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> out
int channels
number of audio channels
static void transpose_perm(int16_t *out, int16_t *in, int num_vect, const uint8_t line_len[2], int length_div)
Interpret the input data as in the following table:
static struct twinvq_data tab
static void eval_lpcenv_or_interp(TwinVQContext *tctx, enum TwinVQFrameType ftype, float *out, const float *in, int size, int step, int part)
Evaluate the LPC amplitude spectrum envelope from the line spectrum pairs.
static float get_cos(int idx, int part, const float *cos_tab, int size)
float * curr_frame
non-interleaved output
static void dec_gain(TwinVQContext *tctx, enum TwinVQFrameType ftype, float *out)
#define TWINVQ_CHANNELS_MAX
uint8_t length[4][2]
main codebook stride
This structure stores compressed data.
static av_cold void construct_perm_table(TwinVQContext *tctx, enum TwinVQFrameType ftype)
#define TWINVQ_SUB_AMP_MAX
int nb_samples
number of audio samples (per channel) described by this frame
void ff_init_ff_sine_windows(int index)
initialize the specified entry of ff_sine_windows
uint8_t lsp_split
number of CB entries for the LSP decoding
uint8_t bark1[TWINVQ_CHANNELS_MAX][TWINVQ_SUBBLOCKS_MAX][TWINVQ_BARK_N_COEF_MAX]
av_cold int ff_twinvq_decode_init(AVCodecContext *avctx)