enh: speedup RS03 repair (fixes #100)

This commit is contained in:
Stéphane Lesimple
2024-08-02 23:49:31 +02:00
parent aa9065f0c0
commit 063ad92460

View File

@@ -734,7 +734,8 @@ void RS03Fix(Image *image)
if(num1 != 0)
{ int location = loc[j];
if(erasure_map[location] != 1) /* erasure came from CRC error */
if((Closure->debugMode && Closure->verbose) || Closure->regtestMode)
{ if (erasure_map[location] != 1) /* erasure came from CRC error */
{ int old = fc->imgBlock[location][offset];
int new = old ^ gf_alpha_to[mod_fieldmax(gf_index_of[num1] + gf_index_of[num2] + GF_FIELDMAX - gf_index_of[den])];
char *msg, *type;
@@ -762,6 +763,14 @@ void RS03Fix(Image *image)
old, canprint(old) ? old : '.',
new, canprint(new) ? new : '.');
}
}
else /* in non-debug mode, apply the only non-printf-preparing code of the above block */
{
if (erasure_map[location] == 0)
{ erasure_map[location] = 7;
error_count++;
}
}
fc->imgBlock[location][offset] ^= gf_alpha_to[mod_fieldmax(gf_index_of[num1] + gf_index_of[num2] + GF_FIELDMAX - gf_index_of[den])];
}