⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 do_queue.pl

📁 au1200 linux2.6.11 硬件解码mae驱动和maiplayer播放器源码
💻 PL
字号:
#!/tool/pandora/bin/perl -w# <LIC_AMD_STD># Copyright (C) 2003-2005 Advanced Micro Devices, Inc.  All Rights Reserved.# # Unless otherwise designated in writing, this software and any related # documentation are the confidential proprietary information of AMD. # THESE MATERIALS ARE PROVIDED "AS IS" WITHOUT ANY# UNLESS OTHERWISE NOTED IN WRITING, EXPRESS OR IMPLIED WARRANTY OF ANY # KIND, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, # NONINFRINGEMENT, TITLE, FITNESS FOR ANY PARTICULAR PURPOSE AND IN NO # EVENT SHALL AMD OR ITS LICENSORS BE LIABLE FOR ANY DAMAGES WHATSOEVER. # # AMD does not assume any responsibility for any errors which may appear # in the Materials nor any responsibility to support or update the# Materials.  AMD retains the right to modify the Materials at any time, # without notice, and is not obligated to provide such modified # Materials to you. AMD is not obligated to furnish, support, or make# any further information available to you.# </LIC_AMD_STD> # <CTL_AMD_STD># </CTL_AMD_STD> # <DOC_AMD_STD># </DOC_AMD_STD> use strict;use FileHandle;use File::Basename;use Getopt::Long;# Register SIG handlers to handle ctrl-c during runs# $SIG{INT} = \&graceful_shutdown;use vars qw(%cl_opt %decoder $tag);$tag = "";use vars qw(%done %passed %unique $total_pass $total_jobs);$total_pass = 0;$total_jobs = 0;Getopt::Long::config("no_auto_abbrev");Getopt::Long::config("pass_through");Getopt::Long::GetOptions(\%cl_opt,"mp4","mp2","wm9","start_frame|sf=i","frames|f=i","copy","clean","check_only","status=s","final","debug");use vars qw($exec_opts $mae_opts $ref_opts $diff_opts);$exec_opts = "";$mae_opts  = "";$ref_opts  = "";$diff_opts = "";if (defined($cl_opt{"final"})) {  print "INFO: Adding -final to do_diff.pl command!\n";  $diff_opts .= " -final";}if (!defined($cl_opt{"mp4"}) and     !defined($cl_opt{"mp2"}) and    !defined($cl_opt{"wm9"})) {  print "ERROR: None of -mp4, -mp2, -wm9 were specified\n";  exit(1);} elsif (defined($cl_opt{"mp4"})) {  # Gary please fix in  $exec_opts = "SHORT_RUN".$cl_opt{"frames"} if defined($cl_opt{"frames"});  $tag = "mp4";} elsif (defined($cl_opt{"mp2"})) {  $exec_opts = "-n".$cl_opt{"frames"} if defined($cl_opt{"frames"});  $tag = "mp2";} elsif (defined($cl_opt{"wm9"})) {  $exec_opts  = " -q".$cl_opt{"frames"} if defined($cl_opt{"frames"});  if (defined($cl_opt{"start_frame"})) {    $mae_opts .= " -g".$cl_opt{"start_frame"};    $diff_opts = " -wm9_skip";  }  $tag = "wm9";}$decoder{"cfg"}  = "/proj/travis/TestMovies/mpeg4_queue_files/decoder.cfg";$decoder{"diff"} = "/proj/travis/u/nathans/travis/mae/env/do_diff.pl $diff_opts ";$decoder{"mp4_exec"} = "/proj/travis/u/nathans/perforce/MPEG4-CModel-2.3/Natural/microsoft-vfdis-v10-990812/vm_dec";$decoder{"wm9_exec"} = "/proj/travis/u/nathans/perforce/WMV9-CModel/nscwmftest/wm9_player";$decoder{"mp2_exec"} = "/proj/travis/u/nathans/perforce/libmpeg2/mpeg2dec-0.4.0/src/mpeg2dec"; sub main {  if ($#ARGV != 0) {    print "Usage: do_queue.pl <stream.list>\n";    exit(1);  }  STDOUT->autoflush(1);    my $list = "$ENV{PWD}/$ARGV[0]";  my $date;  if (defined($cl_opt{"status"})) {    $date = $cl_opt{"status"};  } else {    chomp($date = `date +%h%d%y_%T`);  }  if (!defined($cl_opt{"check_only"}) && !defined($cl_opt{"status"})) {    mkdir($date) or Msg('ERROR', "can't mkdir $date");  }  if (!defined($cl_opt{"check_only"})) {    chdir($date) or Msg('ERROR', "can't chdir $date");  }  my $iter = 0;  open(P, "<$list") or die "can't open $list";  while (defined(my $abs_path = <P>)) {    chomp($abs_path);    $abs_path =~ s|//.*||;    $abs_path =~ s|#.*||;    next if ($abs_path =~ /^\s*$/);    $abs_path =~ s/\s+/ /g;    my @paths = split(/\s/, $abs_path);    my $enh_path;    if ($#paths == 1) {      $abs_path = $paths[0];      $enh_path = $paths[1];      print "Enhanced stream found $abs_path enhanced:$enh_path ";    } elsif ($#paths == 0) {      $abs_path = $paths[0];      $enh_path = "";      print "Normal stream found $abs_path ";    } else {      Msg('ERROR', "While parsing job list");    }    my $extra_args = "";    if (defined($cl_opt{"mp2"})) {      my $type = `file $abs_path`;      if ($type =~ /MPEG system stream data/) {        $extra_args .= "-s ";        print " [system stream] ";      } elsif ($type =~ /MPEG video stream data/) {        print " [video stream] ";      } else {        print " [***unrecognized stream type***: assuming video stream!]\n";        #Msg('ERROR', "Fix your test list!");      }    }    # Close info line    print "\n";    next if defined($cl_opt{"check_only"});      my $file = File::Basename::basename($abs_path);    # Check for duplicates    Msg('ERROR', "Two files with same basename: $file") if defined($unique{$file});    $unique{$file} = 1;    next if defined($cl_opt{"status"});    # Find a place for output    Msg('ERROR', "Directory $file already exists!") if (-e $file);    mkdir($file) or Msg('ERROR', "can't mkdir $file");    chdir($file) or Msg('ERROR', "can't chdir $file");    chomp(my $dir = `pwd`);    # Unique directories, all removal periodically    my $tmp       = "/tmp/do_queue.pl_$tag\_$iter\_$$";    my $clean_tmp = "/tmp/do_queue.pl_*";    $iter++;    # Output script        open(O, ">mae_cmp.tcsh") or Msg('ERROR', "can't open $dir/mae_cmp.tcsh");    print O "#!/tool/pandora/bin/tcsh                  \n";    print O "#\$ -S /tool/pandora/bin/tcsh             \n";    print O "# Job started in:$dir                     \n";    #   use -clear to remove default so we can specify all options    print O "#\$ -clear                                \n";    print O "#\$ -m n                                  \n";    print O "#\$ -cwd                                  \n";    print O "#\$ -N #$tag-$file                        \n";    print O "hostname                                  \n";    print O "echo \"Working in $tmp\"                  \n";    if (defined($cl_opt{"clean"})) {      print O "rm -rf $clean_tmp                       \n";      print O "exit                                    \n";    } else {      print O "rm -rf $tmp                             \n";    }    print O "mkdir -p $tmp                             \n";    print O "cd       $tmp                             \n";    print O "ln -s $decoder{cfg} decoder.cfg           \n";    print O "echo 'Running with CModel'                                                        \n";    if (defined($cl_opt{"mp4"})) {      print O $decoder{"$tag\_exec"}." $abs_path $enh_path out_mae 0 0 USE_MAE $exec_opts >& $dir/mae.log \n";    } elsif (defined($cl_opt{"mp2"})) {      print O $decoder{"$tag\_exec"}." $exec_opts $mae_opts $extra_args -o null -c -d -m $abs_path >& $dir/mae.log  \n";    } elsif (defined($cl_opt{"wm9"})) {      print O $decoder{"$tag\_exec"}." $exec_opts $mae_opts -U_USE_MAE $abs_path >& $dir/mae.log                    \n";    }    print O "echo 'Running with reference code'                                                \n";    if (defined($cl_opt{"mp4"})) {      print O $decoder{"$tag\_exec"}." $abs_path $enh_path out_ref 0 0 USE_REF >& $dir/ref.log \n";    } elsif (defined($cl_opt{"mp2"})) {      print O $decoder{"$tag\_exec"}." $exec_opts $ref_opts $extra_args -o null -c -d $abs_path >& $dir/ref.log     \n";    } elsif (defined($cl_opt{"wm9"})) {      print O $decoder{"$tag\_exec"}." $exec_opts $ref_opts -U_USE_REF $abs_path >& $dir/ref.log                    \n";    }    print O "echo 'Doing diff'                          \n";    print O "$decoder{diff} -$tag -all >& $dir/diff.log \n";    if (defined($cl_opt{"copy"})) {      print O qq[egrep -i "fail|error" $dir/diff.log    \n];      print O qq[if ( "X\$status" == "X0" ) then        \n];      print O qq[  bzip2 *                              \n];      print O qq[  cp * $dir                            \n];      print O qq[endif                                  \n];    }    print O "cd $dir                                    \n";    print O "touch job_done                             \n";    print O "rm -rf $tmp                                \n";    close(O);     # now start the job...    my $rc = `qsub -l linux=1 -soft -l linux64=1 mae_cmp.tcsh`;    my $rc_orig = $rc;    $rc =~ /^your job (\d+).+has been submitted/;    my $job_num = $1;    if(! $job_num) {      print "ERROR: `$rc_orig' Job was not submitted to queue!!!\n";    }      chdir("..") or Msg('ERROR', "can't chdir $file/..");  }  close(P);  return if ($cl_opt{"check_only"});  my $seconds = 300;   my @tests = keys %unique;  $total_jobs = @tests;  WHILE_LOOP: while (1) {    my $done = 1;    print "Going to check...\n";    undef %done;    FOR_LOOP: foreach my $file (keys %unique) {      if (defined($passed{$file})) {        print "$file already passed, ignoring\n";       } elsif (! -e "$file/job_done" ) {        print "$file is not finished\n";        $done = 0;      } else {        $done{$file} = 1;      }    }    if (!$done) {      print "All jobs not finished, outputing current results to do_queue.log\n";      my $msg = check_status();      print "So far: $msg\n";      print "Sleeping for $seconds seconds\n";      sleep($seconds);    } else {      last WHILE_LOOP;    }  }  # One last time  my $msg = check_status();  # Remove the total from the final status message  $msg =~ s/\[\d+ total\] //;  my $mta = ($ENV{"OSTYPE"} =~ /linux/i) ? "mail" : "mailx";  system("$mta -s \"do_queue.pl $tag results=$msg\" $ENV{USER} < do_queue.log") and die "can't mail";  chdir("..") or Msg('ERROR', "can't chdir $date/..");}sub check_status {  my $detail = "";  my $total_done = $total_pass;  foreach my $file (keys %done) {print "Checking $file...\n";    my ($ref_pass, $ref_msg) = check_file("$file/ref.log",  "FileCache: Closing files");    my ($mae_pass, $mae_msg) = check_file("$file/mae.log",  "FileCache: Closing files");    my ($diff_pass, $diff_msg) = check_file("$file/diff.log", "PASS: Differences within tolerances");    my $pass = $ref_pass && $mae_pass && $diff_pass;    if ($pass) {      $total_pass++;      $passed{$file} = 1;    }    $total_done++;        $detail .= sprintf("\n%s: $file\n", $pass ? "PASS" : "FAIL");    $detail .= sprintf("  REF run: %s : %s\n", $ref_pass ? "PASS" : "FAIL", $ref_msg);    $detail .= sprintf("  MAE run: %s : %s\n", $mae_pass ? "PASS" : "FAIL", $mae_msg);    $detail .= sprintf("  do_diff: %s : %s\n", $diff_pass ? "PASS" : "FAIL", $diff_msg);  }  open(O, ">do_queue.log") or die "can't open do_queue.log";  my $msg = sprintf("%d/%d [%d total] PASSED", $total_pass, $total_done, $total_jobs);  printf O $msg."\n\n";  printf O $detail;  close(O);  return $msg;}sub check_file ($$) {  my ($file, $pass_string) = (@_);  my $pass = -1;  my $msg = "";  if (open(I, "<$file")) {    my $okay = 0;    F_WHILE: while (defined(my $line = <I>)) {      chomp($line);      if ($line =~ /$pass_string/) {        $okay = 1; # player probably ran      } elsif (($line =~ /error|fail|info|warn|violation/i) and                ($line !~ /(Video|Audio) Stream Information/) and               ($line !~ /WARN: mae_clip: reference code should have clipped/) and               ($line !~ /WARN : DCT_TYPE_INTERLACED/)        ) {        $pass = 0;        $msg = $line;        # Grab the next line for context        if (defined($line = <I>)) {          chomp($line);          $msg .= " $line";        }        last F_WHILE;      }    }    if ($pass == 0) {      # error already detected, fall thru    } elsif (!$okay) {      $pass = 0;      $msg = "FAIL: Program outputing to $file probably core dumped";    } elsif ($okay and ($pass == -1)) {      # player ran & no error messages is a pass      $pass = 1;      $msg = "PASS";    } else {       $pass = 0;      $msg = "FAIL: do_queue.pl broken #1, not supposed to happen";    }  } else {    $pass = 0;     $msg = "FAIL: Can't find $file";  }  close(I);  if ($pass == -1) {    $pass = 0;    $msg = "FAIL: do_queue.pl broken #2, not supposed to happen";  }  return ($pass, $msg);}# -------------------------------------------------sub graceful_shutdown {# -------------------------------------------------}#--------------------------------------------------------------------------## Log functions#my ($log_fh, $log_open);$log_fh = new FileHandle;$log_open = 0; # -------------------------------------------------sub log_open($) {# -------------------------------------------------  my ($log) = @_;  $log_fh->open(">$log") or Msg('ERROR', "can't open $log");  my $date = localtime;  print $log_fh "# [$date] created\n";  $log_open = 1;}# -------------------------------------------------sub log_close() {# -------------------------------------------------  my $date = localtime;  print $log_fh "# [$date] closed\n";  $log_fh->close();  $log_open = 0;}# -------------------------------------------------sub Msg($$) {# -------------------------------------------------  my ($sev, $msg) = @_;  print "$sev: $msg\n";  if ($log_open) {    print $log_fh "# $sev: $msg\n";  }  if ($sev eq "ERROR") {    ::graceful_shutdown();    exit(1);  }}# -------------------------------------------------sub Debug($) {# -------------------------------------------------  my ($msg) = @_;  if (defined($cl_opt{"debug"})) {    Msg('DEBUG', $msg);  }}##--------------------------------------------------------------------------main();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -