/[amv]/amv.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /amv.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 24 by dpavlin, Sun Jul 22 11:05:47 2007 UTC revision 25 by dpavlin, Sat Aug 18 11:20:25 2007 UTC
# Line 18  use Carp qw/confess/; Line 18  use Carp qw/confess/;
18  use File::Path;  use File::Path;
19  use Getopt::Long;  use Getopt::Long;
20    
21  my $dump = 0;  my $dump_amv = 0;
22    my $dump_video = 0;
23    my $dump_jpeg = 0;
24    my $dump_audio = 0;
25  my $debug = 0;  my $debug = 0;
26  my $verbose = 0;  my $verbose = 0;
27  my $dump_dir = '/tmp/dump/';  my $dump_dir = '/tmp/dump/';
# Line 28  my $jpeg_q = 100; Line 31  my $jpeg_q = 100;
31  my $jpegtran;  my $jpegtran;
32    
33  GetOptions(  GetOptions(
34          "dump!"                 => \$dump,          "dump-amv!"             => \$dump_amv,
35            "dump-video!"   => \$dump_video,
36            "dump-jpeg!"    => \$dump_jpeg,
37            "dump-audio!"   => \$dump_audio,
38          "debug!"                => \$debug,          "debug!"                => \$debug,
39          "dump-dir=s"    => \$dump_dir,          "dump-dir=s"    => \$dump_dir,
40          "no-jpeg-headers!" => \$no_jpeg_header,          "no-jpeg-headers!" => \$no_jpeg_header,
# Line 53  my $o = 0; Line 59  my $o = 0;
59  my $d;  my $d;
60    
61  sub hex_dump {  sub hex_dump {
         return unless $dump;  
   
62          my ( $bytes, $offset ) = @_;          my ( $bytes, $offset ) = @_;
63          return unless $bytes;          return unless $bytes;
64    
# Line 96  sub x { Line 100  sub x {
100          my $r_len = length($bytes);          my $r_len = length($bytes);
101          confess "read $r_len bytes, expected $len" if $len != $r_len;          confess "read $r_len bytes, expected $len" if $len != $r_len;
102    
103          hex_dump( $bytes );          if ( $dump_amv ) {
104                    print "## raw $len bytes\n";
105                    hex_dump( $bytes );
106            }
107    
108          if ( $bytes eq 'AMV_END_' ) {          if ( $bytes eq 'AMV_END_' ) {
109                  print "> end of file marker AMV_END_\n" if $dump;                  print "> end of file marker AMV_END_\n" if $dump_video;
110                  $d->{eof}++;                  $d->{eof}++;
111                  return;                  return;
112          }          }
# Line 139  sub quality { Line 146  sub quality {
146                  $out .= chr($t);                  $out .= chr($t);
147          }          }
148    
149          if ( $dump ) {          if ( $dump_video ) {
150                  print "## quantization table original\n";                  print "## quantization table original\n";
151                  hex_dump( $in );                  hex_dump( $in );
152                  print "## quantization table for $jpeg_q %\n";                  print "## quantization table for $jpeg_q %\n";
# Line 353  sub mkjpg { Line 360  sub mkjpg {
360                  0,                      # Ah, Ai (not used)                  0,                      # Ah, Ai (not used)
361          );          );
362    
363          if ( $dump ) {          if ( $dump_jpeg ) {
364                  print "## created JPEG header...\n";                  print "## created JPEG header...\n";
365                  hex_dump( $header, 0 );                  hex_dump( $header, 0 );
366          }          }
# Line 465  while ( ! defined($d->{eof}) ) { Line 472  while ( ! defined($d->{eof}) ) {
472    
473                          my $audio_frame = x( $len );                          my $audio_frame = x( $len );
474    
475                            if ( $dump_audio ) {
476                                    printf "#### dumping audio frame %d 0x%x bytes\n", length($audio_frame), length($audio_frame);
477                                    hex_dump( $audio_frame );
478                            }
479    
480                          # remove 8 bytes of something                          # remove 8 bytes of something
481                          $audio_frame = substr( $audio_frame, 8 );                          $audio_frame = substr( $audio_frame, 8 );
482    
# Line 473  while ( ! defined($d->{eof}) ) { Line 485  while ( ! defined($d->{eof}) ) {
485  #                               $audio_frame = substr( $audio_frame, 0, -1 );  #                               $audio_frame = substr( $audio_frame, 0, -1 );
486                          }                          }
487    
                         if ( $dump ) {  
                                 print "#### dumping audio frame ", length($audio_frame), " bytes\n";  
                                 hex_dump( $audio_frame );  
                         }  
   
488  #                       print $audio_fh mp3_frame;  #                       print $audio_fh mp3_frame;
489                          print $audio_fh $audio_frame || die "can't write audio frame in $apath: $!";                          print $audio_fh $audio_frame || die "can't write audio frame in $apath: $!";
490    

Legend:
Removed from v.24  
changed lines
  Added in v.25

  ViewVC Help
Powered by ViewVC 1.1.26