Commit 399301e3 authored by Monty's avatar Monty
Browse files

New noise norm, coupling and quant code necessary for depth>1 coupling. Also substantially

cleans up the old code for mono/stereo usage.


svn path=/trunk/vorbis/; revision=16946
parent a60a3a59
......@@ -5,7 +5,7 @@ dnl Initialization and Versioning
dnl ------------------------------------------------
AC_INIT([libvorbis],[1.2.3],[vorbis-dev@xiph.org])
AC_INIT([libvorbis],[1.3.0],[vorbis-dev@xiph.org])
AC_CONFIG_SRCDIR([lib/mdct.c])
......@@ -25,7 +25,7 @@ dnl - interfaces added -> increment AGE
dnl - interfaces removed -> AGE = 0
V_LIB_CURRENT=4
V_LIB_REVISION=3
V_LIB_REVISION=4
V_LIB_AGE=4
VF_LIB_CURRENT=6
......@@ -33,7 +33,7 @@ VF_LIB_REVISION=2
VF_LIB_AGE=3
VE_LIB_CURRENT=2
VE_LIB_REVISION=6
VE_LIB_REVISION=7
VE_LIB_AGE=0
AC_SUBST(V_LIB_CURRENT)
......
......@@ -44,7 +44,7 @@ int main(){
stream of packets */
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
settings */
vorbis_comment vc; /* struct that stores all the user comments */
......@@ -69,7 +69,7 @@ int main(){
#ifdef _WIN32 /* We need to set stdin/stdout to binary mode. Damn windows. */
/* if we were reading/writing a file, it would also need to in
binary mode, eg, fopen("file.wav","wb"); */
/* Beware the evil ifdef. We avoid these where we can, but this one we
/* Beware the evil ifdef. We avoid these where we can, but this one we
cannot. Don't add any more, you'll probably go to hell if you do. */
_setmode( _fileno( stdin ), _O_BINARY );
_setmode( _fileno( stdout ), _O_BINARY );
......@@ -84,16 +84,16 @@ int main(){
for (i=0, founddata=0; i<30 && ! feof(stdin) && ! ferror(stdin); i++)
{
fread(readbuffer,1,2,stdin);
if ( ! strncmp((char*)readbuffer, "da", 2) ){
founddata = 1;
fread(readbuffer,1,6,stdin);
break;
}
}
/********** Encode setup ************/
vorbis_info_init(&vi);
/* choose an encoding mode. A few possibilities commented out, one
......@@ -102,15 +102,15 @@ int main(){
/*********************************************************************
Encoding using a VBR quality mode. The usable range is -.1
(lowest quality, smallest file) to 1. (highest quality, largest file).
Example quality mode .4: 44kHz stereo coupled, roughly 128kbps VBR
Example quality mode .4: 44kHz stereo coupled, roughly 128kbps VBR
ret = vorbis_encode_init_vbr(&vi,2,44100,.4);
---------------------------------------------------------------------
Encoding using an average bitrate mode (ABR).
example: 44kHz stereo coupled, average 128kbps VBR
example: 44kHz stereo coupled, average 128kbps VBR
ret = vorbis_encode_init(&vi,2,44100,-1,128000,-1);
---------------------------------------------------------------------
......@@ -140,7 +140,7 @@ int main(){
/* set up the analysis state and auxiliary encoding storage */
vorbis_analysis_init(&vd,&vi);
vorbis_block_init(&vd,&vb);
/* set up our packet->stream encoder */
/* pick a random serial number; that way we can more likely build
chained streams just by concatenation */
......@@ -174,9 +174,9 @@ int main(){
fwrite(og.header,1,og.header_len,stdout);
fwrite(og.body,1,og.body_len,stdout);
}
}
while(!eos){
long i;
long bytes=fread(readbuffer,1,READ*4,stdin); /* stereo hardwired here */
......@@ -187,13 +187,13 @@ int main(){
Tell the library we're at end of stream so that it can handle
the last frame and mark end of stream in the output properly */
vorbis_analysis_wrote(&vd,0);
}else{
/* data to encode */
/* expose the buffer to submit data */
float **buffer=vorbis_analysis_buffer(&vd,READ);
/* uninterleave samples */
for(i=0;i<bytes/4;i++){
buffer[0][i]=((readbuffer[i*4+1]<<8)|
......@@ -201,7 +201,7 @@ int main(){
buffer[1][i]=((readbuffer[i*4+3]<<8)|
(0x00ff&(int)readbuffer[i*4+2]))/32768.f;
}
/* tell the library how much we actually submitted */
vorbis_analysis_wrote(&vd,i);
}
......@@ -216,20 +216,20 @@ int main(){
vorbis_bitrate_addblock(&vb);
while(vorbis_bitrate_flushpacket(&vd,&op)){
/* weld the packet into the bitstream */
ogg_stream_packetin(&os,&op);
/* write out pages (if any) */
while(!eos){
int result=ogg_stream_pageout(&os,&og);
if(result==0)break;
fwrite(og.header,1,og.header_len,stdout);
fwrite(og.body,1,og.body_len,stdout);
/* this could be set above, but for illustrative purposes, I do
it here (to show that vorbis does know where the stream ends) */
if(ogg_page_eos(&og))eos=1;
}
}
......@@ -237,16 +237,16 @@ int main(){
}
/* clean up and exit. vorbis_info_clear() must be called last */
ogg_stream_clear(&os);
vorbis_block_clear(&vb);
vorbis_dsp_clear(&vd);
vorbis_comment_clear(&vc);
vorbis_info_clear(&vi);
/* ogg_page and ogg_packet structs always point to storage in
libvorbis. They're never freed or manipulated directly */
fprintf(stderr,"Done.\n");
return(0);
}
......@@ -5,7 +5,7 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2010 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
......@@ -31,8 +31,8 @@
#include "misc.h"
#include "os.h"
#define GENERAL_VENDOR_STRING "Xiph.Org libVorbis 1.2.3"
#define ENCODE_VENDOR_STRING "Xiph.Org libVorbis I 20090709"
#define GENERAL_VENDOR_STRING "Xiph.Org libVorbis 1.3.0pre"
#define ENCODE_VENDOR_STRING "Xiph.Org libVorbis I 20100303pre (Everywhere)"
/* helpers */
static int ilog2(unsigned int v){
......
......@@ -5,7 +5,7 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2010 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
......@@ -600,36 +600,6 @@ static int mapping0_forward(vorbis_block *vb){
{
int **couple_bundle=alloca(sizeof(*couple_bundle)*vi->channels);
int *zerobundle=alloca(sizeof(*zerobundle)*vi->channels);
int **sortindex=alloca(sizeof(*sortindex)*vi->channels);
float **mag_memo=NULL;
int **mag_sort=NULL;
if(info->coupling_steps){
mag_memo=_vp_quantize_couple_memo(vb,
&ci->psy_g_param,
psy_look,
info,
gmdct);
mag_sort=_vp_quantize_couple_sort(vb,
psy_look,
info,
mag_memo);
hf_reduction(&ci->psy_g_param,
psy_look,
info,
mag_memo);
}
memset(sortindex,0,sizeof(*sortindex)*vi->channels);
if(psy_look->vi->normal_channel_p){
for(i=0;i<vi->channels;i++){
float *mdct =gmdct[i];
sortindex[i]=alloca(sizeof(**sortindex)*n/2);
_vp_noise_normalize_sort(psy_look,mdct,sortindex[i]);
}
}
for(k=(vorbis_bitrate_managed(vb)?0:PACKETBLOBS/2);
k<=(vorbis_bitrate_managed(vb)?PACKETBLOBS-1:PACKETBLOBS/2);
......@@ -650,9 +620,7 @@ static int mapping0_forward(vorbis_block *vb){
/* encode floor, compute masking curve, sep out residue */
for(i=0;i<vi->channels;i++){
int submap=info->chmuxlist[i];
float *mdct =gmdct[i];
float *res =vb->pcm[i];
int *ilogmask=iwork[i];
int *ilogmask=iwork[i];
nonzero[i]=floor1_encode(opb,vb,b->flr[info->floorsubmap[submap]],
floor_posts[i][k],
......@@ -663,28 +631,8 @@ static int mapping0_forward(vorbis_block *vb){
sprintf(buf,"maskI%c%d",i?'R':'L',k);
float work[n/2];
for(j=0;j<n/2;j++)
work[j]=FLOOR1_fromdB_LOOKUP[iwork[j]];
_analysis_output(buf,seq,work,n/2,1,1,0);
}
#endif
_vp_remove_floor(psy_look,
mdct,
ilogmask,
res,
ci->psy_g_param.sliding_lowpass[vb->W][k]);
_vp_noise_normalize(psy_look,res,res+n/2,sortindex[i]);
#if 0
{
char buf[80];
float work[n/2];
for(j=0;j<n/2;j++)
work[j]=FLOOR1_fromdB_LOOKUP[iwork[j]]*(res+n/2)[j];
sprintf(buf,"resI%c%d",i?'R':'L',k);
work[j]=FLOOR1_fromdB_LOOKUP[iwork[i][j]];
_analysis_output(buf,seq,work,n/2,1,1,0);
}
#endif
}
......@@ -695,24 +643,26 @@ static int mapping0_forward(vorbis_block *vb){
/* quantize/couple */
/* incomplete implementation that assumes the tree is all depth
one, or no tree at all */
if(info->coupling_steps){
_vp_couple(k,
&ci->psy_g_param,
psy_look,
info,
vb->pcm,
mag_memo,
mag_sort,
iwork,
nonzero,
ci->psy_g_param.sliding_lowpass[vb->W][k]);
}
for(j=0;j<vi->channels;j++){
int *ires = iwork[j];
float *res = vb->pcm[j]+n/2;
for(i=0;i<n/2;i++)
ires[i] = (int)rint(res[i]);
_vp_couple_quantize_normalize(k,
&ci->psy_g_param,
psy_look,
info,
gmdct,
iwork,
nonzero,
ci->psy_g_param.sliding_lowpass[vb->W][k],
vi->channels);
#if 0
for(i=0;i<vi->channels;i++){
char buf[80];
sprintf(buf,"resI%c%d",i?'R':'L',k);
float work[n/2];
for(j=0;j<n/2;j++)
work[j]=iwork[i][j];
_analysis_output(buf,seq,work,n/2,0,0,0);
}
#endif
/* classify and encode by submap */
for(i=0;i<info->submaps;i++){
......
......@@ -500,8 +500,8 @@ static const vorbis_info_psy _psy_info_template={
1, -0.f, .5f, .5f, 0,0,0,
/* noiseoffset*3, noisecompand, max_curve_dB */
{{-1},{-1},{-1}},{-1},105.f,
/* noise normalization - channel_p, point_p, start, partition, thresh. */
0,0,-1,-1,0.,
/* noise normalization - noise_p, start, partition, thresh. */
0,-1,-1,0.,
};
/* ath ****************/
......
This diff is collapsed.
......@@ -57,8 +57,7 @@ typedef struct vorbis_info_psy{
float max_curve_dB;
int normal_channel_p;
int normal_point_p;
int normal_p;
int normal_start;
int normal_partition;
double normal_thresh;
......@@ -122,12 +121,6 @@ extern void *_vi_psy_dup(void *source);
extern void _vi_psy_free(vorbis_info_psy *i);
extern vorbis_info_psy *_vi_psy_copy(vorbis_info_psy *i);
extern void _vp_remove_floor(vorbis_look_psy *p,
float *mdct,
int *icodedflr,
float *residue,
int sliding_lowpass);
extern void _vp_noisemask(vorbis_look_psy *p,
float *logmdct,
float *logmask);
......@@ -148,38 +141,14 @@ extern void _vp_offset_and_mix(vorbis_look_psy *p,
extern float _vp_ampmax_decay(float amp,vorbis_dsp_state *vd);
extern float **_vp_quantize_couple_memo(vorbis_block *vb,
vorbis_info_psy_global *g,
vorbis_look_psy *p,
vorbis_info_mapping0 *vi,
float **mdct);
extern void _vp_couple(int blobno,
vorbis_info_psy_global *g,
vorbis_look_psy *p,
vorbis_info_mapping0 *vi,
float **res,
float **mag_memo,
int **mag_sort,
int **ifloor,
int *nonzero,
int sliding_lowpass);
extern void _vp_noise_normalize(vorbis_look_psy *p,
float *in,float *out,int *sortedindex);
extern void _vp_noise_normalize_sort(vorbis_look_psy *p,
float *magnitudes,int *sortedindex);
extern int **_vp_quantize_couple_sort(vorbis_block *vb,
vorbis_look_psy *p,
vorbis_info_mapping0 *vi,
float **mags);
extern void hf_reduction(vorbis_info_psy_global *g,
vorbis_look_psy *p,
vorbis_info_mapping0 *vi,
float **mdct);
extern void _vp_couple_quantize_normalize(int blobno,
vorbis_info_psy_global *g,
vorbis_look_psy *p,
vorbis_info_mapping0 *vi,
float **mdct,
int **iwork,
int *nonzero,
int sliding_lowpass,
int ch);
#endif
......@@ -5,7 +5,7 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2010 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
......@@ -718,7 +718,7 @@ int res0_inverse(vorbis_block *vb,vorbis_look_residue *vl,
int res1_forward(oggpack_buffer *opb,vorbis_block *vb,vorbis_look_residue *vl,
int **in,int *nonzero,int ch, long **partword){
int i,j,used=0,n=vb->pcmend/2;
int i,used=0;
for(i=0;i<ch;i++)
if(nonzero[i])
in[used++]=in[i];
......
......@@ -331,8 +331,7 @@ static void vorbis_encode_psyset_setup(vorbis_info *vi,double s,
p->blockflag=block>>1;
if(hi->noise_normalize_p){
p->normal_channel_p=1;
p->normal_point_p=1;
p->normal_p=1;
p->normal_start=nn_start[is];
p->normal_partition=nn_partition[is];
p->normal_thresh=nn_thresh[is];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment