Package: vobcopy Version: 1.2.0-5 Severity: normal Tags: patch Some of my discs accumulated some scratches. Vobcopy would no longer copy their data efficiently, it would just retry every sector 10 times, essentially stalling.
The attached patch attempts to fix this issue by seeking forward through the error sectors. - Adam
Index: vobcopy-1.2.0/vobcopy.c =================================================================== --- vobcopy-1.2.0.orig/vobcopy.c 2014-10-27 02:36:06.000000000 +0000 +++ vobcopy-1.2.0/vobcopy.c 2014-10-27 02:36:55.402296457 +0000 @@ -1798,19 +1798,15 @@ /* blocks = DVDReadBlocks( dvd_file,( offset + seek_start ), file_block_count, bufferin ); */ - while( ( blocks = DVDReadBlocks( dvd_file,( offset + seek_start ), file_block_count, bufferin ) ) <= 0 && tries < 10 ) - { - if( tries == 9 ) - { - offset += file_block_count; - skipped_blocks +=1; - overall_skipped_blocks +=1; - tries=0; - } - /* if( verbosity_level >= 1 ) - fprintf( stderr, _("[Warn] Had to skip %d blocks (reading block %d)! \n "), skipped_blocks, i ); */ - tries++; - } + if ((blocks = DVDReadBlocks(dvd_file, offset + seek_start, file_block_count, bufferin)) <= 0) { + off_t new_offset = find_error_offset(dvd_file, offset + seek_start, file_size_in_blocks); + + off_t skip = new_offset - offset; + skipped_blocks += skip; + overall_skipped_blocks += skip; + offset = new_offset; + continue; + } if( verbosity_level >= 1 && skipped_blocks > 0 ) fprintf( stderr, @@ -2312,3 +2308,23 @@ } return( 0 ); } + +/* Skip errors */ +ssize_t find_error_offset(dvd_file_t *file, size_t offset, size_t max) +{ + unsigned char crap[DVD_VIDEO_LB_LEN * BLOCK_COUNT]; + int try_offset = 2; + + while (try_offset > 1 && offset + try_offset < max) { + int r = DVDReadBlocks(file, offset + try_offset, 1, crap); + + if (r >= 1) { + offset += try_offset/2; + try_offset /= 4; + } + else + try_offset *= 2; + } + + return offset; +} Index: vobcopy-1.2.0/vobcopy.h =================================================================== --- vobcopy-1.2.0.orig/vobcopy.h 2014-10-27 02:36:06.000000000 +0000 +++ vobcopy-1.2.0/vobcopy.h 2014-10-27 02:36:06.000000000 +0000 @@ -159,6 +159,8 @@ int check_progress( void ); /* this can be removed because the one below supersedes it */ int progressUpdate( int starttime, int cur, int tot, int force ); +ssize_t find_error_offset(dvd_file_t *file, size_t offset, size_t max); + #ifndef HAVE_FDATASYNC #define fdatasync(fd) 0 #endif