From 5a6b18e9140272344c30bc91526547c96f3150d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Tue, 14 Sep 2010 18:43:58 +0000 Subject: [PATCH] * 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 --- .../media/plugins/ffmpeg/AVCodecDecoder.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/add-ons/media/plugins/ffmpeg/AVCodecDecoder.cpp b/src/add-ons/media/plugins/ffmpeg/AVCodecDecoder.cpp index 3615e720f5..5a499865a4 100644 --- a/src/add-ons/media/plugins/ffmpeg/AVCodecDecoder.cpp +++ b/src/add-ons/media/plugins/ffmpeg/AVCodecDecoder.cpp @@ -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;