* Fixed some coding style issues. David, please take a little more care about
this! git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34408 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -22,6 +22,8 @@
|
|||||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -39,7 +41,8 @@
|
|||||||
|
|
||||||
|
|
||||||
OpenDMLIndex::OpenDMLIndex(BPositionIO *source, OpenDMLParser *parser)
|
OpenDMLIndex::OpenDMLIndex(BPositionIO *source, OpenDMLParser *parser)
|
||||||
: Index(source, parser)
|
:
|
||||||
|
Index(source, parser)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,104 +61,106 @@ OpenDMLIndex::Init()
|
|||||||
bigtime_t pts;
|
bigtime_t pts;
|
||||||
odml_index_header superIndex;
|
odml_index_header superIndex;
|
||||||
const OpenDMLStream *stream;
|
const OpenDMLStream *stream;
|
||||||
|
|
||||||
int64 pos = 0;
|
|
||||||
uint32 bytesRead;
|
|
||||||
|
|
||||||
for (uint32 i=0; i < fStreamCount; i++) {
|
int64 pos = 0;
|
||||||
|
uint32 bytesRead;
|
||||||
|
|
||||||
|
for (int32 i = 0; i < fStreamCount; i++) {
|
||||||
stream = fParser->StreamInfo(i);
|
stream = fParser->StreamInfo(i);
|
||||||
|
|
||||||
pos = stream->odml_index_start;
|
pos = stream->odml_index_start;
|
||||||
bytesRead = sizeof(odml_index_header);
|
bytesRead = sizeof(odml_index_header);
|
||||||
|
|
||||||
if ((int32)bytesRead != fSource->ReadAt(pos, &superIndex, bytesRead)) {
|
if ((int32)bytesRead != fSource->ReadAt(pos, &superIndex, bytesRead)) {
|
||||||
ERROR("libOpenDML: OpenDMLIndex::Init file reading failed to read superindex\n");
|
ERROR("libOpenDML: OpenDMLIndex::Init file reading failed to read "
|
||||||
|
"superindex\n");
|
||||||
return B_IO_ERROR;
|
return B_IO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
pos += bytesRead;
|
pos += bytesRead;
|
||||||
|
|
||||||
pts = 0;
|
pts = 0;
|
||||||
lastFrame = 0;
|
lastFrame = 0;
|
||||||
|
|
||||||
ReadIndex(i, pos, &lastFrame, &pts, &superIndex);
|
ReadIndex(i, pos, &lastFrame, &pts, &superIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
OpenDMLIndex::ReadIndex(uint32 stream_index, int64 pos, uint32 *lastFrame, bigtime_t *pts, odml_index_header *superIndex) {
|
OpenDMLIndex::ReadIndex(uint32 stream_index, int64 pos, uint32 *lastFrame,
|
||||||
|
bigtime_t *pts, odml_index_header *superIndex)
|
||||||
|
{
|
||||||
|
odml_superindex_entry superIndexEntry;
|
||||||
|
const OpenDMLStream *stream = fParser->StreamInfo(stream_index);
|
||||||
|
|
||||||
odml_superindex_entry superIndexEntry;
|
for (uint32 i = 0; i < superIndex->entries_used; i++) {
|
||||||
//odml_field_index_entry fieldIndexEntry;
|
|
||||||
uint32 bytesRead;
|
|
||||||
|
|
||||||
const OpenDMLStream *stream = fParser->StreamInfo(stream_index);
|
|
||||||
|
|
||||||
for (uint32 i=0; i < superIndex->entries_used; i++) {
|
|
||||||
|
|
||||||
if (superIndex->index_type == AVI_INDEX_OF_INDEXES) {
|
if (superIndex->index_type == AVI_INDEX_OF_INDEXES) {
|
||||||
|
ssize_t bytesRead = fSource->ReadAt(pos, &superIndexEntry,
|
||||||
bytesRead = sizeof(odml_superindex_entry);
|
sizeof(odml_superindex_entry));
|
||||||
|
if (bytesRead < 0)
|
||||||
if ((int32)bytesRead != fSource->ReadAt(pos, &superIndexEntry, bytesRead)) {
|
return bytesRead;
|
||||||
ERROR("libOpenDML: OpenDMLIndex::Init file reading failed to read superindex entry\n");
|
if (bytesRead != (ssize_t)sizeof(odml_superindex_entry)) {
|
||||||
|
ERROR("libOpenDML: OpenDMLIndex::Init file reading failed to "
|
||||||
|
"read superindex entry\n");
|
||||||
return B_IO_ERROR;
|
return B_IO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
pos += bytesRead;
|
pos += bytesRead;
|
||||||
|
|
||||||
if (superIndexEntry.start == 0) {
|
if (superIndexEntry.start == 0)
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
if (superIndex->index_sub_type != AVI_INDEX_2FIELD) {
|
||||||
if (superIndex->index_sub_type == AVI_INDEX_2FIELD) {
|
ReadChunkIndex(stream_index, superIndexEntry.start + 8,
|
||||||
} else {
|
lastFrame, pts, stream);
|
||||||
ReadChunkIndex(stream_index, superIndexEntry.start + 8, lastFrame, pts, stream);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
OpenDMLIndex::ReadChunkIndex(uint32 stream_index, int64 pos, uint32 *lastFrame, bigtime_t *pts, const OpenDMLStream *stream) {
|
OpenDMLIndex::ReadChunkIndex(uint32 stream_index, int64 pos, uint32 *lastFrame,
|
||||||
|
bigtime_t *pts, const OpenDMLStream *stream)
|
||||||
odml_index_entry chunkIndexEntry;
|
{
|
||||||
odml_chunk_index_header chunkIndex;
|
odml_index_entry chunkIndexEntry;
|
||||||
uint32 bytesRead;
|
odml_chunk_index_header chunkIndex;
|
||||||
uint32 frameNo;
|
uint32 bytesRead;
|
||||||
bool keyframe;
|
uint32 frameNo;
|
||||||
uint32 sample_size;
|
bool keyframe;
|
||||||
int64 position;
|
uint32 sample_size;
|
||||||
uint32 size;
|
int64 position;
|
||||||
|
uint32 size;
|
||||||
|
|
||||||
bytesRead = sizeof(odml_chunk_index_header);
|
bytesRead = sizeof(odml_chunk_index_header);
|
||||||
|
|
||||||
if ((int32)bytesRead != fSource->ReadAt(pos, &chunkIndex, bytesRead)) {
|
if ((int32)bytesRead != fSource->ReadAt(pos, &chunkIndex, bytesRead)) {
|
||||||
ERROR("libOpenDML: OpenDMLIndex::Init file reading failed to read Chunk Index\n");
|
ERROR("libOpenDML: OpenDMLIndex::Init file reading failed to read Chunk Index\n");
|
||||||
return B_IO_ERROR;
|
return B_IO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
pos += bytesRead;
|
pos += bytesRead;
|
||||||
|
|
||||||
for (uint32 i=0; i<chunkIndex.entries_used; i++) {
|
for (uint32 i=0; i<chunkIndex.entries_used; i++) {
|
||||||
bytesRead = sizeof(odml_index_entry);
|
bytesRead = sizeof(odml_index_entry);
|
||||||
|
|
||||||
if ((int32)bytesRead != fSource->ReadAt(pos, &chunkIndexEntry, bytesRead)) {
|
if ((int32)bytesRead != fSource->ReadAt(pos, &chunkIndexEntry, bytesRead)) {
|
||||||
ERROR("libOpenDML: OpenDMLIndex::Init file reading failed to read Chunk Index Entry\n");
|
ERROR("libOpenDML: OpenDMLIndex::Init file reading failed to read Chunk Index Entry\n");
|
||||||
return B_IO_ERROR;
|
return B_IO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
pos += bytesRead;
|
pos += bytesRead;
|
||||||
|
|
||||||
keyframe = (chunkIndexEntry.size & 0x80000000) ? false : true;
|
keyframe = (chunkIndexEntry.size & 0x80000000) ? false : true;
|
||||||
position = chunkIndex.base_offset + chunkIndexEntry.start - 8;
|
position = chunkIndex.base_offset + chunkIndexEntry.start - 8;
|
||||||
size = chunkIndexEntry.size & 0x7fffffff;
|
size = chunkIndexEntry.size & 0x7fffffff;
|
||||||
frameNo = *lastFrame;
|
frameNo = *lastFrame;
|
||||||
|
|
||||||
if (stream->is_video) {
|
if (stream->is_video) {
|
||||||
// Video is easy enough, it is always 1 frame = 1 index
|
// Video is easy enough, it is always 1 frame = 1 index
|
||||||
*pts = *lastFrame * 1000000LL * stream->frames_per_sec_scale / stream->frames_per_sec_rate;
|
*pts = *lastFrame * 1000000LL * stream->frames_per_sec_scale / stream->frames_per_sec_rate;
|
||||||
@@ -191,10 +196,10 @@ uint32 size;
|
|||||||
*lastFrame += size / stream->stream_header.sample_size;
|
*lastFrame += size / stream->stream_header.sample_size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AddIndex(stream_index, position, size, frameNo, *pts, keyframe);
|
AddIndex(stream_index, position, size, frameNo, *pts, keyframe);
|
||||||
}
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user