- ret|=vorbis_encode_floor_setup(vi,hi->base_quality_short,0,
- _floor_44_128_books,_floor_44_128,
- 0,1,1,2,2,2,2,2,2,2,2);
- ret|=vorbis_encode_floor_setup(vi,hi->base_quality_long,1,
- _floor_44_1024_books,_floor_44_1024,
- 0,0,0,0,0,0,0,0,0,0,0);
-
- ret|=vorbis_encode_global_psych_setup(vi,hi->trigger_quality,_psy_global_44,
- 0., 1., 1.5, 2., 2., 2., 2., 2., 2., 2., 2.);
-
- ret|=vorbis_encode_psyset_setup(vi,0);
- ret|=vorbis_encode_psyset_setup(vi,1);
- ret|=vorbis_encode_psyset_setup(vi,2);
- ret|=vorbis_encode_psyset_setup(vi,3);
-
- ret|=vorbis_encode_tonemask_setup(vi,hi->blocktype[0].tone_mask_quality,0,
- _psy_tone_masteratt,_psy_tone_0dB,_psy_ehmer_bandlimit,
- _vp_tonemask_adj_otherblock);
- ret|=vorbis_encode_tonemask_setup(vi,hi->blocktype[1].tone_mask_quality,1,
- _psy_tone_masteratt,_psy_tone_0dB,_psy_ehmer_bandlimit,
- _vp_tonemask_adj_otherblock);
- ret|=vorbis_encode_tonemask_setup(vi,hi->blocktype[2].tone_mask_quality,2,
- _psy_tone_masteratt,_psy_tone_0dB,_psy_ehmer_bandlimit,
- _vp_tonemask_adj_otherblock);
- ret|=vorbis_encode_tonemask_setup(vi,hi->blocktype[3].tone_mask_quality,3,
- _psy_tone_masteratt,_psy_tone_0dB,_psy_ehmer_bandlimit,
- _vp_tonemask_adj_longblock);
-
- ret|=vorbis_encode_compand_setup(vi,hi->blocktype[0].noise_compand_quality,
- 0,_psy_compand_44_short,
- 1., 1., 1.3, 1.6, 2., 2., 2., 2., 2., 2., 2.);
- ret|=vorbis_encode_compand_setup(vi,hi->blocktype[1].noise_compand_quality,
- 1,_psy_compand_44_short,
- 1., 1., 1.3, 1.6, 2., 2., 2., 2., 2., 2., 2.);
- ret|=vorbis_encode_compand_setup(vi,hi->blocktype[2].noise_compand_quality,
- 2,_psy_compand_44,
- 1., 1., 1.3, 1.6, 2., 2., 2., 2., 2., 2., 2.);
- ret|=vorbis_encode_compand_setup(vi,hi->blocktype[3].noise_compand_quality,
- 3,_psy_compand_44,
- 1., 1., 1.3, 1.6, 2., 2., 2., 2., 2., 2., 2.);
- ret|=vorbis_encode_peak_setup(vi,hi->blocktype[0].tone_peaklimit_quality,
- 0,_psy_tone_masterguard,_psy_tone_suppress,
- _vp_peakguard);
- ret|=vorbis_encode_peak_setup(vi,hi->blocktype[1].tone_peaklimit_quality,
- 1,_psy_tone_masterguard,_psy_tone_suppress,
- _vp_peakguard);
- ret|=vorbis_encode_peak_setup(vi,hi->blocktype[2].tone_peaklimit_quality,
- 2,_psy_tone_masterguard,_psy_tone_suppress,
- _vp_peakguard);
- ret|=vorbis_encode_peak_setup(vi,hi->blocktype[3].tone_peaklimit_quality,
- 3,_psy_tone_masterguard,_psy_tone_suppress,
- _vp_peakguard);
-
- ret|=vorbis_encode_noisebias_setup(vi,hi->blocktype[0].noise_bias_quality,
- 0,_psy_noise_suppress,_psy_noisebias_impulse,
- _psy_noiseguards_short);
- ret|=vorbis_encode_noisebias_setup(vi,hi->blocktype[1].noise_bias_quality,
- 1,_psy_noise_suppress,_psy_noisebias_other,
- _psy_noiseguards_short);
- ret|=vorbis_encode_noisebias_setup(vi,hi->blocktype[2].noise_bias_quality,
- 2,_psy_noise_suppress,_psy_noisebias_other,
- _psy_noiseguards_long);
- ret|=vorbis_encode_noisebias_setup(vi,hi->blocktype[3].noise_bias_quality,
- 3,_psy_noise_suppress,_psy_noisebias_long,
- _psy_noiseguards_long);
-
- ret|=vorbis_encode_ath_setup(vi,hi->blocktype[0].ath_quality,0,ATH_Bark_dB,
- 0., 0., 0., 0., .2, .5, 1., 1., 1.5, 2., 2.);
- ret|=vorbis_encode_ath_setup(vi,hi->blocktype[1].ath_quality,1,ATH_Bark_dB,
- 0., 0., 0., 0., .2, .5, 1., 1., 1.5, 2., 2.);
- ret|=vorbis_encode_ath_setup(vi,hi->blocktype[2].ath_quality,2,ATH_Bark_dB,
- 0., 0., 0., 0., .2, .5, 1., 1., 1.5, 2., 2.);
- ret|=vorbis_encode_ath_setup(vi,hi->blocktype[3].ath_quality,3,ATH_Bark_dB,
- 0., 0., 0., 0., .2, .5, 1., 1., 1.5, 2., 2.);
+ if(ci==NULL)return(OV_EINVAL);
+ if(!hi->impulse_block_p)i0=1;
+
+ /* too low/high an ATH floater is nonsensical, but doesn't break anything */
+ if(hi->ath_floating_dB>-80)hi->ath_floating_dB=-80;
+ if(hi->ath_floating_dB<-200)hi->ath_floating_dB=-200;
+
+ /* again, bound this to avoid the app shooting itself int he foot
+ too badly */
+ if(hi->amplitude_track_dBpersec>0.)hi->amplitude_track_dBpersec=0.;
+ if(hi->amplitude_track_dBpersec<-99999.)hi->amplitude_track_dBpersec=-99999.;
+
+ /* get the appropriate setup template; matches the fetch in previous
+ stages */
+ setup=(ve_setup_data_template *)hi->setup;
+ if(setup==NULL)return(OV_EINVAL);
+
+ hi->set_in_stone=1;
+ /* choose block sizes from configured sizes as well as paying
+ attention to long_block_p and short_block_p. If the configured
+ short and long blocks are the same length, we set long_block_p
+ and unset short_block_p */
+ vorbis_encode_blocksize_setup(vi,hi->base_setting,
+ setup->blocksize_short,
+ setup->blocksize_long);
+ if(ci->blocksizes[0]==ci->blocksizes[1])singleblock=1;
+
+ /* floor setup; choose proper floor params. Allocated on the floor
+ stack in order; if we alloc only a single long floor, it's 0 */
+ for(i=0;i<setup->floor_mappings;i++)
+ vorbis_encode_floor_setup(vi,hi->base_setting,
+ setup->floor_books,
+ setup->floor_params,
+ setup->floor_mapping_list[i]);
+
+ /* setup of [mostly] short block detection and stereo*/
+ vorbis_encode_global_psych_setup(vi,hi->trigger_setting,
+ setup->global_params,
+ setup->global_mapping);
+ vorbis_encode_global_stereo(vi,hi,setup->stereo_modes);
+
+ /* basic psych setup and noise normalization */
+ vorbis_encode_psyset_setup(vi,hi->base_setting,
+ setup->psy_noise_normal_start[0],
+ setup->psy_noise_normal_partition[0],
+ setup->psy_noise_normal_thresh,
+ 0);
+ vorbis_encode_psyset_setup(vi,hi->base_setting,
+ setup->psy_noise_normal_start[0],
+ setup->psy_noise_normal_partition[0],
+ setup->psy_noise_normal_thresh,
+ 1);
+ if(!singleblock){
+ vorbis_encode_psyset_setup(vi,hi->base_setting,
+ setup->psy_noise_normal_start[1],
+ setup->psy_noise_normal_partition[1],
+ setup->psy_noise_normal_thresh,
+ 2);
+ vorbis_encode_psyset_setup(vi,hi->base_setting,
+ setup->psy_noise_normal_start[1],
+ setup->psy_noise_normal_partition[1],
+ setup->psy_noise_normal_thresh,
+ 3);
+ }