File: decodebufmodel.cpp

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 (83 lines) | stat: -rw-r--r-- 2,062 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "decodebufmodel.hpp"
#include <stdlib.h>

using std::deque;

/******************************************************************
 *	Remove entries from FIFO buffer list, if their DTS is less than
 *	actual SCR. These packet data have been already decoded and have
 *	been removed from the system target decoder's elementary stream
 *	buffer.
 *****************************************************************/

void DecodeBufModel::Cleaned(clockticks SCR)
{
    while ( bufstate.size() != 0 && bufstate.front().DTS < SCR)
    {
		bufstate.pop_front();
    }
}

/******************************************************************
 * Return the SCR when there will next be some change in the
 * buffer.
 * If the buffer is empty return a zero timestamp.
 *****************************************************************/

clockticks DecodeBufModel::NextChange()
{
	if( bufstate.size() == 0 )
		return static_cast<clockticks>(0);
	else
		return bufstate.front().DTS;
}


/******************************************************************
 *
 *	Remove all entries from FIFO buffer list.
 *
 *****************************************************************/

void DecodeBufModel::Flushed ()
{
	bufstate.clear();
}

/******************************************************************
	DecodeBufModel::Space

	returns free space in the buffer
******************************************************************/

unsigned int DecodeBufModel::Space ()
{
	unsigned int used_bytes = 0;
	for( std::deque<DecodeBufEntry>::iterator i = bufstate.begin(); 
		 i < bufstate.end();
		 ++i )
	{
		used_bytes += i->size;
    }

    return (buffer_size - used_bytes);

}

/******************************************************************
	Queue_Buffer

	adds entry into the buffer FIFO queue
******************************************************************/

void DecodeBufModel::Queued (unsigned int bytes, clockticks TS)
{
	DecodeBufEntry entry;
	entry.size = bytes;
	entry.DTS = TS;
	bufstate.push_back( entry );
}