building clean again.
Monty
svn path=/trunk/vorbis/; revision=247
********************************************************************
function: simple example decoder
- last mod: $Id: decoder_example.c,v 1.4 2000/01/22 13:28:08 xiphmont Exp $
+ last mod: $Id: decoder_example.c,v 1.5 2000/01/28 15:25:06 xiphmont Exp $
********************************************************************/
vorbis_info vi; /* struct that stores all the static vorbis bitstream
settings */
+ vorbis_comment vc; /* struct that stores all the bitstream user comments */
vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
vorbis_block vb; /* local working space for packet->PCM decode */
useful to see that functionality seperated out. */
vorbis_info_init(&vi);
+ vorbis_comment_init(&vc);
if(ogg_stream_pagein(&os,&og)<0){
/* error; stream version mismatch perhaps */
fprintf(stderr,"Error reading first page of Ogg bitstream data.\n");
exit(1);
}
- if(vorbis_info_headerin(&vi,&op)<0){
+ if(vorbis_synthesis_headerin(&vi,&vc,&op)<0){
/* error case; not a vorbis header */
fprintf(stderr,"This Ogg bitstream does not contain Vorbis "
"audio data.\n");
We can't tolerate that in a header. Die. */
fprintf(stderr,"Corrupt secondary header. Exiting.\n");
exit(1);
- }
- vorbis_info_headerin(&vi,&op);
+ }
+ vorbis_synthesis_headerin(&vi,&vc,&op);
i++;
}
}
/* Throw the comments plus a few lines about the bitstream we're
decoding */
{
- char **ptr=vi.user_comments;
+ char **ptr=vc.user_comments;
while(*ptr){
fprintf(stderr,"%s\n",*ptr);
++ptr;
}
fprintf(stderr,"\nBitstream is %d channel, %ldHz\n",vi.channels,vi.rate);
- fprintf(stderr,"Encoded by: %s\n\n",vi.vendor);
+ fprintf(stderr,"Encoded by: %s\n\n",vc.vendor);
}
convsize=4096/vi.channels;
********************************************************************
function: simple example encoder
- last mod: $Id: encoder_example.c,v 1.5 2000/01/28 09:04:58 xiphmont Exp $
+ last mod: $Id: encoder_example.c,v 1.6 2000/01/28 15:25:07 xiphmont Exp $
********************************************************************/
#include <stdlib.h>
#include <time.h>
#include <math.h>
-#include "vorbis/codec.h"
+#include "vorbis/modes.h"
#define READ 1024
signed char readbuffer[READ*4+44]; /* out of the data segment, not the stack */
ogg_page og; /* one Ogg bitstream page. Vorbis packets are inside */
ogg_packet op; /* one raw packet of data for decode */
- vorbis_info vi; /* struct that stores all the static vorbis bitstream
+ vorbis_info *vi; /* struct that stores all the static vorbis bitstream
settings */
vorbis_comment vc; /* struct that stores all the user comments */
- settings */
+
vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
vorbis_block vb; /* local working space for packet->PCM decode */
/* choose an encoding mode */
/* (mode 0: 44kHz stereo uncoupled, roughly 128kbps VBR) */
- vorbis_info_modeset(&vi,0);
+ vi=&info_A;
/* add a comment */
- vorbis_info_addcomment(&vi,"Track encoded by encoder_example.c");
+ vorbis_comment_init(&vc);
+ vorbis_comment_add(&vc,"Track encoded by encoder_example.c");
/* set up the analysis state and auxiliary encoding storage */
- vorbis_analysis_init(&vd,&vi);
+ vorbis_analysis_init(&vd,vi);
vorbis_block_init(&vd,&vb);
/* set up our packet->stream encoder */
ogg_packet header_comm;
ogg_packet header_code;
- vorbis_info_headerout(&vi,&header,&header_comm,&header_code);
+ vorbis_analysis_headerout(&vd,&vc,&header,&header_comm,&header_code);
ogg_stream_packetin(&os,&header); /* automatically placed in its own
page */
ogg_stream_packetin(&os,&header_comm);
ogg_stream_clear(&os);
vorbis_block_clear(&vb);
vorbis_dsp_clear(&vd);
- vorbis_info_clear(&vi);
/* ogg_page and ogg_packet structs always point to storage in
libvorbis. They're never freed or manipulated directly */
********************************************************************
function: predefined encoding modes
- last mod: $Id: modes.h,v 1.3 2000/01/28 14:31:24 xiphmont Exp $
+ last mod: $Id: modes.h,v 1.4 2000/01/28 15:25:08 xiphmont Exp $
********************************************************************/
#include <stdio.h>
#include "vorbis/codec.h"
#include "vorbis/backends.h"
-#include "vorbis/book/lsp20_0.h"
-#include "vorbis/book/lsp32_0.h"
+#include "vorbis/book/lsp20_0.vqh"
+#include "vorbis/book/lsp32_0.vqh"
/*
0 1 2 3 4 5 6 7 8 9
};
/* with GNUisms, this could be short and readable. Oh well */
-static static_codebook *_book_vec0[2]={&_vq_book_lsp20_0,&_vq_book_lsp32_0};
static vorbis_info_time0 _time_set0={0};
static vorbis_info_floor0 _floor_set0={20, 44100, 64, 1, {0} };
static vorbis_info_floor0 _floor_set1={32, 44100, 256, 1, {1} };
static vorbis_info_residue0 _residue_set0={0,0};
static vorbis_info_mapping0 _mapping_set0={1, {0,0}, {0}, {0}, {0}, {0}};
static vorbis_info_mapping0 _mapping_set1={1, {0,0}, {0}, {1}, {0}, {0}};
-static vorbis_info mode _mode_set0={0,0,0,0};
-static vorbis_info mode _mode_set1={1,0,0,1};
-
-static vorbis_info_time *_time_A[1]={&_time_set0};
-static vorbis_info_floor *_floor_A[2]={&_floor_set0,&_floor_set1};
-static vorbis_info_residue *_res_A[1]={&_residue_set0};
-static vorbis_info_psy *_psy_A[1]={&_psy_set0};
-static vorbis_info_mode *_mode_A[2]=
-
+static vorbis_info_mode _mode_set0={0,0,0,0};
+static vorbis_info_mode _mode_set1={1,0,0,1};
/* CD quality stereo, no channel coupling */
vorbis_info info_A={
- {
- /* channels, sample rate, upperkbps, nominalkbps, lowerkbps */
- 2, 44100, 0,0,0,
- /* smallblock, largeblock */
- {256, 2048},
- /* modes,maps,times,floors,residues,books,psys */
- 2, 2, 1, 2, 2, 2, 1,
- /* modes */
- {&_mode_set0,&mode_set1},
- /* maps */
- {0,0},{&_mapping_set0,&_mapping_set1},
- /* times */
- {0,0},{&_time_set0},
- /* floors */
- {0,0},{&_floor_set0,&_floor_set1},
- /* residue */
- {0,0},{&_residue_set0},
- /* books */
- {&_vq_book_lsp20_0,&_vq_book_lsp32_0},
- /* psy */
- {&_psy_set0},
- /* thresh sample period, preecho clamp trigger threshhold, range */
- 64, 10, 2
- }
+ /* channels, sample rate, upperkbps, nominalkbps, lowerkbps */
+ 0, 2, 44100, 0,0,0,
+ /* smallblock, largeblock */
+ {256, 2048},
+ /* modes,maps,times,floors,residues,books,psys */
+ 2, 2, 1, 2, 2, 2, 1,
+ /* modes */
+ {&_mode_set0,&_mode_set1},
+ /* maps */
+ {0,0},{&_mapping_set0,&_mapping_set1},
+ /* times */
+ {0,0},{&_time_set0},
+ /* floors */
+ {0,0},{&_floor_set0,&_floor_set1},
+ /* residue */
+ {0,0},{&_residue_set0},
+ /* books */
+ {&_vq_book_lsp20_0,&_vq_book_lsp32_0},
+ /* psy */
+ {&_psy_set0},
+ /* thresh sample period, preecho clamp trigger threshhold, range */
+ 64, 10, 2
};
#define PREDEF_INFO_MAX 0
********************************************************************
function: channel mapping 0 implementation
- last mod: $Id: mapping0.c,v 1.5 2000/01/28 14:34:44 xiphmont Exp $
+ last mod: $Id: mapping0.c,v 1.6 2000/01/28 15:25:09 xiphmont Exp $
********************************************************************/
} vorbis_look_mapping0;
-void free_info(vorbis_info_mapping *i){
+static void free_info(vorbis_info_mapping *i){
if(i){
memset(i,0,sizeof(vorbis_info_mapping0));
free(i);
}
}
-void free_look(vorbis_look_mapping *look){
+static void free_look(vorbis_look_mapping *look){
int i;
vorbis_look_mapping0 *l=(vorbis_look_mapping0 *)look;
if(l){
}
}
-vorbis_look_mapping *look(vorbis_info *vi,vorbis_info_mode *vm,
+static vorbis_look_mapping *look(vorbis_info *vi,vorbis_info_mode *vm,
vorbis_info_mapping *m){
int i;
vorbis_look_mapping0 *ret=calloc(1,sizeof(vorbis_look_mapping0));
return(ret);
}
-void pack(vorbis_info *vi,vorbis_info_mapping *vm,oggpack_buffer *opb){
+static void pack(vorbis_info *vi,vorbis_info_mapping *vm,oggpack_buffer *opb){
int i;
vorbis_info_mapping0 *d=(vorbis_info_mapping0 *)vm;
}
/* also responsible for range checking */
-vorbis_info_mapping *unpack(vorbis_info *vi,oggpack_buffer *opb){
+static vorbis_info_mapping *unpack(vorbis_info *vi,oggpack_buffer *opb){
int i;
vorbis_info_mapping0 *d=calloc(1,sizeof(vorbis_info_mapping0));
memset(d,0,sizeof(vorbis_info_mapping0));
#include "spectrum.h"
/* no time mapping implementation for now */
-int forward(vorbis_block *vb,vorbis_look_mapping *l){
+static int forward(vorbis_block *vb,vorbis_look_mapping *l){
vorbis_dsp_state *vd=vb->vd;
vorbis_info *vi=vd->vi;
vorbis_look_mapping0 *look=(vorbis_look_mapping0 *)l;
return(0);
}
-int inverse(vorbis_block *vb,vorbis_look_mapping *l){
+static int inverse(vorbis_block *vb,vorbis_look_mapping *l){
vorbis_dsp_state *vd=vb->vd;
vorbis_info *vi=vd->vi;
vorbis_look_mapping0 *look=(vorbis_look_mapping0 *)l;
return(0);
}
+/* export hooks */
+vorbis_func_mapping mapping0_exportbundle={
+ &pack,&unpack,&look,&free_info,&free_look,&forward,&inverse
+};
+
+
********************************************************************
function: psychoacoustics not including preecho
- last mod: $Id: psy.c,v 1.13 2000/01/28 09:05:14 xiphmont Exp $
+ last mod: $Id: psy.c,v 1.14 2000/01/28 15:25:10 xiphmont Exp $
********************************************************************/
}
}
+void _vi_psy_free(vorbis_info_psy *i){
+ if(i){
+ memset(i,0,sizeof(vorbis_info_psy));
+ free(i);
+ }
+}
********************************************************************
function: random psychoacoustics (not including preecho)
- last mod: $Id: psy.h,v 1.7 2000/01/28 09:05:15 xiphmont Exp $
+ last mod: $Id: psy.h,v 1.8 2000/01/28 15:25:11 xiphmont Exp $
********************************************************************/
extern void _vp_psy_init(vorbis_look_psy *p,vorbis_info_psy *vi,int n,long rate);
extern void _vp_psy_clear(vorbis_look_psy *p);
extern void *_vi_psy_dup(void *source);
-extern void _vi_psy_free(void *i);
+extern void _vi_psy_free(vorbis_info_psy *i);
extern void _vp_mask_floor(vorbis_look_psy *p,double *pcm,
double *mask,double *floor);
********************************************************************
function: window functions
- last mod: $Id: window.c,v 1.4 2000/01/22 13:28:36 xiphmont Exp $
+ last mod: $Id: window.c,v 1.5 2000/01/28 15:25:12 xiphmont Exp $
********************************************************************/
#include <math.h>
#include "os.h"
-double *vorbis_window(int type, int window,int left,int right){
+double *_vorbis_window(int type, int window,int left,int right){
double *ret=calloc(window,sizeof(double));
switch(type){