43 #define EXPMAX ((19 + EXPVLCBITS - 1) / EXPVLCBITS)
45 #define HGAINVLCBITS 9
46 #define HGAINMAX ((13 + HGAINVLCBITS - 1) / HGAINVLCBITS)
52 int prec,
const float *
tab,
int n)
57 for (i = 0; i <
n; i++) {
86 flags2 =
AV_RL16(extradata + 2);
88 flags2 =
AV_RL16(extradata + 4);
96 av_log(avctx,
AV_LOG_WARNING,
"Disabling use_variable_block_len, if this fails contact the ffmpeg developers and send us the file\n");
148 t.v = ((
u.v <<
LSP_POW_BITS) & ((1 << 23) - 1)) | (127 << 23);
159 wdel =
M_PI / frame_len;
160 for (i = 0; i < frame_len; i++)
164 for (i = 0; i < 256; i++) {
190 float p, q, w,
v, val_max;
193 for (i = 0; i <
n; i++) {
209 *val_max_ptr = val_max;
221 if (i == 0 || i >= 8)
234 1.7782794100389e-04, 2.0535250264571e-04,
235 2.3713737056617e-04, 2.7384196342644e-04,
236 3.1622776601684e-04, 3.6517412725484e-04,
237 4.2169650342858e-04, 4.8696752516586e-04,
238 5.6234132519035e-04, 6.4938163157621e-04,
239 7.4989420933246e-04, 8.6596432336006e-04,
240 1.0000000000000e-03, 1.1547819846895e-03,
241 1.3335214321633e-03, 1.5399265260595e-03,
242 1.7782794100389e-03, 2.0535250264571e-03,
243 2.3713737056617e-03, 2.7384196342644e-03,
244 3.1622776601684e-03, 3.6517412725484e-03,
245 4.2169650342858e-03, 4.8696752516586e-03,
246 5.6234132519035e-03, 6.4938163157621e-03,
247 7.4989420933246e-03, 8.6596432336006e-03,
248 1.0000000000000e-02, 1.1547819846895e-02,
249 1.3335214321633e-02, 1.5399265260595e-02,
250 1.7782794100389e-02, 2.0535250264571e-02,
251 2.3713737056617e-02, 2.7384196342644e-02,
252 3.1622776601684e-02, 3.6517412725484e-02,
253 4.2169650342858e-02, 4.8696752516586e-02,
254 5.6234132519035e-02, 6.4938163157621e-02,
255 7.4989420933246e-02, 8.6596432336007e-02,
256 1.0000000000000e-01, 1.1547819846895e-01,
257 1.3335214321633e-01, 1.5399265260595e-01,
258 1.7782794100389e-01, 2.0535250264571e-01,
259 2.3713737056617e-01, 2.7384196342644e-01,
260 3.1622776601684e-01, 3.6517412725484e-01,
261 4.2169650342858e-01, 4.8696752516586e-01,
262 5.6234132519035e-01, 6.4938163157621e-01,
263 7.4989420933246e-01, 8.6596432336007e-01,
264 1.0000000000000e+00, 1.1547819846895e+00,
265 1.3335214321633e+00, 1.5399265260595e+00,
266 1.7782794100389e+00, 2.0535250264571e+00,
267 2.3713737056617e+00, 2.7384196342644e+00,
268 3.1622776601684e+00, 3.6517412725484e+00,
269 4.2169650342858e+00, 4.8696752516586e+00,
270 5.6234132519035e+00, 6.4938163157621e+00,
271 7.4989420933246e+00, 8.6596432336007e+00,
272 1.0000000000000e+01, 1.1547819846895e+01,
273 1.3335214321633e+01, 1.5399265260595e+01,
274 1.7782794100389e+01, 2.0535250264571e+01,
275 2.3713737056617e+01, 2.7384196342644e+01,
276 3.1622776601684e+01, 3.6517412725484e+01,
277 4.2169650342858e+01, 4.8696752516586e+01,
278 5.6234132519035e+01, 6.4938163157621e+01,
279 7.4989420933246e+01, 8.6596432336007e+01,
280 1.0000000000000e+02, 1.1547819846895e+02,
281 1.3335214321633e+02, 1.5399265260595e+02,
282 1.7782794100389e+02, 2.0535250264571e+02,
283 2.3713737056617e+02, 2.7384196342644e+02,
284 3.1622776601684e+02, 3.6517412725484e+02,
285 4.2169650342858e+02, 4.8696752516586e+02,
286 5.6234132519035e+02, 6.4938163157621e+02,
287 7.4989420933246e+02, 8.6596432336007e+02,
288 1.0000000000000e+03, 1.1547819846895e+03,
289 1.3335214321633e+03, 1.5399265260595e+03,
290 1.7782794100389e+03, 2.0535250264571e+03,
291 2.3713737056617e+03, 2.7384196342644e+03,
292 3.1622776601684e+03, 3.6517412725484e+03,
293 4.2169650342858e+03, 4.8696752516586e+03,
294 5.6234132519035e+03, 6.4938163157621e+03,
295 7.4989420933246e+03, 8.6596432336007e+03,
296 1.0000000000000e+04, 1.1547819846895e+04,
297 1.3335214321633e+04, 1.5399265260595e+04,
298 1.7782794100389e+04, 2.0535250264571e+04,
299 2.3713737056617e+04, 2.7384196342644e+04,
300 3.1622776601684e+04, 3.6517412725484e+04,
301 4.2169650342858e+04, 4.8696752516586e+04,
302 5.6234132519035e+04, 6.4938163157621e+04,
303 7.4989420933246e+04, 8.6596432336007e+04,
304 1.0000000000000e+05, 1.1547819846895e+05,
305 1.3335214321633e+05, 1.5399265260595e+05,
306 1.7782794100389e+05, 2.0535250264571e+05,
307 2.3713737056617e+05, 2.7384196342644e+05,
308 3.1622776601684e+05, 3.6517412725484e+05,
309 4.2169650342858e+05, 4.8696752516586e+05,
310 5.6234132519035e+05, 6.4938163157621e+05,
311 7.4989420933246e+05, 8.6596432336007e+05,
319 int last_exp,
n, code;
322 uint32_t *q, *q_end, iv;
323 const float *ptab = pow_tab + 60;
324 const uint32_t *iptab = (
const uint32_t *) ptab;
333 iv = iptab[last_exp];
341 }
while ((n -= 4) > 0);
352 last_exp += code - 60;
359 iv = iptab[last_exp];
368 }
while ((n -= 4) > 0);
383 int block_len, bsize,
n;
400 memcpy(out + n + block_len, in + n + block_len, n *
sizeof(
float));
417 memcpy(out, in, n *
sizeof(
float));
422 memset(out + n + block_len, 0, n *
sizeof(
float));
432 int n,
v,
a, ch, bsize;
433 int coef_nb_bits, total_gain;
452 "prev_block_len_bits %d out of range\n",
460 "block_len_bits %d out of range\n",
473 "next_block_len_bits %d out of range\n",
540 for (i = 0; i <
n; i++) {
554 val = (int) 0x80000000;
555 for (i = 0; i <
n; i++) {
557 if (val == (
int) 0x80000000) {
564 "hgain vlc invalid\n");
603 0, ptr, 0, nb_coefs[ch],
613 mdct_norm = 1.0 / (float) n4;
615 mdct_norm *= sqrt(n4);
622 float *coefs, *exponents,
mult, mult1,
noise;
623 int i, j,
n, n1, last_high_band, esize;
629 mult = pow(10, total_gain * 0.05) / s->
max_exponent[ch];
631 coefs = s->
coefs[ch];
637 exponents[i << bsize >> esize] * mult1;
648 for (j = 0; j < n1; j++) {
654 for (i = 0; i <
n; i++) {
655 v = exponents[i << bsize >> esize];
658 exp_power[j] = e2 /
n;
660 ff_tlog(s->
avctx,
"%d: power=%f (%d)\n", j, exp_power[j], n);
662 exponents += n << bsize >> esize;
667 for (j = -1; j < n1; j++) {
675 mult1 = sqrt(exp_power[j] / exp_power[last_high_band]);
680 for (i = 0; i <
n; i++) {
683 *coefs++ = noise * exponents[i << bsize >> esize] * mult1;
685 exponents += n << bsize >> esize;
688 for (i = 0; i <
n; i++) {
691 *coefs++ = ((*coefs1++) + noise) *
692 exponents[i << bsize >> esize] *
mult;
694 exponents += n << bsize >> esize;
700 mult1 = mult * exponents[(-(1 << bsize)) >> esize];
701 for (i = 0; i <
n; i++) {
710 for (i = 0; i <
n; i++)
711 *coefs++ = coefs1[i] * exponents[i << bsize >> esize] * mult;
713 for (i = 0; i <
n; i++)
791 memcpy(samples[ch] + samples_offset, s->
frame_out[ch],
798 dump_floats(s,
"samples", 6, samples[ch] + samples_offset,
807 int *got_frame_ptr,
AVPacket *avpkt)
811 int buf_size = avpkt->
size;
813 int nb_frames, bit_offset, i, pos,
len, ret;
818 ff_tlog(avctx,
"***decode_superframe:\n");
824 if (buf_size < avctx->block_align) {
826 "Input packet size too small (%d < %d)\n",
839 if (nb_frames <= 0) {
842 "nb_frames is %d bits left %d\n",
878 "Invalid last frame bit offset %d > buf size %d (%d)\n",
922 for (i = 0; i < nb_frames; i++) {
933 len = buf_size - pos;
949 (int8_t *) samples - (int8_t *) data, avctx->
block_align);
969 #if CONFIG_WMAV1_DECODER
985 #if CONFIG_WMAV2_DECODER
const struct AVCodec * codec
const char const char void * val
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static void wma_lsp_to_curve(WMACodecContext *s, float *out, float *val_max_ptr, int n, float *lsp)
NOTE: We use the same code as Vorbis here.
This structure describes decoded (raw) audio or video data.
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 next_block_len_bits
log2 of next block length
static av_cold int init(AVCodecContext *avctx)
static const float pow_tab[]
pow(10, i / 16.0) for i in -60..95
int ff_wma_run_level_decode(AVCodecContext *avctx, GetBitContext *gb, VLC *vlc, const float *level_table, const uint16_t *run_table, int version, WMACoef *ptr, int offset, int num_coefs, int block_len, int frame_len_bits, int coef_nb_bits)
Decode run level compressed coefficients.
int block_len
block length in samples
void(* vector_fmul_reverse)(float *dst, const float *src0, const float *src1, int len)
Calculate the entry wise product of two vectors of floats, and store the result in a vector of floats...
float exponents[MAX_CHANNELS][BLOCK_MAX_SIZE]
static void wma_window(WMACodecContext *s, float *out)
Apply MDCT window and add into output.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs...
float lsp_pow_m_table2[(1<< LSP_POW_BITS)]
Macro definitions for various function/variable attributes.
static int wma_decode_block(WMACodecContext *s)
float lsp_cos_table[BLOCK_MAX_SIZE]
int high_band_start[BLOCK_NB_SIZES]
index of first coef in high band
enum AVSampleFormat sample_fmt
audio sample format
float WMACoef
type for decoded coefficients, int16_t would be enough for wma 1/2
const uint8_t ff_aac_scalefactor_bits[121]
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
int block_pos
current position in frame
static int decode_exp_vlc(WMACodecContext *s, int ch)
decode exponents coded with VLC codes
static int get_bits_count(const GetBitContext *s)
float lsp_pow_m_table1[(1<< LSP_POW_BITS)]
int nb_block_sizes
number of block sizes
int ff_wma_total_gain_to_bits(int total_gain)
static int get_bits_left(GetBitContext *gb)
static float pow_m1_4(WMACodecContext *s, float x)
compute x^-0.25 with an exponent and mantissa table.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define PTRDIFF_SPECIFIER
uint16_t exponent_bands[BLOCK_NB_SIZES][25]
uint8_t channel_coded[MAX_CHANNELS]
true if channel is coded
#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.
uint8_t last_superframe[MAX_CODED_SUPERFRAME_SIZE+AV_INPUT_BUFFER_PADDING_SIZE]
const char * name
Name of the codec implementation.
static int wma_decode_superframe(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
FFTSample output[BLOCK_MAX_SIZE *2]
const uint8_t ff_wma_hgain_huffbits[37]
Libavcodec external API header.
static av_cold int wma_decode_init(AVCodecContext *avctx)
void(* imdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input)
int exponent_high_bands[BLOCK_NB_SIZES][HIGH_BAND_MAX_SIZE]
int ff_wma_end(AVCodecContext *avctx)
int high_band_values[MAX_CHANNELS][HIGH_BAND_MAX_SIZE]
#define MAX_CODED_SUPERFRAME_SIZE
av_cold int ff_wma_init(AVCodecContext *avctx, int flags2)
const uint16_t ff_wma_hgain_huffcodes[37]
int version
1 = 0x160 (WMAV1), 2 = 0x161 (WMAV2)
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
int frame_len
frame length in samples
#define FF_ARRAY_ELEMS(a)
static int noise(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args, uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size, int keyframe)
static av_cold void flush(AVCodecContext *avctx)
int frame_len_bits
frame_len = 1 << frame_len_bits
AVSampleFormat
Audio sample formats.
static int wma_decode_frame(WMACodecContext *s, float **samples, int samples_offset)
#define HIGH_BAND_MAX_SIZE
int use_exp_vlc
exponent coding: 0 = lsp, 1 = vlc + delta
main external API structure.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
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){if(!*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));if(!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=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);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);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) 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_log(ac->avr, AV_LOG_TRACE,"%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
#define init_vlc(vlc, nb_bits, nb_codes,bits, bits_wrap, bits_size,codes, codes_wrap, codes_size,flags)
static void wma_lsp_to_curve_init(WMACodecContext *s, int frame_len)
float frame_out[MAX_CHANNELS][BLOCK_MAX_SIZE *2]
static int16_t mult(Float11 *f1, Float11 *f2)
int exponent_high_sizes[BLOCK_NB_SIZES]
void(* vector_fmul_add)(float *dst, const float *src0, const float *src1, const float *src2, int len)
Calculate the entry wise product of two vectors of floats, add a third vector of floats and store the...
static void decode_exp_lsp(WMACodecContext *s, int ch)
decode exponents coded with LSP coefficients (same idea as Vorbis)
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits(GetBitContext *s, int n)
int block_num
block number in current frame
int use_noise_coding
true if perceptual noise is added
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
int use_variable_block_len
uint8_t ms_stereo
true if mid/side stereo mode
FFTContext mdct_ctx[BLOCK_NB_SIZES]
const uint32_t ff_aac_scalefactor_code[121]
int exponents_bsize[MAX_CHANNELS]
log2 ratio frame/exp. length
float coefs[MAX_CHANNELS][BLOCK_MAX_SIZE]
int prev_block_len_bits
log2 of prev block length
static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt)
int coefs_end[BLOCK_NB_SIZES]
max number of coded coefficients
float lsp_pow_e_table[256]
const float ff_wma_lsp_codebook[NB_LSP_COEFS][16]
common internal api header.
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
int channels
number of audio channels
VLC_TYPE(* table)[2]
code, bits
WMACoef coefs1[MAX_CHANNELS][BLOCK_MAX_SIZE]
static const uint8_t * align_get_bits(GetBitContext *s)
static const struct twinvq_data tab
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){if(!*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));if(!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=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);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);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) 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_log(ac->avr, AV_LOG_TRACE,"%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
static enum AVSampleFormat sample_fmts[]
float max_exponent[MAX_CHANNELS]
int coefs_start
first coded coef
int block_len_bits
log2 of current block length
uint8_t ** extended_data
pointers to the data planes/channels.
This structure stores compressed data.
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.
int high_band_coded[MAX_CHANNELS][HIGH_BAND_MAX_SIZE]
float noise_table[NOISE_TAB_SIZE]
const float * windows[BLOCK_NB_SIZES]