/[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 31 by dpavlin, Mon Oct 1 16:34:08 2007 UTC revision 33 by dpavlin, Mon Oct 1 20:26:13 2007 UTC
# Line 163  sub quality { Line 163  sub quality {
163          return $out;          return $out;
164  }  }
165    
 =for obsolete  
   
 sub mp3_frame {  
         my $frame = join('',  
                 # Frame sync (all bits set)  
                 1 x 11 .  
                 # MPEG Audio version ID  
                 # 00 - MPEG Version 2.5 (unofficial)  
                 # 01 - reserved  
                 # 10 - MPEG Version 2 (ISO/IEC 13818-3)  
                 # 11 - MPEG Version 1 (ISO/IEC 11172-3)  
                 1,0,  
                 # Layer description  
                 # 00 - reserved  
                 # 01 - Layer III  
                 # 10 - Layer II  
                 # 11 - Layer I  
                 0,1,  
                 # Protection bit  
                 # 0 - Protected by CRC (16bit crc follows header)  
                 # 1 - Not protected  
                 0,  
                 # Bitrate index  
                 0,0,0,0,  
                 # Sampling rate frequency index (22050)  
                 0,0,  
                 # Padding bit  
                 # 0 - frame is not padded  
                 # 1 - frame is padded with one extra slot  
                 0,  
                 # Private bit  
                 0,  
                 # Channel Mode  
                 # 00 - Stereo  
                 # 01 - Joint stereo (Stereo)  
                 # 10 - Dual channel (2 mono channels)  
                 # 11 - Single channel (Mono)  
                 1,1,  
                 # Mode extension (Only if Joint stereo)  
                 0,0,  
                 # Copyright  
                 0,  
                 # Original  
                 0,  
                 # Emphasis  
                 # 00 - none  
                 # 01 - 50/15 ms  
                 # 10 - reserved  
                 # 11 - CCIT J.17  
                 0,0,  
         );  
   
         die "frame must have 32 bits, not ", length($frame), " for $frame" if length($frame) != 32;  
   
         my $bits = pack("b32", $frame);  
   
         die "packed bits must be 4 bytes, not $bits" if length($bits) != 4;  
   
         my $t = $frame;  
         $t =~ s/(.{8})/$1 /g;  
         warn "## mp3 frame frame = $t\n";  
   
         return $bits;  
 }  
   
 =cut  
   
166  my @subframes;  my @subframes;
167  my $frame_nr = 1;  my $frame_nr = 1;
168    
# Line 502  sub audio_frame { Line 435  sub audio_frame {
435          warn "length isn't corrent $bytes != $size" if $bytes != $size;          warn "length isn't corrent $bytes != $size" if $bytes != $size;
436  }  }
437    
   
 sub x_audio_frame {  
         my $data = shift || die "no data?";  
   
         my $apath = sprintf("$dump_dir/%04d.wav", $frame_nr );  
         open(my $audio_fh, '>', $apath) || die "can't open audio file $apath: $!";  
   
         print $audio_fh pack 'a4Va4a4VvvVVv4', (  
                 # header 'RIFF', size  
                 'RIFF',-1,  
                 # type: 'WAVE'  
                 'WAVE',  
                 'fmt ',0x14,  
                 # format: DVI (IMA) ADPCM Wave Type  
                 0x11,  
                 # channels  
                 1,  
                 # samples/sec  
                 22050,  
                 # avg. bytes/sec (for esimation)  
                 11567,  
                 # block align (size of block)  
                 0x800,  
                 # bits per sample (mono data)  
                 4,  
                 # cbSize (ADPCM with 7 soefficient pairs)  
                 2,  
                 # nSamplesPerBlock  
                 # (((nBlockAlign - (7 * nChannels)) * 8) / (wBitsPerSample * nChannels)) + 2  
                 0x03f9,  
         );  
   
         print $audio_fh pack 'a4VVa4V', (  
                 # time length of the data in samples  
                 'fact',4,  
                 220500,  
                 #  
                 'data',-1,  
         );  
   
         my $riff_header_len = tell($audio_fh);  
   
         print $audio_fh $data;  
   
         my $size = tell($audio_fh);  
         warn "## wav file $apath size: $size\n";  
   
         seek( $audio_fh, 4, 0 );  
         print $audio_fh pack("V", $size - 8);  
         seek( $audio_fh, $riff_header_len - 4, 0 );  
         print $audio_fh pack("V", $size - $riff_header_len);  
   
         close($audio_fh) || die "can't close audio file $apath: $!";  
 }  
   
438  #  #
439  # read AMV file  # read AMV file
440  #  #
# Line 642  while ( ! defined($d->{eof}) ) { Line 520  while ( ! defined($d->{eof}) ) {
520                                          warn "unknown next part $part with $len bytes, skipping!";                                          warn "unknown next part $part with $len bytes, skipping!";
521                                  }                                  }
522    
523                                  warn "## #$frame_nr $name $part has $parts parts\n";                                  warn "## #$frame_nr $name $part has $parts parts\n" if $debug;
524                          }                          }
525    
526                          $frame_nr++;                          $frame_nr++;

Legend:
Removed from v.31  
changed lines
  Added in v.33

  ViewVC Help
Powered by ViewVC 1.1.26