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