~canonical-sysadmins/wordpress/4.7

« back to all changes in this revision

Viewing changes to wp-includes/ID3/module.audio.ogg.php

  • Committer: Nick Moffitt
  • Date: 2015-01-15 11:04:26 UTC
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: nick.moffitt@canonical.com-20150115110426-5stm1p14cfnxrtme
New Upstream Version 4.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
/// getID3() by James Heinrich <info@getid3.org>               //
4
4
//  available at http://getid3.sourceforge.net                 //
5
5
//            or http://www.getid3.org                         //
 
6
//          also https://github.com/JamesHeinrich/getID3       //
6
7
/////////////////////////////////////////////////////////////////
7
8
// See readme.txt for more details                             //
8
9
/////////////////////////////////////////////////////////////////
114
115
                                $info['audio']['bitrate_mode'] = 'vbr';
115
116
                        }
116
117
 
 
118
                } elseif (substr($filedata, 0, 7) == "\x80".'theora') {
 
119
 
 
120
                        // http://www.theora.org/doc/Theora.pdf (section 6.2)
 
121
 
 
122
                        $info['ogg']['pageheader']['theora']['theora_magic']             =                           substr($filedata, $filedataoffset,  7); // hard-coded to "\x80.'theora'
 
123
                        $filedataoffset += 7;
 
124
                        $info['ogg']['pageheader']['theora']['version_major']            = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset,  1));
 
125
                        $filedataoffset += 1;
 
126
                        $info['ogg']['pageheader']['theora']['version_minor']            = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset,  1));
 
127
                        $filedataoffset += 1;
 
128
                        $info['ogg']['pageheader']['theora']['version_revision']         = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset,  1));
 
129
                        $filedataoffset += 1;
 
130
                        $info['ogg']['pageheader']['theora']['frame_width_macroblocks']  = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset,  2));
 
131
                        $filedataoffset += 2;
 
132
                        $info['ogg']['pageheader']['theora']['frame_height_macroblocks'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset,  2));
 
133
                        $filedataoffset += 2;
 
134
                        $info['ogg']['pageheader']['theora']['resolution_x']             = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset,  3));
 
135
                        $filedataoffset += 3;
 
136
                        $info['ogg']['pageheader']['theora']['resolution_y']             = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset,  3));
 
137
                        $filedataoffset += 3;
 
138
                        $info['ogg']['pageheader']['theora']['picture_offset_x']         = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset,  1));
 
139
                        $filedataoffset += 1;
 
140
                        $info['ogg']['pageheader']['theora']['picture_offset_y']         = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset,  1));
 
141
                        $filedataoffset += 1;
 
142
                        $info['ogg']['pageheader']['theora']['frame_rate_numerator']     = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset,  4));
 
143
                        $filedataoffset += 4;
 
144
                        $info['ogg']['pageheader']['theora']['frame_rate_denominator']   = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset,  4));
 
145
                        $filedataoffset += 4;
 
146
                        $info['ogg']['pageheader']['theora']['pixel_aspect_numerator']   = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset,  3));
 
147
                        $filedataoffset += 3;
 
148
                        $info['ogg']['pageheader']['theora']['pixel_aspect_denominator'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset,  3));
 
149
                        $filedataoffset += 3;
 
150
                        $info['ogg']['pageheader']['theora']['color_space_id']           = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset,  1));
 
151
                        $filedataoffset += 1;
 
152
                        $info['ogg']['pageheader']['theora']['nominal_bitrate']          = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset,  3));
 
153
                        $filedataoffset += 3;
 
154
                        $info['ogg']['pageheader']['theora']['flags']                    = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset,  2));
 
155
                        $filedataoffset += 2;
 
156
 
 
157
                        $info['ogg']['pageheader']['theora']['quality']         = ($info['ogg']['pageheader']['theora']['flags'] & 0xFC00) >> 10;
 
158
                        $info['ogg']['pageheader']['theora']['kfg_shift']       = ($info['ogg']['pageheader']['theora']['flags'] & 0x03E0) >>  5;
 
159
                        $info['ogg']['pageheader']['theora']['pixel_format_id'] = ($info['ogg']['pageheader']['theora']['flags'] & 0x0018) >>  3;
 
160
                        $info['ogg']['pageheader']['theora']['reserved']        = ($info['ogg']['pageheader']['theora']['flags'] & 0x0007) >>  0; // should be 0
 
161
                        $info['ogg']['pageheader']['theora']['color_space']     = self::TheoraColorSpace($info['ogg']['pageheader']['theora']['color_space_id']);
 
162
                        $info['ogg']['pageheader']['theora']['pixel_format']    = self::TheoraPixelFormat($info['ogg']['pageheader']['theora']['pixel_format_id']);
 
163
 
 
164
                        $info['video']['dataformat']   = 'theora';
 
165
                        $info['mime_type']             = 'video/ogg';
 
166
                        //$info['audio']['bitrate_mode'] = 'abr';
 
167
                        //$info['audio']['lossless']     = false;
 
168
                        $info['video']['resolution_x'] = $info['ogg']['pageheader']['theora']['resolution_x'];
 
169
                        $info['video']['resolution_y'] = $info['ogg']['pageheader']['theora']['resolution_y'];
 
170
                        if ($info['ogg']['pageheader']['theora']['frame_rate_denominator'] > 0) {
 
171
                                $info['video']['frame_rate'] = (float) $info['ogg']['pageheader']['theora']['frame_rate_numerator'] / $info['ogg']['pageheader']['theora']['frame_rate_denominator'];
 
172
                        }
 
173
                        if ($info['ogg']['pageheader']['theora']['pixel_aspect_denominator'] > 0) {
 
174
                                $info['video']['pixel_aspect_ratio'] = (float) $info['ogg']['pageheader']['theora']['pixel_aspect_numerator'] / $info['ogg']['pageheader']['theora']['pixel_aspect_denominator'];
 
175
                        }
 
176
$info['warning'][] = 'Ogg Theora (v3) not fully supported in this version of getID3 ['.$this->getid3->version().'] -- bitrate, playtime and all audio data are currently unavailable';
 
177
 
117
178
 
118
179
                } elseif (substr($filedata, 0, 8) == "fishead\x00") {
119
180
 
172
233
 
173
234
                                } elseif (substr($filedata, 1, 6) == 'theora') {
174
235
 
175
 
                                        $info['video']['dataformat'] = 'theora';
176
 
                                        $info['error'][] = 'Ogg Theora not correctly handled in this version of getID3 ['.$this->getid3->version().']';
 
236
                                        $info['video']['dataformat'] = 'theora1';
 
237
                                        $info['error'][] = 'Ogg Theora (v1) not correctly handled in this version of getID3 ['.$this->getid3->version().']';
177
238
                                        //break;
178
239
 
179
240
                                } elseif (substr($filedata, 1, 6) == 'vorbis') {
668
729
                return round($qval, 1); // 5 or 4.9
669
730
        }
670
731
 
671
 
}
 
732
        public static function TheoraColorSpace($colorspace_id) {
 
733
                // http://www.theora.org/doc/Theora.pdf (table 6.3)
 
734
                static $TheoraColorSpaceLookup = array();
 
735
                if (empty($TheoraColorSpaceLookup)) {
 
736
                        $TheoraColorSpaceLookup[0] = 'Undefined';
 
737
                        $TheoraColorSpaceLookup[1] = 'Rec. 470M';
 
738
                        $TheoraColorSpaceLookup[2] = 'Rec. 470BG';
 
739
                        $TheoraColorSpaceLookup[3] = 'Reserved';
 
740
                }
 
741
                return (isset($TheoraColorSpaceLookup[$colorspace_id]) ? $TheoraColorSpaceLookup[$colorspace_id] : null);
 
742
        }
 
743
 
 
744
        public static function TheoraPixelFormat($pixelformat_id) {
 
745
                // http://www.theora.org/doc/Theora.pdf (table 6.4)
 
746
                static $TheoraPixelFormatLookup = array();
 
747
                if (empty($TheoraPixelFormatLookup)) {
 
748
                        $TheoraPixelFormatLookup[0] = '4:2:0';
 
749
                        $TheoraPixelFormatLookup[1] = 'Reserved';
 
750
                        $TheoraPixelFormatLookup[2] = '4:2:2';
 
751
                        $TheoraPixelFormatLookup[3] = '4:4:4';
 
752
                }
 
753
                return (isset($TheoraPixelFormatLookup[$pixelformat_id]) ? $TheoraPixelFormatLookup[$pixelformat_id] : null);
 
754
        }
 
755
 
 
756
}
 
 
b'\\ No newline at end of file'