diffvideo 2.19 KB
#!/usr/bin/perl
#
# Script to extract images from vi.tab file and displays it
#
# Usage: diffvideo -i in.tab -g golden.rgb -h hblank -v vblank [-f N] [-n]
#        -f N specifies number of fields per image
#        -n means don't call vparse on the input tab file
#
# This script does require customization for different video formats!!!
# vparse/monitor arguments must be adjusted to decipher the correct video format
#

require "/usr/lib/perl/getopts.pl";

sub GetArguments
{
    &Getopts('i:g:h:v:f:n');

    if (!defined($opt_i))
    {
	printf("!!!ERROR: must specify input tab file \n");
	exit;
    }
    else
    {
	$FILE = $opt_i;
    }

    if (!defined($opt_g))
    {
	printf("!!!ERROR: must specify golden rgb file \n");
	exit;
    }
    else
    {
	$GOLDFILE = $opt_g;
    }
    
    if (!defined($opt_h))
    {
	printf("!!!ERROR: must specify horizontal blanking information \n");
	exit;
    }
    
    if (!defined($opt_v))
    {
	printf("!!!ERROR: must specify vertical blanking information \n");
	exit;
    }

    if (!defined($opt_f))
    {
	$NumFields = 2;
    }
    else
    {
	$NumFields = $opt_f;
    }
    if (!defined($opt_n))
    {
	$SkipVparse = 0;
    }
    else
    {
	$SkipVparse = 1;
    }
    
}				

$error = 0;
$Count = 0;

&GetArguments;

$OUT = $FILE;
$OUT =~ s/\..*$//;

if (! $SkipVparse)
{
    open(TABFILES, "$ENV{'ROOT'}/usr/sbin/vparse -i $FILE -o $OUT.tab -f $NumFields |");
    $temp = <TABFILES>;

    @OutFiles = split(/[ \t\n]+/,$temp);
    printf("outfiles: @OutFiles \n");
}
else
{
    @OutFiles = "$FILE";
}

foreach $intab (@OutFiles)
{
    $rgbfile = $intab;
    $rgbfile =~ s/\..*$//;
    $rgbfile = sprintf("$rgbfile.rgb%.3d",$Count);
    $diffile = sprintf("diff%.3d.rgb", $Count++);

    $monitorError = (system("$ENV{'ROOT'}/usr/sbin/monitor -i $intab -o $rgbfile -h $opt_h -v $opt_v"))/256; 
    
    if ($monitorError)
    {
	printf("!!!ERROR monitor had problems \n");
    }

    $idfError     = (system("$ENV{'ROOT'}/usr/sbin/idf $rgbfile $GOLDFILE $diffile"))/256;

    if ($monitorError || $idfError)
    {
	$error = 1;
	printf("!!!Error in comparing $rgbfile and $GOLDFILE \n");
    }
    else
    {
	printf("images $rgbfile and $GOLDFILE equate \n");
    }
    
}

exit $error;