[SPIP][PLUGINS] v3.0-->v3.2
[lhc/web/www.git] / www / plugins-dist / medias / lib / getid3 / module.audio-video.bink.php
1 <?php
2 /////////////////////////////////////////////////////////////////
3 /// getID3() by James Heinrich <info@getid3.org> //
4 // available at http://getid3.sourceforge.net //
5 // or http://www.getid3.org //
6 // also https://github.com/JamesHeinrich/getID3 //
7 /////////////////////////////////////////////////////////////////
8 // See readme.txt for more details //
9 /////////////////////////////////////////////////////////////////
10 // //
11 // module.audio.bink.php //
12 // module for analyzing Bink or Smacker audio-video files //
13 // dependencies: NONE //
14 // ///
15 /////////////////////////////////////////////////////////////////
16
17
18 class getid3_bink extends getid3_handler
19 {
20
21 public function Analyze() {
22 $info = &$this->getid3->info;
23
24 $this->error('Bink / Smacker files not properly processed by this version of getID3() ['.$this->getid3->version().']');
25
26 $this->fseek($info['avdataoffset']);
27 $fileTypeID = $this->fread(3);
28 switch ($fileTypeID) {
29 case 'BIK':
30 return $this->ParseBink();
31 break;
32
33 case 'SMK':
34 return $this->ParseSmacker();
35 break;
36
37 default:
38 $this->error('Expecting "BIK" or "SMK" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($fileTypeID).'"');
39 return false;
40 break;
41 }
42
43 return true;
44
45 }
46
47 public function ParseBink() {
48 $info = &$this->getid3->info;
49 $info['fileformat'] = 'bink';
50 $info['video']['dataformat'] = 'bink';
51
52 $fileData = 'BIK'.$this->fread(13);
53
54 $info['bink']['data_size'] = getid3_lib::LittleEndian2Int(substr($fileData, 4, 4));
55 $info['bink']['frame_count'] = getid3_lib::LittleEndian2Int(substr($fileData, 8, 2));
56
57 if (($info['avdataend'] - $info['avdataoffset']) != ($info['bink']['data_size'] + 8)) {
58 $this->error('Probably truncated file: expecting '.$info['bink']['data_size'].' bytes, found '.($info['avdataend'] - $info['avdataoffset']));
59 }
60
61 return true;
62 }
63
64 public function ParseSmacker() {
65 $info = &$this->getid3->info;
66 $info['fileformat'] = 'smacker';
67 $info['video']['dataformat'] = 'smacker';
68
69 return true;
70 }
71
72 }