22 #include "../vorbis/codec.h"
23 #include "../vorbis/vorbisenc.h"
122 int *psy_noise_normal_start[2];
123 int *psy_noise_normal_partition[2];
150 {1, {0,0}, {0}, {0}, 1,{0},{1}},
151 {1, {0,0}, {1}, {1}, 1,{0},{1}}
193 static int vorbis_encode_toplevel_setup(
vorbis_info *vi,
int ch,
long rate){
205 static void vorbis_encode_floor_setup(
vorbis_info *vi,
double s,
int block,
213 memcpy(f,in+x[is],
sizeof(*f));
222 for(i=0;i<partitions;i++)
224 for(i=0;i<=maxclass;i++){
233 for(i=0;i<=maxbook;i++)
245 static void vorbis_encode_global_psych_setup(
vorbis_info *vi,
double s,
253 memcpy(g,in+(
int)x[is],
sizeof(*g));
255 ds=x[is]*(1.-ds)+x[is+1]*ds;
272 static void vorbis_encode_global_stereo(
vorbis_info *vi,
288 float kHz=p[is].
kHz[
i]*(1.-ds)+p[is+1].kHz[i]*ds;
293 kHz=p[is].
lowpasskHz[
i]*(1.-ds)+p[is+1].lowpasskHz[i]*ds;
306 kHz=p[is].
lowpasskHz[PACKETBLOBS/2]*(1.-ds)+p[is+1].lowpasskHz[PACKETBLOBS/2]*ds;
321 static void vorbis_encode_psyset_setup(
vorbis_info *vi,
double s,
338 memcpy(p,&_psy_info_template,
sizeof(*p));
352 static void vorbis_encode_tonemask_setup(
vorbis_info *vi,
double s,
int block,
377 static void vorbis_encode_compand_setup(
vorbis_info *vi,
double s,
int block,
384 ds=x[is]*(1.-ds)+x[is+1]*ds;
398 static void vorbis_encode_peak_setup(
vorbis_info *vi,
double s,
int block,
410 static void vorbis_encode_noisebias_setup(
vorbis_info *vi,
double s,
int block,
442 static void vorbis_encode_ath_setup(
vorbis_info *vi,
int block){
454 for(i=0;i<ci->
books;i++)
460 static void vorbis_encode_blocksize_setup(
vorbis_info *vi,
double s,
461 int *shortb,
int *longb){
466 int blockshort=shortb[is];
467 int blocklong=longb[is];
473 static void vorbis_encode_residue_setup(
vorbis_info *vi,
474 int number,
int block,
483 memcpy(r,res->
res,
sizeof(*r));
487 case 64:
case 128:
case 256:
550 double nyq=vi->
rate/2.;
554 if(freq>nyq)freq=nyq;
558 f->
n=freq/nyq*blocksize;
567 if(freq>nyq)freq=nyq;
584 static void vorbis_encode_map_n_res_setup(
vorbis_info *vi,
double s,
588 int i,
j,is=
s,modes=2;
595 for(i=0;i<modes;i++){
600 memcpy(ci->
mode_param[i],mode+i,
sizeof(*_mode_template));
604 memcpy(ci->
map_param[i],map+i,
sizeof(*map));
608 vorbis_encode_residue_setup(vi,map[i].residuesubmap[j],i
609 ,res+map[i].residuesubmap[j]);
613 static double setting_to_approx_bitrate(
vorbis_info *vi){
625 return((r[is]*(1.-ds)+r[is+1]*ds)*ch);
630 double req,
int q_or_bitrate){
634 if(q_or_bitrate)req/=ch;
636 while(setup_list[i]){
637 if(setup_list[i]->coupling_restriction==-1 ||
638 setup_list[i]->coupling_restriction==ch){
639 if(srate>=setup_list[i]->samplerate_min_restriction &&
640 srate<=setup_list[i]->samplerate_max_restriction){
642 double *map=(q_or_bitrate?
648 if(req<map[0]){++
i;
continue;}
649 if(req>map[setup_list[i]->mappings]){++
i;
continue;}
650 for(j=0;j<mappings;j++)
651 if(req>=map[j] && req<map[j+1])
break;
659 float del=(req-low)/(high-low);
679 int i0=0,singleblock=0;
822 vorbis_encode_ath_setup(vi,0);
823 vorbis_encode_ath_setup(vi,1);
825 vorbis_encode_ath_setup(vi,2);
826 vorbis_encode_ath_setup(vi,3);
853 static int vorbis_encode_setup_setting(
vorbis_info *vi,
862 ret=vorbis_encode_toplevel_setup(vi,channels,rate);
906 if(quality>=1.)quality=.9999;
908 get_setup_template(vi,channels,rate,quality,0);
911 return vorbis_encode_setup_setting(vi,channels,rate);
939 long nominal_bitrate,
944 double tnominal=nominal_bitrate;
947 if(nominal_bitrate<=0.){
949 nominal_bitrate=max_bitrate*.875;
952 nominal_bitrate=min_bitrate;
959 get_setup_template(vi,channels,rate,nominal_bitrate,1);
962 ret=vorbis_encode_setup_setting(vi,channels,rate);
988 long nominal_bitrate,
1010 int setp=(number&0xf);
1100 double *farg=(
double *)arg;
1106 double *farg=(
double *)arg;
1115 double *farg=(
double *)arg;
1121 double *farg=(
double *)arg;
ve_setup_data_template ve_setup_44_uncoupled
vorbis_mapping_template * maps
int class_subbook[VIF_CLASS][8]
compandblock * psy_noise_compand
vorbis_info_residue * residue_param[64]
#define OV_ECTL_RATEMANAGE_GET
int * psy_noise_normal_start[2]
int vorbis_encode_init_vbr(vorbis_info *vi, long channels, long rate, float base_quality)
ve_setup_data_template ve_setup_X_stereo
att3 * psy_tone_masteratt
vorbis_info_floor * floor_param[64]
static_codebook * book_param[256]
int sliding_lowpass[2][PACKETBLOBS]
int vorbis_encode_ctl(vorbis_info *vi, int number, void *arg)
noise3 * psy_noise_bias_impulse
float lowpasskHz[PACKETBLOBS]
#define OV_ECTL_RATEMANAGE_SET
ve_setup_data_template ve_setup_11_uncoupled
static_codebook *** floor_books
highlevel_byblocktype block[4]
vorbis_residue_template * res
int class_subs[VIF_CLASS]
ve_setup_data_template ve_setup_X_stereo_low
ve_setup_data_template ve_setup_XX_stereo
vorbis_info_floor1 * floor_params
int vorbis_encode_setup_init(vorbis_info *vi)
ve_setup_data_template ve_setup_32_uncoupled_low
long samplerate_min_restriction
vorbis_info_residue0 * res
vp_adjblock * psy_tone_adj_long
double noise_bias_setting
ve_setup_data_template ve_setup_8_stereo
vorbis_info_mode * mode_param[64]
float noiseoff[P_NOISECURVES][P_BANDS]
ve_setup_data_template ve_setup_22_stereo
int partitionclass[VIF_PARTS]
int * psy_tone_dBsuppress
#define OV_ECTL_LOWPASS_GET
noise3 * psy_noise_bias_padding
static_codebook * book_aux_managed
double avgfloat_downslew_max
double bitrate_av_window_center
ve_setup_data_template ve_setup_X_uncoupled_low
int coupling_postpointamp[PACKETBLOBS]
int * psy_noise_normal_partition[2]
adj_stereo * stereo_modes
int vorbis_encode_setup_managed(vorbis_info *vi, long channels, long rate, long max_bitrate, long nominal_bitrate, long min_bitrate)
double bitrate_limit_window
vorbis_info_psy_global psy_g_param
vp_adjblock * psy_tone_adj_impulse
int * psy_noise_dBsuppress
ve_setup_data_template ve_setup_44_uncoupled_low
highlevel_encode_setup hi
ve_setup_data_template ve_setup_X_uncoupled
vp_adjblock * psy_tone_adj_other
int data[P_NOISECURVES][17]
noiseguard * psy_noiseguards
ve_setup_data_template ve_setup_32_stereo
GLsizei GLsizei GLenum GLenum const GLvoid * data
ve_setup_data_template ve_setup_32_stereo_low
static_bookblock * books_base_managed
ve_setup_data_template ve_setup_32_uncoupled
static_codebook * book_aux
#define NOISE_COMPAND_LEVELS
#define OV_ECTL_IBLOCK_SET
double bitrate_hard_window
double * psy_noise_compand_short_mapping
#define OV_ECTL_RATEMANAGE_HARD
float noisecompand[NOISE_COMPAND_LEVELS]
noise3 * psy_noise_bias_trans
void vorbis_info_clear(vorbis_info *vi)
vorbis_info_mapping0 * map
ve_setup_data_template ve_setup_11_stereo
int coupling_pkHz[PACKETBLOBS]
ve_setup_data_template ve_setup_16_uncoupled
int vorbis_encode_setup_vbr(vorbis_info *vi, long channels, long rate, float quality)
double avgfloat_upslew_max
#define OV_ECTL_RATEMANAGE_AVG
long samplerate_max_restriction
double * psy_noise_compand_long_mapping
double stereo_point_setting
int vorbis_encode_init(vorbis_info *vi, long channels, long rate, long max_bitrate, long nominal_bitrate, long min_bitrate)
float preecho_thresh[VE_BANDS]
double amplitude_track_dBpersec
GLdouble GLdouble GLdouble r
int * floor_short_mapping
float tone_masteratt[P_NOISECURVES]
int data[NOISE_COMPAND_LEVELS]
ve_setup_data_template ve_setup_22_uncoupled
int coupling_prepointamp[PACKETBLOBS]
double noise_compand_setting
ve_setup_data_template ve_setup_16_stereo
vorbis_info_psy_global * global_params
#define OV_ECTL_IBLOCK_GET
static_bookblock * books_base
ve_setup_data_template ve_setup_XX_uncoupled
#define OV_ECTL_LOWPASS_SET
double * psy_noise_normal_thresh
ve_setup_data_template ve_setup_44_stereo_low
vorbis_info_psy * psy_param[4]
ve_setup_data_template ve_setup_8_uncoupled
struct vp_adjblock vp_adjblock
double bitrate_av_window_center
int coupling_pointlimit[2][PACKETBLOBS]
ve_setup_data_template ve_setup_44_stereo
int class_book[VIF_CLASS]
double tone_peaklimit_setting
static_codebook * books[12][3]
noise3 * psy_noise_bias_long
float postecho_thresh[VE_BANDS]
vorbis_info_mapping * map_param[64]