diff -ur mp3guessenc-0.25alpha23/ChangeLog mp3guessenc-0.25alpha23-HPR/ChangeLog --- mp3guessenc-0.25alpha23/ChangeLog 2012-04-21 16:32:37.000000000 +0200 +++ mp3guessenc-0.25alpha23-HPR/ChangeLog 2012-04-22 11:24:22.000000000 +0200 @@ -2,6 +2,10 @@ mp3guessenc changelog ====================== +version 0.25 alpha 23 (2012/04/22, the "Sparrow's Nightmare" Haiku Powered Re-release) + - minor modifications applied so now you can build and run mp3guessenc on Haiku R1 alpha3 also! + + version 0.25 alpha 23 (2012/04/21, the "Sparrow's Nightmare" release) - added a check so now the very last frame won't be read if broken (it will be reported as garbage) - enlarged buffers in order to accomodate big free format frames (I see this as a workaround and I diff -ur mp3guessenc-0.25alpha23/Makefile mp3guessenc-0.25alpha23-HPR/Makefile --- mp3guessenc-0.25alpha23/Makefile 2012-04-21 16:43:34.000000000 +0200 +++ mp3guessenc-0.25alpha23-HPR/Makefile 2012-04-22 11:32:08.000000000 +0200 @@ -8,22 +8,38 @@ BUILD = release #BUILD = debug -# choose installation path -PREFIX=/usr/local +# choose the target OS - `other' is good for both *nix and win32 systems +# some gcc options have to be avoided since the version bundled with haiku is quite old (2.95.3) +TARGET_OS = other +#TARGET_OS = haiku + +# choose installation path (only one will be used) +INST_PATH_OTHER=/usr/local +INST_PATH_HAIKU=/boot/common # common preferences CC = gcc -CFLAGS = -Wall -Wextra +CFLAGS = -Wall # no need to change anything below here #-------------------------------------- +ifeq ($(TARGET_OS),other) + CFLAGS += -Wextra + PREFIX = $(INST_PATH_OTHER) +else + PREFIX = $(INST_PATH_HAIKU) +endif + ifeq ($(BUILD),release) CFLAGS += -O2 LDFLAGS = -s else - CFLAGS += -fno-stack-protector -g + CFLAGS += -g LDFLAGS = + ifeq ($(TARGET_OS),other) + CFLAGS += -fno-stack-protector + endif endif SRC0 = mp3guessenc.c decode.c diff -ur mp3guessenc-0.25alpha23/mp3guessenc.c mp3guessenc-0.25alpha23-HPR/mp3guessenc.c --- mp3guessenc-0.25alpha23/mp3guessenc.c 2012-04-21 16:29:39.000000000 +0200 +++ mp3guessenc-0.25alpha23-HPR/mp3guessenc.c 2012-04-22 16:59:28.000000000 +0200 @@ -129,6 +129,7 @@ unsigned char ly=(head&HEADER_FIELD_LAYER)>>17; /* layer index */ unsigned char bi=(head&HEADER_FIELD_BITRATE)>>12; /* bitrate index */ unsigned char mp=(head&HEADER_FIELD_MPEG_ID)>>19; /* mpeg version */ + unsigned char md; /* audio mode */ if ((head&HEADER_FIELD_SYNC)!=HEADER_FIELD_SYNC) return 0; /* check for sync bits */ if (mp == 1) return 0; /* check for reserved value in mpeg version field */ @@ -142,7 +143,7 @@ if ((ly != 2)||(mp != 3)) return 1; /* if mpeg 1 layerII, then check for not allowed bitrate-mode combinations */ if (bi == 0) return 1; - unsigned char md=(head&HEADER_FIELD_CHANNELS)>>6; /* audio mode */ + md=(head&HEADER_FIELD_CHANNELS)>>6; if (bi<4 && md!=3) return 0; if (bi==5 && md!=3) return 0; if (bi>10 && md==3) return 0; @@ -186,6 +187,7 @@ void reset_tag_data(VBRTAGDATA *p) { + unsigned char i; p->alert=0; p->tagId=NULL; p->tagStartsAt=0; @@ -201,7 +203,6 @@ p->frames=0; p->bytes=0; p->vbr_scale=0; - unsigned char i; for (i=0; ilametag[i]=0; return; } @@ -319,9 +320,11 @@ * 0: no tag * 1: tag found (details into pTagData) */ + int head; + reset_tag_data(pTagData); - int head=ExtractI4(buf); /* this mpeg header was already checked before calling GetInfoTag */ + head=ExtractI4(buf); /* this mpeg header was already checked before calling GetInfoTag */ if ((buf[36]=='V')&&(buf[37]=='B')&&(buf[38]=='R')&&(buf[39]=='I')) { @@ -332,9 +335,10 @@ else { unsigned char mono,lsf; + int offset; lsf = 1-((head&HEADER_FIELD_LSF)>>19); mono =((head&HEADER_FIELD_CHANNELS)>>6)/3; - int offset = 4+(int)sideinfo_tab[mono][lsf]; + offset = 4+(int)sideinfo_tab[mono][lsf]; if ( ((buf[offset] == 'X') && (buf[offset+1] == 'i') && (buf[offset+2] == 'n') && (buf[offset+3] == 'g')) @@ -444,9 +448,9 @@ printf("\n Lame tag : "); if (lameTag) { + unsigned char c,i; printf("yes\n"); /* print details from lame tag */ - unsigned char c,i; printf("Lame tag details...\n Lame short string : "); for(i=0;i<9;i++) if (isprint(p.lametag[i])) putchar(p.lametag[i]); else putchar(' '); @@ -707,9 +711,9 @@ * Note: the file pointer IS modified and then it IS restored */ { - int filepos=ftell(fi); + int filepos=ftell(fi),pos,read; fseek(fi,0,SEEK_END); - int pos = ftell(fi),read; + pos = ftell(fi); fseek(fi,-128,SEEK_END); read = fread(id3,sizeof(id3tag),1,fi); @@ -843,8 +847,8 @@ * As a safe move, I will keep it here for a while and see whether the alert is printed or not */ while(fb->nLastBits <= 24) { -printf("*** while statement @ %d ***\n",__LINE__); int tmp; +printf("*** while statement @ %d ***\n",__LINE__); tmp = getc(fb->fp); c = tmp; fb->lastBits = fb->lastBits << 8; @@ -970,6 +974,7 @@ void load_into_p23b(FILEBITS *fb,int len) { + unsigned int bytes2read; p23b[p23b_in].pos = ftellBits(fb); p23b[p23b_in].len = len + (p23b[p23b_in].pos & 7); /* @@ -977,7 +982,7 @@ * has to be used in conjunction with `readBits', not `fread'. */ fseek(fb->fp,fb->location/8,SEEK_SET); - unsigned int bytes2read=len/8; + bytes2read=len/8; if (len%8) bytes2read++; if (fread(p23b[p23b_in].buf,1,bytes2read,fb->fp)!=bytes2read) printf("Warning: read failure.\n"); fseekBits(fb,p23b[p23b_in].pos-(p23b[p23b_in].pos&7)+p23b[p23b_in].len,SEEK_SET); @@ -1185,8 +1190,8 @@ if (pos_main_data_begin-tell_p23b() >= 8) { char buf[BUFFER_SIZE],*p; - p = buf; unsigned char c; + p = buf; while(pos_main_data_begin-tell_p23b() >= 8) { c = readOneByte_p23b(); @@ -1350,11 +1355,11 @@ if (mdb-tell_p23b() > 8) { char buf[BUFFER_SIZE],*p; + unsigned char c; p = buf; //printf("anc start pos : %d\n",(endOfLastPart3+7)&~7); //printf("ancillary(%d,%d) : ",framenum,((endOfLastPart3+7)&~7)/8); //printf("ancillary(%d) : ",framenum); - unsigned char c; while(mdb-tell_p23b() > 8) { c = readOneByte_p23b(); @@ -1564,21 +1569,24 @@ int main(int argc,char **argv) { - char lame_string[LAME_STRING_LENGTH]; + char lame_string[LAME_STRING_LENGTH], buf[LARGEST_BUFFER]; id3tag id3; - unsigned char id3V2Maj,id3V2min; - int pos=0,i,option,head,bytes2read; - int id3pos=0,id3v2size; + unsigned char id3V2Maj, id3V2min; + int pos=0, i, option, head, bytes2read, id3pos=0, id3v2size; FILE *input_file; detectionInfo di; - di.usesScfsi=0;di.usesScalefacScale=0;di.usesPadding=0; streamInfo si; - si.totFrameLen=0;si.totFrameNum=0;si.reservoirMax=0;si.nSyncError=0;si.freeformat=0; struct stat fileStat; + VBRTAGDATA TagData; + + /* reset some values */ + di.usesScfsi=0;di.usesScalefacScale=0;di.usesPadding=0; + si.totFrameLen=0;si.totFrameNum=0;si.reservoirMax=0;si.nSyncError=0;si.freeformat=0; opterr=0; while ((option = getopt(argc, argv, "hV")) != -1) { + char source[DATA_LEN]; switch (option) { case 'h': @@ -1586,7 +1594,6 @@ return 0; case 'V': print_version(1); - char source[DATA_LEN]; if (optindLARGEST_BUFFER) bytes2read=LARGEST_BUFFER; - char buf[bytes2read]; - VBRTAGDATA TagData; - -// int success=(int)fread(&buf,1,bytes2read,input_file); i=(int)fread(&buf,1,bytes2read,input_file); if (GetInfoTag(&TagData,buf,bytes2read,i,pos)) { diff -ur mp3guessenc-0.25alpha23/tools/Makefile mp3guessenc-0.25alpha23-HPR/tools/Makefile --- mp3guessenc-0.25alpha23/tools/Makefile 2012-04-21 16:46:11.000000000 +0200 +++ mp3guessenc-0.25alpha23-HPR/tools/Makefile 2012-04-22 11:15:04.000000000 +0200 @@ -4,7 +4,7 @@ # common preferences CC = gcc -CFLAGS = -Wall -Wextra -O2 +CFLAGS = -Wall -O2 LDFLAGS = -s # no need to change anything below here diff -ur mp3guessenc-0.25alpha23/tools/strencode.c mp3guessenc-0.25alpha23-HPR/tools/strencode.c --- mp3guessenc-0.25alpha23/tools/strencode.c 2012-04-16 17:40:32.000000000 +0200 +++ mp3guessenc-0.25alpha23-HPR/tools/strencode.c 2012-04-22 11:17:47.000000000 +0200 @@ -8,9 +8,10 @@ int main(int argc,char **argv) { - char data[MAX_BUFFER_LEN],s[MAX_BUFFER_LEN]; + char data[MAX_BUFFER_LEN],s[MAX_BUFFER_LEN], + stat_len; /* this is the length of a single statement */ unsigned char f2c,verb=0; - int i,errors=0,punta=0; + int i,errors=0,punta=0,len; FILE *input_file; struct stat buf; @@ -81,9 +82,8 @@ else if (verb) printf("all went OK.\n"); - int len=strlen(data); + len=strlen(data); #define MAX_STATEMENT 77 - char stat_len; /* this is the length of a single statement */ for (i=0; i