* 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
This commit is contained in:
Stephan Aßmus 2009-09-29 19:37:22 +00:00
parent cc04faa6c1
commit bf38341488

View File

@ -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");