[xiph-cvs] cvs commit: vorbis/lib/modes psych_44.h residue_44.h
Monty
xiphmont at xiph.org
Tue May 14 00:06:48 PDT 2002
xiphmont 02/05/14 00:06:47
Modified: lib Tag: branch_monty_20020507 Makefile.am analysis.c
backends.h block.c codec_internal.h floor0.c
floor1.c mapping0.c psy.c psy.h registry.c res0.c
vorbisenc.c
lib/modes Tag: branch_monty_20020507 psych_44.h residue_44.h
Removed: lib Tag: branch_monty_20020507 registry-api.h time0.c
Log:
commit to avoid losing work. The Grand Simplification continued. This code *does not build*
Revision Changes Path
No revision
<p>No revision
<p>1.14.2.2 +1 -1 vorbis/lib/Makefile.am
Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/Makefile.am,v
retrieving revision 1.14.2.1
retrieving revision 1.14.2.2
diff -u -r1.14.2.1 -r1.14.2.2
--- Makefile.am 2002/05/07 23:47:12 1.14.2.1
+++ Makefile.am 2002/05/14 07:06:40 1.14.2.2
@@ -22,7 +22,7 @@
libvorbisfile_la_SOURCES = vorbisfile.c
libvorbisfile_la_LDFLAGS = -version-info @VF_LIB_CURRENT@:@VF_LIB_REVISION@:@VF_LIB_AGE@
-libvorbisenc_la_SOURCES = vorbisenc.c registry-api.h
+libvorbisenc_la_SOURCES = vorbisenc.c
libvorbisenc_la_LDFLAGS = -version-info @VE_LIB_CURRENT@:@VE_LIB_REVISION@:@VE_LIB_AGE@
EXTRA_PROGRAMS = barkmel tone psytune
<p><p>1.51.2.2 +5 -16 vorbis/lib/analysis.c
Index: analysis.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/analysis.c,v
retrieving revision 1.51.2.1
retrieving revision 1.51.2.2
diff -u -r1.51.2.1 -r1.51.2.2
--- analysis.c 2002/05/07 23:47:12 1.51.2.1
+++ analysis.c 2002/05/14 07:06:40 1.51.2.2
@@ -11,7 +11,7 @@
********************************************************************
function: single-block PCM analysis mode dispatch
- last mod: $Id: analysis.c,v 1.51.2.1 2002/05/07 23:47:12 xiphmont Exp $
+ last mod: $Id: analysis.c,v 1.51.2.2 2002/05/14 07:06:40 xiphmont Exp $
********************************************************************/
@@ -44,23 +44,12 @@
/* first things first. Make sure encode is ready */
oggpack_reset(&vb->opb);
- /* Encode the packet type */
- oggpack_write(&vb->opb,0,1);
- /* currently lazy. Short block dispatches to 0, long to 1. */
-
- if(vb->W &&ci->modes>1)mode=1;
- type=ci->map_type[ci->mode_param[mode]->mapping];
- vb->mode=mode;
-
- /* Encode frame mode, pre,post windowsize, then dispatch */
- oggpack_write(&vb->opb,mode,b->modebits);
- if(vb->W){
- oggpack_write(&vb->opb,vb->lW,1);
- oggpack_write(&vb->opb,vb->nW,1);
- }
+ /* we only have one mapping type (0), and we let the mapping code
+ itself figure out what soft mode to use. This allows easier
+ bitrate management */
- if((ret=_mapping_P[type]->forward(vb,b->mode[mode])))
+ if((ret=_mapping_P[0]->forward(vb)))
return(ret);
if(op){
<p><p>1.12.6.2 +10 -22 vorbis/lib/backends.h
Index: backends.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/backends.h,v
retrieving revision 1.12.6.1
retrieving revision 1.12.6.2
diff -u -r1.12.6.1 -r1.12.6.2
--- backends.h 2002/05/07 23:47:12 1.12.6.1
+++ backends.h 2002/05/14 07:06:40 1.12.6.2
@@ -12,7 +12,7 @@
function: libvorbis backend and mapping structures; needed for
static mode headers
- last mod: $Id: backends.h,v 1.12.6.1 2002/05/07 23:47:12 xiphmont Exp $
+ last mod: $Id: backends.h,v 1.12.6.2 2002/05/14 07:06:40 xiphmont Exp $
********************************************************************/
@@ -30,9 +30,7 @@
typedef struct{
void (*pack) (vorbis_info_floor *,oggpack_buffer *);
vorbis_info_floor *(*unpack)(vorbis_info *,oggpack_buffer *);
- vorbis_look_floor *(*look) (vorbis_dsp_state *,vorbis_info_mode *,
- vorbis_info_floor *);
- vorbis_info_floor *(*copy_info)(vorbis_info_floor *);
+ vorbis_look_floor *(*look) (vorbis_dsp_state *,vorbis_info_floor *);
void (*free_info) (vorbis_info_floor *);
void (*free_look) (vorbis_look_floor *);
void *(*inverse1) (struct vorbis_block *,vorbis_look_floor *);
@@ -94,9 +92,8 @@
typedef struct{
void (*pack) (vorbis_info_residue *,oggpack_buffer *);
vorbis_info_residue *(*unpack)(vorbis_info *,oggpack_buffer *);
- vorbis_look_residue *(*look) (vorbis_dsp_state *,vorbis_info_mode *,
+ vorbis_look_residue *(*look) (vorbis_dsp_state *,
vorbis_info_residue *);
- vorbis_info_residue *(*copy_info)(vorbis_info_residue *);
void (*free_info) (vorbis_info_residue *);
void (*free_look) (vorbis_look_residue *);
long **(*class) (struct vorbis_block *,vorbis_look_residue *,
@@ -120,10 +117,9 @@
int booklist[256]; /* list of second stage books */
/* encode-only heuristic settings */
- float entmax[64]; /* book entropy threshholds*/
float ampmax[64]; /* book amp threshholds*/
- int subgrp[64]; /* book heuristic subgroup size */
- int blimit[64]; /* subgroup position limits */
+ int blimit[64]; /* subgroup position limits *
+
} vorbis_info_residue0;
/* Mapping backend generic *****************************************/
@@ -131,34 +127,26 @@
void (*pack) (vorbis_info *,vorbis_info_mapping *,
oggpack_buffer *);
vorbis_info_mapping *(*unpack)(vorbis_info *,oggpack_buffer *);
- vorbis_look_mapping *(*look) (vorbis_dsp_state *,vorbis_info_mode *,
- vorbis_info_mapping *);
- vorbis_info_mapping *(*copy_info)(vorbis_info_mapping *);
void (*free_info) (vorbis_info_mapping *);
- void (*free_look) (vorbis_look_mapping *);
- int (*forward) (struct vorbis_block *vb,vorbis_look_mapping *);
- int (*inverse) (struct vorbis_block *vb,vorbis_look_mapping *);
+ int (*forward) (struct vorbis_block *vb);
+ int (*inverse) (struct vorbis_block *vb,vorbis_info_mapping *);
} vorbis_func_mapping;
typedef struct vorbis_info_mapping0{
int submaps; /* <= 16 */
int chmuxlist[256]; /* up to 256 channels in a Vorbis stream */
- int timesubmap[16]; /* [mux] */
int floorsubmap[16]; /* [mux] submap to floors */
int residuesubmap[16]; /* [mux] submap to residue */
- int psy[2]; /* by blocktype; impulse/padding for short,
- transition/normal for long */
-
int coupling_steps;
int coupling_mag[256];
int coupling_ang[256];
+ int coupling_pointlimit;
+ int coupling_pointamp;
+
} vorbis_info_mapping0;
#endif
-
-
-
<p><p>1.64.2.2 +50 -20 vorbis/lib/block.c
Index: block.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/block.c,v
retrieving revision 1.64.2.1
retrieving revision 1.64.2.2
diff -u -r1.64.2.1 -r1.64.2.2
--- block.c 2002/05/07 23:47:12 1.64.2.1
+++ block.c 2002/05/14 07:06:40 1.64.2.2
@@ -11,7 +11,7 @@
********************************************************************
function: PCM data vector blocking, windowing and dis/reassembly
- last mod: $Id: block.c,v 1.64.2.1 2002/05/07 23:47:12 xiphmont Exp $
+ last mod: $Id: block.c,v 1.64.2.2 2002/05/14 07:06:40 xiphmont Exp $
Handle windowing, overlap-add, etc of the PCM vectors. This is made
more amusing by Vorbis' current two allowed block sizes.
@@ -189,12 +189,27 @@
b->window[1]=_vorbis_window(0,ci->blocksizes[1]/2);
if(encp){ /* encode/decode differ here */
+
+ /* analysis always needs an fft */
+ drft_init(&b->fft_look[0],ci->blocksizes[0]);
+ drft_init(&b->fft_look[1],ci->blocksizes[0]);
+
/* finish the codebooks */
if(!ci->fullbooks){
ci->fullbooks=_ogg_calloc(ci->books,sizeof(*ci->fullbooks));
for(i=0;i<ci->books;i++)
vorbis_book_init_encode(ci->fullbooks+i,ci->book_param[i]);
}
+
+ b->psy=_ogg_calloc(ci->psys,sizeof(*b->psy));
+ for(i=0;i<ci->psys;i++){
+ _vp_psy_init(b->psy+i,
+ ci->psy_param[i],
+ &ci->psy_g_param,
+ ci->blocksizes[ci->psy_param[i]->blockflag]/2,
+ vi->rate);
+ }
+
v->analysisp=1;
}else{
/* finish the codebooks */
@@ -230,14 +245,17 @@
v->pcm_current=v->centerW;
- /* initialize all the mapping/backend lookups */
- b->mode=_ogg_calloc(ci->modes,sizeof(*b->mode));
- for(i=0;i<ci->modes;i++){
- int mapnum=ci->mode_param[i]->mapping;
- int maptype=ci->map_type[mapnum];
- b->mode[i]=_mapping_P[maptype]->look(v,ci->mode_param[i],
- ci->map_param[mapnum]);
- }
+ /* initialize all the backend lookups */
+ b->floor=_ogg_calloc(ci->floors,sizeof(*b->floor));
+ b->residue=_ogg_calloc(ci->residues,sizeof(*b->residue));
+
+ for(i=0;i<ci->floors;i++)
+ b->floor[i]=_floor_P[ci->floor_type[i]]->
+ look(vd,ci->floor_param[i]);
+
+ for(i=0;i<ci->residues;i++)
+ b->residue[i]=_residue_P[ci->residue_type[i]]->
+ look(vd,ci->residue_param[i]);
return(0);
}
@@ -287,8 +305,31 @@
_ogg_free(b->transform[1][0]);
_ogg_free(b->transform[1]);
}
+
+ if(b->floor){
+ for(i=0;i<ci->floors;i++)
+ _floor_P[ci->floor_type[i]]->
+ free_look(b->floor[i]);
+ _ogg_free(b->floor);
+ }
+ if(b->residue){
+ for(i=0;i<ci->residues;i++)
+ _residue_P[ci->residue_type[i]]->
+ free_look(b->residue[i]);
+ _ogg_free(b->residue);
+ }
+ if(b->psy){
+ for(i=0;i<ci->psys;i++)
+ _vp_psy_clear(b->psy+i);
+ _ogg_free(b->psy);
+ }
+
if(b->psy_g_look)_vp_global_free(b->psy_g_look);
vorbis_bitrate_clear(&b->bms);
+
+ drft_clear(&b->fft_look[0]);
+ drft_clear(&b->fft_look[1]);
+
}
if(v->pcm){
@@ -298,18 +339,7 @@
if(v->pcmret)_ogg_free(v->pcmret);
}
- /* free mode lookups; these are actually vorbis_look_mapping structs */
- if(ci){
- for(i=0;i<ci->modes;i++){
- int mapnum=ci->mode_param[i]->mapping;
- int maptype=ci->map_type[mapnum];
- if(b && b->mode)_mapping_P[maptype]->free_look(b->mode[i]);
- }
- }
-
if(b){
- if(b->mode)_ogg_free(b->mode);
-
/* free header, header1, header2 */
if(b->header)_ogg_free(b->header);
if(b->header1)_ogg_free(b->header1);
<p><p>1.14.4.2 +10 -6 vorbis/lib/codec_internal.h
Index: codec_internal.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/codec_internal.h,v
retrieving revision 1.14.4.1
retrieving revision 1.14.4.2
diff -u -r1.14.4.1 -r1.14.4.2
--- codec_internal.h 2002/05/07 23:47:13 1.14.4.1
+++ codec_internal.h 2002/05/14 07:06:40 1.14.4.2
@@ -11,7 +11,7 @@
********************************************************************
function: libvorbis codec headers
- last mod: $Id: codec_internal.h,v 1.14.4.1 2002/05/07 23:47:13 xiphmont Exp $
+ last mod: $Id: codec_internal.h,v 1.14.4.2 2002/05/14 07:06:40 xiphmont Exp $
********************************************************************/
@@ -36,7 +36,6 @@
ogg_uint32_t packetblob_markers[PACKETBLOBS];
} vorbis_block_internal;
-typedef void vorbis_look_mapping;
typedef void vorbis_look_floor;
typedef void vorbis_look_residue;
typedef void vorbis_look_transform;
@@ -61,11 +60,13 @@
envelope_lookup *ve; /* envelope lookup */
float *window[2];
vorbis_look_transform **transform[2]; /* block, type */
- vorbis_look_psy_global *psy_g_look;
+ drft_lookup fft_look[2];
- /* backend lookups are tied to the mode, not the backend or naked mapping */
int modebits;
- vorbis_look_mapping **mode;
+ vorbis_look_floor **floor;
+ vorbis_look_residue **residue;
+ vorbis_look_psy *psy;
+ vorbis_look_psy_global *psy_g_look;
/* local storage, only used on the encoding side. This way the
application does not need to worry about freeing some packets'
@@ -152,11 +153,14 @@
static_codebook *book_param[256];
codebook *fullbooks;
- vorbis_info_psy *psy_param[64]; /* encode only */
+ int block_to_psy_map[4];
+ vorbis_info_psy *psy_param[4]; /* encode only */
vorbis_info_psy_global psy_g_param;
bitrate_manager_info bi;
+ int modeselect[2][PACKETBLOBS];
highlevel_encode_setup hi;
+
} codec_setup_info;
extern vorbis_look_psy_global *_vp_global_look(vorbis_info *vi);
<p><p>1.51.4.2 +55 -38 vorbis/lib/floor0.c
Index: floor0.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/floor0.c,v
retrieving revision 1.51.4.1
retrieving revision 1.51.4.2
diff -u -r1.51.4.1 -r1.51.4.2
--- floor0.c 2002/05/07 23:47:13 1.51.4.1
+++ floor0.c 2002/05/14 07:06:40 1.51.4.2
@@ -11,7 +11,7 @@
********************************************************************
function: floor backend 0 implementation
- last mod: $Id: floor0.c,v 1.51.4.1 2002/05/07 23:47:13 xiphmont Exp $
+ last mod: $Id: floor0.c,v 1.51.4.2 2002/05/14 07:06:40 xiphmont Exp $
********************************************************************/
@@ -33,10 +33,10 @@
#include <stdio.h>
typedef struct {
- long n;
int ln;
int m;
- int *linearmap;
+ int **linearmap;
+ int n[2];
vorbis_info_floor0 *vi;
lpc_lookup lpclook;
@@ -49,13 +49,6 @@
/***********************************************/
-static vorbis_info_floor *floor0_copy_info (vorbis_info_floor *i){
- vorbis_info_floor0 *info=(vorbis_info_floor0 *)i;
- vorbis_info_floor0 *ret=_ogg_malloc(sizeof(*ret));
- memcpy(ret,info,sizeof(*ret));
- return(ret);
-}
-
static void floor0_free_info(vorbis_info_floor *i){
vorbis_info_floor0 *info=(vorbis_info_floor0 *)i;
if(info){
@@ -68,10 +61,13 @@
vorbis_look_floor0 *look=(vorbis_look_floor0 *)i;
if(look){
- /*fprintf(stderr,"floor 0 bit usage %f\n",
- (float)look->bits/look->frames);*/
+ if(look->linearmap){
- if(look->linearmap)_ogg_free(look->linearmap);
+ if(look->linearmap[0])_ogg_free(look->linearmap[0]);
+ if(look->linearmap[1])_ogg_free(look->linearmap[1]);
+
+ _ogg_free(look->linearmap);
+ }
if(look->lsp_look)_ogg_free(look->lsp_look);
lpc_clear(&look->lpclook);
memset(look,0,sizeof(*look));
@@ -115,8 +111,41 @@
Note that the scale depends on the sampling rate as well as the
linear block and mapping sizes */
-static vorbis_look_floor *floor0_look (vorbis_dsp_state *vd,vorbis_info_mode *mi,
- vorbis_info_floor *i){
+static void floor0_map_lazy_init(vorbis_block *vb,
+ vorbis_info_floor *info,
+ vorbis_look_floor0 *look){
+ if(!look->linearmap[W]){
+ vorbis_dsp_state *vd=vb->vd;
+ vorbis_info *vi=vd->vi;
+ codec_setup_info *ci=vi->codec_setup;
+ int W=vb->W;
+ int n=ci->blocksizes[W]/2,j;
+
+ /* we choose a scaling constant so that:
+ floor(bark(rate/2-1)*C)=mapped-1
+ floor(bark(rate/2)*C)=mapped */
+ float scale=look->ln/toBARK(info->rate/2.f);
+
+ /* the mapping from a linear scale to a smaller bark scale is
+ straightforward. We do *not* make sure that the linear mapping
+ does not skip bark-scale bins; the decoder simply skips them and
+ the encoder may do what it wishes in filling them. They're
+ necessary in some mapping combinations to keep the scale spacing
+ accurate */
+ look->linearmap[W]=_ogg_malloc((n+1)*sizeof(**look->linearmap));
+ for(j=0;j<n;j++){
+ int val=floor( toBARK((info->rate/2.f)/n*j)
+ *scale); /* bark numbers represent band edges */
+ if(val>=look->ln)val=look->ln-1; /* guard against the approximation */
+ look->linearmap[W][j]=val;
+ }
+ look->linearmap[W][j]=-1;
+ look->n[W]=n;
+ }
+}
+
+static vorbis_look_floor *floor0_look(vorbis_dsp_state *vd,
+ vorbis_info_floor *i){
int j;
float scale;
vorbis_info *vi=vd->vi;
@@ -131,25 +160,7 @@
if(vd->analysisp)
lpc_init(&look->lpclook,look->ln,look->m);
- /* we choose a scaling constant so that:
- floor(bark(rate/2-1)*C)=mapped-1
- floor(bark(rate/2)*C)=mapped */
- scale=look->ln/toBARK(info->rate/2.f);
-
- /* the mapping from a linear scale to a smaller bark scale is
- straightforward. We do *not* make sure that the linear mapping
- does not skip bark-scale bins; the decoder simply skips them and
- the encoder may do what it wishes in filling them. They're
- necessary in some mapping combinations to keep the scale spacing
- accurate */
- look->linearmap=_ogg_malloc((look->n+1)*sizeof(*look->linearmap));
- for(j=0;j<look->n;j++){
- int val=floor( toBARK((info->rate/2.f)/look->n*j)
- *scale); /* bark numbers represent band edges */
- if(val>=look->ln)val=look->ln-1; /* guard against the approximation */
- look->linearmap[j]=val;
- }
- look->linearmap[j]=-1;
+ look->linearmap=_ogg_calloc(2,sizeof(*look->linearmap));
look->lsp_look=_ogg_malloc(look->ln*sizeof(*look->lsp_look));
for(j=0;j<look->ln;j++)
@@ -162,7 +173,7 @@
vorbis_look_floor0 *look=(vorbis_look_floor0 *)i;
vorbis_info_floor0 *info=look->vi;
int j,k;
-
+
int ampraw=oggpack_read(&vb->opb,info->ampbits);
if(ampraw>0){ /* also handles the -1 out of data case */
long maxval=(1<<info->ampbits)-1;
@@ -195,23 +206,29 @@
vorbis_look_floor0 *look=(vorbis_look_floor0 *)i;
vorbis_info_floor0 *info=look->vi;
+ floor0_map_lazy_init(vb,info,look);
+
if(memo){
float *lsp=(float *)memo;
float amp=lsp[look->m];
/* take the coefficients back to a spectral envelope curve */
- vorbis_lsp_to_curve(out,look->linearmap,look->n,look->ln,
+ vorbis_lsp_to_curve(out,
+ look->linearmap[vb->W],
+ look->n[vb->W],
+ look->ln,
lsp,look->m,amp,(float)info->ampdB);
return(1);
}
- memset(out,0,sizeof(*out)*look->n);
+ memset(out,0,sizeof(*out)*look->n[vb->W]);
return(0);
}
/* export hooks */
vorbis_func_floor floor0_exportbundle={
- NULL,&floor0_unpack,&floor0_look,&floor0_copy_info,&floor0_free_info,
+ NULL,&floor0_unpack,&floor0_look,&floor0_free_info,
&floor0_free_look,&floor0_inverse1,&floor0_inverse2
};
+
<p><p>1.20.4.2 +4 -11 vorbis/lib/floor1.c
Index: floor1.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/floor1.c,v
retrieving revision 1.20.4.1
retrieving revision 1.20.4.2
diff -u -r1.20.4.1 -r1.20.4.2
--- floor1.c 2002/05/07 23:47:13 1.20.4.1
+++ floor1.c 2002/05/14 07:06:41 1.20.4.2
@@ -11,7 +11,7 @@
********************************************************************
function: floor backend 1 implementation
- last mod: $Id: floor1.c,v 1.20.4.1 2002/05/07 23:47:13 xiphmont Exp $
+ last mod: $Id: floor1.c,v 1.20.4.2 2002/05/14 07:06:41 xiphmont Exp $
********************************************************************/
@@ -66,13 +66,6 @@
/***********************************************/
-static vorbis_info_floor *floor1_copy_info (vorbis_info_floor *i){
- vorbis_info_floor1 *info=(vorbis_info_floor1 *)i;
- vorbis_info_floor1 *ret=_ogg_malloc(sizeof(*ret));
- memcpy(ret,info,sizeof(*ret));
- return(ret);
-}
-
static void floor1_free_info(vorbis_info_floor *i){
vorbis_info_floor1 *info=(vorbis_info_floor1 *)i;
if(info){
@@ -203,8 +196,8 @@
return(**(int **)a-**(int **)b);
}
-static vorbis_look_floor *floor1_look(vorbis_dsp_state *vd,vorbis_info_mode *mi,
- vorbis_info_floor *in){
+static vorbis_look_floor *floor1_look(vorbis_dsp_state *vd,
+ vorbis_info_floor *in){
int *sortpointer[VIF_POSIT+2];
vorbis_info_floor1 *info=(vorbis_info_floor1 *)in;
@@ -1182,7 +1175,7 @@
/* export hooks */
vorbis_func_floor floor1_exportbundle={
- &floor1_pack,&floor1_unpack,&floor1_look,&floor1_copy_info,&floor1_free_info,
+ &floor1_pack,&floor1_unpack,&floor1_look,&floor1_free_info,
&floor1_free_look,&floor1_inverse1,&floor1_inverse2
};
<p><p>1.49.2.2 +72 -179 vorbis/lib/mapping0.c
Index: mapping0.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/mapping0.c,v
retrieving revision 1.49.2.1
retrieving revision 1.49.2.2
diff -u -r1.49.2.1 -r1.49.2.2
--- mapping0.c 2002/05/07 23:47:13 1.49.2.1
+++ mapping0.c 2002/05/14 07:06:41 1.49.2.2
@@ -11,7 +11,7 @@
********************************************************************
function: channel mapping 0 implementation
- last mod: $Id: mapping0.c,v 1.49.2.1 2002/05/07 23:47:13 xiphmont Exp $
+ last mod: $Id: mapping0.c,v 1.49.2.2 2002/05/14 07:06:41 xiphmont Exp $
********************************************************************/
@@ -39,31 +39,6 @@
extern int analysis_noisy;
-typedef struct {
- drft_lookup fft_look;
- vorbis_info_mode *mode;
- vorbis_info_mapping0 *map;
-
- vorbis_look_floor **floor_look;
-
- vorbis_look_residue **residue_look;
- vorbis_look_psy *psy_look[2];
-
- vorbis_func_floor **floor_func;
- vorbis_func_residue **residue_func;
-
- int ch;
- long lastframe; /* if a different mode is called, we need to
- invalidate decay */
-} vorbis_look_mapping0;
-
-static vorbis_info_mapping *mapping0_copy_info(vorbis_info_mapping *vm){
- vorbis_info_mapping0 *info=(vorbis_info_mapping0 *)vm;
- vorbis_info_mapping0 *ret=_ogg_malloc(sizeof(*ret));
- memcpy(ret,info,sizeof(*ret));
- return(ret);
-}
-
static void mapping0_free_info(vorbis_info_mapping *i){
vorbis_info_mapping0 *info=(vorbis_info_mapping0 *)i;
if(info){
@@ -72,93 +47,6 @@
}
}
-static void mapping0_free_look(vorbis_look_mapping *look){
- int i;
- vorbis_look_mapping0 *l=(vorbis_look_mapping0 *)look;
- if(l){
- drft_clear(&l->fft_look);
-
- for(i=0;i<l->map->submaps;i++){
- l->floor_func[i]->free_look(l->floor_look[i]);
- l->residue_func[i]->free_look(l->residue_look[i]);
- }
- if(l->psy_look[1] && l->psy_look[1]!=l->psy_look[0]){
- _vp_psy_clear(l->psy_look[1]);
- _ogg_free(l->psy_look[1]);
- }
- if(l->psy_look[0]){
- _vp_psy_clear(l->psy_look[0]);
- _ogg_free(l->psy_look[0]);
- }
- _ogg_free(l->floor_func);
- _ogg_free(l->residue_func);
- _ogg_free(l->floor_look);
- _ogg_free(l->residue_look);
- memset(l,0,sizeof(*l));
- _ogg_free(l);
- }
-}
-
-static vorbis_look_mapping *mapping0_look(vorbis_dsp_state *vd,vorbis_info_mode *vm,
- vorbis_info_mapping *m){
- int i;
- vorbis_info *vi=vd->vi;
- codec_setup_info *ci=vi->codec_setup;
- vorbis_look_mapping0 *look=_ogg_calloc(1,sizeof(*look));
- vorbis_info_mapping0 *info=look->map=(vorbis_info_mapping0 *)m;
- look->mode=vm;
-
- look->floor_look=_ogg_calloc(info->submaps,sizeof(*look->floor_look));
-
- look->residue_look=_ogg_calloc(info->submaps,sizeof(*look->residue_look));
-
- look->floor_func=_ogg_calloc(info->submaps,sizeof(*look->floor_func));
- look->residue_func=_ogg_calloc(info->submaps,sizeof(*look->residue_func));
-
- for(i=0;i<info->submaps;i++){
- int floornum=info->floorsubmap[i];
- int resnum=info->residuesubmap[i];
-
- look->floor_func[i]=_floor_P[ci->floor_type[floornum]];
- look->floor_look[i]=look->floor_func[i]->
- look(vd,vm,ci->floor_param[floornum]);
- look->residue_func[i]=_residue_P[ci->residue_type[resnum]];
- look->residue_look[i]=look->residue_func[i]->
- look(vd,vm,ci->residue_param[resnum]);
-
- }
- if(ci->psys && vd->analysisp){
- if(info->psy[0] != info->psy[1]){
-
- int psynum=info->psy[0];
- look->psy_look[0]=_ogg_calloc(1,sizeof(*look->psy_look[0]));
- _vp_psy_init(look->psy_look[0],ci->psy_param[psynum],
- &ci->psy_g_param,
- ci->blocksizes[vm->blockflag]/2,vi->rate);
-
- psynum=info->psy[1];
- look->psy_look[1]=_ogg_calloc(1,sizeof(*look->psy_look[1]));
- _vp_psy_init(look->psy_look[1],ci->psy_param[psynum],
- &ci->psy_g_param,
- ci->blocksizes[vm->blockflag]/2,vi->rate);
- }else{
-
- int psynum=info->psy[0];
- look->psy_look[0]=_ogg_calloc(1,sizeof(*look->psy_look[0]));
- look->psy_look[1]=look->psy_look[0];
- _vp_psy_init(look->psy_look[0],ci->psy_param[psynum],
- &ci->psy_g_param,
- ci->blocksizes[vm->blockflag]/2,vi->rate);
-
- }
- }
-
- look->ch=vi->channels;
-
- if(vd->analysisp)drft_init(&look->fft_look,ci->blocksizes[vm->blockflag]);
- return(look);
-}
-
static int ilog2(unsigned int v){
int ret=0;
while(v>1){
@@ -285,14 +173,11 @@
int *post,int *ilogmask);
-static int mapping0_forward(vorbis_block *vb,vorbis_look_mapping *l){
+static int mapping0_forward(vorbis_block *vb){
vorbis_dsp_state *vd=vb->vd;
vorbis_info *vi=vd->vi;
codec_setup_info *ci=vi->codec_setup;
backend_lookup_state *b=vb->vd->backend_state;
- vorbis_look_mapping0 *look=(vorbis_look_mapping0 *)l;
- vorbis_info_mapping0 *info=look->map;
- /*vorbis_info_mode *mode=look->mode;*/
vorbis_block_internal *vbi=(vorbis_block_internal *)vb->internal;
int n=vb->pcmend;
int i,j,k;
@@ -305,25 +190,14 @@
float global_ampmax=vbi->ampmax;
float *local_ampmax=alloca(sizeof(*local_ampmax)*vi->channels);
int blocktype=vbi->blocktype;
+ vorbis_psy_look *psy_look=
+ b->psy+ci->block_to_psy_map[blocktype+(vb->W?2:0)];
long setup_bits=0;
-
- /* we differentiate between short and long block types to help the
- masking engine; the window shapes also matter.
- impulse block (a short block in which an impulse occurs)
- padding block (a short block that pads between a transitional
- long block and an impulse block, or vice versa)
- transition block (the weird one; a long block with the transition
- window; affects bass/midrange response and that must be
- accounted for in masking)
- long block (run of the mill long block)
- */
-
for(i=0;i<vi->channels;i++){
float scale=4.f/n;
float scale_dB;
- /* the following makes things clearer to *me* anyway */
float *pcm =vb->pcm[i];
float *logfft =pcm;
@@ -355,7 +229,7 @@
mdct_forward(b->transform[vb->W][0],pcm,gmdct[i]);
/* FFT yields more accurate tonal estimation (not phase sensitive) */
- drft_forward(&look->fft_look,pcm);
+ drft_forward(&b->fft_look[vb->W],pcm);
logfft[0]=scale_dB+todB(pcm);
local_ampmax[i]=logfft[0];
for(j=1;j<n-1;j+=2){
@@ -376,11 +250,11 @@
#endif
}
-
+
{
float *noise = _vorbis_block_alloc(vb,n/2*sizeof(*noise));
float *tone = _vorbis_block_alloc(vb,n/2*sizeof(*tone));
-
+
for(i=0;i<vi->channels;i++){
int submap=info->chmuxlist[i];
@@ -391,19 +265,26 @@
float *logmdct =logfft+n/2;
float *logmask =logfft;
+ /* the encoder setup assumes that all the modes used by any
+ specific bitrate tweaking use the same floor */
+
+ int modenumber=ci->modeselect[vb->W][PACKETBLOBS/2];
+ vorbis_info_mapping0 *info=ci->map_param[modenumber];
+ vb->mode=modenumber;
+
floor_posts[i]=_vorbis_block_alloc(vb,PACKETBLOBS*sizeof(**floor_posts));
memset(floor_posts[i],0,sizeof(**floor_posts)*PACKETBLOBS);
for(j=0;j<n/2;j++)
logmdct[j]=todB(mdct+j);
-#if 0
+ //#if 0
if(vi->channels==2)
if(i==0)
_analysis_output_always("mdctL",seq,logmdct,n/2,1,0,0);
else
_analysis_output_always("mdctR",seq,logmdct,n/2,1,0,0);
-#endif
+ //#endif
/* first step; noise masking. Not only does 'noise masking'
give us curves from which we can decide how much resolution
@@ -411,23 +292,23 @@
us a tonality estimate (the larger the value in the
'noise_depth' vector, the more tonal that area is) */
- _vp_noisemask(look->psy_look[blocktype],
+ _vp_noisemask(psy_look.
logmdct,
noise); /* noise does not have by-frequency offset
bias applied yet */
-#if 0
+ //#if 0
if(vi->channels==2)
if(i==0)
_analysis_output_always("noiseL",seq,noise,n/2,1,0,0);
else
_analysis_output_always("noiseR",seq,noise,n/2,1,0,0);
-#endif
+ //#endif
/* second step: 'all the other crap'; all the stuff that isn't
computed/fit for bitrate management goes in the second psy
vector. This includes tone masking, peak limiting and ATH */
- _vp_tonemask(look->psy_look[blocktype],
+ _vp_tonemask(psy_look,
logfft,
tone,
global_ampmax,
@@ -446,7 +327,7 @@
performing bitrate management, the line fit is performed
multiple times for up/down tweakage on demand. */
- _vp_offset_and_mix(look->psy_look[blocktype],
+ _vp_offset_and_mix(psy_look,
noise,
tone,
1,
@@ -466,7 +347,7 @@
if(ci->floor_type[info->floorsubmap[submap]]!=1)return(-1);
floor_posts[i][PACKETBLOBS/2]=
- floor1_fit(vb,look->floor_look[submap],
+ floor1_fit(vb,b->floor[info->floorsubmap[submap]],
logmdct,
logmask);
@@ -474,7 +355,7 @@
later rate tweaking (fits represent hi/lo) */
if(vorbis_bitrate_managed(vb) && floor_posts[i][PACKETBLOBS/2]){
/* higher rate by way of lower noise curve */
- _vp_offset_and_mix(look->psy_look[blocktype],
+ _vp_offset_and_mix(psy_look,
noise,
tone,
2,
@@ -487,14 +368,14 @@
else
_analysis_output_always("mask2R",seq,logmask,n/2,1,0,0);
#endif
-
+
floor_posts[i][PACKETBLOBS-1]=
- floor1_fit(vb,look->floor_look[submap],
+ floor1_fit(vb,b->floor[info->floorsubmap[submap]],
logmdct,
logmask);
/* lower rate by way of higher noise curve */
- _vp_offset_and_mix(look->psy_look[blocktype],
+ _vp_offset_and_mix(psy_look,
noise,
tone,
0,
@@ -509,7 +390,7 @@
#endif
floor_posts[i][0]=
- floor1_fit(vb,look->floor_look[submap],
+ floor1_fit(vb,b->floor[info->floorsubmap[submap]],
logmdct,
logmask);
@@ -517,13 +398,13 @@
intermediate rates */
for(k=1;k<PACKETBLOBS/2;k++)
floor_posts[i][k]=
- floor1_interpolate_fit(vb,look->floor_look[submap],
+ floor1_interpolate_fit(vb,b->floor[info->floorsubmap[submap]],
floor_posts[i][0],
floor_posts[i][PACKETBLOBS/2],
k*65536/(PACKETBLOBS/2));
for(k=PACKETBLOBS/2+1;k<PACKETBLOBS-1;k++)
floor_posts[i][k]=
- floor1_interpolate_fit(vb,look->floor_look[submap],
+ floor1_interpolate_fit(vb,b->floor[info->floorsubmap[submap]],
floor_posts[i][PACKETBLOBS/2],
floor_posts[i][PACKETBLOBS-1],
(k-PACKETBLOBS/2)*65536/(PACKETBLOBS/2));
@@ -539,7 +420,7 @@
the next phases are performed once for vbr-only and PACKETBLOB
times for bitrate managed modes.
- 1) reset write buffer
+ 1) encode actual mode being used
2) encode the floor for each channel, compute coded mask curve/res
3) normalize and couple.
4) encode residue
@@ -556,7 +437,7 @@
float **mag_memo=
_vp_quantize_couple_memo(vb,
- look->psy_look[blocktype],
+ psy_look,
info,
gmdct);
@@ -564,12 +445,19 @@
k<=(vorbis_bitrate_managed(vb)?PACKETBLOBS-1:PACKETBLOBS/2);
k++){
- /* Abuse the bitpacker abstraction slightly by storing multiple
- packets in one packbuffer. */
- if(vorbis_bitrate_managed(vb) && k){
- oggpack_writecopy(&vb->opb,
- oggpack_get_buffer(&vb->opb),
- setup_bits);
+ int modenumber=ci->modeselect[vb->W][k];
+ vorbis_info_mapping0 *info=ci->map_param[modenumber];
+ vb->mode=modenumber;
+
+ /* start out our new packet blob with packet type and mode */
+ /* Encode the packet type */
+ oggpack_write(&vb->opb,0,1);
+ /* Encode the modenumber */
+ /* Encode frame mode, pre,post windowsize, then dispatch */
+ oggpack_write(&vb->opb,modenumber,b->modebits);
+ if(vb->W){
+ oggpack_write(&vb->opb,vb->lW,1);
+ oggpack_write(&vb->opb,vb->nW,1);
}
/* encode floor, compute masking curve, sep out residue */
@@ -580,7 +468,14 @@
int *ilogmask=ilogmaskch[i]=
_vorbis_block_alloc(vb,n/2*sizeof(**gmdct));
- nonzero[i]=floor1_encode(vb,look->floor_look[submap],
+ if(info->floorsubmap[submap] !=
+ ci->map_param[ci->modeselect[vb->W][PACKETBLOBS/2]]->
+ floorsubmap[submap])return(-1); /* breaks encoder
+ assumptions; all the
+ packetblobs must use the
+ same floor */
+
+ nonzero[i]=floor1_encode(vb,b->floor[info->floorsubmap[submap]],
floor_posts[i][k],
ilogmask);
#if 0
@@ -590,7 +485,7 @@
_analysis_output_always(buf,seq+i,mask,n/2,1,1,0);
}
#endif
- _vp_remove_floor(look->psy_look[blocktype],
+ _vp_remove_floor(psy_look,
mdct,
ilogmask,
res);
@@ -608,7 +503,7 @@
coupling. Only one prequant/coupling step */
/* quantize/couple */
- _vp_quantize_couple(look->psy_look[blocktype],
+ _vp_quantize_couple(psy_look,
info,
vb->pcm,
mag_memo,
@@ -620,6 +515,7 @@
for(i=0;i<info->submaps;i++){
int ch_in_bundle=0;
long **classifications;
+ int resnum=info->residuesubmap[i];
for(j=0;j<vi->channels;j++){
if(info->chmuxlist[j]==i){
@@ -630,12 +526,11 @@
}
}
- classifications=look->residue_func[i]->
- class(vb,look->residue_look[i],
- res_bundle,zerobundle,ch_in_bundle);
+ classifications=_residue_P[ci->residue_type[resnum]]->
+ class(vb,b->residue[resnum],res_bundle,zerobundle,ch_in_bundle);
- look->residue_func[i]->
- forward(vb,look->residue_look[i],
+ _residue_P[ci->residue_type[resnum]]->
+ forward(vb,b->residue[resnum],
couple_bundle,NULL,zerobundle,ch_in_bundle,classifications);
}
@@ -649,18 +544,16 @@
}
total+=ci->blocksizes[vb->W]/4+ci->blocksizes[vb->nW]/4;
- look->lastframe=vb->sequence;
return(0);
}
-static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){
+static int mapping0_inverse(vorbis_block *vb,vorbis_info_mapping *l){
vorbis_dsp_state *vd=vb->vd;
vorbis_info *vi=vd->vi;
codec_setup_info *ci=vi->codec_setup;
backend_lookup_state *b=vd->backend_state;
- vorbis_look_mapping0 *look=(vorbis_look_mapping0 *)l;
- vorbis_info_mapping0 *info=look->map;
- /*vorbis_info_mode *mode=look->mode;*/
+ vorbis_info_mapping0 *info=(vorbis_info_mapping0 *)l;
+
int i,j;
long n=vb->pcmend=ci->blocksizes[vb->W];
@@ -673,8 +566,8 @@
/* recover the spectral envelope; store it in the PCM vector for now */
for(i=0;i<vi->channels;i++){
int submap=info->chmuxlist[i];
- floormemo[i]=look->floor_func[submap]->
- inverse1(vb,look->floor_look[submap]);
+ floormemo[i]=_floor_P[ci->floor_type[info->floorsubmap[submap]]]->
+ inverse1(vb,b->floor[info->floorsubmap[submap]]);
if(floormemo[i])
nonzero[i]=1;
else
@@ -703,9 +596,10 @@
pcmbundle[ch_in_bundle++]=vb->pcm[j];
}
}
-
- look->residue_func[i]->inverse(vb,look->residue_look[i],
- pcmbundle,zerobundle,ch_in_bundle);
+
+ _residue_P[ci->residue_type[info->residuesubmap[i]]]->
+ inverse(vb,b->residue[info->residuesubmap[i]],
+ pcmbundle,zerobundle,ch_in_bundle);
}
/* channel coupling */
@@ -740,8 +634,10 @@
for(i=0;i<vi->channels;i++){
float *pcm=vb->pcm[i];
int submap=info->chmuxlist[i];
- look->floor_func[submap]->
- inverse2(vb,look->floor_look[submap],floormemo[i],pcm);
+ _floor_P[ci->floor_type[info->floorsubmap[submap]]]->
+ inverse2(vb,b->floor[info->floorsubmap[submap]],
+ floormemo[i],pcm);
+
//_analysis_output_always("out",seq++,pcm,n/2,1,1,0);
}
@@ -771,10 +667,7 @@
vorbis_func_mapping mapping0_exportbundle={
&mapping0_pack,
&mapping0_unpack,
- &mapping0_look,
- &mapping0_copy_info,
&mapping0_free_info,
- &mapping0_free_look,
&mapping0_forward,
&mapping0_inverse
};
<p><p>1.67.2.3 +0 -24 vorbis/lib/psy.c
Index: psy.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/psy.c,v
retrieving revision 1.67.2.2
retrieving revision 1.67.2.3
diff -u -r1.67.2.2 -r1.67.2.3
--- psy.c 2002/05/08 01:06:33 1.67.2.2
+++ psy.c 2002/05/14 07:06:41 1.67.2.3
@@ -11,7 +11,7 @@
********************************************************************
function: psychoacoustics not including preecho
- last mod: $Id: psy.c,v 1.67.2.2 2002/05/08 01:06:33 xiphmont Exp $
+ last mod: $Id: psy.c,v 1.67.2.3 2002/05/14 07:06:41 xiphmont Exp $
********************************************************************/
@@ -1042,30 +1042,6 @@
*mag=premag*floormag;
*ang=0.f;
}
-
-#if 0
-static void couple_point(float A, float B, float fA, float fB,
- float granule,float igranule,
- float fmag, float *mag, float *ang){
-
- if(fmag!=0.f){
- float corr=FAST_HYPOT(A*fA,B*fB)/FAST_HYPOT(fA,fB);
-
- if(fabs(A)>fabs(B)){
- *mag=A;
- }else{
- *mag=B;
- }
-
- *mag=unitnorm(*mag)*floor(corr*igranule+.5f)*granule;
- *ang=0.f;
-
- }else{
- *mag=0.f;
- *ang=0.f;
- }
-}
-#endif
/* just like below, this is currently set up to only do
single-step-depth coupling. Otherwise, we'd have to do more
<p><p>1.28.2.2 +20 -25 vorbis/lib/psy.h
Index: psy.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/psy.h,v
retrieving revision 1.28.2.1
retrieving revision 1.28.2.2
diff -u -r1.28.2.1 -r1.28.2.2
--- psy.h 2002/05/07 23:47:14 1.28.2.1
+++ psy.h 2002/05/14 07:06:42 1.28.2.2
@@ -11,7 +11,7 @@
********************************************************************
function: random psychoacoustics (not including preecho)
- last mod: $Id: psy.h,v 1.28.2.1 2002/05/07 23:47:14 xiphmont Exp $
+ last mod: $Id: psy.h,v 1.28.2.2 2002/05/14 07:06:42 xiphmont Exp $
********************************************************************/
@@ -32,27 +32,20 @@
#define P_LEVELS 11
#define P_NOISECURVES 3
-typedef struct vp_couple{
- float granulem;
- float igranulem;
-
- int limit; /* sample post */
- float amppost_point;
-
-} vp_couple;
-
typedef struct vp_attenblock{
float block[P_BANDS][P_LEVELS];
} vp_attenblock;
#define NOISE_COMPAND_LEVELS 40
typedef struct vorbis_info_psy{
- float ath[27];
+ int blockflag;
+
+ float ath[27];
- float ath_adjatt;
- float ath_maxatt;
+ float ath_adjatt;
+ float ath_maxatt;
- float tone_masteratt;
+ float tone_masteratt[P_NOISECURVES];
float tone_guard;
float tone_abs_limit;
vp_attenblock toneatt;
@@ -73,29 +66,31 @@
float max_curve_dB;
- vp_couple couple_pass;
-
} vorbis_info_psy;
typedef struct{
- int eighth_octave_lines;
+ int eighth_octave_lines;
/* for block long/short tuning; encode only */
- float preecho_thresh[VE_BANDS];
- float postecho_thresh[VE_BANDS];
- float stretch_penalty;
- float preecho_minenergy;
+ float preecho_thresh[VE_BANDS];
+ float postecho_thresh[VE_BANDS];
+ float stretch_penalty;
+ float preecho_minenergy;
- float ampmax_att_per_sec;
+ float ampmax_att_per_sec;
/* delay caching... how many samples to keep around prior to our
current block to aid in analysis? */
- int delaycache;
+ int delaycache;
+
+ /* channel monofilter config */
+ float monofilter_kHz[P_NOISECURVES];
+
} vorbis_info_psy_global;
typedef struct {
- float ampmax;
- int channels;
+ float ampmax;
+ int channels;
vorbis_info_psy_global *gi;
} vorbis_look_psy_global;
<p><p>1.13.6.2 +1 -7 vorbis/lib/registry.c
Index: registry.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/registry.c,v
retrieving revision 1.13.6.1
retrieving revision 1.13.6.2
diff -u -r1.13.6.1 -r1.13.6.2
--- registry.c 2002/05/07 23:47:14 1.13.6.1
+++ registry.c 2002/05/14 07:06:42 1.13.6.2
@@ -11,7 +11,7 @@
********************************************************************
function: registry for time, floor, res backends and channel mappings
- last mod: $Id: registry.c,v 1.13.6.1 2002/05/07 23:47:14 xiphmont Exp $
+ last mod: $Id: registry.c,v 1.13.6.2 2002/05/14 07:06:42 xiphmont Exp $
********************************************************************/
@@ -46,10 +46,4 @@
vorbis_func_mapping *_mapping_P[]={
&mapping0_exportbundle,
};
-
-/* make Windows happy; can't access the registry directly outside of
- libvorbis, and vorbisenc needs a few functions */
-void residue_free_info(vorbis_info_residue *r,int type){
- _residue_P[type]->free_info(r);
-}
<p><p>1.45.4.2 +4 -15 vorbis/lib/res0.c
Index: res0.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/res0.c,v
retrieving revision 1.45.4.1
retrieving revision 1.45.4.2
diff -u -r1.45.4.1 -r1.45.4.2
--- res0.c 2002/05/07 23:47:15 1.45.4.1
+++ res0.c 2002/05/14 07:06:42 1.45.4.2
@@ -11,7 +11,7 @@
********************************************************************
function: residue backend 0, 1 and 2 implementation
- last mod: $Id: res0.c,v 1.45.4.1 2002/05/07 23:47:15 xiphmont Exp $
+ last mod: $Id: res0.c,v 1.45.4.2 2002/05/14 07:06:42 xiphmont Exp $
********************************************************************/
@@ -37,7 +37,6 @@
typedef struct {
vorbis_info_residue0 *info;
- int map;
int parts;
int stages;
@@ -63,13 +62,6 @@
} vorbis_look_residue0;
-vorbis_info_residue *res0_copy_info(vorbis_info_residue *vr){
- vorbis_info_residue0 *info=(vorbis_info_residue0 *)vr;
- vorbis_info_residue0 *ret=_ogg_malloc(sizeof(*ret));
- memcpy(ret,info,sizeof(*ret));
- return(ret);
-}
-
void res0_free_info(vorbis_info_residue *i){
vorbis_info_residue0 *info=(vorbis_info_residue0 *)i;
if(info){
@@ -235,8 +227,8 @@
return(NULL);
}
-vorbis_look_residue *res0_look(vorbis_dsp_state *vd,vorbis_info_mode *vm,
- vorbis_info_residue *vr){
+vorbis_look_residue *res0_look(vorbis_dsp_state *vd,
+ vorbis_info_residue *vr){
vorbis_info_residue0 *info=(vorbis_info_residue0 *)vr;
vorbis_look_residue0 *look=_ogg_calloc(1,sizeof(*look));
codec_setup_info *ci=vd->vi->codec_setup;
@@ -245,7 +237,6 @@
int dim;
int maxstage=0;
look->info=info;
- look->map=vm->mapping;
look->parts=info->partitions;
look->fullbooks=ci->fullbooks;
@@ -888,7 +879,6 @@
NULL,
&res0_unpack,
&res0_look,
- &res0_copy_info,
&res0_free_info,
&res0_free_look,
NULL,
@@ -900,7 +890,6 @@
&res0_pack,
&res0_unpack,
&res0_look,
- &res0_copy_info,
&res0_free_info,
&res0_free_look,
&res1_class,
@@ -912,10 +901,10 @@
&res0_pack,
&res0_unpack,
&res0_look,
- &res0_copy_info,
&res0_free_info,
&res0_free_look,
&res2_class,
&res2_forward,
&res2_inverse
};
+
<p><p>1.39.2.2 +102 -84 vorbis/lib/vorbisenc.c
Index: vorbisenc.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/vorbisenc.c,v
retrieving revision 1.39.2.1
retrieving revision 1.39.2.2
diff -u -r1.39.2.1 -r1.39.2.2
--- vorbisenc.c 2002/05/07 23:47:15 1.39.2.1
+++ vorbisenc.c 2002/05/14 07:06:42 1.39.2.2
@@ -11,7 +11,7 @@
********************************************************************
function: simple programmatic interface for encoder mode setup
- last mod: $Id: vorbisenc.c,v 1.39.2.1 2002/05/07 23:47:15 xiphmont Exp $
+ last mod: $Id: vorbisenc.c,v 1.39.2.2 2002/05/14 07:06:42 xiphmont Exp $
********************************************************************/
@@ -39,6 +39,12 @@
static_codebook *books_base[5][10][3];
} vorbis_residue_template;
+typedef struct {
+ int modenum[2][PACKETBLOBS];
+ float couple_pointlimit_kHz[2][PACKETBLOBS];
+ int couple_pointamp[2][PACKETBLOBS];
+} mode_easy_setup;
+
static double stereo_threshholds[]={0.0, 2.5, 4.5, 8.5, 16.5};
typedef struct vp_adjblock{
@@ -50,18 +56,21 @@
#include "modes/floor_44.h"
/* a few static coder conventions */
-static vorbis_info_mode _mode_set_short={0,0,0,0};
-static vorbis_info_mode _mode_set_long={1,0,0,1};
+static vorbis_info_mode _mode_template[2]={
+ {0,0,0,-1},
+ {1,0,0,-1}
+};
/* mapping conventions:
only one submap (this would change for efficient 5.1 support for example)*/
/* Four psychoacoustic profiles are used, one for each blocktype */
-static vorbis_info_mapping0 _mapping_set_short={
- 1, {0,0}, {0}, {0}, {0}, {0,1}, 0,{0},{0}};
-static vorbis_info_mapping0 _mapping_set_long={
- 1, {0,0}, {0}, {1}, {1}, {2,3}, 0,{0},{0}};
+static vorbis_info_mapping0 _mapping_template[2]={
+ {1, {0,0}, {0}, {-1}, {0,1}, 0,{0},{0},0,0},
+ {1, {0,0}, {1}, {-1}, {2,3}, 0,{0},{0},0,0}
+};
-static int vorbis_encode_toplevel_setup(vorbis_info *vi,int small,int large,int ch,long rate){
+static int vorbis_encode_toplevel_setup(vorbis_info *vi,int small,
+ int large,int ch,long rate){
if(vi && vi->codec_setup){
codec_setup_info *ci=vi->codec_setup;
@@ -72,24 +81,6 @@
ci->blocksizes[0]=small;
ci->blocksizes[1]=large;
- /* by convention, two modes: one for short, one for long blocks.
- short block mode uses mapping sero, long block uses mapping 1 */
- ci->modes=2;
- ci->mode_param[0]=_ogg_calloc(1,sizeof(_mode_set_short));
- memcpy(ci->mode_param[0],&_mode_set_short,sizeof(_mode_set_short));
- ci->mode_param[1]=_ogg_calloc(1,sizeof(_mode_set_long));
- memcpy(ci->mode_param[1],&_mode_set_long,sizeof(_mode_set_long));
-
- /* by convention two mappings, both mapping type zero (polyphonic
- PCM), first for short, second for long blocks */
- ci->maps=2;
- ci->map_type[0]=0;
- ci->map_param[0]=_ogg_calloc(1,sizeof(_mapping_set_short));
- memcpy(ci->map_param[0],&_mapping_set_short,sizeof(_mapping_set_short));
- ci->map_type[1]=0;
- ci->map_param[1]=_ogg_calloc(1,sizeof(_mapping_set_long));
- memcpy(ci->map_param[1],&_mapping_set_long,sizeof(_mapping_set_long));
-
return(0);
}
return(OV_EINVAL);
@@ -197,7 +188,7 @@
}
static int vorbis_encode_tonemask_setup(vorbis_info *vi,double q,int block,
- double *att,
+ double **att,
double *max,
int *peaklimit_bands,
vp_adjblock *in){
@@ -214,7 +205,12 @@
dq=q*10.-iq;
}
- p->tone_masteratt=att[iq]*(1.-dq)+att[iq+1]*dq;
+ /* 0 and 2 are only used by bitmanagement, but there's no harm to always
+ filling the values in here */
+ p->tone_masteratt[0]=att[iq][0]*(1.-dq)+att[iq+1][0]*dq;
+ p->tone_masteratt[1]=att[iq][1]*(1.-dq)+att[iq+1][1]*dq;
+ p->tone_masteratt[2]=att[iq][2]*(1.-dq)+att[iq+1][2]*dq;
+
p->max_curve_dB=max[iq]*(1.-dq)+max[iq+1]*dq;
p->curvelimitp=peaklimit_bands[iq];
@@ -377,29 +373,40 @@
return(ci->books++);
}
-static int vorbis_encode_residue_setup(vorbis_info *vi,double q,int block,
- int coupled_p,
- vorbis_residue_template *in,
- int point_dB,
- double point_kHz){
+/* modes, mappings and residue backends all correlate by convention in
+ this coder, so we set them up together here */
+static int vorbis_encode_residue_one(vorbis_info *vi,
+ double q,
+ int block,
+ int number,
+ int coupled_p,
+ vorbis_residue_template *in,
+ int point_dB,
+ double point_kHz){
int i,iq=q*10;
int n,k;
int partition_position=0;
int res_position=0;
-
codec_setup_info *ci=vi->codec_setup;
- vorbis_info_residue0 *r;
- vorbis_info_psy *psy=ci->psy_param[block*2];
-
- /* may be re-called due to ctl */
- if(ci->residue_param[block])
- /* free preexisting instance */
- residue_free_info(ci->residue_param[block],ci->residue_type[block]);
-
- r=ci->residue_param[block]=_ogg_malloc(sizeof(*r));
- memcpy(r,in[iq].res[block],sizeof(*r));
- if(ci->residues<=block)ci->residues=block+1;
+ vorbis_info_residue0 *r=ci->residue_param[number]=
+ _ogg_malloc(sizeof(*r));
+ vorbis_info_mapping0 *map=ci->map_param[number]=
+ _ogg_calloc(1,sizeof(*_mapping_set));
+
+ ci->mode_param[number]=_ogg_calloc(1,sizeof(*_mode_set));
+
+ memcpy(ci->mode_param[number],&_mode_set[block],sizeof(*_mode_set));
+ if(number>=ci->modes)ci->modes=number+1;
+ ci->mode_param[number]->mapping=number;
+
+ ci->map_type[number]=0;
+ memcpy(ci->map_param[number],&_mapping_set[block],sizeof(*_mapping_set));
+ if(number>=ci->mappings)ci->mappings=number+1;
+ ci->map_param[number]->residuesubmap[0]=number;
+
+ memcpy(r,in[iq].res[number],sizeof(*r));
+ if(ci->residues<=number)ci->residues=number+1;
if(block){
r->grouping=32;
@@ -409,12 +416,12 @@
/* for uncoupled, we use type 1, else type 2 */
if(coupled_p){
- ci->residue_type[block]=2;
+ ci->residue_type[number]=2;
}else{
- ci->residue_type[block]=1;
+ ci->residue_type[number]=1;
}
- switch(ci->residue_type[block]){
+ switch(ci->residue_type[number]){
case 1:
n=r->end=ci->blocksizes[block?1:0]>>1; /* to be adjusted by lowpass later */
partition_position=rint(point_kHz*1000./(vi->rate/2)*n/r->grouping);
@@ -436,24 +443,17 @@
r->secondstages[i]|=(1<<k);
if(coupled_p){
- vorbis_info_mapping0 *map=ci->map_param[block];
+ vorbis_info_mapping0 *map=ci->map_param[number];
map->coupling_steps=1;
map->coupling_mag[0]=0;
map->coupling_ang[0]=1;
-
- psy->couple_pass.granulem=1.;
- psy->couple_pass.igranulem=1.;
-
- psy->couple_pass.limit=res_position;
- psy->couple_pass.amppost_point= stereo_threshholds[point_dB];
-
+
+ map->coupling_pointlimit=res_position;
+ map->coupling_pointamp=stereo_threshholds[point_dB];
+
}
- memcpy(&ci->psy_param[block*2+1]->couple_pass,
- &ci->psy_param[block*2]->couple_pass,
- sizeof(psy->couple_pass));
-
/* fill in all the books */
{
int booklist=0,k;
@@ -471,6 +471,47 @@
}
return(0);
+}
+
+static int vorbis_encode_residue_setup(vorbis_info *vi,double q,int block,
+ int coupled_p,
+ vorbis_residue_template *in,
+ int *point_dB,
+ double point_kHz){
+
+ int i,iq=q*10;
+ int n,k;
+ int partition_position=0;
+ int res_position=0;
+ int alternate_modes=1;
+ codec_setup_info *ci=vi->codec_setup;
+
+ /* more complex than in rc3 due to coupling; we may be using
+ multiple modes, each with a different residue setup, as a helper
+ to bitrate managemnt, letting us change the stereo model
+ parameters in use. */
+
+ /* first assumption: short and long blocks use the same number of
+ alternate modes (things are currently configured that way) */
+ if(coupled_p){
+ int count=0;
+ for(i=1;i<PACKETBLOBS;i++)
+ if(point_dB[i-1]!=point_dB[i])alternate_modes++;
+
+ vorbis_encode_residue_one(vi,q,block,block*alternate_modes,
+ coupled_p,in,point_dB[0],point_kHz);
+ count++;
+ for(i=1;i<PACKETBLOBS;i++)
+ if(point_dB[i-1]!=point_dB[i])
+ vorbis_encode_residue_one(vi,q,block,block*alternate_modes+count++,
+ coupled_p,in,point_dB[i],point_kHz);
+ }else{
+ vorbis_encode_residue_one(vi,q,block,block*alternate_modes,
+ coupled_p,in,point_dB[PACKETBLOBS/2],
+ point_kHz);
+ }
+
+ return(0);
}
static int vorbis_encode_lowpass_setup(vorbis_info *vi,double q,int block){
@@ -528,7 +569,7 @@
ret|=vorbis_encode_floor_setup(vi,hi->base_quality_short,0,
_floor_44_128_books,_floor_44_128,
- 0,1,1,2,0,2,2,2,2,2,2);
+ 0,1,1,2,2,2,2,2,2,2,2);
ret|=vorbis_encode_floor_setup(vi,hi->base_quality_long,1,
_floor_44_1024_books,_floor_44_1024,
0,0,0,0,0,0,0,0,0,0,0);
@@ -849,29 +890,6 @@
{
codec_setup_info *ci=vi->codec_setup;
highlevel_encode_setup *hi=&ci->hi;
-
-#if 0
- /* no impulse blocks */
- hi->impulse_block_p=0;
- /* de-rate stereo */
- if(hi->stereo_point_dB && hi->stereo_couple_p && channels==2){
- hi->stereo_point_dB++;
- if(hi->stereo_point_dB>3)hi->stereo_point_dB=3;
- }
- /* slug the vbr noise setting*/
- hi->blocktype[0].noise_bias_quality-=.1;
- if(hi->blocktype[0].noise_bias_quality<0.)
- hi->blocktype[0].noise_bias_quality=0.;
- hi->blocktype[1].noise_bias_quality-=.1;
- if(hi->blocktype[1].noise_bias_quality<0.)
- hi->blocktype[1].noise_bias_quality=0.;
- hi->blocktype[2].noise_bias_quality-=.05;
- if(hi->blocktype[2].noise_bias_quality<0.)
- hi->blocktype[2].noise_bias_quality=0.;
- hi->blocktype[3].noise_bias_quality-=.05;
- if(hi->blocktype[3].noise_bias_quality<0.)
- hi->blocktype[3].noise_bias_quality=0.;
-#endif
/* initialize management. Currently hardcoded for 44, but so is above. */
memcpy(&ci->bi,&_bm_44_default,sizeof(ci->bi));
<p><p>No revision
<p>No revision
<p>1.15.2.2 +67 -9 vorbis/lib/modes/psych_44.h
Index: psych_44.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/modes/psych_44.h,v
retrieving revision 1.15.2.1
retrieving revision 1.15.2.2
diff -u -r1.15.2.1 -r1.15.2.2
--- psych_44.h 2002/05/07 23:47:21 1.15.2.1
+++ psych_44.h 2002/05/14 07:06:46 1.15.2.2
@@ -11,7 +11,7 @@
********************************************************************
function: key psychoacoustic settings for 44.1/48kHz
- last mod: $Id: psych_44.h,v 1.15.2.1 2002/05/07 23:47:21 xiphmont Exp $
+ last mod: $Id: psych_44.h,v 1.15.2.2 2002/05/14 07:06:46 xiphmont Exp $
********************************************************************/
@@ -669,10 +669,6 @@
10,10,100,
};
-static double _psy_tone_masteratt[11]={
- 3.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
-};
-
static double _psy_tone_masterguard[11]={
-18.,-24.,-24.,-24.,-26.,-40.,-40.,-40.,-45.,-45.,-45.,
};
@@ -730,15 +726,77 @@
2.f, 6.f, 5.f, 5.f, 15.f, 20.f, 40.f,
}
};
+
+/* stereo setup. These don't map directly to quality level, there's
+ an additional indirection as several of the below may be used in a
+ single bitmanaged stream
+
+****************/
+
+/* various stereo possibilities */
+
+/* stereo mode by base quality level */
+static int _psy_stereo_modes_44[10][PACKETBLOBS]={
+
+ /*0 1 2 3 4 5 6 7 8 9 10 11 12 13 14*/
+ { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}, /* 0 */
+ /*0 1 2 3 4 5 6 7 8 9 10 11 12 13 14*/
+ { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}, /* 1 */
+ /*0 1 2 3 4 5 6 7 8 9 10 11 12 13 14*/
+ { 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}, /* 2 */
+ /*0 1 2 3 4 5 6 7 8 9 10 11 12 13 14*/
+ { 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1}, /* 3 */
+ /*0 1 2 3 4 5 6 7 8 9 10 11 12 13 14*/
+ { 3, 3, 3, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* 4 */
+ /*0 1 2 3 4 5 6 7 8 9 10 11 12 13 14*/
+ {0}, /* 5 */
+ /*0 1 2 3 4 5 6 7 8 9 10 11 12 13 14*/
+ {0}, /* 6 */
+ /*0 1 2 3 4 5 6 7 8 9 10 11 12 13 14*/
+ {0}, /* 7 */
+ /*0 1 2 3 4 5 6 7 8 9 10 11 12 13 14*/
+ {0}, /* 8 */
+ /*0 1 2 3 4 5 6 7 8 9 10 11 12 13 14*/
+ {0}, /* 9 */
-/* stereo ****************/
-static int _psy_stereo_point_dB_44[11]={3, 3, 2, 2, 1, 0, 0, 0, 0, 0, 0};
+}
+
static double _psy_stereo_point_kHz_44[2][11]={
- {4., 6., 6., 6., 10., 6., 6., 4., 4., 4., 4.},
+ {4., 6., 6., 6., 10., 6., 6., 4., 4., 4., 4.},
{6., 6., 6., 10., 10., 6., 6., 4., 4., 4., 4.}
};
+
+static double _psy_tone_monopass_44[11][3]={
+ {0}, /* 0 */
+ {0}, /* 1 */
+ {0}, /* 2 */
+ {99.,99.,99.}, /* 3 */
+ {99.,99.,99.}, /* 4 */
+ {99.,99.,99.}, /* 5 */
+ {0}, /* 6 */
+ {0}, /* 7 */
+ {0}, /* 8 */
+ {0}, /* 9 */
+ {0}, /* 10 */
+};
+
+/* tone master attenuation by base quality mode and bitrate tweak */
+
+static double _psy_tone_masteratt_44[11][3]={
+ {0}, /* 0 */
+ {0}, /* 1 */
+ {0}, /* 2 */
+ { 0, 0, -10}, /* 3 */
+ { 0, 0, -10}, /* 4 */
+ { 0, 0, -10}, /* 5 */
+ {0}, /* 6 */
+ {0}, /* 7 */
+ {0}, /* 8 */
+ {0}, /* 9 */
+ {0}, /* 10 */
+};
-/* lowpass **************/
+/* lowpass by mode **************/
static double _psy_lowpass_44[11]={
15.1,15.8,16.5,17.9,20.5,48.,999.,999.,999.,999.,999.
};
<p><p>1.11.6.2 +6 -11 vorbis/lib/modes/residue_44.h
Index: residue_44.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/modes/residue_44.h,v
retrieving revision 1.11.6.1
retrieving revision 1.11.6.2
diff -u -r1.11.6.1 -r1.11.6.2
--- residue_44.h 2002/05/07 23:47:21 1.11.6.1
+++ residue_44.h 2002/05/14 07:06:46 1.11.6.2
@@ -11,7 +11,7 @@
********************************************************************
function: toplevel residue templates for 32/44.1/48kHz
- last mod: $Id: residue_44.h,v 1.11.6.1 2002/05/07 23:47:21 xiphmont Exp $
+ last mod: $Id: residue_44.h,v 1.11.6.2 2002/05/14 07:06:46 xiphmont Exp $
********************************************************************/
@@ -48,20 +48,18 @@
0,-1, -1, 8,-1,
{0},
{-1},
- {9999, 9999, 9999, 9999, 9999, 9999, 9999},
{ .5, 1.5, 2.5, 4.5, 26.5, 1.5, 4.5},
- {0},
{ 99, -1, -1, -1, -1, 99, 99}
+ -1,-1
};
/* 26 doesn't cascade well; use 28 instead */
static vorbis_info_residue0 _residue_44_low_un={
0,-1, -1, 8,-1,
{0},
{-1},
- {9999, 9999, 9999, 9999, 9999, 9999, 9999},
{ .5, 1.5, 2.5, 4.5, 28.5, 1.5, 4.5},
- {0},
{ 99, -1, -1, -1, -1, 99, 99}
+ -1,-1
};
/* 0 1 2 4 1 2 4 16 42 +
@@ -78,10 +76,9 @@
/* 0 1 2 3 4 5 6 7 8 9 */
{0},
{-1},
- {9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999},
{ .5, 1.5, 1.5, 2.5, 2.5, 4.5, 4.5, 16.5, 42.5},
- {0},
{ 99, -1, 99, -1, 99, -1, 99, 99, 99}
+ -1,-1
};
@@ -99,10 +96,9 @@
/* 0 1 2 3 4 5 6 7 8 9 */
{0},
{-1},
- {9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999},
{ .5, 8.5, 42.5, 1.5, 2.5, 4.5, 8.5, 16.5, 56.5},
- {0},
{ 99, -1, -1, 99, 99, 99, 99, 99, 99}
+ -1,-1
};
/* 56 doesn't cascade well; use 59 */
static vorbis_info_residue0 _residue_44_high_un={
@@ -110,10 +106,9 @@
/* 0 1 2 3 4 5 6 7 8 9 */
{0},
{-1},
- {9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999},
{ .5, 8.5, 42.5, 1.5, 2.5, 4.5, 8.5, 16.5, 59.5},
- {0},
{ 99, -1, -1, 99, 99, 99, 99, 99, 99}
+ -1,-1
};
#include "books/coupled/_44c0_short.vqh"
<p><p><p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list