Time for some news!
What has been done since last time- sfe::Movie::Stop() is working fine now. It goes back to the beginning and you can resume playing right after stopping the movie.
- I've been working a lot on performance optimization. Now if the video decoding is late, it is shortened as much as possible (the image is still decoded, but not resized, not converted, not loaded, and not synchronized ; in other words, it's skipped). Thus audio and video keep synchronized. See the second part of this post for more information about this point.
- I've added sfe::Movie::ResizeToFrame() to easily resize the movie. It's main interest is that you *can* preserve the original movie ratio. If you choose to do so, the movie will be centered according to the given frame. Thus you can really easily get the right position and size for your movie, so that it best fits your screen when you want to play a movie in full screen mode for example.
- I've also updated the Xcode (Mac OS X), and Code::Blocks (Windows) project files to match the file name changes.
PerformancesI did a lot of testing to find which parts in the code were taking too much time. These tests have been done on my personal laptop :
Intel Core 2 Duo 2.4 GHz, Intel GMA X3100 graphic card with 144 MB, 2 GB of DDR2 RAM.
Here are the results :
On Mac OS X:
- 31.6% : sf::Sprite::Draw()
- 16% : video decoding (avcodec_decode_video2())
- 10.1% : synchronization between the main thread and the video decoding thread with mutexes (sf::Lock)
- 7.7% : image loading (sf::Image::LoadFromPixels())
- 4.4% : image conversion from YUV to RGBA format (sws_scale())
On Windows (same computer) :
- 38% : sf::Sprite::Draw()
- 18.3% : video decoding (avcodec_decode_video2())
- 18.4% (!!!) : synchronization between the main thread and the video decoding thread with mutexes (sf::Lock)
- 6.1% : image loading (sf::Image::LoadFromPixels())
- 6.3% : image conversion from YUV to RGBA format (sws_scale()) (sws_scale())
As you can see, on Windows the synchronization is taking twice as much time as on Mac OS X. I've no explanation about this for now. But to sum it up : a 1280x544 definition movie plays fine on both Mac OS X and Windows, but as for the 2048x872 definition movie... it works fine on Mac OS X (no frame skipped) but not on Windows (frames are skipped every 1 or 2 seconds).
To my mind, this is still quite good, 1280x544 is still a good definition, and I don't have a very powerful laptop, this should be usable for higher definition movies with computers that are just a bit more powerful. I'll of course try to improve the performances for Windows if I can find a solution.