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/ovFramer.cpp | 128 +++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 mpeglib/lib/oggvorbis/ovFramer.cpp (limited to 'mpeglib/lib/oggvorbis/ovFramer.cpp') diff --git a/mpeglib/lib/oggvorbis/ovFramer.cpp b/mpeglib/lib/oggvorbis/ovFramer.cpp new file mode 100644 index 00000000..ca3506af --- /dev/null +++ b/mpeglib/lib/oggvorbis/ovFramer.cpp @@ -0,0 +1,128 @@ +/* + frames raw data into Ogg/Vorbis frames. + 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 "ovFramer.h" + +#define OGG_SYNC_BUFF_SIZE 4096 + + +#define _OV_SETSERIAL 1 +#define _OV_STREAMIN 2 +#define _OV_STREAMOUT 3 + +#include + +using namespace std; + + +#ifdef OGG_VORBIS + +OVFramer::OVFramer(OGGFrame* dest):Framer(1) { + if (dest == NULL) { + cout << "OGGFrame NULL in OVFramer"<dest=dest; + /********** Decode setup ************/ + ogg_sync_init(&oy); /* Now we can read pages */ + + vorbis_state=_OV_SETSERIAL; +} + + +OVFramer::~OVFramer() { + /* OK, clean up the framer */ + ogg_sync_clear(&oy); +} + + +int OVFramer::find_frame(RawDataBuffer* input,RawDataBuffer* store) { + while(input->eof()==true) { + cout << "input eof"<getData())!=1){ + vorbis_state=_OV_STREAMIN; + return false; + } + return true; + } + + // do we have ogg packets in the ogg framer? + if (ogg_sync_pageout(&oy,&og) == 0) { + // no, ok insert some. + int bytes=input->untilend(); + input->inc(bytes); + store->inc(bytes); + ogg_sync_wrote(&oy,bytes); + // and setup the next buffer + /* submit a 4k block to libvorbis' Ogg layer */ + buffer=ogg_sync_buffer(&oy,OGG_SYNC_BUFF_SIZE); + /* override our own dummy buffer with size 1 */ + setRemoteFrameBuffer((unsigned char*)buffer,OGG_SYNC_BUFF_SIZE); + return false; + } + // we have an ogg page + // now try to build an ogg packet + switch(vorbis_state) { + case _OV_SETSERIAL: + /* Get the serial number and set up the rest of decode. */ + /* serialno first; use it to set up a logical stream */ + ogg_stream_init(&os,ogg_page_serialno(&og)); + vorbis_state=_OV_STREAMIN; + // yes we need to put this into the "pager" + // no break. + case _OV_STREAMIN: + if(ogg_stream_pagein(&os,&og)<0){ + /* error; stream version mismatch perhaps */ + fprintf(stderr,"Error reading first page of Ogg bitstream data.\n"); + exit(1); + } + vorbis_state=_OV_STREAMOUT; + break; + default: + cout << "unknow vorbis_state"<setpos(0); + ogg_sync_reset(&oy); + /* submit a 4k block to libvorbis' Ogg layer */ + buffer=ogg_sync_buffer(&oy,OGG_SYNC_BUFF_SIZE); + /* override our own dummy buffer with size 1 */ + setRemoteFrameBuffer((unsigned char*)buffer,OGG_SYNC_BUFF_SIZE); + } + +} + + +void OVFramer::printPrivateStates() { + cout << "OVFramer::printPrivateStates"<