From bf3834148818c986500033c3581f527a58d1d1a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Tue, 29 Sep 2009 19:37:22 +0000 Subject: [PATCH] * Use the block-alignment from the codec context as the buffer size suggestion. The audio decoding in AVDecoder needs this to work at all. * Set the infoBuffer and infoSize correctly in GetStreamInfo(). At least this is what I extract from what the AVDecoder expects. * Use a slightly more precise timeStamp calculation in the Seek() method. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33358 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../media/plugins/ffmpeg/AVFormatReader.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/add-ons/media/plugins/ffmpeg/AVFormatReader.cpp b/src/add-ons/media/plugins/ffmpeg/AVFormatReader.cpp index 588191d91e..979c0e1707 100644 --- a/src/add-ons/media/plugins/ffmpeg/AVFormatReader.cpp +++ b/src/add-ons/media/plugins/ffmpeg/AVFormatReader.cpp @@ -486,6 +486,7 @@ AVFormatReader::StreamCookie::Init(int32 virtualIndex) = codecContext->channels; format->u.encoded_audio.output.format = avformat_to_beos_format(codecContext->sample_fmt); + format->u.raw_audio.buffer_size = codecContext->block_align; break; case B_MEDIA_ENCODED_VIDEO: @@ -698,9 +699,8 @@ AVFormatReader::StreamCookie::GetStreamInfo(int64* frameCount, *format = fFormat; - // TODO: Possibly use fStream->metadata for this? - *infoBuffer = 0; - *infoSize = 0; + *infoBuffer = fStream->codec->extradata; + *infoSize = fStream->codec->extradata_size; return B_OK; } @@ -730,17 +730,19 @@ AVFormatReader::StreamCookie::Seek(uint32 flags, int64* frame, if ((flags & B_MEDIA_SEEK_TO_FRAME) != 0) *time = (bigtime_t)(*frame * 1000000LL / FrameRate()); - double timeBase = av_q2d(fStream->time_base); int64_t timeStamp; if ((flags & B_MEDIA_SEEK_TO_FRAME) != 0) { // Can use frame, because stream timeStamp is actually in frame // units. timeStamp = *frame; - } else - timeStamp = (int64_t)(*time / timeBase / 1000000.0); + } else { + timeStamp = *time * fStream->time_base.num + / ((int64_t)fStream->time_base.den * 1000000); + } - TRACE_SEEK(" time: %.2fs -> %lld, current DTS: %lld (time_base: %f)\n", - *time / 1000000.0, timeStamp, fStream->cur_dts, timeBase); + TRACE_SEEK(" time: %.5fs -> %lld, current DTS: %lld (time_base: %d/%d)\n", + *time / 1000000.0, timeStamp, fStream->cur_dts, fStream->time_base.num, + fStream->time_base.den); if (av_seek_frame(fContext, Index(), timeStamp, 0) < 0) { TRACE_SEEK(" av_seek_frame() failed.\n");