To initialize Scaleform video playback system an instance of Video class should be set on the GFx::Loader object. The purpose of this state is to create an instance of a video player when the application needs to play a video file. If the video file has audio data and needs to be played then an instance of VideoSoundSystem interface should be set to GFx::Video::Video object. Scaleform provides implementations of this interface of each supported platform and the one, which is implemented based on SoundRenderer interface.
Example:
// Setting an instance of Video on the loader. An optional parameter //allows to specify the priority of the video decoding thread. Ptr<GFx::Video::Video> pvc = *new Video(Thread::NormalPriority); // Setting a video sound system instance which is based on SoundRenderer //interface if (psoundRenderer) { pvc->SetSoundSystem(psoundRenderer); } // Setting a video sound system instance which is specific to a particular //platform. // Note: SetSoundSystem method should be called only once per an instance of Video pvc->SetSoundSystem(Ptr<Video::VideoSoundSystem>(*new VideoSoundSystemDX8(0))); loader.SetVideo(pvc);
For Windows, the Video::Video class is named as VideoPC and takes three parameters. The first parameter specifies priority of the video decoding threads. The second parameter specifies the number of threads which will be used for video decoding and the third is an array of the affinity masks for each decoding thread.
VideoPC(Thread::ThreadPriority decodingThreadsPriority = Thread::NormalPriority, int decodingThreadsNumber = MAX_VIDEO_DECODING_THREADS, UInt32* affinityMask = NULL); Example: UInt32 affinities[] = { DEFAULT_VIDEO_DECODING_AFFINITY_MASK, DEFAULT_VIDEO_DECODING_AFFINITY_MASK, DEFAULT_VIDEO_DECODING_AFFINITY_MASK }; Ptr<Video::Video> pvc = *new Video::VideoPC(Thread::NormalPriority, MAX_VIDEO_DECODING_THREADS, affinities);
For PS3 and Xbox360 platforms Scaleform provides specialized version of Video classes which take some additional initialization parameters.
For PS3 this state is named GFx::Video::VideoPS3 and takes five parameters:
VideoPS3(CellSpurs* spurs, int ppu_num, Thread::ThreadPriority ppu_priority, int spu_num, UInt8* spurs_priorities = NULL);
spurs - Pointer for CellSpurs structure. spu_num - Number of SPUs which can be used for the video decoding. ppu_num - Number of PPU threads which can be used for the video decoding. ppu_priority - Priority of PPU threads. spurs_priorities- Priority of SPU cores.
Example:
UInt8 spurs_priorities[] = {1,1,1,1,0,0,0,0}; Ptr<Video::Video> pvc = *new VideoPS3(GetSpurs(), 0, 1000, 4, spurs_priorities);
Example for minimal PPU usage:
Scaleform Video can be initialized so that its PPU usage will be minimal. For example, 720p videos can be played with 50-60 FPS with less than 5% of PPU usage. This will occur if the main thread is busy enough to preempt the video decoding thread. For example, if a game is running, the main thread will be busy enough to produce this situation.
Keep in mind that the PPU usage of the decoding thread depends on the load of other threads. If the main thread is not busy, the decoding threads will use around 40% of the PPU. However, with the settings below, if the main thread is busy it will take priority over the decoding threads and the decoding thread will only use 4 or 5% of the resources. In fact, the decoding thread can be as low as 1% usage, if priorities are set correctly.
UInt8 spurs_priors[] = {0,0,1,1,1,1,0,0}; Ptr<Video::Video> pVideo = *new VideoPS3(GetSpurs(), 0, Thread::BelowNormalPriority, 4, spurs_priors);
Fox Xbox360, GFx::Video::Video state is named as VideoXbox360 and takes three parameters that specify which hardware threads will be used for the video decoding. The first parameter specifies the two threads which will do the most work internally, so these threads should not overlap if possible. The second parameter specifies the priority for the video decoding threads. The third parameter specifies the additional hardware thread for the video reader.
VideoXbox360(unsigned decodingProcs = Xbox360_Proc1 | Xbox360_Proc3 | Xbox360_Proc5, Thread::ThreadPriority decodingThreadsPriority = Thread::NormalPriority, Xbox360Proc readerProc = Xbox360_Proc2);
Example:
Ptr<Video::Video> pvc = *new VideoXbox360(Xbox360_Proc1 | Xbox360_proc3|Xbox360_Proc5, Thread::NormalPriority, Xbox360_Proc2);