in progress commit
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5710 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
141121d9e9
commit
34aaa850a8
@ -16,22 +16,20 @@
|
|||||||
|
|
||||||
vorbisDecoder::vorbisDecoder()
|
vorbisDecoder::vorbisDecoder()
|
||||||
{
|
{
|
||||||
InitMP3(&fMpgLibPrivate);
|
vorbis_info_init(&fVorbisInfo);
|
||||||
|
|
||||||
fResidualBytes = 0;
|
fResidualBytes = 0;
|
||||||
fResidualBuffer = 0;
|
fResidualBuffer = 0;
|
||||||
fDecodeBuffer = new uint8 [DECODE_BUFFER_SIZE];
|
fDecodeBuffer = new uint8 [DECODE_BUFFER_SIZE];
|
||||||
fStartTime = 0;
|
fStartTime = 0;
|
||||||
fFrameSize = 0;
|
fFrameSize = 0;
|
||||||
fFrameRate = 0;
|
|
||||||
fBitRate = 0;
|
fBitRate = 0;
|
||||||
fChannelCount = 0;
|
|
||||||
fOutputBufferSize = 0;
|
fOutputBufferSize = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
vorbisDecoder::~vorbisDecoder()
|
vorbisDecoder::~vorbisDecoder()
|
||||||
{
|
{
|
||||||
ExitMP3(&fMpgLibPrivate);
|
|
||||||
delete [] fDecodeBuffer;
|
delete [] fDecodeBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,23 +38,18 @@ status_t
|
|||||||
vorbisDecoder::Setup(media_format *ioEncodedFormat,
|
vorbisDecoder::Setup(media_format *ioEncodedFormat,
|
||||||
const void *infoBuffer, int32 infoSize)
|
const void *infoBuffer, int32 infoSize)
|
||||||
{
|
{
|
||||||
// decode first chunk to initialize mpeg library
|
if (ioEncodedFormat->type != B_MEDIA_ENCODED_AUDIO) {
|
||||||
if (B_OK != DecodeNextChunk()) {
|
TRACE("vorbisDecoder::Setup not called with encoded video");
|
||||||
printf("vorbisDecoder::Setup failed, can't decode first chunk\n");
|
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize fBitRate, fFrameRate and fChannelCount from mpg decode library values of first header
|
// save the extractor information for future reference
|
||||||
extern int tabsel_123[2][3][16];
|
fOutput = ioEncodedFormat->u.encoded_audio.output;
|
||||||
extern long freqs[9];
|
fBitRate = ioEncodedFormat->u.encoded_audio.bit_rate;
|
||||||
fBitRate = tabsel_123[fMpgLibPrivate.fr.lsf][fMpgLibPrivate.fr.lay-1][fMpgLibPrivate.fr.bitrate_index] * 1000;
|
fFrameSize = ioEncodedFormat->u.encoded_audio.frame_size;
|
||||||
fFrameRate = freqs[fMpgLibPrivate.fr.sampling_frequency];
|
|
||||||
fChannelCount = fMpgLibPrivate.fr.stereo;
|
|
||||||
|
|
||||||
printf("vorbisDecoder::Setup: channels %d, bitrate %d, framerate %d\n", fChannelCount, fBitRate, fFrameRate);
|
printf("vorbisDecoder::Setup: bitrate %d\n", fBitRate);
|
||||||
|
|
||||||
// put some more useful info into the media_format describing our input format
|
|
||||||
ioEncodedFormat->u.encoded_audio.bit_rate = fBitRate;
|
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@ -75,13 +68,15 @@ vorbisDecoder::NegotiateOutputFormat(media_format *ioDecodedFormat)
|
|||||||
ioDecodedFormat->u.raw_audio.channel_count = fChannelCount;
|
ioDecodedFormat->u.raw_audio.channel_count = fChannelCount;
|
||||||
ioDecodedFormat->u.raw_audio.format = media_raw_audio_format::B_AUDIO_SHORT; // XXX should support other formats, too
|
ioDecodedFormat->u.raw_audio.format = media_raw_audio_format::B_AUDIO_SHORT; // XXX should support other formats, too
|
||||||
ioDecodedFormat->u.raw_audio.byte_order = B_MEDIA_HOST_ENDIAN; // XXX should support other endain, too
|
ioDecodedFormat->u.raw_audio.byte_order = B_MEDIA_HOST_ENDIAN; // XXX should support other endain, too
|
||||||
if (ioDecodedFormat->u.raw_audio.buffer_size < 512 || ioDecodedFormat->u.raw_audio.buffer_size > 65536)
|
if (ioDecodedFormat->u.raw_audio.buffer_size < 512
|
||||||
ioDecodedFormat->u.raw_audio.buffer_size = BMediaRoster::Roster()->AudioBufferSizeFor(
|
|| ioDecodedFormat->u.raw_audio.buffer_size > 65536)
|
||||||
fChannelCount,
|
ioDecodedFormat->u.raw_audio.buffer_size
|
||||||
ioDecodedFormat->u.raw_audio.format,
|
= BMediaRoster::Roster()->AudioBufferSizeFor(fChannelCount,
|
||||||
fFrameRate);
|
ioDecodedFormat->u.raw_audio.format,
|
||||||
|
fFrameRate);
|
||||||
if (ioDecodedFormat->u.raw_audio.channel_mask == 0)
|
if (ioDecodedFormat->u.raw_audio.channel_mask == 0)
|
||||||
ioDecodedFormat->u.raw_audio.channel_mask = (fChannelCount == 1) ? B_CHANNEL_LEFT : B_CHANNEL_LEFT | B_CHANNEL_RIGHT;
|
ioDecodedFormat->u.raw_audio.channel_mask
|
||||||
|
= (fChannelCount == 1) ? B_CHANNEL_LEFT : B_CHANNEL_LEFT | B_CHANNEL_RIGHT;
|
||||||
|
|
||||||
// setup rest of the needed variables
|
// setup rest of the needed variables
|
||||||
fFrameSize = (ioDecodedFormat->u.raw_audio.format & 0xf) * fChannelCount;
|
fFrameSize = (ioDecodedFormat->u.raw_audio.format & 0xf) * fChannelCount;
|
||||||
@ -175,12 +170,10 @@ vorbisDecoderPlugin::NewDecoder()
|
|||||||
{
|
{
|
||||||
static BLocker locker;
|
static BLocker locker;
|
||||||
static bool initdone = false;
|
static bool initdone = false;
|
||||||
locker.Lock();
|
BAutolock lock(locker);
|
||||||
if (!initdone) {
|
if (!initdone) {
|
||||||
InitMpgLib();
|
|
||||||
initdone = true;
|
initdone = true;
|
||||||
}
|
}
|
||||||
locker.Unlock();
|
|
||||||
return new vorbisDecoder;
|
return new vorbisDecoder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,15 +181,7 @@ vorbisDecoderPlugin::NewDecoder()
|
|||||||
status_t
|
status_t
|
||||||
vorbisDecoderPlugin::RegisterPlugin()
|
vorbisDecoderPlugin::RegisterPlugin()
|
||||||
{
|
{
|
||||||
PublishDecoder("audiocodec/mpeg1layer1", "mp3", "MPEG 1 audio layer 1 decoder, based on mpeg123 mpglib");
|
PublishDecoder("audiocodec/vorbis", "vorbis", "vorbis decoder, based on libvorbis");
|
||||||
PublishDecoder("audiocodec/mpeg1layer2", "mp3", "MPEG 1 audio layer 2 decoder, based on mpeg123 mpglib");
|
|
||||||
PublishDecoder("audiocodec/mpeg1layer3", "mp3", "MPEG 1 audio layer 3 decoder, based on mpeg123 mpglib");
|
|
||||||
PublishDecoder("audiocodec/mpeg2layer1", "mp3", "MPEG 2 audio layer 1 decoder, based on mpeg123 mpglib");
|
|
||||||
PublishDecoder("audiocodec/mpeg2layer2", "mp3", "MPEG 2 audio layer 2 decoder, based on mpeg123 mpglib");
|
|
||||||
PublishDecoder("audiocodec/mpeg2layer3", "mp3", "MPEG 2 audio layer 3 decoder, based on mpeg123 mpglib");
|
|
||||||
PublishDecoder("audiocodec/mpeg2.5layer1", "mp3", "MPEG 2.5 audio layer 1 decoder, based on mpeg123 mpglib");
|
|
||||||
PublishDecoder("audiocodec/mpeg2.5layer2", "mp3", "MPEG 2.5 audio layer 2 decoder, based on mpeg123 mpglib");
|
|
||||||
PublishDecoder("audiocodec/mpeg2.5layer3", "mp3", "MPEG 2.5 audio layer 3 decoder, based on mpeg123 mpglib");
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,15 +24,15 @@ public:
|
|||||||
status_t DecodeNextChunk();
|
status_t DecodeNextChunk();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct mpstr fMpgLibPrivate;
|
struct vorbis_dsp_state fVorbisDspState;
|
||||||
|
struct vorbis_info fVorbisInfo;
|
||||||
|
struct media_raw_video_format fOutput;
|
||||||
int32 fResidualBytes;
|
int32 fResidualBytes;
|
||||||
uint8 * fResidualBuffer;
|
uint8 * fResidualBuffer;
|
||||||
uint8 * fDecodeBuffer;
|
uint8 * fDecodeBuffer;
|
||||||
bigtime_t fStartTime;
|
bigtime_t fStartTime;
|
||||||
int fFrameSize;
|
int fFrameSize;
|
||||||
int fFrameRate;
|
|
||||||
int fBitRate;
|
int fBitRate;
|
||||||
int fChannelCount;
|
|
||||||
int fOutputBufferSize;
|
int fOutputBufferSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -243,8 +243,8 @@ xvidDecoderPlugin::NewDecoder()
|
|||||||
TRACE("xvidDecoder: xvid API_VERSION mismatch\n");
|
TRACE("xvidDecoder: xvid API_VERSION mismatch\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
initdone = true;
|
||||||
}
|
}
|
||||||
initdone = true;
|
|
||||||
return new xvidDecoder;
|
return new xvidDecoder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user