muhammara 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -1
- package/node_modules/@mapbox/node-pre-gyp/CHANGELOG.md +3 -0
- package/node_modules/@mapbox/node-pre-gyp/package.json +6 -7
- package/node_modules/ansi-regex/package.json +1 -2
- package/node_modules/brace-expansion/package.json +2 -1
- package/node_modules/gauge/CHANGELOG.md +163 -0
- package/node_modules/gauge/LICENSE +13 -0
- package/node_modules/gauge/README.md +1 -1
- package/node_modules/gauge/{lib/base-theme.js → base-theme.js} +3 -7
- package/node_modules/gauge/{lib/error.js → error.js} +0 -0
- package/node_modules/gauge/{lib/has-color.js → has-color.js} +0 -0
- package/node_modules/gauge/{lib/index.js → index.js} +32 -89
- package/node_modules/gauge/package.json +42 -37
- package/node_modules/gauge/{lib/plumbing.js → plumbing.js} +1 -3
- package/node_modules/gauge/{lib/process.js → process.js} +0 -0
- package/node_modules/gauge/{lib/progress-bar.js → progress-bar.js} +5 -11
- package/node_modules/gauge/{lib/render-template.js → render-template.js} +24 -68
- package/node_modules/gauge/{lib/set-immediate.js → set-immediate.js} +0 -0
- package/node_modules/gauge/{lib/set-interval.js → set-interval.js} +0 -0
- package/node_modules/gauge/{lib/spin.js → spin.js} +0 -0
- package/node_modules/gauge/{lib/template-item.js → template-item.js} +6 -21
- package/node_modules/gauge/{lib/theme-set.js → theme-set.js} +23 -31
- package/node_modules/gauge/{lib/themes.js → themes.js} +13 -13
- package/node_modules/gauge/{lib/wide-truncate.js → wide-truncate.js} +3 -9
- package/node_modules/minimatch/README.md +22 -1
- package/node_modules/minimatch/minimatch.js +93 -69
- package/node_modules/minimatch/package.json +11 -10
- package/node_modules/minipass/index.js +6 -1
- package/node_modules/minipass/package.json +5 -5
- package/node_modules/node-fetch/lib/index.es.js +28 -2
- package/node_modules/node-fetch/lib/index.js +28 -2
- package/node_modules/node-fetch/lib/index.mjs +28 -2
- package/node_modules/node-fetch/package.json +13 -5
- package/node_modules/npmlog/LICENSE +15 -0
- package/node_modules/npmlog/{lib/log.js → log.js} +9 -9
- package/node_modules/npmlog/package.json +20 -31
- package/node_modules/object-assign/index.js +90 -0
- package/node_modules/object-assign/license +21 -0
- package/node_modules/object-assign/package.json +74 -0
- package/node_modules/object-assign/readme.md +61 -0
- package/node_modules/signal-exit/index.js +4 -2
- package/node_modules/signal-exit/package.json +5 -5
- package/package.json +1 -1
- package/src/deps/PDFWriter/CMakeLists.txt +8 -0
- package/src/deps/PDFWriter/DecryptionHelper.cpp +10 -8
- package/src/deps/PDFWriter/Deletable.h +46 -0
- package/src/deps/PDFWriter/DocumentContext.h +3 -3
- package/src/deps/PDFWriter/IDeletable.h +6 -0
- package/src/deps/PDFWriter/InputLZWDecodeStream.cpp +208 -0
- package/src/deps/PDFWriter/InputLZWDecodeStream.h +77 -0
- package/src/deps/PDFWriter/InputStreamSkipperStream.cpp +1 -1
- package/src/deps/PDFWriter/JPEGImageHandler.h +2 -2
- package/src/deps/PDFWriter/ObjectsContext.cpp +5 -0
- package/src/deps/PDFWriter/ObjectsContext.h +1 -0
- package/src/deps/PDFWriter/PDFDocumentHandler.cpp +19 -3
- package/src/deps/PDFWriter/PDFObject.cpp +13 -11
- package/src/deps/PDFWriter/PDFObject.h +7 -5
- package/src/deps/PDFWriter/PDFObjectParser.cpp +8 -0
- package/src/deps/PDFWriter/PDFObjectParser.h +6 -0
- package/src/deps/PDFWriter/PDFParser.cpp +25 -13
- package/src/deps/PDFWriter/PDFParserTokenizer.cpp +25 -24
- package/src/deps/PDFWriter/PDFParserTokenizer.h +1 -0
- package/src/deps/PDFWriter/PDFWriter.h +2 -2
- package/src/deps/PDFWriter/binding.gyp +2 -0
- package/node_modules/gauge/LICENSE.md +0 -20
- package/node_modules/gauge/lib/demo.js +0 -45
- package/node_modules/npmlog/LICENSE.md +0 -20
- package/src/deps/PDFWriter/InputPredictorPNGAverageStream.cpp +0 -120
- package/src/deps/PDFWriter/InputPredictorPNGAverageStream.h +0 -49
- package/src/deps/PDFWriter/InputPredictorPNGNoneStream.cpp +0 -109
- package/src/deps/PDFWriter/InputPredictorPNGNoneStream.h +0 -47
- package/src/deps/PDFWriter/InputPredictorPNGPaethStream.cpp +0 -136
- package/src/deps/PDFWriter/InputPredictorPNGPaethStream.h +0 -51
- package/src/deps/PDFWriter/InputPredictorPNGSubStream.cpp +0 -113
- package/src/deps/PDFWriter/InputPredictorPNGSubStream.h +0 -47
- package/src/deps/PDFWriter/InputPredictorPNGUpStream.cpp +0 -120
- package/src/deps/PDFWriter/InputPredictorPNGUpStream.h +0 -49
|
@@ -67,7 +67,7 @@ BoolAndString PDFParserTokenizer::GetNextToken()
|
|
|
67
67
|
Byte buffer;
|
|
68
68
|
OutputStringBufferStream tokenBuffer;
|
|
69
69
|
|
|
70
|
-
if(!
|
|
70
|
+
if(!CanGetNextByte())
|
|
71
71
|
{
|
|
72
72
|
result.first = false;
|
|
73
73
|
return result;
|
|
@@ -76,7 +76,7 @@ BoolAndString PDFParserTokenizer::GetNextToken()
|
|
|
76
76
|
do
|
|
77
77
|
{
|
|
78
78
|
SkipTillToken();
|
|
79
|
-
if(!
|
|
79
|
+
if(!CanGetNextByte())
|
|
80
80
|
{
|
|
81
81
|
result.first = false;
|
|
82
82
|
break;
|
|
@@ -103,11 +103,11 @@ BoolAndString PDFParserTokenizer::GetNextToken()
|
|
|
103
103
|
case '%':
|
|
104
104
|
{
|
|
105
105
|
// for a comment, the token goes on till the end of line marker [not including]
|
|
106
|
-
while(
|
|
106
|
+
while(CanGetNextByte())
|
|
107
107
|
{
|
|
108
108
|
if(GetNextByteForToken(buffer) != PDFHummus::eSuccess)
|
|
109
109
|
{
|
|
110
|
-
result.first = !
|
|
110
|
+
result.first = !CanGetNextByte();
|
|
111
111
|
break;
|
|
112
112
|
}
|
|
113
113
|
if(0xD == buffer|| 0xA == buffer)
|
|
@@ -123,11 +123,11 @@ BoolAndString PDFParserTokenizer::GetNextToken()
|
|
|
123
123
|
// for a literal string, the token goes on until the balanced-closing right paranthesis
|
|
124
124
|
int balanceLevel = 1;
|
|
125
125
|
bool backSlashEncountered = false;
|
|
126
|
-
while(balanceLevel > 0 &&
|
|
126
|
+
while(balanceLevel > 0 && CanGetNextByte())
|
|
127
127
|
{
|
|
128
128
|
if(GetNextByteForToken(buffer) != PDFHummus::eSuccess)
|
|
129
129
|
{
|
|
130
|
-
result.first = !
|
|
130
|
+
result.first = !CanGetNextByte();
|
|
131
131
|
break;
|
|
132
132
|
}
|
|
133
133
|
|
|
@@ -138,11 +138,11 @@ BoolAndString PDFParserTokenizer::GetNextToken()
|
|
|
138
138
|
{
|
|
139
139
|
// ignore backslash and newline. might also need to read extra
|
|
140
140
|
// for cr-ln
|
|
141
|
-
if(0xD == buffer &&
|
|
141
|
+
if(0xD == buffer && CanGetNextByte())
|
|
142
142
|
{
|
|
143
143
|
if(GetNextByteForToken(buffer) != PDFHummus::eSuccess)
|
|
144
144
|
{
|
|
145
|
-
result.first = !
|
|
145
|
+
result.first = !CanGetNextByte();
|
|
146
146
|
break;
|
|
147
147
|
}
|
|
148
148
|
if(buffer != 0xA)
|
|
@@ -179,7 +179,7 @@ BoolAndString PDFParserTokenizer::GetNextToken()
|
|
|
179
179
|
// k. this might be a dictionary start marker or a hax string start. depending on whether it has a < following it or not
|
|
180
180
|
|
|
181
181
|
// Hex string, read till end of hex string marker
|
|
182
|
-
if(!
|
|
182
|
+
if(!CanGetNextByte())
|
|
183
183
|
{
|
|
184
184
|
result.second = tokenBuffer.ToString();
|
|
185
185
|
break;
|
|
@@ -187,7 +187,7 @@ BoolAndString PDFParserTokenizer::GetNextToken()
|
|
|
187
187
|
|
|
188
188
|
if(GetNextByteForToken(buffer) != PDFHummus::eSuccess)
|
|
189
189
|
{
|
|
190
|
-
result.first = !
|
|
190
|
+
result.first = !CanGetNextByte();
|
|
191
191
|
break;
|
|
192
192
|
}
|
|
193
193
|
|
|
@@ -204,11 +204,11 @@ BoolAndString PDFParserTokenizer::GetNextToken()
|
|
|
204
204
|
|
|
205
205
|
tokenBuffer.Write(&buffer,1);
|
|
206
206
|
|
|
207
|
-
while(
|
|
207
|
+
while(CanGetNextByte() && buffer != '>')
|
|
208
208
|
{
|
|
209
209
|
if(GetNextByteForToken(buffer) != PDFHummus::eSuccess)
|
|
210
210
|
{
|
|
211
|
-
result.first = !
|
|
211
|
+
result.first = !CanGetNextByte();
|
|
212
212
|
break;
|
|
213
213
|
}
|
|
214
214
|
|
|
@@ -227,7 +227,7 @@ BoolAndString PDFParserTokenizer::GetNextToken()
|
|
|
227
227
|
break;
|
|
228
228
|
case '>': // parse end dictionary marker as a single entity or a hex string end marker
|
|
229
229
|
{
|
|
230
|
-
if(!
|
|
230
|
+
if(!CanGetNextByte()) // this means a loose end string marker...wierd
|
|
231
231
|
{
|
|
232
232
|
result.second = tokenBuffer.ToString();
|
|
233
233
|
break;
|
|
@@ -235,7 +235,7 @@ BoolAndString PDFParserTokenizer::GetNextToken()
|
|
|
235
235
|
|
|
236
236
|
if(GetNextByteForToken(buffer) != PDFHummus::eSuccess)
|
|
237
237
|
{
|
|
238
|
-
result.first = !
|
|
238
|
+
result.first = !CanGetNextByte();
|
|
239
239
|
break;
|
|
240
240
|
}
|
|
241
241
|
|
|
@@ -258,11 +258,11 @@ BoolAndString PDFParserTokenizer::GetNextToken()
|
|
|
258
258
|
|
|
259
259
|
default: // regular token. read till next breaker or whitespace
|
|
260
260
|
{
|
|
261
|
-
while(
|
|
261
|
+
while(CanGetNextByte())
|
|
262
262
|
{
|
|
263
263
|
if(GetNextByteForToken(buffer) != PDFHummus::eSuccess)
|
|
264
264
|
{
|
|
265
|
-
result.first = !
|
|
265
|
+
result.first = !CanGetNextByte();
|
|
266
266
|
break;
|
|
267
267
|
}
|
|
268
268
|
if(IsPDFWhiteSpace(buffer))
|
|
@@ -279,7 +279,7 @@ BoolAndString PDFParserTokenizer::GetNextToken()
|
|
|
279
279
|
}
|
|
280
280
|
result.second = tokenBuffer.ToString();
|
|
281
281
|
|
|
282
|
-
if(result.first &&
|
|
282
|
+
if(result.first && CanGetNextByte() && scStream == result.second)
|
|
283
283
|
{
|
|
284
284
|
// k. a bit of a special case here for streams. the reading changes after the keyword "stream",
|
|
285
285
|
// essentially forcing the next content to start after either CR, CR-LF or LF. so there might be a little
|
|
@@ -288,9 +288,9 @@ BoolAndString PDFParserTokenizer::GetNextToken()
|
|
|
288
288
|
// that we should either skip one more "LF" or do nothing (based on what was parsed)
|
|
289
289
|
|
|
290
290
|
// verify that when whitespaces are finished buffer is either CR or LF, and behave accordingly
|
|
291
|
-
while(
|
|
291
|
+
while(CanGetNextByte()) {
|
|
292
292
|
if (!IsPDFWhiteSpace(buffer)) {
|
|
293
|
-
result.first = !
|
|
293
|
+
result.first = !CanGetNextByte(); // something wrong! not whitespace
|
|
294
294
|
break;
|
|
295
295
|
}
|
|
296
296
|
|
|
@@ -311,7 +311,7 @@ BoolAndString PDFParserTokenizer::GetNextToken()
|
|
|
311
311
|
} // else - some other white space
|
|
312
312
|
|
|
313
313
|
if (GetNextByteForToken(buffer) != PDFHummus::eSuccess) {
|
|
314
|
-
result.first = !
|
|
314
|
+
result.first = !CanGetNextByte(); //can't read but not eof. fail
|
|
315
315
|
break;
|
|
316
316
|
}
|
|
317
317
|
}
|
|
@@ -332,11 +332,8 @@ void PDFParserTokenizer::SkipTillToken()
|
|
|
332
332
|
{
|
|
333
333
|
Byte buffer = 0;
|
|
334
334
|
|
|
335
|
-
if(!mStream)
|
|
336
|
-
return;
|
|
337
|
-
|
|
338
335
|
// skip till hitting first non space, or segment end
|
|
339
|
-
while(
|
|
336
|
+
while(CanGetNextByte())
|
|
340
337
|
{
|
|
341
338
|
if(GetNextByteForToken(buffer) != PDFHummus::eSuccess)
|
|
342
339
|
break;
|
|
@@ -349,6 +346,10 @@ void PDFParserTokenizer::SkipTillToken()
|
|
|
349
346
|
}
|
|
350
347
|
}
|
|
351
348
|
|
|
349
|
+
bool PDFParserTokenizer::CanGetNextByte() {
|
|
350
|
+
return !!mStream && (mHasTokenBuffer || mStream->NotEnded());
|
|
351
|
+
}
|
|
352
|
+
|
|
352
353
|
EStatusCode PDFParserTokenizer::GetNextByteForToken(Byte& outByte)
|
|
353
354
|
{
|
|
354
355
|
++mStreamPositionTracker; // advance position tracker, because we are reading the next byte.
|
|
@@ -83,6 +83,7 @@ private:
|
|
|
83
83
|
|
|
84
84
|
void SkipTillToken();
|
|
85
85
|
|
|
86
|
+
bool CanGetNextByte();
|
|
86
87
|
// failure in GetNextByteForToken actually marks a true read failure, if you checked end of file before calling it...
|
|
87
88
|
PDFHummus::EStatusCode GetNextByteForToken(IOBasicTypes::Byte& outByte);
|
|
88
89
|
|
|
@@ -263,8 +263,8 @@ public:
|
|
|
263
263
|
|
|
264
264
|
// some public image info services, for users of hummus
|
|
265
265
|
DoubleAndDoublePair GetImageDimensions(const std::string& inImageFile,unsigned long inImageIndex = 0, const PDFParsingOptions& inParsingOptions = PDFParsingOptions::DefaultPDFParsingOptions());
|
|
266
|
-
|
|
267
|
-
|
|
266
|
+
DoubleAndDoublePair GetImageDimensions(IByteReaderWithPosition* inImageStream,unsigned long inImageIndex = 0, const PDFParsingOptions& inParsingOptions = PDFParsingOptions::DefaultPDFParsingOptions());
|
|
267
|
+
EHummusImageType GetImageType(const std::string& inImageFile,unsigned long inImageIndex);
|
|
268
268
|
unsigned long GetImagePagesCount(const std::string& inImageFile, const PDFParsingOptions& inOptions = PDFParsingOptions::DefaultPDFParsingOptions());
|
|
269
269
|
|
|
270
270
|
|
|
@@ -73,6 +73,7 @@
|
|
|
73
73
|
'InputFile.cpp',
|
|
74
74
|
'InputFileStream.cpp',
|
|
75
75
|
'InputFlateDecodeStream.cpp',
|
|
76
|
+
'InputLZWDecodeStream.cpp',
|
|
76
77
|
'InputLimitedStream.cpp',
|
|
77
78
|
'InputPFBDecodeStream.cpp',
|
|
78
79
|
'InputPredictorPNGOptimumStream.cpp',
|
|
@@ -239,6 +240,7 @@
|
|
|
239
240
|
'InputDCTDecodeStream.h',
|
|
240
241
|
'InputFile.h',
|
|
241
242
|
'InputFileStream.h',
|
|
243
|
+
'InputLZWDecodeStream.h',
|
|
242
244
|
'InputFlateDecodeStream.h',
|
|
243
245
|
'InputLimitedStream.h',
|
|
244
246
|
'InputPFBDecodeStream.h',
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
<!-- This file is automatically added by @npmcli/template-oss. Do not edit. -->
|
|
2
|
-
|
|
3
|
-
ISC License
|
|
4
|
-
|
|
5
|
-
Copyright npm, Inc.
|
|
6
|
-
|
|
7
|
-
Permission to use, copy, modify, and/or distribute this
|
|
8
|
-
software for any purpose with or without fee is hereby
|
|
9
|
-
granted, provided that the above copyright notice and this
|
|
10
|
-
permission notice appear in all copies.
|
|
11
|
-
|
|
12
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND NPM DISCLAIMS ALL
|
|
13
|
-
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
|
14
|
-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
|
|
15
|
-
EVENT SHALL NPM BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
17
|
-
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
|
18
|
-
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
19
|
-
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
|
|
20
|
-
USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
var Gauge = require('./')
|
|
2
|
-
var gaugeDefault = require('./themes.js')
|
|
3
|
-
var onExit = require('signal-exit')
|
|
4
|
-
|
|
5
|
-
var activeGauge
|
|
6
|
-
|
|
7
|
-
onExit(function () {
|
|
8
|
-
activeGauge.disable()
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
var themes = gaugeDefault.getThemeNames()
|
|
12
|
-
|
|
13
|
-
nextBar()
|
|
14
|
-
function nextBar () {
|
|
15
|
-
var themeName = themes.shift()
|
|
16
|
-
|
|
17
|
-
console.log('Demoing output for ' + themeName)
|
|
18
|
-
|
|
19
|
-
var gt = new Gauge(process.stderr, {
|
|
20
|
-
updateInterval: 50,
|
|
21
|
-
theme: themeName,
|
|
22
|
-
cleanupOnExit: false,
|
|
23
|
-
})
|
|
24
|
-
activeGauge = gt
|
|
25
|
-
|
|
26
|
-
var progress = 0
|
|
27
|
-
|
|
28
|
-
var cnt = 0
|
|
29
|
-
var pulse = setInterval(function () {
|
|
30
|
-
gt.pulse('this is a thing that happened ' + (++cnt))
|
|
31
|
-
}, 110)
|
|
32
|
-
var prog = setInterval(function () {
|
|
33
|
-
progress += 0.04
|
|
34
|
-
gt.show(themeName + ':' + Math.round(progress * 1000), progress)
|
|
35
|
-
if (progress >= 1) {
|
|
36
|
-
clearInterval(prog)
|
|
37
|
-
clearInterval(pulse)
|
|
38
|
-
gt.disable()
|
|
39
|
-
if (themes.length) {
|
|
40
|
-
nextBar()
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}, 100)
|
|
44
|
-
gt.show()
|
|
45
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
<!-- This file is automatically added by @npmcli/template-oss. Do not edit. -->
|
|
2
|
-
|
|
3
|
-
ISC License
|
|
4
|
-
|
|
5
|
-
Copyright npm, Inc.
|
|
6
|
-
|
|
7
|
-
Permission to use, copy, modify, and/or distribute this
|
|
8
|
-
software for any purpose with or without fee is hereby
|
|
9
|
-
granted, provided that the above copyright notice and this
|
|
10
|
-
permission notice appear in all copies.
|
|
11
|
-
|
|
12
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND NPM DISCLAIMS ALL
|
|
13
|
-
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
|
14
|
-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
|
|
15
|
-
EVENT SHALL NPM BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
17
|
-
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
|
18
|
-
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
19
|
-
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
|
|
20
|
-
USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Source File : InputPredictorPNGAverageStream.cpp
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Copyright 2011 Gal Kahana PDFWriter
|
|
6
|
-
|
|
7
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
you may not use this file except in compliance with the License.
|
|
9
|
-
You may obtain a copy of the License at
|
|
10
|
-
|
|
11
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
|
|
13
|
-
Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
See the License for the specific language governing permissions and
|
|
17
|
-
limitations under the License.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*/
|
|
21
|
-
#include "InputPredictorPNGAverageStream.h"
|
|
22
|
-
|
|
23
|
-
#include "Trace.h"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
using namespace IOBasicTypes;
|
|
27
|
-
|
|
28
|
-
InputPredictorPNGAverageStream::InputPredictorPNGAverageStream(void)
|
|
29
|
-
{
|
|
30
|
-
mSourceStream = NULL;
|
|
31
|
-
mBuffer = NULL;
|
|
32
|
-
mIndex = NULL;
|
|
33
|
-
mBufferSize = 0;
|
|
34
|
-
mUpValues = NULL;
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
InputPredictorPNGAverageStream::~InputPredictorPNGAverageStream(void)
|
|
39
|
-
{
|
|
40
|
-
delete[] mBuffer;
|
|
41
|
-
delete[] mUpValues;
|
|
42
|
-
delete mSourceStream;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
InputPredictorPNGAverageStream::InputPredictorPNGAverageStream(IByteReader* inSourceStream,IOBasicTypes::LongBufferSizeType inColumns)
|
|
46
|
-
{
|
|
47
|
-
mSourceStream = NULL;
|
|
48
|
-
mBuffer = NULL;
|
|
49
|
-
mIndex = NULL;
|
|
50
|
-
mBufferSize = 0;
|
|
51
|
-
mUpValues = NULL;
|
|
52
|
-
|
|
53
|
-
Assign(inSourceStream,inColumns);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
LongBufferSizeType InputPredictorPNGAverageStream::Read(Byte* inBuffer,LongBufferSizeType inBufferSize)
|
|
58
|
-
{
|
|
59
|
-
LongBufferSizeType readBytes = 0;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
// exhaust what's in the buffer currently
|
|
63
|
-
while(mBufferSize > (LongBufferSizeType)(mIndex - mBuffer) && readBytes < inBufferSize)
|
|
64
|
-
{
|
|
65
|
-
DecodeNextByte(inBuffer[readBytes]);
|
|
66
|
-
++readBytes;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// now repeatedly read bytes from the input stream, and decode
|
|
70
|
-
while(readBytes < inBufferSize && mSourceStream->NotEnded())
|
|
71
|
-
{
|
|
72
|
-
memcpy(mUpValues,mBuffer,mBufferSize);
|
|
73
|
-
LongBufferSizeType readFromSource = mSourceStream->Read(mBuffer, mBufferSize);
|
|
74
|
-
if (readFromSource == 0) {
|
|
75
|
-
break; // a belated end. must be flate
|
|
76
|
-
}
|
|
77
|
-
if (readFromSource != mBufferSize)
|
|
78
|
-
{
|
|
79
|
-
TRACE_LOG("InputPredictorPNGOptimumStream::Read, problem, expected columns number read. didn't make it");
|
|
80
|
-
break;
|
|
81
|
-
}
|
|
82
|
-
*mBuffer = 0; // so i can use this as "left" value...we don't care about this one...it's just a tag
|
|
83
|
-
mIndex = mBuffer+1; // skip the first tag
|
|
84
|
-
|
|
85
|
-
while(mBufferSize > (LongBufferSizeType)(mIndex - mBuffer) && readBytes < inBufferSize)
|
|
86
|
-
{
|
|
87
|
-
DecodeNextByte(inBuffer[readBytes]);
|
|
88
|
-
++readBytes;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return readBytes;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
bool InputPredictorPNGAverageStream::NotEnded()
|
|
95
|
-
{
|
|
96
|
-
return mSourceStream->NotEnded() || (LongBufferSizeType)(mIndex - mBuffer) < mBufferSize;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
void InputPredictorPNGAverageStream::DecodeNextByte(Byte& outDecodedByte)
|
|
100
|
-
{
|
|
101
|
-
outDecodedByte = (Byte)((char)mBuffer[mIndex-mBuffer - 1]/2 + (char)mUpValues[mIndex-mBuffer]/2 + (char)*mIndex);
|
|
102
|
-
|
|
103
|
-
*mIndex = outDecodedByte; // saving the encoded value back to the buffer, for later copying as "Up value", and current using as "Left" value
|
|
104
|
-
++mIndex;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
void InputPredictorPNGAverageStream::Assign(IByteReader* inSourceStream,IOBasicTypes::LongBufferSizeType inColumns)
|
|
108
|
-
{
|
|
109
|
-
mSourceStream = inSourceStream;
|
|
110
|
-
|
|
111
|
-
delete[] mBuffer;
|
|
112
|
-
delete[] mUpValues;
|
|
113
|
-
mBufferSize = inColumns + 1;
|
|
114
|
-
mBuffer = new Byte[mBufferSize];
|
|
115
|
-
memset(mBuffer,0,mBufferSize);
|
|
116
|
-
mUpValues = new Byte[mBufferSize];
|
|
117
|
-
memset(mUpValues,0,mBufferSize); // that's less important
|
|
118
|
-
mIndex = mBuffer + mBufferSize;
|
|
119
|
-
|
|
120
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Source File : InputPredictorPNGAverageStream.h
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Copyright 2011 Gal Kahana PDFWriter
|
|
6
|
-
|
|
7
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
you may not use this file except in compliance with the License.
|
|
9
|
-
You may obtain a copy of the License at
|
|
10
|
-
|
|
11
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
|
|
13
|
-
Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
See the License for the specific language governing permissions and
|
|
17
|
-
limitations under the License.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*/
|
|
21
|
-
#pragma once
|
|
22
|
-
|
|
23
|
-
#include "IByteReader.h"
|
|
24
|
-
|
|
25
|
-
class InputPredictorPNGAverageStream : public IByteReader
|
|
26
|
-
{
|
|
27
|
-
public:
|
|
28
|
-
InputPredictorPNGAverageStream(void);
|
|
29
|
-
// Takes ownership (use Assign(NULL,0) to unassign)
|
|
30
|
-
InputPredictorPNGAverageStream(IByteReader* inSourceStream,IOBasicTypes::LongBufferSizeType inColumns);
|
|
31
|
-
virtual ~InputPredictorPNGAverageStream(void);
|
|
32
|
-
|
|
33
|
-
virtual IOBasicTypes::LongBufferSizeType Read(IOBasicTypes::Byte* inBuffer,IOBasicTypes::LongBufferSizeType inBufferSize);
|
|
34
|
-
|
|
35
|
-
virtual bool NotEnded();
|
|
36
|
-
|
|
37
|
-
// Takes ownership (use Assign(NULL,0) to unassign)
|
|
38
|
-
void Assign(IByteReader* inSourceStream,IOBasicTypes::LongBufferSizeType inColumns);
|
|
39
|
-
|
|
40
|
-
private:
|
|
41
|
-
IByteReader* mSourceStream;
|
|
42
|
-
IOBasicTypes::Byte* mBuffer;
|
|
43
|
-
IOBasicTypes::LongBufferSizeType mBufferSize;
|
|
44
|
-
IOBasicTypes::Byte* mIndex;
|
|
45
|
-
|
|
46
|
-
IOBasicTypes::Byte* mUpValues;
|
|
47
|
-
|
|
48
|
-
void DecodeNextByte(IOBasicTypes::Byte& outDecodedByte);
|
|
49
|
-
};
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Source File : InputPredictorPNGNoneStream.cpp
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Copyright 2011 Gal Kahana PDFWriter
|
|
6
|
-
|
|
7
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
you may not use this file except in compliance with the License.
|
|
9
|
-
You may obtain a copy of the License at
|
|
10
|
-
|
|
11
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
|
|
13
|
-
Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
See the License for the specific language governing permissions and
|
|
17
|
-
limitations under the License.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*/
|
|
21
|
-
#include "InputPredictorPNGNoneStream.h"
|
|
22
|
-
|
|
23
|
-
#include "Trace.h"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
using namespace IOBasicTypes;
|
|
27
|
-
|
|
28
|
-
InputPredictorPNGNoneStream::InputPredictorPNGNoneStream(void)
|
|
29
|
-
{
|
|
30
|
-
mSourceStream = NULL;
|
|
31
|
-
mBuffer = NULL;
|
|
32
|
-
mIndex = NULL;
|
|
33
|
-
mBufferSize = 0;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
InputPredictorPNGNoneStream::~InputPredictorPNGNoneStream(void)
|
|
37
|
-
{
|
|
38
|
-
delete[] mBuffer;
|
|
39
|
-
delete mSourceStream;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
InputPredictorPNGNoneStream::InputPredictorPNGNoneStream(IByteReader* inSourceStream,IOBasicTypes::LongBufferSizeType inColumns)
|
|
43
|
-
{
|
|
44
|
-
mSourceStream = NULL;
|
|
45
|
-
mBuffer = NULL;
|
|
46
|
-
mIndex = NULL;
|
|
47
|
-
mBufferSize = 0;
|
|
48
|
-
|
|
49
|
-
Assign(inSourceStream,inColumns);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
LongBufferSizeType InputPredictorPNGNoneStream::Read(Byte* inBuffer,LongBufferSizeType inBufferSize)
|
|
54
|
-
{
|
|
55
|
-
LongBufferSizeType readBytes = 0;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
// exhaust what's in the buffer currently
|
|
59
|
-
while(mBufferSize > (LongBufferSizeType)(mIndex - mBuffer) && readBytes < inBufferSize)
|
|
60
|
-
{
|
|
61
|
-
DecodeNextByte(inBuffer[readBytes]);
|
|
62
|
-
++readBytes;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// now repeatedly read bytes from the input stream, and decode
|
|
66
|
-
while(readBytes < inBufferSize && mSourceStream->NotEnded())
|
|
67
|
-
{
|
|
68
|
-
LongBufferSizeType readFromSource = mSourceStream->Read(mBuffer, mBufferSize);
|
|
69
|
-
if (readFromSource == 0) {
|
|
70
|
-
break; // a belated end. must be flate
|
|
71
|
-
}
|
|
72
|
-
if (readFromSource != mBufferSize)
|
|
73
|
-
{
|
|
74
|
-
TRACE_LOG("InputPredictorPNGOptimumStream::Read, problem, expected columns number read. didn't make it");
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
77
|
-
mIndex = mBuffer+1; // skip the first tag
|
|
78
|
-
|
|
79
|
-
while(mBufferSize > (LongBufferSizeType)(mIndex - mBuffer) && readBytes < inBufferSize)
|
|
80
|
-
{
|
|
81
|
-
DecodeNextByte(inBuffer[readBytes]);
|
|
82
|
-
++readBytes;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return readBytes;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
bool InputPredictorPNGNoneStream::NotEnded()
|
|
89
|
-
{
|
|
90
|
-
return mSourceStream->NotEnded() || (LongBufferSizeType)(mIndex - mBuffer) < mBufferSize;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
void InputPredictorPNGNoneStream::DecodeNextByte(Byte& outDecodedByte)
|
|
94
|
-
{
|
|
95
|
-
outDecodedByte = *mIndex;
|
|
96
|
-
|
|
97
|
-
++mIndex;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
void InputPredictorPNGNoneStream::Assign(IByteReader* inSourceStream,IOBasicTypes::LongBufferSizeType inColumns)
|
|
101
|
-
{
|
|
102
|
-
mSourceStream = inSourceStream;
|
|
103
|
-
|
|
104
|
-
delete[] mBuffer;
|
|
105
|
-
mBufferSize = inColumns + 1;
|
|
106
|
-
mBuffer = new Byte[mBufferSize];
|
|
107
|
-
mIndex = mBuffer + mBufferSize;
|
|
108
|
-
|
|
109
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Source File : InputPredictorPNGNoneStream.h
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Copyright 2011 Gal Kahana PDFWriter
|
|
6
|
-
|
|
7
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
you may not use this file except in compliance with the License.
|
|
9
|
-
You may obtain a copy of the License at
|
|
10
|
-
|
|
11
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
|
|
13
|
-
Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
See the License for the specific language governing permissions and
|
|
17
|
-
limitations under the License.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*/
|
|
21
|
-
#pragma once
|
|
22
|
-
|
|
23
|
-
#include "IByteReader.h"
|
|
24
|
-
|
|
25
|
-
class InputPredictorPNGNoneStream : public IByteReader
|
|
26
|
-
{
|
|
27
|
-
public:
|
|
28
|
-
InputPredictorPNGNoneStream(void);
|
|
29
|
-
// Takes ownership (use Assign(NULL,0) to unassign)
|
|
30
|
-
InputPredictorPNGNoneStream(IByteReader* inSourceStream,IOBasicTypes::LongBufferSizeType inColumns);
|
|
31
|
-
virtual ~InputPredictorPNGNoneStream(void);
|
|
32
|
-
|
|
33
|
-
virtual IOBasicTypes::LongBufferSizeType Read(IOBasicTypes::Byte* inBuffer,IOBasicTypes::LongBufferSizeType inBufferSize);
|
|
34
|
-
|
|
35
|
-
virtual bool NotEnded();
|
|
36
|
-
|
|
37
|
-
// Takes ownership (use Assign(NULL,0) to unassign)
|
|
38
|
-
void Assign(IByteReader* inSourceStream,IOBasicTypes::LongBufferSizeType inColumns);
|
|
39
|
-
|
|
40
|
-
private:
|
|
41
|
-
IByteReader* mSourceStream;
|
|
42
|
-
IOBasicTypes::Byte* mBuffer;
|
|
43
|
-
IOBasicTypes::LongBufferSizeType mBufferSize;
|
|
44
|
-
IOBasicTypes::Byte* mIndex;
|
|
45
|
-
|
|
46
|
-
void DecodeNextByte(IOBasicTypes::Byte& outDecodedByte);
|
|
47
|
-
};
|