• Home
  • Raw
  • Download

Lines Matching +full:test +full:- +full:docs +full:- +full:mr

4  *      Copyright (c) 1999-2000 Mark Taylor
5 * Copyright (c) 2001-2002 Naoki Shibata
6 * Copyright (c) 2000-2003 Takehiro Tominaga
7 * Copyright (c) 2000-2012 Robert Hegemann
8 * Copyright (c) 2000-2005 Gabriel Bouvigne
9 * Copyright (c) 2000-2005 Alexander Leidinger
23 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 * Boston, MA 02111-1307, USA.
55 barks: a non-linear frequency scale. Mapping from frequency to
67 band is about .34 barks wide. There are about 2-5
91 s3(bark(i)-bark(j))*strength(i)
106 masking(j) = sum_over_i s3(i-j)*strength(i) = s3 o strength
128 Other data computed by the psy-model:
130 ms_ratio side-channel / mid-channel masking ratio (for previous granule)
131 ms_ratio_next side-channel / mid-channel masking ratio for this granule
133 percep_entropy[2] L and R values (prev granule) of PE - A measure of how
134 much pre-echo is in the previous granule
156 #include "lame-analysis.h"
200 jd - 2001 mar 12
201 in: energy - BLKSIZE/2 elements of frequency magnitudes ^ 2
202 gfp - uses out_samplerate, ATHtype (also needed for ATHformula)
206 values +32767 or -32768 should return values that approach 3.
237 * i>=9 || i<=-9
240 * log10(m2/m1)>=9/16 || log10(m2/m1)<=-9/16
242 * m2/m1 >= 10^(9/16) || m2/m1<=10^(-9/16) which are comparisons to constants
247 #define I2LIMIT 23 /* as in if(i>24) -> changed 23 */
264 1.0 /*pow(10, -0) */ ,
265 0.79433 /*pow(10, -0.1) */ ,
266 0.63096 /*pow(10, -0.2) */ ,
267 0.63096 /*pow(10, -0.2) */ ,
268 0.63096 /*pow(10, -0.2) */ ,
269 0.63096 /*pow(10, -0.2) */ ,
270 0.63096 /*pow(10, -0.2) */ ,
271 0.25119 /*pow(10, -0.6) */ ,
272 0.11749 /*pow(10, -0.93) */
275 static const int tab_mask_add_delta[] = { 2, 2, 2, 1, 1, 1, 0, 0, -1 };
294 assert(fabs(ma_max_i1 - _ma_max_i1) <= FLT_EPSILON); in init_mask_add_max_values()
295 assert(fabs(ma_max_i2 - _ma_max_i2) <= FLT_EPSILON); in init_mask_add_max_values()
296 assert(fabs(ma_max_m - _ma_max_m ) <= FLT_EPSILON); in init_mask_add_max_values()
365 int sb, b, n = gd->n_sb; in convert_partition2scalefac()
368 int const bo_sb = gd->bo[sb]; in convert_partition2scalefac()
369 int const npart = gd->npart; in convert_partition2scalefac()
387 /* at transition sfb -> sfb+1 */ in convert_partition2scalefac()
388 FLOAT const w_curr = gd->bo_weight[sb]; in convert_partition2scalefac()
389 FLOAT const w_next = 1.0f - w_curr; in convert_partition2scalefac()
409 PsyStateVar_t *const psv = &gfc->sv_psy; in convert_partition2scalefac_s()
410 PsyConst_CB2SB_t const *const gds = &gfc->cd_psy->s; in convert_partition2scalefac_s()
415 psv->en[chn].s[sb][sblock] = enn[sb]; in convert_partition2scalefac_s()
416 psv->thm[chn].s[sb][sblock] = thm[sb]; in convert_partition2scalefac_s()
424 PsyStateVar_t *const psv = &gfc->sv_psy; in convert_partition2scalefac_l()
425 PsyConst_CB2SB_t const *const gdl = &gfc->cd_psy->l; in convert_partition2scalefac_l()
426 FLOAT *enn = &psv->en[chn].l[0]; in convert_partition2scalefac_l()
427 FLOAT *thm = &psv->thm[chn].l[0]; in convert_partition2scalefac_l()
435 PsyStateVar_t *const psv = &gfc->sv_psy; in convert_partition2scalefac_l_to_s()
436 PsyConst_CB2SB_t const *const gds = &gfc->cd_psy->l_to_s; in convert_partition2scalefac_l_to_s()
445 psv->en[chn].s[sb][sblock] = tmp_enn; in convert_partition2scalefac_l_to_s()
446 psv->thm[chn].s[sb][sblock] = tmp_thm; in convert_partition2scalefac_l_to_s()
456 /* was pow((x),(r))*pow((y),1-(r)) */ in NS_INTERP()
469 pecalc_s(III_psy_ratio const *mr, FLOAT masking_lower) in pecalc_s() argument
490 for (sb = 0; sb < SBMAX_s - 1; sb++) { in pecalc_s()
492 FLOAT const thm = mr->thm.s[sb][sblock]; in pecalc_s()
496 FLOAT const en = mr->en.s[sb][sblock]; in pecalc_s()
514 pecalc_l(III_psy_ratio const *mr, FLOAT masking_lower) in pecalc_l() argument
544 for (sb = 0; sb < SBMAX_l - 1; sb++) { in pecalc_l()
545 FLOAT const thm = mr->thm.l[sb]; in pecalc_l()
549 FLOAT const en = mr->en.l[sb]; in pecalc_l()
571 for (b = j = 0; b < l->npart; ++b) { in calc_energy()
574 for (i = 0; i < l->numlines[b]; ++i, ++j) { in calc_energy()
583 avg[b] = ebb * l->rnumlines[b]; in calc_energy()
584 assert(l->rnumlines[b] >= 0); in calc_energy()
597 PsyConst_CB2SB_t const *const gdl = &gfc->cd_psy->l; in calc_mask_index_l()
600 int const last_tab_entry = sizeof(tab) / sizeof(tab[0]) - 1; in calc_mask_index_l()
608 assert((gdl->numlines[b] + gdl->numlines[b + 1] - 1) > 0); in calc_mask_index_l()
609 a = 20.0f * (m * 2.0f - a) in calc_mask_index_l()
610 / (a * (gdl->numlines[b] + gdl->numlines[b + 1] - 1)); in calc_mask_index_l()
620 for (b = 1; b < gdl->npart - 1; b++) { in calc_mask_index_l()
621 a = avg[b - 1] + avg[b] + avg[b + 1]; in calc_mask_index_l()
624 m = max[b - 1]; in calc_mask_index_l()
629 assert((gdl->numlines[b - 1] + gdl->numlines[b] + gdl->numlines[b + 1] - 1) > 0); in calc_mask_index_l()
630 a = 20.0f * (m * 3.0f - a) in calc_mask_index_l()
631 / (a * (gdl->numlines[b - 1] + gdl->numlines[b] + gdl->numlines[b + 1] - 1)); in calc_mask_index_l()
642 assert(b == gdl->npart - 1); in calc_mask_index_l()
644 a = avg[b - 1] + avg[b]; in calc_mask_index_l()
647 m = max[b - 1]; in calc_mask_index_l()
650 assert((gdl->numlines[b - 1] + gdl->numlines[b] - 1) > 0); in calc_mask_index_l()
651 a = 20.0f * (m * 2.0f - a) in calc_mask_index_l()
652 / (a * (gdl->numlines[b - 1] + gdl->numlines[b] - 1)); in calc_mask_index_l()
661 assert(b == (gdl->npart - 1)); in calc_mask_index_l()
669 SessionConfig_t const *const cfg = &gfc->cfg; in vbrpsy_compute_fft_l()
670 PsyStateVar_t *psv = &gfc->sv_psy; in vbrpsy_compute_fft_l()
671 plotting_data *plt = cfg->analysis ? gfc->pinfo : 0; in vbrpsy_compute_fft_l()
680 for (j = BLKSIZE - 1; j >= 0; --j) { in vbrpsy_compute_fft_l()
684 wsamp_l[1][j] = (l - r) * sqrt2_half; in vbrpsy_compute_fft_l()
694 for (j = BLKSIZE / 2 - 1; j >= 0; --j) { in vbrpsy_compute_fft_l()
695 FLOAT const re = (*wsamp_l)[BLKSIZE / 2 - j]; in vbrpsy_compute_fft_l()
697 fftenergy[BLKSIZE / 2 - j] = (re * re + im * im) * 0.5f; in vbrpsy_compute_fft_l()
705 psv->tot_ener[chn] = totalenergy; in vbrpsy_compute_fft_l()
710 plt->energy[gr_out][chn][j] = plt->energy_save[chn][j]; in vbrpsy_compute_fft_l()
711 plt->energy_save[chn][j] = fftenergy[j]; in vbrpsy_compute_fft_l()
729 for (j = BLKSIZE_s - 1; j >= 0; --j) { in vbrpsy_compute_fft_s()
733 wsamp_s[1][sblock][j] = (l - r) * sqrt2_half; in vbrpsy_compute_fft_s()
742 for (j = BLKSIZE_s / 2 - 1; j >= 0; --j) { in vbrpsy_compute_fft_s()
743 FLOAT const re = (*wsamp_s)[sblock][BLKSIZE_s / 2 - j]; in vbrpsy_compute_fft_s()
745 fftenergy_s[sblock][BLKSIZE_s / 2 - j] = (re * re + im * im) * 0.5f; in vbrpsy_compute_fft_s()
751 * compute loudness approximation (used for ATH auto-level adjustment)
757 PsyStateVar_t *psv = &gfc->sv_psy; in vbrpsy_compute_loudness_approximation_l()
759 gfc->ov_psy.loudness_sq[gr_out][chn] = psv->loudness_sq_save[chn]; in vbrpsy_compute_loudness_approximation_l()
760 psv->loudness_sq_save[chn] = psycho_loudness_approx(fftenergy, gfc->ATH->eql_w); in vbrpsy_compute_loudness_approximation_l()
776 SessionConfig_t const *const cfg = &gfc->cfg; in vbrpsy_attack_detection()
777 PsyStateVar_t *const psv = &gfc->sv_psy; in vbrpsy_attack_detection()
778 plotting_data *plt = cfg->analysis ? gfc->pinfo : 0; in vbrpsy_attack_detection()
779 int const n_chn_out = cfg->channels_out; in vbrpsy_attack_detection()
781 int const n_chn_psy = (cfg->mode == JOINT_STEREO) ? 4 : n_chn_out; in vbrpsy_attack_detection()
789 -8.65163e-18 * 2, -0.00851586 * 2, -6.74764e-18 * 2, 0.0209036 * 2, in vbrpsy_attack_detection()
790 -3.36639e-17 * 2, -0.0438162 * 2, -1.54175e-17 * 2, 0.0931738 * 2, in vbrpsy_attack_detection()
791 -5.52212e-17 * 2, -0.313819 * 2 in vbrpsy_attack_detection()
794 const sample_t *const firbuf = &buffer[chn][576 - 350 - NSFIRLEN + 192]; in vbrpsy_attack_detection()
795 assert(dimension_of(fircoef) == ((NSFIRLEN - 1) / 2)); in vbrpsy_attack_detection()
800 for (j = 0; j < ((NSFIRLEN - 1) / 2) - 1; j += 2) { in vbrpsy_attack_detection()
801 sum1 += fircoef[j] * (firbuf[i + j] + firbuf[i + NSFIRLEN - j]); in vbrpsy_attack_detection()
802 sum2 += fircoef[j + 1] * (firbuf[i + j + 1] + firbuf[i + NSFIRLEN - j - 1]); in vbrpsy_attack_detection()
806 masking_ratio[gr_out][chn].en = psv->en[chn]; in vbrpsy_attack_detection()
807 masking_ratio[gr_out][chn].thm = psv->thm[chn]; in vbrpsy_attack_detection()
810 /*percep_MS_entropy [chn-2] = gfc -> pe [chn]; */ in vbrpsy_attack_detection()
811 masking_MS_ratio[gr_out][chn].en = psv->en[chn + 2]; in vbrpsy_attack_detection()
812 masking_MS_ratio[gr_out][chn].thm = psv->thm[chn + 2]; in vbrpsy_attack_detection()
823 for (i = 0, j = 576; j > 0; ++i, --j) { in vbrpsy_attack_detection()
827 ns_hpfsmpl[1][i] = l - r; in vbrpsy_attack_detection()
833 /* calculate energies of each sub-shortblocks */ in vbrpsy_attack_detection()
835 en_subshort[i] = psv->last_en_subshort[chn][i + 6]; in vbrpsy_attack_detection()
836 assert(psv->last_en_subshort[chn][i + 4] > 0); in vbrpsy_attack_detection()
837 attack_intensity[i] = en_subshort[i] / psv->last_en_subshort[chn][i + 4]; in vbrpsy_attack_detection()
847 psv->last_en_subshort[chn][i] = en_subshort[i + 3] = p; in vbrpsy_attack_detection()
849 if (p > en_subshort[i + 3 - 2]) { in vbrpsy_attack_detection()
850 assert(en_subshort[i + 3 - 2] > 0); in vbrpsy_attack_detection()
851 p = p / en_subshort[i + 3 - 2]; in vbrpsy_attack_detection()
853 else if (en_subshort[i + 3 - 2] > p * 10.0f) { in vbrpsy_attack_detection()
855 p = en_subshort[i + 3 - 2] / (p * 10.0f); in vbrpsy_attack_detection()
884 plt->ers[gr_out][chn] = plt->ers_save[chn]; in vbrpsy_attack_detection()
885 plt->ers_save[chn] = x; in vbrpsy_attack_detection()
888 /* compare energies between sub-shortblocks */ in vbrpsy_attack_detection()
890 FLOAT x = gfc->cd_psy->attack_threshold[chn]; in vbrpsy_attack_detection()
900 /* Good samples to show the effect are Trumpet test songs */ in vbrpsy_attack_detection()
901 /* GB: tuned (1) to avoid too many short blocks for test sample TRUMPET */ in vbrpsy_attack_detection()
902 /* RH: tuned (2) to let enough short blocks through for test sample FSOL and SNAPS */ in vbrpsy_attack_detection()
904 FLOAT const u = en_short[i - 1]; in vbrpsy_attack_detection()
917 if (ns_attacks[chn][0] <= psv->last_attacks[chn]) { in vbrpsy_attack_detection()
921 if (psv->last_attacks[chn] == 3 || in vbrpsy_attack_detection()
948 energy[chn] = psv->tot_ener[chn]; in vbrpsy_attack_detection()
957 FLOAT *nbs2 = &gfc->sv_psy.nb_s2[chn][0]; in vbrpsy_skip_masking_s()
958 FLOAT *nbs1 = &gfc->sv_psy.nb_s1[chn][0]; in vbrpsy_skip_masking_s()
959 int const n = gfc->cd_psy->s.npart; in vbrpsy_skip_masking_s()
972 PsyConst_CB2SB_t const *const gds = &gfc->cd_psy->s; in vbrpsy_calc_mask_index_s()
975 int const last_tab_entry = dimension_of(tab) - 1; in vbrpsy_calc_mask_index_s()
983 assert((gds->numlines[b] + gds->numlines[b + 1] - 1) > 0); in vbrpsy_calc_mask_index_s()
984 a = 20.0f * (m * 2.0f - a) in vbrpsy_calc_mask_index_s()
985 / (a * (gds->numlines[b] + gds->numlines[b + 1] - 1)); in vbrpsy_calc_mask_index_s()
995 for (b = 1; b < gds->npart - 1; b++) { in vbrpsy_calc_mask_index_s()
996 a = avg[b - 1] + avg[b] + avg[b + 1]; in vbrpsy_calc_mask_index_s()
997 assert(b + 1 < gds->npart); in vbrpsy_calc_mask_index_s()
1000 m = max[b - 1]; in vbrpsy_calc_mask_index_s()
1005 assert((gds->numlines[b - 1] + gds->numlines[b] + gds->numlines[b + 1] - 1) > 0); in vbrpsy_calc_mask_index_s()
1006 a = 20.0f * (m * 3.0f - a) in vbrpsy_calc_mask_index_s()
1007 / (a * (gds->numlines[b - 1] + gds->numlines[b] + gds->numlines[b + 1] - 1)); in vbrpsy_calc_mask_index_s()
1018 assert(b == gds->npart - 1); in vbrpsy_calc_mask_index_s()
1020 a = avg[b - 1] + avg[b]; in vbrpsy_calc_mask_index_s()
1023 m = max[b - 1]; in vbrpsy_calc_mask_index_s()
1026 assert((gds->numlines[b - 1] + gds->numlines[b] - 1) > 0); in vbrpsy_calc_mask_index_s()
1027 a = 20.0f * (m * 2.0f - a) in vbrpsy_calc_mask_index_s()
1028 / (a * (gds->numlines[b - 1] + gds->numlines[b] - 1)); in vbrpsy_calc_mask_index_s()
1037 assert(b == (gds->npart - 1)); in vbrpsy_calc_mask_index_s()
1045 PsyStateVar_t *const psv = &gfc->sv_psy; in vbrpsy_compute_masking_s()
1046 PsyConst_CB2SB_t const *const gds = &gfc->cd_psy->s; in vbrpsy_compute_masking_s()
1054 for (b = j = 0; b < gds->npart; ++b) { in vbrpsy_compute_masking_s()
1056 int const n = gds->numlines[b]; in vbrpsy_compute_masking_s()
1067 avg[b] = ebb * gds->rnumlines[b]; in vbrpsy_compute_masking_s()
1070 assert(b == gds->npart); in vbrpsy_compute_masking_s()
1073 for (j = b = 0; b < gds->npart; b++) { in vbrpsy_compute_masking_s()
1074 int kk = gds->s3ind[b][0]; in vbrpsy_compute_masking_s()
1075 int const last = gds->s3ind[b][1]; in vbrpsy_compute_masking_s()
1079 FLOAT const masking_lower = gds->masking_lower[b] * gfc->sv_qnt.masking_lower; in vbrpsy_compute_masking_s()
1083 ecb = gds->s3[j] * eb[kk] * tab[mask_idx_s[kk]]; in vbrpsy_compute_masking_s()
1088 x = gds->s3[j] * eb[kk] * tab[mask_idx_s[kk]]; in vbrpsy_compute_masking_s()
1089 ecb = vbrpsy_mask_add(ecb, x, kk - b, delta); in vbrpsy_compute_masking_s()
1096 if (psv->blocktype_old[chn & 0x01] == SHORT_TYPE) { in vbrpsy_compute_masking_s()
1098 FLOAT const t1 = rpelev_s * psv->nb_s1[chn][b]; in vbrpsy_compute_masking_s()
1099 FLOAT const t2 = rpelev2_s * psv->nb_s2[chn][b]; in vbrpsy_compute_masking_s()
1105 FLOAT const t1 = rpelev_s * psv->nb_s1[chn][b]; in vbrpsy_compute_masking_s()
1111 psv->nb_s2[chn][b] = psv->nb_s1[chn][b]; in vbrpsy_compute_masking_s()
1112 psv->nb_s1[chn][b] = ecb; in vbrpsy_compute_masking_s()
1119 x *= gds->minval[b]; in vbrpsy_compute_masking_s()
1148 PsyStateVar_t *const psv = &gfc->sv_psy; in vbrpsy_compute_masking_l()
1149 PsyConst_CB2SB_t const *const gdl = &gfc->cd_psy->l; in vbrpsy_compute_masking_l()
1165 for (b = 0; b < gdl->npart; b++) { in vbrpsy_compute_masking_l()
1167 FLOAT const masking_lower = gdl->masking_lower[b] * gfc->sv_qnt.masking_lower; in vbrpsy_compute_masking_l()
1169 int kk = gdl->s3ind[b][0]; in vbrpsy_compute_masking_l()
1170 int const last = gdl->s3ind[b][1]; in vbrpsy_compute_masking_l()
1176 ecb = gdl->s3[k] * eb_l[kk] * tab[mask_idx_l[kk]]; in vbrpsy_compute_masking_l()
1181 x = gdl->s3[k] * eb_l[kk] * tab[mask_idx_l[kk]]; in vbrpsy_compute_masking_l()
1182 t = vbrpsy_mask_add(ecb, x, kk - b, delta); in vbrpsy_compute_masking_l()
1197 /**** long block pre-echo control ****/ in vbrpsy_compute_masking_l()
1198 /* dont use long block pre-echo control if previous granule was in vbrpsy_compute_masking_l()
1202 * frame2: regular frame. looks like pre-echo when compared to in vbrpsy_compute_masking_l()
1203 * frame0, but all pre-echo was in frame1. in vbrpsy_compute_masking_l()
1208 if (psv->blocktype_old[chn & 0x01] == SHORT_TYPE) { in vbrpsy_compute_masking_l()
1209 FLOAT const ecb_limit = rpelev * psv->nb_l1[chn][b]; in vbrpsy_compute_masking_l()
1226 FLOAT ecb_limit_2 = rpelev2 * psv->nb_l2[chn][b]; in vbrpsy_compute_masking_l()
1227 FLOAT ecb_limit_1 = rpelev * psv->nb_l1[chn][b]; in vbrpsy_compute_masking_l()
1235 if (psv->blocktype_old[chn & 0x01] == NORM_TYPE) { in vbrpsy_compute_masking_l()
1243 psv->nb_l2[chn][b] = psv->nb_l1[chn][b]; in vbrpsy_compute_masking_l()
1244 psv->nb_l1[chn][b] = ecb; in vbrpsy_compute_masking_l()
1251 x *= gdl->minval[b]; in vbrpsy_compute_masking_l()
1280 if (cfg->short_blocks == short_block_coupled in vbrpsy_compute_block_type()
1287 for (chn = 0; chn < cfg->channels_out; chn++) { in vbrpsy_compute_block_type()
1289 if (cfg->short_blocks == short_block_dispensed) { in vbrpsy_compute_block_type()
1292 if (cfg->short_blocks == short_block_forced) { in vbrpsy_compute_block_type()
1312 assert(psv->blocktype_old[chn] != START_TYPE); in vbrpsy_apply_block_type()
1313 if (psv->blocktype_old[chn] == SHORT_TYPE) in vbrpsy_apply_block_type()
1319 if (psv->blocktype_old[chn] == NORM_TYPE) { in vbrpsy_apply_block_type()
1320 psv->blocktype_old[chn] = START_TYPE; in vbrpsy_apply_block_type()
1322 if (psv->blocktype_old[chn] == STOP_TYPE) in vbrpsy_apply_block_type()
1323 psv->blocktype_old[chn] = SHORT_TYPE; in vbrpsy_apply_block_type()
1326 blocktype_d[chn] = psv->blocktype_old[chn]; /* value returned to calling program */ in vbrpsy_apply_block_type()
1327 psv->blocktype_old[chn] = blocktype; /* save for next call to l3psy_anal */ in vbrpsy_apply_block_type()
1402 * NOTE: the bitrate reduction from the inter-channel masking effect is low
1415 SessionConfig_t const *const cfg = &gfc->cfg; in L3psycho_anal_vbr()
1416 PsyStateVar_t *const psv = &gfc->sv_psy; in L3psycho_anal_vbr()
1417 PsyConst_CB2SB_t const *const gdl = &gfc->cd_psy->l; in L3psycho_anal_vbr()
1418 PsyConst_CB2SB_t const *const gds = &gfc->cd_psy->s; in L3psycho_anal_vbr()
1419 plotting_data *plt = cfg->analysis ? gfc->pinfo : 0; in L3psycho_anal_vbr()
1436 (cfg->msfix > 0.f) ? (cfg->ATH_offset_factor * gfc->ATH->adjust_factor) : 1.f; in L3psycho_anal_vbr()
1449 int const n_chn_psy = (cfg->mode == JOINT_STEREO) ? 4 : cfg->channels_out; in L3psycho_anal_vbr()
1451 memcpy(&last_thm[0], &psv->thm[0], sizeof(last_thm)); in L3psycho_anal_vbr()
1468 if (cfg->mode == JOINT_STEREO) { in L3psycho_anal_vbr()
1470 vbrpsy_compute_MS_thresholds(const_eb, thr, gdl->mld_cb, gfc->ATH->cb_l, in L3psycho_anal_vbr()
1471 ath_factor, cfg->msfix, gdl->npart); in L3psycho_anal_vbr()
1482 int const force_short_block_calc = gfc->cd_psy->force_short_block_calc; in L3psycho_anal_vbr()
1497 if (cfg->mode == JOINT_STEREO) { in L3psycho_anal_vbr()
1499 vbrpsy_compute_MS_thresholds(const_eb, thr, gds->mld_cb, gfc->ATH->cb_s, in L3psycho_anal_vbr()
1500 ath_factor, cfg->msfix, gds->npart); in L3psycho_anal_vbr()
1512 /**** short block pre-echo control ****/ in L3psycho_anal_vbr()
1517 thmm = psv->thm[chn].s[sb][sblock]; in L3psycho_anal_vbr()
1523 prev_thm = new_thmm[sblock - 1]; in L3psycho_anal_vbr()
1535 else if ((sblock == 0 && psv->last_attacks[chn] == 3) in L3psycho_anal_vbr()
1536 … || (sblock > 0 && ns_attacks[chn][sblock - 1] == 3)) { /* 2nd preceeding block */ in L3psycho_anal_vbr()
1560 psv->thm[chn].s[sb][sblock] = new_thmm[sblock]; in L3psycho_anal_vbr()
1566 psv->last_attacks[chn] = ns_attacks[chn][2]; in L3psycho_anal_vbr()
1573 vbrpsy_apply_block_type(psv, cfg->channels_out, uselongblock, blocktype_d); in L3psycho_anal_vbr()
1581 III_psy_ratio const *mr; in L3psycho_anal_vbr() local
1584 ppe = percep_MS_entropy - 2; in L3psycho_anal_vbr()
1588 mr = &masking_MS_ratio[gr_out][chn - 2]; in L3psycho_anal_vbr()
1593 mr = &masking_ratio[gr_out][chn]; in L3psycho_anal_vbr()
1596 ppe[chn] = pecalc_s(mr, gfc->sv_qnt.masking_lower); in L3psycho_anal_vbr()
1599 ppe[chn] = pecalc_l(mr, gfc->sv_qnt.masking_lower); in L3psycho_anal_vbr()
1603 plt->pe[gr_out][chn] = ppe[chn]; in L3psycho_anal_vbr()
1626 temp = tempx - 0.5; in s3_func()
1627 x = 8.0 * (temp * temp - 2.0 * temp); in s3_func()
1632 tempy = 15.811389 + 7.5 * tempx - 17.5 * sqrt(1.0 + tempx * tempx); in s3_func()
1634 if (tempy <= -60.0) in s3_func()
1644 -inf in s3_func()
1656 for (x = 0; s3_func(x) > 1e-20; x -= 1);
1659 while (fabs(h - l) > 1e-12) {
1669 for (x = 0; s3_func(x) > 1e-20; x += 1);
1672 while (fabs(h - l) > 1e-12) {
1687 double x = lim_a + i * (lim_b - lim_a) / m;
1692 double norm = (m + 1) / (sum * (lim_b - lim_a));
1708 return pow(10.0, 1.25 * (1 - cos(PI * arg)) - 2.5); in stereo_demask()
1733 for (j2 = j; freq2bark(sfreq * j2) - bark1 < DELBARK && j2 <= fft_size / 2; j2++); in init_numline()
1735 nl = j2 - j; in init_numline()
1736 gd->numlines[i] = nl; in init_numline()
1737 gd->rnumlines[i] = (nl > 0) ? (1.0f / nl) : 0; in init_numline()
1754 gd->n_sb = sbmax; in init_numline()
1755 gd->npart = ni; in init_numline()
1759 for (i = 0; i < gd->npart; i++) { in init_numline()
1760 int const nl = gd->numlines[i]; in init_numline()
1762 gd->mld_cb[i] = stereo_demask(freq); in init_numline()
1766 gd->mld_cb[i] = 1; in init_numline()
1774 i1 = floor(.5 + deltafreq * (start - .5)); in init_numline()
1777 i2 = floor(.5 + deltafreq * (end - .5)); in init_numline()
1783 gd->bm[sfb] = (partition[i1] + partition[i2]) / 2; in init_numline()
1784 gd->bo[sfb] = bo; in init_numline()
1789 FLOAT bo_w = (f_tmp - b_frq[bo]) / (b_frq[bo + 1] - b_frq[bo]); in init_numline()
1798 gd->bo_weight[sfb] = bo_w; in init_numline()
1800 gd->mld[sfb] = stereo_demask(mdct_freq_frac * start); in init_numline()
1809 int k, j = 0, ni = gd->npart; in compute_bark_values()
1812 int const w = gd->numlines[k]; in compute_bark_values()
1816 bark2 = freq2bark(sfreq * (j + w - 1)); in compute_bark_values()
1819 bark1 = freq2bark(sfreq * (j - .5)); in compute_bark_values()
1820 bark2 = freq2bark(sfreq * (j + w - .5)); in compute_bark_values()
1821 bval_width[k] = bark2 - bark1; in compute_bark_values()
1843 * NOTE: i and j are used opposite as in the ISO docs in init_s3_values()
1847 FLOAT v = s3_func(bval[i] - bval[j]) * bval_width[j]; in init_s3_values()
1858 for (j = npart - 1; j > 0; j--) { in init_s3_values()
1863 numberOfNoneZero += (s3ind[i][1] - s3ind[i][0] + 1); in init_s3_values()
1867 return -1; in init_s3_values()
1880 lame_internal_flags *const gfc = gfp->internal_flags; in psymodel_init()
1881 SessionConfig_t *const cfg = &gfc->cfg; in psymodel_init()
1882 PsyStateVar_t *const psv = &gfc->sv_psy; in psymodel_init()
1887 FLOAT snr_s_a = -8.25, snr_s_b = -4.5; in psymodel_init()
1892 FLOAT const sfreq = cfg->samplerate_out; in psymodel_init()
1895 FLOAT const minval_low = (0.f - cfg->minval); in psymodel_init()
1897 if (gfc->cd_psy != 0) { in psymodel_init()
1903 gfc->cd_psy = gd; in psymodel_init()
1905 gd->force_short_block_calc = gfp->experimentalZ; in psymodel_init()
1907 psv->blocktype_old[0] = psv->blocktype_old[1] = NORM_TYPE; /* the vbr header is long blocks */ in psymodel_init()
1911 psv->nb_l1[i][j] = 1e20; in psymodel_init()
1912 psv->nb_l2[i][j] = 1e20; in psymodel_init()
1913 psv->nb_s1[i][j] = psv->nb_s2[i][j] = 1.0; in psymodel_init()
1916 psv->en[i].l[sb] = 1e20; in psymodel_init()
1917 psv->thm[i].l[sb] = 1e20; in psymodel_init()
1921 psv->en[i].s[sb][j] = 1e20; in psymodel_init()
1922 psv->thm[i].s[sb][j] = 1e20; in psymodel_init()
1924 psv->last_attacks[i] = 0; in psymodel_init()
1927 psv->last_en_subshort[i][j] = 10.; in psymodel_init()
1931 /* init. for loudness approx. -jd 2001 mar 27 */ in psymodel_init()
1932 psv->loudness_sq_save[0] = psv->loudness_sq_save[1] = 0.0; in psymodel_init()
1940 init_numline(&gd->l, sfreq, BLKSIZE, 576, SBMAX_l, gfc->scalefac_band.l); in psymodel_init()
1941 assert(gd->l.npart < CBANDS); in psymodel_init()
1942 compute_bark_values(&gd->l, sfreq, BLKSIZE, bval, bval_width); in psymodel_init()
1945 for (i = 0; i < gd->l.npart; i++) { in psymodel_init()
1948 snr = snr_l_b * (bval[i] - bvl_a) / (bvl_b - bvl_a) in psymodel_init()
1949 + snr_l_a * (bvl_b - bval[i]) / (bvl_b - bvl_a); in psymodel_init()
1953 i = init_s3_values(&gd->l.s3, gd->l.s3ind, gd->l.npart, bval, bval_width, norm); in psymodel_init()
1959 for (i = 0; i < gd->l.npart; i++) { in psymodel_init()
1964 for (k = 0; k < gd->l.numlines[i]; k++, j++) { in psymodel_init()
1968 … level = ATHformula(cfg, freq * 1000) - 20; /* scale to FFT units; returned value is in dB */ in psymodel_init()
1969 level = pow(10., 0.1 * level); /* convert from dB -> energy */ in psymodel_init()
1970 level *= gd->l.numlines[i]; in psymodel_init()
1974 gfc->ATH->cb_l[i] = x; in psymodel_init()
1979 /* FIXME: it does work to reduce low-freq problems in S53-Wind-Sax in psymodel_init()
1980 and lead-voice samples, but introduces some 3 kbps bit bloat too. in psymodel_init()
1983 x = 20.0 * (bval[i] / xav - 1.0); in psymodel_init()
1990 if (cfg->samplerate_out < 44000) { in psymodel_init()
1993 x -= 8.; in psymodel_init()
1994 gd->l.minval[i] = pow(10.0, x / 10.) * gd->l.numlines[i]; in psymodel_init()
2000 init_numline(&gd->s, sfreq, BLKSIZE_s, 192, SBMAX_s, gfc->scalefac_band.s); in psymodel_init()
2001 assert(gd->s.npart < CBANDS); in psymodel_init()
2002 compute_bark_values(&gd->s, sfreq, BLKSIZE_s, bval, bval_width); in psymodel_init()
2006 for (i = 0; i < gd->s.npart; i++) { in psymodel_init()
2010 snr = snr_s_b * (bval[i] - bvl_a) / (bvl_b - bvl_a) in psymodel_init()
2011 + snr_s_a * (bvl_b - bval[i]) / (bvl_b - bvl_a); in psymodel_init()
2017 for (k = 0; k < gd->s.numlines[i]; k++, j++) { in psymodel_init()
2021 … level = ATHformula(cfg, freq * 1000) - 20; /* scale to FFT units; returned value is in dB */ in psymodel_init()
2022 level = pow(10., 0.1 * level); /* convert from dB -> energy */ in psymodel_init()
2023 level *= gd->s.numlines[i]; in psymodel_init()
2027 gfc->ATH->cb_s[i] = x; in psymodel_init()
2032 x = 7.0 * (bval[i] / xbv - 1.0); in psymodel_init()
2037 x *= 1 + log(1 - x) * 2.3; in psymodel_init()
2045 if (cfg->samplerate_out < 44000) { in psymodel_init()
2048 x -= 8; in psymodel_init()
2049 gd->s.minval[i] = pow(10.0, x / 10) * gd->s.numlines[i]; in psymodel_init()
2052 i = init_s3_values(&gd->s.s3, gd->s.s3ind, gd->s.npart, bval, bval_width, norm); in psymodel_init()
2061 gd->decay = exp(-1.0 * LOG10 / (temporalmask_sustain_sec * sfreq / 192.0)); in psymodel_init()
2066 if (cfg->use_safe_joint_stereo) in psymodel_init()
2068 if (fabs(cfg->msfix) > 0.0) in psymodel_init()
2069 msfix = cfg->msfix; in psymodel_init()
2070 cfg->msfix = msfix; in psymodel_init()
2075 for (b = 0; b < gd->l.npart; b++) in psymodel_init()
2076 if (gd->l.s3ind[b][1] > gd->l.npart - 1) in psymodel_init()
2077 gd->l.s3ind[b][1] = gd->l.npart - 1; in psymodel_init()
2083 #define frame_duration (576. * cfg->mode_gr / sfreq) in psymodel_init()
2084 gfc->ATH->decay = pow(10., -12. / 10. * frame_duration); in psymodel_init()
2085 gfc->ATH->adjust_factor = 0.01; /* minimum, for leading low loudness */ in psymodel_init()
2086 gfc->ATH->adjust_limit = 1.0; /* on lead, allow adjust up to maximum */ in psymodel_init()
2089 assert(gd->l.bo[SBMAX_l - 1] <= gd->l.npart); in psymodel_init()
2090 assert(gd->s.bo[SBMAX_s - 1] <= gd->s.npart); in psymodel_init()
2092 if (cfg->ATHtype != -1) { in psymodel_init()
2095 FLOAT const freq_inc = (FLOAT) cfg->samplerate_out / (FLOAT) (BLKSIZE); in psymodel_init()
2102 gfc->ATH->eql_w[i] = 1. / pow(10, ATHformula(cfg, freq) / 10); in psymodel_init()
2103 eql_balance += gfc->ATH->eql_w[i]; in psymodel_init()
2106 for (i = BLKSIZE / 2; --i >= 0;) { /* scale weights */ in psymodel_init()
2107 gfc->ATH->eql_w[i] *= eql_balance; in psymodel_init()
2111 for (b = j = 0; b < gd->s.npart; ++b) { in psymodel_init()
2112 for (i = 0; i < gd->s.numlines[b]; ++i) { in psymodel_init()
2117 for (b = j = 0; b < gd->l.npart; ++b) { in psymodel_init()
2118 for (i = 0; i < gd->l.numlines[b]; ++i) { in psymodel_init()
2126 float x = gfp->attackthre; in psymodel_init()
2127 float y = gfp->attackthre_s; in psymodel_init()
2134 gd->attack_threshold[0] = gd->attack_threshold[1] = gd->attack_threshold[2] = x; in psymodel_init()
2135 gd->attack_threshold[3] = y; in psymodel_init()
2138 float sk_s = -10.f, sk_l = -4.7f; in psymodel_init()
2140 { -7.4, -7.4, -7.4, -9.5, -7.4, -6.1, -5.5, -4.7, -4.7, -4.7, -4.7 }; in psymodel_init()
2141 if (gfp->VBR_q < 4) { in psymodel_init()
2145 sk_l = sk_s = sk[gfp->VBR_q] + gfp->VBR_q_frac * (sk[gfp->VBR_q] - sk[gfp->VBR_q + 1]); in psymodel_init()
2148 for (; b < gd->s.npart; b++) { in psymodel_init()
2149 float m = (float) (gd->s.npart - b) / gd->s.npart; in psymodel_init()
2150 gd->s.masking_lower[b] = powf(10.f, sk_s * m * 0.1f); in psymodel_init()
2153 gd->s.masking_lower[b] = 1.f; in psymodel_init()
2156 for (; b < gd->l.npart; b++) { in psymodel_init()
2157 float m = (float) (gd->l.npart - b) / gd->l.npart; in psymodel_init()
2158 gd->l.masking_lower[b] = powf(10.f, sk_l * m * 0.1f); in psymodel_init()
2161 gd->l.masking_lower[b] = 1.f; in psymodel_init()
2164 memcpy(&gd->l_to_s, &gd->l, sizeof(gd->l_to_s)); in psymodel_init()
2165 init_numline(&gd->l_to_s, sfreq, BLKSIZE, 192, SBMAX_s, gfc->scalefac_band.s); in psymodel_init()