diff --git a/lib/paranoia/paranoia.c b/lib/paranoia/paranoia.c index 8ecced4b..9648667d 100644 --- a/lib/paranoia/paranoia.c +++ b/lib/paranoia/paranoia.c @@ -1,5 +1,5 @@ /* - $Id: paranoia.c,v 1.13 2005/10/04 00:38:34 rocky Exp $ + $Id: paranoia.c,v 1.14 2005/10/05 00:02:12 rocky Exp $ Copyright (C) 2004, 2005 Rocky Bernstein Copyright (C) 1998 Monty xiphmont@mit.edu @@ -133,6 +133,16 @@ rv(root_block *root){ #define rc(r) (r->vector) +enum { + FLAGS_EDGE =0x1, /**< first/last N words of frame */ + FLAGS_UNREAD =0x2, /**< unread, hence missing and unmatchable */ + FLAGS_VERIFIED=0x4 /**< block read and verified */ +} paranoia_read_flags; + +#define FLAGS_EDGE 0x01 +#define FLAGS_UNREAD 0x02 +#define FLAGS_VERIFIED 0x04 + /**** matching and analysis code *****************************************/ static inline long @@ -171,12 +181,12 @@ i_paranoia_overlap2(int16_t *buffA,int16_t *buffB, if ( buffA[beginA] != buffB[beginB] ) break; /* don't allow matching across matching sector boundaries */ /* don't allow matching through known missing data */ - if((flagsA[beginA]&flagsB[beginB]&1)){ + if((flagsA[beginA]&flagsB[beginB]&FLAGS_EDGE)){ beginA--; beginB--; break; } - if((flagsA[beginA]&2)|| (flagsB[beginB]&2))break; + if((flagsA[beginA]&FLAGS_UNREAD) || (flagsB[beginB]&FLAGS_UNREAD))break; } beginA++; beginB++; @@ -184,12 +194,12 @@ i_paranoia_overlap2(int16_t *buffA,int16_t *buffB, for(;endAflags; /* block flag matches 0x02 (unmatchable) */ - if(Bflags==NULL || (Bflags[post-cb(B)]&2)==0){ + if(Bflags==NULL || (Bflags[post-cb(B)]&FLAGS_UNREAD)==0){ /* always try absolute offset zero first! */ { long zeropos=post-ib(A); @@ -307,8 +317,8 @@ stage1_matched(c_block_t *old, c_block_t *new, if ( matchbegin-matchoffset<=cb(new) || matchbegin<=cb(old) - || (new->flags[newadjbegin]&1) - || (old->flags[oldadjbegin]&1) ) { + || (new->flags[newadjbegin]&FLAGS_EDGE) + || (old->flags[oldadjbegin]&FLAGS_EDGE) ) { if ( matchoffset && callback ) (*callback)(matchbegin,PARANOIA_CB_FIXUP_EDGE); } else @@ -316,9 +326,9 @@ stage1_matched(c_block_t *old, c_block_t *new, (*callback)(matchbegin,PARANOIA_CB_FIXUP_ATOM); if ( matchend-matchoffset>=ce(new) || - (new->flags[newadjend]&1) || + (new->flags[newadjend]&FLAGS_EDGE) || matchend>=ce(old) || - (old->flags[oldadjend]&1) ) { + (old->flags[oldadjend]&FLAGS_EDGE) ) { if ( matchoffset && callback ) (*callback)(matchend,PARANOIA_CB_FIXUP_EDGE); } else @@ -334,12 +344,12 @@ stage1_matched(c_block_t *old, c_block_t *new, newadjbegin+=OVERLAP_ADJ; newadjend-=OVERLAP_ADJ; for(i=newadjbegin;iflags[i]|=4; /* mark verified */ + new->flags[i]|=FLAGS_VERIFIED; /* mark verified */ oldadjbegin+=OVERLAP_ADJ; oldadjend-=OVERLAP_ADJ; for(i=oldadjbegin;iflags[i]|=4; /* mark verified */ + old->flags[i]|=FLAGS_VERIFIED; /* mark verified */ } @@ -365,7 +375,7 @@ i_iterate_stage1(cdrom_paranoia_t *p, c_block_t *old, c_block_t *new, /* match return values are in terms of the new vector, not old */ for(j=searchbegin;jflags[j-cb(new)]&6)==0){ + if((new->flags[j-cb(new)]&(FLAGS_VERIFIED|FLAGS_UNREAD))==0){ tried++; if(try_sort_sync(p,i,new->flags,old,j,&matchbegin,&matchend,&matchoffset, callback)==1){ @@ -424,9 +434,9 @@ i_stage1(cdrom_paranoia_t *p, c_block_t *p_new, begin=0; while (beginflags[begin]&4) break; + if(p_new->flags[begin]&FLAGS_VERIFIED) break; for (end=begin; end < size; end++) - if((p_new->flags[end]&4)==0) break; + if((p_new->flags[end]&FLAGS_VERIFIED)==0) break; if (begin>=size) break; ret++; @@ -1035,9 +1045,9 @@ verify_skip_case(cdrom_paranoia_t *p, if(cbegin<=post && cend>post){ long vend=post; - if(c->flags[post-cbegin]&4){ + if(c->flags[post-cbegin]&FLAGS_VERIFIED){ /* verified area! */ - while(vendflags[vend-cbegin]&4))vend++; + while(vendflags[vend-cbegin]&FLAGS_VERIFIED))vend++; if(!vflag || vend>vflag){ graft=c; gend=vend; @@ -1046,7 +1056,7 @@ verify_skip_case(cdrom_paranoia_t *p, } else { /* not a verified area */ if(!vflag){ - while(vendflags[vend-cbegin]&4)==0)vend++; + while(vendflags[vend-cbegin]&FLAGS_VERIFIED)==0)vend++; if(graft==NULL || gend>vend){ /* smallest unverified area */ graft=c; @@ -1062,7 +1072,7 @@ verify_skip_case(cdrom_paranoia_t *p, long cbegin=cb(graft); long cend=ce(graft); - while(gendflags[gend-cbegin]&4))gend++; + while(gendflags[gend-cbegin]&FLAGS_VERIFIED))gend++; gend=min(gend+OVERLAP_ADJ,cend); if(rv(root)==NULL){ @@ -1251,8 +1261,9 @@ i_read_c_block(cdrom_paranoia_t *p,long beginword,long endword, (*callback)((adjread+thisread)*CD_FRAMEWORDS, PARANOIA_CB_READERR); memset(buffer+(sofar+thisread)*CD_FRAMEWORDS,0, CDIO_CD_FRAMESIZE_RAW*(secread-thisread)); - if(flags)memset(flags+(sofar+thisread)*CD_FRAMEWORDS,2, - CD_FRAMEWORDS*(secread-thisread)); + if(flags) + memset(flags+(sofar+thisread)*CD_FRAMEWORDS, FLAGS_UNREAD, + CD_FRAMEWORDS*(secread-thisread)); } if(thisread!=0)anyflag=1; @@ -1261,7 +1272,7 @@ i_read_c_block(cdrom_paranoia_t *p,long beginword,long endword, another */ int i=0; for(i=-MIN_WORDS_OVERLAP/2;ilastread=adjread+secread; @@ -1363,9 +1374,9 @@ paranoia_read_limited(cdrom_paranoia_t *p, long begin=0,end=0; while(beginflags[begin]&1))begin++; + while(endflags[begin]&FLAGS_EDGE))begin++; end=begin+1; - while(endflags[end]&1)==0)end++; + while(endflags[end]&FLAGS_EDGE)==0)end++; { new_v_fragment(p,new,begin+cb(new), end+cb(new),