Blame lib/psy.h

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