* Print the performance stats every five frames, and reset

the counters, so it's not the average for the entire
   decoding time, but for the last five frames. This gives
   a more accurate picture of what's going on.
 * Added NOTE about possibly removing the SWS version of the
   colorspace conversion code unless it's used for otherwise
   unsupported conversions. David's code is about 40% faster
   in my tests (nice job!).
 * Free the sws context in NegotiateVideoFormat, if necessary.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38651 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2010-09-14 18:43:58 +00:00
parent 338ddd836f
commit 5a6b18e914

View File

@ -41,6 +41,9 @@
#endif
#define USE_SWS_FOR_COLOR_SPACE_CONVERSION 0
// NOTE: David's color space conversion is much faster than the FFmpeg
// version. Perhaps the SWS code can be used for unsupported conversions?
// Otherwise the alternative code could simply be removed from this file.
struct wave_format_ex {
@ -494,6 +497,8 @@ AVCodecDecoder::_NegotiateVideoOutputFormat(media_format* inOutFormat)
// But libavcodec doesn't seem to offer any way to tell the decoder
// which format it should use.
#if USE_SWS_FOR_COLOR_SPACE_CONVERSION
if (fSwsContext != NULL)
sws_freeContext(fSwsContext);
fSwsContext = NULL;
#else
fFormatConversionFunc = 0;
@ -852,20 +857,23 @@ AVCodecDecoder::_DecodeVideo(void* outBuffer, int64* outFrameCount,
decodingTime += formatConversionStart - startTime;
conversionTime += doneTime - formatConversionStart;
profileCounter++;
if (!(fFrame % 10)) {
if (!(fFrame % 5)) {
if (info) {
printf("[v] profile: d1 = %lld, d2 = %lld (%Ld) required "
printf("[v] profile: d1 = %lld, d2 = %lld (%lld) required "
"%Ld\n",
decodingTime / profileCounter,
conversionTime / profileCounter,
fFrame, info->time_to_decode);
} else {
printf("[v] profile: d1 = %lld, d2 = %lld (%Ld) required "
printf("[v] profile: d1 = %lld, d2 = %lld (%lld) required "
"%Ld\n",
decodingTime / profileCounter,
conversionTime / profileCounter,
fFrame, bigtime_t(1000000LL / fOutputFrameRate));
}
decodingTime = 0;
conversionTime = 0;
profileCounter = 0;
}
#endif
return B_OK;