* printf -> TRACE (turned off)
* fixed a few compiler warnings git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24475 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -27,7 +27,7 @@
|
|||||||
#include "OpenDMLParser.h"
|
#include "OpenDMLParser.h"
|
||||||
#include "avi.h"
|
#include "avi.h"
|
||||||
|
|
||||||
#define TRACE_ODML_PARSER
|
//#define TRACE_ODML_PARSER
|
||||||
#ifdef TRACE_ODML_PARSER
|
#ifdef TRACE_ODML_PARSER
|
||||||
#define TRACE printf
|
#define TRACE printf
|
||||||
#else
|
#else
|
||||||
@@ -167,9 +167,13 @@ OpenDMLParser::Init()
|
|||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 frame_count = OdmlExtendedHeader() ? OdmlExtendedHeader()->total_frames : AviMainHeader()->total_frames;
|
#ifdef TRACE_ODML_PARSER
|
||||||
bigtime_t duration = frame_count * AviMainHeader()->micro_sec_per_frame;
|
uint32 frameCount = OdmlExtendedHeader() ?
|
||||||
printf("AVI Header frame count %lu, duration %.6f\n", frame_count, duration / 1E6);
|
OdmlExtendedHeader()->total_frames : AviMainHeader()->total_frames;
|
||||||
|
bigtime_t duration = frameCount * AviMainHeader()->micro_sec_per_frame;
|
||||||
|
printf("AVI Header frame count %lu, duration %.6f\n", frameCount,
|
||||||
|
duration / 1E6);
|
||||||
|
#endif
|
||||||
|
|
||||||
for (int i = 0; i < fStreamCount; i++) {
|
for (int i = 0; i < fStreamCount; i++) {
|
||||||
SetupStreamLength(const_cast<stream_info *>(StreamInfo(i)));
|
SetupStreamLength(const_cast<stream_info *>(StreamInfo(i)));
|
||||||
@@ -197,42 +201,48 @@ OpenDMLParser::SetupAudioStreamLength(stream_info *stream)
|
|||||||
&& stream->stream_header.sample_size != 0
|
&& stream->stream_header.sample_size != 0
|
||||||
&& stream->stream_header.sample_size != 1) { // PCM
|
&& stream->stream_header.sample_size != 1) { // PCM
|
||||||
stream->frame_count /= (stream->stream_header.sample_size + 7) / 8;
|
stream->frame_count /= (stream->stream_header.sample_size + 7) / 8;
|
||||||
printf("audio: messing up PCM frame_count?\n");
|
TRACE("audio: messing up PCM frame_count?\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stream->stream_header.rate && stream->stream_header.scale) {
|
if (stream->stream_header.rate && stream->stream_header.scale) {
|
||||||
stream->frames_per_sec_rate = stream->stream_header.rate;
|
stream->frames_per_sec_rate = stream->stream_header.rate;
|
||||||
stream->frames_per_sec_scale = stream->stream_header.scale;
|
stream->frames_per_sec_scale = stream->stream_header.scale;
|
||||||
stream->duration = (stream->frame_count * stream->frames_per_sec_scale * 1000000) / stream->frames_per_sec_rate;
|
stream->duration = (stream->frame_count * stream->frames_per_sec_scale * 1000000) / stream->frames_per_sec_rate;
|
||||||
printf("audio: using rate+scale\n");
|
TRACE("audio: using rate+scale\n");
|
||||||
} else if (stream->audio_format->avg_bytes_per_sec) {
|
} else if (stream->audio_format->avg_bytes_per_sec) {
|
||||||
stream->frames_per_sec_rate = stream->audio_format->avg_bytes_per_sec;
|
stream->frames_per_sec_rate = stream->audio_format->avg_bytes_per_sec;
|
||||||
stream->frames_per_sec_scale = 1;
|
stream->frames_per_sec_scale = 1;
|
||||||
stream->duration = (stream->frame_count * stream->frames_per_sec_scale * 1000000) / stream->frames_per_sec_rate;
|
stream->duration = (stream->frame_count * stream->frames_per_sec_scale * 1000000) / stream->frames_per_sec_rate;
|
||||||
printf("audio: using avg_bytes_per_sec\n");
|
TRACE("audio: using avg_bytes_per_sec\n");
|
||||||
} else if (AviMainHeader()->micro_sec_per_frame) {
|
} else if (AviMainHeader()->micro_sec_per_frame) {
|
||||||
uint32 video_frame_count = OdmlExtendedHeader() ? OdmlExtendedHeader()->total_frames : AviMainHeader()->total_frames;
|
uint32 video_frame_count = OdmlExtendedHeader() ? OdmlExtendedHeader()->total_frames : AviMainHeader()->total_frames;
|
||||||
stream->duration = video_frame_count * AviMainHeader()->micro_sec_per_frame;
|
stream->duration = video_frame_count * AviMainHeader()->micro_sec_per_frame;
|
||||||
stream->frames_per_sec_rate = (stream->frame_count * 1000 * 1000000) / stream->duration;
|
stream->frames_per_sec_rate = (stream->frame_count * 1000 * 1000000) / stream->duration;
|
||||||
stream->frames_per_sec_scale = 1000;
|
stream->frames_per_sec_scale = 1000;
|
||||||
printf("audio: using micro_sec_per_frame\n");
|
TRACE("audio: using micro_sec_per_frame\n");
|
||||||
} else {
|
} else {
|
||||||
printf("audio: no idea what to do\n");
|
TRACE("audio: no idea what to do\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stream->audio_format->avg_bytes_per_sec) {
|
if (stream->audio_format->avg_bytes_per_sec) {
|
||||||
int64 expected_frame_count = (stream->duration * stream->audio_format->avg_bytes_per_sec) / 1000000;
|
int64 expectedFrameCount
|
||||||
printf("audio: expected frame_count %lld, calculated stream frame_count %lld\n", expected_frame_count, stream->frame_count);
|
= (stream->duration * stream->audio_format->avg_bytes_per_sec)
|
||||||
if (expected_frame_count * 9 > stream->frame_count * 10) {
|
/ 1000000;
|
||||||
printf("audio: something is wrong, ignoring calculated stream frame_count, rate and scale\n");
|
TRACE("audio: expected frame_count %lld, calculated stream "
|
||||||
stream->frame_count = expected_frame_count;
|
"frame_count %lld\n", expectedFrameCount, stream->frame_count);
|
||||||
stream->frames_per_sec_rate = stream->audio_format->avg_bytes_per_sec;
|
if (expectedFrameCount * 9 > stream->frame_count * 10) {
|
||||||
|
TRACE("audio: something is wrong, ignoring calculated stream "
|
||||||
|
"frame_count, rate and scale\n");
|
||||||
|
stream->frame_count = expectedFrameCount;
|
||||||
|
stream->frames_per_sec_rate
|
||||||
|
= stream->audio_format->avg_bytes_per_sec;
|
||||||
stream->frames_per_sec_scale = 1;
|
stream->frames_per_sec_scale = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("audio: frame_count %lld, duration %.6f, fps %.3f\n",
|
TRACE("audio: frame_count %lld, duration %.6f, fps %.3f\n",
|
||||||
stream->frame_count, stream->duration / 1E6, stream->frames_per_sec_rate / (double)stream->frames_per_sec_scale);
|
stream->frame_count, stream->duration / 1E6,
|
||||||
|
stream->frames_per_sec_rate / (double)stream->frames_per_sec_scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -242,20 +252,22 @@ OpenDMLParser::SetupVideoStreamLength(stream_info *stream)
|
|||||||
if (stream->stream_header.rate && stream->stream_header.scale) {
|
if (stream->stream_header.rate && stream->stream_header.scale) {
|
||||||
stream->frames_per_sec_rate = stream->stream_header.rate;
|
stream->frames_per_sec_rate = stream->stream_header.rate;
|
||||||
stream->frames_per_sec_scale = stream->stream_header.scale;
|
stream->frames_per_sec_scale = stream->stream_header.scale;
|
||||||
printf("video: using rate+scale\n");
|
TRACE("video: using rate+scale\n");
|
||||||
} else if (AviMainHeader()->micro_sec_per_frame) {
|
} else if (AviMainHeader()->micro_sec_per_frame) {
|
||||||
stream->frames_per_sec_rate = 1000000;
|
stream->frames_per_sec_rate = 1000000;
|
||||||
stream->frames_per_sec_scale = AviMainHeader()->micro_sec_per_frame;
|
stream->frames_per_sec_scale = AviMainHeader()->micro_sec_per_frame;
|
||||||
printf("video: using micro_sec_per_frame\n");
|
TRACE("video: using micro_sec_per_frame\n");
|
||||||
} else {
|
} else {
|
||||||
stream->frames_per_sec_rate = 25;
|
stream->frames_per_sec_rate = 25;
|
||||||
stream->frames_per_sec_scale = 1;
|
stream->frames_per_sec_scale = 1;
|
||||||
printf("video: using fallback\n");
|
TRACE("video: using fallback\n");
|
||||||
}
|
}
|
||||||
stream->duration = (stream->frame_count * stream->frames_per_sec_scale * 1000000) / stream->frames_per_sec_rate;
|
stream->duration = (stream->frame_count * stream->frames_per_sec_scale
|
||||||
|
* 1000000) / stream->frames_per_sec_rate;
|
||||||
|
|
||||||
printf("video: frame_count %lld, duration %.6f, fps %.3f\n",
|
TRACE("video: frame_count %lld, duration %.6f, fps %.3f\n",
|
||||||
stream->frame_count, stream->duration / 1E6, stream->frames_per_sec_rate / (double)stream->frames_per_sec_scale);
|
stream->frame_count, stream->duration / 1E6,
|
||||||
|
stream->frames_per_sec_rate / (double)stream->frames_per_sec_scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
|
|||||||
@@ -33,6 +33,16 @@
|
|||||||
#include <StopWatch.h>
|
#include <StopWatch.h>
|
||||||
|
|
||||||
|
|
||||||
|
//#define TRACE_ODML_PARSER
|
||||||
|
#ifdef TRACE_ODML_PARSER
|
||||||
|
#define TRACE printf
|
||||||
|
#else
|
||||||
|
#define TRACE(a...)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define ERROR(a...) fprintf(stderr, a)
|
||||||
|
|
||||||
|
|
||||||
StandardIndex::StandardIndex(BPositionIO *source, OpenDMLParser *parser)
|
StandardIndex::StandardIndex(BPositionIO *source, OpenDMLParser *parser)
|
||||||
: Index(source, parser)
|
: Index(source, parser)
|
||||||
, fIndex(NULL)
|
, fIndex(NULL)
|
||||||
@@ -64,13 +74,15 @@ StandardIndex::Init()
|
|||||||
uint32 seekHintsStride = 1800 * fStreamCount;
|
uint32 seekHintsStride = 1800 * fStreamCount;
|
||||||
uint32 seekHintsMax = fIndexSize / seekHintsStride;
|
uint32 seekHintsMax = fIndexSize / seekHintsStride;
|
||||||
|
|
||||||
printf("StandardIndex::Init: seekHintsStride %lu\n", seekHintsStride);
|
TRACE("StandardIndex::Init: seekHintsStride %lu\n", seekHintsStride);
|
||||||
printf("StandardIndex::Init: seekHintsMax %lu\n", seekHintsMax);
|
TRACE("StandardIndex::Init: seekHintsMax %lu\n", seekHintsMax);
|
||||||
|
|
||||||
{ BStopWatch w("StandardIndex::Init: malloc");
|
#ifdef TRACE_ODML_PARSER
|
||||||
|
{ BStopWatch w("StandardIndex::Init: malloc");
|
||||||
|
#endif
|
||||||
|
|
||||||
if (indexBytes > 0x1900000) { // 25 MB
|
if (indexBytes > 0x1900000) { // 25 MB
|
||||||
printf("StandardIndex::Init index is way too big\n");
|
ERROR("libOpenDML: StandardIndex::Init index is way too big\n");
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,21 +93,25 @@ StandardIndex::Init()
|
|||||||
|
|
||||||
fIndex = new (std::nothrow) avi_standard_index_entry[fIndexSize];
|
fIndex = new (std::nothrow) avi_standard_index_entry[fIndexSize];
|
||||||
if (fIndex == NULL) {
|
if (fIndex == NULL) {
|
||||||
printf("StandardIndex::Init out of memory\n");
|
ERROR("libOpenDML: StandardIndex::Init out of memory\n");
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
#ifdef TRACE_ODML_PARSER
|
||||||
}
|
}
|
||||||
{ BStopWatch w("StandardIndex::Init: file read");
|
{ BStopWatch w("StandardIndex::Init: file read");
|
||||||
|
#endif
|
||||||
|
|
||||||
if (indexBytes != fSource->ReadAt(fParser->StandardIndexStart(), fIndex, indexBytes)) {
|
if ((int32)indexBytes != fSource->ReadAt(fParser->StandardIndexStart(),
|
||||||
printf("StandardIndex::Init file reading failed\n");
|
fIndex, indexBytes)) {
|
||||||
|
ERROR("libOpenDML: StandardIndex::Init file reading failed\n");
|
||||||
delete [] fIndex;
|
delete [] fIndex;
|
||||||
fIndex = NULL;
|
fIndex = NULL;
|
||||||
return B_IO_ERROR;
|
return B_IO_ERROR;
|
||||||
}
|
}
|
||||||
|
#ifdef TRACE_ODML_PARSER
|
||||||
}
|
}
|
||||||
|
|
||||||
//DumpIndex();
|
//DumpIndex();
|
||||||
|
#endif
|
||||||
|
|
||||||
fStreamData = new stream_data[fStreamCount];
|
fStreamData = new stream_data[fStreamCount];
|
||||||
for (int i = 0; i < fStreamCount; i++) {
|
for (int i = 0; i < fStreamCount; i++) {
|
||||||
@@ -109,16 +125,18 @@ StandardIndex::Init()
|
|||||||
fStreamData[i].seek_hints_next = seekHintsStride;
|
fStreamData[i].seek_hints_next = seekHintsStride;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef TRACE_ODML_PARSER
|
||||||
{ BStopWatch w("StandardIndex::Init: scan index");
|
{ BStopWatch w("StandardIndex::Init: scan index");
|
||||||
|
#endif
|
||||||
|
|
||||||
for (int stream = 0; stream < fStreamCount; stream++) {
|
for (int stream = 0; stream < fStreamCount; stream++) {
|
||||||
uint32 chunk_id = fStreamData[stream].chunk_id;
|
uint32 chunk_id = fStreamData[stream].chunk_id;
|
||||||
uint64 stream_size = 0;
|
uint64 stream_size = 0;
|
||||||
uint32 chunk_count = 0;
|
uint32 chunk_count = 0;
|
||||||
uint32 keyframe_count = 0;
|
uint32 keyframe_count = 0;
|
||||||
int seek_hints_next = seekHintsStride;
|
uint32 seek_hints_next = seekHintsStride;
|
||||||
int seek_hints_count = 0;
|
uint32 seek_hints_count = 0;
|
||||||
for (int i = 0; i < fIndexSize; i++) {
|
for (uint32 i = 0; i < fIndexSize; i++) {
|
||||||
if ((fIndex[i].chunk_id & 0xffff) == chunk_id) {
|
if ((fIndex[i].chunk_id & 0xffff) == chunk_id) {
|
||||||
stream_size += fIndex[i].chunk_length;
|
stream_size += fIndex[i].chunk_length;
|
||||||
chunk_count++;
|
chunk_count++;
|
||||||
@@ -126,7 +144,8 @@ StandardIndex::Init()
|
|||||||
|
|
||||||
if (i >= seek_hints_next) {
|
if (i >= seek_hints_next) {
|
||||||
seek_hints_next = i + seekHintsStride;
|
seek_hints_next = i + seekHintsStride;
|
||||||
seek_hint *hint = &fStreamData[stream].seek_hints[seek_hints_count++];
|
seek_hint *hint = &fStreamData[stream].seek_hints[
|
||||||
|
seek_hints_count++];
|
||||||
hint->stream_pos = fIndex[i].chunk_offset;
|
hint->stream_pos = fIndex[i].chunk_offset;
|
||||||
hint->index_pos = i;
|
hint->index_pos = i;
|
||||||
}
|
}
|
||||||
@@ -137,19 +156,23 @@ StandardIndex::Init()
|
|||||||
fStreamData[stream].keyframe_count = keyframe_count;
|
fStreamData[stream].keyframe_count = keyframe_count;
|
||||||
fStreamData[stream].seek_hints_count = seek_hints_count;
|
fStreamData[stream].seek_hints_count = seek_hints_count;
|
||||||
}
|
}
|
||||||
|
#ifdef TRACE_ODML_PARSER
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < fStreamCount; i++) {
|
for (int i = 0; i < fStreamCount; i++) {
|
||||||
printf("stream %d, stream_size %llu\n", i, fStreamData[i].stream_size);
|
printf("stream %d, stream_size %llu\n", i, fStreamData[i].stream_size);
|
||||||
printf("stream %d, chunk_count %lu\n", i, fStreamData[i].chunk_count);
|
printf("stream %d, chunk_count %lu\n", i, fStreamData[i].chunk_count);
|
||||||
printf("stream %d, keyframe_count %lu\n", i, fStreamData[i].keyframe_count);
|
printf("stream %d, keyframe_count %lu\n", i,
|
||||||
printf("stream %d, seek_hints_count %lu\n", i, fStreamData[i].seek_hints_count);
|
fStreamData[i].keyframe_count);
|
||||||
|
printf("stream %d, seek_hints_count %lu\n", i,
|
||||||
|
fStreamData[i].seek_hints_count);
|
||||||
for (int j = 0; j < fStreamData[i].seek_hints_count; j++) {
|
for (int j = 0; j < fStreamData[i].seek_hints_count; j++) {
|
||||||
printf(" seek_hint %3d, index_pos %6lu, stream_pos %lld\n", j,
|
printf(" seek_hint %3d, index_pos %6lu, stream_pos %lld\n", j,
|
||||||
fStreamData[i].seek_hints[j].index_pos,
|
fStreamData[i].seek_hints[j].index_pos,
|
||||||
fStreamData[i].seek_hints[j].stream_pos);
|
fStreamData[i].seek_hints[j].stream_pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // TRACE_ODML_PARSER
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@@ -162,8 +185,8 @@ StandardIndex::DumpIndex()
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
|
||||||
printf("StandardIndex::DumpIndex %u entries\n", fIndexSize);
|
printf("StandardIndex::DumpIndex %lu entries\n", fIndexSize);
|
||||||
for (int i = 0; i < fIndexSize; i++) {
|
for (uint32 i = 0; i < fIndexSize; i++) {
|
||||||
count++;
|
count++;
|
||||||
if (chunk != fIndex[i].chunk_id) {
|
if (chunk != fIndex[i].chunk_id) {
|
||||||
printf("%3d %c%c%c%c", count, FOURCC_PARAM(chunk));
|
printf("%3d %c%c%c%c", count, FOURCC_PARAM(chunk));
|
||||||
@@ -180,13 +203,15 @@ StandardIndex::DumpIndex()
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
StandardIndex::GetNextChunkInfo(int stream_index, int64 *start, uint32 *size, bool *keyframe)
|
StandardIndex::GetNextChunkInfo(int stream_index, int64 *start, uint32 *size,
|
||||||
|
bool *keyframe)
|
||||||
{
|
{
|
||||||
stream_data *data = &fStreamData[stream_index];
|
stream_data *data = &fStreamData[stream_index];
|
||||||
while (data->stream_pos < fIndexSize) {
|
while (data->stream_pos < fIndexSize) {
|
||||||
if ((fIndex[data->stream_pos].chunk_id & 0xffff) == data->chunk_id) {
|
if ((fIndex[data->stream_pos].chunk_id & 0xffff) == data->chunk_id) {
|
||||||
*keyframe = fIndex[data->stream_pos].flags & AVIIF_KEYFRAME;
|
*keyframe = fIndex[data->stream_pos].flags & AVIIF_KEYFRAME;
|
||||||
*start = fDataOffset + fIndex[data->stream_pos].chunk_offset + 8; // skip 8 bytes (chunk id + chunk size)
|
*start = fDataOffset + fIndex[data->stream_pos].chunk_offset + 8;
|
||||||
|
// skip 8 bytes (chunk id + chunk size)
|
||||||
*size = fIndex[data->stream_pos].chunk_length;
|
*size = fIndex[data->stream_pos].chunk_length;
|
||||||
data->stream_pos++;
|
data->stream_pos++;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -199,14 +224,17 @@ StandardIndex::GetNextChunkInfo(int stream_index, int64 *start, uint32 *size, bo
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
StandardIndex::Seek(int stream_index, uint32 seekTo, int64 *frame, bigtime_t *time)
|
StandardIndex::Seek(int stream_index, uint32 seekTo, int64 *frame,
|
||||||
|
bigtime_t *time)
|
||||||
{
|
{
|
||||||
printf("StandardIndex::Seek: stream %d, seekTo%s%s%s%s, time %Ld, frame %Ld\n",
|
TRACE("StandardIndex::Seek: stream %d, seekTo%s%s%s%s, time %Ld, "
|
||||||
stream_index,
|
"frame %Ld\n", stream_index,
|
||||||
(seekTo & B_MEDIA_SEEK_TO_TIME) ? " B_MEDIA_SEEK_TO_TIME" : "",
|
(seekTo & B_MEDIA_SEEK_TO_TIME) ? " B_MEDIA_SEEK_TO_TIME" : "",
|
||||||
(seekTo & B_MEDIA_SEEK_TO_FRAME) ? " B_MEDIA_SEEK_TO_FRAME" : "",
|
(seekTo & B_MEDIA_SEEK_TO_FRAME) ? " B_MEDIA_SEEK_TO_FRAME" : "",
|
||||||
(seekTo & B_MEDIA_SEEK_CLOSEST_FORWARD) ? " B_MEDIA_SEEK_CLOSEST_FORWARD" : "",
|
(seekTo & B_MEDIA_SEEK_CLOSEST_FORWARD) ?
|
||||||
(seekTo & B_MEDIA_SEEK_CLOSEST_BACKWARD) ? " B_MEDIA_SEEK_CLOSEST_BACKWARD" : "",
|
" B_MEDIA_SEEK_CLOSEST_FORWARD" : "",
|
||||||
|
(seekTo & B_MEDIA_SEEK_CLOSEST_BACKWARD) ?
|
||||||
|
" B_MEDIA_SEEK_CLOSEST_BACKWARD" : "",
|
||||||
*time, *frame);
|
*time, *frame);
|
||||||
|
|
||||||
const stream_info *stream = fParser->StreamInfo(stream_index);
|
const stream_info *stream = fParser->StreamInfo(stream_index);
|
||||||
@@ -215,14 +243,15 @@ StandardIndex::Seek(int stream_index, uint32 seekTo, int64 *frame, bigtime_t *ti
|
|||||||
int64 frame_pos;
|
int64 frame_pos;
|
||||||
if (seekTo & B_MEDIA_SEEK_TO_FRAME)
|
if (seekTo & B_MEDIA_SEEK_TO_FRAME)
|
||||||
frame_pos = *frame;
|
frame_pos = *frame;
|
||||||
else if (seekTo & B_MEDIA_SEEK_TO_TIME)
|
else if (seekTo & B_MEDIA_SEEK_TO_TIME) {
|
||||||
frame_pos = (*time * stream->frames_per_sec_rate) / (1000000 * stream->frames_per_sec_scale);
|
frame_pos = (*time * stream->frames_per_sec_rate)
|
||||||
else
|
/ (1000000 * stream->frames_per_sec_scale);
|
||||||
|
} else
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
if (stream->is_audio) {
|
if (stream->is_audio) {
|
||||||
int64 bytes = 0;
|
int64 bytes = 0;
|
||||||
for (int i = 0; i < fIndexSize; i++) {
|
for (uint32 i = 0; i < fIndexSize; i++) {
|
||||||
if ((fIndex[i].chunk_id & 0xffff) == data->chunk_id) {
|
if ((fIndex[i].chunk_id & 0xffff) == data->chunk_id) {
|
||||||
int64 bytesNext = bytes + fIndex[i].chunk_length;
|
int64 bytesNext = bytes + fIndex[i].chunk_length;
|
||||||
if (bytes <= frame_pos && bytesNext > frame_pos) {
|
if (bytes <= frame_pos && bytesNext > frame_pos) {
|
||||||
@@ -234,7 +263,7 @@ StandardIndex::Seek(int stream_index, uint32 seekTo, int64 *frame, bigtime_t *ti
|
|||||||
}
|
}
|
||||||
} else if (stream->is_video) {
|
} else if (stream->is_video) {
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
for (int i = 0; i < fIndexSize; i++) {
|
for (uint32 i = 0; i < fIndexSize; i++) {
|
||||||
if ((fIndex[i].chunk_id & 0xffff) == data->chunk_id) {
|
if ((fIndex[i].chunk_id & 0xffff) == data->chunk_id) {
|
||||||
if (pos == frame_pos) {
|
if (pos == frame_pos) {
|
||||||
data->stream_pos = i;
|
data->stream_pos = i;
|
||||||
@@ -247,11 +276,11 @@ StandardIndex::Seek(int stream_index, uint32 seekTo, int64 *frame, bigtime_t *ti
|
|||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("seek failed, position not found\n");
|
ERROR("libOpenDML: seek failed, position not found\n");
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
done:
|
done:
|
||||||
printf("seek done: index: pos %d, size %d\n", data->stream_pos, fIndexSize);
|
TRACE("seek done: index: pos %d, size %d\n", data->stream_pos, fIndexSize);
|
||||||
*frame = frame_pos;
|
*frame = frame_pos;
|
||||||
*time = (frame_pos * 1000000 * stream->frames_per_sec_scale) / stream->frames_per_sec_rate;
|
*time = (frame_pos * 1000000 * stream->frames_per_sec_scale) / stream->frames_per_sec_rate;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|||||||
Reference in New Issue
Block a user