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/frame/framer.cpp | 241 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 241 insertions(+) create mode 100644 mpeglib/lib/frame/framer.cpp (limited to 'mpeglib/lib/frame/framer.cpp') diff --git a/mpeglib/lib/frame/framer.cpp b/mpeglib/lib/frame/framer.cpp new file mode 100644 index 00000000..d380b2ec --- /dev/null +++ b/mpeglib/lib/frame/framer.cpp @@ -0,0 +1,241 @@ +/* + base class for converting raw data(stream) into some frametype. + 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 "framer.h" + + + +#define PROCESS_FIND 0 +#define PROCESS_READ 1 + +#include + +using namespace std; + +Framer::Framer(int outsize) { + unsigned char* outptr=new unsigned char[outsize]; + init(outsize,outptr,true); +} + + +Framer::Framer(int outsize,unsigned char* outptr) { + if (outptr == NULL) { + cout << "Framer::Framer outptr NULL"<lDeleteOutPtr=lDeleteOutPtr; + input_info=new RawDataBuffer(NULL,0); + buffer_info=new RawDataBuffer(buffer_data,outsize); + lConstruct=true; + reset(); +} + + +Framer::~Framer() { + if (lDeleteOutPtr) { + delete[] buffer_data; + } + delete buffer_info; + delete input_info; +} + + +int Framer::canStore() { + return buffer_info->untilend(); +} + +int Framer::restBytes() { + return (input_info->size()-input_info->pos()); +} + + +void Framer::store(unsigned char* start,int bytes) { + if (buffer_info->pos()+bytes > buffer_info->size()) { + cout << "too much bytes inserted. cannot store that"<set(start,bytes,0); + int fillgrade=input_info->untilend(); + if (fillgrade > 0) { + main_state=FRAME_WORK; + } +} + + +int Framer::work() { + if (main_state != FRAME_WORK) { + cout << "cannot find_frame, when not in MPEGAUDIOFRAME_WORK"<eof()) { + main_state=FRAME_NEED; + } + } + if (main_state == FRAME_HAS) return true; + return false; +} + + +void Framer::reset() { + unsync(buffer_info,true); + lAutoNext=false; + main_state=FRAME_NEED; + input_info->set(NULL,0,0); + buffer_info->setpos(0); + setState(PROCESS_FIND); +} + + +void Framer::next() { + unsync(buffer_info,false); + lAutoNext=false; + main_state=FRAME_WORK; + setState(PROCESS_FIND); +} + + +int Framer::getState() { + int back=main_state; + if (main_state == FRAME_HAS) { + // autonext when we devlivered one frame + lAutoNext=true; + main_state=FRAME_WORK; + setState(PROCESS_FIND); + } + if (lConstruct == true) { + lConstruct=false; + unsync(buffer_info,true); + } + return back; +} + + +void Framer::setState(int state) { + this->process_state=state; +} + + + +unsigned char* Framer::outdata() { + return buffer_info->ptr(); +} + + +unsigned char* Framer::indata() { + return buffer_info->current(); +} + +int Framer::len() { + return buffer_info->pos(); +} + + + +void Framer::printMainStates(const char* msg) { + cout << msg<set(NULL,0,0); + buffer_info->set(outptr,size,0); +} -- cgit v1.2.3