performance improvements

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13658 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
David McPaul 2005-07-13 13:41:08 +00:00
parent 24af6494ea
commit f1459e8f91
2 changed files with 13 additions and 9 deletions

View File

@ -519,13 +519,17 @@ uint32 MOVFileReader::getChunkSize(uint32 stream_index, uint32 pFrameNo)
// Get first sample in chunk
uint32 SampleNo = aTrakAtom->getFirstSampleInChunk(ChunkNo);
// Add up all sample sizes in chunk
uint32 ChunkSize = 0;
for (uint32 i=0;i<aTrakAtom->getNoSamplesInChunk(ChunkNo);i++) {
ChunkSize += aTrakAtom->getSizeForSample(SampleNo);
SampleNo++;
if (aTrakAtom->IsSingleSampleSize()) {
ChunkSize = aTrakAtom->getNoSamplesInChunk(ChunkNo) * aTrakAtom->getSizeForSample(SampleNo);
} else {
// Add up all sample sizes in chunk
for (uint32 i=0;i<aTrakAtom->getNoSamplesInChunk(ChunkNo);i++) {
ChunkSize += aTrakAtom->getSizeForSample(SampleNo);
SampleNo++;
}
}
return ChunkSize;
}
@ -557,7 +561,6 @@ bool MOVFileReader::IsKeyFrame(uint32 stream_index, uint32 pFrameNo)
bool MOVFileReader::GetNextChunkInfo(uint32 stream_index, uint32 pFrameNo, off_t *start, uint32 *size, bool *keyframe)
{
*start = getOffsetForFrame(stream_index, pFrameNo);
*size = getChunkSize(stream_index, pFrameNo);

View File

@ -26,6 +26,7 @@
#include <string.h>
#include <malloc.h>
#include <DataIO.h>
#include <StopWatch.h>
#include <ByteOrder.h>
#include <InterfaceDefs.h>
#include <MediaFormats.h>
@ -369,7 +370,7 @@ movReader::AllocateCookie(int32 streamNumber, void **_cookie)
TRACE("frame_count %Ld\n", cookie->frame_count);
TRACE("duration %.6f (%Ld)\n", cookie->duration / 1E6, cookie->duration);
TRACE("compression %s\n", &video_format->compression);
TRACE("compression %s\n", (char *)(&video_format->compression));
description.family = B_QUICKTIME_FORMAT_FAMILY;
if (stream_header->fourcc_handler == 'ekaf' || stream_header->fourcc_handler == 0) // 'fake' or 0 fourcc => used compression id
@ -482,7 +483,7 @@ movReader::GetNextChunk(void *_cookie,
mov_cookie *cookie = (mov_cookie *)_cookie;
int64 start; uint32 size; bool keyframe;
if (cookie->audio) {
if (!theFileReader->GetNextChunkInfo(cookie->stream, cookie->chunk_pos, &start, &size, &keyframe))
return B_LAST_BUFFER_ERROR;
@ -503,7 +504,7 @@ movReader::GetNextChunk(void *_cookie,
mediaHeader->u.encoded_audio.buffer_flags = keyframe ? B_MEDIA_KEY_FRAME : 0;
// This will only work with raw audio I think.
mediaHeader->start_time = (cookie->byte_pos * 1000000L * cookie->bytes_per_sec_scale) / cookie->bytes_per_sec_rate;
mediaHeader->start_time = (cookie->byte_pos * 1000000LL * cookie->bytes_per_sec_scale) / cookie->bytes_per_sec_rate;
TRACE("Audio - Frames in Chunk %ld / Actual Start Time %Ld using byte_pos\n",theFileReader->getNoFramesInChunk(cookie->stream,cookie->chunk_pos),mediaHeader->start_time);
// We should find the current frame position (ie first frame in chunk) then compute using fps