improved info extraction.. plays as fast as possible in MediaPlayer, not well in nplay
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6524 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
|
|
||||||
static media_format_description
|
static media_format_description
|
||||||
tobias_description()
|
tobias_video_description()
|
||||||
{
|
{
|
||||||
media_format_description description;
|
media_format_description description;
|
||||||
description.family = B_AVI_FORMAT_FAMILY;
|
description.family = B_AVI_FORMAT_FAMILY;
|
||||||
@@ -21,15 +21,15 @@ tobias_description()
|
|||||||
static void
|
static void
|
||||||
init_tobias_media_raw_video_format(media_raw_video_format * output)
|
init_tobias_media_raw_video_format(media_raw_video_format * output)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static media_format
|
static media_format
|
||||||
tobias_encoded_media_format()
|
tobias_video_encoded_media_format()
|
||||||
{
|
{
|
||||||
media_format format;
|
media_format format;
|
||||||
format.type = B_MEDIA_ENCODED_VIDEO;
|
format.type = B_MEDIA_ENCODED_VIDEO;
|
||||||
format.u.encoded_audio.frame_size = sizeof(ogg_packet);
|
|
||||||
init_tobias_media_raw_video_format(&format.u.encoded_video.output);
|
init_tobias_media_raw_video_format(&format.u.encoded_video.output);
|
||||||
return format;
|
return format;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,8 +104,9 @@ OggTobiasStream::GetStreamInfo(int64 *frameCount, bigtime_t *duration,
|
|||||||
void * data = &(packet.packet[1]);
|
void * data = &(packet.packet[1]);
|
||||||
tobias_stream_header * header = (tobias_stream_header *)data;
|
tobias_stream_header * header = (tobias_stream_header *)data;
|
||||||
|
|
||||||
|
if (strcmp(header->streamtype, "video") == 0) {
|
||||||
// get the format for the description
|
// get the format for the description
|
||||||
media_format_description description = tobias_description();
|
media_format_description description = tobias_video_description();
|
||||||
description.u.avi.codec = header->subtype[3] << 24 | header->subtype[2] << 16
|
description.u.avi.codec = header->subtype[3] << 24 | header->subtype[2] << 16
|
||||||
| header->subtype[1] << 8 | header->subtype[0];
|
| header->subtype[1] << 8 | header->subtype[0];
|
||||||
BMediaFormats formats;
|
BMediaFormats formats;
|
||||||
@@ -114,7 +115,7 @@ OggTobiasStream::GetStreamInfo(int64 *frameCount, bigtime_t *duration,
|
|||||||
result = formats.GetFormatFor(description, format);
|
result = formats.GetFormatFor(description, format);
|
||||||
}
|
}
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
*format = tobias_encoded_media_format();
|
*format = tobias_video_encoded_media_format();
|
||||||
// ignore error, allow user to use ReadChunk interface
|
// ignore error, allow user to use ReadChunk interface
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,9 +124,22 @@ OggTobiasStream::GetStreamInfo(int64 *frameCount, bigtime_t *duration,
|
|||||||
strncpy((char*)format->user_data, header->subtype, 4);
|
strncpy((char*)format->user_data, header->subtype, 4);
|
||||||
format->u.encoded_video.frame_size
|
format->u.encoded_video.frame_size
|
||||||
= header->video.width * header->video.height;
|
= header->video.width * header->video.height;
|
||||||
|
format->u.encoded_video.output.field_rate = 10000000.0 / header->time_unit;
|
||||||
|
format->u.encoded_video.output.interlace = 1;
|
||||||
|
format->u.encoded_video.output.first_active = 0;
|
||||||
|
format->u.encoded_video.output.last_active = header->video.height - 1;
|
||||||
|
format->u.encoded_video.output.orientation = B_VIDEO_TOP_LEFT_RIGHT;
|
||||||
|
format->u.encoded_video.output.pixel_width_aspect = 1;
|
||||||
|
format->u.encoded_video.output.pixel_height_aspect = 1;
|
||||||
format->u.encoded_video.output.display.line_width = header->video.width;
|
format->u.encoded_video.output.display.line_width = header->video.width;
|
||||||
format->u.encoded_video.output.display.line_count = header->video.height;
|
format->u.encoded_video.output.display.line_count = header->video.height;
|
||||||
|
format->u.encoded_video.output.display.bytes_per_row = 0;
|
||||||
|
format->u.encoded_video.output.display.pixel_offset = 0;
|
||||||
|
format->u.encoded_video.output.display.line_offset = 0;
|
||||||
|
format->u.encoded_video.output.display.flags = 0;
|
||||||
|
|
||||||
// TODO: wring more info out of the headers
|
// TODO: wring more info out of the headers
|
||||||
|
}
|
||||||
|
|
||||||
// get comment packet
|
// get comment packet
|
||||||
if (GetHeaderPackets().size() < 2) {
|
if (GetHeaderPackets().size() < 2) {
|
||||||
@@ -137,8 +151,9 @@ OggTobiasStream::GetStreamInfo(int64 *frameCount, bigtime_t *duration,
|
|||||||
}
|
}
|
||||||
|
|
||||||
format->SetMetaData((void*)&GetHeaderPackets(),sizeof(GetHeaderPackets()));
|
format->SetMetaData((void*)&GetHeaderPackets(),sizeof(GetHeaderPackets()));
|
||||||
*duration = 80000000;
|
*frameCount = 2000000;
|
||||||
*frameCount = 60000;
|
*duration = *frameCount * format->u.encoded_video.output.field_rate;
|
||||||
|
fMediaFormat = *format;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,5 +168,17 @@ OggTobiasStream::GetNextChunk(void **chunkBuffer, int32 *chunkSize,
|
|||||||
}
|
}
|
||||||
*chunkBuffer = fChunkPacket.packet;
|
*chunkBuffer = fChunkPacket.packet;
|
||||||
*chunkSize = fChunkPacket.bytes;
|
*chunkSize = fChunkPacket.bytes;
|
||||||
|
// bool keyframe = fChunkPacket.packet[0] & (1 << 3); // ??
|
||||||
|
if (mediaHeader->type == B_MEDIA_ENCODED_VIDEO) {
|
||||||
|
mediaHeader->type = fMediaFormat.type;
|
||||||
|
mediaHeader->start_time = fCurrentTime;
|
||||||
|
// mediaHeader->u.encoded_video.field_flags = (keyframe ? B_MEDIA_KEY_FRAME : 0);
|
||||||
|
mediaHeader->u.encoded_video.first_active_line
|
||||||
|
= fMediaFormat.u.encoded_video.output.first_active;
|
||||||
|
mediaHeader->u.encoded_video.line_count
|
||||||
|
= fMediaFormat.u.encoded_video.output.display.line_count;
|
||||||
|
fCurrentFrame++;
|
||||||
|
fCurrentTime = 1000000LL * fCurrentFrame / fMediaFormat.u.encoded_video.output.field_rate;
|
||||||
|
}
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ public:
|
|||||||
virtual status_t GetNextChunk(void **chunkBuffer, int32 *chunkSize,
|
virtual status_t GetNextChunk(void **chunkBuffer, int32 *chunkSize,
|
||||||
media_header *mediaHeader);
|
media_header *mediaHeader);
|
||||||
|
|
||||||
|
private:
|
||||||
|
media_format fMediaFormat;
|
||||||
};
|
};
|
||||||
|
|
||||||
} } // namespace BPrivate::media
|
} } // namespace BPrivate::media
|
||||||
|
|||||||
Reference in New Issue
Block a user