50 #define IMC_BLOCK_SIZE 64
51 #define IMC_FRAME_ID 0x21
111 #define VLC_TABLES_SIZE 9512
114 0, 640, 1156, 1732, 2308, 2852, 3396, 3924,
122 return 3.5 * atan((freq / 7500.0) * (freq / 7500.0)) + 13.0 * atan(freq * 0.00076);
127 double freqmin[32], freqmid[32], freqmax[32];
128 double scale = sampling_rate / (256.0 * 2.0 * 2.0);
129 double nyquist_freq = sampling_rate * 0.5;
130 double freq, bark, prev_bark = 0,
tf,
tb;
133 for (i = 0; i < 32; i++) {
138 tb = bark - prev_bark;
147 while (
tf < nyquist_freq) {
159 if (tb <= bark - 0.5)
165 for (i = 0; i < 32; i++) {
167 for (j = 31; j > 0 && freq <= freqmid[j]; j--);
171 for (j = 0; j < 32 && freq >= freqmid[j]; j++);
184 "Strange sample rate of %i, file likely corrupt or "
185 "needing a new table derivation method.\n",
198 for (j = 0; j < avctx->
channels; j++) {
201 for (i = 0; i <
BANDS; i++)
210 for (i = 0; i <
COEFFS; i++)
212 for (i = 0; i < COEFFS / 2; i++) {
213 q->
post_cos[i] = (1.0f / 32768) * cos(i / 256.0 *
M_PI);
214 q->
post_sin[i] = (1.0f / 32768) * sin(i / 256.0 *
M_PI);
216 r1 = sin((i * 4.0 + 1.0) / 1024.0 *
M_PI);
217 r2 = cos((i * 4.0 + 1.0) / 1024.0 *
M_PI);
221 q->
pre_coef2[i] = -(r1 - r2) * sqrt(2.0);
223 q->
pre_coef1[i] = -(r1 + r2) * sqrt(2.0);
230 for (i = 0; i < 30; i++)
234 for (i = 0; i < 4 ; i++) {
235 for (j = 0; j < 4; j++) {
237 huffman_vlc[i][j].
table_allocated = vlc_offsets[i * 4 + j + 1] - vlc_offsets[i * 4 + j];
273 float *flcoeffs2,
int *bandWidthT,
274 float *flcoeffs3,
float *flcoeffs5)
279 float snr_limit = 1.e-30;
283 for (i = 0; i <
BANDS; i++) {
284 flcoeffs5[i] = workT2[i] = 0.0;
286 workT1[i] = flcoeffs1[i] * flcoeffs1[i];
287 flcoeffs3[i] = 2.0 * flcoeffs2[i];
290 flcoeffs3[i] = -30000.0;
292 workT3[i] = bandWidthT[i] * workT1[i] * 0.01;
293 if (workT3[i] <= snr_limit)
297 for (i = 0; i <
BANDS; i++) {
298 for (cnt2 = i; cnt2 < q->
cyclTab[i]; cnt2++)
299 flcoeffs5[cnt2] = flcoeffs5[cnt2] + workT3[i];
300 workT2[cnt2 - 1] = workT2[cnt2 - 1] + workT3[i];
303 for (i = 1; i <
BANDS; i++) {
304 accum = (workT2[i - 1] + accum) * q->
weights1[i - 1];
305 flcoeffs5[i] += accum;
308 for (i = 0; i <
BANDS; i++)
311 for (i = 0; i <
BANDS; i++) {
312 for (cnt2 = i - 1; cnt2 > q->
cyclTab2[i]; cnt2--)
313 flcoeffs5[cnt2] += workT3[i];
314 workT2[cnt2+1] += workT3[i];
319 for (i = BANDS-2; i >= 0; i--) {
320 accum = (workT2[i+1] + accum) * q->
weights2[i];
321 flcoeffs5[i] += accum;
336 s = stream_format_code >> 1;
337 hufftab[0] = &huffman_vlc[
s][0];
338 hufftab[1] = &huffman_vlc[
s][1];
339 hufftab[2] = &huffman_vlc[
s][2];
340 hufftab[3] = &huffman_vlc[
s][3];
343 if (stream_format_code & 4)
347 for (i = start; i <
BANDS; i++) {
349 hufftab[cb_sel[i]]->
bits, 2);
350 if (levlCoeffs[i] == 17)
362 for (i = 1; i <
BANDS; i++)
367 float *flcoeffs1,
float *flcoeffs2)
373 flcoeffs1[0] = 20000.0 /
exp2 (levlCoeffBuf[0] * 0.18945);
374 flcoeffs2[0] =
log2f(flcoeffs1[0]);
378 for (i = 1; i <
BANDS; i++) {
379 level = levlCoeffBuf[i];
386 else if (level <= 24)
392 tmp2 += 0.83048 *
level;
401 float *old_floor,
float *flcoeffs1,
409 for (i = 0; i <
BANDS; i++) {
411 if (levlCoeffBuf[i] < 16) {
412 flcoeffs1[i] =
imc_exp_tab2[levlCoeffBuf[i]] * old_floor[i];
413 flcoeffs2[i] = (levlCoeffBuf[i] - 7) * 0.83048 + flcoeffs2[i];
415 flcoeffs1[i] = old_floor[i];
421 float *flcoeffs1,
float *flcoeffs2)
427 flcoeffs1[pos] = 20000.0 / pow (2, levlCoeffBuf[0] * 0.18945);
428 flcoeffs2[pos] =
log2f(flcoeffs1[pos]);
429 tmp = flcoeffs1[pos];
430 tmp2 = flcoeffs2[pos];
433 for (i = 0; i <
BANDS; i++) {
436 level = *levlCoeffBuf++;
437 flcoeffs1[i] = tmp *
powf(10.0, -level * 0.4375);
438 flcoeffs2[i] = tmp2 - 1.4533435415 *
level;
446 int stream_format_code,
int freebits,
int flag)
449 const float limit = -1.e20;
458 float lowest = 1.e10;
464 for (i = 0; i <
BANDS; i++)
467 for (i = 0; i < BANDS - 1; i++) {
476 highest = highest * 0.25;
478 for (i = 0; i <
BANDS; i++) {
495 if (stream_format_code & 0x2) {
502 for (i = (stream_format_code & 0x2) ? 4 : 0; i < BANDS - 1; i++) {
511 summa = (summa * 0.5 - freebits) / iacc;
514 for (i = 0; i < BANDS / 2; i++) {
515 rres = summer - freebits;
516 if ((rres >= -8) && (rres <= 8))
522 for (j = (stream_format_code & 0x2) ? 4 : 0; j <
BANDS; j++) {
523 cwlen = av_clipf(((chctx->
flcoeffs4[j] * 0.5) - summa + 0.5), 0, 6);
534 if (freebits < summer)
541 summa = (float)(summer - freebits) / ((t1 + 1) * iacc) + summa;
544 for (i = (stream_format_code & 0x2) ? 4 : 0; i <
BANDS; i++) {
549 if (freebits > summer) {
550 for (i = 0; i <
BANDS; i++) {
551 workT[i] = (chctx->
bitsBandT[i] == 6) ? -1.e20
558 if (highest <= -1.e20)
564 for (i = 0; i <
BANDS; i++) {
565 if (workT[i] > highest) {
571 if (highest > -1.e20) {
572 workT[found_indx] -= 2.0;
574 workT[found_indx] = -1.e20;
576 for (j =
band_tab[found_indx]; j < band_tab[found_indx + 1] && (freebits > summer); j++) {
581 }
while (freebits > summer);
583 if (freebits < summer) {
584 for (i = 0; i <
BANDS; i++) {
588 if (stream_format_code & 0x2) {
594 while (freebits < summer) {
597 for (i = 0; i <
BANDS; i++) {
598 if (workT[i] < lowest) {
605 workT[low_indx] = lowest + 2.0;
608 workT[low_indx] = 1.e20;
610 for (j =
band_tab[low_indx]; j <
band_tab[low_indx+1] && (freebits < summer); j++) {
627 for (i = 0; i <
BANDS; i++) {
634 for (j = band_tab[i]; j < band_tab[i + 1]; j++) {
665 if (j < band_tab[i + 1]) {
686 for (i = 0; i <
BANDS; i++) {
687 workT[i] = (chctx->
bitsBandT[i] == 6) ? -1.e20
691 while (corrected < summer) {
692 if (highest <= -1.e20)
697 for (i = 0; i <
BANDS; i++) {
698 if (workT[i] > highest) {
704 if (highest > -1.e20) {
705 workT[found_indx] -= 2.0;
706 if (++(chctx->
bitsBandT[found_indx]) == 6)
707 workT[found_indx] = -1.e20;
709 for (j =
band_tab[found_indx]; j <
band_tab[found_indx+1] && (corrected < summer); j++) {
727 for (i = 0; i <
COEFFS / 2; i++) {
739 for (i = 0; i <
COEFFS / 2; i++) {
753 int stream_format_code)
756 int middle_value, cw_len, max_size;
757 const float *quantizer;
759 for (i = 0; i <
BANDS; i++) {
764 if (cw_len <= 0 || chctx->skipFlags[j])
767 max_size = 1 << cw_len;
768 middle_value = max_size >> 1;
795 int i, j, cw_len, cw;
797 for (i = 0; i <
BANDS; i++) {
808 "Potential problem on band %i, coefficient %i"
809 ": cw_len=%i\n", i, j, cw_len);
825 for (i = 0; i <
BANDS; i++) {
831 if (((
int)((band_tab[i + 1] - band_tab[i]) * 1.5) > chctx->
sumLenArr[i]) && (chctx->
sumLenArr[i] > 0))
837 for (i = 0; i <
BANDS; i++) {
849 for (i = 0; i <
BANDS; i++) {
866 int stream_format_code;
867 int imc_hdr, i, j, ret;
870 int counter, bitscount;
876 if (imc_hdr & 0x18) {
883 if (stream_format_code & 0x04)
887 for (i = 0; i <
BANDS; i++)
895 if (stream_format_code & 0x1)
900 if (stream_format_code & 0x1)
903 else if (stream_format_code & 0x4)
910 for(i=0; i<
BANDS; i++) {
920 if (stream_format_code & 0x1) {
921 for (i = 0; i <
BANDS; i++) {
928 for (i = 0; i <
BANDS; i++) {
937 for (i = 0; i < BANDS - 1; i++)
948 if (stream_format_code & 0x2) {
955 for (i = 1; i < 4; i++) {
956 if (stream_format_code & 0x1)
969 if (!(stream_format_code & 0x2))
981 if (stream_format_code & 0x1) {
982 for (i = 0; i <
BANDS; i++)
988 for (i = 0; i <
BANDS; i++) {
1014 int *got_frame_ptr,
AVPacket *avpkt)
1018 int buf_size = avpkt->
size;
1025 if (buf_size < IMC_BLOCK_SIZE * avctx->
channels) {
1035 for (i = 0; i < avctx->
channels; i++) {
1076 #if CONFIG_IMC_DECODER
1092 #if CONFIG_IAC_DECODER
int skipFlags[COEFFS]
skip coefficient decoding or not
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
int codewords[COEFFS]
raw codewords read from bitstream
ptrdiff_t const GLvoid * data
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
int skipFlagRaw[BANDS]
skip flags are stored in raw form or not
void(* bswap16_buf)(uint16_t *dst, const uint16_t *src, int len)
static av_cold int init(AVCodecContext *avctx)
static const int vlc_offsets[17]
float mdct_sine_window[COEFFS]
MDCT tables.
void(* fft_permute)(struct FFTContext *s, FFTComplex *z)
Do the permutation needed BEFORE calling fft_calc().
static const uint8_t imc_huffman_lens[4][4][18]
int skipFlagCount[BANDS]
skipped coefficients per band
static const float imc_weights2[31]
#define AV_CH_LAYOUT_STEREO
static void imc_read_level_coeffs(IMCContext *q, int stream_format_code, int *levlCoeffs)
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
enum AVSampleFormat sample_fmt
audio sample format
int bandFlagsBuf[BANDS]
flags for each band
static av_cold int imc_decode_close(AVCodecContext *avctx)
static const int8_t cyclTab[32]
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
static int get_bits_count(const GetBitContext *s)
static const float imc_weights1[31]
bitstream reader API header.
static void imc_get_skip_coeff(IMCContext *q, IMCChannel *chctx)
static void imc_refine_bit_allocation(IMCContext *q, IMCChannel *chctx)
static av_always_inline double ff_exp10(double x)
Compute 10^x for floating point values.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
static const float *const imc_exp_tab2
#define init_vlc(vlc, nb_bits, nb_codes,bits, bits_wrap, bits_size,codes, codes_wrap, codes_size,flags)
static void imc_decode_level_coefficients_raw(IMCContext *q, int *levlCoeffBuf, float *flcoeffs1, float *flcoeffs2)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void(* butterflies_float)(float *av_restrict v1, float *av_restrict v2, int len)
Calculate the sum and difference of two vectors of floats.
static void imc_imdct256(IMCContext *q, IMCChannel *chctx, int channels)
int flags
AV_CODEC_FLAG_*.
static void imc_calculate_coeffs(IMCContext *q, float *flcoeffs1, float *flcoeffs2, int *bandWidthT, float *flcoeffs3, float *flcoeffs5)
const char * name
Name of the codec implementation.
uint64_t channel_layout
Audio channel layout.
static const int8_t cyclTab2[32]
static int imc_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
static void imc_decode_level_coefficients2(IMCContext *q, int *levlCoeffBuf, float *old_floor, float *flcoeffs1, float *flcoeffs2)
common internal API header
audio channel layout utility functions
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
static const uint16_t band_tab[33]
int bitsBandT[BANDS]
how many bits per codeword in band
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
float last_fft_im[COEFFS]
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static void imc_get_coeffs(AVCodecContext *avctx, IMCContext *q, IMCChannel *chctx)
#define AV_LOG_INFO
Standard information.
static const float xTab[14]
FFTComplex samples[COEFFS/2]
Libavcodec external API header.
AVSampleFormat
Audio sample formats.
static int inverse_quant_coeff(IMCContext *q, IMCChannel *chctx, int stream_format_code)
int sample_rate
samples per second
void AAC_RENAME() ff_sine_window_init(INTFLOAT *window, int n)
Generate a sine window.
main external API structure.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
static double freq2bark(double freq)
static unsigned int get_bits1(GetBitContext *s)
int bandWidthT[BANDS]
codewords per band
static av_cold void flush(AVCodecContext *avctx)
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
static VLC huffman_vlc[4][4]
static VLC_TYPE vlc_tables[VLC_TABLES_SIZE][2]
static const float imc_quantizer1[4][8]
static av_cold void iac_generate_tabs(IMCContext *q, int sampling_rate)
internal math functions header
common internal api header.
static int imc_decode_block(AVCodecContext *avctx, IMCContext *q, int ch)
#define INIT_VLC_USE_NEW_STATIC
static int bit_allocation(IMCContext *q, IMCChannel *chctx, int stream_format_code, int freebits, int flag)
Perform bit allocation depending on bits available.
void(* fft_calc)(struct FFTContext *s, FFTComplex *z)
Do a complex FFT with the parameters defined in ff_fft_init().
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
static const uint8_t imc_cb_select[4][32]
av_cold void ff_bswapdsp_init(BswapDSPContext *c)
int channels
number of audio channels
VLC_TYPE(* table)[2]
code, bits
static enum AVSampleFormat sample_fmts[]
#define LOCAL_ALIGNED_16(t, v,...)
static void imc_adjust_bit_allocation(IMCContext *q, IMCChannel *chctx, int summer)
Increase highest' band coefficient sizes as some bits won't be used.
static const float imc_quantizer2[2][56]
int sumLenArr[BANDS]
bits for all coeffs in band
static const uint8_t imc_huffman_sizes[4]
uint8_t ** extended_data
pointers to the data planes/channels.
#define AV_CH_LAYOUT_MONO
static void imc_read_level_coeffs_raw(IMCContext *q, int stream_format_code, int *levlCoeffs)
This structure stores compressed data.
static void imc_decode_level_coefficients(IMCContext *q, int *levlCoeffBuf, float *flcoeffs1, float *flcoeffs2)
int skipFlagBits[BANDS]
bits used to code skip flags
static av_cold int imc_decode_init(AVCodecContext *avctx)
int nb_samples
number of audio samples (per channel) described by this frame
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static const float imc_exp_tab[32]
static const uint16_t imc_huffman_bits[4][4][18]
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(constuint8_t *) pi-0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(constint16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(constint32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(constint64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(constfloat *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(constdouble *) pi *(INT64_C(1)<< 63)))#defineFMT_PAIR_FUNC(out, in) staticconv_func_type *constfmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE_FMT_NB]={FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64),};staticvoidcpy1(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, len);}staticvoidcpy2(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 2 *len);}staticvoidcpy4(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 4 *len);}staticvoidcpy8(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 8 *len);}AudioConvert *swri_audio_convert_alloc(enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, constint *ch_map, intflags){AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) returnNULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) returnNULL;if(channels==1){in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);}ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map){switch(av_get_bytes_per_sample(in_fmt)){case1:ctx->simd_f=cpy1;break;case2:ctx->simd_f=cpy2;break;case4:ctx->simd_f=cpy4;break;case8:ctx->simd_f=cpy8;break;}}if(HAVE_X86ASM &&1) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels);if(ARCH_ARM) swri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels);if(ARCH_AARCH64) swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels);returnctx;}voidswri_audio_convert_free(AudioConvert **ctx){av_freep(ctx);}intswri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, intlen){intch;intoff=0;constintos=(out->planar?1:out->ch_count)*out->bps;unsignedmisaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask){intplanes=in->planar?in->ch_count:1;unsignedm=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;}if(ctx->out_simd_align_mask){intplanes=out->planar?out->ch_count:1;unsignedm=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;}if(ctx->simd_f &&!ctx->ch_map &&!misaligned){off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){if(out->planar==in->planar){intplanes=out->planar?out->ch_count:1;for(ch=0;ch< planes;ch++){ctx->simd_f(out-> ch ch
int CWlengthT[COEFFS]
how many bits in each codeword