examples/sfexamples/oggvorbiscodec/src/libvorbis/lib/psy.h

00001 /********************************************************************
00002  *                                                                  *
00003  * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE.   *
00004  * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
00005  * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
00006  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
00007  *                                                                  *
00008  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002             *
00009  * by the XIPHOPHORUS Company http://www.xiph.org/                  *
00010  *                                                                  *
00011  ********************************************************************
00012 
00013  function: random psychoacoustics (not including preecho)
00014  last mod: $Id: psy.h 7187 2004-07-20 07:24:27Z xiphmont $
00015 
00016  ********************************************************************/
00017 
00018 #ifndef _V_PSY_H_
00019 #define _V_PSY_H_
00020 #include "smallft.h"
00021 
00022 #include "backends.h"
00023 #include "envelope.h"
00024 
00025 #ifndef EHMER_MAX
00026 #define EHMER_MAX 56
00027 #endif
00028 
00029 /* psychoacoustic setup ********************************************/
00030 #define P_BANDS 17      /* 62Hz to 16kHz */
00031 #define P_LEVELS 8      /* 30dB to 100dB */
00032 #define P_LEVEL_0 30.    /* 30 dB */
00033 #define P_NOISECURVES 3
00034 
00035 #define NOISE_COMPAND_LEVELS 40
00036 typedef struct vorbis_info_psy{
00037   int   blockflag;
00038 
00039   float ath_adjatt;
00040   float ath_maxatt;
00041 
00042   float tone_masteratt[P_NOISECURVES];
00043   float tone_centerboost;
00044   float tone_decay;
00045   float tone_abs_limit;
00046   float toneatt[P_BANDS];
00047 
00048   int noisemaskp;
00049   float noisemaxsupp;
00050   float noisewindowlo;
00051   float noisewindowhi;
00052   int   noisewindowlomin;
00053   int   noisewindowhimin;
00054   int   noisewindowfixed;
00055   float noiseoff[P_NOISECURVES][P_BANDS];
00056   float noisecompand[NOISE_COMPAND_LEVELS];
00057 
00058   float max_curve_dB;
00059 
00060   int normal_channel_p;
00061   int normal_point_p;
00062   int normal_start;
00063   int normal_partition;
00064   double normal_thresh;
00065 } vorbis_info_psy;
00066 
00067 typedef struct{
00068   int   eighth_octave_lines;
00069 
00070   /* for block long/short tuning; encode only */
00071   float preecho_thresh[VE_BANDS];
00072   float postecho_thresh[VE_BANDS];
00073   float stretch_penalty;
00074   float preecho_minenergy;
00075 
00076   float ampmax_att_per_sec;
00077 
00078   /* channel coupling config */
00079   int   coupling_pkHz[PACKETBLOBS];  
00080   int   coupling_pointlimit[2][PACKETBLOBS];  
00081   int   coupling_prepointamp[PACKETBLOBS];  
00082   int   coupling_postpointamp[PACKETBLOBS];  
00083   int   sliding_lowpass[2][PACKETBLOBS];  
00084 
00085 } vorbis_info_psy_global;
00086 
00087 typedef struct {
00088   float ampmax;
00089   int   channels;
00090 
00091   vorbis_info_psy_global *gi;
00092   int   coupling_pointlimit[2][P_NOISECURVES];  
00093 } vorbis_look_psy_global;
00094 
00095 
00096 typedef struct {
00097   int n;
00098   struct vorbis_info_psy *vi;
00099 
00100   float ***tonecurves;
00101   float **noiseoffset;
00102 
00103   float *ath;
00104   long  *octave;             /* in n.ocshift format */
00105   long  *bark;
00106 
00107   long  firstoc;
00108   long  shiftoc;
00109   int   eighth_octave_lines; /* power of two, please */
00110   int   total_octave_lines;  
00111   long  rate; /* cache it */
00112 
00113   float m_val; /* Masking compensation value */
00114 
00115 } vorbis_look_psy;
00116 
00117 extern void   _vp_psy_init(vorbis_look_psy *p,vorbis_info_psy *vi,
00118                            vorbis_info_psy_global *gi,int n,long rate);
00119 extern void   _vp_psy_clear(vorbis_look_psy *p);
00120 extern void  *_vi_psy_dup(void *source);
00121 
00122 extern void   _vi_psy_free(vorbis_info_psy *i);
00123 extern vorbis_info_psy *_vi_psy_copy(vorbis_info_psy *i);
00124 
00125 extern void _vp_remove_floor(vorbis_look_psy *p,
00126                              float *mdct,
00127                              int *icodedflr,
00128                              float *residue,
00129                              int sliding_lowpass);
00130 
00131 extern void _vp_noisemask(vorbis_look_psy *p,
00132                           float *logmdct, 
00133                           float *logmask);
00134 
00135 extern void _vp_tonemask(vorbis_look_psy *p,
00136                          float *logfft,
00137                          float *logmask,
00138                          float global_specmax,
00139                          float local_specmax);
00140 
00141 extern void _vp_offset_and_mix(vorbis_look_psy *p,
00142                                float *noise,
00143                                float *tone,
00144                                int offset_select,
00145                                float *logmask,
00146                                float *mdct,
00147                                float *logmdct);
00148 
00149 extern float _vp_ampmax_decay(float amp,vorbis_dsp_state *vd);
00150 
00151 extern float **_vp_quantize_couple_memo(vorbis_block *vb,
00152                                         vorbis_info_psy_global *g,
00153                                         vorbis_look_psy *p,
00154                                         vorbis_info_mapping0 *vi,
00155                                         float **mdct);
00156 
00157 extern void _vp_couple(int blobno,
00158                        vorbis_info_psy_global *g,
00159                        vorbis_look_psy *p,
00160                        vorbis_info_mapping0 *vi,
00161                        float **res,
00162                        float **mag_memo,
00163                        int   **mag_sort,
00164                        int   **ifloor,
00165                        int   *nonzero,
00166                        int   sliding_lowpass);
00167 
00168 extern void _vp_noise_normalize(vorbis_look_psy *p,
00169                                 float *in,float *out,int *sortedindex);
00170 
00171 extern void _vp_noise_normalize_sort(vorbis_look_psy *p,
00172                                      float *magnitudes,int *sortedindex);
00173 
00174 extern int **_vp_quantize_couple_sort(vorbis_block *vb,
00175                                       vorbis_look_psy *p,
00176                                       vorbis_info_mapping0 *vi,
00177                                       float **mags);
00178 
00179 extern void hf_reduction(vorbis_info_psy_global *g,
00180                          vorbis_look_psy *p,
00181                          vorbis_info_mapping0 *vi,
00182                          float **mdct);
00183 
00184 
00185 #endif
00186 

Generated by  doxygen 1.6.2