media/libtremor/include/tremor/ivorbiscodec.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/libtremor/include/tremor/ivorbiscodec.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,204 @@
     1.4 +/********************************************************************
     1.5 + *                                                                  *
     1.6 + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE.   *
     1.7 + *                                                                  *
     1.8 + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
     1.9 + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
    1.10 + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
    1.11 + *                                                                  *
    1.12 + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002    *
    1.13 + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/                  *
    1.14 + *                                                                  *
    1.15 + ********************************************************************
    1.16 +
    1.17 + function: libvorbis codec headers
    1.18 +
    1.19 + ********************************************************************/
    1.20 +
    1.21 +#ifndef _vorbis_codec_h_
    1.22 +#define _vorbis_codec_h_
    1.23 +
    1.24 +#ifdef __cplusplus
    1.25 +extern "C"
    1.26 +{
    1.27 +#endif /* __cplusplus */
    1.28 +
    1.29 +#include <ogg/ogg.h>
    1.30 +
    1.31 +typedef struct vorbis_info{
    1.32 +  int version;
    1.33 +  int channels;
    1.34 +  long rate;
    1.35 +
    1.36 +  /* The below bitrate declarations are *hints*.
    1.37 +     Combinations of the three values carry the following implications:
    1.38 +     
    1.39 +     all three set to the same value: 
    1.40 +       implies a fixed rate bitstream
    1.41 +     only nominal set: 
    1.42 +       implies a VBR stream that averages the nominal bitrate.  No hard 
    1.43 +       upper/lower limit
    1.44 +     upper and or lower set: 
    1.45 +       implies a VBR bitstream that obeys the bitrate limits. nominal 
    1.46 +       may also be set to give a nominal rate.
    1.47 +     none set:
    1.48 +       the coder does not care to speculate.
    1.49 +  */
    1.50 +
    1.51 +  long bitrate_upper;
    1.52 +  long bitrate_nominal;
    1.53 +  long bitrate_lower;
    1.54 +  long bitrate_window;
    1.55 +
    1.56 +  void *codec_setup;
    1.57 +} vorbis_info;
    1.58 +
    1.59 +/* vorbis_dsp_state buffers the current vorbis audio
    1.60 +   analysis/synthesis state.  The DSP state belongs to a specific
    1.61 +   logical bitstream ****************************************************/
    1.62 +typedef struct vorbis_dsp_state{
    1.63 +  int analysisp;
    1.64 +  vorbis_info *vi;
    1.65 +
    1.66 +  ogg_int32_t **pcm;
    1.67 +  ogg_int32_t **pcmret;
    1.68 +  int      pcm_storage;
    1.69 +  int      pcm_current;
    1.70 +  int      pcm_returned;
    1.71 +
    1.72 +  int  preextrapolate;
    1.73 +  int  eofflag;
    1.74 +
    1.75 +  long lW;
    1.76 +  long W;
    1.77 +  long nW;
    1.78 +  long centerW;
    1.79 +
    1.80 +  ogg_int64_t granulepos;
    1.81 +  ogg_int64_t sequence;
    1.82 +
    1.83 +  void       *backend_state;
    1.84 +} vorbis_dsp_state;
    1.85 +
    1.86 +typedef struct vorbis_block{
    1.87 +  /* necessary stream state for linking to the framing abstraction */
    1.88 +  ogg_int32_t  **pcm;       /* this is a pointer into local storage */ 
    1.89 +  oggpack_buffer opb;
    1.90 +  
    1.91 +  long  lW;
    1.92 +  long  W;
    1.93 +  long  nW;
    1.94 +  int   pcmend;
    1.95 +  int   mode;
    1.96 +
    1.97 +  int         eofflag;
    1.98 +  ogg_int64_t granulepos;
    1.99 +  ogg_int64_t sequence;
   1.100 +  vorbis_dsp_state *vd; /* For read-only access of configuration */
   1.101 +
   1.102 +  /* local storage to avoid remallocing; it's up to the mapping to
   1.103 +     structure it */
   1.104 +  void               *localstore;
   1.105 +  long                localtop;
   1.106 +  long                localalloc;
   1.107 +  long                totaluse;
   1.108 +  struct alloc_chain *reap;
   1.109 +
   1.110 +} vorbis_block;
   1.111 +
   1.112 +/* vorbis_block is a single block of data to be processed as part of
   1.113 +the analysis/synthesis stream; it belongs to a specific logical
   1.114 +bitstream, but is independant from other vorbis_blocks belonging to
   1.115 +that logical bitstream. *************************************************/
   1.116 +
   1.117 +struct alloc_chain{
   1.118 +  void *ptr;
   1.119 +  struct alloc_chain *next;
   1.120 +};
   1.121 +
   1.122 +/* vorbis_info contains all the setup information specific to the
   1.123 +   specific compression/decompression mode in progress (eg,
   1.124 +   psychoacoustic settings, channel setup, options, codebook
   1.125 +   etc). vorbis_info and substructures are in backends.h.
   1.126 +*********************************************************************/
   1.127 +
   1.128 +/* the comments are not part of vorbis_info so that vorbis_info can be
   1.129 +   static storage */
   1.130 +typedef struct vorbis_comment{
   1.131 +  /* unlimited user comment fields.  libvorbis writes 'libvorbis'
   1.132 +     whatever vendor is set to in encode */
   1.133 +  char **user_comments;
   1.134 +  int   *comment_lengths;
   1.135 +  int    comments;
   1.136 +  char  *vendor;
   1.137 +
   1.138 +} vorbis_comment;
   1.139 +
   1.140 +
   1.141 +/* libvorbis encodes in two abstraction layers; first we perform DSP
   1.142 +   and produce a packet (see docs/analysis.txt).  The packet is then
   1.143 +   coded into a framed OggSquish bitstream by the second layer (see
   1.144 +   docs/framing.txt).  Decode is the reverse process; we sync/frame
   1.145 +   the bitstream and extract individual packets, then decode the
   1.146 +   packet back into PCM audio.
   1.147 +
   1.148 +   The extra framing/packetizing is used in streaming formats, such as
   1.149 +   files.  Over the net (such as with UDP), the framing and
   1.150 +   packetization aren't necessary as they're provided by the transport
   1.151 +   and the streaming layer is not used */
   1.152 +
   1.153 +/* Vorbis PRIMITIVES: general ***************************************/
   1.154 +
   1.155 +extern void     vorbis_info_init(vorbis_info *vi);
   1.156 +extern void     vorbis_info_clear(vorbis_info *vi);
   1.157 +extern int      vorbis_info_blocksize(vorbis_info *vi,int zo);
   1.158 +extern void     vorbis_comment_init(vorbis_comment *vc);
   1.159 +extern void     vorbis_comment_add(vorbis_comment *vc, char *comment); 
   1.160 +extern void     vorbis_comment_add_tag(vorbis_comment *vc, 
   1.161 +				       char *tag, char *contents);
   1.162 +extern char    *vorbis_comment_query(vorbis_comment *vc, char *tag, int count);
   1.163 +extern int      vorbis_comment_query_count(vorbis_comment *vc, char *tag);
   1.164 +extern void     vorbis_comment_clear(vorbis_comment *vc);
   1.165 +
   1.166 +extern int      vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb);
   1.167 +extern int      vorbis_block_clear(vorbis_block *vb);
   1.168 +extern void     vorbis_dsp_clear(vorbis_dsp_state *v);
   1.169 +
   1.170 +/* Vorbis PRIMITIVES: synthesis layer *******************************/
   1.171 +extern int      vorbis_synthesis_idheader(ogg_packet *op);
   1.172 +extern int      vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc,
   1.173 +					  ogg_packet *op);
   1.174 +
   1.175 +extern int      vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi);
   1.176 +extern int      vorbis_synthesis_restart(vorbis_dsp_state *v);
   1.177 +extern int      vorbis_synthesis(vorbis_block *vb,ogg_packet *op);
   1.178 +extern int      vorbis_synthesis_trackonly(vorbis_block *vb,ogg_packet *op);
   1.179 +extern int      vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb);
   1.180 +extern int      vorbis_synthesis_pcmout(vorbis_dsp_state *v,ogg_int32_t ***pcm);
   1.181 +extern int      vorbis_synthesis_read(vorbis_dsp_state *v,int samples);
   1.182 +extern long     vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op);
   1.183 +
   1.184 +/* Vorbis ERRORS and return codes ***********************************/
   1.185 +
   1.186 +#define OV_FALSE      -1  
   1.187 +#define OV_EOF        -2
   1.188 +#define OV_HOLE       -3
   1.189 +
   1.190 +#define OV_EREAD      -128
   1.191 +#define OV_EFAULT     -129
   1.192 +#define OV_EIMPL      -130
   1.193 +#define OV_EINVAL     -131
   1.194 +#define OV_ENOTVORBIS -132
   1.195 +#define OV_EBADHEADER -133
   1.196 +#define OV_EVERSION   -134
   1.197 +#define OV_ENOTAUDIO  -135
   1.198 +#define OV_EBADPACKET -136
   1.199 +#define OV_EBADLINK   -137
   1.200 +#define OV_ENOSEEK    -138
   1.201 +
   1.202 +#ifdef __cplusplus
   1.203 +}
   1.204 +#endif /* __cplusplus */
   1.205 +
   1.206 +#endif
   1.207 +

mercurial