blob: 727cf5741d8f3c8bfb60f23e383d8e0702f1de1c (
plain) (
blame)
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
84
85
86
87
88
89
90
91
92
|
#include "Decoder.h"
/*
* decode headers from one input stream
* until an End of Sequence or picture start code
* is found
*/
int Decoder::getheader()
{
unsigned int sorenson_version;
/* look for startcode */
startcode();
buffer.getbits(PSC_LENGTH);
sorenson_version = buffer.getbits(5);
if (sorenson_version <= 1)
{
escapemode=sorenson_version;
getpicturehdr();
}
else
return 0;
return 1;
}
/* align to start of next startcode */
void Decoder::startcode()
{
/* search for new picture start code */
while (buffer.showbits(PSC_LENGTH)!=1l)
buffer.flushbits(1);
}
/* decode picture header */
void Decoder::getpicturehdr()
{
int pei, tmp;
buffer.getbits(8);
tmp = buffer.getbits(3);
switch(tmp)
{
case 0:
horizontal_size = buffer.getbits(8);
vertical_size = buffer.getbits(8);
break;
case 1:
horizontal_size = buffer.getbits(16);
vertical_size = buffer.getbits(16);
break;
case 2:
horizontal_size = 352;
vertical_size = 288;
break;
case 3:
horizontal_size = 176;
vertical_size = 144;
break;
case 4:
horizontal_size = 128;
vertical_size = 96;
break;
case 5:
horizontal_size = 320;
vertical_size = 240;
break;
case 6:
horizontal_size = 160;
vertical_size = 120;
break;
}
pict_type = buffer.getbits(2);
deblock=buffer.getbits(1); // deblocking flag
quant = buffer.getbits(5);
pei = buffer.getbits(1);
pspare:
if (pei) {
/* extra info for possible future backward compatible additions */
buffer.getbits(8); /* not used */
pei = buffer.getbits(1);
if (pei) goto pspare; /* keep on reading pspare until pei=0 */
}
}
|