* 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:
@@ -486,6 +486,7 @@ AVFormatReader::StreamCookie::Init(int32 virtualIndex)
|
|||||||
= codecContext->channels;
|
= codecContext->channels;
|
||||||
format->u.encoded_audio.output.format
|
format->u.encoded_audio.output.format
|
||||||
= avformat_to_beos_format(codecContext->sample_fmt);
|
= avformat_to_beos_format(codecContext->sample_fmt);
|
||||||
|
format->u.raw_audio.buffer_size = codecContext->block_align;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_MEDIA_ENCODED_VIDEO:
|
case B_MEDIA_ENCODED_VIDEO:
|
||||||
@@ -698,9 +699,8 @@ AVFormatReader::StreamCookie::GetStreamInfo(int64* frameCount,
|
|||||||
|
|
||||||
*format = fFormat;
|
*format = fFormat;
|
||||||
|
|
||||||
// TODO: Possibly use fStream->metadata for this?
|
*infoBuffer = fStream->codec->extradata;
|
||||||
*infoBuffer = 0;
|
*infoSize = fStream->codec->extradata_size;
|
||||||
*infoSize = 0;
|
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@@ -730,17 +730,19 @@ AVFormatReader::StreamCookie::Seek(uint32 flags, int64* frame,
|
|||||||
if ((flags & B_MEDIA_SEEK_TO_FRAME) != 0)
|
if ((flags & B_MEDIA_SEEK_TO_FRAME) != 0)
|
||||||
*time = (bigtime_t)(*frame * 1000000LL / FrameRate());
|
*time = (bigtime_t)(*frame * 1000000LL / FrameRate());
|
||||||
|
|
||||||
double timeBase = av_q2d(fStream->time_base);
|
|
||||||
int64_t timeStamp;
|
int64_t timeStamp;
|
||||||
if ((flags & B_MEDIA_SEEK_TO_FRAME) != 0) {
|
if ((flags & B_MEDIA_SEEK_TO_FRAME) != 0) {
|
||||||
// Can use frame, because stream timeStamp is actually in frame
|
// Can use frame, because stream timeStamp is actually in frame
|
||||||
// units.
|
// units.
|
||||||
timeStamp = *frame;
|
timeStamp = *frame;
|
||||||
} else
|
} else {
|
||||||
timeStamp = (int64_t)(*time / timeBase / 1000000.0);
|
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",
|
TRACE_SEEK(" time: %.5fs -> %lld, current DTS: %lld (time_base: %d/%d)\n",
|
||||||
*time / 1000000.0, timeStamp, fStream->cur_dts, timeBase);
|
*time / 1000000.0, timeStamp, fStream->cur_dts, fStream->time_base.num,
|
||||||
|
fStream->time_base.den);
|
||||||
|
|
||||||
if (av_seek_frame(fContext, Index(), timeStamp, 0) < 0) {
|
if (av_seek_frame(fContext, Index(), timeStamp, 0) < 0) {
|
||||||
TRACE_SEEK(" av_seek_frame() failed.\n");
|
TRACE_SEEK(" av_seek_frame() failed.\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user