Cleanup some dependencies

This commit is contained in:
twinaphex 2021-10-08 16:59:44 +02:00
parent 9100eae148
commit 2e3e16ae3f
3 changed files with 24 additions and 229 deletions

View File

@ -145,26 +145,26 @@ SOURCES_C += $(FLUIDSYNTH_DIR)/src/fluid_chan.c \
$(FLUIDSYNTH_DIR)/src/fluid_voice.c
SOURCES_C += $(LIBVORBIS_DIR)/lib/analysis.c \
$(LIBVORBIS_DIR)/lib/bitrate.c \
$(LIBVORBIS_DIR)/lib/block.c \
$(LIBVORBIS_DIR)/lib/codebook.c \
$(LIBVORBIS_DIR)/lib/envelope.c \
$(LIBVORBIS_DIR)/lib/floor0.c \
$(LIBVORBIS_DIR)/lib/floor1.c \
$(LIBVORBIS_DIR)/lib/info.c \
$(LIBVORBIS_DIR)/lib/lookup.c \
$(LIBVORBIS_DIR)/lib/lpc.c \
$(LIBVORBIS_DIR)/lib/lsp.c \
$(LIBVORBIS_DIR)/lib/mapping0.c \
$(LIBVORBIS_DIR)/lib/mdct.c \
$(LIBVORBIS_DIR)/lib/psy.c \
$(LIBVORBIS_DIR)/lib/registry.c \
$(LIBVORBIS_DIR)/lib/res0.c \
$(LIBVORBIS_DIR)/lib/sharedbook.c \
$(LIBVORBIS_DIR)/lib/smallft.c \
$(LIBVORBIS_DIR)/lib/synthesis.c \
$(LIBVORBIS_DIR)/lib/vorbisfile.c \
$(LIBVORBIS_DIR)/lib/window.c
$(LIBVORBIS_DIR)/lib/bitrate.c \
$(LIBVORBIS_DIR)/lib/block.c \
$(LIBVORBIS_DIR)/lib/codebook.c \
$(LIBVORBIS_DIR)/lib/envelope.c \
$(LIBVORBIS_DIR)/lib/floor0.c \
$(LIBVORBIS_DIR)/lib/floor1.c \
$(LIBVORBIS_DIR)/lib/info.c \
$(LIBVORBIS_DIR)/lib/lookup.c \
$(LIBVORBIS_DIR)/lib/lpc.c \
$(LIBVORBIS_DIR)/lib/lsp.c \
$(LIBVORBIS_DIR)/lib/mapping0.c \
$(LIBVORBIS_DIR)/lib/mdct.c \
$(LIBVORBIS_DIR)/lib/psy.c \
$(LIBVORBIS_DIR)/lib/registry.c \
$(LIBVORBIS_DIR)/lib/res0.c \
$(LIBVORBIS_DIR)/lib/sharedbook.c \
$(LIBVORBIS_DIR)/lib/smallft.c \
$(LIBVORBIS_DIR)/lib/synthesis.c \
$(LIBVORBIS_DIR)/lib/vorbisfile.c \
$(LIBVORBIS_DIR)/lib/window.c
SOURCES_C += $(LIBOGG_DIR)/src/bitwise.c \
$(LIBOGG_DIR)/src/framing.c

View File

@ -881,17 +881,6 @@ int floor1_encode(oggpack_buffer *opb,vorbis_block *vb,
look->phrasebits+=
vorbis_book_encode(books+info->class_book[class],cval,opb);
#ifdef TRAIN_FLOOR1
{
FILE *of;
char buffer[80];
sprintf(buffer,"line_%dx%ld_class%d.vqd",
vb->pcmend/2,posts-2,class);
of=fopen(buffer,"a");
fprintf(of,"%d\n",cval);
fclose(of);
}
#endif
}
/* write post values */
@ -902,20 +891,6 @@ int floor1_encode(oggpack_buffer *opb,vorbis_block *vb,
if(out[j+k]<(books+book)->entries)
look->postbits+=vorbis_book_encode(books+book,
out[j+k],opb);
/*else
fprintf(stderr,"+!");*/
#ifdef TRAIN_FLOOR1
{
FILE *of;
char buffer[80];
sprintf(buffer,"line_%dx%ld_%dsub%d.vqd",
vb->pcmend/2,posts-2,class,bookas[k]);
of=fopen(buffer,"a");
fprintf(of,"%d\n",out[j+k]);
fclose(of);
}
#endif
}
}
j+=cdim;

View File

@ -31,13 +31,6 @@
#include "misc.h"
#include "os.h"
//#define TRAIN_RES 1
//#define TRAIN_RESAUX 1
#if defined(TRAIN_RES) || defined (TRAIN_RESAUX)
#include <stdio.h>
#endif
typedef struct {
vorbis_info_residue0 *info;
@ -53,17 +46,6 @@ typedef struct {
long postbits;
long phrasebits;
long frames;
#if defined(TRAIN_RES) || defined(TRAIN_RESAUX)
int train_seq;
long *training_data[8][64];
float training_max[8][64];
float training_min[8][64];
float tmin;
float tmax;
int submap;
#endif
} vorbis_look_residue0;
void res0_free_info(vorbis_info_residue *i){
@ -80,66 +62,6 @@ void res0_free_look(vorbis_look_residue *i){
vorbis_look_residue0 *look=(vorbis_look_residue0 *)i;
#ifdef TRAIN_RES
{
int j,k,l;
for(j=0;j<look->parts;j++){
/*fprintf(stderr,"partition %d: ",j);*/
for(k=0;k<8;k++)
if(look->training_data[k][j]){
char buffer[80];
FILE *of;
codebook *statebook=look->partbooks[j][k];
/* long and short into the same bucket by current convention */
sprintf(buffer,"res_sub%d_part%d_pass%d.vqd",look->submap,j,k);
of=fopen(buffer,"a");
for(l=0;l<statebook->entries;l++)
fprintf(of,"%d:%ld\n",l,look->training_data[k][j][l]);
fclose(of);
/*fprintf(stderr,"%d(%.2f|%.2f) ",k,
look->training_min[k][j],look->training_max[k][j]);*/
_ogg_free(look->training_data[k][j]);
look->training_data[k][j]=NULL;
}
/*fprintf(stderr,"\n");*/
}
}
fprintf(stderr,"min/max residue: %g::%g\n",look->tmin,look->tmax);
/*fprintf(stderr,"residue bit usage %f:%f (%f total)\n",
(float)look->phrasebits/look->frames,
(float)look->postbits/look->frames,
(float)(look->postbits+look->phrasebits)/look->frames);*/
#endif
/*vorbis_info_residue0 *info=look->info;
fprintf(stderr,
"%ld frames encoded in %ld phrasebits and %ld residue bits "
"(%g/frame) \n",look->frames,look->phrasebits,
look->resbitsflat,
(look->phrasebits+look->resbitsflat)/(float)look->frames);
for(j=0;j<look->parts;j++){
long acc=0;
fprintf(stderr,"\t[%d] == ",j);
for(k=0;k<look->stages;k++)
if((info->secondstages[j]>>k)&1){
fprintf(stderr,"%ld,",look->resbits[j][k]);
acc+=look->resbits[j][k];
}
fprintf(stderr,":: (%ld vals) %1.2fbits/sample\n",look->resvals[j],
acc?(float)acc/(look->resvals[j]*info->grouping):0);
}
fprintf(stderr,"\n");*/
for(j=0;j<look->parts;j++)
if(look->partbooks[j])_ogg_free(look->partbooks[j]);
_ogg_free(look->partbooks);
@ -282,10 +204,6 @@ vorbis_look_residue *res0_look(vorbis_dsp_state *vd,
for(k=0;k<stages;k++)
if(info->secondstages[j]&(1<<k)){
look->partbooks[j][k]=ci->fullbooks+info->booklist[acc++];
#ifdef TRAIN_RES
look->training_data[k][j]=_ogg_calloc(look->partbooks[j][k]->entries,
sizeof(***look->training_data));
#endif
}
}
}
@ -307,12 +225,6 @@ vorbis_look_residue *res0_look(vorbis_dsp_state *vd,
look->decodemap[j][k]=deco;
}
}
#if defined(TRAIN_RES) || defined (TRAIN_RESAUX)
{
static int train_seq=0;
look->train_seq=train_seq++;
}
#endif
return(look);
}
@ -381,13 +293,8 @@ static int local_book_besterror(codebook *book,int *a){
return(index);
}
#ifdef TRAIN_RES
static int _encodepart(oggpack_buffer *opb,int *vec, int n,
codebook *book,long *acc){
#else
static int _encodepart(oggpack_buffer *opb,int *vec, int n,
codebook *book){
#endif
int i,bits=0;
int dim=book->dim;
int step=n/dim;
@ -395,11 +302,6 @@ static int _encodepart(oggpack_buffer *opb,int *vec, int n,
for(i=0;i<step;i++){
int entry=local_book_besterror(book,vec+i*dim);
#ifdef TRAIN_RES
if(entry>=0)
acc[entry]++;
#endif
bits+=vorbis_book_encode(book,entry,opb);
}
@ -451,21 +353,6 @@ static long **_01class(vorbis_block *vb,vorbis_look_residue *vl,
}
}
#ifdef TRAIN_RESAUX
{
FILE *of;
char buffer[80];
for(i=0;i<ch;i++){
sprintf(buffer,"resaux_%d.vqd",look->train_seq);
of=fopen(buffer,"a");
for(j=0;j<partvals;j++)
fprintf(of,"%ld, ",partword[i][j]);
fprintf(of,"\n");
fclose(of);
}
}
#endif
look->frames++;
return(partword);
@ -488,11 +375,6 @@ static long **_2class(vorbis_block *vb,vorbis_look_residue *vl,int **in,
int partvals=n/samples_per_partition;
long **partword=_vorbis_block_alloc(vb,sizeof(*partword));
#if defined(TRAIN_RES) || defined (TRAIN_RESAUX)
FILE *of;
char buffer[80];
#endif
partword[0]=_vorbis_block_alloc(vb,partvals*sizeof(*partword[0]));
memset(partword[0],0,partvals*sizeof(*partword[0]));
@ -515,15 +397,6 @@ static long **_2class(vorbis_block *vb,vorbis_look_residue *vl,int **in,
}
#ifdef TRAIN_RESAUX
sprintf(buffer,"resaux_%d.vqd",look->train_seq);
of=fopen(buffer,"a");
for(i=0;i<partvals;i++)
fprintf(of,"%ld, ",partword[0][i]);
fprintf(of,"\n");
fclose(of);
#endif
look->frames++;
return(partword);
@ -533,22 +406,13 @@ static int _01forward(oggpack_buffer *opb,
vorbis_look_residue *vl,
int **in,int ch,
long **partword,
#ifdef TRAIN_RES
int (*encode)(oggpack_buffer *,int *,int,
codebook *,long *),
int submap
#else
int (*encode)(oggpack_buffer *,int *,int,
codebook *)
#endif
){
long i,j,k,s;
vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl;
vorbis_info_residue0 *info=look->info;
#ifdef TRAIN_RES
look->submap=submap;
#endif
/* move all this setup out later */
int samples_per_partition=info->grouping;
@ -560,14 +424,6 @@ static int _01forward(oggpack_buffer *opb,
long resbits[128];
long resvals[128];
#ifdef TRAIN_RES
for(i=0;i<ch;i++)
for(j=info->begin;j<info->end;j++){
if(in[i][j]>look->tmax)look->tmax=in[i][j];
if(in[i][j]<look->tmin)look->tmin=in[i][j];
}
#endif
memset(resbits,0,sizeof(resbits));
memset(resvals,0,sizeof(resvals));
@ -593,11 +449,6 @@ static int _01forward(oggpack_buffer *opb,
/* training hack */
if(val<look->phrasebook->entries)
look->phrasebits+=vorbis_book_encode(look->phrasebook,val,opb);
#if 0 /*def TRAIN_RES*/
else
fprintf(stderr,"!");
#endif
}
}
@ -611,25 +462,8 @@ static int _01forward(oggpack_buffer *opb,
codebook *statebook=look->partbooks[partword[j][i]][s];
if(statebook){
int ret;
#ifdef TRAIN_RES
long *accumulator=NULL;
accumulator=look->training_data[s][partword[j][i]];
{
int l;
int *samples=in[j]+offset;
for(l=0;l<samples_per_partition;l++){
if(samples[l]<look->training_min[s][partword[j][i]])
look->training_min[s][partword[j][i]]=samples[l];
if(samples[l]>look->training_max[s][partword[j][i]])
look->training_max[s][partword[j][i]]=samples[l];
}
}
ret=encode(opb,in[j]+offset,samples_per_partition,
statebook,accumulator);
#else
ret=encode(opb,in[j]+offset,samples_per_partition,
statebook);
#endif
look->postbits+=ret;
resbits[partword[j][i]]+=ret;
@ -724,16 +558,9 @@ int res1_forward(oggpack_buffer *opb,vorbis_block *vb,vorbis_look_residue *vl,
if(nonzero[i])
in[used++]=in[i];
if(used){
#ifdef TRAIN_RES
return _01forward(opb,vl,in,used,partword,_encodepart,submap);
#else
(void)submap;
if(used)
return _01forward(opb,vl,in,used,partword,_encodepart);
#endif
}else{
return(0);
}
return(0);
}
long **res1_class(vorbis_block *vb,vorbis_look_residue *vl,
@ -790,16 +617,9 @@ int res2_forward(oggpack_buffer *opb,
work[k]=pcm[j];
}
if(used){
#ifdef TRAIN_RES
return _01forward(opb,vl,&work,1,partword,_encodepart,submap);
#else
(void)submap;
if(used)
return _01forward(opb,vl,&work,1,partword,_encodepart);
#endif
}else{
return(0);
}
return(0);
}
/* duplicate code here as speed is somewhat more important */