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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
This removes unused code from ebuffer -- some of that code never
worked and now clang-3.8.0 issues a very valid warning about it...
Some of the variables are made static, while I'm here. This code
was never thread-safe either...
-mi
--- jpeg/ebuffer.h 2013-09-02 11:45:00.000000000 -0400
+++ jpeg/ebuffer.h 2016-02-18 16:31:36.053668000 -0500
@@ -22,26 +22,12 @@
long int buf_size);
JPEGEXPORT
-void EB_Clear(unsigned char *buf, /* output buffer */
- long int buf_size);
-JPEGEXPORT
-void EB_Write_Bits_Init(unsigned char *buf, /* compressed bitstream buffer */
- long int buf_size);
-JPEGEXPORT
-void EB_Write_Bytes(unsigned char *data,
- int size);
+void EB_Write_Bytes(const void *data, size_t size);
JPEGEXPORT
long cEB_Byte_Count(void);
JPEGEXPORT
-void EB_Copy_To_Memory(unsigned char *buf,
- unsigned char *mem,
- long int num);
-JPEGEXPORT
void EB_End(long int *bytes);
JPEGEXPORT
-void EB_Write_Bits_End(long int *bytes);
-
-JPEGEXPORT
int EB_Write_Bits(int val,
int nbits);
--- jpeg/ebuffer.c 2013-09-02 11:45:00.000000000 -0400
+++ jpeg/ebuffer.c 2016-02-18 16:32:03.964436000 -0500
@@ -24,9 +24,9 @@
/****************************** GLOBAL VARIABLES **************************/
-unsigned char *eb_ptr; /* points to next avaible byte in output buffer */
-unsigned char eb_byte; /* current output byte to be inserted into buffer */
-int eb_nbits; /* # bits available in *eb_ptr */
-unsigned char *eb_end_ptr, *eb_start_ptr;
-long int eb_byte_count;
+static unsigned char *eb_ptr; /* points to next avaible byte in output buffer */
+static unsigned char eb_byte; /* current output byte to be inserted into buffer */
+static int eb_nbits; /* # bits available in *eb_ptr */
+static unsigned char *eb_end_ptr, *eb_start_ptr;
+static long int eb_byte_count;
void EB_Init(unsigned char *buf, /* output buffer */
@@ -40,31 +40,7 @@
}
-void EB_Clear(unsigned char *buf, /* output buffer */
-long int buf_size)
-{
- unsigned char *eb_ptr, *eb_end_ptr;
-
- eb_end_ptr = buf + buf_size;
- for (eb_ptr = buf; eb_ptr < eb_end_ptr ;*eb_ptr++ = 0)
- eb_byte = 0;
- eb_nbits = 8;
- eb_byte_count = 0;
-}
-
-void EB_Write_Bits_Init(unsigned char *buf, /* compressed bitstream buffer */
-long int buf_size)
-{
- eb_ptr = eb_start_ptr = buf;
- eb_end_ptr = buf + buf_size;
- eb_byte = 0;
- eb_nbits = 8;
- eb_byte_count = 0;
-}
-
-void EB_Write_Bytes(unsigned char *data,
-int size)
+void
+EB_Write_Bytes(const void *data, size_t size)
{
- int i;
- unsigned char *ptr;
/* byte-align previous bits if any */
@@ -74,24 +50,5 @@
if (eb_byte == 0xff) *eb_ptr++ = 0x00; /* byte stuffing */
}
- for (i=0, ptr=data; i < size ;i++) {
- *eb_ptr++ = *ptr++;
- }
-}
-
-/* calculates the actual number of bytes written into output buffer */
-long cEB_Byte_Count(void)
-{
- return((long)(eb_ptr - eb_start_ptr));
-}
-
-void EB_Copy_To_Memory(unsigned char *buf,
-unsigned char *mem,
-long int num)
-{
- long int i;
- unsigned char *mem_ptr,*buf_ptr;
-
- for(i=0,mem_ptr=mem,buf_ptr=buf; i < num ;*mem_ptr++=*buf_ptr++);
-
+ memcpy(eb_ptr, data, size);
}
@@ -102,10 +59,4 @@
}
-/* calculates the actual number of bytes written into output buffer */
-void EB_Write_Bits_End(long int *bytes)
-{
- *bytes = eb_ptr - eb_start_ptr;
-}
-
/*
* Write 'nbits' bits of 'val' to the output buffer.
|