Use #defines (and enums for debugging) for paranoia read flags.

Patch from Peter J. Creath.
This commit is contained in:
rocky
2005-10-05 00:02:12 +00:00
parent 01a86fd79d
commit f3b673dec7

View File

@@ -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 <rocky@panix.com>
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(;endA<sizeA && endB<sizeB;endA++,endB++){
if(buffA[endA]!=buffB[endB])break;
/* don't allow matching across matching sector boundaries */
if((flagsA[endA]&flagsB[endB]&1) &&endA!=beginA){
if((flagsA[endA]&flagsB[endB]&FLAGS_EDGE) && endA!=beginA){
break;
}
/* don't allow matching through known missing data */
if((flagsA[endA]&2)||(flagsB[endB]&2))break;
if((flagsA[endA]&FLAGS_UNREAD) || (flagsB[endB]&FLAGS_UNREAD))break;
}
if(ret_begin)*ret_begin=beginA;
@@ -254,7 +264,7 @@ try_sort_sync(cdrom_paranoia_t *p,
unsigned char *Bflags=B->flags;
/* 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;i<newadjend;i++)
new->flags[i]|=4; /* mark verified */
new->flags[i]|=FLAGS_VERIFIED; /* mark verified */
oldadjbegin+=OVERLAP_ADJ;
oldadjend-=OVERLAP_ADJ;
for(i=oldadjbegin;i<oldadjend;i++)
old->flags[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;j<searchend;j+=23){
if((new->flags[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 (begin<size) {
for ( ; begin < size; begin++)
if(p_new->flags[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(vend<cend && (c->flags[vend-cbegin]&4))vend++;
while(vend<cend && (c->flags[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(vend<cend && (c->flags[vend-cbegin]&4)==0)vend++;
while(vend<cend && (c->flags[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(gend<cend && (graft->flags[gend-cbegin]&4))gend++;
while(gend<cend && (graft->flags[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;i<MIN_WORDS_OVERLAP/2;i++)
flags[sofar*CD_FRAMEWORDS+i]|=1;
flags[sofar*CD_FRAMEWORDS+i]|=FLAGS_EDGE;
}
p->lastread=adjread+secread;
@@ -1363,9 +1374,9 @@ paranoia_read_limited(cdrom_paranoia_t *p,
long begin=0,end=0;
while(begin<cs(new)){
while(end<cs(new)&&(new->flags[begin]&1))begin++;
while(end<cs(new) && (new->flags[begin]&FLAGS_EDGE))begin++;
end=begin+1;
while(end<cs(new)&&(new->flags[end]&1)==0)end++;
while(end<cs(new) && (new->flags[end]&FLAGS_EDGE)==0)end++;
{
new_v_fragment(p,new,begin+cb(new),
end+cb(new),