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

📄 do_diff.pl

📁 au1200 linux2.6.11 硬件解码mae驱动和maiplayer播放器源码
💻 PL
📖 第 1 页 / 共 2 页
字号:
#!/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 Getopt::Long;use Compress::Zlib;my %cl_opt;Getopt::Long::config("no_auto_abbrev");Getopt::Long::config("pass_through");Getopt::Long::GetOptions(\%cl_opt,  "ref_block_diff|rbdiff|rbd=i",  "iquant_diff|iqdiff|iqd=i",  "mc_diff|mcdiff|mcd=i",  "peak_diff|peakdiff|pd=i",  "final_diff|finaldiff|fd=i",  "omse=f",  "ome=f",  "pmse=f",  "pme=f",  "mp4", "mp2", "wm9",  "wm9_skip",             # for wm9 -g use only .mae* files for -all  "check_mc",  "keep_going|k",  "report",  "log",  "debug",  "all",  "final",  "spew");# Prototype because used in checking command line argumentssub Msg($$);#==========================================================================## Defaults#  use vars qw($mp4 $mp2 $wm9 $error);  if (!defined($cl_opt{"mp4"}) and      !defined($cl_opt{"mp2"}) and      !defined($cl_opt{"wm9"})) {    Msg('ERROR', "One of -wm9, -mp4, or -mp2 must be specified!");  }  $error = 0;  $mp4 = defined($cl_opt{"mp4"}) ? 1 : 0;  $mp2 = defined($cl_opt{"mp2"}) ? 1 : 0;  $wm9 = defined($cl_opt{"wm9"}) ? 1 : 0;  use vars qw($ppe $iquant_diff $ref_block_diff $mc_diff $peak_diff $final_diff);  $ppe            = ($wm9 ? 0 : 1);  # IQUANT is always exact, or not used on MPEG-4   $iquant_diff    = defined($cl_opt{"iquant_diff"})    ? $cl_opt{"iquant_diff"}    : 0;  $ref_block_diff = defined($cl_opt{"ref_block_diff"}) ? $cl_opt{"ref_block_diff"} : ($wm9 ? 0 : 3);  $mc_diff        = defined($cl_opt{"mc_diff"})        ? $cl_opt{"mc_diff"}        : ($wm9 ? 0 : 3);  $peak_diff      = defined($cl_opt{"peak_diff"})      ? $cl_opt{"peak_diff"}      : ($wm9 ? 0 : 0);  $final_diff     = defined($cl_opt{"final_diff"})     ? $cl_opt{"final_diff"}     : ($wm9 ? 0 : 3);    use vars qw($omse $ome $pmse $pme);  $omse           = defined($cl_opt{"omse"}) ? $cl_opt{"omse"} : .02;  $ome            = defined($cl_opt{"ome"})  ? $cl_opt{"ome"}  : .0015;  $pmse           = defined($cl_opt{"pmse"}) ? $cl_opt{"pmse"} : .06;  $pme            = defined($cl_opt{"pme"})  ? $cl_opt{"pme"}  : .015;##==========================================================================# -------------------------------------------------sub usage() {# -------------------------------------------------  Msg('Usage', "do_diff.pl [Options] <name> [<name1> <name2>]");  Msg('Usage', "");  Msg('Usage', "Options:");  Msg('Usage', "  -debug       # Print verbose diff");  Msg('Usage', "  -report      # Print stats while running");  Msg('Usage', "  -keep_going  # Continue when error detected");  Msg('Usage', "");  Msg('Usage', "One of the following is required:");  Msg('Usage', "  -mp4         # Use MPEG-4 allowed differences");  Msg('Usage', "  -mp2         # Use MPEG-2 allowed differences");  Msg('Usage', "  -wm9         # Use Windows Media 9 allowed differences");  Msg('Usage', "");  Msg('Usage', "  High level checks:");  Msg('Usage', "    -ref_block_diff | -rbd <max>  # Fail if RefBlocks diff > <max>");  Msg('Usage', "    -iquant_diff    | -iqd <max>  # Fail if IQUANT*   diff > <max>");  Msg('Usage', "    -mc_diff        | -mcd <max>  # Fail if MC*       diff > <max>");  Msg('Usage', "");  Msg('Usage', "  IDCT specific checks:");  Msg('Usage', "    -omse      # Specify IEEE omse maximum");  Msg('Usage', "    -ome       # Specify IEEE ome  maximum");  Msg('Usage', "    -pmse      # Specify IEEE pmse maximum");  Msg('Usage', "    -pme       # Specify IEEE pme  maximum");  Msg('Usage', "");  Msg('Usage', "  Motion compensation specific checks:");  Msg('Usage', "");  Msg('Usage', "    -check_mc  # Verify RefBlocks -> MC doesn't increase peak error");  Msg('Usage', "");  Msg('Usage', "Notes:");  Msg('Usage', "  1. ppe is always hardcoded to 1");  Msg('Usage', "  2. Always fails if sees array values <-255 or >255");  Msg('Usage', "    ***This will have to be fixed for non-MP4 IQUANT***");  Msg('Usage', "  3. -check_mc is NOT on by default");  exit(1);}#==========================================================================## State tracking  use vars qw($iquant $idct $mc $ref_blocks $final);##==========================================================================#==========================================================================## IDCT tracking#  use vars qw($omse_num $ome_num @pmse_num @pme_num $oe_total $pe_total);  # -------------------------------------------------  sub reset_idct_tracking {  # -------------------------------------------------    $omse_num  = 0;        # Stream total abs(diff) for all (i,j)    $ome_num   = 0;        # Stream total diff for all (i,j)    @pmse_num  = (         # Stream abs(diff) at each (i,j)      0, 0, 0, 0, 0, 0, 0, 0,      0, 0, 0, 0, 0, 0, 0, 0,      0, 0, 0, 0, 0, 0, 0, 0,      0, 0, 0, 0, 0, 0, 0, 0,      0, 0, 0, 0, 0, 0, 0, 0,      0, 0, 0, 0, 0, 0, 0, 0,      0, 0, 0, 0, 0, 0, 0, 0,      0, 0, 0, 0, 0, 0, 0, 0    );    @pme_num   = @pmse_num; # Stream diff  at each (i,j)    $oe_total  = 0;         # Stream total number of (i,j)    $pe_total  = 0;         # Stream total number of blocks  }    # -------------------------------------------------  sub check_idct() {  # -------------------------------------------------    Msg('Report', "Checking IDCT accuracy...");    my $calc_omse = $omse_num / $oe_total;    my $calc_ome  = $ome_num  / $oe_total;    Msg('Report', sprintf("omse: %7.4f [require < %7.4f]", $calc_omse, $omse));    Msg('Report', sprintf("ome : %7.4f [require < %7.4f]", $calc_ome, $ome));    Msg('ERROR', "$calc_omse > allowed $omse") unless ($calc_omse <= $omse);    Msg('ERROR', "$calc_ome  > allowed $ome")  unless ($calc_ome  <= $ome);    my $line = "";    $line .= sprintf(" pmse [require < %7.4f]                     ", $pmse);    $line .= sprintf("                      pme  [require < %7.4f]", $pme);    Msg('Report', $line);    my (@calc_pmse, @calc_pme);    for (my $row = 0; $row < 8; $row++) {      my ($pmse_line, $pme_line) = ("", "");      for (my $col = 0; $col < 8; $col++) {        my $entry = $row * 8 + $col;        $calc_pmse[$entry] = $pmse_num[$entry] / $pe_total;        $calc_pme [$entry] = $pme_num [$entry] / $pe_total;        $pmse_line .= sprintf("%7.4f ", $calc_pmse[$entry]);        $pme_line  .= sprintf("%7.4f ", $calc_pme [$entry]);      }      Msg('Report', $pmse_line."    ".$pme_line);    }    for (my $i = 0; $i < 64; $i++) {      Msg('ERROR', "$calc_pmse[$i] > allowed $pmse for entry $i") unless ($calc_pmse[$i] <= $pmse);      Msg('ERROR', "$calc_pme[$i]  > allowed $pme for entry $i")  unless ($calc_pme[$i]  <= $pme);   }  }##==========================================================================#==========================================================================## RefBlocks->MC tracking## Maximum peak difference in macroblock  use vars qw(%peak_ref %peak_diff);##==========================================================================#==========================================================================## File I/O#  use vars qw($zipped $peeked $peek_m_line $peek_r_line $M $R);  sub file_open ($) {    # Note: All inputs are references    my ($file) = @_;      # Find file    my $ext = "";    if (-r "$$file.ref" and -r "$$file.mae") {      $zipped = 0;      $ext = "";    } elsif (-r "$$file.ref.gz" and -r "$$file.mae.gz") {      $zipped = 1;      $ext = ".gz";    } else {      Msg('ERROR', "Can't find $$file.(ref|mae) or $$file.(ref|mae).gz, player broken?");      return 0;    }       # Open file    #$zipped = (`file $$file.ref$ext` =~ /gzip/) ? 1 : 0;    if ($zipped) {      Debug("Found gzip'ed file $$file");      $M = Compress::Zlib::gzopen("$$file.mae$ext", "r");      $R = Compress::Zlib::gzopen("$$file.ref$ext", "r");    } else {      $M = new FileHandle;      $R = new FileHandle;        $M->open("<$$file.mae$ext") or die "can't open $$file.mae$ext";      $R->open("<$$file.ref$ext") or die "can't open $$file.ref$ext";    }    # Initial peek state    $peeked = 0;    return 1;  }    sub file_getlines($$$) {    # Note: All inputs are references    # Note: Returns 1 if EOF    my ($m_line, $r_line, $peek) = @_;    # If already fetched these lines, just return them    if ($peeked) {      $$m_line = $peek_m_line;       $$r_line = $peek_r_line;       $peeked = 0;      return 0;    }     my $eof;     if ($zipped) {      my $m_bytes = $M->gzreadline($$m_line);      my $r_bytes = $R->gzreadline($$r_line);      $eof = ($m_bytes == 0) ? 1 : 0;    } else {      $$m_line = $M->getline();      $$r_line = $R->getline();      $eof = defined($$m_line) ? 0 : 1;    }    if (!$eof) {      chomp($$m_line);      chomp($$r_line);      if (defined($cl_opt{"spew"})) {          Debug("M_PROC $$m_line");        Debug("R_PROC $$r_line");      }    }    if ($peek) {      $peek_m_line = $$m_line;      $peek_r_line = $$r_line;      $peeked = 1;    }    return $eof;  }##==========================================================================sub by_frame {  my $aa = $a;  $aa =~ s/(Final|MC|RefBlocksMV|IQUANT|IDCT|DB|OL|For)//g;  $aa =~ s/(Intra|Inter)//;  $aa =~ s/[YUV]//;  $aa =~ s/[BP]//;  $aa =~ s/.(ref|mae).gz//;  my $bb = $b;  $bb =~ s/(Final|MC|RefBlocksMV|IQUANT|IDCT|DB|OL|For)//g;  $bb =~ s/(Intra|Inter)//;  $bb =~ s/[YUV]//;  $bb =~ s/[BP]//;  $bb =~ s/.(ref|mae).gz//;  #print "$aa $bb\n";  return $aa <=> $bb;}# -------------------------------------------------sub main() {# -------------------------------------------------  log_open("do_diff.log") if defined($cl_opt{"log"});   usage() unless (defined($cl_opt{"all"}) or ($#ARGV > -1));  my %files;  my $num_idct_files = 0;  my @expanded_argv;  # Avoid shell limits on maximum # of files  if (defined($cl_opt{"all"})) {    my $all_string;    if (defined($cl_opt{"wm9_skip"})) {      $all_string = "*.mae.gz *.mae";    } else {      $all_string = "*.gz *.ref *.mae";    }    foreach my $file (glob($all_string)) {      if (defined($cl_opt{"final"})) {        if ($file !~ /^(Final|DB|OL)/) {          print "Ignoring $file\n";          next;        }      }      print "Adding $file\n";      push(@expanded_argv, $file);    }  }  foreach my $file (@ARGV) {    if ($file =~ /\*/) {      push(@expanded_argv, glob($file));    } else {      push(@expanded_argv, $file);    }  }  foreach my $file (@expanded_argv) {    $file =~ s/\.mae$//;    $file =~ s/\.mae.gz$//;    $file =~ s/\.ref$//;    $file =~ s/\.ref.gz$//;    if (!$wm9 and ($file =~ /MCInter/)) {      #$cl_opt{"check_mc"} = 1;    }    if ($file =~ /IDCT/) {      $num_idct_files++;    }    $files{$file} = 1;  }    my $did_idct = 0;  reset_idct_tracking();  foreach my $file (sort by_frame keys %files) {    if ($file =~ /Final/) {       ($iquant, $idct, $mc, $ref_blocks, $final)   = (0, 0, 0, 0, 1);      do_diff($file, $final_diff);    } elsif ($file =~ /IDCT/) {      ($iquant, $idct, $mc, $ref_blocks, $final)   = (0, 1, 0, 0, 0);      do_diff($file, $ppe);    } elsif ($file =~ /IQUANT/) {      ($iquant, $idct, $mc, $ref_blocks, $final)   = (1, 0, 0, 0, 0);      do_diff($file, $iquant_diff);    } elsif ($file =~ /MC/) {      if (defined($cl_opt{"check_mc"}))  {        my $rb_file = $file;        $rb_file =~ s/MCInter/RefBlocksMV/;        undef %peak_ref;        undef %peak_diff;        ($iquant, $idct, $mc, $ref_blocks, $final) = (0, 0, 0, 1, 0);        do_diff($rb_file, $ref_block_diff);      }      ($iquant, $idct, $mc, $ref_blocks, $final)   = (0, 0, 1, 0, 0);      do_diff($file, $mc_diff);    } elsif ($file =~ /RefBlock/) {      if (!defined($cl_opt{"check_mc"}))  {        ($iquant, $idct, $mc, $ref_blocks, $final) = (0, 0, 0, 1, 0);        do_diff($file, $ref_block_diff);      }    } elsif ($file =~ /^(DB|OL)/) {

⌨️ 快捷键说明

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