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

Method read

Engine/source/core/ogg/oggTheoraDecoder.cpp:253–317  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

251//-----------------------------------------------------------------------------
252
253U32 OggTheoraDecoder::read( OggTheoraFrame** buffer, U32 num )
254{
255 #ifdef TORQUE_DEBUG
256 AssertFatal( dCompareAndSwap( mLock, 0, 1 ), "OggTheoraDecoder::read() - simultaneous reads not thread-safe" );
257 #endif
258
259 U32 numRead = 0;
260
261 for( U32 i = 0; i < num; ++ i )
262 {
263 // Read and decode a packet.
264
265 if( !_nextPacket() )
266 return numRead; // End of stream.
267
268 // Decode the frame to Y'CbCr.
269
270 th_ycbcr_buffer ycbcr;
271 th_decode_ycbcr_out( mTheoraDecoder, ycbcr );
272
273 // Allocate a packet.
274
275 const U32 width = getFrameWidth();
276 const U32 height = getFrameHeight();
277
278 OggTheoraFrame* packet;
279 if( !mFreePackets.tryPopFront( packet ) )
280 packet = constructSingle< OggTheoraFrame* >( mPacketFormat.mPitch * height );
281
282 packet->mFrameNumber = mCurrentFrameNumber;
283 packet->mFrameTime = mCurrentFrameTime;
284 packet->mFrameDuration = mFrameDuration;
285
286 // Transcode the packet.
287
288 #if ( defined( TORQUE_COMPILER_GCC ) || defined( TORQUE_COMPILER_VISUALC ) ) && (defined( TORQUE_CPU_X86 ) )
289 if( ( mTranscoder == TRANSCODER_Auto || mTranscoder == TRANSCODER_SSE2420RGBA ) &&
290 getDecoderPixelFormat() == PIXEL_FORMAT_420 &&
291 Platform::SystemInfo.processor.properties & CPU_PROP_SSE2 &&
292 mPacketFormat.mFormat == GFXFormatR8G8B8A8 &&
293 mTheoraInfo.pic_x == 0 &&
294 mTheoraInfo.pic_y == 0 )
295 {
296 _transcode420toRGBA_SSE2( ycbcr, ( U8* ) packet->data, width, height, mPacketFormat.mPitch );
297 }
298 else
299
300 #endif
301
302 {
303 // Use generic transcoder.
304
305 _transcode( ycbcr, ( U8* ) packet->data, width, height );
306 }
307
308 buffer[ i ] = packet;
309 ++ numRead;
310 }

Callers 1

_pullNextPageMethod · 0.45

Calls 3

th_decode_ycbcr_outFunction · 0.85
dCompareAndSwapFunction · 0.50
tryPopFrontMethod · 0.45

Tested by

no test coverage detected