38 #define BITSTREAM_READER_LE
54 #define QDM2_LIST_ADD(list, size, packet) \
57 list[size - 1].next = &list[size]; \
59 list[size].packet = packet; \
60 list[size].next = NULL; \
65 #define QDM2_SB_USED(sub_sampling) (((sub_sampling) >= 2) ? 30 : 8 << (sub_sampling))
67 #define FIX_NOISE_IDX(noise_idx) \
68 if ((noise_idx) >= 3840) \
69 (noise_idx) -= 3840; \
71 #define SB_DITHERING_NOISE(sb,noise_idx) (noise_table[(noise_idx)++] * sb_noise_attenuation[(sb)])
73 #define BITS_LEFT(length,gb) ((length) - get_bits_count ((gb)))
75 #define SAMPLES_NEEDED \
76 av_log (NULL,AV_LOG_INFO,"This file triggers some untested code. Please contact the developers.\n");
78 #define SAMPLES_NEEDED_2(why) \
79 av_log (NULL,AV_LOG_INFO,"This file triggers some missing code. Please contact the developers.\nPosition: %s\n",why);
81 #define QDM2_MAX_FRAME_SIZE 512
167 int fft_coefs_min_index[5];
168 int fft_coefs_max_index[5];
169 int fft_level_exp[6];
223 0,260,566,598,894,1166,1230,1294,1678,1950,2214,2278,2310,2570,2834,3124,3448,3838,
228 static int vlcs_initialized = 0;
229 static VLC_TYPE qdm2_table[3838][2];
231 if (!vlcs_initialized) {
239 vlc_tab_diff.
table = &qdm2_table[qdm2_vlc_offs[1]];
245 vlc_tab_run.
table = &qdm2_table[qdm2_vlc_offs[2]];
251 fft_level_exp_alt_vlc.
table = &qdm2_table[qdm2_vlc_offs[3]];
252 fft_level_exp_alt_vlc.
table_allocated = qdm2_vlc_offs[4] - qdm2_vlc_offs[3];
253 init_vlc (&fft_level_exp_alt_vlc, 8, 28,
258 fft_level_exp_vlc.
table = &qdm2_table[qdm2_vlc_offs[4]];
259 fft_level_exp_vlc.
table_allocated = qdm2_vlc_offs[5] - qdm2_vlc_offs[4];
260 init_vlc (&fft_level_exp_vlc, 8, 20,
264 fft_stereo_exp_vlc.
table = &qdm2_table[qdm2_vlc_offs[5]];
265 fft_stereo_exp_vlc.
table_allocated = qdm2_vlc_offs[6] - qdm2_vlc_offs[5];
266 init_vlc (&fft_stereo_exp_vlc, 6, 7,
270 fft_stereo_phase_vlc.
table = &qdm2_table[qdm2_vlc_offs[6]];
271 fft_stereo_phase_vlc.
table_allocated = qdm2_vlc_offs[7] - qdm2_vlc_offs[6];
272 init_vlc (&fft_stereo_phase_vlc, 6, 9,
276 vlc_tab_tone_level_idx_hi1.
table = &qdm2_table[qdm2_vlc_offs[7]];
277 vlc_tab_tone_level_idx_hi1.
table_allocated = qdm2_vlc_offs[8] - qdm2_vlc_offs[7];
278 init_vlc (&vlc_tab_tone_level_idx_hi1, 8, 20,
282 vlc_tab_tone_level_idx_mid.
table = &qdm2_table[qdm2_vlc_offs[8]];
283 vlc_tab_tone_level_idx_mid.
table_allocated = qdm2_vlc_offs[9] - qdm2_vlc_offs[8];
284 init_vlc (&vlc_tab_tone_level_idx_mid, 8, 24,
288 vlc_tab_tone_level_idx_hi2.
table = &qdm2_table[qdm2_vlc_offs[9]];
289 vlc_tab_tone_level_idx_hi2.
table_allocated = qdm2_vlc_offs[10] - qdm2_vlc_offs[9];
290 init_vlc (&vlc_tab_tone_level_idx_hi2, 8, 24,
294 vlc_tab_type30.
table = &qdm2_table[qdm2_vlc_offs[10]];
295 vlc_tab_type30.
table_allocated = qdm2_vlc_offs[11] - qdm2_vlc_offs[10];
300 vlc_tab_type34.
table = &qdm2_table[qdm2_vlc_offs[11]];
301 vlc_tab_type34.
table_allocated = qdm2_vlc_offs[12] - qdm2_vlc_offs[11];
306 vlc_tab_fft_tone_offset[0].
table = &qdm2_table[qdm2_vlc_offs[12]];
307 vlc_tab_fft_tone_offset[0].
table_allocated = qdm2_vlc_offs[13] - qdm2_vlc_offs[12];
308 init_vlc (&vlc_tab_fft_tone_offset[0], 8, 23,
312 vlc_tab_fft_tone_offset[1].
table = &qdm2_table[qdm2_vlc_offs[13]];
313 vlc_tab_fft_tone_offset[1].
table_allocated = qdm2_vlc_offs[14] - qdm2_vlc_offs[13];
314 init_vlc (&vlc_tab_fft_tone_offset[1], 8, 28,
318 vlc_tab_fft_tone_offset[2].
table = &qdm2_table[qdm2_vlc_offs[14]];
319 vlc_tab_fft_tone_offset[2].
table_allocated = qdm2_vlc_offs[15] - qdm2_vlc_offs[14];
320 init_vlc (&vlc_tab_fft_tone_offset[2], 8, 32,
324 vlc_tab_fft_tone_offset[3].
table = &qdm2_table[qdm2_vlc_offs[15]];
325 vlc_tab_fft_tone_offset[3].
table_allocated = qdm2_vlc_offs[16] - qdm2_vlc_offs[15];
326 init_vlc (&vlc_tab_fft_tone_offset[3], 8, 35,
330 vlc_tab_fft_tone_offset[4].
table = &qdm2_table[qdm2_vlc_offs[16]];
331 vlc_tab_fft_tone_offset[4].
table_allocated = qdm2_vlc_offs[17] - qdm2_vlc_offs[16];
332 init_vlc (&vlc_tab_fft_tone_offset[4], 8, 38,
354 if ((value & ~3) > 0)
367 return (value & 1) ? ((value + 1) >> 1) : -(value >> 1);
383 for (i=0; i < length; i++)
386 return (uint16_t)(value & 0xffff);
400 if (sub_packet->
type == 0) {
401 sub_packet->
size = 0;
406 if (sub_packet->
type & 0x80) {
407 sub_packet->
size <<= 8;
409 sub_packet->
type &= 0x7f;
412 if (sub_packet->
type == 0x7f)
449 int i, j, n, ch, sum;
454 for (i = 0; i < n; i++) {
457 for (j = 0; j < 8; j++)
464 for (j=0; j < 8; j++)
487 for (j = 0; j < 64; j++) {
508 int switchtable[23] = {0,5,1,5,5,5,5,5,2,5,5,5,5,5,5,5,3,5,5,5,5,5,4};
510 for (ch = 0; ch < channels; ch++) {
511 for (j = 0; j < 64; ) {
512 if (coding_method[ch][sb][j] < 8)
514 if ((coding_method[ch][sb][j] - 8) > 22) {
518 switch (switchtable[coding_method[ch][sb][j]-8]) {
519 case 0: run = 10; case_val = 10;
break;
520 case 1: run = 1; case_val = 16;
break;
521 case 2: run = 5; case_val = 24;
break;
522 case 3: run = 3; case_val = 30;
break;
523 case 4: run = 1; case_val = 30;
break;
524 case 5: run = 1; case_val = 8;
break;
525 default: run = 1; case_val = 8;
break;
528 for (k = 0; k <
run; k++)
530 if (coding_method[ch][sb + (j + k) / 64][(j + k) % 64] > coding_method[ch][sb][j])
534 memset(&coding_method[ch][sb][j + k], case_val, k *
sizeof(int8_t));
535 memset(&coding_method[ch][sb][j + k], case_val, 3 *
sizeof(int8_t));
553 int i, sb, ch, sb_used;
561 for (sb = 0; sb < 30; sb++)
562 for (i = 0; i < 8; i++) {
576 for (sb = 0; sb < sb_used; sb++)
578 for (i = 0; i < 64; i++) {
587 for (sb = 0; sb < sb_used; sb++) {
588 if ((sb >= 4) && (sb <= 23)) {
590 for (i = 0; i < 64; i++) {
604 for (i = 0; i < 64; i++) {
616 for (i = 0; i < 64; i++) {
648 int c,
int superblocktype_2_3,
int cm_table_select)
652 int add1, add2, add3, add4;
656 if (nb_channels <= 0)
659 if (!superblocktype_2_3) {
663 for (sb = 0; sb < 30; sb++) {
664 for (j = 1; j < 63; j++) {
665 add1 = tone_level_idx[ch][sb][j] - 10;
668 add2 = add3 = add4 = 0;
684 tmp = tone_level_idx[ch][sb][j + 1] * 2 - add4 - add3 - add2 - add1;
687 tone_level_idx_temp[ch][sb][j + 1] = tmp & 0xff;
689 tone_level_idx_temp[ch][sb][0] = tone_level_idx_temp[ch][sb][1];
693 for (sb = 0; sb < 30; sb++)
694 for (j = 0; j < 64; j++)
695 acc += tone_level_idx_temp[ch][sb][j];
697 multres = 0x66666667 * (acc * 10);
698 esp_40 = (multres >> 32) / 8 + ((multres & 0xffffffff) >> 31);
700 for (sb = 0; sb < 30; sb++)
701 for (j = 0; j < 64; j++) {
702 comp = tone_level_idx_temp[ch][sb][j]* esp_40 * 10;
733 coding_method[ch][sb][j] = ((tmp & 0xfffa) + 30 )& 0xff;
735 for (sb = 0; sb < 30; sb++)
738 for (sb = 0; sb < 30; sb++)
739 for (j = 0; j < 64; j++)
741 if (coding_method[ch][sb][j] < 10)
742 coding_method[ch][sb][j] = 10;
745 if (coding_method[ch][sb][j] < 16)
746 coding_method[ch][sb][j] = 16;
748 if (coding_method[ch][sb][j] < 30)
749 coding_method[ch][sb][j] = 30;
754 for (sb = 0; sb < 30; sb++)
755 for (j = 0; j < 64; j++)
776 int sb, j, k, n, ch,
run, channels;
777 int joined_stereo, zero_encoding;
779 float type34_div = 0;
780 float type34_predictor;
781 float samples[10], sign_bits[16];
785 for (sb=sb_min; sb < sb_max; sb++)
791 for (sb = sb_min; sb < sb_max; sb++) {
803 for (j = 0; j < 16; j++)
806 for (j = 0; j < 64; j++)
818 for (ch = 0; ch < channels; ch++) {
821 type34_predictor = 0.0;
824 for (j = 0; j < 128; ) {
829 for (k = 0; k < 5; k++) {
830 if ((j + 2 * k) >= 128)
836 for (k = 0; k < 5; k++)
839 for (k = 0; k < 5; k++)
842 for (k = 0; k < 10; k++)
854 f -=
noise_samples[((sb + 1) * (j +5 * ch + 1)) & 127] * 9.0 / 40.0;
865 for (k = 0; k < 5; k++) {
872 for (k = 0; k < 5; k++)
876 for (k = 0; k < 5; k++)
885 for (k = 0; k < 3; k++)
888 for (k = 0; k < 3; k++)
910 type34_div = (float)(1 <<
get_bits(gb, 2));
911 samples[0] = ((float)
get_bits(gb, 5) - 16.0) / 15.0;
912 type34_predictor = samples[0];
918 type34_predictor = samples[0];
935 for (k = 0; k < run && j + k < 128; k++) {
937 q->
tone_level[0][sb][(j + k) / 2] * samples[k];
939 if (sign_bits[(j + k) / 8])
941 q->
tone_level[1][sb][(j + k) / 2] * -samples[k];
944 q->
tone_level[1][sb][(j + k) / 2] * samples[k];
948 for (k = 0; k <
run; k++)
977 quantized_coeffs[0] =
level;
979 for (i = 0; i < 7; ) {
988 for (k = 1; k <=
run; k++)
989 quantized_coeffs[i + k] = (level + ((k * diff) / run));
1008 int sb, j, k, n, ch;
1021 for (sb = 0; sb < n; sb++)
1023 for (j = 0; j < 8; j++) {
1027 for (k=0; k < 8; k++) {
1033 for (k=0; k < 8; k++)
1040 for (sb = 0; sb < n; sb++)
1048 for (j = 0; j < 8; j++)
1054 for (sb = 0; sb < n; sb++)
1056 for (j = 0; j < 8; j++) {
1072 int i, j, k, n, ch,
run,
level, diff;
1078 for (i = 1; i < n; i++)
1083 for (j = 0; j < (8 - 1); ) {
1087 for (k = 1; k <=
run; k++)
1096 for (i = 0; i < 8; i++)
1173 if (nodes[0] !=
NULL)
1177 if (nodes[1] !=
NULL)
1183 if (nodes[0] !=
NULL && nodes[1] !=
NULL && nodes[2] !=
NULL)
1189 if (nodes[0] !=
NULL && nodes[1] !=
NULL && nodes[3] !=
NULL)
1205 int i, packet_bytes, sub_packet_size, sub_packets_D;
1206 unsigned int next_index = 0;
1220 if (header.
type < 2 || header.
type >= 8) {
1231 if (header.
type == 2 || header.
type == 4 || header.
type == 5) {
1247 for (i = 0; i < 6; i++)
1251 for (i = 0; packet_bytes > 0; i++) {
1268 if (next_index >= header.
size)
1276 sub_packet_size = ((packet->
size > 0xff) ? 1 : 0) + packet->
size + 2;
1278 if (packet->
type == 0)
1281 if (sub_packet_size > packet_bytes) {
1282 if (packet->
type != 10 && packet->
type != 11 && packet->
type != 12)
1284 packet->
size += packet_bytes - sub_packet_size;
1287 packet_bytes -= sub_packet_size;
1293 if (packet->
type == 8) {
1296 }
else if (packet->
type >= 9 && packet->
type <= 12) {
1299 }
else if (packet->
type == 13) {
1300 for (j = 0; j < 6; j++)
1302 }
else if (packet->
type == 14) {
1303 for (j = 0; j < 6; j++)
1305 }
else if (packet->
type == 15) {
1328 int offset,
int duration,
int channel,
1345 int channel, stereo, phase, exp;
1346 int local_int_4, local_int_8, stereo_phase, local_int_10;
1347 int local_int_14, stereo_exp, local_int_20, local_int_28;
1354 local_int_10 = 1 << (q->
group_order - duration - 1);
1359 while ((n =
qdm2_get_vlc(gb, &vlc_tab_fft_tone_offset[local_int_8], 1, 2)) < 2) {
1362 local_int_4 += local_int_10;
1363 local_int_28 += (1 << local_int_8);
1365 local_int_4 += 8*local_int_10;
1366 local_int_28 += (8 << local_int_8);
1371 offset +=
qdm2_get_vlc(gb, &vlc_tab_fft_tone_offset[local_int_8], 1, 2);
1372 while (offset >= (local_int_10 - 1)) {
1373 offset += (1 - (local_int_10 - 1));
1374 local_int_4 += local_int_10;
1375 local_int_28 += (1 << local_int_8);
1382 local_int_14 = (offset >> local_int_8);
1394 exp =
qdm2_get_vlc(gb, (b ? &fft_level_exp_vlc : &fft_level_exp_alt_vlc), 0, 2);
1396 exp = (exp < 0) ? 0 : exp;
1403 stereo_exp = (exp -
qdm2_get_vlc(gb, &fft_stereo_exp_vlc, 0, 1));
1404 stereo_phase = (phase -
qdm2_get_vlc(gb, &fft_stereo_phase_vlc, 0, 1));
1405 if (stereo_phase < 0)
1410 int sub_packet = (local_int_20 + local_int_28);
1424 int i, j,
min, max, value, type, unknown_flag;
1432 for (i=0; i < 5; i++)
1442 if (value > min && value < max) {
1465 type = packet->
type;
1467 if ((type >= 17 && type < 24) || (type >= 33 && type < 40)) {
1470 if (duration >= 0 && duration < 4)
1472 }
else if (type == 31) {
1473 for (j=0; j < 4; j++)
1475 }
else if (type == 46) {
1476 for (j=0; j < 6; j++)
1478 for (j=0; j < 4; j++)
1484 for (i = 0, j = -1; i < 5; i++)
1500 const double iscale = 2.0*
M_PI / 512.0;
1506 c.
im = level * sin(tone->
phase*iscale);
1507 c.
re = level * cos(tone->
phase*iscale);
1516 f[1] = -tone->
table[4];
1518 f[2] = 1.0 - tone->
table[2] - tone->
table[3];
1519 f[3] = tone->
table[1] + tone->
table[4] - 1.0;
1521 f[5] = tone->
table[2];
1522 for (i = 0; i < 2; i++) {
1526 for (i = 0; i < 4; i++) {
1543 const double iscale = 0.25 *
M_PI;
1545 for (ch = 0; ch < q->
channels; ch++) {
1577 for (i = 0; i < 4; i++)
1590 if (offset < q->frequency_range) {
1594 tone.
cutoff = (offset >= 60) ? 3 : 2;
1631 int i, k, ch, sb_used, sub_sampling, dither_state = 0;
1636 for (ch = 0; ch < q->
channels; ch++)
1637 for (i = 0; i < 8; i++)
1638 for (k=sb_used; k <
SBLIMIT; k++)
1642 float *samples_ptr = q->
samples + ch;
1644 for (i = 0; i < 8; i++) {
1657 for (ch = 0; ch < q->
channels; ch++)
1669 static int initialized = 0;
1671 if (initialized != 0)
1689 #define PRINT(a,b) av_log(NULL,AV_LOG_DEBUG," %s = %d\n", a, b);
1722 PRINT(
" samples_im", t->samples_im);
1723 PRINT(
" samples_re", t->samples_re);
1739 int tmp_val, tmp,
size;
1783 while (extradata_size > 7) {
1784 if (!memcmp(extradata,
"frmaQDM", 7))
1790 if (extradata_size < 12) {
1796 if (memcmp(extradata,
"frmaQDM", 7)) {
1801 if (extradata[7] ==
'C') {
1808 extradata_size -= 8;
1812 if(size > extradata_size){
1814 extradata_size, size);
1863 case 0: tmp = 40;
break;
1864 case 1: tmp = 48;
break;
1865 case 2: tmp = 56;
break;
1866 case 3: tmp = 72;
break;
1867 case 4: tmp = 80;
break;
1868 case 5: tmp = 100;
break;
1872 if ((tmp * 1000) < avctx->
bit_rate) tmp_val = 1;
1873 if ((tmp * 1440) < avctx->
bit_rate) tmp_val = 2;
1874 if ((tmp * 1760) < avctx->
bit_rate) tmp_val = 3;
1875 if ((tmp * 2240) < avctx->
bit_rate) tmp_val = 4;
1889 else if (tmp <= 16000)
1942 memset(&q->
output_buffer[frame_size], 0, frame_size *
sizeof(
float));
1960 for (ch = 0; ch < q->
channels; ch++) {
1976 for (i = 0; i < frame_size; i++) {
1992 int *got_frame_ptr,
AVPacket *avpkt)
1994 const uint8_t *buf = avpkt->
data;
1995 int buf_size = avpkt->
size;
2002 if(buf_size < s->checksum_size)
2013 for (i = 0; i < 16; i++) {
av_cold void ff_rdft_end(RDFTContext *s)
static const uint16_t vlc_tab_tone_level_idx_mid_huffcodes[24]
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
FFTTone fft_tones[1000]
FFT and tones.
static const uint8_t vlc_tab_level_huffbits[24]
A node in the subpacket list.
AV_WL32 AV_WL24 AV_WL16 AV_RB32
static int fix_coding_method_array(int sb, int channels, sb_int8_array coding_method)
Called while processing data from subpackets 11 and 12.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static const float fft_tone_level_table[2][64]
AVFrame * coded_frame
the picture in the bitstream
static void process_subpacket_12(QDM2Context *q, QDM2SubPNode *node, int length)
Process subpacket 12.
static void average_quantized_coeffs(QDM2Context *q)
Replace 8 elements with their average value.
static void synthfilt_build_sb_samples(QDM2Context *q, GetBitContext *gb, int length, int sb_min, int sb_max)
Called by process_subpacket_11 to process more data from subpacket 11 with sb 0-8 Called by process_s...
#define QDM2_MAX_FRAME_SIZE
float synth_buf[MPA_MAX_CHANNELS][512 *2]
static const uint8_t vlc_tab_type34_huffbits[10]
static const uint8_t fft_level_exp_alt_huffbits[28]
#define DECLARE_ALIGNED(n, t, v)
static const uint16_t vlc_tab_fft_tone_offset_0_huffcodes[23]
int8_t tone_level_idx_base[MPA_MAX_CHANNELS][30][8]
static const uint8_t fft_stereo_phase_huffbits[9]
int coeff_per_sb_select
selector for "num. of coeffs. per subband" tables. Can be 0, 1, 2
static av_cold int qdm2_decode_close(AVCodecContext *avctx)
unsigned int size
subpacket size
int8_t tone_level_idx_hi2[MPA_MAX_CHANNELS][26]
#define FF_ARRAY_ELEMS(a)
float sb_samples[MPA_MAX_CHANNELS][128][SBLIMIT]
static void qdm2_decode_sub_packet_header(GetBitContext *gb, QDM2SubPacket *sub_packet)
Fill a QDM2SubPacket structure with packet type, size, and data pointer.
static void qdm2_fft_init_coefficient(QDM2Context *q, int sub_packet, int offset, int duration, int channel, int exp, int phase)
QDM2SubPNode sub_packet_list_C[16]
packets with errors?
static QDM2SubPNode * qdm2_search_subpacket_type_in_list(QDM2SubPNode *list, int type)
Return node pointer to first packet of requested type in list.
static void init_quantized_coeffs_elem0(int8_t *quantized_coeffs, GetBitContext *gb, int length)
Init the first element of a channel in quantized_coeffs with data from packet 10 (quantized_coeffs[ch...
static VLC vlc_tab_tone_level_idx_hi1
static VLC vlc_tab_type30
static av_cold int qdm2_decode_init(AVCodecContext *avctx)
Init parameters from codec extradata.
static VLC vlc_tab_fft_tone_offset[5]
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
enum AVSampleFormat sample_fmt
audio sample format
int fft_order
order of FFT (actually fftorder+1)
static void process_subpacket_11(QDM2Context *q, QDM2SubPNode *node, int length)
Process subpacket 11.
static void qdm2_decode_fft_packets(QDM2Context *q)
int sub_sampling
subsampling: 0=25%, 1=50%, 2=100% */
void ff_mpa_synth_init_float(float *window)
#define SOFTCLIP_THRESHOLD
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
static void qdm2_fft_tone_synthesizer(QDM2Context *q, int sub_packet)
static const int16_t fft_level_index_table[256]
static const float fft_tone_envelope_table[4][31]
static const uint8_t vlc_tab_tone_level_idx_hi2_huffbits[24]
static int get_bits_count(const GetBitContext *s)
bitstream reader API header.
static const uint8_t coeff_per_sb_for_dequant[3][30]
int checksum_size
size of data block, used also for checksum
static const uint16_t vlc_tab_fft_tone_offset_1_huffcodes[28]
static int qdm2_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
static const uint8_t fft_subpackets[32]
static const uint8_t vlc_tab_run_huffbits[6]
static int init(AVCodecParserContext *s)
static const uint8_t vlc_tab_tone_level_idx_mid_huffbits[24]
static const uint8_t vlc_tab_type30_huffbits[9]
int channels
number of channels
static void fill_tone_level_array(QDM2Context *q, int flag)
Related to synthesis filter Called by process_subpacket_10.
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static av_cold void qdm2_init(QDM2Context *q)
Init static data (does not depend on specific file)
static const uint8_t fft_stereo_exp_huffbits[7]
int synth_buf_offset[MPA_MAX_CHANNELS]
static av_cold void rnd_table_init(void)
static uint8_t random_dequant_type24[128][3]
static const uint8_t vlc_tab_fft_tone_offset_4_huffbits[38]
static void process_subpacket_10(QDM2Context *q, QDM2SubPNode *node, int length)
Process subpacket 10 if not null, else.
const uint8_t * data
pointer to subpacket data (points to input data buffer, it's not a private copy)
float output_buffer[QDM2_MAX_FRAME_SIZE *2]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
int group_size
size of frame group (16 frames per group)
void ff_mpa_synth_filter_float(MPADSPContext *s, float *synth_buf_ptr, int *synth_buf_offset, float *window, int *dither_state, float *samples, int incr, float *sb_samples)
static const uint16_t vlc_tab_level_huffcodes[24]
VLC TABLES.
int sub_packets_B
number of packets on 'B' list
QDM2SubPNode sub_packet_list_A[16]
list of all packets
void av_log(void *avcl, int level, const char *fmt,...)
int noise_idx
index for dithering noise table
const char * name
Name of the codec implementation.
static VLC fft_level_exp_alt_vlc
float tone_level[MPA_MAX_CHANNELS][30][64]
Mixed temporary data used in decoding.
static const uint16_t vlc_tab_fft_tone_offset_4_huffcodes[38]
void(* rdft_calc)(struct RDFTContext *s, FFTSample *z)
void ff_mpadsp_init(MPADSPContext *s)
int8_t quantized_coeffs[MPA_MAX_CHANNELS][10][8]
static void qdm2_synthesis_filter(QDM2Context *q, int index)
static void init_tone_level_dequantization(QDM2Context *q, GetBitContext *gb, int length)
Related to synthesis filter, process data from packet 10 Init part of quantized_coeffs via function i...
#define QDM2_SB_USED(sub_sampling)
int group_order
Parameters built from header parameters, do not change during playback.
int bit_rate
the average bitrate
static const uint8_t vlc_tab_run_huffcodes[6]
int fft_frame_size
size of fft frame, in components (1 comples = re + im)
static const uint8_t vlc_tab_fft_tone_offset_1_huffbits[28]
static float noise_samples[128]
QDM2SubPNode sub_packet_list_B[16]
FFT packets B are on list.
static const uint16_t fft_level_exp_alt_huffcodes[28]
FFT TABLES.
static const uint8_t vlc_tab_diff_huffbits[37]
struct QDM2SubPNode * next
pointer to next packet in the list, NULL if leaf node
static const int8_t tone_level_idx_offset_table[30][4]
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame)
static VLC vlc_tab_type34
float ff_mpa_synth_window_float[]
static VLC fft_stereo_exp_vlc
static void qdm2_decode_super_block(QDM2Context *q)
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
#define SAMPLES_NEEDED_2(why)
static const int8_t coding_method_table[5][30]
static uint16_t qdm2_packet_checksum(const uint8_t *data, int length, int value)
QDM2 checksum.
static const uint16_t vlc_tab_tone_level_idx_hi1_huffcodes[20]
#define QDM2_LIST_ADD(list, size, packet)
static uint8_t random_dequant_index[256][5]
static const float type30_dequant[8]
static VLC vlc_tab_tone_level_idx_hi2
static VLC fft_level_exp_vlc
#define INIT_VLC_USE_NEW_STATIC
static uint16_t softclip_table[HARDCLIP_THRESHOLD-SOFTCLIP_THRESHOLD+1]
QDM2Complex complex[MPA_MAX_CHANNELS][256]
static const float type34_delta[10]
static const float dequant_1bit[2][3]
static const uint8_t fft_stereo_exp_huffcodes[7]
static void build_sb_samples_from_noise(QDM2Context *q, int sb)
Build subband samples with noise weighted by q->tone_level.
float samples[MPA_MAX_CHANNELS *MPA_FRAME_SIZE]
static const uint8_t last_coeff[3]
static const int fft_cutoff_index_table[4][2]
int sample_rate
samples per second
static void qdm2_fft_decode_tones(QDM2Context *q, int duration, GetBitContext *gb, int b)
static const uint8_t coeff_per_sb_for_avg[3][30]
int8_t tone_level_idx_mid[MPA_MAX_CHANNELS][26][8]
main external API structure.
static void close(AVCodecParserContext *s)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define init_vlc(vlc, nb_bits, nb_codes,bits, bits_wrap, bits_size,codes, codes_wrap, codes_size,flags)
int fft_coefs_min_index[5]
static void process_subpacket_9(QDM2Context *q, QDM2SubPNode *node)
Process subpacket 9, init quantized_coeffs with data from it.
FFTCoefficient fft_coefs[1000]
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits(GetBitContext *s, int n)
int has_errors
packet has errors
static const uint8_t dequant_table[64]
static const uint16_t vlc_tab_fft_tone_offset_2_huffcodes[32]
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
static void fill_coding_method_array(sb_int8_array tone_level_idx, sb_int8_array tone_level_idx_temp, sb_int8_array coding_method, int nb_channels, int c, int superblocktype_2_3, int cm_table_select)
Related to synthesis filter Called by process_subpacket_11 c is built with data from subpacket 11 Mos...
#define HARDCLIP_THRESHOLD
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
static const uint8_t vlc_tab_type34_huffcodes[10]
int8_t coding_method[MPA_MAX_CHANNELS][30][64]
static int qdm2_get_se_vlc(VLC *vlc, GetBitContext *gb, int depth)
static av_cold void softclip_table_init(void)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int fft_size
size of FFT, in complex numbers
static const uint8_t vlc_tab_fft_tone_offset_0_huffbits[23]
int fft_coefs_max_index[5]
int frame_size
size of data frame
static int qdm2_decode(QDM2Context *q, const uint8_t *in, int16_t *out)
#define FIX_NOISE_IDX(noise_idx)
static const float fft_tone_sample_table[4][16][5]
int8_t tone_level_idx_hi1[MPA_MAX_CHANNELS][3][8][8]
int nb_channels
Parameters from codec header, do not change during playback.
int superblocktype_2_3
select fft tables and some algorithm based on superblock type
static const uint8_t fft_stereo_phase_huffcodes[9]
common internal api header.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static const uint16_t vlc_tab_tone_level_idx_hi2_huffcodes[24]
static const uint16_t vlc_tab_fft_tone_offset_3_huffcodes[35]
int cm_table_select
selector for "coding method" tables. Can be 0, 1 (from init: 0-4)
QDM2SubPacket * packet
packet
QDM2SubPacket sub_packets[16]
Packets and packet lists.
static const int vlc_stage3_values[60]
static const uint8_t vlc_tab_fft_tone_offset_2_huffbits[32]
mpeg audio declarations for both encoder and decoder.
static const uint16_t vlc_tab_diff_huffcodes[37]
int do_synth_filter
used to perform or skip synthesis filter
const uint8_t * compressed_data
I/O data.
int8_t tone_level_idx_temp[MPA_MAX_CHANNELS][30][64]
#define MKBETAG(a, b, c, d)
static int qdm2_get_vlc(GetBitContext *gb, VLC *vlc, int flag, int depth)
MPADSPContext mpadsp
Synthesis filter.
static void av_cold dump_context(WMAProDecodeCtx *s)
helper function to print the most important members of the context
static VLC fft_stereo_phase_vlc
int channels
number of audio channels
static const uint8_t vlc_tab_tone_level_idx_hi1_huffbits[20]
static void qdm2_fft_generate_tone(QDM2Context *q, FFTTone *tone)
QDM2SubPNode sub_packet_list_D[16]
DCT packets.
static VLC vlc_tab_tone_level_idx_mid
int8_t tone_level_idx[MPA_MAX_CHANNELS][30][64]
VLC_TYPE(* table)[2]
code, bits
static const uint16_t qdm2_vlc_offs[]
static const uint8_t vlc_tab_type30_huffcodes[9]
static const uint8_t fft_level_exp_huffbits[20]
static const struct @46 tab
TwinVQ codebooks.
struct QDM2SubPNode QDM2SubPNode
A node in the subpacket list.
static av_cold void qdm2_init_vlc(void)
static void comp(unsigned char *dst, int dst_stride, unsigned char *src, int src_stride, int add)
void avcodec_get_frame_defaults(AVFrame *pic)
Set the fields of the given AVFrame to default values.
int8_t sb_int8_array[2][30][64]
#define SB_DITHERING_NOISE(sb, noise_idx)
static void qdm2_calculate_fft(QDM2Context *q, int channel, int sub_packet)
static const uint8_t vlc_tab_fft_tone_offset_3_huffbits[35]
static void process_synthesis_subpackets(QDM2Context *q, QDM2SubPNode *list)
av_cold int ff_rdft_init(RDFTContext *s, int nbits, enum RDFTransformType trans)
Set up a real FFT.
static const uint16_t fft_level_exp_huffcodes[20]
static av_cold void init_noise_samples(void)
int nb_samples
number of audio samples (per channel) described by this frame
static uint8_t empty_buffer[FF_INPUT_BUFFER_PADDING_SIZE]
#define BITS_LEFT(length, gb)