This fixes the bugs that crashed nplay and ColdCut during the Begeistert 13 presentation
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9463 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -52,13 +52,17 @@ public:
|
||||
inline operator int8() { return (int8)data[2]; }
|
||||
inline operator int16() { return (int16)((uint32)data[2] << 8 | (uint32)data[1]); }
|
||||
inline operator int32() { return (int32)((uint32)data[2] << 24 | (uint32)data[1] << 16 | (uint32)data[0] << 8); }
|
||||
inline operator float() { return (int32)((uint32)data[2] << 24 | (uint32)data[1] << 16 | (uint32)data[0] << 8) * (1.0f / 2147483647.0f); }
|
||||
inline operator float() { return (int32)((uint32)data[2] << 16 | (uint32)data[1] << 8 | (uint32)data[0]) * (1.0f / (2147483647.0f / 256)); }
|
||||
// XXX is the line above correct? long version:
|
||||
// inline operator float() { return (int32)((uint32)data[2] << 24 | (uint32)data[1] << 16 | (uint32)data[0] << 8) * (1.0f / 2147483647.0f); }
|
||||
#else
|
||||
inline operator uint8() { return (int32)data[0] + 128; }
|
||||
inline operator int8() { return (int8)data[0]; }
|
||||
inline operator int16() { return (int16)((uint32)data[0] << 8 | (uint32)data[1]); }
|
||||
inline operator int32() { return (int32)((uint32)data[0] << 24 | (uint32)data[1] << 16 | (uint32)data[2] << 8); }
|
||||
inline operator float() { return (int32)((uint32)data[0] << 24 | (uint32)data[1] << 16 | (uint32)data[2] << 8) * (1.0f / 2147483647.0f); }
|
||||
inline operator float() { return (int32)((uint32)data[0] << 16 | (uint32)data[1] << 8 | (uint32)data[2]) * (1.0f / (2147483647.0f / 256)); }
|
||||
// XXX is the line above correct? long version:
|
||||
// inline operator float() { return (int32)((uint32)data[0] << 24 | (uint32)data[1] << 16 | (uint32)data[2] << 8) * (1.0f / 2147483647.0f); }
|
||||
#endif
|
||||
private:
|
||||
uint8 data[3];
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#include "RawDecoderPlugin.h"
|
||||
#include "AudioConversion.h"
|
||||
|
||||
#define TRACE_THIS 0
|
||||
#if TRACE_THIS
|
||||
#define TRACE_DECODER
|
||||
#ifdef TRACE_DECODER
|
||||
#define TRACE printf
|
||||
#else
|
||||
#define TRACE(a...)
|
||||
@@ -98,10 +98,11 @@ RawDecoder::NegotiateOutputFormat(media_format *ioDecodedFormat)
|
||||
// BeBook says: The codec will find and return in ioFormat its best matching format
|
||||
// => This means, we never return an error, and always change the format values
|
||||
// that we don't support to something more applicable
|
||||
if (ioDecodedFormat->type == B_MEDIA_RAW_VIDEO)
|
||||
if (fInputFormat.type == B_MEDIA_RAW_VIDEO)
|
||||
return NegotiateVideoOutputFormat(ioDecodedFormat);
|
||||
if (ioDecodedFormat->type == B_MEDIA_RAW_AUDIO)
|
||||
if (fInputFormat.type == B_MEDIA_RAW_AUDIO)
|
||||
return NegotiateAudioOutputFormat(ioDecodedFormat);
|
||||
debugger("RawDecoder::NegotiateOutputFormat: wrong encoded format type");
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
@@ -159,10 +160,11 @@ RawDecoder::NegotiateAudioOutputFormat(media_format *ioDecodedFormat)
|
||||
break;
|
||||
}
|
||||
|
||||
fFrameRate = (int32) ioDecodedFormat->u.raw_audio.frame_rate;
|
||||
ioDecodedFormat->u.raw_audio.frame_rate = fInputFormat.u.raw_audio.frame_rate;
|
||||
ioDecodedFormat->u.raw_audio.channel_count = fInputFormat.u.raw_audio.channel_count;
|
||||
|
||||
fFrameRate = (int32) ioDecodedFormat->u.raw_audio.frame_rate;
|
||||
|
||||
fOutputSampleSize = (ioDecodedFormat->u.raw_audio.format & B_AUDIO_FORMAT_SIZE_MASK);
|
||||
fOutputFrameSize = fOutputSampleSize * ioDecodedFormat->u.raw_audio.channel_count;
|
||||
|
||||
@@ -412,6 +414,9 @@ RawDecoder::NegotiateAudioOutputFormat(media_format *ioDecodedFormat)
|
||||
|
||||
string_for_format(*ioDecodedFormat, s, sizeof(s));
|
||||
TRACE("RawDecoder::NegotiateAudioOutputFormat leave: %s\n", s);
|
||||
|
||||
if (ioDecodedFormat->type == 0)
|
||||
debugger("RawDecoder::NegotiateAudioOutputFormat ioDecodedFormat->type == 0");
|
||||
/*
|
||||
TRACE("fFrameRate %ld\n", fFrameRate);
|
||||
TRACE("fInputFrameSize %ld\n", fInputFrameSize);
|
||||
|
||||
Reference in New Issue
Block a user