preparation for aac_decoder

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26912 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
David McPaul
2008-08-10 13:51:39 +00:00
parent 0bdaf02821
commit 1ac79e42f3
@@ -38,7 +38,7 @@
#include <string.h> #include <string.h>
//#define TRACE_MP4_READER #define TRACE_MP4_READER
#ifdef TRACE_MP4_READER #ifdef TRACE_MP4_READER
# define TRACE printf # define TRACE printf
#else #else
@@ -185,7 +185,8 @@ mp4Reader::AllocateCookie(int32 streamNumber, void **_cookie)
} }
codecID = B_BENDIAN_TO_HOST_INT32(audio_format->compression); codecID = B_BENDIAN_TO_HOST_INT32(audio_format->compression);
cookie->frame_count = theFileReader->getFrameCount(cookie->stream); // frame_count is actually sample_count for audio - makes media_player happy but david sad
cookie->frame_count = theFileReader->getFrameCount(cookie->stream) * audio_format->FrameSize;
cookie->duration = theFileReader->getAudioDuration(cookie->stream); cookie->duration = theFileReader->getAudioDuration(cookie->stream);
cookie->audio = true; cookie->audio = true;
@@ -310,7 +311,7 @@ mp4Reader::AllocateCookie(int32 streamNumber, void **_cookie)
// Average BitRate = (TotalBytes * 8 * (SampleRate / FrameSize)) / TotalFrames // Average BitRate = (TotalBytes * 8 * (SampleRate / FrameSize)) / TotalFrames
// Setting a bitrate seems to cause more problems than it solves // Setting a bitrate seems to cause more problems than it solves
format->u.encoded_audio.bit_rate = audio_format->BitRate; // usually 128000 for AAC format->u.encoded_audio.bit_rate = audio_format->BitRate; // Should be 64000 * channelcount
TRACE("Audio NoOfChannels %d, SampleSize %d, SampleRate %f, FrameSize %ld\n",audio_format->NoOfChannels, audio_format->SampleSize, audio_format->SampleRate, audio_format->FrameSize); TRACE("Audio NoOfChannels %d, SampleSize %d, SampleRate %f, FrameSize %ld\n",audio_format->NoOfChannels, audio_format->SampleSize, audio_format->SampleRate, audio_format->FrameSize);
@@ -340,6 +341,7 @@ mp4Reader::AllocateCookie(int32 streamNumber, void **_cookie)
size = audio_format->DecoderConfigSize; size = audio_format->DecoderConfigSize;
data = audio_format->theDecoderConfig; data = audio_format->theDecoderConfig;
if (size > 0) { if (size > 0) {
TRACE("Audio Decoder Config Found Size is %ld\n",size);
if (format->SetMetaData(data, size) != B_OK) { if (format->SetMetaData(data, size) != B_OK) {
ERROR("Failed to set Decoder Config\n"); ERROR("Failed to set Decoder Config\n");
delete cookie; delete cookie;
@@ -460,7 +462,7 @@ mp4Reader::AllocateCookie(int32 streamNumber, void **_cookie)
size = video_format->DecoderConfigSize; size = video_format->DecoderConfigSize;
data = video_format->theDecoderConfig; data = video_format->theDecoderConfig;
if (size > 0) { if (size > 0) {
TRACE("Decoder Config Found Size is %ld\n",size); TRACE("Video Decoder Config Found Size is %ld\n",size);
if (format->SetMetaData(data, size) != B_OK) { if (format->SetMetaData(data, size) != B_OK) {
ERROR("Failed to set Decoder Config\n"); ERROR("Failed to set Decoder Config\n");
delete cookie; delete cookie;
@@ -508,6 +510,7 @@ mp4Reader::GetStreamInfo(void *_cookie, int64 *frameCount, bigtime_t *duration,
{ {
mp4_cookie *cookie = (mp4_cookie *)_cookie; mp4_cookie *cookie = (mp4_cookie *)_cookie;
if (cookie) {
*frameCount = cookie->frame_count; *frameCount = cookie->frame_count;
*duration = cookie->duration; *duration = cookie->duration;
*format = cookie->format; *format = cookie->format;
@@ -517,10 +520,13 @@ mp4Reader::GetStreamInfo(void *_cookie, int64 *frameCount, bigtime_t *duration,
const VideoMetaData *video_format = theFileReader->VideoFormat(cookie->stream); const VideoMetaData *video_format = theFileReader->VideoFormat(cookie->stream);
*infoBuffer = video_format->theDecoderConfig; *infoBuffer = video_format->theDecoderConfig;
*infoSize = video_format->DecoderConfigSize; *infoSize = video_format->DecoderConfigSize;
} else { } else if (theFileReader->IsAudio(cookie->stream)) {
const AudioMetaData *audio_format = theFileReader->AudioFormat(cookie->stream); const AudioMetaData *audio_format = theFileReader->AudioFormat(cookie->stream);
*infoBuffer = audio_format->theDecoderConfig; *infoBuffer = audio_format->theDecoderConfig;
*infoSize = audio_format->DecoderConfigSize; *infoSize = audio_format->DecoderConfigSize;
} else {
printf("No stream Info for stream %d\n",cookie->stream);
}
} }
return B_OK; return B_OK;
} }