Author: stippi Date: 2010-09-14 20:43:58 +0200 (Tue, 14 Sep 2010) New Revision: 38651 Changeset: http://dev.haiku-os.org/changeset/38651 Modified: haiku/trunk/src/add-ons/media/plugins/ffmpeg/AVCodecDecoder.cpp Log: * 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. Modified: haiku/trunk/src/add-ons/media/plugins/ffmpeg/AVCodecDecoder.cpp =================================================================== --- haiku/trunk/src/add-ons/media/plugins/ffmpeg/AVCodecDecoder.cpp 2010-09-14 18:43:24 UTC (rev 38650) +++ haiku/trunk/src/add-ons/media/plugins/ffmpeg/AVCodecDecoder.cpp 2010-09-14 18:43:58 UTC (rev 38651) @@ -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 @@ // 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 @@ 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;