MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / _init

Method _init

Engine/source/core/ogg/oggTheoraDecoder.cpp:157–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155//-----------------------------------------------------------------------------
156
157bool OggTheoraDecoder::_init()
158{
159 ogg_packet nextPacket;
160
161 // Read header packets.
162
163 bool haveTheoraHeader = true;
164 while( 1 )
165 {
166 if( !_readNextPacket( &nextPacket ) )
167 {
168 haveTheoraHeader = false;
169 break;
170 }
171
172 S32 result = th_decode_headerin( &mTheoraInfo, &mTheoraComment, &mTheoraSetup, &nextPacket );
173 if( result < 0 )
174 {
175 haveTheoraHeader = false;
176 break;
177 }
178 else if( result == 0 )
179 break;
180 }
181
182 // Fail if we have no valid and complete Theora header.
183
184 if( !haveTheoraHeader )
185 {
186 th_comment_clear( &mTheoraComment );
187 th_info_clear( &mTheoraInfo );
188
189 Con::errorf( "OggTheoraDecoder::_init() - incorrect or corrupt Theora headers" );
190
191 return false;
192 }
193
194 // Init the decoder.
195
196 mTheoraDecoder = th_decode_alloc( &mTheoraInfo, mTheoraSetup );
197
198 // Feed the first video packet to the decoder.
199
200 ogg_int64_t granulePos;
201 th_decode_packetin( mTheoraDecoder, &nextPacket, &granulePos );
202
203 mCurrentFrameTime = th_granule_time( mTheoraDecoder, granulePos );
204 mCurrentFrameNumber = 0;
205 mFrameDuration = 1.f / getFramesPerSecond();
206
207 // Make sure we have a valid pitch.
208
209 if( !mPacketFormat.mPitch )
210 mPacketFormat.mPitch = getFrameWidth() * GFXFormatInfo( mPacketFormat.mFormat ).getBytesPerPixel();
211
212 return true;
213}
214

Callers 1

initMethod · 0.45

Calls 9

th_decode_headerinFunction · 0.85
th_comment_clearFunction · 0.85
th_info_clearFunction · 0.85
th_decode_allocFunction · 0.85
th_decode_packetinFunction · 0.85
th_granule_timeFunction · 0.85
GFXFormatInfoClass · 0.85
errorfFunction · 0.50
getBytesPerPixelMethod · 0.45

Tested by

no test coverage detected