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: libvorbis codec headers Chris@1: last mod: $Id: codec_internal.h 16227 2009-07-08 06:58:46Z xiphmont $ Chris@1: Chris@1: ********************************************************************/ Chris@1: Chris@1: #ifndef _V_CODECI_H_ Chris@1: #define _V_CODECI_H_ Chris@1: Chris@1: #include "envelope.h" Chris@1: #include "codebook.h" Chris@1: Chris@1: #define BLOCKTYPE_IMPULSE 0 Chris@1: #define BLOCKTYPE_PADDING 1 Chris@1: #define BLOCKTYPE_TRANSITION 0 Chris@1: #define BLOCKTYPE_LONG 1 Chris@1: Chris@1: #define PACKETBLOBS 15 Chris@1: Chris@1: typedef struct vorbis_block_internal{ Chris@1: float **pcmdelay; /* this is a pointer into local storage */ Chris@1: float ampmax; Chris@1: int blocktype; Chris@1: Chris@1: oggpack_buffer *packetblob[PACKETBLOBS]; /* initialized, must be freed; Chris@1: blob [PACKETBLOBS/2] points to Chris@1: the oggpack_buffer in the Chris@1: main vorbis_block */ Chris@1: } vorbis_block_internal; Chris@1: Chris@1: typedef void vorbis_look_floor; Chris@1: typedef void vorbis_look_residue; Chris@1: typedef void vorbis_look_transform; Chris@1: Chris@1: /* mode ************************************************************/ Chris@1: typedef struct { Chris@1: int blockflag; Chris@1: int windowtype; Chris@1: int transformtype; Chris@1: int mapping; Chris@1: } vorbis_info_mode; Chris@1: Chris@1: typedef void vorbis_info_floor; Chris@1: typedef void vorbis_info_residue; Chris@1: typedef void vorbis_info_mapping; Chris@1: Chris@1: #include "psy.h" Chris@1: #include "bitrate.h" Chris@1: Chris@1: typedef struct private_state { Chris@1: /* local lookup storage */ Chris@1: envelope_lookup *ve; /* envelope lookup */ Chris@1: int window[2]; Chris@1: vorbis_look_transform **transform[2]; /* block, type */ Chris@1: drft_lookup fft_look[2]; Chris@1: Chris@1: int modebits; Chris@1: vorbis_look_floor **flr; Chris@1: vorbis_look_residue **residue; Chris@1: vorbis_look_psy *psy; Chris@1: vorbis_look_psy_global *psy_g_look; Chris@1: Chris@1: /* local storage, only used on the encoding side. This way the Chris@1: application does not need to worry about freeing some packets' Chris@1: memory and not others'; packet storage is always tracked. Chris@1: Cleared next call to a _dsp_ function */ Chris@1: unsigned char *header; Chris@1: unsigned char *header1; Chris@1: unsigned char *header2; Chris@1: Chris@1: bitrate_manager_state bms; Chris@1: Chris@1: ogg_int64_t sample_count; Chris@1: } private_state; Chris@1: Chris@1: /* codec_setup_info contains all the setup information specific to the Chris@1: specific compression/decompression mode in progress (eg, Chris@1: psychoacoustic settings, channel setup, options, codebook Chris@1: etc). Chris@1: *********************************************************************/ Chris@1: Chris@1: #include "highlevel.h" Chris@1: typedef struct codec_setup_info { Chris@1: Chris@1: /* Vorbis supports only short and long blocks, but allows the Chris@1: encoder to choose the sizes */ Chris@1: Chris@1: long blocksizes[2]; Chris@1: Chris@1: /* modes are the primary means of supporting on-the-fly different Chris@1: blocksizes, different channel mappings (LR or M/A), Chris@1: different residue backends, etc. Each mode consists of a Chris@1: blocksize flag and a mapping (along with the mapping setup */ Chris@1: Chris@1: int modes; Chris@1: int maps; Chris@1: int floors; Chris@1: int residues; Chris@1: int books; Chris@1: int psys; /* encode only */ Chris@1: Chris@1: vorbis_info_mode *mode_param[64]; Chris@1: int map_type[64]; Chris@1: vorbis_info_mapping *map_param[64]; Chris@1: int floor_type[64]; Chris@1: vorbis_info_floor *floor_param[64]; Chris@1: int residue_type[64]; Chris@1: vorbis_info_residue *residue_param[64]; Chris@1: static_codebook *book_param[256]; Chris@1: codebook *fullbooks; Chris@1: Chris@1: vorbis_info_psy *psy_param[4]; /* encode only */ Chris@1: vorbis_info_psy_global psy_g_param; Chris@1: Chris@1: bitrate_manager_info bi; Chris@1: highlevel_encode_setup hi; /* used only by vorbisenc.c. It's a Chris@1: highly redundant structure, but Chris@1: improves clarity of program flow. */ Chris@1: int halfrate_flag; /* painless downsample for decode */ Chris@1: } codec_setup_info; Chris@1: Chris@1: extern vorbis_look_psy_global *_vp_global_look(vorbis_info *vi); Chris@1: extern void _vp_global_free(vorbis_look_psy_global *look); Chris@1: Chris@1: Chris@1: Chris@1: typedef struct { Chris@1: int sorted_index[VIF_POSIT+2]; Chris@1: int forward_index[VIF_POSIT+2]; Chris@1: int reverse_index[VIF_POSIT+2]; Chris@1: Chris@1: int hineighbor[VIF_POSIT]; Chris@1: int loneighbor[VIF_POSIT]; Chris@1: int posts; Chris@1: Chris@1: int n; Chris@1: int quant_q; Chris@1: vorbis_info_floor1 *vi; Chris@1: Chris@1: long phrasebits; Chris@1: long postbits; Chris@1: long frames; Chris@1: } vorbis_look_floor1; Chris@1: Chris@1: Chris@1: Chris@1: extern int *floor1_fit(vorbis_block *vb,vorbis_look_floor1 *look, Chris@1: const float *logmdct, /* in */ Chris@1: const float *logmask); Chris@1: extern int *floor1_interpolate_fit(vorbis_block *vb,vorbis_look_floor1 *look, Chris@1: int *A,int *B, Chris@1: int del); Chris@1: extern int floor1_encode(oggpack_buffer *opb,vorbis_block *vb, Chris@1: vorbis_look_floor1 *look, Chris@1: int *post,int *ilogmask); Chris@1: #endif