-
Notifications
You must be signed in to change notification settings - Fork 4
/
imgproc.c
54 lines (47 loc) · 1.15 KB
/
imgproc.c
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
#include <stdio.h>
int is_huffman(unsigned char *buf)
{
int i = 0;
unsigned char *pbuf = buf;
while (((pbuf[0] << 8) | pbuf[1]) != 0xffda)
{
if (i++ > 2048)
{
return 0;
}
if (((pbuf[0] << 8) | pbuf[1]) == 0xffc4)
{
return 1;
}
pbuf++;
}
return 0;
}
int mjpeg(unsigned char* buf,int length)
{
unsigned char *ptcur = buf;
int i1,i;
for(i1=0; i1<length; i1++)
{
if((buf[i1] == 0x000000FF) && (buf[i1+1] == 0x000000C4))
{
//printf("huffman table finded! \nbuf.bytesused = %d\nFFC4 = %d \n",buf.bytesused,i1);
break;
}
}
if(i1 == length)
{
printf("huffman tables don't exist!!!!!!!!!!!\n");
return -1;
}
else
{
for(i=0; i<length; i++)
{
if((buf== (unsigned char *)0x000000FF) && (buf== (unsigned char *)0x000000D8)) break;
ptcur++;
}
printf("i = %d,FF = %02x,D8 = %02x\n",i,buf[i],buf[i+1]);
return i;
}
}