FFmpeg
Loading...
Searching...
No Matches
atrac3.c
Go to the documentation of this file.
1/*
2 * ATRAC3 compatible decoder
3 * Copyright (c) 2006-2008 Maxim Poliakovski
4 * Copyright (c) 2006-2008 Benjamin Larsson
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23/**
24 * @file
25 * ATRAC3 compatible decoder.
26 * This decoder handles Sony's ATRAC3 data.
27 *
28 * Container formats used to store ATRAC3 data:
29 * RealMedia (.rm), RIFF WAV (.wav, .at3), Sony OpenMG (.oma, .aa3).
30 *
31 * To use this decoder, a calling application must supply the extradata
32 * bytes provided in the containers above.
33 */
34
35#include <math.h>
36#include <stddef.h>
37
39#include "libavutil/float_dsp.h"
40#include "libavutil/libm.h"
41#include "libavutil/mem.h"
43#include "libavutil/thread.h"
44#include "libavutil/tx.h"
45
46#include "avcodec.h"
47#include "bytestream.h"
48#include "codec_internal.h"
49#include "decode.h"
50#include "get_bits.h"
51
52#include "atrac.h"
53#include "atrac3data.h"
54
55#define MIN_CHANNELS 1
56#define MAX_CHANNELS 8
57#define MAX_JS_PAIRS 8 / 2
58
59#define JOINT_STEREO 0x12
60#define SINGLE 0x2
61
62#define SAMPLES_PER_FRAME 1024
63#define MDCT_SIZE 512
64
65#define ATRAC3_VLC_BITS 8
66
67typedef struct GainBlock {
69} GainBlock;
70
71typedef struct TonalComponent {
72 int pos;
74 float coef[8];
76
92
93typedef struct ATRAC3Context {
95 //@{
96 /** stream data */
98
100 //@}
101 //@{
102 /** joint-stereo related variables */
107 //@}
108 //@{
109 /** data buffers */
111 float temp_buf[1070];
112 //@}
113 //@{
114 /** extradata */
116 //@}
117
121 void (*vector_fmul)(float *dst, const float *src0, const float *src1,
122 int len);
124
128
129/**
130 * Regular 512 points IMDCT without overlapping, with the exception of the
131 * swapping of odd bands caused by the reverse spectra of the QMF.
132 *
133 * @param odd_band 1 if the band is an odd band
134 */
135static void imlt(ATRAC3Context *q, float *input, float *output, int odd_band)
136{
137 int i;
138
139 if (odd_band) {
140 /**
141 * Reverse the odd bands before IMDCT, this is an effect of the QMF
142 * transform or it gives better compression to do it this way.
143 * FIXME: It should be possible to handle this in imdct_calc
144 * for that to happen a modification of the prerotation step of
145 * all SIMD code and C code is needed.
146 * Or fix the functions before so they generate a pre reversed spectrum.
147 */
148 for (i = 0; i < 128; i++)
149 FFSWAP(float, input[i], input[255 - i]);
150 }
151
152 q->mdct_fn(q->mdct_ctx, output, input, sizeof(float));
153
154 /* Perform windowing on the output. */
155 q->vector_fmul(output, output, mdct_window, MDCT_SIZE);
156}
157
158/*
159 * indata descrambling, only used for data coming from the rm container
160 */
161static int decode_bytes(const uint8_t *input, uint8_t *out, int bytes)
162{
163 int i, off;
164 uint32_t c;
165 const uint32_t *buf;
166 uint32_t *output = (uint32_t *)out;
167
168 off = (intptr_t)input & 3;
169 buf = (const uint32_t *)(input - off);
170 if (off)
171 c = av_be2ne32((0x537F6103U >> (off * 8)) | (0x537F6103U << (32 - (off * 8))));
172 else
173 c = av_be2ne32(0x537F6103U);
174 bytes += 3 + off;
175 for (i = 0; i < bytes / 4; i++)
176 output[i] = c ^ buf[i];
177
178 if (off)
179 avpriv_request_sample(NULL, "Offset of %d", off);
180
181 return off;
182}
183
184static av_cold void init_imdct_window(void)
185{
186 int i, j;
187
188 /* generate the mdct window, for details see
189 * http://wiki.multimedia.cx/index.php?title=RealAudio_atrc#Windows */
190 for (i = 0, j = 255; i < 128; i++, j--) {
191 float wi = sin(((i + 0.5) / 256.0 - 0.5) * M_PI) + 1.0;
192 float wj = sin(((j + 0.5) / 256.0 - 0.5) * M_PI) + 1.0;
193 float w = 0.5 * (wi * wi + wj * wj);
194 mdct_window[i] = mdct_window[511 - i] = wi / w;
195 mdct_window[j] = mdct_window[511 - j] = wj / w;
196 }
197}
198
200{
201 ATRAC3Context *q = avctx->priv_data;
202
203 av_freep(&q->units);
205
207
208 return 0;
209}
210
211/**
212 * Mantissa decoding
213 *
214 * @param selector which table the output values are coded with
215 * @param coding_flag constant length coding or variable length coding
216 * @param mantissas mantissa output table
217 * @param num_codes number of values to get
218 */
219static void read_quant_spectral_coeffs(GetBitContext *gb, int selector,
220 int coding_flag, int *mantissas,
221 int num_codes)
222{
223 int i, code, huff_symb;
224
225 if (selector == 1)
226 num_codes /= 2;
227
228 if (coding_flag != 0) {
229 /* constant length coding (CLC) */
230 int num_bits = clc_length_tab[selector];
231
232 if (selector > 1) {
233 for (i = 0; i < num_codes; i++) {
234 if (num_bits)
235 code = get_sbits(gb, num_bits);
236 else
237 code = 0;
238 mantissas[i] = code;
239 }
240 } else {
241 for (i = 0; i < num_codes; i++) {
242 if (num_bits)
243 code = get_bits(gb, num_bits); // num_bits is always 4 in this case
244 else
245 code = 0;
246 mantissas[i * 2 ] = mantissa_clc_tab[code >> 2];
247 mantissas[i * 2 + 1] = mantissa_clc_tab[code & 3];
248 }
249 }
250 } else {
251 /* variable length coding (VLC) */
252 if (selector != 1) {
253 for (i = 0; i < num_codes; i++) {
254 mantissas[i] = get_vlc2(gb, spectral_coeff_tab[selector-1].table,
255 ATRAC3_VLC_BITS, 1);
256 }
257 } else {
258 for (i = 0; i < num_codes; i++) {
259 huff_symb = get_vlc2(gb, spectral_coeff_tab[selector - 1].table,
260 ATRAC3_VLC_BITS, 1);
261 mantissas[i * 2 ] = mantissa_vlc_tab[huff_symb * 2 ];
262 mantissas[i * 2 + 1] = mantissa_vlc_tab[huff_symb * 2 + 1];
263 }
264 }
265 }
266}
267
268/**
269 * Restore the quantized band spectrum coefficients
270 *
271 * @return subband count, fix for broken specification/files
272 */
273static int decode_spectrum(GetBitContext *gb, float *output)
274{
275 int num_subbands, coding_mode, i, j, first, last, subband_size;
276 int subband_vlc_index[32], sf_index[32];
277 int mantissas[128];
278 float scale_factor;
279
280 num_subbands = get_bits(gb, 5); // number of coded subbands
281 coding_mode = get_bits1(gb); // coding Mode: 0 - VLC/ 1-CLC
282
283 /* get the VLC selector table for the subbands, 0 means not coded */
284 for (i = 0; i <= num_subbands; i++)
285 subband_vlc_index[i] = get_bits(gb, 3);
286
287 /* read the scale factor indexes from the stream */
288 for (i = 0; i <= num_subbands; i++) {
289 if (subband_vlc_index[i] != 0)
290 sf_index[i] = get_bits(gb, 6);
291 }
292
293 for (i = 0; i <= num_subbands; i++) {
294 first = subband_tab[i ];
295 last = subband_tab[i + 1];
296
297 subband_size = last - first;
298
299 if (subband_vlc_index[i] != 0) {
300 /* decode spectral coefficients for this subband */
301 /* TODO: This can be done faster is several blocks share the
302 * same VLC selector (subband_vlc_index) */
303 read_quant_spectral_coeffs(gb, subband_vlc_index[i], coding_mode,
304 mantissas, subband_size);
305
306 /* decode the scale factor for this subband */
307 scale_factor = ff_atrac_sf_table[sf_index[i]] *
308 inv_max_quant[subband_vlc_index[i]];
309
310 /* inverse quantize the coefficients */
311 for (j = 0; first < last; first++, j++)
312 output[first] = mantissas[j] * scale_factor;
313 } else {
314 /* this subband was not coded, so zero the entire subband */
315 memset(output + first, 0, subband_size * sizeof(*output));
316 }
317 }
318
319 /* clear the subbands that were not coded */
320 first = subband_tab[i];
321 memset(output + first, 0, (SAMPLES_PER_FRAME - first) * sizeof(*output));
322 return num_subbands;
323}
324
325/**
326 * Restore the quantized tonal components
327 *
328 * @param components tonal components
329 * @param num_bands number of coded bands
330 */
332 TonalComponent *components, int num_bands)
333{
334 int i, b, c, m;
335 int nb_components, coding_mode_selector, coding_mode;
336 int band_flags[4], mantissa[8];
337 int component_count = 0;
338
339 nb_components = get_bits(gb, 5);
340
341 /* no tonal components */
342 if (nb_components == 0)
343 return 0;
344
345 coding_mode_selector = get_bits(gb, 2);
346 if (coding_mode_selector == 2)
347 return AVERROR_INVALIDDATA;
348
349 coding_mode = coding_mode_selector & 1;
350
351 for (i = 0; i < nb_components; i++) {
352 int coded_values_per_component, quant_step_index;
353
354 for (b = 0; b <= num_bands; b++)
355 band_flags[b] = get_bits1(gb);
356
357 coded_values_per_component = get_bits(gb, 3);
358
359 quant_step_index = get_bits(gb, 3);
360 if (quant_step_index <= 1)
361 return AVERROR_INVALIDDATA;
362
363 if (coding_mode_selector == 3)
364 coding_mode = get_bits1(gb);
365
366 for (b = 0; b < (num_bands + 1) * 4; b++) {
367 int coded_components;
368
369 if (band_flags[b >> 2] == 0)
370 continue;
371
372 coded_components = get_bits(gb, 3);
373
374 for (c = 0; c < coded_components; c++) {
375 TonalComponent *cmp = &components[component_count];
376 int sf_index, coded_values, max_coded_values;
377 float scale_factor;
378
379 sf_index = get_bits(gb, 6);
380 if (component_count >= 64)
381 return AVERROR_INVALIDDATA;
382
383 cmp->pos = b * 64 + get_bits(gb, 6);
384
385 max_coded_values = SAMPLES_PER_FRAME - cmp->pos;
386 coded_values = coded_values_per_component + 1;
387 coded_values = FFMIN(max_coded_values, coded_values);
388
389 scale_factor = ff_atrac_sf_table[sf_index] *
390 inv_max_quant[quant_step_index];
391
392 read_quant_spectral_coeffs(gb, quant_step_index, coding_mode,
393 mantissa, coded_values);
394
395 cmp->num_coefs = coded_values;
396
397 /* inverse quant */
398 for (m = 0; m < coded_values; m++)
399 cmp->coef[m] = mantissa[m] * scale_factor;
400
401 component_count++;
402 }
403 }
404 }
405
406 return component_count;
407}
408
409/**
410 * Decode gain parameters for the coded bands
411 *
412 * @param block the gainblock for the current band
413 * @param num_bands amount of coded bands
414 */
416 int num_bands)
417{
418 int b, j;
419 int *level, *loc;
420
421 AtracGainInfo *gain = block->g_block;
422
423 for (b = 0; b <= num_bands; b++) {
424 gain[b].num_points = get_bits(gb, 3);
425 level = gain[b].lev_code;
426 loc = gain[b].loc_code;
427
428 for (j = 0; j < gain[b].num_points; j++) {
429 level[j] = get_bits(gb, 4);
430 loc[j] = get_bits(gb, 5);
431 if (j && loc[j] <= loc[j - 1])
432 return AVERROR_INVALIDDATA;
433 }
434 }
435
436 /* Clear the unused blocks. */
437 for (; b < 4 ; b++)
438 gain[b].num_points = 0;
439
440 return 0;
441}
442
443/**
444 * Combine the tonal band spectrum and regular band spectrum
445 *
446 * @param spectrum output spectrum buffer
447 * @param num_components number of tonal components
448 * @param components tonal components for this band
449 * @return position of the last tonal coefficient
450 */
451static int add_tonal_components(float *spectrum, int num_components,
452 TonalComponent *components)
453{
454 int i, j, last_pos = -1;
455 float *input, *output;
456
457 for (i = 0; i < num_components; i++) {
458 last_pos = FFMAX(components[i].pos + components[i].num_coefs, last_pos);
459 input = components[i].coef;
460 output = &spectrum[components[i].pos];
461
462 for (j = 0; j < components[i].num_coefs; j++)
463 output[j] += input[j];
464 }
465
466 return last_pos;
467}
468
469#define INTERPOLATE(old, new, nsample) \
470 ((old) + (nsample) * 0.125 * ((new) - (old)))
471
472static void reverse_matrixing(float *su1, float *su2, int *prev_code,
473 int *curr_code)
474{
475 int i, nsample, band;
476 float mc1_l, mc1_r, mc2_l, mc2_r;
477
478 for (i = 0, band = 0; band < 4 * 256; band += 256, i++) {
479 int s1 = prev_code[i];
480 int s2 = curr_code[i];
481 nsample = band;
482
483 if (s1 != s2) {
484 /* Selector value changed, interpolation needed. */
485 mc1_l = matrix_coeffs[s1 * 2 ];
486 mc1_r = matrix_coeffs[s1 * 2 + 1];
487 mc2_l = matrix_coeffs[s2 * 2 ];
488 mc2_r = matrix_coeffs[s2 * 2 + 1];
489
490 /* Interpolation is done over the first eight samples. */
491 for (; nsample < band + 8; nsample++) {
492 float c1 = su1[nsample];
493 float c2 = su2[nsample];
494 c2 = c1 * INTERPOLATE(mc1_l, mc2_l, nsample - band) +
495 c2 * INTERPOLATE(mc1_r, mc2_r, nsample - band);
496 su1[nsample] = c2;
497 su2[nsample] = c1 * 2.0 - c2;
498 }
499 }
500
501 /* Apply the matrix without interpolation. */
502 switch (s2) {
503 case 0: /* M/S decoding */
504 for (; nsample < band + 256; nsample++) {
505 float c1 = su1[nsample];
506 float c2 = su2[nsample];
507 su1[nsample] = c2 * 2.0;
508 su2[nsample] = (c1 - c2) * 2.0;
509 }
510 break;
511 case 1:
512 for (; nsample < band + 256; nsample++) {
513 float c1 = su1[nsample];
514 float c2 = su2[nsample];
515 su1[nsample] = (c1 + c2) * 2.0;
516 su2[nsample] = c2 * -2.0;
517 }
518 break;
519 case 2:
520 case 3:
521 for (; nsample < band + 256; nsample++) {
522 float c1 = su1[nsample];
523 float c2 = su2[nsample];
524 su1[nsample] = c1 + c2;
525 su2[nsample] = c1 - c2;
526 }
527 break;
528 default:
529 av_unreachable("curr_code/matrix_coeff_index_* values are stored in two bits");
530 }
531 }
532}
533
534static void get_channel_weights(int index, int flag, float ch[2])
535{
536 if (index == 7) {
537 ch[0] = 1.0;
538 ch[1] = 1.0;
539 } else {
540 ch[0] = (index & 7) / 7.0;
541 ch[1] = sqrt(2 - ch[0] * ch[0]);
542 if (flag)
543 FFSWAP(float, ch[0], ch[1]);
544 }
545}
546
547static void channel_weighting(float *su1, float *su2, int *p3)
548{
549 int band, nsample;
550 /* w[x][y] y=0 is left y=1 is right */
551 float w[2][2];
552
553 if (p3[1] != 7 || p3[3] != 7) {
554 get_channel_weights(p3[1], p3[0], w[0]);
555 get_channel_weights(p3[3], p3[2], w[1]);
556
557 for (band = 256; band < 4 * 256; band += 256) {
558 for (nsample = band; nsample < band + 8; nsample++) {
559 su1[nsample] *= INTERPOLATE(w[0][0], w[0][1], nsample - band);
560 su2[nsample] *= INTERPOLATE(w[1][0], w[1][1], nsample - band);
561 }
562 for(; nsample < band + 256; nsample++) {
563 su1[nsample] *= w[1][0];
564 su2[nsample] *= w[1][1];
565 }
566 }
567 }
568}
569
570/**
571 * Decode a Sound Unit
572 *
573 * @param snd the channel unit to be used
574 * @param output the decoded samples before IQMF in float representation
575 * @param channel_num channel number
576 * @param coding_mode the coding mode (JOINT_STEREO or single channels)
577 */
579 ChannelUnit *snd, float *output,
580 int channel_num, int coding_mode)
581{
582 int band, ret, num_subbands, last_tonal, num_bands;
583 GainBlock *gain1 = &snd->gain_block[ snd->gc_blk_switch];
584 GainBlock *gain2 = &snd->gain_block[1 - snd->gc_blk_switch];
585
586 if (coding_mode == JOINT_STEREO && (channel_num % 2) == 1) {
587 if (get_bits(gb, 2) != 3) {
588 av_log(NULL,AV_LOG_ERROR,"JS mono Sound Unit id != 3.\n");
589 return AVERROR_INVALIDDATA;
590 }
591 } else {
592 if (get_bits(gb, 6) != 0x28) {
593 av_log(NULL,AV_LOG_ERROR,"Sound Unit id != 0x28.\n");
594 return AVERROR_INVALIDDATA;
595 }
596 }
597
598 /* number of coded QMF bands */
599 snd->bands_coded = get_bits(gb, 2);
600
601 ret = decode_gain_control(gb, gain2, snd->bands_coded);
602 if (ret)
603 return ret;
604
606 snd->bands_coded);
607 if (snd->num_components < 0)
608 return snd->num_components;
609
610 num_subbands = decode_spectrum(gb, snd->spectrum);
611
612 /* Merge the decoded spectrum and tonal components. */
613 last_tonal = add_tonal_components(snd->spectrum, snd->num_components,
614 snd->components);
615
616
617 /* calculate number of used MLT/QMF bands according to the amount of coded
618 spectral lines */
619 num_bands = (subband_tab[num_subbands + 1] - 1) >> 8;
620 if (last_tonal >= 0)
621 num_bands = FFMAX((last_tonal + 256) >> 8, num_bands);
622
623
624 /* Reconstruct time domain samples. */
625 for (band = 0; band < 4; band++) {
626 /* Perform the IMDCT step without overlapping. */
627 if (band <= num_bands)
628 imlt(q, &snd->spectrum[band * 256], snd->imdct_buf, band & 1);
629 else
630 memset(snd->imdct_buf, 0, 512 * sizeof(*snd->imdct_buf));
631
632 /* gain compensation and overlapping */
634 &snd->prev_frame[band * 256],
635 &gain1->g_block[band], &gain2->g_block[band],
636 256, &output[band * 256]);
637 }
638
639 /* Swap the gain control buffers for the next frame. */
640 snd->gc_blk_switch ^= 1;
641
642 return 0;
643}
644
645static int decode_frame(AVCodecContext *avctx, const uint8_t *databuf,
646 float **out_samples)
647{
648 ATRAC3Context *q = avctx->priv_data;
649 int ret, i, ch;
650 uint8_t *ptr1;
651 int channels = avctx->ch_layout.nb_channels;
652
653 if (q->coding_mode == JOINT_STEREO) {
654 /* channel coupling mode */
655
656 /* Decode sound unit pairs (channels are expected to be even).
657 * Multichannel joint stereo interleaves pairs (6ch: 2ch + 2ch + 2ch) */
658 const uint8_t *js_databuf;
659 int js_pair, js_block_align;
660
661 js_block_align = (avctx->block_align / channels) * 2; /* block pair */
662
663 for (ch = 0; ch < channels; ch = ch + 2) {
664 js_pair = ch/2;
665 js_databuf = databuf + js_pair * js_block_align; /* align to current pair */
666
667 /* Set the bitstream reader at the start of first channel sound unit. */
668 init_get_bits(&q->gb,
669 js_databuf, js_block_align * 8);
670
671 /* decode Sound Unit 1 */
672 ret = decode_channel_sound_unit(q, &q->gb, &q->units[ch],
673 out_samples[ch], ch, JOINT_STEREO);
674 if (ret != 0)
675 return ret;
676
677 /* Framedata of the su2 in the joint-stereo mode is encoded in
678 * reverse byte order so we need to swap it first. */
679 if (js_databuf == q->decoded_bytes_buffer) {
680 uint8_t *ptr2 = q->decoded_bytes_buffer + js_block_align - 1;
681 ptr1 = q->decoded_bytes_buffer;
682 for (i = 0; i < js_block_align / 2; i++, ptr1++, ptr2--)
683 FFSWAP(uint8_t, *ptr1, *ptr2);
684 } else {
685 const uint8_t *ptr2 = js_databuf + js_block_align - 1;
686 for (i = 0; i < js_block_align; i++)
687 q->decoded_bytes_buffer[i] = *ptr2--;
688 }
689
690 /* Skip the sync codes (0xF8). */
691 ptr1 = q->decoded_bytes_buffer;
692 for (i = 4; *ptr1 == 0xF8; i++, ptr1++) {
693 if (i >= js_block_align)
694 return AVERROR_INVALIDDATA;
695 }
696
697
698 /* set the bitstream reader at the start of the second Sound Unit */
699 ret = init_get_bits8(&q->gb,
700 ptr1, q->decoded_bytes_buffer + js_block_align - ptr1);
701 if (ret < 0)
702 return ret;
703
704 /* Fill the Weighting coeffs delay buffer */
705 memmove(q->weighting_delay[js_pair], &q->weighting_delay[js_pair][2],
706 4 * sizeof(*q->weighting_delay[js_pair]));
707 q->weighting_delay[js_pair][4] = get_bits1(&q->gb);
708 q->weighting_delay[js_pair][5] = get_bits(&q->gb, 3);
709
710 for (i = 0; i < 4; i++) {
711 q->matrix_coeff_index_prev[js_pair][i] = q->matrix_coeff_index_now[js_pair][i];
712 q->matrix_coeff_index_now[js_pair][i] = q->matrix_coeff_index_next[js_pair][i];
713 q->matrix_coeff_index_next[js_pair][i] = get_bits(&q->gb, 2);
714 }
715
716 /* Decode Sound Unit 2. */
717 ret = decode_channel_sound_unit(q, &q->gb, &q->units[ch+1],
718 out_samples[ch+1], ch+1, JOINT_STEREO);
719 if (ret != 0)
720 return ret;
721
722 /* Reconstruct the channel coefficients. */
723 reverse_matrixing(out_samples[ch], out_samples[ch+1],
724 q->matrix_coeff_index_prev[js_pair],
725 q->matrix_coeff_index_now[js_pair]);
726
727 channel_weighting(out_samples[ch], out_samples[ch+1], q->weighting_delay[js_pair]);
728 }
729 } else {
730 /* single channels */
731 /* Decode the channel sound units. */
732 for (i = 0; i < channels; i++) {
733 /* Set the bitstream reader at the start of a channel sound unit. */
734 init_get_bits(&q->gb,
735 databuf + i * avctx->block_align / channels,
736 avctx->block_align * 8 / channels);
737
738 ret = decode_channel_sound_unit(q, &q->gb, &q->units[i],
739 out_samples[i], i, q->coding_mode);
740 if (ret != 0)
741 return ret;
742 }
743 }
744
745 /* Apply the iQMF synthesis filter. */
746 for (i = 0; i < channels; i++) {
747 float *p1 = out_samples[i];
748 float *p2 = p1 + 256;
749 float *p3 = p2 + 256;
750 float *p4 = p3 + 256;
751 ff_atrac_iqmf(p1, p2, 256, p1, q->units[i].delay_buf1, q->temp_buf);
752 ff_atrac_iqmf(p4, p3, 256, p3, q->units[i].delay_buf2, q->temp_buf);
753 ff_atrac_iqmf(p1, p3, 512, p1, q->units[i].delay_buf3, q->temp_buf);
754 }
755
756 return 0;
757}
758
759static int al_decode_frame(AVCodecContext *avctx, const uint8_t *databuf,
760 int size, float **out_samples)
761{
762 ATRAC3Context *q = avctx->priv_data;
763 int channels = avctx->ch_layout.nb_channels;
764 int ret, i;
765
766 /* Set the bitstream reader at the start of a channel sound unit. */
767 init_get_bits(&q->gb, databuf, size * 8);
768 /* single channels */
769 /* Decode the channel sound units. */
770 for (i = 0; i < channels; i++) {
771 ret = decode_channel_sound_unit(q, &q->gb, &q->units[i],
772 out_samples[i], i, q->coding_mode);
773 if (ret != 0)
774 return ret;
775 while (i < channels && get_bits_left(&q->gb) > 6 && show_bits(&q->gb, 6) != 0x28) {
776 skip_bits(&q->gb, 1);
777 }
778 }
779
780 /* Apply the iQMF synthesis filter. */
781 for (i = 0; i < channels; i++) {
782 float *p1 = out_samples[i];
783 float *p2 = p1 + 256;
784 float *p3 = p2 + 256;
785 float *p4 = p3 + 256;
786 ff_atrac_iqmf(p1, p2, 256, p1, q->units[i].delay_buf1, q->temp_buf);
787 ff_atrac_iqmf(p4, p3, 256, p3, q->units[i].delay_buf2, q->temp_buf);
788 ff_atrac_iqmf(p1, p3, 512, p1, q->units[i].delay_buf3, q->temp_buf);
789 }
790
791 return 0;
792}
793
795 int *got_frame_ptr, AVPacket *avpkt)
796{
797 const uint8_t *buf = avpkt->data;
798 int buf_size = avpkt->size;
799 ATRAC3Context *q = avctx->priv_data;
800 int ret;
801 const uint8_t *databuf;
802
803 if (buf_size < avctx->block_align) {
804 av_log(avctx, AV_LOG_ERROR,
805 "Frame too small (%d bytes). Truncated file?\n", buf_size);
806 return AVERROR_INVALIDDATA;
807 }
808
809 /* get output buffer */
810 frame->nb_samples = SAMPLES_PER_FRAME;
811 if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
812 return ret;
813
814 /* Check if we need to descramble and what buffer to pass on. */
815 if (q->scrambled_stream) {
817 databuf = q->decoded_bytes_buffer;
818 } else {
819 databuf = buf;
820 }
821
822 ret = decode_frame(avctx, databuf, (float **)frame->extended_data);
823 if (ret) {
824 av_log(avctx, AV_LOG_ERROR, "Frame decoding error!\n");
825 return ret;
826 }
827
828 *got_frame_ptr = 1;
829
830 return avctx->block_align;
831}
832
834 int *got_frame_ptr, AVPacket *avpkt)
835{
836 int ret;
837
838 frame->nb_samples = SAMPLES_PER_FRAME;
839 if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
840 return ret;
841
842 ret = al_decode_frame(avctx, avpkt->data, avpkt->size,
843 (float **)frame->extended_data);
844 if (ret) {
845 av_log(avctx, AV_LOG_ERROR, "Frame decoding error!\n");
846 return ret;
847 }
848
849 *got_frame_ptr = 1;
850
851 return avpkt->size;
852}
853
855{
857 const uint8_t (*hufftabs)[2] = atrac3_hufftabs;
858 int i;
859
862
863 /* Initialize the VLC tables. */
864 for (i = 0; i < 7; i++) {
865 spectral_coeff_tab[i].table = table;
866 spectral_coeff_tab[i].table_allocated = 256;
868 &hufftabs[0][1], 2,
869 &hufftabs[0][0], 2, 1,
871 hufftabs += huff_tab_sizes[i];
872 table += 256;
873 }
874}
875
877{
878 static AVOnce init_static_once = AV_ONCE_INIT;
879 int i, js_pair, ret;
880 int version, delay, samples_per_frame, frame_factor;
881 const uint8_t *edata_ptr = avctx->extradata;
882 ATRAC3Context *q = avctx->priv_data;
883 AVFloatDSPContext *fdsp;
884 float scale = 1.0 / 32768;
885 int channels = avctx->ch_layout.nb_channels;
886
888 av_log(avctx, AV_LOG_ERROR, "Channel configuration error!\n");
889 return AVERROR(EINVAL);
890 }
891
892 /* Take care of the codec-specific extradata. */
893 if (avctx->codec_id == AV_CODEC_ID_ATRAC3AL) {
894 version = 4;
895 samples_per_frame = SAMPLES_PER_FRAME * channels;
896 delay = 0x88E;
897 q->coding_mode = SINGLE;
898 } else if (avctx->extradata_size == 14) {
899 /* Parse the extradata, WAV format */
900 av_log(avctx, AV_LOG_DEBUG, "[0-1] %d\n",
901 bytestream_get_le16(&edata_ptr)); // Unknown value always 1
902 edata_ptr += 4; // samples per channel
903 q->coding_mode = bytestream_get_le16(&edata_ptr);
904 av_log(avctx, AV_LOG_DEBUG,"[8-9] %d\n",
905 bytestream_get_le16(&edata_ptr)); //Dupe of coding mode
906 frame_factor = bytestream_get_le16(&edata_ptr); // Unknown always 1
907 av_log(avctx, AV_LOG_DEBUG,"[12-13] %d\n",
908 bytestream_get_le16(&edata_ptr)); // Unknown always 0
909
910 /* setup */
911 samples_per_frame = SAMPLES_PER_FRAME * channels;
912 version = 4;
913 delay = 0x88E;
915 q->scrambled_stream = 0;
916
917 if (avctx->block_align != 96 * channels * frame_factor &&
918 avctx->block_align != 152 * channels * frame_factor &&
919 avctx->block_align != 192 * channels * frame_factor) {
920 av_log(avctx, AV_LOG_ERROR, "Unknown frame/channel/frame_factor "
921 "configuration %d/%d/%d\n", avctx->block_align,
922 channels, frame_factor);
923 return AVERROR_INVALIDDATA;
924 }
925 } else if (avctx->extradata_size == 12 || avctx->extradata_size == 10) {
926 /* Parse the extradata, RM format. */
927 version = bytestream_get_be32(&edata_ptr);
928 samples_per_frame = bytestream_get_be16(&edata_ptr);
929 delay = bytestream_get_be16(&edata_ptr);
930 q->coding_mode = bytestream_get_be16(&edata_ptr);
931 q->scrambled_stream = 1;
932
933 } else {
934 av_log(avctx, AV_LOG_ERROR, "Unknown extradata size %d.\n",
935 avctx->extradata_size);
936 return AVERROR(EINVAL);
937 }
938
939 /* Check the extradata */
940
941 if (version != 4) {
942 av_log(avctx, AV_LOG_ERROR, "Version %d != 4.\n", version);
943 return AVERROR_INVALIDDATA;
944 }
945
946 if (samples_per_frame != SAMPLES_PER_FRAME * channels) {
947 av_log(avctx, AV_LOG_ERROR, "Unknown amount of samples per frame %d.\n",
948 samples_per_frame);
949 return AVERROR_INVALIDDATA;
950 }
951
952 if (delay != 0x88E) {
953 av_log(avctx, AV_LOG_ERROR, "Unknown amount of delay %x != 0x88E.\n",
954 delay);
955 return AVERROR_INVALIDDATA;
956 }
957
958 if (q->coding_mode == SINGLE)
959 av_log(avctx, AV_LOG_DEBUG, "Single channels detected.\n");
960 else if (q->coding_mode == JOINT_STEREO) {
961 if (channels % 2 == 1) { /* Joint stereo channels must be even */
962 av_log(avctx, AV_LOG_ERROR, "Invalid joint stereo channel configuration.\n");
963 return AVERROR_INVALIDDATA;
964 }
965 av_log(avctx, AV_LOG_DEBUG, "Joint stereo detected.\n");
966 } else {
967 av_log(avctx, AV_LOG_ERROR, "Unknown channel coding mode %x!\n",
968 q->coding_mode);
969 return AVERROR_INVALIDDATA;
970 }
971
972 if (avctx->block_align > 4096 || avctx->block_align <= 0)
973 return AVERROR(EINVAL);
974
977 if (!q->decoded_bytes_buffer)
978 return AVERROR(ENOMEM);
979
981
982 /* initialize the MDCT transform */
983 if ((ret = av_tx_init(&q->mdct_ctx, &q->mdct_fn, AV_TX_FLOAT_MDCT, 1, 256,
984 &scale, AV_TX_FULL_IMDCT)) < 0) {
985 av_log(avctx, AV_LOG_ERROR, "Error initializing MDCT\n");
986 return ret;
987 }
988
989 /* init the joint-stereo decoding data */
990 for (js_pair = 0; js_pair < MAX_JS_PAIRS; js_pair++) {
991 q->weighting_delay[js_pair][0] = 0;
992 q->weighting_delay[js_pair][1] = 7;
993 q->weighting_delay[js_pair][2] = 0;
994 q->weighting_delay[js_pair][3] = 7;
995 q->weighting_delay[js_pair][4] = 0;
996 q->weighting_delay[js_pair][5] = 7;
997
998 for (i = 0; i < 4; i++) {
999 q->matrix_coeff_index_prev[js_pair][i] = 3;
1000 q->matrix_coeff_index_now[js_pair][i] = 3;
1001 q->matrix_coeff_index_next[js_pair][i] = 3;
1002 }
1003 }
1004
1007 if (!fdsp)
1008 return AVERROR(ENOMEM);
1009 q->vector_fmul = fdsp->vector_fmul;
1010 av_free(fdsp);
1011
1012 q->units = av_calloc(channels, sizeof(*q->units));
1013 if (!q->units)
1014 return AVERROR(ENOMEM);
1015
1016 ff_thread_once(&init_static_once, atrac3_init_static_data);
1017
1018 return 0;
1019}
1020
1022 .p.name = "atrac3",
1023 CODEC_LONG_NAME("ATRAC3 (Adaptive TRansform Acoustic Coding 3)"),
1024 .p.type = AVMEDIA_TYPE_AUDIO,
1025 .p.id = AV_CODEC_ID_ATRAC3,
1026 .priv_data_size = sizeof(ATRAC3Context),
1030 .p.capabilities = AV_CODEC_CAP_DR1,
1031 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
1032};
1033
1035 .p.name = "atrac3al",
1036 CODEC_LONG_NAME("ATRAC3 AL (Adaptive TRansform Acoustic Coding 3 Advanced Lossless)"),
1037 .p.type = AVMEDIA_TYPE_AUDIO,
1038 .p.id = AV_CODEC_ID_ATRAC3AL,
1039 .priv_data_size = sizeof(ATRAC3Context),
1043 .p.capabilities = AV_CODEC_CAP_DR1,
1044 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
1045};
#define MAX_CHANNELS
Definition aac.h:33
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:87
const FFCodec ff_atrac3al_decoder
Definition atrac3.c:1034
const FFCodec ff_atrac3_decoder
Definition atrac3.c:1021
channels
Definition aptx.h:31
static av_cold void close(AVCodecParserContext *s)
Definition apv_parser.c:197
static int add_tonal_components(float *spectrum, int num_components, TonalComponent *components)
Combine the tonal band spectrum and regular band spectrum.
Definition atrac3.c:451
static av_cold void init_imdct_window(void)
Definition atrac3.c:184
static int decode_spectrum(GetBitContext *gb, float *output)
Restore the quantized band spectrum coefficients.
Definition atrac3.c:273
static void read_quant_spectral_coeffs(GetBitContext *gb, int selector, int coding_flag, int *mantissas, int num_codes)
Mantissa decoding.
Definition atrac3.c:219
static int al_decode_frame(AVCodecContext *avctx, const uint8_t *databuf, int size, float **out_samples)
Definition atrac3.c:759
static int atrac3al_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
Definition atrac3.c:833
static void reverse_matrixing(float *su1, float *su2, int *prev_code, int *curr_code)
Definition atrac3.c:472
#define MDCT_SIZE
Definition atrac3.c:63
#define JOINT_STEREO
Definition atrac3.c:59
static av_cold int atrac3_decode_close(AVCodecContext *avctx)
Definition atrac3.c:199
static void get_channel_weights(int index, int flag, float ch[2])
Definition atrac3.c:534
#define ATRAC3_VLC_BITS
Definition atrac3.c:65
#define MAX_JS_PAIRS
Definition atrac3.c:57
static VLCElem atrac3_vlc_table[7 *1<< ATRAC3_VLC_BITS]
Definition atrac3.c:126
static int decode_tonal_components(GetBitContext *gb, TonalComponent *components, int num_bands)
Restore the quantized tonal components.
Definition atrac3.c:331
static int decode_bytes(const uint8_t *input, uint8_t *out, int bytes)
Definition atrac3.c:161
#define SAMPLES_PER_FRAME
Definition atrac3.c:62
static VLC spectral_coeff_tab[7]
Definition atrac3.c:127
static void channel_weighting(float *su1, float *su2, int *p3)
Definition atrac3.c:547
static av_cold void atrac3_init_static_data(void)
Definition atrac3.c:854
#define INTERPOLATE(old, new, nsample)
Definition atrac3.c:469
static av_cold int atrac3_decode_init(AVCodecContext *avctx)
Definition atrac3.c:876
static int atrac3_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
Definition atrac3.c:794
#define SINGLE
Definition atrac3.c:60
static int decode_gain_control(GetBitContext *gb, GainBlock *block, int num_bands)
Decode gain parameters for the coded bands.
Definition atrac3.c:415
static void imlt(ATRAC3Context *q, float *input, float *output, int odd_band)
Regular 512 points IMDCT without overlapping, with the exception of the swapping of odd bands caused ...
Definition atrac3.c:135
static int decode_frame(AVCodecContext *avctx, const uint8_t *databuf, float **out_samples)
Definition atrac3.c:645
static float mdct_window[MDCT_SIZE]
Definition atrac3.c:125
static int decode_channel_sound_unit(ATRAC3Context *q, GetBitContext *gb, ChannelUnit *snd, float *output, int channel_num, int coding_mode)
Decode a Sound Unit.
Definition atrac3.c:578
ATRAC3 AKA RealAudio 8 compatible decoder data.
static const int8_t mantissa_vlc_tab[18]
Definition atrac3data.h:82
static const uint16_t subband_tab[33]
Definition atrac3data.h:94
static const uint8_t huff_tab_sizes[7]
Definition atrac3data.h:72
static const float matrix_coeffs[8]
Definition atrac3data.h:103
static const uint8_t clc_length_tab[8]
Definition atrac3data.h:78
static const float inv_max_quant[8]
Definition atrac3data.h:89
static const uint8_t atrac3_hufftabs[][2]
Definition atrac3data.h:35
static const int8_t mantissa_clc_tab[4]
Definition atrac3data.h:80
void ff_atrac_gain_compensation(AtracGCContext *gctx, float *in, float *prev, AtracGainInfo *gc_now, AtracGainInfo *gc_next, int num_samples, float *out)
Apply gain compensation and perform the MDCT overlapping part.
Definition atrac.c:85
av_cold void ff_atrac_init_gain_compensation(AtracGCContext *gctx, int id2exp_offset, int loc_scale)
Initialize gain compensation context.
Definition atrac.c:67
float ff_atrac_sf_table[64]
Definition atrac.c:36
av_cold void ff_atrac_generate_tables(void)
Generate common tables.
Definition atrac.c:61
void ff_atrac_iqmf(float *inlo, float *inhi, unsigned int nIn, float *pOut, float *delayBuf, float *temp)
Quadrature mirror synthesis filter.
Definition atrac.c:128
ATRAC common header.
#define av_unreachable(msg)
Asserts that are used as compiler optimization hints depending upon ASSERT_LEVEL and NBDEBUG.
Definition avassert.h:109
Libavcodec external API header.
#define av_be2ne32(x)
Definition bswap.h:89
#define flag(name)
Definition cbs_h264.c:60
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
#define NULL
Definition coverity.c:32
static int16_t block[64]
Definition dct.c:125
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Definition decode.c:1777
static AVFrame * frame
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
bitstream reader API header.
static av_always_inline int get_vlc2(GetBitContext *s, const VLCElem *table, int bits, int max_depth)
Parse a vlc code.
Definition get_bits.h:645
static int get_sbits(GetBitContext *s, int n)
Definition get_bits.h:322
static int get_bits_left(GetBitContext *gb)
Definition get_bits.h:688
static unsigned int get_bits1(GetBitContext *s)
Definition get_bits.h:391
static void skip_bits(GetBitContext *s, int n)
Definition get_bits.h:383
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
Definition get_bits.h:544
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition get_bits.h:337
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
Definition get_bits.h:373
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
Definition get_bits.h:517
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
Definition avcodec.h:322
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition codec.h:49
@ AV_CODEC_ID_ATRAC3AL
Definition codec_id.h:535
@ AV_CODEC_ID_ATRAC3
Definition codec_id.h:484
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
Definition defs.h:40
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition error.h:61
#define AVERROR(e)
Definition error.h:45
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition log.h:231
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
@ AVMEDIA_TYPE_AUDIO
Definition avutil.h:201
@ AV_SAMPLE_FMT_FLTP
float, planar
Definition samplefmt.h:66
int index
Definition gxfenc.c:90
#define b
Definition input.c:43
static void scale(int *out, const int *in, const int w, const int h, const int shift)
Definition intra.c:278
Macro definitions for various function/variable attributes.
#define av_cold
Definition attributes.h:117
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
Definition float_dsp.c:135
#define AVOnce
Definition thread.h:202
static int ff_thread_once(char *control, void(*routine)(void))
Definition thread.h:205
#define AV_ONCE_INIT
Definition thread.h:203
version
Definition libkvazaar.c:313
Replacements for frequently missing libm functions.
uint8_t w
Definition llvidencdsp.c:39
#define FFSWAP(type, a, b)
Definition macros.h:52
#define FFMIN(a, b)
Definition macros.h:49
#define FFMAX(a, b)
Definition macros.h:47
#define FFALIGN(x, a)
Definition macros.h:78
#define M_PI
Definition mathematics.h:67
void * av_calloc(size_t nmemb, size_t size)
Definition mem.c:264
Memory handling functions.
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
static av_always_inline int cmp(MPVEncContext *const s, const int x, const int y, const int subx, const int suby, const int size, const int h, int ref_index, int src_index, me_cmp_func cmp_func, me_cmp_func chroma_cmp_func, const int flags)
compares a block (either a full macroblock or a partition thereof) against a proposed motion-compensa...
Definition motion_est.c:263
static const uint64_t c2
Definition murmur3.c:53
static const uint64_t c1
Definition murmur3.c:52
static const uint16_t table[]
Definition prosumer.c:203
const uint8_t * code
Definition spdifenc.c:433
unsigned int pos
Definition spdifenc.c:431
int matrix_coeff_index_next[MAX_JS_PAIRS][4]
Definition atrac3.c:105
int weighting_delay[MAX_JS_PAIRS][6]
Definition atrac3.c:106
float temp_buf[1070]
Definition atrac3.c:111
void(* vector_fmul)(float *dst, const float *src0, const float *src1, int len)
Definition atrac3.c:121
int matrix_coeff_index_now[MAX_JS_PAIRS][4]
Definition atrac3.c:104
int scrambled_stream
extradata
Definition atrac3.c:115
AtracGCContext gainc_ctx
Definition atrac3.c:118
uint8_t * decoded_bytes_buffer
data buffers
Definition atrac3.c:110
av_tx_fn mdct_fn
Definition atrac3.c:120
int coding_mode
stream data
Definition atrac3.c:97
GetBitContext gb
Definition atrac3.c:94
ChannelUnit * units
Definition atrac3.c:99
int matrix_coeff_index_prev[MAX_JS_PAIRS][4]
joint-stereo related variables
Definition atrac3.c:103
AVTXContext * mdct_ctx
Definition atrac3.c:119
int nb_channels
Number of channels in this layout.
main external API structure.
Definition avcodec.h:443
AVChannelLayout ch_layout
Audio channel layout.
Definition avcodec.h:1055
enum AVSampleFormat sample_fmt
audio sample format
Definition avcodec.h:1047
int flags
AV_CODEC_FLAG_*.
Definition avcodec.h:500
uint8_t * extradata
Out-of-band global headers that may be used by some codecs.
Definition avcodec.h:526
enum AVCodecID codec_id
Definition avcodec.h:453
int extradata_size
Definition avcodec.h:527
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs.
Definition avcodec.h:1075
void * priv_data
Definition avcodec.h:470
void(* vector_fmul)(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.
Definition float_dsp.h:38
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
This structure stores compressed data.
Definition packet.h:580
int size
Definition packet.h:604
uint8_t * data
Definition packet.h:603
Gain compensation context structure.
Definition atrac.h:44
Gain control parameters for one subband.
Definition atrac.h:35
int num_points
number of gain control points
Definition atrac.h:36
int loc_code[7]
location of gain control points
Definition atrac.h:38
int lev_code[7]
level at corresponding control point
Definition atrac.h:37
float delay_buf3[46]
Definition atrac3.c:90
float imdct_buf[SAMPLES_PER_FRAME]
Definition atrac3.c:86
float spectrum[SAMPLES_PER_FRAME]
Definition atrac3.c:85
float delay_buf1[46]
qmf delay buffers
Definition atrac3.c:88
TonalComponent components[64]
Definition atrac3.c:82
int num_components
Definition atrac3.c:79
int bands_coded
Definition atrac3.c:78
float prev_frame[SAMPLES_PER_FRAME]
Definition atrac3.c:80
int gc_blk_switch
Definition atrac3.c:81
float delay_buf2[46]
Definition atrac3.c:89
GainBlock gain_block[2]
Definition atrac3.c:83
AtracGainInfo g_block[4]
Definition atrac3.c:68
int num_coefs
Definition atrac3.c:73
float coef[8]
Definition atrac3.c:74
Definition vlc.h:32
Definition vlc.h:50
uint8_t level
Definition svq3.c:208
#define av_free(p)
#define av_mallocz(s)
#define avpriv_request_sample(...)
#define av_freep(p)
#define av_log(a,...)
#define src1
Definition h264pred.c:141
#define src0
Definition h264pred.c:140
static FILE * out
Definition movenc.c:55
int size
av_cold void av_tx_uninit(AVTXContext **ctx)
Frees a context and sets *ctx to NULL, does nothing when *ctx == NULL.
Definition tx.c:295
av_cold int av_tx_init(AVTXContext **ctx, av_tx_fn *tx, enum AVTXType type, int inv, int len, const void *scale, uint64_t flags)
Initialize a transform context with the given configuration (i)MDCTs with an odd length are currently...
Definition tx.c:903
@ AV_TX_FULL_IMDCT
Performs a full inverse MDCT rather than leaving out samples that can be derived through symmetry.
Definition tx.h:175
@ AV_TX_FLOAT_MDCT
Standard MDCT with a sample data type of float, double or int32_t, respectively.
Definition tx.h:68
void(* av_tx_fn)(AVTXContext *s, void *out, void *in, ptrdiff_t stride)
Function pointer to a function to perform the transform.
Definition tx.h:151
int ff_vlc_init_from_lengths(VLC *vlc, int nb_bits, int nb_codes, const int8_t *lens, int lens_wrap, const void *symbols, int symbols_wrap, int symbols_size, int offset, int flags, void *logctx)
Build VLC decoding tables suitable for use with get_vlc2()
Definition vlc.c:306
#define VLC_INIT_USE_STATIC
Definition vlc.h:190
int len
static double c[64]