set user data to contain codec id

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25519 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
David McPaul 2008-05-16 02:29:10 +00:00
parent 4c1f76cbf4
commit fa9257456d
4 changed files with 35 additions and 15 deletions

View File

@ -817,7 +817,6 @@ void STSDAtom::ReadSoundDescription()
Read(&aSoundDescriptionV1->desc.SampleRate);
if ((aSoundDescriptionV1->desc.Version == 1) && (aSoundDescriptionV1->basefields.DataFormat != AUDIO_IMA4)) {
printf("V1 Sound Description Found\n");
Read(&(aSoundDescriptionV1->samplesPerPacket));
Read(&(aSoundDescriptionV1->bytesPerPacket));
Read(&(aSoundDescriptionV1->bytesPerFrame));
@ -826,14 +825,12 @@ void STSDAtom::ReadSoundDescription()
} else {
// Calculate?
if (aSoundDescriptionV1->basefields.DataFormat == AUDIO_IMA4) {
printf("Calculating IMA4 Sound Description\n");
aSoundDescriptionV1->samplesPerPacket = 64;
aSoundDescriptionV1->bytesPerFrame = aSoundDescriptionV1->desc.NoOfChannels * 34;
aSoundDescriptionV1->bytesPerSample = aSoundDescriptionV1->desc.SampleSize / 8;
aSoundDescriptionV1->bytesPerPacket = 64 * aSoundDescriptionV1->bytesPerFrame;
} else {
printf("Calculating Sound Description\n");
aSoundDescriptionV1->bytesPerSample = aSoundDescriptionV1->desc.SampleSize / 8;
aSoundDescriptionV1->bytesPerFrame = aSoundDescriptionV1->desc.NoOfChannels * aSoundDescriptionV1->bytesPerSample;
aSoundDescriptionV1->bytesPerPacket = aSoundDescriptionV1->desc.PacketSize;

View File

@ -34,7 +34,7 @@
#include "mov_reader.h"
#define TRACE_MOV_READER
//#define TRACE_MOV_READER
#ifdef TRACE_MOV_READER
#define TRACE printf
#else
@ -85,7 +85,7 @@ movReader::~movReader()
const char *
movReader::Copyright()
{
return "QUICKTIME & libMOV, " B_UTF8_COPYRIGHT " by David McPaul";
return "mov_reader & libMOV, " B_UTF8_COPYRIGHT " by David McPaul";
}
status_t
@ -331,6 +331,12 @@ movReader::AllocateCookie(int32 streamNumber, void **_cookie)
format->SetMetaData(data, size);
}
if (codecID != 0) {
// Put the codeid in the user data in case someone wants it
format->user_data_type = B_CODEC_TYPE_INFO;
*(uint32 *)format->user_data = codecID; format->user_data[4] = 0;
}
return B_OK;
}
@ -406,6 +412,12 @@ movReader::AllocateCookie(int32 streamNumber, void **_cookie)
format->SetMetaData(data, size);
}
if (codecID != 0) {
// Put the codeid in the user data in case someone wants it
format->user_data_type = B_CODEC_TYPE_INFO;
*(uint32 *)format->user_data = codecID; format->user_data[4] = 0;
}
return B_OK;
}

View File

@ -1182,8 +1182,8 @@ char *WAVEAtom::OnGetAtomName()
void WAVEAtom::OnOverrideAudioDescription(AudioDescription *pAudioDescription)
{
pAudioDescription->codecSubType = 'alac';
pAudioDescription->FrameSize = 4096;
pAudioDescription->codecSubType = 'mp3';
pAudioDescription->FrameSize = 0;
}
void WAVEAtom::OnOverrideVideoDescription(VideoDescription *pVideoDescription)

View File

@ -89,7 +89,7 @@ mp4Reader::~mp4Reader()
const char *
mp4Reader::Copyright()
{
return "MPEG4 & libMP4, " B_UTF8_COPYRIGHT " by David McPaul";
return "mp4_reader & libMP4, " B_UTF8_COPYRIGHT " by David McPaul";
}
@ -143,6 +143,8 @@ mp4Reader::GetFileFormatInfo(media_file_format *mff)
status_t
mp4Reader::AllocateCookie(int32 streamNumber, void **_cookie)
{
uint32 codecID = 0;
size_t size;
const void *data;
@ -181,6 +183,7 @@ mp4Reader::AllocateCookie(int32 streamNumber, void **_cookie)
delete cookie;
return B_ERROR;
}
codecID = B_BENDIAN_TO_HOST_INT32(audio_format->compression);
cookie->frame_count = theFileReader->getFrameCount(cookie->stream);
cookie->duration = theFileReader->getAudioDuration(cookie->stream);
@ -289,6 +292,7 @@ mp4Reader::AllocateCookie(int32 streamNumber, void **_cookie)
format->u.encoded_audio.output.channel_count = audio_format->NoOfChannels;
break;
case 'mp4a':
codecID = B_BENDIAN_TO_HOST_INT32('aac ');
case 'alac':
TRACE("AAC audio (mp4a) or ALAC audio\n");
@ -332,10 +336,6 @@ mp4Reader::AllocateCookie(int32 streamNumber, void **_cookie)
}
}
// this doesn't seem to work (it's not even a fourcc)
format->user_data_type = B_CODEC_TYPE_INFO;
*(uint32 *)format->user_data = audio_format->compression; format->user_data[4] = 0;
// Set the DecoderConfigSize
size = audio_format->DecoderConfigSize;
data = audio_format->theDecoderConfig;
@ -355,6 +355,12 @@ mp4Reader::AllocateCookie(int32 streamNumber, void **_cookie)
}
#endif
if (codecID != 0) {
// Put the codeid in the user data in case someone wants it
format->user_data_type = B_CODEC_TYPE_INFO;
*(uint32 *)format->user_data = codecID; format->user_data[4] = 0;
}
return B_OK;
}
@ -366,6 +372,8 @@ mp4Reader::AllocateCookie(int32 streamNumber, void **_cookie)
return B_ERROR;
}
codecID = B_BENDIAN_TO_HOST_INT32(video_format->compression);
cookie->audio = false;
cookie->line_count = theFileReader->MovMainHeader()->height;
@ -406,9 +414,6 @@ mp4Reader::AllocateCookie(int32 streamNumber, void **_cookie)
if (B_OK != formats.GetFormatFor(description, format))
format->type = B_MEDIA_ENCODED_VIDEO;
format->user_data_type = B_CODEC_TYPE_INFO;
*(uint32 *)format->user_data = description.u.quicktime.codec; format->user_data[4] = 0;
// format->u.encoded_video.max_bit_rate = 8 * theFileReader->MovMainHeader()->max_bytes_per_sec;
// format->u.encoded_video.avg_bit_rate = format->u.encoded_video.max_bit_rate / 2; // XXX fix this
format->u.encoded_video.output.field_rate = cookie->frames_per_sec_rate / (float)cookie->frames_per_sec_scale;
@ -471,6 +476,12 @@ mp4Reader::AllocateCookie(int32 streamNumber, void **_cookie)
#endif
}
if (codecID != 0) {
// Put the codeid in the user data in case someone wants it
format->user_data_type = B_CODEC_TYPE_INFO;
*(uint32 *)format->user_data = codecID; format->user_data[4] = 0;
}
return B_OK;
}