From e2de64d6f1beb9e492daf5b886e19933c1fa41dd Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdemultimedia@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- mpeglib/lib/oggvorbis/vorbisDecoder.cpp | 135 ++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 mpeglib/lib/oggvorbis/vorbisDecoder.cpp (limited to 'mpeglib/lib/oggvorbis/vorbisDecoder.cpp') diff --git a/mpeglib/lib/oggvorbis/vorbisDecoder.cpp b/mpeglib/lib/oggvorbis/vorbisDecoder.cpp new file mode 100644 index 00000000..24e9370d --- /dev/null +++ b/mpeglib/lib/oggvorbis/vorbisDecoder.cpp @@ -0,0 +1,135 @@ +/* + converts ogg frames into audioFrames + Copyright (C) 2001 Martin Vogt + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as published by + the Free Software Foundation. + + For more information look at the file COPYRIGHT in this package + + */ + + +#include "vorbisDecoder.h" + +#ifdef OGG_VORBIS + +#define _VORBIS_NEED_SYNTHHEADER_1 1 +#define _VORBIS_NEED_SYNTHHEADER_2 2 +#define _VORBIS_NEED_SYNTHHEADER_3 3 + +#define _VORBIS_DECODE_SETUP 4 +#define _VORBIS_DECODE_LOOP 5 + +#include + +using namespace std; + + +VorbisDecoder::VorbisDecoder() { + vorbis_info_init(&vi); + vorbis_comment_init(&vc); + reset(); +} + + +VorbisDecoder::~VorbisDecoder() { +} + +int VorbisDecoder::hasHeader() { + return (initState>=_VORBIS_DECODE_LOOP); +} + +int VorbisDecoder::decode(RawFrame* rawFrame,AudioFrame* dest) { + + if ((rawFrame == NULL) || (dest == NULL)) { + cout << "VorbisDecoder::decode NULL pointer!"<getFrameType() != _FRAME_RAW_OGG) { + cout << "VorbisDecoder::decode not _FRAME_RAW_OGG"<getData(); + switch(initState) { + case _VORBIS_NEED_SYNTHHEADER_1: + case _VORBIS_NEED_SYNTHHEADER_2: + case _VORBIS_NEED_SYNTHHEADER_3: + cout << "_VORBIS_NEED_SYNTHHEADER:"< 0) { + int maxSamples=dest->getSize(); + if (samples > maxSamples) { + cout << "more samples in vorbis than we can store"<clearrawdata(); + dest->setFrameFormat(vi.channels-1,vi.rate); + + if (vi.channels == 2) { + dest->putFloatData(pcm[0],pcm[1],samples); + } else { + dest->putFloatData(pcm[0],NULL,samples); + } + + vorbis_synthesis_read(&vd,samples); /* tell libvorbis how + many samples we + actually consumed */ + return true; + } + + return false; + } + default: + cout << "unknown state in vorbis decoder"<