mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-05-31 07:11:00 +02:00
Merge pull request #21190 from Snuffleupagus/DecodeStream-abstract-readBlock
Add an abstract `readBlock` method in the `DecodeStream` class
This commit is contained in:
commit
e2591b3fbb
@ -13,10 +13,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { shadow, unreachable } from "../shared/util.js";
|
||||
import { DecodeStream } from "./decode_stream.js";
|
||||
import { Dict } from "./primitives.js";
|
||||
import { JBig2CCITTFaxImage } from "./jbig2_ccittFax.js";
|
||||
import { shadow } from "../shared/util.js";
|
||||
|
||||
class CCITTFaxStream extends DecodeStream {
|
||||
constructor(str, maybeLength, params) {
|
||||
@ -46,10 +46,6 @@ class CCITTFaxStream extends DecodeStream {
|
||||
return shadow(this, "bytes", this.stream.getBytes(this.maybeLength));
|
||||
}
|
||||
|
||||
readBlock() {
|
||||
unreachable("CCITTFaxStream.readBlock");
|
||||
}
|
||||
|
||||
get isImageStream() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
|
||||
import { BaseStream } from "./base_stream.js";
|
||||
import { Stream } from "./stream.js";
|
||||
import { unreachable } from "../shared/util.js";
|
||||
|
||||
// Lots of DecodeStreams are created whose buffers are never used. For these
|
||||
// we share a single empty buffer. This is (a) space-efficient and (b) avoids
|
||||
@ -24,15 +25,20 @@ const emptyBuffer = new Uint8Array(0);
|
||||
|
||||
// Super class for the decoding streams.
|
||||
class DecodeStream extends BaseStream {
|
||||
buffer = emptyBuffer;
|
||||
|
||||
bufferLength = 0;
|
||||
|
||||
eof = false;
|
||||
|
||||
minBufferLength = 512;
|
||||
|
||||
pos = 0;
|
||||
|
||||
constructor(maybeMinBufferLength) {
|
||||
super();
|
||||
this._rawMinBufferLength = maybeMinBufferLength || 0;
|
||||
|
||||
this.pos = 0;
|
||||
this.bufferLength = 0;
|
||||
this.eof = false;
|
||||
this.buffer = emptyBuffer;
|
||||
this.minBufferLength = 512;
|
||||
if (maybeMinBufferLength) {
|
||||
// Compute the first power of two that is as big as maybeMinBufferLength.
|
||||
while (this.minBufferLength < maybeMinBufferLength) {
|
||||
@ -41,6 +47,10 @@ class DecodeStream extends BaseStream {
|
||||
}
|
||||
}
|
||||
|
||||
readBlock() {
|
||||
unreachable("Abstract method `readBlock` called");
|
||||
}
|
||||
|
||||
get isEmpty() {
|
||||
while (!this.eof && this.bufferLength === 0) {
|
||||
this.readBlock();
|
||||
|
||||
@ -13,11 +13,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { shadow, unreachable } from "../shared/util.js";
|
||||
import { BaseStream } from "./base_stream.js";
|
||||
import { DecodeStream } from "./decode_stream.js";
|
||||
import { Dict } from "./primitives.js";
|
||||
import { JBig2CCITTFaxImage } from "./jbig2_ccittFax.js";
|
||||
import { shadow } from "../shared/util.js";
|
||||
|
||||
/**
|
||||
* For JBIG2's we use a library to decode these images and
|
||||
@ -43,10 +43,6 @@ class Jbig2Stream extends DecodeStream {
|
||||
// directly insert all of its data into `this.buffer`.
|
||||
}
|
||||
|
||||
readBlock() {
|
||||
unreachable("Jbig2Stream.readBlock");
|
||||
}
|
||||
|
||||
get isAsyncDecoder() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -13,9 +13,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { shadow, unreachable } from "../shared/util.js";
|
||||
import { DecodeStream } from "./decode_stream.js";
|
||||
import { JpxImage } from "./jpx.js";
|
||||
import { shadow } from "../shared/util.js";
|
||||
|
||||
/**
|
||||
* For JPEG 2000's we use a library to decode these images and
|
||||
@ -41,10 +41,6 @@ class JpxStream extends DecodeStream {
|
||||
// directly insert all of its data into `this.buffer`.
|
||||
}
|
||||
|
||||
readBlock(decoderOptions) {
|
||||
unreachable("JpxStream.readBlock");
|
||||
}
|
||||
|
||||
get isAsyncDecoder() {
|
||||
return true;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user