21 $ThisFileInfo[
'fileformat'] =
'gif';
22 $ThisFileInfo[
'video'][
'dataformat'] =
'gif';
23 $ThisFileInfo[
'video'][
'lossless'] =
true;
24 $ThisFileInfo[
'video'][
'pixel_aspect_ratio'] = (float) 1;
26 fseek($fd, $ThisFileInfo[
'avdataoffset'], SEEK_SET);
27 $GIFheader = fread($fd, 13);
30 $ThisFileInfo[
'gif'][
'header'][
'raw'][
'identifier'] = substr($GIFheader, $offset, 3);
33 if ($ThisFileInfo[
'gif'][
'header'][
'raw'][
'identifier'] !=
'GIF') {
34 $ThisFileInfo[
'error'][] =
'Expecting "GIF" at offset '.$ThisFileInfo[
'avdataoffset'].
', found "'.$ThisFileInfo[
'gif'][
'header'][
'raw'][
'identifier'].
'"';
35 unset($ThisFileInfo[
'fileformat']);
36 unset($ThisFileInfo[
'gif']);
40 $ThisFileInfo[
'gif'][
'header'][
'raw'][
'version'] = substr($GIFheader, $offset, 3);
53 $ThisFileInfo[
'video'][
'resolution_x'] = $ThisFileInfo[
'gif'][
'header'][
'raw'][
'width'];
54 $ThisFileInfo[
'video'][
'resolution_y'] = $ThisFileInfo[
'gif'][
'header'][
'raw'][
'height'];
55 $ThisFileInfo[
'gif'][
'version'] = $ThisFileInfo[
'gif'][
'header'][
'raw'][
'version'];
56 $ThisFileInfo[
'gif'][
'header'][
'flags'][
'global_color_table'] = (bool) ($ThisFileInfo[
'gif'][
'header'][
'raw'][
'flags'] & 0x80);
57 if ($ThisFileInfo[
'gif'][
'header'][
'raw'][
'flags'] & 0x80) {
59 $ThisFileInfo[
'gif'][
'header'][
'bits_per_pixel'] = 3 * ((($ThisFileInfo[
'gif'][
'header'][
'raw'][
'flags'] & 0x70) >> 4) + 1);
61 $ThisFileInfo[
'gif'][
'header'][
'bits_per_pixel'] = 0;
63 $ThisFileInfo[
'gif'][
'header'][
'flags'][
'global_color_sorted'] = (bool) ($ThisFileInfo[
'gif'][
'header'][
'raw'][
'flags'] & 0x40);
64 if ($ThisFileInfo[
'gif'][
'header'][
'flags'][
'global_color_table']) {
67 $ThisFileInfo[
'gif'][
'header'][
'global_color_size'] = pow(2, ($ThisFileInfo[
'gif'][
'header'][
'raw'][
'flags'] & 0x07) + 1);
68 $ThisFileInfo[
'video'][
'bits_per_sample'] = ($ThisFileInfo[
'gif'][
'header'][
'raw'][
'flags'] & 0x07) + 1;
70 $ThisFileInfo[
'gif'][
'header'][
'global_color_size'] = 0;
72 if ($ThisFileInfo[
'gif'][
'header'][
'raw'][
'aspect_ratio'] != 0) {
74 $ThisFileInfo[
'gif'][
'header'][
'aspect_ratio'] = ($ThisFileInfo[
'gif'][
'header'][
'raw'][
'aspect_ratio'] + 15) / 64;
168 static $bitbuffer =
'';
169 while (strlen($bitbuffer) < $bits) {
171 $bitbuffer = str_pad(decbin(ord(fread($fd, 1))), 8,
'0', STR_PAD_LEFT).$bitbuffer;
174 $value = bindec(substr($bitbuffer, 0 - $bits));
175 $bitbuffer = substr($bitbuffer, 0, 0 - $bits);