[xiph-commits] r17705 - trunk/squishyball
xiphmont at svn.xiph.org
xiphmont at svn.xiph.org
Thu Dec 2 09:47:21 PST 2010
Author: xiphmont
Date: 2010-12-02 09:47:21 -0800 (Thu, 02 Dec 2010)
New Revision: 17705
Modified:
trunk/squishyball/audio.c
trunk/squishyball/loader.c
trunk/squishyball/main.c
trunk/squishyball/main.h
trunk/squishyball/tty.c
Log:
Trim path names
Modified: trunk/squishyball/audio.c
===================================================================
--- trunk/squishyball/audio.c 2010-12-02 14:11:13 UTC (rev 17704)
+++ trunk/squishyball/audio.c 2010-12-02 17:47:21 UTC (rev 17705)
@@ -126,9 +126,9 @@
if(count){
if(bps==4)
- fprintf(stderr,"CLIPPING WARNING: %ld clipped samples in %s.\n",(long)count,pcm->path);
+ fprintf(stderr,"CLIPPING WARNING: %ld clipped samples in %s.\n",(long)count,pcm->name);
else
- fprintf(stderr,"CLIPPING WARNING: %ld probably clipped samples in %s.\n",(long)count,pcm->path);
+ fprintf(stderr,"CLIPPING WARNING: %ld probably clipped samples in %s.\n",(long)count,pcm->name);
}
}
@@ -143,7 +143,7 @@
unsigned char *d = pcm->data;
off_t j;
if(sb_verbose)
- fprintf(stderr,"\rConverting %s to 24 bit... ",pcm->path);
+ fprintf(stderr,"\rConverting %s to 24 bit... ",pcm->name);
for(j=0;j<pcm->size/4;j++){
int val=0;
int mantissa = d[j*4] | (d[j*4+1]<<8) | ((d[j*4+2]&0x7f)<<16) | (1<<23);
@@ -151,7 +151,7 @@
int sign = d[j*4+3]>>7;
if(exponent <= 0){
if(exponent == -128){
- fprintf(stderr,"%s: Input file contains invalid floating point values.\n",pcm->path);
+ fprintf(stderr,"%s: Input file contains invalid floating point values.\n",pcm->name);
exit(6);
}
if(sign)
@@ -186,7 +186,7 @@
if(sb_verbose)
fprintf(stderr,"\r%s %s to 16 bit... ",
- pcm->dither?"Dithering":"Down-converting",pcm->path);
+ pcm->dither?"Dithering":"Down-converting",pcm->name);
/* again assumes IEEE754, which is not pedantically correct */
if(sizeof(float)==4){
@@ -247,7 +247,7 @@
if(sb_verbose)
fprintf(stderr,"\r%s %s to 16 bit... ",
- pcm->dither?"Dithering":"Down-converting",pcm->path);
+ pcm->dither?"Dithering":"Down-converting",pcm->name);
memset(t,0,sizeof(t));
@@ -284,7 +284,7 @@
off_t i;
if(sb_verbose)
- fprintf(stderr,"\rPromoting %s to 24 bit... ",pcm->path);
+ fprintf(stderr,"\rPromoting %s to 24 bit... ",pcm->name);
{
unsigned char *ret=realloc(pcm->data,pcm->size*3/2);
@@ -318,7 +318,7 @@
float32_to_16(pcm);
break;
default:
- fprintf(stderr,"%s: Unsupported sample format.\n",pcm->path);
+ fprintf(stderr,"%s: Unsupported sample format.\n",pcm->name);
exit(6);
}
}
@@ -334,7 +334,7 @@
float32_to_24(pcm);
break;
default:
- fprintf(stderr,"%s: Unsupported sample format.\n",pcm->path);
+ fprintf(stderr,"%s: Unsupported sample format.\n",pcm->name);
exit(6);
}
}
Modified: trunk/squishyball/loader.c
===================================================================
--- trunk/squishyball/loader.c 2010-12-02 14:11:13 UTC (rev 17704)
+++ trunk/squishyball/loader.c 2010-12-02 17:47:21 UTC (rev 17705)
@@ -45,6 +45,22 @@
return 0;
}
+static char *trim_path(char *in){
+ /* search back to first /, \, or : */
+ if(in){
+ char *a = strrchr(in,'/');
+ char *b = strrchr(in,'\\');
+ char *c = strrchr(in,':');
+ int posa = (a ? a-in+1 : 0);
+ int posb = (b ? b-in+1 : 0);
+ int posc = (c ? c-in+1 : 0);
+ if(posb>posa)posa=posb;
+ if(posc>posa)posa=posc;
+ return in+posa;
+ }
+ return NULL;
+}
+
typedef struct{
int (*id_func)(char *path,unsigned char *buf);
pcm_t *(*load_func)(char *path, FILE *in);
@@ -140,7 +156,7 @@
}
pcm = calloc(1,sizeof(pcm_t));
- pcm->path=strdup(path);
+ pcm->name=strdup(trim_path(path));
if(!find_wav_chunk(in, path, "fmt ", &len)){
fprintf(stderr,"%s: Failed to find fmt chunk in WAV file\n",path);
@@ -428,7 +444,7 @@
}
pcm = calloc(1,sizeof(pcm_t));
- pcm->path=strdup(path);
+ pcm->name=strdup(trim_path(path));
if(buf2[11]=='C')
aifc=1;
@@ -592,7 +608,7 @@
static pcm_t *sw_load(char *path, FILE *in){
pcm_t *pcm = calloc(1,sizeof(pcm_t));
- pcm->path=strdup(path);
+ pcm->name=strdup(trim_path(path));
pcm->bits=16;
pcm->ch=1;
pcm->rate=48000;
@@ -665,7 +681,7 @@
}
if(sb_verbose)
- fprintf(stderr,"\rLoading %s: %ld to go... ",flac->pcm->path,(long)(pcm->size-flac->fill));
+ fprintf(stderr,"\rLoading %s: %ld to go... ",flac->pcm->name,(long)(pcm->size-flac->fill));
*bytes = fread(buffer, sizeof(FLAC__byte), *bytes, flac->in);
return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
@@ -692,11 +708,11 @@
}
if(channels != pcm->ch){
- fprintf(stderr,"\r%s: number of channels changes part way through file\n",pcm->path);
+ fprintf(stderr,"\r%s: number of channels changes part way through file\n",pcm->name);
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
}
if(pcm->bits != (bits_per_sample+7)/8*8){
- fprintf(stderr,"\r%s: bit depth changes part way through file\n",pcm->path);
+ fprintf(stderr,"\r%s: bit depth changes part way through file\n",pcm->name);
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
}
@@ -725,7 +741,7 @@
}
break;
default:
- fprintf(stderr,"\r%s: Only 16- and 24-bit FLACs are supported for decode right now.\n",pcm->path);
+ fprintf(stderr,"\r%s: Only 16- and 24-bit FLACs are supported for decode right now.\n",pcm->name);
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
}
}
@@ -756,7 +772,7 @@
flac_callback_arg *flac = (flac_callback_arg *)client_data;
pcm_t *pcm = flac->pcm;
- fprintf(stderr,"\r%s: Error decoding file.\n",pcm->path);
+ fprintf(stderr,"\r%s: Error decoding file.\n",pcm->name);
}
static FLAC__bool eof_callback(const FLAC__StreamDecoder *decoder,
@@ -772,7 +788,7 @@
FLAC__bool ret;
FLAC__stream_decoder_set_md5_checking(decoder, true);
FLAC__stream_decoder_set_metadata_respond(decoder, FLAC__METADATA_TYPE_STREAMINFO);
- pcm->path=strdup(path);
+ pcm->name=strdup(trim_path(path));
flac->in=in;
flac->pcm=pcm;
@@ -873,7 +889,7 @@
vi=ov_info(&vf,-1);
pcm = calloc(1,sizeof(pcm_t));
- pcm->path=strdup(path);
+ pcm->name=strdup(trim_path(path));
pcm->bits=-32;
pcm->ch=vi->channels;
pcm->rate=vi->rate;
@@ -967,7 +983,7 @@
}
fill += ret*pcm->ch*4;
if (sb_verbose && (throttle&0x3f)==0)
- fprintf(stderr,"\rLoading %s: %ld to go... ",pcm->path,(long)(pcm->size-fill));
+ fprintf(stderr,"\rLoading %s: %ld to go... ",pcm->name,(long)(pcm->size-fill));
throttle++;
}
ov_clear(&vf);
@@ -1026,7 +1042,7 @@
void free_pcm(pcm_t *pcm){
if(pcm){
- if(pcm->path)free(pcm->path);
+ if(pcm->name)free(pcm->name);
if(pcm->matrix)free(pcm->matrix);
if(pcm->data)free(pcm->data);
memset(pcm,0,sizeof(pcm));
Modified: trunk/squishyball/main.c
===================================================================
--- trunk/squishyball/main.c 2010-12-02 14:11:13 UTC (rev 17704)
+++ trunk/squishyball/main.c 2010-12-02 17:47:21 UTC (rev 17705)
@@ -497,7 +497,7 @@
fprintf(stderr,"Input sample rates do not match!\n"
"\t%s: %dHz\n"
"\t%s: %dHz\n"
- "Aborting\n",pcm[0]->path,pcm[0]->rate,pcm[i]->path,pcm[i]->rate);
+ "Aborting\n",pcm[0]->name,pcm[0]->rate,pcm[i]->name,pcm[i]->rate);
exit(3);
}
@@ -506,7 +506,7 @@
fprintf(stderr,"Input channel counts do not match!\n"
"\t%s: %d channels\n"
"\t%s: %d channels\n"
- "Aborting\n",pcm[0]->path,pcm[0]->ch,pcm[i]->path,pcm[i]->ch);
+ "Aborting\n",pcm[0]->name,pcm[0]->ch,pcm[i]->name,pcm[i]->ch);
exit(3);
}
@@ -565,7 +565,7 @@
for(i=0;i<test_files;i++){
if(sb_verbose)
- fprintf(stderr,"\t%s: %s\n",pcm[i]->path,
+ fprintf(stderr,"\t%s: %s\n",pcm[i]->name,
make_time_string((double)pcm[i]->size/pcm[i]->ch/((pcm[i]->bits+7)/8)/pcm[i]->rate,0));
pcm[i]->size=n;
}
@@ -1018,8 +1018,8 @@
switch(test_mode){
case 0:
fprintf(stdout, "\nA/B test results:\n");
- fprintf(stdout, "\tSample 1 (%s): %d/%d trials.\n",pcm[0]->path,tests_cursor-total1,tests_cursor);
- fprintf(stdout, "\tSample 2 (%s): %d/%d trials.\n",pcm[1]->path,total1,tests_cursor);
+ fprintf(stdout, "\tSample 1 (%s): %d/%d trials.\n",pcm[0]->name,tests_cursor-total1,tests_cursor);
+ fprintf(stdout, "\tSample 2 (%s): %d/%d trials.\n",pcm[1]->name,total1,tests_cursor);
break;
case 1:
fprintf(stdout, "\nA/B/X test results:\n");
Modified: trunk/squishyball/main.h
===================================================================
--- trunk/squishyball/main.h 2010-12-02 14:11:13 UTC (rev 17704)
+++ trunk/squishyball/main.h 2010-12-02 17:47:21 UTC (rev 17705)
@@ -29,7 +29,7 @@
typedef struct pcm_struct pcm_t;
struct pcm_struct {
- char *path;
+ char *name;
int rate;
int bits; /* negative indicates IEEE754 float */
int ch;
Modified: trunk/squishyball/tty.c
===================================================================
--- trunk/squishyball/tty.c 2010-12-02 14:11:13 UTC (rev 17704)
+++ trunk/squishyball/tty.c 2010-12-02 17:47:21 UTC (rev 17705)
@@ -248,10 +248,10 @@
}else
min_putchar(' ');
- if(strlen(pcm_p[i]->path)>columns-4)
- print_into(buf,0,pcm_p[i]->path+strlen(pcm_p[i]->path)-columns+4);
+ if(strlen(pcm_p[i]->name)>columns-4)
+ print_into(buf,0,pcm_p[i]->name+strlen(pcm_p[i]->name)-columns+4);
else
- print_into(buf,0,pcm_p[i]->path);
+ print_into(buf,0,pcm_p[i]->name);
min_putstr(buf);
if(i==p_pl)
min_bold(0);
@@ -549,8 +549,8 @@
char bufBn[10];
char *Ap=bufA,*Bp=bufB;
double p=compute_pdual(count,n);
- snprintf(bufA,PATH_MAX,"%s: ",pcm_p[0]->path);
- snprintf(bufB,PATH_MAX,"%s: ",pcm_p[1]->path);
+ snprintf(bufA,PATH_MAX,"%s: ",pcm_p[0]->name);
+ snprintf(bufB,PATH_MAX,"%s: ",pcm_p[1]->name);
snprintf(bufAn,10,"%d ",n-count);
snprintf(bufBn,10,"%d ",count);
if(n>1)
@@ -611,18 +611,18 @@
if(p_tm==3){
min_mvcur(1,boxrow+1+p_pl);
min_putchar(' ');
- if(strlen(pcm_p[p_pl]->path)>columns-4)
- min_putstr(pcm_p[p_pl]->path+strlen(pcm_p[p_pl]->path)-columns+4);
+ if(strlen(pcm_p[p_pl]->name)>columns-4)
+ min_putstr(pcm_p[p_pl]->name+strlen(pcm_p[p_pl]->name)-columns+4);
else
- min_putstr(pcm_p[p_pl]->path);
+ min_putstr(pcm_p[p_pl]->name);
min_mvcur(1,boxrow+1+n);
min_putchar('>');
min_bold(1);
- if(strlen(pcm_p[n]->path)>columns-4)
- min_putstr(pcm_p[n]->path+strlen(pcm_p[n]->path)-columns+4);
+ if(strlen(pcm_p[n]->name)>columns-4)
+ min_putstr(pcm_p[n]->name+strlen(pcm_p[n]->name)-columns+4);
else
- min_putstr(pcm_p[n]->path);
+ min_putstr(pcm_p[n]->name);
min_unset();
}
More information about the commits
mailing list