function: libvorbis backend and mapping structures; needed for
static mode headers
- last mod: $Id: backends.h,v 1.3 2000/01/28 09:04:59 xiphmont Exp $
+ last mod: $Id: backends.h,v 1.4 2000/01/28 14:31:22 xiphmont Exp $
********************************************************************/
int order;
long rate;
long barkmap;
- int stages;
- int *books;
+ int stages; /* <= 16 */
+ int books[16];
} vorbis_info_floor0;
/* Residue backend generic *****************************************/
long end;
/* way unfinished, just so you know while poking around CVS ;-) */
- int stages;
- int *books;
+
} vorbis_info_residue0;
/* Mapping backend generic *****************************************/
} vorbis_func_mapping;
typedef struct vorbis_info_mapping0{
- int submaps;
- int *chmuxlist;
+ int submaps; /* <= 16 */
+ int chmuxlist[256]; /* up to 256 channels in a Vorbis stream */
- int *timesubmap; /* [mux] */
- int *floorsubmap; /* [mux] submap to floors */
- int *residuesubmap; /* [mux] submap to residue */
- int *psysubmap; /* [mux]; encode only */
+ int timesubmap[16]; /* [mux] */
+ int floorsubmap[16]; /* [mux] submap to floors */
+ int residuesubmap[16]; /* [mux] submap to residue */
+ int psysubmap[16]; /* [mux]; encode only */
} vorbis_info_mapping0;
#endif
********************************************************************
function: libvorbis codec headers
- last mod: $Id: codec.h,v 1.6 2000/01/28 09:05:01 xiphmont Exp $
+ last mod: $Id: codec.h,v 1.7 2000/01/28 14:31:23 xiphmont Exp $
********************************************************************/
int books;
int psys; /* encode only */
- vorbis_info_mode **mode_param;
- int *map_type;
- vorbis_info_mapping **map_param;
- int *time_type;
- vorbis_info_time **time_param;
- int *floor_type;
- vorbis_info_floor **floor_param;
- int *residue_type;
- vorbis_info_residue **residue_param;
- static_codebook **book_param;
- vorbis_info_psy **psy_param; /* encode only */
+ vorbis_info_mode *mode_param[64];
+ int map_type[64];
+ vorbis_info_mapping *map_param[64];
+ int time_type[64];
+ vorbis_info_time *time_param[64];
+ int floor_type[64];
+ vorbis_info_floor *floor_param[64];
+ int residue_type[64];
+ vorbis_info_residue *residue_param[64];
+ static_codebook *book_param[256];
+ vorbis_info_psy *psy_param[64]; /* encode only */
/* for block long/sort tuning; encode only */
int envelopesa;
********************************************************************
function: predefined encoding modes
- last mod: $Id: modes.h,v 1.2 2000/01/12 11:34:38 xiphmont Exp $
+ last mod: $Id: modes.h,v 1.3 2000/01/28 14:31:24 xiphmont Exp $
********************************************************************/
#include <stdio.h>
#include "vorbis/codec.h"
-#include "vorbis/book/lsp20_0a.h"
-#include "vorbis/book/lsp20_0b.h"
-#include "vorbis/book/lsp32_0a.h"
-#include "vorbis/book/lsp32_0b.h"
-
-static int _intvector_0_15[]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
-static *codebook _bookvector0[4]={_vq_book_lsp20_0a,_vq_book_lsp20_0b,
- _vq_book_lsp32_0a,_vq_book_lsp32_0b};
+#include "vorbis/backends.h"
+#include "vorbis/book/lsp20_0.h"
+#include "vorbis/book/lsp32_0.h"
/*
0 1 2 3 4 5 6 7 8 9
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 */
+/* a good set of rolloffs for nigh-transparent masking */
+static vorbis_info_psy _psy_set0={
+ { -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}, 24,10
+};
+/* 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]=
+
+
+/* CD quality stereo, no channel coupling */
+vorbis_info info_A={
+ {
/* channels, sample rate, upperkbps, nominalkbps, lowerkbps */
- { 2, 44100, 0,0,0,
- /* dummy, dummy, dummy, dummy */
- NULL, 0, NULL,
+ 2, 44100, 0,0,0,
/* smallblock, largeblock */
{256, 2048},
-
- /* LSP/LPC order (small, large), LPC bark mapping size, floor channels */
- {20,32}, {64,256}, 2,
- /* LSP encoding */
- 2, _intvector_0_15, 2, _intvector_0_15+2,
-
- /* channel mapping. Right now, no balance, no coupling */
- {0,0},
-
- /* residue encoding */
-
- /* codebooks */
- _bookvector0, 4,
-
- /* 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},
-
+ /* 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_mode_max 0
+#define PREDEF_INFO_MAX 0
#endif
********************************************************************
function: floor backend 0 implementation
- last mod: $Id: floor0.c,v 1.3 2000/01/28 09:05:09 xiphmont Exp $
+ last mod: $Id: floor0.c,v 1.4 2000/01/28 14:31:25 xiphmont Exp $
********************************************************************/
#include "registry.h"
static void free_info(vorbis_info_floor *i){
- vorbis_info_floor0 *d=(vorbis_info_floor0 *)i;
- if(d){
- if(d->books)free(d->books);
+ if(i){
memset(i,0,sizeof(vorbis_info_floor0));
+ free(i);
}
}
static void free_look(vorbis_look_floor *i){
_oggpack_write(opb,d->order,8);
_oggpack_write(opb,d->rate,16);
_oggpack_write(opb,d->barkmap,16);
- _oggpack_write(opb,d->stages,8);
+ _oggpack_write(opb,d->stages,4);
for(j=0;j<d->stages;j++)
_oggpack_write(opb,d->books[j],8);
}
d->order=_oggpack_read(opb,8);
d->rate=_oggpack_read(opb,16);
d->barkmap=_oggpack_read(opb,16);
- d->stages=_oggpack_read(opb,8);
+ d->stages=_oggpack_read(opb,4);
if(d->order<1)goto err_out;
if(d->rate<1)goto err_out;
if(d->barkmap<1)goto err_out;
if(d->stages<1)goto err_out;
- d->books=alloca(sizeof(int)*d->stages);
for(j=0;j<d->stages;j++){
d->books[j]=_oggpack_read(opb,8);
if(d->books[j]<0 || d->books[j]>=vi->books)goto err_out;
********************************************************************
function: maintain the info structure, info <-> header packets
- last mod: $Id: info.c,v 1.18 2000/01/28 09:05:10 xiphmont Exp $
+ last mod: $Id: info.c,v 1.19 2000/01/28 14:31:26 xiphmont Exp $
********************************************************************/
for(i=0;i<vi->modes;i++)
if(vi->mode_param[i])free(vi->mode_param[i]);
- if(vi->mode_param)free(vi->mode_param);
+ /*if(vi->mode_param)free(vi->mode_param);*/
for(i=0;i<vi->maps;i++) /* unpack does the range checking */
_mapping_P[i]->free_info(vi->map_param[i]);
- if(vi->map_param)free(vi->map_param);
+ /*if(vi->map_param)free(vi->map_param);*/
for(i=0;i<vi->times;i++) /* unpack does the range checking */
_time_P[i]->free_info(vi->time_param[i]);
- if(vi->time_param)free(vi->time_param);
+ /*if(vi->time_param)free(vi->time_param);*/
for(i=0;i<vi->floors;i++) /* unpack does the range checking */
_floor_P[i]->free_info(vi->floor_param[i]);
- if(vi->floor_param)free(vi->floor_param);
+ /*if(vi->floor_param)free(vi->floor_param);*/
for(i=0;i<vi->residues;i++) /* unpack does the range checking */
_residue_P[i]->free_info(vi->residue_param[i]);
- if(vi->residue_param)free(vi->residue_param);
+ /*if(vi->residue_param)free(vi->residue_param);*/
/* the static codebooks *are* freed if you call info_clear, because
decode side does alloc a 'static' codebook. Calling clear on the
free(vi->book_param[i]);
}
}
- if(vi->book_param)free(vi->book_param);
+ /*if(vi->book_param)free(vi->book_param);*/
for(i=0;i<vi->psys;i++)
_vi_psy_free(vi->psy_param[i]);
- if(vi->psy_param)free(vi->psy_param);
+ /*if(vi->psy_param)free(vi->psy_param);*/
memset(vi,0,sizeof(vorbis_info));
}
int i;
/* codebooks */
- vi->books=_oggpack_read(opb,16);
- vi->book_param=calloc(vi->books,sizeof(static_codebook *));
+ vi->books=_oggpack_read(opb,8)+1;
+ /*vi->book_param=calloc(vi->books,sizeof(static_codebook *));*/
for(i=0;i<vi->books;i++){
vi->book_param[i]=calloc(1,sizeof(static_codebook));
if(vorbis_staticbook_unpack(opb,vi->book_param[i]))goto err_out;
}
/* time backend settings */
- vi->times=_oggpack_read(opb,8);
- vi->time_type=malloc(vi->times*sizeof(int));
- vi->time_param=calloc(vi->times,sizeof(void *));
+ vi->times=_oggpack_read(opb,6)+1;
+ /*vi->time_type=malloc(vi->times*sizeof(int));*/
+ /*vi->time_param=calloc(vi->times,sizeof(void *));*/
for(i=0;i<vi->times;i++){
vi->time_type[i]=_oggpack_read(opb,16);
if(vi->time_type[i]<0 || vi->time_type[i]>=VI_TIMEB)goto err_out;
}
/* floor backend settings */
- vi->floors=_oggpack_read(opb,8);
- vi->floor_type=malloc(vi->floors*sizeof(int));
- vi->floor_param=calloc(vi->floors,sizeof(void *));
+ vi->floors=_oggpack_read(opb,6)+1;
+ /*vi->floor_type=malloc(vi->floors*sizeof(int));*/
+ /*vi->floor_param=calloc(vi->floors,sizeof(void *));*/
for(i=0;i<vi->floors;i++){
vi->floor_type[i]=_oggpack_read(opb,16);
if(vi->floor_type[i]<0 || vi->floor_type[i]>=VI_FLOORB)goto err_out;
}
/* residue backend settings */
- vi->residues=_oggpack_read(opb,8);
- vi->residue_type=malloc(vi->residues*sizeof(int));
- vi->residue_param=calloc(vi->residues,sizeof(void *));
+ vi->residues=_oggpack_read(opb,6)+1;
+ /*vi->residue_type=malloc(vi->residues*sizeof(int));*/
+ /*vi->residue_param=calloc(vi->residues,sizeof(void *));*/
for(i=0;i<vi->residues;i++){
vi->residue_type[i]=_oggpack_read(opb,16);
if(vi->residue_type[i]<0 || vi->residue_type[i]>=VI_RESB)goto err_out;
}
/* map backend settings */
- vi->maps=_oggpack_read(opb,8);
- vi->map_type=malloc(vi->maps*sizeof(int));
- vi->map_param=calloc(vi->maps,sizeof(void *));
+ vi->maps=_oggpack_read(opb,6)+1;
+ /*vi->map_type=malloc(vi->maps*sizeof(int));*/
+ /*vi->map_param=calloc(vi->maps,sizeof(void *));*/
for(i=0;i<vi->maps;i++){
vi->map_type[i]=_oggpack_read(opb,16);
if(vi->map_type[i]<0 || vi->map_type[i]>=VI_MAPB)goto err_out;
}
/* mode settings */
- vi->modes=_oggpack_read(opb,8);
- vi->mode_param=calloc(vi->modes,sizeof(void *));
+ vi->modes=_oggpack_read(opb,6)+1;
+ /*vi->mode_param=calloc(vi->modes,sizeof(void *));*/
for(i=0;i<vi->modes;i++){
vi->mode_param[i]=calloc(1,sizeof(vorbis_info_mode));
vi->mode_param[i]->blockflag=_oggpack_read(opb,1);
_oggpack_write(opb,0x82,8);
/* books */
- _oggpack_write(opb,vi->books,16);
+ _oggpack_write(opb,vi->books-1,8);
for(i=0;i<vi->books;i++)
if(vorbis_staticbook_pack(vi->book_param[i],opb))goto err_out;
/* times */
- _oggpack_write(opb,vi->times,8);
+ _oggpack_write(opb,vi->times-1,6);
for(i=0;i<vi->times;i++){
_oggpack_write(opb,vi->time_type[i],16);
_time_P[vi->time_type[i]]->pack(vi->time_param[i],opb);
}
/* floors */
- _oggpack_write(opb,vi->floors,8);
+ _oggpack_write(opb,vi->floors-1,6);
for(i=0;i<vi->floors;i++){
_oggpack_write(opb,vi->floor_type[i],16);
_floor_P[vi->floor_type[i]]->pack(vi->floor_param[i],opb);
}
/* residues */
- _oggpack_write(opb,vi->residues,8);
+ _oggpack_write(opb,vi->residues-1,6);
for(i=0;i<vi->residues;i++){
_oggpack_write(opb,vi->residue_type[i],16);
_residue_P[vi->residue_type[i]]->pack(vi->residue_param[i],opb);
}
/* maps */
- _oggpack_write(opb,vi->maps,8);
+ _oggpack_write(opb,vi->maps-1,6);
for(i=0;i<vi->maps;i++){
_oggpack_write(opb,vi->map_type[i],16);
_mapping_P[vi->map_type[i]]->pack(vi,vi->map_param[i],opb);
}
/* modes */
- _oggpack_write(opb,vi->modes,8);
+ _oggpack_write(opb,vi->modes-1,6);
for(i=0;i<vi->modes;i++){
_oggpack_write(opb,vi->mode_param[i]->blockflag,1);
_oggpack_write(opb,vi->mode_param[i]->windowtype,16);
********************************************************************
function: channel mapping 0 implementation
- last mod: $Id: mapping0.c,v 1.3 2000/01/28 09:05:13 xiphmont Exp $
+ last mod: $Id: mapping0.c,v 1.4 2000/01/28 14:31:27 xiphmont Exp $
********************************************************************/
} vorbis_look_mapping0;
void free_info(vorbis_info_mapping *i){
- vorbis_info_mapping0 *d=(vorbis_info_mapping0 *)i;
-
- if(d){
- if(d->chmuxlist)free(d->chmuxlist);
- if(d->timesubmap)free(d->timesubmap);
- if(d->floorsubmap)free(d->floorsubmap);
- if(d->residuesubmap)free(d->residuesubmap);
- if(d->psysubmap)free(d->psysubmap);
- memset(d,0,sizeof(vorbis_info_mapping0));
- free(d);
+ if(i){
+ memset(i,0,sizeof(vorbis_info_mapping0));
+ free(i);
}
}
d->submaps=_oggpack_read(opb,4);
- d->chmuxlist=calloc(vi->channels,sizeof(int));
- d->timesubmap=malloc(sizeof(int)*d->submaps);
- d->floorsubmap=malloc(sizeof(int)*d->submaps);
- d->residuesubmap=malloc(sizeof(int)*d->submaps);
-
if(d->submaps>1){
for(i=0;i<vi->channels;i++){
d->chmuxlist[i]=_oggpack_read(opb,4);
********************************************************************
function: residue backend 0 implementation
- last mod: $Id: res0.c,v 1.2 2000/01/28 09:05:16 xiphmont Exp $
+ last mod: $Id: res0.c,v 1.3 2000/01/28 14:31:28 xiphmont Exp $
********************************************************************/
/* unfinished as of 20000118 */
void free_info(vorbis_info_residue *i){
- vorbis_info_residue0 *d=(vorbis_info_residue0 *)i;
- if(d){
- if(d->books)free(d->books);
- memset(d,0,sizeof(vorbis_info_residue0));
- free(d);
+ if(i){
+ memset(i,0,sizeof(vorbis_info_residue0));
+ free(i);
}
}
-# $Id: Makefile.in,v 1.7 2000/01/06 13:57:09 xiphmont Exp $
+# $Id: Makefile.in,v 1.8 2000/01/28 14:31:29 xiphmont Exp $
###############################################################################
# #
clean:
-rm -f *.o *.a test* *~ *.out *.m config.* \
- lspvqtrain
+ lspvqtrain genericvqtrain vqbuild vqmetrics vqpartition vqcascade
distclean: clean
-rm -f Makefile