Lines Matching refs:cfg
107 SessionConfig_t *const cfg = &gfc->cfg;
118 if (cfg->lowpass1 > 0) {
123 if (freq >= cfg->lowpass2) {
126 if (cfg->lowpass1 < freq && freq < cfg->lowpass2) {
134 cfg->lowpass1 = (lowpass_band - .75) / 31.0;
137 cfg->lowpass1 = (minband - .75) / 31.0;
139 cfg->lowpass2 = lowpass_band / 31.0;
144 if (cfg->highpass2 > 0) {
145 if (cfg->highpass2 < .9 * (.75 / 31.0)) {
146 cfg->highpass1 = 0;
147 cfg->highpass2 = 0;
152 if (cfg->highpass2 > 0) {
157 if (freq <= cfg->highpass1) {
160 if (cfg->highpass1 < freq && freq < cfg->highpass2) {
166 cfg->highpass1 = highpass_band / 31.0;
168 cfg->highpass2 = (highpass_band + .75) / 31.0;
171 cfg->highpass2 = (maxband + .75) / 31.0;
178 if (cfg->highpass2 > cfg->highpass1) {
179 fc1 = filter_coef((cfg->highpass2 - freq) / (cfg->highpass2 - cfg->highpass1 + 1e-20));
184 if (cfg->lowpass2 > cfg->lowpass1) {
185 fc2 = filter_coef((freq - cfg->lowpass1) / (cfg->lowpass2 - cfg->lowpass1 + 1e-20));
368 SessionConfig_t *const cfg = &gfc->cfg;
373 cfg->noise_shaping = 0;
374 cfg->noise_shaping_amp = 0;
375 cfg->noise_shaping_stop = 0;
376 cfg->use_best_huffman = 0;
377 cfg->full_outer_loop = 0;
384 cfg->noise_shaping = 0;
385 cfg->noise_shaping_amp = 0;
386 cfg->noise_shaping_stop = 0;
387 cfg->use_best_huffman = 0;
388 cfg->full_outer_loop = 0;
389 if (cfg->vbr == vbr_mt || cfg->vbr == vbr_mtrh) {
390 cfg->full_outer_loop = -1;
395 if (cfg->noise_shaping == 0)
396 cfg->noise_shaping = 1;
397 cfg->noise_shaping_amp = 0;
398 cfg->noise_shaping_stop = 0;
399 if (cfg->subblock_gain == -1)
400 cfg->subblock_gain = 1;
401 cfg->use_best_huffman = 0;
402 cfg->full_outer_loop = 0;
406 if (cfg->noise_shaping == 0)
407 cfg->noise_shaping = 1;
408 cfg->noise_shaping_amp = 0;
409 cfg->noise_shaping_stop = 0;
410 if (cfg->subblock_gain == -1)
411 cfg->subblock_gain = 1;
412 cfg->use_best_huffman = 0;
413 cfg->full_outer_loop = 0;
417 if (cfg->noise_shaping == 0)
418 cfg->noise_shaping = 1;
419 cfg->noise_shaping_amp = 0;
420 cfg->noise_shaping_stop = 0;
421 if (cfg->subblock_gain == -1)
422 cfg->subblock_gain = 1;
423 cfg->use_best_huffman = 1;
424 cfg->full_outer_loop = 0;
428 if (cfg->noise_shaping == 0)
429 cfg->noise_shaping = 1;
430 cfg->noise_shaping_amp = 1;
431 cfg->noise_shaping_stop = 1;
432 if (cfg->subblock_gain == -1)
433 cfg->subblock_gain = 1;
434 cfg->use_best_huffman = 1;
435 cfg->full_outer_loop = 0;
439 if (cfg->noise_shaping == 0)
440 cfg->noise_shaping = 1;
443 cfg->noise_shaping_amp = 1;
444 cfg->noise_shaping_stop = 1;
445 if (cfg->subblock_gain == -1)
446 cfg->subblock_gain = 1;
447 cfg->use_best_huffman = 1; /* inner loop */
448 cfg->full_outer_loop = 0;
452 if (cfg->noise_shaping == 0)
453 cfg->noise_shaping = 1;
456 cfg->noise_shaping_amp = 2;
457 cfg->noise_shaping_stop = 1;
458 if (cfg->subblock_gain == -1)
459 cfg->subblock_gain = 1;
460 cfg->use_best_huffman = 1;
461 cfg->full_outer_loop = 0;
465 if (cfg->noise_shaping == 0)
466 cfg->noise_shaping = 1;
469 cfg->noise_shaping_amp = 2;
470 cfg->noise_shaping_stop = 1;
471 if (cfg->subblock_gain == -1)
472 cfg->subblock_gain = 1;
473 cfg->use_best_huffman = 1; /*type 2 disabled because of it slowness,
475 cfg->full_outer_loop = 1;
546 SessionConfig_t *cfg;
572 cfg = &gfc->cfg;
574 cfg->enforce_min_bitrate = gfp->VBR_hard_min;
575 cfg->analysis = gfp->analysis;
576 if (cfg->analysis)
608 cfg->vbr = gfp->VBR;
609 cfg->error_protection = gfp->error_protection;
610 cfg->copyright = gfp->copyright;
611 cfg->original = gfp->original;
612 cfg->extension = gfp->extension;
613 cfg->emphasis = gfp->emphasis;
615 cfg->channels_in = gfp->num_channels;
616 if (cfg->channels_in == 1)
618 cfg->channels_out = (gfp->mode == MONO) ? 1 : 2;
621 cfg->force_ms = gfp->force_ms;
623 if (cfg->vbr == vbr_off && gfp->VBR_mean_bitrate_kbps != 128 && gfp->brate == 0)
626 switch (cfg->vbr) {
637 cfg->free_format = gfp->free_format;
639 if (cfg->vbr == vbr_off && gfp->brate == 0) {
646 if (cfg->vbr == vbr_off && gfp->compression_ratio > 0) {
654 gfp->brate = gfp->samplerate_out * 16 * cfg->channels_out / (1.e3 * gfp->compression_ratio);
657 cfg->samplerate_index = SmpFrqIndex(gfp->samplerate_out, &cfg->version);
658 assert(cfg->samplerate_index >=0);
660 if (!cfg->free_format) /* for non Free Format find the nearest allowed bitrate */
661 gfp->brate = FindNearestBitrate(gfp->brate, cfg->version, gfp->samplerate_out);
679 if (gfp->samplerate_out == 0 && (cfg->vbr == vbr_mt || cfg->vbr == vbr_mtrh)) {
726 switch (cfg->vbr) {
776 if (gfp->mode == MONO && (cfg->vbr == vbr_off || cfg->vbr == vbr_abr))
788 if (cfg->vbr == vbr_mt || cfg->vbr == vbr_mtrh) {
796 if (cfg->vbr == vbr_off) {
797 gfp->compression_ratio = gfp->samplerate_out * 16 * cfg->channels_out / (1.e3 * gfp->brate);
799 if (cfg->vbr == vbr_abr) {
801 gfp->samplerate_out * 16 * cfg->channels_out / (1.e3 * gfp->VBR_mean_bitrate_kbps);
804 cfg->disable_reservoir = gfp->disable_reservoir;
805 cfg->lowpassfreq = gfp->lowpassfreq;
806 cfg->highpassfreq = gfp->highpassfreq;
807 cfg->samplerate_in = gfp->samplerate_in;
808 cfg->samplerate_out = gfp->samplerate_out;
809 cfg->mode_gr = cfg->samplerate_out <= 24000 ? 1 : 2; /* Number of granules per frame */
840 switch (cfg->vbr) {
852 cfg->samplerate_out * 16 * cfg->channels_out / (1.e3 * gfp->VBR_mean_bitrate_kbps);
855 gfp->compression_ratio = cfg->samplerate_out * 16 * cfg->channels_out / (1.e3 * gfp->brate);
868 cfg->mode = gfp->mode;
872 if (cfg->highpassfreq > 0) {
873 cfg->highpass1 = 2. * cfg->highpassfreq;
876 cfg->highpass2 = 2. * (cfg->highpassfreq + gfp->highpasswidth);
878 cfg->highpass2 = (1 + 0.00) * 2. * cfg->highpassfreq;
880 cfg->highpass1 /= cfg->samplerate_out;
881 cfg->highpass2 /= cfg->samplerate_out;
884 cfg->highpass1 = 0;
885 cfg->highpass2 = 0;
888 cfg->lowpass1 = 0;
889 cfg->lowpass2 = 0;
890 if (cfg->lowpassfreq > 0 && cfg->lowpassfreq < (cfg->samplerate_out / 2) ) {
891 cfg->lowpass2 = 2. * cfg->lowpassfreq;
893 cfg->lowpass1 = 2. * (cfg->lowpassfreq - gfp->lowpasswidth);
894 if (cfg->lowpass1 < 0) /* has to be >= 0 */
895 cfg->lowpass1 = 0;
898 cfg->lowpass1 = (1 - 0.00) * 2. * cfg->lowpassfreq;
900 cfg->lowpass1 /= cfg->samplerate_out;
901 cfg->lowpass2 /= cfg->samplerate_out;
916 cfg->samplerate_index = SmpFrqIndex(cfg->samplerate_out, &cfg->version);
917 assert(cfg->samplerate_index >= 0);
919 if (cfg->vbr == vbr_off) {
920 if (cfg->free_format) {
924 gfp->brate = FindNearestBitrate(gfp->brate, cfg->version, cfg->samplerate_out);
925 gfc->ov_enc.bitrate_index = BitrateIndex(gfp->brate, cfg->version, cfg->samplerate_out);
941 j = cfg->samplerate_index + (3 * cfg->version) + 6 * (cfg->samplerate_out < 16000);
963 if (cfg->mode_gr == 2) /* MPEG 1 */
964 cfg->sideinfo_len = (cfg->channels_out == 1) ? 4 + 17 : 4 + 32;
966 cfg->sideinfo_len = (cfg->channels_out == 1) ? 4 + 9 : 4 + 17;
968 if (cfg->error_protection)
969 cfg->sideinfo_len += 2;
975 gfc->sv_enc.pefirbuf[k] = 700 * cfg->mode_gr * cfg->channels_out;
984 switch (cfg->vbr) {
1013 gfc->sv_qnt.sfb21_extra = (cfg->samplerate_out > 44000);
1027 gfc->sv_qnt.sfb21_extra = (cfg->samplerate_out > 44000);
1054 if (cfg->vbr == vbr_off)
1058 gfp->VBR = cfg->vbr;
1076 if (cfg->vbr != vbr_off) { /* choose a min/max bitrate for VBR */
1078 cfg->vbr_min_bitrate_index = 1; /* default: allow 8 kbps (MPEG-2) or 32 kbps (MPEG-1) */
1079 cfg->vbr_max_bitrate_index = 14; /* default: allow 160 kbps (MPEG-2) or 320 kbps (MPEG-1) */
1080 if (cfg->samplerate_out < 16000)
1081 cfg->vbr_max_bitrate_index = 8; /* default: allow 64 kbps (MPEG-2.5) */
1084 FindNearestBitrate(gfp->VBR_min_bitrate_kbps, cfg->version, cfg->samplerate_out);
1085 cfg->vbr_min_bitrate_index =
1086 BitrateIndex(gfp->VBR_min_bitrate_kbps, cfg->version, cfg->samplerate_out);
1087 if (cfg->vbr_min_bitrate_index < 0) {
1092 cfg->vbr_min_bitrate_index = 1;
1097 FindNearestBitrate(gfp->VBR_max_bitrate_kbps, cfg->version, cfg->samplerate_out);
1098 cfg->vbr_max_bitrate_index =
1099 BitrateIndex(gfp->VBR_max_bitrate_kbps, cfg->version, cfg->samplerate_out);
1100 if (cfg->vbr_max_bitrate_index < 0) {
1105 cfg->vbr_max_bitrate_index = cfg->samplerate_out < 16000 ? 8 : 14;
1108 gfp->VBR_min_bitrate_kbps = bitrate_table[cfg->version][cfg->vbr_min_bitrate_index];
1109 gfp->VBR_max_bitrate_kbps = bitrate_table[cfg->version][cfg->vbr_max_bitrate_index];
1111 Min(bitrate_table[cfg->version][cfg->vbr_max_bitrate_index],
1114 Max(bitrate_table[cfg->version][cfg->vbr_min_bitrate_index],
1118 cfg->preset = gfp->preset;
1119 cfg->write_lame_tag = gfp->write_lame_tag;
1121 cfg->noise_shaping = gfp->noise_shaping;
1122 cfg->subblock_gain = gfp->subblock_gain;
1123 cfg->use_best_huffman = gfp->use_best_huffman;
1124 cfg->avg_bitrate = gfp->brate;
1125 cfg->vbr_avg_bitrate_kbps = gfp->VBR_mean_bitrate_kbps;
1126 cfg->compression_ratio = gfp->compression_ratio;
1157 && (cfg->mode == JOINT_STEREO || cfg->mode == STEREO)) {
1161 cfg->short_blocks = gfp->short_blocks;
1188 cfg->interChRatio = gfp->interChRatio;
1189 cfg->msfix = gfp->msfix;
1190 cfg->ATH_offset_db = 0-gfp->ATH_lower_db;
1191 cfg->ATH_offset_factor = powf(10.f, cfg->ATH_offset_db * 0.1f);
1192 cfg->ATHcurve = gfp->ATHcurve;
1193 cfg->ATHtype = gfp->ATHtype;
1194 cfg->ATHonly = gfp->ATHonly;
1195 cfg->ATHshort = gfp->ATHshort;
1196 cfg->noATH = gfp->noATH;
1198 cfg->quant_comp = gfp->quant_comp;
1199 cfg->quant_comp_short = gfp->quant_comp_short;
1201 cfg->use_temporal_masking_effect = gfp->useTemporal;
1202 if (cfg->mode == JOINT_STEREO) {
1203 cfg->use_safe_joint_stereo = gfp->exp_nspsytune & 2;
1206 cfg->use_safe_joint_stereo = 0;
1209 cfg->adjust_bass_db = (gfp->exp_nspsytune >> 2) & 63;
1210 if (cfg->adjust_bass_db >= 32.f)
1211 cfg->adjust_bass_db -= 64.f;
1212 cfg->adjust_bass_db *= 0.25f;
1214 cfg->adjust_alto_db = (gfp->exp_nspsytune >> 8) & 63;
1215 if (cfg->adjust_alto_db >= 32.f)
1216 cfg->adjust_alto_db -= 64.f;
1217 cfg->adjust_alto_db *= 0.25f;
1219 cfg->adjust_treble_db = (gfp->exp_nspsytune >> 14) & 63;
1220 if (cfg->adjust_treble_db >= 32.f)
1221 cfg->adjust_treble_db -= 64.f;
1222 cfg->adjust_treble_db *= 0.25f;
1226 cfg->adjust_sfb21_db = (gfp->exp_nspsytune >> 20) & 63;
1227 if (cfg->adjust_sfb21_db >= 32.f)
1228 cfg->adjust_sfb21_db -= 64.f;
1229 cfg->adjust_sfb21_db *= 0.25f;
1230 cfg->adjust_sfb21_db += cfg->adjust_treble_db;
1251 if (cfg->channels_in == 2 && cfg->channels_out == 1) {
1257 cfg->pcm_transform[0][0] = m[0][0];
1258 cfg->pcm_transform[0][1] = m[0][1];
1259 cfg->pcm_transform[1][0] = m[1][0];
1260 cfg->pcm_transform[1][1] = m[1][1];
1272 if (cfg->vbr == vbr_off)
1274 = ((cfg->version + 1) * 72000L * cfg->avg_bitrate) % cfg->samplerate_out;
1281 cfg->buffer_constraint = get_max_frame_buffer_size_by_constraint(cfg, gfp->strict_ISO);
1284 cfg->findReplayGain = gfp->findReplayGain;
1285 cfg->decode_on_the_fly = gfp->decode_on_the_fly;
1287 if (cfg->decode_on_the_fly)
1288 cfg->findPeakSample = 1;
1290 if (cfg->findReplayGain) {
1291 if (InitGainAnalysis(gfc->sv_rpg.rgdata, cfg->samplerate_out) == INIT_GAIN_ANALYSIS_ERROR) {
1296 cfg->findReplayGain = 0;
1301 if (cfg->decode_on_the_fly && !gfp->decode_only) {
1337 SessionConfig_t const *const cfg = &gfc->cfg;
1338 double const out_samplerate = cfg->samplerate_out;
1339 double const in_samplerate = cfg->samplerate_in;
1387 if (cfg->channels_in == 2 && cfg->channels_out == 1 /* mono */ ) {
1391 if (isResamplingNecessary(cfg)) {
1396 if (cfg->highpass2 > 0.)
1399 0.5 * cfg->highpass1 * out_samplerate, 0.5 * cfg->highpass2 * out_samplerate);
1400 if (0. < cfg->lowpass1 || 0. < cfg->lowpass2) {
1403 0.5 * cfg->lowpass1 * out_samplerate, 0.5 * cfg->lowpass2 * out_samplerate);
1409 if (cfg->free_format) {
1411 if (cfg->avg_bitrate > 320) {
1428 SessionConfig_t const *const cfg = &gfc->cfg;
1438 switch (cfg->use_best_huffman) {
1456 switch (cfg->version) {
1471 switch (cfg->mode) {
1491 MSGF(gfc, "\t%d channel - %s\n", cfg->channels_out, pc);
1493 switch (cfg->vbr) {
1503 if (vbr_default == cfg->vbr)
1505 else if (cfg->free_format)
1509 switch (cfg->vbr) {
1529 if (cfg->write_lame_tag)
1537 switch (cfg->short_blocks) {
1556 MSGF(gfc, "\tsubblock gain: %d\n", cfg->subblock_gain);
1559 MSGF(gfc, "\tquantization comparison: %d\n", cfg->quant_comp);
1560 MSGF(gfc, "\t ^ comparison short blocks: %d\n", cfg->quant_comp_short);
1561 MSGF(gfc, "\tnoise shaping: %d\n", cfg->noise_shaping);
1562 MSGF(gfc, "\t ^ amplification: %d\n", cfg->noise_shaping_amp);
1563 MSGF(gfc, "\t ^ stopping: %d\n", cfg->noise_shaping_stop);
1566 if (cfg->ATHshort)
1568 if (cfg->ATHonly)
1570 if (cfg->noATH)
1573 MSGF(gfc, "\t ^ type: %d\n", cfg->ATHtype);
1574 MSGF(gfc, "\t ^ shape: %g%s\n", cfg->ATHcurve, " (only for type 4)");
1575 MSGF(gfc, "\t ^ level adjustement: %g dB\n", cfg->ATH_offset_db);
1585 pc = cfg->use_temporal_masking_effect ? "yes" : "no";
1587 MSGF(gfc, "\tinterchannel masking ratio: %g\n", cfg->interChRatio);
1600 SessionConfig_t const *const cfg = &gfc->cfg;
1604 if (cfg->findReplayGain) {
1615 if (cfg->findPeakSample) {
1661 calcNeeded(SessionConfig_t const * cfg)
1664 int pcm_samples_per_frame = 576 * cfg->mode_gr;
1708 SessionConfig_t const *const cfg = &gfc->cfg;
1710 int pcm_samples_per_frame = 576 * cfg->mode_gr;
1735 mf_needed = calcNeeded(cfg);
1752 if (cfg->findReplayGain && !cfg->decode_on_the_fly)
1755 cfg->channels_out) == GAIN_ANALYSIS_ERROR)
1763 if (cfg->channels_out == 2)
1803 for (ch = 0; ch < cfg->channels_out; ch++)
1826 SessionConfig_t const *const cfg = &gfc->cfg;
1833 m[0][0] = s * cfg->pcm_transform[0][0];
1834 m[0][1] = s * cfg->pcm_transform[0][1];
1835 m[1][0] = s * cfg->pcm_transform[1][0];
1836 m[1][1] = s * cfg->pcm_transform[1][1];
1882 SessionConfig_t const *const cfg = &gfc->cfg;
1891 if (cfg->channels_in > 1) {
2075 if (gfc->cfg.write_lame_tag)
2118 SessionConfig_t const *cfg;
2140 cfg = &gfc->cfg;
2147 pcm_samples_per_frame = 576 * cfg->mode_gr;
2148 mf_needed = calcNeeded(cfg);
2155 is_resampling_necessary = isResamplingNecessary(cfg);
2157 resample_ratio = (double)cfg->samplerate_in / (double)cfg->samplerate_out;
2238 duration /= cfg->samplerate_out;
2243 MSGF(gfc, "sample count=%d (%g)\n", ns, cfg->samplerate_in * duration);
2311 SessionConfig_t const *cfg;
2319 cfg = &gfc->cfg;
2320 if (!cfg->write_lame_tag) {
2353 gfc->cfg.vbr_min_bitrate_index = 1; /* not 0 ????? */
2354 gfc->cfg.vbr_max_bitrate_index = 13; /* not 14 ????? */
2355 gfc->cfg.decode_on_the_fly = 0;
2356 gfc->cfg.findReplayGain = 0;
2357 gfc->cfg.findPeakSample = 0;
2541 SessionConfig_t const *const cfg = &gfc->cfg;
2543 if (cfg->free_format) {
2546 bitrate_kbps[0] = cfg->avg_bitrate;
2550 bitrate_kbps[i] = bitrate_table[cfg->version][i + 1];
2563 SessionConfig_t const *const cfg = &gfc->cfg;
2567 if (cfg->free_format) {
2607 SessionConfig_t const *const cfg = &gfc->cfg;
2612 if (cfg->free_format) {
2657 SessionConfig_t const *const cfg = &gfc->cfg;
2661 if (cfg->free_format) {