misc/libtremor/tremor/codec_internal.h
changeset 7849 a12155461b34
parent 7697 767d3c4153a1
equal deleted inserted replaced
7848:775a72905708 7849:a12155461b34
     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-2003    *
     9  * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002    *
    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
    21 #include "codebook.h"
    22 
    22 
    23 #include "codebook.h"
    23 typedef void vorbis_look_mapping;
    24 #include "ivorbiscodec.h"
    24 typedef void vorbis_look_floor;
    25 
    25 typedef void vorbis_look_residue;
    26 #define VI_TRANSFORMB 1
    26 typedef void vorbis_look_transform;
    27 #define VI_WINDOWB 1
       
    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);
       
   132 
    27 
   133 /* mode ************************************************************/
    28 /* mode ************************************************************/
   134 typedef struct {
    29 typedef struct {
   135   unsigned char blockflag;
    30   int blockflag;
   136   unsigned char mapping;
    31   int windowtype;
       
    32   int transformtype;
       
    33   int mapping;
   137 } vorbis_info_mode;
    34 } vorbis_info_mode;
   138 
    35 
   139 /* Mapping backend generic *****************************************/
    36 typedef void vorbis_info_floor;
   140 typedef struct coupling_step{
    37 typedef void vorbis_info_residue;
   141   unsigned char mag;
    38 typedef void vorbis_info_mapping;
   142   unsigned char ang;
       
   143 } coupling_step;
       
   144 
    39 
   145 typedef struct submap{
    40 typedef struct private_state {
   146   char floor;
    41   /* local lookup storage */
   147   char residue;
    42   const void             *window[2];
   148 } submap;
       
   149 
    43 
   150 typedef struct vorbis_info_mapping{
    44   /* backend lookups are tied to the mode, not the backend or naked mapping */
   151   int            submaps; 
    45   int                     modebits;
   152   
    46   vorbis_look_mapping   **mode;
   153   unsigned char *chmuxlist;
       
   154   submap        *submaplist;
       
   155 
    47 
   156   int            coupling_steps;
    48   ogg_int64_t sample_count;
   157   coupling_step *coupling;
       
   158 } vorbis_info_mapping;
       
   159 
    49 
   160 extern int mapping_info_unpack(vorbis_info_mapping *,vorbis_info *,
    50 } private_state;
   161 			       oggpack_buffer *);
       
   162 extern void mapping_clear_info(vorbis_info_mapping *);
       
   163 extern int mapping_inverse(struct vorbis_dsp_state *,vorbis_info_mapping *);
       
   164 
    51 
   165 /* codec_setup_info contains all the setup information specific to the
    52 /* codec_setup_info contains all the setup information specific to the
   166    specific compression/decompression mode in progress (eg,
    53    specific compression/decompression mode in progress (eg,
   167    psychoacoustic settings, channel setup, options, codebook
    54    psychoacoustic settings, channel setup, options, codebook
   168    etc).  
    55    etc).  
   180      different residue backends, etc.  Each mode consists of a
    67      different residue backends, etc.  Each mode consists of a
   181      blocksize flag and a mapping (along with the mapping setup */
    68      blocksize flag and a mapping (along with the mapping setup */
   182 
    69 
   183   int        modes;
    70   int        modes;
   184   int        maps;
    71   int        maps;
       
    72   int        times;
   185   int        floors;
    73   int        floors;
   186   int        residues;
    74   int        residues;
   187   int        books;
    75   int        books;
   188 
    76 
   189   vorbis_info_mode       *mode_param;
    77   vorbis_info_mode       *mode_param[64];
   190   vorbis_info_mapping    *map_param;
    78   int                     map_type[64];
   191   char                   *floor_type;
    79   vorbis_info_mapping    *map_param[64];
   192   vorbis_info_floor     **floor_param;
    80   int                     time_type[64];
   193   vorbis_info_residue    *residue_param;
    81   int                     floor_type[64];
   194   codebook               *book_param;
    82   vorbis_info_floor      *floor_param[64];
       
    83   int                     residue_type[64];
       
    84   vorbis_info_residue    *residue_param[64];
       
    85   static_codebook        *book_param[256];
       
    86   codebook               *fullbooks;
   195 
    87 
       
    88   int    passlimit[32];     /* iteration limit per couple/quant pass */
       
    89   int    coupling_passes;
   196 } codec_setup_info;
    90 } codec_setup_info;
   197 
    91 
   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 
       
   213 #endif
    92 #endif