Lines Matching refs:sb
71 #define SB_DITHERING_NOISE(sb,noise_idx) (noise_table[(noise_idx)++] * sb_noise_attenuation[(sb)])
344 * @param sb subband index
346 static void build_sb_samples_from_noise(QDM2Context *q, int sb)
357 q->sb_samples[ch][j * 2][sb] =
358 SB_DITHERING_NOISE(sb, q->noise_idx) * q->tone_level[ch][sb][j];
359 q->sb_samples[ch][j * 2 + 1][sb] =
360 SB_DITHERING_NOISE(sb, q->noise_idx) * q->tone_level[ch][sb][j];
369 * @param sb subband index
373 static int fix_coding_method_array(int sb, int channels,
382 if (coding_method[ch][sb][j] < 8)
384 if ((coding_method[ch][sb][j] - 8) > 22) {
388 switch (switchtable[coding_method[ch][sb][j] - 8]) {
414 int sbjk = sb + (j + k) / 64;
419 if (coding_method[ch][sbjk][(j + k) % 64] > coding_method[ch][sb][j]) {
423 memset(&coding_method[ch][sb][j + k], case_val,
425 memset(&coding_method[ch][sb][j + k], case_val,
446 int i, sb, ch, sb_used;
450 for (sb = 0; sb < 30; sb++)
452 if ((tab=coeff_per_sb_for_dequant[q->coeff_per_sb_select][sb]) < (last_coeff[q->coeff_per_sb_select] - 1))
453 tmp = q->quantized_coeffs[ch][tab + 1][i] * dequant_table[q->coeff_per_sb_select][tab + 1][sb]+
454 q->quantized_coeffs[ch][tab][i] * dequant_table[q->coeff_per_sb_select][tab][sb];
456 tmp = q->quantized_coeffs[ch][tab][i] * dequant_table[q->coeff_per_sb_select][tab][sb];
459 q->tone_level_idx_base[ch][sb][i] = (tmp / 256) & 0xff;
465 for (sb = 0; sb < sb_used; sb++)
468 q->tone_level_idx[ch][sb][i] = q->tone_level_idx_base[ch][sb][i / 8];
469 if (q->tone_level_idx[ch][sb][i] < 0)
470 q->tone_level[ch][sb][i] = 0;
472 q->tone_level[ch][sb][i] = fft_tone_level_table[0][q->tone_level_idx[ch][sb][i] & 0x3f];
476 for (sb = 0; sb < sb_used; sb++) {
477 if ((sb >= 4) && (sb <= 23)) {
480 tmp = q->tone_level_idx_base[ch][sb][i / 8] -
481 q->tone_level_idx_hi1[ch][sb / 8][i / 8][i % 8] -
482 q->tone_level_idx_mid[ch][sb - 4][i / 8] -
483 q->tone_level_idx_hi2[ch][sb - 4];
484 q->tone_level_idx[ch][sb][i] = tmp & 0xff;
486 q->tone_level[ch][sb][i] = 0;
488 q->tone_level[ch][sb][i] = fft_tone_level_table[tab][tmp & 0x3f];
491 if (sb > 4) {
494 tmp = q->tone_level_idx_base[ch][sb][i / 8] -
496 q->tone_level_idx_hi2[ch][sb - 4];
497 q->tone_level_idx[ch][sb][i] = tmp & 0xff;
499 q->tone_level[ch][sb][i] = 0;
501 q->tone_level[ch][sb][i] = fft_tone_level_table[tab][tmp & 0x3f];
506 tmp = q->tone_level_idx[ch][sb][i] = q->tone_level_idx_base[ch][sb][i / 8];
508 q->tone_level[ch][sb][i] = 0;
510 q->tone_level[ch][sb][i] = fft_tone_level_table[tab][tmp & 0x3f];
540 int ch, sb, j;
550 for (sb = 0; sb < 30; sb++) {
552 add1 = tone_level_idx[ch][sb][j] - 10;
556 if (sb > 1) {
557 add2 = tone_level_idx[ch][sb - 2][j] + tone_level_idx_offset_table[sb][0] - 6;
561 if (sb > 0) {
562 add3 = tone_level_idx[ch][sb - 1][j] + tone_level_idx_offset_table[sb][1] - 6;
566 if (sb < 29) {
567 add4 = tone_level_idx[ch][sb + 1][j] + tone_level_idx_offset_table[sb][3] - 6;
571 tmp = tone_level_idx[ch][sb][j + 1] * 2 - add4 - add3 - add2 - add1;
574 tone_level_idx_temp[ch][sb][j + 1] = tmp & 0xff;
576 tone_level_idx_temp[ch][sb][0] = tone_level_idx_temp[ch][sb][1];
581 for (sb = 0; sb < 30; sb++)
583 acc += tone_level_idx_temp[ch][sb][j];
588 for (sb = 0; sb < 30; sb++)
590 comp = tone_level_idx_temp[ch][sb][j]* esp_40 * 10;
594 switch(sb) {
621 coding_method[ch][sb][j] = ((tmp & 0xfffa) + 30 )& 0xff;
623 for (sb = 0; sb < 30; sb++)
624 fix_coding_method_array(sb, nb_channels, coding_method);
626 for (sb = 0; sb < 30; sb++)
628 if (sb >= 10) {
629 if (coding_method[ch][sb][j] < 10)
630 coding_method[ch][sb][j] = 10;
632 if (sb >= 2) {
633 if (coding_method[ch][sb][j] < 16)
634 coding_method[ch][sb][j] = 16;
636 if (coding_method[ch][sb][j] < 30)
637 coding_method[ch][sb][j] = 30;
642 for (sb = 0; sb < 30; sb++)
644 coding_method[ch][sb][j] = coding_method_table[cm_table_select][sb];
650 * with sb 0-8.
652 * sb 8-sb_used.
663 int sb, j, k, n, ch, run, channels;
673 for (sb=sb_min; sb < sb_max; sb++)
674 build_sb_samples_from_noise(q, sb);
679 for (sb = sb_min; sb < sb_max; sb++) {
682 if (q->nb_channels <= 1 || sb < 12)
684 else if (sb >= 24)
695 if (q->coding_method[1][sb][j] > q->coding_method[0][sb][j])
696 q->coding_method[0][sb][j] = q->coding_method[1][sb][j];
698 if (fix_coding_method_array(sb, q->nb_channels,
701 build_sb_samples_from_noise(q, sb);
714 switch (q->coding_method[ch][sb][j / 2]) {
734 samples[2 * k + 1] = SB_DITHERING_NOISE(sb,q->noise_idx);
737 samples[k] = SB_DITHERING_NOISE(sb,q->noise_idx);
748 f -= noise_samples[((sb + 1) * (j +5 * ch + 1)) & 127] * 9.0 / 40.0;
751 samples[0] = SB_DITHERING_NOISE(sb,q->noise_idx);
776 samples[k] = SB_DITHERING_NOISE(sb,q->noise_idx);
793 samples[k] = SB_DITHERING_NOISE(sb,q->noise_idx);
807 samples[0] = SB_DITHERING_NOISE(sb,q->noise_idx);
829 samples[0] = SB_DITHERING_NOISE(sb,q->noise_idx);
835 samples[0] = SB_DITHERING_NOISE(sb,q->noise_idx);
842 q->sb_samples[0][j + k][sb] =
843 q->tone_level[0][sb][(j + k) / 2] * samples[k];
846 q->sb_samples[1][j + k][sb] =
847 q->tone_level[1][sb][(j + k) / 2] * -samples[k];
849 q->sb_samples[1][j + k][sb] =
850 q->tone_level[1][sb][(j + k) / 2] * samples[k];
856 q->sb_samples[ch][j + k][sb] = q->tone_level[ch][sb][(j + k)/2] * samples[k];
919 int sb, j, k, n, ch;
932 for (sb = 0; sb < n; sb++)
941 q->tone_level_idx_hi1[ch][sb][j][k] = qdm2_get_vlc(gb, &vlc_tab_tone_level_idx_hi1, 0, 2);
945 q->tone_level_idx_hi1[ch][sb][j][k] = 0;
951 for (sb = 0; sb < n; sb++)
955 q->tone_level_idx_hi2[ch][sb] = qdm2_get_vlc(gb, &vlc_tab_tone_level_idx_hi2, 0, 2);
956 if (sb > 19)
957 q->tone_level_idx_hi2[ch][sb] -= 16;
960 q->tone_level_idx_mid[ch][sb][j] = -16;
965 for (sb = 0; sb < n; sb++)
970 q->tone_level_idx_mid[ch][sb][j] = qdm2_get_vlc(gb, &vlc_tab_tone_level_idx_mid, 0, 2) - 32;