Le quartidi 4 thermidor, an CCXXV, Michael Niedermayer a écrit : > we might be able to get away with strings and lower precission.
We might be lucky like that, but we cannot expect it to work always: the value always has a small chance to be too near the cutoff value between two rounded numbers. Also, decreasing the precision increases the risk of missing a regression. I just wrote the attached script, it may or may not be of use. Regards, -- Nicolas George
#!/usr/bin/env perl # Compare two text files with fuzzy nummeric values # The numbers in the first (reference) file must be written: # ~value~precision~ # For example ~42~0.1~ will accept any number between 41.9 and 42.1. # The files must contain no '~' and the end of numbers must be unambiguous. # # Public domain. use strict; use warnings; die "Usage: $0 reference test\n" unless @ARGV == 2; sub read_file($) { my ($filename) = @_; open my $f, "<", $filename or die "$filename: $!\n"; local $/; return <$f>; } my ($ref_filename, $cmp_filename) = @ARGV; my $ref = read_file $ref_filename; my $cmp = read_file $cmp_filename; my $ref_pos = pos($ref) = 0; my $cmp_pos = 0; sub show_position() { return " at ${ref_filename}:${ref_pos} vs ${cmp_filename}:${cmp_pos}\n"; } while (1) { $ref_pos = pos($ref); if ($ref =~ /\G[^~]+/gc) { my $len = pos($ref) - $ref_pos; substr($ref, $ref_pos, $len) eq substr($cmp, $cmp_pos, $len) or die "Raw mismatch", show_position; $cmp_pos += $len; } elsif ($ref =~ /\G\~(.*?)\~(.*?)\~/gc) { my ($ref_val, $precision) = ($1 + 0, $2 + 0); pos($cmp) = $cmp_pos; my ($cmp_val) = $cmp =~ /\G([+-]?\d+(?:\.\d+)?)/ or die "Expected number", show_position; $cmp_pos += length($cmp_val); abs($cmp_val - $ref_val) <= $precision or die "| ${cmp_val} - ${ref_val} | > ${precision}", show_position; } elsif ($ref =~ /\G\z/) { last; } else { die "$ref_filename: syntax error at position $ref_pos\n"; } }
signature.asc
Description: Digital signature
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel