summaryrefslogtreecommitdiff
path: root/include/vorbis
diff options
context:
space:
mode:
authorMonty <xiphmont@xiph.org>2000-01-05 03:11:12 +0000
committerMonty <xiphmont@xiph.org>2000-01-05 03:11:12 +0000
commit652d2ed76323192989fde63ef434e8392d16f7b8 (patch)
treea95bfb38b3321fc827d563053e27c90ef219614f /include/vorbis
parent80ccca876413fd0c8f3364197503d0c49a1742e6 (diff)
downloadlibvorbis-git-652d2ed76323192989fde63ef434e8392d16f7b8.tar.gz
More shuffling of includes to ease codebook integration. This breaks
the VQ build, but I'll fix that right away. Monty svn path=/trunk/vorbis/; revision=223
Diffstat (limited to 'include/vorbis')
-rw-r--r--include/vorbis/codebook.h80
-rw-r--r--include/vorbis/codec.h341
-rw-r--r--include/vorbis/internal.h84
-rw-r--r--include/vorbis/modes.h60
-rw-r--r--include/vorbis/vorbisfile.h86
5 files changed, 651 insertions, 0 deletions
diff --git a/include/vorbis/codebook.h b/include/vorbis/codebook.h
new file mode 100644
index 00000000..9132561d
--- /dev/null
+++ b/include/vorbis/codebook.h
@@ -0,0 +1,80 @@
+/********************************************************************
+ * *
+ * THIS FILE IS PART OF THE Ogg Vorbis SOFTWARE CODEC SOURCE CODE. *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
+ * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE. *
+ * PLEASE READ THESE TERMS DISTRIBUTING. *
+ * *
+ * THE OggSQUISH SOURCE CODE IS (C) COPYRIGHT 1994-2000 *
+ * by Monty <monty@xiph.org> and The XIPHOPHORUS Company *
+ * http://www.xiph.org/ *
+ * *
+ ********************************************************************
+
+ function: codebook types
+ last mod: $Id: codebook.h,v 1.1 2000/01/05 03:10:47 xiphmont Exp $
+
+ ********************************************************************/
+
+#ifndef _V_CODEBOOK_H_
+#define _V_CODEBOOK_H_
+
+/* This structure encapsulates huffman and VQ style encoding books; it
+ doesn't do anything specific to either.
+
+ valuelist/quantlist are nonNULL (and q_* significant) only if
+ there's entry->value mapping to be done.
+
+ If encode-side mapping must be done (and thus the entry needs to be
+ hunted), the auxiliary encode pointer will point to a decision
+ tree. This is true of both VQ and huffman, but is mostly useful
+ with VQ.
+
+*/
+
+typedef struct codebook{
+ long dim; /* codebook dimensions (elements per vector) */
+ long entries; /* codebook entries */
+
+ /* mapping */
+ long q_min; /* packed 24 bit float; quant value 0 maps to minval */
+ long q_delta; /* packed 24 bit float; val 1 - val 0 == delta */
+ int q_quant; /* 0 < quant <= 16 */
+ int q_sequencep; /* bitflag */
+
+ double *valuelist; /* list of dim*entries actual entry values */
+ long *quantlist; /* list of dim*entries quantized entry values */
+
+ /* actual codewords/lengths */
+ long *codelist; /* list of bitstream codewords for each entry */
+ long *lengthlist; /* codeword lengths in bits */
+
+ struct encode_aux *encode_tree;
+ struct decode_aux *decode_tree;
+
+} codebook;
+
+typedef struct encode_aux{
+ /* pre-calculated partitioning tree */
+ long *ptr0;
+ long *ptr1;
+
+ double *n; /* decision hyperplanes: sum(x_i*n_i)[0<=i<dim]=c */
+ double *c; /* decision hyperplanes: sum(x_i*n_i)[0<=i<dim]=c */
+ long *p; /* decision points (each is an entry) */
+ long *q; /* decision points (each is an entry) */
+ long aux; /* number of tree entries */
+ long alloc;
+} encode_aux;
+
+typedef struct decode_aux{
+ long *ptr0;
+ long *ptr1;
+} decode_aux;
+
+#endif
+
+
+
+
+
diff --git a/include/vorbis/codec.h b/include/vorbis/codec.h
new file mode 100644
index 00000000..bb521202
--- /dev/null
+++ b/include/vorbis/codec.h
@@ -0,0 +1,341 @@
+/********************************************************************
+ * *
+ * THIS FILE IS PART OF THE Ogg Vorbis SOFTWARE CODEC SOURCE CODE. *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
+ * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE. *
+ * PLEASE READ THESE TERMS DISTRIBUTING. *
+ * *
+ * THE OggSQUISH SOURCE CODE IS (C) COPYRIGHT 1994-2000 *
+ * by Monty <monty@xiph.org> and The XIPHOPHORUS Company *
+ * http://www.xiph.org/ *
+ * *
+ ********************************************************************
+
+ function: libvorbis codec headers
+ last mod: $Id: codec.h,v 1.1 2000/01/05 03:10:47 xiphmont Exp $
+
+ ********************************************************************/
+
+#ifndef _vorbis_codec_h_
+#define _vorbis_codec_h_
+
+#include <sys/types.h> /* get BSD style 16/32/64 bit types */
+
+/* if no BSD width types, get them from the configure script */
+#ifndef int64_t
+# define int64_t size64
+#endif
+#ifndef int32_t
+# define int32_t size32
+#endif
+#ifndef int16_t
+# define int16_t size16
+#endif
+
+#include "vorbis/codebook.h"
+#include "vorbis/internal.h"
+
+/* vobis_info contains all the setup information specific to the specific
+ compression/decompression mode in progress (eg, psychoacoustic settings,
+ channel setup, options, codebook etc) *********************************/
+
+#define MAX_BARK 27
+
+typedef struct vorbis_info{
+ int channels;
+ long rate;
+ int version;
+
+ /* The below bitrate declarations are *hints*.
+ Combinations of the three values carry the following implications:
+
+ all three set to the same value:
+ implies a fixed rate bitstream
+ only nominal set:
+ implies a VBR stream that averages the nominal bitrate. No hard
+ upper/lower limit
+ upper and or lower set:
+ implies a VBR bitstream that obeys the bitrate limits. nominal
+ may also be set to give a nominal rate.
+ none set:
+ the coder does not care to speculate.
+ */
+
+ long bitrate_upper;
+ long bitrate_nominal;
+ long bitrate_lower;
+
+ char **user_comments;
+ int comments;
+ char *vendor;
+
+ int blocksize[2];
+ int floororder[2];
+ int floormap[2];
+
+ int floorch;
+
+ /* int smallblock;
+ int largeblock;
+ int floororder;
+ int flooroctaves;
+ int floorch;*/
+
+ /* no mapping, coupling, balance yet. */
+
+ /*int balanceorder;
+ int balanceoctaves;
+ this would likely need to be by channel and blocksize anyway*/
+
+ /* Encode-side settings for analysis */
+
+ int envelopesa;
+ double preecho_thresh;
+ double preecho_clamp;
+
+ double maskthresh[MAX_BARK];
+ double lrolldB;
+ double hrolldB;
+
+ /* local storage, only used on the encoding size. This way the
+ application does not need to worry about freeing some packets'
+ memory and not others'. Packet storage is always tracked */
+ char *header;
+ char *header1;
+ char *header2;
+
+} vorbis_info;
+
+/* ogg_page is used to encapsulate the data in one Ogg bitstream page *****/
+
+typedef struct {
+ unsigned char *header;
+ long header_len;
+ unsigned char *body;
+ long body_len;
+} ogg_page;
+
+/* ogg_stream_state contains the current encode/decode state of a logical
+ Ogg bitstream **********************************************************/
+
+typedef struct {
+ unsigned char *body_data; /* bytes from packet bodies */
+ long body_storage; /* storage elements allocated */
+ long body_fill; /* elements stored; fill mark */
+ long body_returned; /* elements of fill returned */
+
+
+ int *lacing_vals; /* The values that will go to the segment table */
+ int64_t *pcm_vals; /* pcm_pos values for headers. Not compact
+ this way, but it is simple coupled to the
+ lacing fifo */
+ long lacing_storage;
+ long lacing_fill;
+ long lacing_packet;
+ long lacing_returned;
+
+ unsigned char header[282]; /* working space for header encode */
+ int header_fill;
+
+ int e_o_s; /* set when we have buffered the last packet in the
+ logical bitstream */
+ int b_o_s; /* set after we've written the initial page
+ of a logical bitstream */
+ long serialno;
+ long pageno;
+ long packetno; /* sequence number for decode; the framing
+ knows where there's a hole in the data,
+ but we need coupling so that the codec
+ (which is in a seperate abstraction
+ layer) also knows about the gap */
+ int64_t pcmpos;
+
+} ogg_stream_state;
+
+/* ogg_packet is used to encapsulate the data and metadata belonging
+ to a single raw Ogg/Vorbis packet *************************************/
+
+typedef struct {
+ unsigned char *packet;
+ long bytes;
+ long b_o_s;
+ long e_o_s;
+
+ int64_t frameno;
+ long packetno; /* sequence number for decode; the framing
+ knows where there's a hole in the data,
+ but we need coupling so that the codec
+ (which is in a seperate abstraction
+ layer) also knows about the gap */
+
+} ogg_packet;
+
+typedef struct {
+ unsigned char *data;
+ int storage;
+ int fill;
+ int returned;
+
+ int unsynced;
+ int headerbytes;
+ int bodybytes;
+} ogg_sync_state;
+
+/* vorbis_dsp_state buffers the current vorbis audio
+ analysis/synthesis state. The DSP state belongs to a specific
+ logical bitstream ****************************************************/
+
+typedef struct vorbis_dsp_state{
+ int analysisp;
+ vorbis_info *vi;
+
+ double *window[2][2][2]; /* windowsize, leadin, leadout */
+ envelope_lookup ve;
+ mdct_lookup vm[2];
+ lpc_lookup vl[2];
+ lpc_lookup vbal[2];
+ psy_lookup vp[2];
+
+ double **pcm;
+ double **pcmret;
+ int pcm_storage;
+ int pcm_current;
+ int pcm_returned;
+
+ double *multipliers;
+ int envelope_storage;
+ int envelope_current;
+
+ int eofflag;
+
+ long lW;
+ long W;
+ long nW;
+ long centerW;
+
+ long frameno;
+ long sequence;
+
+ int64_t gluebits;
+ int64_t time_envelope_bits;
+ int64_t spectral_envelope_bits;
+ int64_t spectral_residue_bits;
+
+} vorbis_dsp_state;
+
+/* vorbis_block is a single block of data to be processed as part of
+the analysis/synthesis stream; it belongs to a specific logical
+bitstream, but is independant from other vorbis_blocks belonging to
+that logical bitstream. *************************************************/
+
+typedef struct vorbis_block{
+ double **pcm;
+ double **lpc;
+ double **lsp;
+ double *amp;
+ oggpack_buffer opb;
+
+ int pcm_channels; /* allocated, not used */
+ int pcm_storage; /* allocated, not used */
+ int floor_channels;
+ int floor_storage;
+
+ long lW;
+ long W;
+ long nW;
+ int pcmend;
+
+ int eofflag;
+ int frameno;
+ int sequence;
+ vorbis_dsp_state *vd; /* For read-only access of configuration */
+
+ long gluebits;
+ long time_envelope_bits;
+ long spectral_envelope_bits;
+ long spectral_residue_bits;
+
+} vorbis_block;
+
+/* libvorbis encodes in two abstraction layers; first we perform DSP
+ and produce a packet (see docs/analysis.txt). The packet is then
+ coded into a framed OggSquish bitstream by the second layer (see
+ docs/framing.txt). Decode is the reverse process; we sync/frame
+ the bitstream and extract individual packets, then decode the
+ packet back into PCM audio.
+
+ The extra framing/packetizing is used in streaming formats, such as
+ files. Over the net (such as with UDP), the framing and
+ packetization aren't necessary as they're provided by the transport
+ and the streaming layer is not used */
+
+/* OggSquish BITSREAM PRIMITIVES: encoding **************************/
+
+extern int ogg_stream_packetin(ogg_stream_state *os, ogg_packet *op);
+extern int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og);
+
+/* OggSquish BITSREAM PRIMITIVES: decoding **************************/
+
+extern int ogg_sync_init(ogg_sync_state *oy);
+extern int ogg_sync_clear(ogg_sync_state *oy);
+extern int ogg_sync_destroy(ogg_sync_state *oy);
+extern int ogg_sync_reset(ogg_sync_state *oy);
+
+extern char *ogg_sync_buffer(ogg_sync_state *oy, long size);
+extern int ogg_sync_wrote(ogg_sync_state *oy, long bytes);
+extern long ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og);
+extern int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og);
+extern int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og);
+extern int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op);
+
+/* OggSquish BITSREAM PRIMITIVES: general ***************************/
+
+extern int ogg_stream_init(ogg_stream_state *os,int serialno);
+extern int ogg_stream_clear(ogg_stream_state *os);
+extern int ogg_stream_reset(ogg_stream_state *os,long expected_pageno);
+extern int ogg_stream_destroy(ogg_stream_state *os);
+extern int ogg_stream_eof(ogg_stream_state *os);
+
+extern int ogg_page_version(ogg_page *og);
+extern int ogg_page_continued(ogg_page *og);
+extern int ogg_page_bos(ogg_page *og);
+extern int ogg_page_eos(ogg_page *og);
+extern int64_t ogg_page_frameno(ogg_page *og);
+extern int ogg_page_serialno(ogg_page *og);
+extern int ogg_page_pageno(ogg_page *og);
+
+/* Vorbis PRIMITIVES: general ***************************************/
+
+extern void vorbis_dsp_clear(vorbis_dsp_state *v);
+
+extern void vorbis_info_init(vorbis_info *vi);
+extern void vorbis_info_clear(vorbis_info *vi);
+extern int vorbis_info_modeset(vorbis_info *vi, int mode);
+extern int vorbis_info_addcomment(vorbis_info *vi, char *comment);
+extern int vorbis_info_headerin(vorbis_info *vi,ogg_packet *op);
+extern int vorbis_info_headerout(vorbis_info *vi,
+ ogg_packet *op,
+ ogg_packet *op_comm,
+ ogg_packet *op_code);
+
+extern int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb);
+extern int vorbis_block_clear(vorbis_block *vb);
+
+/* Vorbis PRIMITIVES: analysis/DSP layer ****************************/
+extern int vorbis_analysis_init(vorbis_dsp_state *v,vorbis_info *vi);
+
+extern double **vorbis_analysis_buffer(vorbis_dsp_state *v,int vals);
+extern int vorbis_analysis_wrote(vorbis_dsp_state *v,int vals);
+extern int vorbis_analysis_blockout(vorbis_dsp_state *v,vorbis_block *vb);
+extern int vorbis_analysis(vorbis_block *vb,ogg_packet *op);
+
+/* Vorbis PRIMITIVES: synthesis layer *******************************/
+extern int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi);
+
+extern int vorbis_synthesis(vorbis_block *vb,ogg_packet *op);
+extern int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb);
+extern int vorbis_synthesis_pcmout(vorbis_dsp_state *v,double ***pcm);
+extern int vorbis_synthesis_read(vorbis_dsp_state *v,int samples);
+
+#endif
+
diff --git a/include/vorbis/internal.h b/include/vorbis/internal.h
new file mode 100644
index 00000000..b81874b3
--- /dev/null
+++ b/include/vorbis/internal.h
@@ -0,0 +1,84 @@
+/********************************************************************
+ * *
+ * THIS FILE IS PART OF THE Ogg Vorbis SOFTWARE CODEC SOURCE CODE. *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
+ * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE. *
+ * PLEASE READ THESE TERMS DISTRIBUTING. *
+ * *
+ * THE OggSQUISH SOURCE CODE IS (C) COPYRIGHT 1994-2000 *
+ * by Monty <monty@xiph.org> and The XIPHOPHORUS Company *
+ * http://www.xiph.org/ *
+ * *
+ ********************************************************************
+
+ function: libvorbis codec internal types. These structures are
+ 'visible', but generally uninteresting to the developer
+ last mod: $Id: internal.h,v 1.1 2000/01/05 03:10:47 xiphmont Exp $
+
+ ********************************************************************/
+
+#ifndef _vorbis_internal_h_
+#define _vorbis_internal_h_
+
+/* lookup structures for various simple transforms *****************/
+
+typedef struct {
+ int n;
+ struct vorbis_info *vi;
+
+ double *maskthresh;
+ double *barknum;
+
+} psy_lookup;
+
+typedef struct {
+ int n;
+ int log2n;
+
+ double *trig;
+ int *bitrev;
+
+} mdct_lookup;
+
+typedef struct {
+ int n;
+ double *trigcache;
+ int *splitcache;
+} drft_lookup;
+
+typedef struct {
+ int winlen;
+ double *window;
+ mdct_lookup mdct;
+} envelope_lookup;
+
+typedef struct lpclook{
+ /* en/decode lookups */
+ int *linearmap;
+ double *barknorm;
+ drft_lookup fft;
+
+ int n;
+ int ln;
+ int m;
+
+} lpc_lookup;
+
+/* structures for various internal data abstractions ********************/
+
+typedef struct {
+ long endbyte;
+ int endbit;
+
+ unsigned char *buffer;
+ unsigned char *ptr;
+ long storage;
+
+} oggpack_buffer;
+
+#endif
+
+
+
+
+
diff --git a/include/vorbis/modes.h b/include/vorbis/modes.h
new file mode 100644
index 00000000..62fc98c5
--- /dev/null
+++ b/include/vorbis/modes.h
@@ -0,0 +1,60 @@
+/********************************************************************
+ * *
+ * THIS FILE IS PART OF THE Ogg Vorbis SOFTWARE CODEC SOURCE CODE. *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
+ * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE. *
+ * PLEASE READ THESE TERMS DISTRIBUTING. *
+ * *
+ * THE OggSQUISH SOURCE CODE IS (C) COPYRIGHT 1994-2000 *
+ * by Monty <monty@xiph.org> and The XIPHOPHORUS Company *
+ * http://www.xiph.org/ *
+ * *
+ ********************************************************************
+
+ function: predefined encoding modes
+ last mod: $Id: modes.h,v 1.1 2000/01/05 03:10:47 xiphmont Exp $
+
+ ********************************************************************/
+
+#ifndef _V_MODES_H_
+#define _V_MODES_H_
+
+#include <stdio.h>
+#include "vorbis/codec.h"
+
+/*
+ 0 1 2 3 4 5 6 7 8 9
+ 0, 100, 200, 300, 400, 510, 630, 770, 920, 1080,
+
+ 10 11 12 13 14 15 16 17 18 19
+ 1270, 1480, 1720, 2000, 2320, 2700, 3150, 3700, 4400, 5300,
+
+ 20 21 22 23 24 25 26 Bark
+ 6400, 7700, 9500, 12000, 15500, 20500, 27000 Hz */
+
+vorbis_info predef_modes[]={
+ /* CD quality stereo, no channel coupling */
+
+ /* channels, sample rate, upperkbps, nominalkbps, lowerkbps */
+ { 2, 44100, 0,0,0,
+ /* dummy, dummy, dummy, dummy */
+ 0, NULL, 0, NULL,
+ /* smallblock, largeblock, LPC order (small, large) */
+ {256, 2048}, {20,32},
+ /* {bark mapping size}, spectral channels */
+ {64,256}, 2,
+ /* thresh sample period, preecho clamp trigger threshhold, range, dummy */
+ 64, 10, 2,
+ /* tone masking curve dB attenuation levels [27] */
+ { -10, -10, -10, -10, -10, -10, -10, -10, -10, -10,
+ -12, -14, -16, -16, -16, -16, -18, -18, -16, -16,
+ -12, -10, -8, -6, -6, -6, -4},
+ /* tone masking rolloff settings (dB per octave), octave bias */
+ 24,10,
+ NULL,NULL,NULL},
+
+};
+
+#define predef_mode_max 0
+
+#endif
diff --git a/include/vorbis/vorbisfile.h b/include/vorbis/vorbisfile.h
new file mode 100644
index 00000000..854e5078
--- /dev/null
+++ b/include/vorbis/vorbisfile.h
@@ -0,0 +1,86 @@
+/********************************************************************
+ * *
+ * THIS FILE IS PART OF THE Ogg Vorbis SOFTWARE CODEC SOURCE CODE. *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
+ * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE. *
+ * PLEASE READ THESE TERMS DISTRIBUTING. *
+ * *
+ * THE OggSQUISH SOURCE CODE IS (C) COPYRIGHT 1994-2000 *
+ * by Monty <monty@xiph.org> and The XIPHOPHORUS Company *
+ * http://www.xiph.org/ *
+ * *
+ ********************************************************************
+
+ function: stdio-based convenience library for opening/seeking/decoding
+ last mod: $Id: vorbisfile.h,v 1.1 2000/01/05 03:10:47 xiphmont Exp $
+
+ ********************************************************************/
+
+#ifndef _OV_FILE_H_
+#define _OV_FILE_H_
+
+#include <stdio.h>
+#include "codec.h"
+
+typedef struct {
+ FILE *f;
+ int seekable;
+ long offset;
+ long end;
+ ogg_sync_state oy;
+
+ /* If the FILE handle isn't seekable (eg, a pipe), only the current
+ stream appears */
+ int links;
+ long *offsets;
+ long *dataoffsets;
+ long *serialnos;
+ int64_t *pcmlengths;
+ vorbis_info *vi;
+
+ /* Decoding working state local storage */
+ int64_t pcm_offset;
+ int decode_ready;
+ long current_serialno;
+ int current_link;
+
+ ogg_stream_state os; /* take physical pages, weld into a logical
+ stream of packets */
+ vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
+ vorbis_block vb; /* local working space for packet->PCM decode */
+
+} OggVorbis_File;
+
+extern int ov_clear(OggVorbis_File *vf);
+extern int ov_open(FILE *f,OggVorbis_File *vf,char *initial,long ibytes);
+
+extern long ov_bitrate(OggVorbis_File *vf,int i);
+extern long ov_streams(OggVorbis_File *vf);
+extern long ov_seekable(OggVorbis_File *vf);
+extern long ov_serialnumber(OggVorbis_File *vf,int i);
+
+extern long ov_raw_total(OggVorbis_File *vf,int i);
+extern int64_t ov_pcm_total(OggVorbis_File *vf,int i);
+extern double ov_time_total(OggVorbis_File *vf,int i);
+
+extern int ov_raw_seek(OggVorbis_File *vf,long pos);
+extern int ov_pcm_seek(OggVorbis_File *vf,int64_t pos);
+extern int ov_time_seek(OggVorbis_File *vf,double pos);
+
+extern long ov_raw_tell(OggVorbis_File *vf);
+extern int64_t ov_pcm_tell(OggVorbis_File *vf);
+extern double ov_time_tell(OggVorbis_File *vf);
+
+extern vorbis_info *ov_info(OggVorbis_File *vf,int link);
+
+extern long ov_read(OggVorbis_File *vf,char *buffer,int length,
+ int bigendianp,int word,int sgned,int *bitstream);
+
+#endif
+
+
+
+
+
+
+