Go to the documentation of this file.
44 #define EXPMAX ((19 + EXPVLCBITS - 1) / EXPVLCBITS)
46 #define HGAINVLCBITS 9
47 #define HGAINMAX ((13 + HGAINVLCBITS - 1) / HGAINVLCBITS)
53 int prec,
const float *
tab,
int n)
58 for (
i = 0;
i <
n;
i++) {
87 flags2 =
AV_RL16(extradata + 2);
89 flags2 =
AV_RL16(extradata + 4);
91 s->use_exp_vlc = flags2 & 0x0001;
92 s->use_bit_reservoir = flags2 & 0x0002;
93 s->use_variable_block_len = flags2 & 0x0004;
96 if (
AV_RL16(extradata+4)==0xd &&
s->use_variable_block_len){
97 av_log(avctx,
AV_LOG_WARNING,
"Disabling use_variable_block_len, if this fails contact the ffmpeg developers and send us the file\n");
98 s->use_variable_block_len= 0;
103 s->max_exponent[
i] = 1.0;
109 for (
i = 0;
i <
s->nb_block_sizes;
i++)
112 if (
s->use_noise_coding) {
149 t.v = ((
u.v <<
LSP_POW_BITS) & ((1 << 23) - 1)) | (127 << 23);
150 a =
s->lsp_pow_m_table1[m];
151 b =
s->lsp_pow_m_table2[m];
152 return s->lsp_pow_e_table[e] * (
a +
b * t.f);
160 wdel =
M_PI / frame_len;
161 for (
i = 0;
i < frame_len;
i++)
162 s->lsp_cos_table[
i] = 2.0f * cos(wdel *
i);
165 for (
i = 0;
i < 256;
i++) {
167 s->lsp_pow_e_table[
i] =
exp2f(e * -0.25);
177 s->lsp_pow_m_table1[
i] = 2 *
a -
b;
178 s->lsp_pow_m_table2[
i] =
b -
a;
191 float p, q,
w, v, val_max;
194 for (
i = 0;
i <
n;
i++) {
197 w =
s->lsp_cos_table[
i];
210 *val_max_ptr = val_max;
222 if (
i == 0 ||
i >= 8)
230 s->block_len, lsp_coefs);
235 1.7782794100389e-04, 2.0535250264571e-04,
236 2.3713737056617e-04, 2.7384196342644e-04,
237 3.1622776601684e-04, 3.6517412725484e-04,
238 4.2169650342858e-04, 4.8696752516586e-04,
239 5.6234132519035e-04, 6.4938163157621e-04,
240 7.4989420933246e-04, 8.6596432336006e-04,
241 1.0000000000000e-03, 1.1547819846895e-03,
242 1.3335214321633e-03, 1.5399265260595e-03,
243 1.7782794100389e-03, 2.0535250264571e-03,
244 2.3713737056617e-03, 2.7384196342644e-03,
245 3.1622776601684e-03, 3.6517412725484e-03,
246 4.2169650342858e-03, 4.8696752516586e-03,
247 5.6234132519035e-03, 6.4938163157621e-03,
248 7.4989420933246e-03, 8.6596432336006e-03,
249 1.0000000000000e-02, 1.1547819846895e-02,
250 1.3335214321633e-02, 1.5399265260595e-02,
251 1.7782794100389e-02, 2.0535250264571e-02,
252 2.3713737056617e-02, 2.7384196342644e-02,
253 3.1622776601684e-02, 3.6517412725484e-02,
254 4.2169650342858e-02, 4.8696752516586e-02,
255 5.6234132519035e-02, 6.4938163157621e-02,
256 7.4989420933246e-02, 8.6596432336007e-02,
257 1.0000000000000e-01, 1.1547819846895e-01,
258 1.3335214321633e-01, 1.5399265260595e-01,
259 1.7782794100389e-01, 2.0535250264571e-01,
260 2.3713737056617e-01, 2.7384196342644e-01,
261 3.1622776601684e-01, 3.6517412725484e-01,
262 4.2169650342858e-01, 4.8696752516586e-01,
263 5.6234132519035e-01, 6.4938163157621e-01,
264 7.4989420933246e-01, 8.6596432336007e-01,
265 1.0000000000000e+00, 1.1547819846895e+00,
266 1.3335214321633e+00, 1.5399265260595e+00,
267 1.7782794100389e+00, 2.0535250264571e+00,
268 2.3713737056617e+00, 2.7384196342644e+00,
269 3.1622776601684e+00, 3.6517412725484e+00,
270 4.2169650342858e+00, 4.8696752516586e+00,
271 5.6234132519035e+00, 6.4938163157621e+00,
272 7.4989420933246e+00, 8.6596432336007e+00,
273 1.0000000000000e+01, 1.1547819846895e+01,
274 1.3335214321633e+01, 1.5399265260595e+01,
275 1.7782794100389e+01, 2.0535250264571e+01,
276 2.3713737056617e+01, 2.7384196342644e+01,
277 3.1622776601684e+01, 3.6517412725484e+01,
278 4.2169650342858e+01, 4.8696752516586e+01,
279 5.6234132519035e+01, 6.4938163157621e+01,
280 7.4989420933246e+01, 8.6596432336007e+01,
281 1.0000000000000e+02, 1.1547819846895e+02,
282 1.3335214321633e+02, 1.5399265260595e+02,
283 1.7782794100389e+02, 2.0535250264571e+02,
284 2.3713737056617e+02, 2.7384196342644e+02,
285 3.1622776601684e+02, 3.6517412725484e+02,
286 4.2169650342858e+02, 4.8696752516586e+02,
287 5.6234132519035e+02, 6.4938163157621e+02,
288 7.4989420933246e+02, 8.6596432336007e+02,
289 1.0000000000000e+03, 1.1547819846895e+03,
290 1.3335214321633e+03, 1.5399265260595e+03,
291 1.7782794100389e+03, 2.0535250264571e+03,
292 2.3713737056617e+03, 2.7384196342644e+03,
293 3.1622776601684e+03, 3.6517412725484e+03,
294 4.2169650342858e+03, 4.8696752516586e+03,
295 5.6234132519035e+03, 6.4938163157621e+03,
296 7.4989420933246e+03, 8.6596432336007e+03,
297 1.0000000000000e+04, 1.1547819846895e+04,
298 1.3335214321633e+04, 1.5399265260595e+04,
299 1.7782794100389e+04, 2.0535250264571e+04,
300 2.3713737056617e+04, 2.7384196342644e+04,
301 3.1622776601684e+04, 3.6517412725484e+04,
302 4.2169650342858e+04, 4.8696752516586e+04,
303 5.6234132519035e+04, 6.4938163157621e+04,
304 7.4989420933246e+04, 8.6596432336007e+04,
305 1.0000000000000e+05, 1.1547819846895e+05,
306 1.3335214321633e+05, 1.5399265260595e+05,
307 1.7782794100389e+05, 2.0535250264571e+05,
308 2.3713737056617e+05, 2.7384196342644e+05,
309 3.1622776601684e+05, 3.6517412725484e+05,
310 4.2169650342858e+05, 4.8696752516586e+05,
311 5.6234132519035e+05, 6.4938163157621e+05,
312 7.4989420933246e+05, 8.6596432336007e+05,
320 int last_exp,
n,
code;
323 uint32_t *q, *q_end, iv;
324 const float *ptab =
pow_tab + 60;
325 const uint32_t *iptab = (
const uint32_t *) ptab;
327 ptr =
s->exponent_bands[
s->frame_len_bits -
s->block_len_bits];
328 q = (uint32_t *)
s->exponents[
ch];
329 q_end = q +
s->block_len;
331 if (
s->version == 1) {
334 iv = iptab[last_exp];
342 }
while ((
n -= 4) > 0);
353 last_exp +=
code - 60;
360 iv = iptab[last_exp];
369 }
while ((
n -= 4) > 0);
371 s->max_exponent[
ch] = max_scale;
383 float *
in =
s->output;
384 int block_len, bsize,
n;
387 if (
s->block_len_bits <=
s->prev_block_len_bits) {
388 block_len =
s->block_len;
389 bsize =
s->frame_len_bits -
s->block_len_bits;
391 s->fdsp->vector_fmul_add(
out,
in,
s->windows[bsize],
394 block_len = 1 <<
s->prev_block_len_bits;
395 n = (
s->block_len - block_len) / 2;
396 bsize =
s->frame_len_bits -
s->prev_block_len_bits;
398 s->fdsp->vector_fmul_add(
out +
n,
in +
n,
s->windows[bsize],
401 memcpy(
out +
n + block_len,
in +
n + block_len,
n *
sizeof(
float));
408 if (
s->block_len_bits <=
s->next_block_len_bits) {
409 block_len =
s->block_len;
410 bsize =
s->frame_len_bits -
s->block_len_bits;
412 s->fdsp->vector_fmul_reverse(
out,
in,
s->windows[bsize], block_len);
414 block_len = 1 <<
s->next_block_len_bits;
415 n = (
s->block_len - block_len) / 2;
416 bsize =
s->frame_len_bits -
s->next_block_len_bits;
418 memcpy(
out,
in,
n *
sizeof(
float));
420 s->fdsp->vector_fmul_reverse(
out +
n,
in +
n,
s->windows[bsize],
423 memset(
out +
n + block_len, 0,
n *
sizeof(
float));
433 int n, v,
a,
ch, bsize;
434 int coef_nb_bits, total_gain;
440 ff_tlog(
s->avctx,
"***decode_block: %d:%d\n",
441 s->frame_count - 1,
s->block_num);
445 if (
s->use_variable_block_len) {
448 if (
s->reset_block_lengths) {
449 s->reset_block_lengths = 0;
451 if (v >=
s->nb_block_sizes) {
453 "prev_block_len_bits %d out of range\n",
454 s->frame_len_bits - v);
457 s->prev_block_len_bits =
s->frame_len_bits - v;
459 if (v >=
s->nb_block_sizes) {
461 "block_len_bits %d out of range\n",
462 s->frame_len_bits - v);
465 s->block_len_bits =
s->frame_len_bits - v;
468 s->prev_block_len_bits =
s->block_len_bits;
469 s->block_len_bits =
s->next_block_len_bits;
472 if (v >=
s->nb_block_sizes) {
474 "next_block_len_bits %d out of range\n",
475 s->frame_len_bits - v);
478 s->next_block_len_bits =
s->frame_len_bits - v;
481 s->next_block_len_bits =
s->frame_len_bits;
482 s->prev_block_len_bits =
s->frame_len_bits;
483 s->block_len_bits =
s->frame_len_bits;
486 if (
s->frame_len_bits -
s->block_len_bits >=
s->nb_block_sizes){
492 s->block_len = 1 <<
s->block_len_bits;
493 if ((
s->block_pos +
s->block_len) >
s->frame_len) {
498 if (
s->avctx->channels == 2)
501 for (
ch = 0;
ch <
s->avctx->channels;
ch++) {
503 s->channel_coded[
ch] =
a;
507 bsize =
s->frame_len_bits -
s->block_len_bits;
531 n =
s->coefs_end[bsize] -
s->coefs_start;
532 for (
ch = 0;
ch <
s->avctx->channels;
ch++)
536 if (
s->use_noise_coding) {
537 for (
ch = 0;
ch <
s->avctx->channels;
ch++) {
538 if (
s->channel_coded[
ch]) {
540 n =
s->exponent_high_sizes[bsize];
541 for (
i = 0;
i <
n;
i++) {
543 s->high_band_coded[
ch][
i] =
a;
546 nb_coefs[
ch] -=
s->exponent_high_bands[bsize][
i];
550 for (
ch = 0;
ch <
s->avctx->channels;
ch++) {
551 if (
s->channel_coded[
ch]) {
554 n =
s->exponent_high_sizes[bsize];
556 for (
i = 0;
i <
n;
i++) {
557 if (
s->high_band_coded[
ch][
i]) {
558 if (
val == (
int) 0x80000000) {
565 "hgain vlc invalid\n");
570 s->high_band_values[
ch][
i] =
val;
578 if ((
s->block_len_bits ==
s->frame_len_bits) ||
get_bits1(&
s->gb)) {
579 for (
ch = 0;
ch <
s->avctx->channels;
ch++) {
580 if (
s->channel_coded[
ch]) {
581 if (
s->use_exp_vlc) {
587 s->exponents_bsize[
ch] = bsize;
588 s->exponents_initialized[
ch] = 1;
593 for (
ch = 0;
ch <
s->avctx->channels;
ch++) {
594 if (
s->channel_coded[
ch] && !
s->exponents_initialized[
ch])
599 for (
ch = 0;
ch <
s->avctx->channels;
ch++) {
600 if (
s->channel_coded[
ch]) {
606 tindex = (
ch == 1 &&
s->ms_stereo);
607 memset(ptr, 0,
s->block_len *
sizeof(
WMACoef));
609 s->level_table[tindex],
s->run_table[tindex],
610 0, ptr, 0, nb_coefs[
ch],
611 s->block_len,
s->frame_len_bits, coef_nb_bits);
613 if (
s->version == 1 &&
s->avctx->channels >= 2)
619 int n4 =
s->block_len / 2;
620 mdct_norm = 1.0 / (float) n4;
622 mdct_norm *= sqrt(n4);
626 for (
ch = 0;
ch <
s->avctx->channels;
ch++) {
627 if (
s->channel_coded[
ch]) {
629 float *coefs, *exponents,
mult, mult1,
noise;
630 int i, j,
n, n1, last_high_band, esize;
633 coefs1 =
s->coefs1[
ch];
634 exponents =
s->exponents[
ch];
635 esize =
s->exponents_bsize[
ch];
638 coefs =
s->coefs[
ch];
639 if (
s->use_noise_coding) {
642 for (
i = 0;
i <
s->coefs_start;
i++) {
643 *coefs++ =
s->noise_table[
s->noise_index] *
644 exponents[i << bsize >> esize] * mult1;
645 s->noise_index = (
s->noise_index + 1) &
649 n1 =
s->exponent_high_sizes[bsize];
652 exponents =
s->exponents[
ch] +
653 (
s->high_band_start[bsize] << bsize >> esize);
655 for (j = 0; j < n1; j++) {
656 n =
s->exponent_high_bands[
s->frame_len_bits -
657 s->block_len_bits][j];
658 if (
s->high_band_coded[
ch][j]) {
661 for (
i = 0;
i <
n;
i++) {
662 v = exponents[i << bsize >> esize];
665 exp_power[j] = e2 /
n;
667 ff_tlog(
s->avctx,
"%d: power=%f (%d)\n", j, exp_power[j],
n);
669 exponents += n << bsize >> esize;
673 exponents =
s->exponents[
ch] + (
s->coefs_start << bsize >> esize);
674 for (j = -1; j < n1; j++) {
676 n =
s->high_band_start[bsize] -
s->coefs_start;
678 n =
s->exponent_high_bands[
s->frame_len_bits -
679 s->block_len_bits][j];
680 if (j >= 0 &&
s->high_band_coded[
ch][j]) {
682 mult1 = sqrt(exp_power[j] / exp_power[last_high_band]);
684 mult1 = mult1 *
ff_exp10(
s->high_band_values[
ch][j] * 0.05);
685 mult1 = mult1 / (
s->max_exponent[
ch] *
s->noise_mult);
687 for (
i = 0;
i <
n;
i++) {
688 noise =
s->noise_table[
s->noise_index];
690 *coefs++ =
noise * exponents[i << bsize >> esize] * mult1;
692 exponents += n << bsize >> esize;
695 for (
i = 0;
i <
n;
i++) {
696 noise =
s->noise_table[
s->noise_index];
698 *coefs++ = ((*coefs1++) +
noise) *
699 exponents[i << bsize >> esize] *
mult;
701 exponents += n << bsize >> esize;
706 n =
s->block_len -
s->coefs_end[bsize];
707 mult1 =
mult * exponents[(-(1 << bsize)) >> esize];
708 for (
i = 0;
i <
n;
i++) {
709 *coefs++ =
s->noise_table[
s->noise_index] * mult1;
714 for (
i = 0;
i <
s->coefs_start;
i++)
717 for (
i = 0;
i <
n;
i++)
718 *coefs++ = coefs1[
i] * exponents[
i << bsize >> esize] *
mult;
719 n =
s->block_len -
s->coefs_end[bsize];
720 for (
i = 0;
i <
n;
i++)
727 for (
ch = 0;
ch <
s->avctx->channels;
ch++) {
728 if (
s->channel_coded[
ch]) {
729 dump_floats(
s,
"exponents", 3,
s->exponents[
ch],
s->block_len);
730 dump_floats(
s,
"coefs", 1,
s->coefs[
ch],
s->block_len);
735 if (
s->ms_stereo &&
s->channel_coded[1]) {
739 if (!
s->channel_coded[0]) {
740 ff_tlog(
s->avctx,
"rare ms-stereo case happened\n");
741 memset(
s->coefs[0], 0,
sizeof(
float) *
s->block_len);
742 s->channel_coded[0] = 1;
745 s->fdsp->butterflies_float(
s->coefs[0],
s->coefs[1],
s->block_len);
749 mdct = &
s->mdct_ctx[bsize];
751 for (
ch = 0;
ch <
s->avctx->channels;
ch++) {
754 n4 =
s->block_len / 2;
755 if (
s->channel_coded[
ch])
757 else if (!(
s->ms_stereo &&
ch == 1))
758 memset(
s->output, 0,
sizeof(
s->output));
761 index = (
s->frame_len / 2) +
s->block_pos - n4;
767 s->block_pos +=
s->block_len;
768 if (
s->block_pos >=
s->frame_len)
781 ff_tlog(
s->avctx,
"***decode_frame: %d size=%d\n",
782 s->frame_count++,
s->frame_len);
796 for (
ch = 0;
ch <
s->avctx->channels;
ch++) {
799 s->frame_len *
sizeof(*
s->frame_out[
ch]));
801 memmove(&
s->frame_out[
ch][0], &
s->frame_out[
ch][
s->frame_len],
802 s->frame_len *
sizeof(*
s->frame_out[
ch]));
805 dump_floats(
s,
"samples", 6,
samples[
ch] + samples_offset,
814 int *got_frame_ptr,
AVPacket *avpkt)
818 int buf_size = avpkt->
size;
820 int nb_frames, bit_offset,
i, pos,
len,
ret;
825 ff_tlog(avctx,
"***decode_superframe:\n");
828 s->last_superframe_len = 0;
831 if (buf_size < avctx->block_align) {
833 "Input packet size too small (%d < %d)\n",
842 if (
s->use_bit_reservoir) {
845 nb_frames =
get_bits(&
s->gb, 4) - (
s->last_superframe_len <= 0);
846 if (nb_frames <= 0) {
849 "nb_frames is %d bits left %d\n",
854 if ((
s->last_superframe_len + buf_size - 1) >
858 q =
s->last_superframe +
s->last_superframe_len;
866 s->last_superframe_len += 8*buf_size - 8;
875 frame->nb_samples = nb_frames *
s->frame_len;
881 if (
s->use_bit_reservoir) {
882 bit_offset =
get_bits(&
s->gb,
s->byte_offset_bits + 3);
885 "Invalid last frame bit offset %d > buf size %d (%d)\n",
890 if (
s->last_superframe_len > 0) {
892 if ((
s->last_superframe_len + ((bit_offset + 7) >> 3)) >
895 q =
s->last_superframe +
s->last_superframe_len;
907 s->last_superframe_len * 8 + bit_offset);
909 if (
s->last_bitoffset > 0)
915 samples_offset +=
s->frame_len;
920 pos = bit_offset + 4 + 4 +
s->byte_offset_bits + 3;
928 s->reset_block_lengths = 1;
929 for (
i = 0;
i < nb_frames;
i++) {
932 samples_offset +=
s->frame_len;
937 ((bit_offset + 4 + 4 +
s->byte_offset_bits + 3) & ~7);
938 s->last_bitoffset = pos & 7;
940 len = buf_size - pos;
945 s->last_superframe_len =
len;
946 memcpy(
s->last_superframe,
buf + pos,
len);
951 samples_offset +=
s->frame_len;
955 s->frame_len_bits,
s->block_len_bits,
s->frame_len,
s->block_len,
964 s->last_superframe_len = 0;
973 s->last_superframe_len = 0;
976 #if CONFIG_WMAV1_DECODER
992 #if CONFIG_WMAV2_DECODER
@ AV_SAMPLE_FMT_FLTP
float, planar
#define AV_LOG_WARNING
Something somehow does not look correct.
static av_always_inline double ff_exp10(double x)
Compute 10^x for floating point values.
static av_cold int init(AVCodecContext *avctx)
static int get_bits_left(GetBitContext *gb)
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
#define u(width, name, range_min, range_max)
static enum AVSampleFormat sample_fmts[]
static av_cold void flush(AVCodecContext *avctx)
const uint16_t ff_wma_hgain_huffcodes[37]
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(const uint8_t *) pi - 0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(const int16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(const int16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(const int32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(const int32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(const int64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(const float *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(const double *) pi *(INT64_C(1)<< 63))) #define FMT_PAIR_FUNC(out, in) static conv_func_type *const fmt_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), };static void cpy1(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, len);} static void cpy2(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 2 *len);} static void cpy4(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 4 *len);} static void cpy8(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 8 *len);} AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, const int *ch_map, int flags) { 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) return NULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) return NULL;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)){ case 1:ctx->simd_f=cpy1;break;case 2:ctx->simd_f=cpy2;break;case 4:ctx->simd_f=cpy4;break;case 8: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);return ctx;} void swri_audio_convert_free(AudioConvert **ctx) { av_freep(ctx);} int swri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, int len) { int ch;int off=0;const int os=(out->planar ? 1 :out->ch_count) *out->bps;unsigned misaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask) { int planes=in->planar ? in->ch_count :1;unsigned m=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) { int planes=out->planar ? out->ch_count :1;unsigned m=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){ int planes=out->planar ? out->ch_count :1;for(ch=0;ch< planes;ch++){ ctx->simd_f(out-> ch ch
static int get_bits_count(const GetBitContext *s)
This structure describes decoded (raw) audio or video data.
static void wma_lsp_to_curve_init(WMACodecContext *s, int frame_len)
#define init_vlc(vlc, nb_bits, nb_codes, bits, bits_wrap, bits_size, codes, codes_wrap, codes_size, flags)
const uint8_t ff_wma_hgain_huffbits[37]
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
static int wma_decode_frame(WMACodecContext *s, float **samples, int samples_offset)
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
static void skip_bits(GetBitContext *s, int n)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define HIGH_BAND_MAX_SIZE
static void decode_exp_lsp(WMACodecContext *s, int ch)
decode exponents coded with LSP coefficients (same idea as Vorbis)
const struct AVCodec * codec
float WMACoef
type for decoded coefficients, int16_t would be enough for wma 1/2
static const struct twinvq_data tab
static int16_t mult(Float11 *f1, Float11 *f2)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
int ff_wma_total_gain_to_bits(int total_gain)
#define PTRDIFF_SPECIFIER
static unsigned int get_bits1(GetBitContext *s)
#define MAX_CODED_SUPERFRAME_SIZE
int ff_wma_end(AVCodecContext *avctx)
void(* imdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input)
const uint8_t ff_aac_scalefactor_bits[121]
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
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.
enum AVSampleFormat sample_fmt
audio sample format
av_cold int ff_wma_init(AVCodecContext *avctx, int flags2)
const char const char void * val
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
static int wma_decode_block(WMACodecContext *s)
static const float pow_tab[]
pow(10, i / 16.0) for i in -60..95
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;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);return NULL;} return ac;} 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;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->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);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
#define i(width, name, range_min, range_max)
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some it can consider them to be part of the FIFO and delay acknowledging a status change accordingly Example code
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
AVSampleFormat
Audio sample formats.
static void wma_window(WMACodecContext *s, float *out)
Apply MDCT window and add into output.
const char * name
Name of the codec implementation.
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
static const uint8_t * align_get_bits(GetBitContext *s)
#define AV_INPUT_BUFFER_PADDING_SIZE
#define FF_ARRAY_ELEMS(a)
main external API structure.
static int noise(AVBSFContext *ctx, AVPacket *pkt)
static int decode_exp_vlc(WMACodecContext *s, int ch)
decode exponents coded with VLC codes
Filter the word “frame” indicates either a video frame or a group of audio samples
const float ff_wma_lsp_codebook[NB_LSP_COEFS][16]
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.
This structure stores compressed data.
static av_cold int wma_decode_init(AVCodecContext *avctx)
static float pow_m1_4(WMACodecContext *s, float x)
compute x^-0.25 with an exponent and mantissa table.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int wma_decode_superframe(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
const uint32_t ff_aac_scalefactor_code[121]