Chris@1: /******************************************************************** Chris@1: * * Chris@1: * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * Chris@1: * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * Chris@1: * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * Chris@1: * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * Chris@1: * * Chris@1: * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * Chris@1: * by the Xiph.Org Foundation http://www.xiph.org/ * Chris@1: * * Chris@1: ******************************************************************** Chris@1: Chris@1: function: random psychoacoustics (not including preecho) Chris@1: last mod: $Id: psy.h 16946 2010-03-03 16:12:40Z xiphmont $ Chris@1: Chris@1: ********************************************************************/ Chris@1: Chris@1: #ifndef _V_PSY_H_ Chris@1: #define _V_PSY_H_ Chris@1: #include "smallft.h" Chris@1: Chris@1: #include "backends.h" Chris@1: #include "envelope.h" Chris@1: Chris@1: #ifndef EHMER_MAX Chris@1: #define EHMER_MAX 56 Chris@1: #endif Chris@1: Chris@1: /* psychoacoustic setup ********************************************/ Chris@1: #define P_BANDS 17 /* 62Hz to 16kHz */ Chris@1: #define P_LEVELS 8 /* 30dB to 100dB */ Chris@1: #define P_LEVEL_0 30. /* 30 dB */ Chris@1: #define P_NOISECURVES 3 Chris@1: Chris@1: #define NOISE_COMPAND_LEVELS 40 Chris@1: typedef struct vorbis_info_psy{ Chris@1: int blockflag; Chris@1: Chris@1: float ath_adjatt; Chris@1: float ath_maxatt; Chris@1: Chris@1: float tone_masteratt[P_NOISECURVES]; Chris@1: float tone_centerboost; Chris@1: float tone_decay; Chris@1: float tone_abs_limit; Chris@1: float toneatt[P_BANDS]; Chris@1: Chris@1: int noisemaskp; Chris@1: float noisemaxsupp; Chris@1: float noisewindowlo; Chris@1: float noisewindowhi; Chris@1: int noisewindowlomin; Chris@1: int noisewindowhimin; Chris@1: int noisewindowfixed; Chris@1: float noiseoff[P_NOISECURVES][P_BANDS]; Chris@1: float noisecompand[NOISE_COMPAND_LEVELS]; Chris@1: Chris@1: float max_curve_dB; Chris@1: Chris@1: int normal_p; Chris@1: int normal_start; Chris@1: int normal_partition; Chris@1: double normal_thresh; Chris@1: } vorbis_info_psy; Chris@1: Chris@1: typedef struct{ Chris@1: int eighth_octave_lines; Chris@1: Chris@1: /* for block long/short tuning; encode only */ Chris@1: float preecho_thresh[VE_BANDS]; Chris@1: float postecho_thresh[VE_BANDS]; Chris@1: float stretch_penalty; Chris@1: float preecho_minenergy; Chris@1: Chris@1: float ampmax_att_per_sec; Chris@1: Chris@1: /* channel coupling config */ Chris@1: int coupling_pkHz[PACKETBLOBS]; Chris@1: int coupling_pointlimit[2][PACKETBLOBS]; Chris@1: int coupling_prepointamp[PACKETBLOBS]; Chris@1: int coupling_postpointamp[PACKETBLOBS]; Chris@1: int sliding_lowpass[2][PACKETBLOBS]; Chris@1: Chris@1: } vorbis_info_psy_global; Chris@1: Chris@1: typedef struct { Chris@1: float ampmax; Chris@1: int channels; Chris@1: Chris@1: vorbis_info_psy_global *gi; Chris@1: int coupling_pointlimit[2][P_NOISECURVES]; Chris@1: } vorbis_look_psy_global; Chris@1: Chris@1: Chris@1: typedef struct { Chris@1: int n; Chris@1: struct vorbis_info_psy *vi; Chris@1: Chris@1: float ***tonecurves; Chris@1: float **noiseoffset; Chris@1: Chris@1: float *ath; Chris@1: long *octave; /* in n.ocshift format */ Chris@1: long *bark; Chris@1: Chris@1: long firstoc; Chris@1: long shiftoc; Chris@1: int eighth_octave_lines; /* power of two, please */ Chris@1: int total_octave_lines; Chris@1: long rate; /* cache it */ Chris@1: Chris@1: float m_val; /* Masking compensation value */ Chris@1: Chris@1: } vorbis_look_psy; Chris@1: Chris@1: extern void _vp_psy_init(vorbis_look_psy *p,vorbis_info_psy *vi, Chris@1: vorbis_info_psy_global *gi,int n,long rate); Chris@1: extern void _vp_psy_clear(vorbis_look_psy *p); Chris@1: extern void *_vi_psy_dup(void *source); Chris@1: Chris@1: extern void _vi_psy_free(vorbis_info_psy *i); Chris@1: extern vorbis_info_psy *_vi_psy_copy(vorbis_info_psy *i); Chris@1: Chris@1: extern void _vp_noisemask(vorbis_look_psy *p, Chris@1: float *logmdct, Chris@1: float *logmask); Chris@1: Chris@1: extern void _vp_tonemask(vorbis_look_psy *p, Chris@1: float *logfft, Chris@1: float *logmask, Chris@1: float global_specmax, Chris@1: float local_specmax); Chris@1: Chris@1: extern void _vp_offset_and_mix(vorbis_look_psy *p, Chris@1: float *noise, Chris@1: float *tone, Chris@1: int offset_select, Chris@1: float *logmask, Chris@1: float *mdct, Chris@1: float *logmdct); Chris@1: Chris@1: extern float _vp_ampmax_decay(float amp,vorbis_dsp_state *vd); Chris@1: Chris@1: extern void _vp_couple_quantize_normalize(int blobno, Chris@1: vorbis_info_psy_global *g, Chris@1: vorbis_look_psy *p, Chris@1: vorbis_info_mapping0 *vi, Chris@1: float **mdct, Chris@1: int **iwork, Chris@1: int *nonzero, Chris@1: int sliding_lowpass, Chris@1: int ch); Chris@1: Chris@1: #endif