misc/libtremor/tremor/codec_internal.h
changeset 7697 767d3c4153a1
parent 6045 9a7cc0f29430
child 7849 a12155461b34
equal deleted inserted replaced
7696:78a00bc68913 7697:767d3c4153a1
     4  *                                                                  *
     4  *                                                                  *
     5  * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
     5  * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
     6  * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
     6  * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
     7  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
     7  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
     8  *                                                                  *
     8  *                                                                  *
     9  * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002    *
     9  * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003    *
    10  * BY THE Xiph.Org FOUNDATION http://www.xiph.org/                  *
    10  * BY THE Xiph.Org FOUNDATION http://www.xiph.org/                  *
    11  *                                                                  *
    11  *                                                                  *
    12  ********************************************************************
    12  ********************************************************************
    13 
    13 
    14  function: libvorbis codec headers
    14  function: libvorbis codec headers
    16  ********************************************************************/
    16  ********************************************************************/
    17 
    17 
    18 #ifndef _V_CODECI_H_
    18 #ifndef _V_CODECI_H_
    19 #define _V_CODECI_H_
    19 #define _V_CODECI_H_
    20 
    20 
       
    21 #define CHUNKSIZE 1024
       
    22 
    21 #include "codebook.h"
    23 #include "codebook.h"
    22 
    24 #include "ivorbiscodec.h"
    23 typedef void vorbis_look_mapping;
    25 
    24 typedef void vorbis_look_floor;
    26 #define VI_TRANSFORMB 1
    25 typedef void vorbis_look_residue;
    27 #define VI_WINDOWB 1
    26 typedef void vorbis_look_transform;
    28 #define VI_TIMEB 1
       
    29 #define VI_FLOORB 2
       
    30 #define VI_RESB 3
       
    31 #define VI_MAPB 1
       
    32 
       
    33 typedef void vorbis_info_floor;
       
    34 
       
    35 /* vorbis_dsp_state buffers the current vorbis audio
       
    36    analysis/synthesis state.  The DSP state belongs to a specific
       
    37    logical bitstream ****************************************************/
       
    38 struct vorbis_dsp_state{
       
    39   vorbis_info    *vi;
       
    40   oggpack_buffer  opb;
       
    41 
       
    42   ogg_int32_t   **work;
       
    43   ogg_int32_t   **mdctright;
       
    44   int             out_begin;
       
    45   int             out_end;
       
    46 
       
    47   long lW;
       
    48   long W;
       
    49 
       
    50   ogg_int64_t granulepos;
       
    51   ogg_int64_t sequence;
       
    52   ogg_int64_t sample_count;
       
    53 
       
    54 };
       
    55 
       
    56 
       
    57 /* Floor backend generic *****************************************/
       
    58 
       
    59 extern vorbis_info_floor *floor0_info_unpack(vorbis_info *,oggpack_buffer *);
       
    60 extern void floor0_free_info(vorbis_info_floor *);
       
    61 extern int floor0_memosize(vorbis_info_floor *);
       
    62 extern ogg_int32_t *floor0_inverse1(struct vorbis_dsp_state *,
       
    63 				    vorbis_info_floor *,ogg_int32_t *);
       
    64 extern int floor0_inverse2 (struct vorbis_dsp_state *,vorbis_info_floor *,
       
    65 			    ogg_int32_t *buffer,ogg_int32_t *);
       
    66 
       
    67 extern vorbis_info_floor *floor1_info_unpack(vorbis_info *,oggpack_buffer *);
       
    68 extern void floor1_free_info(vorbis_info_floor *);
       
    69 extern int floor1_memosize(vorbis_info_floor *);
       
    70 extern ogg_int32_t *floor1_inverse1(struct vorbis_dsp_state *,
       
    71 				    vorbis_info_floor *,ogg_int32_t *);
       
    72 extern int floor1_inverse2 (struct vorbis_dsp_state *,vorbis_info_floor *,
       
    73 			    ogg_int32_t *buffer,ogg_int32_t *);
       
    74 
       
    75 typedef struct{
       
    76   int   order;
       
    77   long  rate;
       
    78   long  barkmap;
       
    79 
       
    80   int   ampbits;
       
    81   int   ampdB;
       
    82 
       
    83   int   numbooks; /* <= 16 */
       
    84   char  books[16];
       
    85 
       
    86 } vorbis_info_floor0;
       
    87 
       
    88 typedef struct{
       
    89   char  class_dim;        /* 1 to 8 */
       
    90   char  class_subs;       /* 0,1,2,3 (bits: 1<<n poss) */
       
    91   unsigned char  class_book;       /* subs ^ dim entries */
       
    92   unsigned char  class_subbook[8]; /* [VIF_CLASS][subs] */
       
    93 } floor1class;  
       
    94 
       
    95 typedef struct{
       
    96   floor1class  *class;          /* [VIF_CLASS] */
       
    97   char         *partitionclass; /* [VIF_PARTS]; 0 to 15 */
       
    98   ogg_uint16_t *postlist;       /* [VIF_POSIT+2]; first two implicit */ 
       
    99   char         *forward_index;  /* [VIF_POSIT+2]; */
       
   100   char         *hineighbor;     /* [VIF_POSIT]; */
       
   101   char         *loneighbor;     /* [VIF_POSIT]; */
       
   102 
       
   103   int          partitions;    /* 0 to 31 */
       
   104   int          posts;
       
   105   int          mult;          /* 1 2 3 or 4 */ 
       
   106 
       
   107 } vorbis_info_floor1;
       
   108 
       
   109 /* Residue backend generic *****************************************/
       
   110 
       
   111 typedef struct vorbis_info_residue{
       
   112   int type;
       
   113   unsigned char *stagemasks;
       
   114   unsigned char *stagebooks;
       
   115 
       
   116 /* block-partitioned VQ coded straight residue */
       
   117   long begin;
       
   118   long end;
       
   119 
       
   120   /* first stage (lossless partitioning) */
       
   121   int           grouping;         /* group n vectors per partition */
       
   122   char          partitions;       /* possible codebooks for a partition */
       
   123   unsigned char groupbook;        /* huffbook for partitioning */
       
   124   char          stages;
       
   125 } vorbis_info_residue;
       
   126 
       
   127 extern void res_clear_info(vorbis_info_residue *info);
       
   128 extern int res_unpack(vorbis_info_residue *info,
       
   129 		      vorbis_info *vi,oggpack_buffer *opb);
       
   130 extern int res_inverse(vorbis_dsp_state *,vorbis_info_residue *info,
       
   131 		       ogg_int32_t **in,int *nonzero,int ch);
    27 
   132 
    28 /* mode ************************************************************/
   133 /* mode ************************************************************/
    29 typedef struct {
   134 typedef struct {
    30   int blockflag;
   135   unsigned char blockflag;
    31   int windowtype;
   136   unsigned char mapping;
    32   int transformtype;
       
    33   int mapping;
       
    34 } vorbis_info_mode;
   137 } vorbis_info_mode;
    35 
   138 
    36 typedef void vorbis_info_floor;
   139 /* Mapping backend generic *****************************************/
    37 typedef void vorbis_info_residue;
   140 typedef struct coupling_step{
    38 typedef void vorbis_info_mapping;
   141   unsigned char mag;
    39 
   142   unsigned char ang;
    40 typedef struct private_state {
   143 } coupling_step;
    41   /* local lookup storage */
   144 
    42   const void             *window[2];
   145 typedef struct submap{
    43 
   146   char floor;
    44   /* backend lookups are tied to the mode, not the backend or naked mapping */
   147   char residue;
    45   int                     modebits;
   148 } submap;
    46   vorbis_look_mapping   **mode;
   149 
    47 
   150 typedef struct vorbis_info_mapping{
    48   ogg_int64_t sample_count;
   151   int            submaps; 
    49 
   152   
    50 } private_state;
   153   unsigned char *chmuxlist;
       
   154   submap        *submaplist;
       
   155 
       
   156   int            coupling_steps;
       
   157   coupling_step *coupling;
       
   158 } vorbis_info_mapping;
       
   159 
       
   160 extern int mapping_info_unpack(vorbis_info_mapping *,vorbis_info *,
       
   161 			       oggpack_buffer *);
       
   162 extern void mapping_clear_info(vorbis_info_mapping *);
       
   163 extern int mapping_inverse(struct vorbis_dsp_state *,vorbis_info_mapping *);
    51 
   164 
    52 /* codec_setup_info contains all the setup information specific to the
   165 /* codec_setup_info contains all the setup information specific to the
    53    specific compression/decompression mode in progress (eg,
   166    specific compression/decompression mode in progress (eg,
    54    psychoacoustic settings, channel setup, options, codebook
   167    psychoacoustic settings, channel setup, options, codebook
    55    etc).  
   168    etc).  
    67      different residue backends, etc.  Each mode consists of a
   180      different residue backends, etc.  Each mode consists of a
    68      blocksize flag and a mapping (along with the mapping setup */
   181      blocksize flag and a mapping (along with the mapping setup */
    69 
   182 
    70   int        modes;
   183   int        modes;
    71   int        maps;
   184   int        maps;
    72   int        times;
       
    73   int        floors;
   185   int        floors;
    74   int        residues;
   186   int        residues;
    75   int        books;
   187   int        books;
    76 
   188 
    77   vorbis_info_mode       *mode_param[64];
   189   vorbis_info_mode       *mode_param;
    78   int                     map_type[64];
   190   vorbis_info_mapping    *map_param;
    79   vorbis_info_mapping    *map_param[64];
   191   char                   *floor_type;
    80   int                     time_type[64];
   192   vorbis_info_floor     **floor_param;
    81   int                     floor_type[64];
   193   vorbis_info_residue    *residue_param;
    82   vorbis_info_floor      *floor_param[64];
   194   codebook               *book_param;
    83   int                     residue_type[64];
   195 
    84   vorbis_info_residue    *residue_param[64];
       
    85   static_codebook        *book_param[256];
       
    86   codebook               *fullbooks;
       
    87 
       
    88   int    passlimit[32];     /* iteration limit per couple/quant pass */
       
    89   int    coupling_passes;
       
    90 } codec_setup_info;
   196 } codec_setup_info;
    91 
   197 
       
   198 extern vorbis_dsp_state *vorbis_dsp_create(vorbis_info *vi);
       
   199 extern void     vorbis_dsp_destroy(vorbis_dsp_state *v);
       
   200 extern int      vorbis_dsp_headerin(vorbis_info *vi,vorbis_comment *vc,
       
   201 				    ogg_packet *op);
       
   202 
       
   203 extern int      vorbis_dsp_restart(vorbis_dsp_state *v);
       
   204 extern int      vorbis_dsp_synthesis(vorbis_dsp_state *vd,
       
   205 				     ogg_packet *op,int decodep);
       
   206 extern int      vorbis_dsp_pcmout(vorbis_dsp_state *v,
       
   207 				  ogg_int16_t *pcm,int samples);
       
   208 extern int      vorbis_dsp_read(vorbis_dsp_state *v,int samples);
       
   209 extern long     vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op);
       
   210 
       
   211 
       
   212 
    92 #endif
   213 #endif