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 int8() { return (int8)data[2]; }
|
||||||
inline operator int16() { return (int16)((uint32)data[2] << 8 | (uint32)data[1]); }
|
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 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
|
#else
|
||||||
inline operator uint8() { return (int32)data[0] + 128; }
|
inline operator uint8() { return (int32)data[0] + 128; }
|
||||||
inline operator int8() { return (int8)data[0]; }
|
inline operator int8() { return (int8)data[0]; }
|
||||||
inline operator int16() { return (int16)((uint32)data[0] << 8 | (uint32)data[1]); }
|
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 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
|
#endif
|
||||||
private:
|
private:
|
||||||
uint8 data[3];
|
uint8 data[3];
|
||||||
|
|||||||
@@ -7,8 +7,8 @@
|
|||||||
#include "RawDecoderPlugin.h"
|
#include "RawDecoderPlugin.h"
|
||||||
#include "AudioConversion.h"
|
#include "AudioConversion.h"
|
||||||
|
|
||||||
#define TRACE_THIS 0
|
#define TRACE_DECODER
|
||||||
#if TRACE_THIS
|
#ifdef TRACE_DECODER
|
||||||
#define TRACE printf
|
#define TRACE printf
|
||||||
#else
|
#else
|
||||||
#define TRACE(a...)
|
#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
|
// 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
|
// => This means, we never return an error, and always change the format values
|
||||||
// that we don't support to something more applicable
|
// 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);
|
return NegotiateVideoOutputFormat(ioDecodedFormat);
|
||||||
if (ioDecodedFormat->type == B_MEDIA_RAW_AUDIO)
|
if (fInputFormat.type == B_MEDIA_RAW_AUDIO)
|
||||||
return NegotiateAudioOutputFormat(ioDecodedFormat);
|
return NegotiateAudioOutputFormat(ioDecodedFormat);
|
||||||
|
debugger("RawDecoder::NegotiateOutputFormat: wrong encoded format type");
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,10 +160,11 @@ RawDecoder::NegotiateAudioOutputFormat(media_format *ioDecodedFormat)
|
|||||||
break;
|
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.frame_rate = fInputFormat.u.raw_audio.frame_rate;
|
||||||
ioDecodedFormat->u.raw_audio.channel_count = fInputFormat.u.raw_audio.channel_count;
|
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);
|
fOutputSampleSize = (ioDecodedFormat->u.raw_audio.format & B_AUDIO_FORMAT_SIZE_MASK);
|
||||||
fOutputFrameSize = fOutputSampleSize * ioDecodedFormat->u.raw_audio.channel_count;
|
fOutputFrameSize = fOutputSampleSize * ioDecodedFormat->u.raw_audio.channel_count;
|
||||||
|
|
||||||
@@ -412,6 +414,9 @@ RawDecoder::NegotiateAudioOutputFormat(media_format *ioDecodedFormat)
|
|||||||
|
|
||||||
string_for_format(*ioDecodedFormat, s, sizeof(s));
|
string_for_format(*ioDecodedFormat, s, sizeof(s));
|
||||||
TRACE("RawDecoder::NegotiateAudioOutputFormat leave: %s\n", s);
|
TRACE("RawDecoder::NegotiateAudioOutputFormat leave: %s\n", s);
|
||||||
|
|
||||||
|
if (ioDecodedFormat->type == 0)
|
||||||
|
debugger("RawDecoder::NegotiateAudioOutputFormat ioDecodedFormat->type == 0");
|
||||||
/*
|
/*
|
||||||
TRACE("fFrameRate %ld\n", fFrameRate);
|
TRACE("fFrameRate %ld\n", fFrameRate);
|
||||||
TRACE("fInputFrameSize %ld\n", fInputFrameSize);
|
TRACE("fInputFrameSize %ld\n", fInputFrameSize);
|
||||||
|
|||||||
Reference in New Issue
Block a user