Show / Hide Table of Contents

Class jpeg_source_mgr

Data source object for decompression.

Inheritance
System.Object
jpeg_source_mgr
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: BitMiracle.LibJpeg.Classic
Assembly: BitMiracle.LibJpeg.NET.dll
Syntax
public abstract class jpeg_source_mgr

Methods

| Improve this Doc View Source

fill_input_buffer()

Fills input buffer

Declaration
public abstract bool fill_input_buffer()
Returns
Type Description
System.Boolean

true if operation succeed; otherwise, false

| Improve this Doc View Source

GetByte(out Int32)

Read a byte into variable V. If must suspend, take the specified action (typically "return false").

Declaration
public virtual bool GetByte(out int V)
Parameters
Type Name Description
System.Int32 V

The result.

Returns
Type Description
System.Boolean

true if operation succeed; otherwise, false

| Improve this Doc View Source

GetBytes(Byte[], Int32)

Gets the bytes.

Declaration
public virtual int GetBytes(byte[] dest, int amount)
Parameters
Type Name Description
System.Byte[] dest

The destination.

System.Int32 amount

The amount.

Returns
Type Description
System.Int32

The number of available bytes.

| Improve this Doc View Source

GetTwoBytes(out Int32)

Reads two bytes interpreted as an unsigned 16-bit integer.

Declaration
public virtual bool GetTwoBytes(out int V)
Parameters
Type Name Description
System.Int32 V

The result.

Returns
Type Description
System.Boolean

true if operation succeed; otherwise, false

| Improve this Doc View Source

init_source()

Initializes this instance.

Declaration
public abstract void init_source()
| Improve this Doc View Source

initInternalBuffer(Byte[], Int32)

Initializes the internal buffer.

Declaration
protected void initInternalBuffer(byte[] buffer, int size)
Parameters
Type Name Description
System.Byte[] buffer

The buffer.

System.Int32 size

The size.

| Improve this Doc View Source

MakeByteAvailable()

Functions for fetching data from the data source module.

Declaration
public virtual bool MakeByteAvailable()
Returns
Type Description
System.Boolean

true if operation succeed; otherwise, false

Remarks

At all times, cinfo.src.next_input_byte and .bytes_in_buffer reflect the current restart point; we update them only when we have reached a suitable place to restart if a suspension occurs.

| Improve this Doc View Source

resync_to_restart(jpeg_decompress_struct, Int32)

This is the default resync_to_restart method for data source managers to use if they don't have any better approach.

Declaration
public virtual bool resync_to_restart(jpeg_decompress_struct cinfo, int desired)
Parameters
Type Name Description
jpeg_decompress_struct cinfo

An instance of jpeg_decompress_struct

System.Int32 desired

The desired

Returns
Type Description
System.Boolean

false if suspension is required.

Remarks

That method assumes that no backtracking is possible. Some data source managers may be able to back up, or may have additional knowledge about the data which permits a more intelligent recovery strategy; such managers would presumably supply their own resync method.

read_restart_marker calls resync_to_restart if it finds a marker other than the restart marker it was expecting. (This code is not used unless a nonzero restart interval has been declared.) cinfo.unread_marker is the marker code actually found (might be anything, except 0 or FF). The desired restart marker number (0..7) is passed as a parameter.

This routine is supposed to apply whatever error recovery strategy seems appropriate in order to position the input stream to the next data segment. Note that cinfo.unread_marker is treated as a marker appearing before the current data-source input point; usually it should be reset to zero before returning.

This implementation is substantially constrained by wanting to treat the input as a data stream; this means we can't back up. Therefore, we have only the following actions to work with:

  1. Simply discard the marker and let the entropy decoder resume at next byte of file.
  2. Read forward until we find another marker, discarding intervening data. (In theory we could look ahead within the current bufferload, without having to discard data if we don't find the desired marker. This idea is not implemented here, in part because it makes behavior dependent on buffer size and chance buffer-boundary positions.)
  3. Leave the marker unread (by failing to zero cinfo.unread_marker). This will cause the entropy decoder to process an empty data segment, inserting dummy zeroes, and then we will reprocess the marker.

2 is appropriate if we think the desired marker lies ahead, while #3 is

appropriate if the found marker is a future restart marker (indicating that we have missed the desired restart marker, probably because it got corrupted).
We apply #2 or #3 if the found marker is a restart marker no more than two counts behind or ahead of the expected one. We also apply #2 if the found marker is not a legal JPEG marker code (it's certainly bogus data). If the found marker is a restart marker more than 2 counts away, we do #1 (too much risk that the marker is erroneous; with luck we will be able to resync at some future point).
For any valid non-restart JPEG marker, we apply #3. This keeps us from overrunning the end of a scan. An implementation limited to single-scan files might find it better to apply #2 for markers other than EOI, since any other marker would have to be bogus data in that case.

| Improve this Doc View Source

skip_input_data(Int32)

Skip data - used to skip over a potentially large amount of uninteresting data (such as an APPn marker).

Declaration
public virtual void skip_input_data(int num_bytes)
Parameters
Type Name Description
System.Int32 num_bytes

The number of bytes to skip.

Remarks

Writers of suspendable-input applications must note that skip_input_data is not granted the right to give a suspension return. If the skip extends beyond the data currently in the buffer, the buffer can be marked empty so that the next read will cause a fill_input_buffer call that can suspend. Arranging for additional bytes to be discarded before reloading the input buffer is the application writer's problem.

| Improve this Doc View Source

term_source()

Terminate source - called by jpeg_finish_decompress after all data has been read. Often a no-op.

Declaration
public virtual void term_source()
Remarks

NB: not called by jpeg_abort or jpeg_destroy; surrounding application must deal with any cleanup that should happen even for error exit.

  • Improve this Doc
  • View Source
Back to top Generated by DocFX