File: aunitbuffer.hpp

package info (click to toggle)
mjpegtools 1%3A2.2.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 10,460 kB
  • sloc: ansic: 60,386; cpp: 32,062; sh: 5,978; makefile: 751; asm: 103
file content (65 lines) | stat: -rw-r--r-- 1,025 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef __AUNITBUFFER_H__
#define __AUNITBUFFER_H__

#include <deque>
#include "mjpeg_logging.h"
#include "aunit.hpp"

class AUStream
{
public:
	AUStream()  {}
	~AUStream() 
	{
		for( std::deque<AUnit *>::iterator i = buf.begin(); i != buf.end(); ++i )
			delete *i;
	}
	
	void Append( AUnit &rec )
	{
		if( buf.size() >= BUF_SIZE_SANITY )
			mjpeg_error_exit1( "INTERNAL ERROR: AU buffer overflow" );
		buf.push_back( new AUnit(rec) );
	}

	inline AUnit *Next( ) 
	{ 
		if( buf.size()==0 )
		{
			return 0;
		}
	    else
		{
			AUnit *res = buf.front();
			buf.pop_front();
			return res;
		}
	}

	inline void DropLast()
		{
			if( buf.empty() )
				mjpeg_error_exit1( "INTERNAL ERROR: droplast empty AU buffer" );
			buf.pop_back();
			
		}

	inline AUnit *Lookahead( unsigned int n)
	{
		return buf.size() <= n ? 0 : buf[n];
    }

	inline unsigned int MaxAULookahead() const { return buf.size(); }

private:
	static const unsigned int BUF_SIZE_SANITY = 1000;


	
	std::deque<AUnit *> buf;
};




#endif // __AUSTREAM_H__