codec_internal.h 5.27 KB
Newer Older
Monty's avatar
 
Monty committed
1 2 3
/********************************************************************
 *                                                                  *
 * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE.   *
Monty's avatar
 
Monty committed
4 5 6
 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
Monty's avatar
 
Monty committed
7
 *                                                                  *
Monty's avatar
Monty committed
8
 * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009             *
9
 * by the Xiph.Org Foundation http://www.xiph.org/                  *
10
 *                                                                  *
Monty's avatar
 
Monty committed
11 12 13 14 15 16 17 18 19 20 21 22
 ********************************************************************

 function: libvorbis codec headers

 ********************************************************************/

#ifndef _V_CODECI_H_
#define _V_CODECI_H_

#include "envelope.h"
#include "codebook.h"

Monty's avatar
 
Monty committed
23 24
#define BLOCKTYPE_IMPULSE    0
#define BLOCKTYPE_PADDING    1
Monty's avatar
Monty committed
25
#define BLOCKTYPE_TRANSITION 0
Monty's avatar
 
Monty committed
26 27
#define BLOCKTYPE_LONG       1

Monty's avatar
 
Monty committed
28 29
#define PACKETBLOBS 15

Monty's avatar
 
Monty committed
30
typedef struct vorbis_block_internal{
Monty's avatar
Monty committed
31
  float  **pcmdelay;  /* this is a pointer into local storage */
Monty's avatar
 
Monty committed
32
  float  ampmax;
Monty's avatar
 
Monty committed
33 34
  int    blocktype;

Monty's avatar
Monty committed
35
  oggpack_buffer *packetblob[PACKETBLOBS]; /* initialized, must be freed;
36
                                              blob [PACKETBLOBS/2] points to
Monty's avatar
Monty committed
37
                                              the oggpack_buffer in the
38
                                              main vorbis_block */
Monty's avatar
 
Monty committed
39 40
} vorbis_block_internal;

Monty's avatar
 
Monty committed
41 42 43 44
typedef void vorbis_look_floor;
typedef void vorbis_look_residue;
typedef void vorbis_look_transform;

Monty's avatar
 
Monty committed
45 46 47 48 49 50 51 52 53 54 55 56 57
/* mode ************************************************************/
typedef struct {
  int blockflag;
  int windowtype;
  int transformtype;
  int mapping;
} vorbis_info_mode;

typedef void vorbis_info_floor;
typedef void vorbis_info_residue;
typedef void vorbis_info_mapping;

#include "psy.h"
Monty's avatar
 
Monty committed
58
#include "bitrate.h"
Monty's avatar
 
Monty committed
59

Monty's avatar
 
Monty committed
60
typedef struct private_state {
Monty's avatar
 
Monty committed
61
  /* local lookup storage */
Monty's avatar
Monty committed
62
  envelope_lookup        *ve; /* envelope lookup */
Monty's avatar
 
Monty committed
63
  int                     window[2];
Monty's avatar
 
Monty committed
64
  vorbis_look_transform **transform[2];    /* block, type */
Monty's avatar
 
Monty committed
65
  drft_lookup             fft_look[2];
Monty's avatar
 
Monty committed
66 67

  int                     modebits;
Monty's avatar
 
Monty committed
68 69 70 71
  vorbis_look_floor     **flr;
  vorbis_look_residue   **residue;
  vorbis_look_psy        *psy;
  vorbis_look_psy_global *psy_g_look;
Monty's avatar
 
Monty committed
72 73 74 75 76 77 78 79

  /* local storage, only used on the encoding side.  This way the
     application does not need to worry about freeing some packets'
     memory and not others'; packet storage is always tracked.
     Cleared next call to a _dsp_ function */
  unsigned char *header;
  unsigned char *header1;
  unsigned char *header2;
Monty's avatar
 
Monty committed
80 81 82

  bitrate_manager_state bms;

Monty's avatar
 
Monty committed
83 84
  ogg_int64_t sample_count;
} private_state;
Monty's avatar
 
Monty committed
85

Monty's avatar
 
Monty committed
86
/* codec_setup_info contains all the setup information specific to the
Monty's avatar
 
Monty committed
87 88
   specific compression/decompression mode in progress (eg,
   psychoacoustic settings, channel setup, options, codebook
Monty's avatar
Monty committed
89
   etc).
Monty's avatar
 
Monty committed
90 91
*********************************************************************/

Monty's avatar
 
Monty committed
92
#include "highlevel.h"
Monty's avatar
 
Monty committed
93 94 95 96 97 98 99 100
typedef struct codec_setup_info {

  /* Vorbis supports only short and long blocks, but allows the
     encoder to choose the sizes */

  long blocksizes[2];

  /* modes are the primary means of supporting on-the-fly different
Monty's avatar
 
Monty committed
101
     blocksizes, different channel mappings (LR or M/A),
Monty's avatar
 
Monty committed
102 103 104 105 106 107 108 109 110 111
     different residue backends, etc.  Each mode consists of a
     blocksize flag and a mapping (along with the mapping setup */

  int        modes;
  int        maps;
  int        floors;
  int        residues;
  int        books;
  int        psys;     /* encode only */

Monty's avatar
 
Monty committed
112 113 114 115 116 117 118 119
  vorbis_info_mode       *mode_param[64];
  int                     map_type[64];
  vorbis_info_mapping    *map_param[64];
  int                     floor_type[64];
  vorbis_info_floor      *floor_param[64];
  int                     residue_type[64];
  vorbis_info_residue    *residue_param[64];
  static_codebook        *book_param[256];
Monty's avatar
 
Monty committed
120
  codebook               *fullbooks;
Monty's avatar
 
Monty committed
121

Monty's avatar
 
Monty committed
122
  vorbis_info_psy        *psy_param[4]; /* encode only */
Monty's avatar
 
Monty committed
123
  vorbis_info_psy_global psy_g_param;
Monty's avatar
 
Monty committed
124

Monty's avatar
 
Monty committed
125
  bitrate_manager_info   bi;
Monty's avatar
 
Monty committed
126 127 128
  highlevel_encode_setup hi; /* used only by vorbisenc.c.  It's a
                                highly redundant structure, but
                                improves clarity of program flow. */
Monty's avatar
Monty committed
129
  int         halfrate_flag; /* painless downsample for decode */
Monty's avatar
 
Monty committed
130 131
} codec_setup_info;

Monty's avatar
 
Monty committed
132 133 134
extern vorbis_look_psy_global *_vp_global_look(vorbis_info *vi);
extern void _vp_global_free(vorbis_look_psy_global *look);

135 136 137 138 139 140


typedef struct {
  int sorted_index[VIF_POSIT+2];
  int forward_index[VIF_POSIT+2];
  int reverse_index[VIF_POSIT+2];
Monty's avatar
Monty committed
141

142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
  int hineighbor[VIF_POSIT];
  int loneighbor[VIF_POSIT];
  int posts;

  int n;
  int quant_q;
  vorbis_info_floor1 *vi;

  long phrasebits;
  long postbits;
  long frames;
} vorbis_look_floor1;



extern int *floor1_fit(vorbis_block *vb,vorbis_look_floor1 *look,
158 159
                          const float *logmdct,   /* in */
                          const float *logmask);
160
extern int *floor1_interpolate_fit(vorbis_block *vb,vorbis_look_floor1 *look,
161 162
                          int *A,int *B,
                          int del);
163
extern int floor1_encode(oggpack_buffer *opb,vorbis_block *vb,
164 165
                  vorbis_look_floor1 *look,
                  int *post,int *ilogmask);
Monty's avatar
 
Monty committed
166
#endif