"L. Spiro Engine"
|
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-2009 * 00009 * by the Xiph.Org Foundation http://www.xiph.org/ * 00010 * * 00011 ******************************************************************** 00012 00013 function: libvorbis codec headers 00014 last mod: $Id: codec_internal.h 16227 2009-07-08 06:58:46Z xiphmont $ 00015 00016 ********************************************************************/ 00017 00018 00019 #ifndef __LSS_VORBISCODECINTERNAL_H__ 00020 #define __LSS_VORBISCODECINTERNAL_H__ 00021 00022 #include "../LSSSoundLib.h" 00023 #include "LSSOgg.h" 00024 #include "LSSVorbisBackends.h" 00025 #include "LSSVorbisBitrate.h" 00026 #include "LSSVorbisCodeBook.h" 00027 #include "LSSVorbisCodec.h" 00028 #include "LSSVorbisConstants.h" 00029 #include "LSSVorbisEnvelope.h" 00030 #include "LSSVorbisHighLevel.h" 00031 #include "LSSVorbisPsy.h" 00032 #include "LSSVorbisSmallFt.h" 00033 00034 namespace lss { 00035 00042 class CVorbisCodecInternal { 00043 public : 00044 // == Types. 00045 typedef struct vorbis_block_internal { 00046 LSFLOAT ** pcmdelay; // This is a pointer into local storage. 00047 LSFLOAT ampmax; 00048 LSINT32 blocktype; 00049 00050 COgg::oggpack_buffer * packetblob[PACKETBLOBS]; // Initialized, must be freed; 00051 // blob [PACKETBLOBS/2] points to 00052 // the oggpack_buffer in the 00053 // main vorbis_block. 00054 } * LPvorbis_block_internal, * const LPCvorbis_block_internal; 00055 00059 typedef struct private_state { 00060 // Local lookup storage. 00061 CVorbisEnvelope::envelope_lookup * ve; // Envelope lookup. 00062 LSINT32 window[2]; 00063 CVorbisStructs::vorbis_look_transform **transform[2]; // block, type. 00064 CVorbisSmallFt::drft_lookup fft_look[2]; 00065 00066 LSINT32 modebits; 00067 CVorbisStructs::vorbis_look_floor ** flr; 00068 CVorbisStructs::vorbis_look_residue ** residue; 00069 CVorbisPsy::vorbis_look_psy * psy; 00070 CVorbisPsy::vorbis_look_psy_global * psy_g_look; 00071 00072 // Local storage, only used on the encoding side. This way the 00073 // application does not need to worry about freeing some packets' 00074 // memory and not others'; packet storage is always tracked. 00075 // Cleared next call to a _dsp_ function. 00076 LSUINT8 * header; 00077 LSUINT8 * header1; 00078 LSUINT8 * header2; 00079 00080 CVorbisBitrate::bitrate_manager_state bms; 00081 00082 LSINT64 sample_count; 00083 } private_state; 00084 00088 typedef struct codec_setup_info { 00089 // Vorbis supports only short and LSINT32 blocks, but allows the 00090 // encoder to choose the sizes. 00091 LSINT32 blocksizes[2]; 00092 00093 // Modes are the primary means of supporting on-the-fly different 00094 // blocksizes, different channel mappings (LR or M/A), 00095 // different residue backends, etc. Each mode consists of a 00096 // blocksize flag and a mapping (along with the mapping setup. 00097 00098 LSINT32 modes; 00099 LSINT32 maps; 00100 LSINT32 floors; 00101 LSINT32 residues; 00102 LSINT32 books; 00103 LSINT32 psys; // Encode only. 00104 00105 CVorbisStructs::vorbis_info_mode * mode_param[64]; 00106 LSINT32 map_type[64]; 00107 CVorbisStructs::vorbis_info_mapping * map_param[64]; 00108 LSINT32 floor_type[64]; 00109 CVorbisStructs::vorbis_info_floor * floor_param[64]; 00110 LSINT32 residue_type[64]; 00111 CVorbisStructs::vorbis_info_residue * residue_param[64]; 00112 CVorbisCodeBook::static_codebook * book_param[256]; 00113 CVorbisCodeBook::codebook * fullbooks; 00114 00115 CVorbisPsy::vorbis_info_psy * psy_param[4]; // Encode only. 00116 CVorbisPsy::vorbis_info_psy_global psy_g_param; 00117 00118 CVorbisBitrate::bitrate_manager_info bi; 00119 CVorbisHighLevel::highlevel_encode_setup 00120 hi; 00121 LSINT32 halfrate_flag; // Painless downsample for decode. 00122 } codec_setup_info; 00123 00127 typedef struct vorbis_look_floor1 { 00128 LSINT32 sorted_index[VIF_POSIT+2]; 00129 LSINT32 forward_index[VIF_POSIT+2]; 00130 LSINT32 reverse_index[VIF_POSIT+2]; 00131 00132 LSINT32 hineighbor[VIF_POSIT]; 00133 LSINT32 loneighbor[VIF_POSIT]; 00134 LSINT32 posts; 00135 00136 LSINT32 n; 00137 LSINT32 quant_q; 00138 CVorbisBackends::vorbis_info_floor1 * vi; 00139 00140 LSINT32 phrasebits; 00141 LSINT32 postbits; 00142 LSINT32 frames; 00143 } * LPvorbis_look_floor1, * const LPCvorbis_look_floor1; 00144 00145 00146 // == Functions. 00153 static CVorbisPsy::vorbis_look_psy_global * _vp_global_look( CVorbisCodec::vorbis_info * _pviVi ); 00154 00160 static LSVOID _vp_global_free( CVorbisPsy::vorbis_look_psy_global * _pvlpgLook ); 00161 00171 static LSINT32 * floor1_fit( CVorbisCodec::vorbis_block * _pvbVb, vorbis_look_floor1 * _pvlfLook, 00172 const LSFLOAT * _pfLogMdct, 00173 const LSFLOAT * _pfLogMask ); 00174 00185 static LSINT32 * floor1_interpolate_fit( CVorbisCodec::vorbis_block * _pvbVb, vorbis_look_floor1 * _pvlfLook, 00186 LSINT32 * _pi32A, LSINT32 * _pi32B, 00187 LSINT32 _i32Del ); 00188 00199 static LSINT32 floor1_encode( COgg::oggpack_buffer * _poOpb, CVorbisCodec::vorbis_block * _pvbVb, 00200 vorbis_look_floor1 * _pvlfLook, 00201 LSINT32 * _pi32Post, LSINT32 * _pi32LogMaskI ); 00202 00203 00204 protected : 00217 static LSINT32 accumulate_fit( const LSFLOAT * _pfFlr, const LSFLOAT * _pfMdct, 00218 LSINT32 _i32X0, LSINT32 _i32X1, CVorbisStructs::lsfit_acc * _plaA, 00219 LSINT32 _i32N, CVorbisBackends::vorbis_info_floor1 * _pvfiInfo ); 00220 00231 static LSINT32 fit_line( CVorbisStructs::lsfit_acc * _plaA, LSINT32 _i32Fits, LSINT32 * _pi32Y0, LSINT32 * _pi32Y1, 00232 CVorbisBackends::vorbis_info_floor1 * _pvifInfo ); 00233 00242 static LSINT32 post_Y( LSINT32 * _pi32A, LSINT32 * _pi32B, LSINT32 _i32Pos ); 00243 00256 static LSINT32 inspect_error( LSINT32 _i32X0, LSINT32 _i32X1, LSINT32 _i32Y0, LSINT32 _i32Y1, const LSFLOAT * _pfMask, 00257 const LSFLOAT * _pfMdct, 00258 CVorbisBackends::vorbis_info_floor1 * _pvifInfo ); 00259 00270 static LSINT32 render_point( LSINT32 _i32X0, LSINT32 _i32X1, LSINT32 _i32Y0, LSINT32 _i32Y1, LSINT32 _i32X ); 00271 00278 static LSINT32 vorbis_dBquant( const LSFLOAT * _pfX ); 00279 00286 static LSINT32 ilog( LSUINT32 _ui32V ); 00287 00298 static LSVOID render_line0( LSINT32 _i32N, LSINT32 _i32X0, LSINT32 _i32X1, LSINT32 _i32Y0, LSINT32 _i32Y1, LSINT32 * _pi32D ); 00299 00300 }; 00301 00302 } // namespace lss 00303 00304 #endif // __LSS_VORBISCODECINTERNAL_H__ 00305