Classes | Public Types | Public Member Functions | Static Public Member Functions

Celartem::DjVu::DjVuEncoder Class Reference

#include <djv_djvuencoder.h>

Inheritance diagram for Celartem::DjVu::DjVuEncoder:
Inheritance graph
[legend]

List of all members.

Classes

class  Helper
struct  Params

Public Types

enum  DictionaryType { dtNoSharedDict = 0, dtUseSharedDict = 1 }
enum  EncodeMode {
  em3Layer = 0, emFG44 = 0, em2Layer = 1, emColorJB2 = 1,
  emPicture = 2, emBitonal = 3, emAuto = 4, emFG44ColorJB2 = 5
}
enum  EncodeFlags { efNoMaskDilation = 1, efWriteAppInfo = 2, efSegmentForBitonal = 4, efForceSegmentation = 8 }
enum  BitonalEncodingMethod { bemJB2 = 0, bemMMR = 1, bemJBIG2 = 2 }
enum  PictureEncodingMethod { pemIW44 = 0, pemJPEG = 1, pemJPX = 2 }
enum  EmptyMaskProcess { mepBitonalOrPicture = 0, mepPicture = 1, mepBitonalOrSegmentation = 2, mepSegmentation = 3 }

Public Member Functions

virtual void startParallel (size_t inPagesInParallel)=0
virtual void addPage (const u8 *CEL_RESTRICT inImagePtr, ssize_t inImageRowStride, Photometric inImagePm, size_t inWidth, size_t inHeight, size_t inDPI, const Params *inParams=NULL, const u8 *CEL_RESTRICT inMaskPtr=NULL, ssize_t inMaskRowStride=0, MaskType inMaskType=mtUnpacked, size_t inPageIndex=0)=0
virtual void appendChunkToLastPage (Chunk *inChunk)=0
virtual size_t getQueuedPageCount () const =0
virtual size_t getFullPageCount () const =0
virtual AutoPtr< ChunkfinalizeSession ()=0
virtual void reset ()=0

Static Public Member Functions

static AutoPtr< DjVuEncodercreate (DictionaryType inUseDictionary=dtUseSharedDict, size_t inAutoDictFlushFreq=20, const Params *inParams=NULL, Helper *inHelper=NULL)
static AutoPtr< DjVuEncodercreate (const Params &inParams, Helper *inHelper=NULL)
static AutoPtr< DjVuEncodercreate (const Profile *inProfile, Helper *inHelper=NULL)

Detailed Description

DjVuEncoder encodes DjVu files.


Member Enumeration Documentation

This enumeration is used to specify mask/bitonal layer encoding method.

Enumerator:
bemJB2 

Use JB2 for mask/bitonal encoding.

bemMMR 

Use MMR (G4) for mask/bitonal encoding.

bemJBIG2 

Use JBIG2 for mask/bitonal encoding.

This enumeration is used to determine whether DjVuEncoder uses shared dictionary or not.

Enumerator:
dtNoSharedDict 

Never use shared dictionary.

dtUseSharedDict 

Use shared dictionary.

This enumeration is used to specify how to process the image when the mask is empty.

Enumerator:
mepBitonalOrPicture 

Treat as a bitonal or a picture according to the image type.

mepPicture 

Treat as a color image.

mepBitonalOrSegmentation 

Treat as a bitonal or do segmentation according to the image type.

mepSegmentation 

Do segmentation to generate mask.

This enumeration is used to specify additional conditions.

Enumerator:
efNoMaskDilation 

Never to dilate mask for background subsampling.

efWriteAppInfo 

Write Application Info to the encoded DjVu file.

efSegmentForBitonal 

Use segmentation rather than simple thresholding for emBitonal.

efForceSegmentation 

Force segmentation even if mask is explictly specified.

This enumeration is used to determine what kind of encoding is used to encode the page.

Enumerator:
em3Layer 

3-Layer image encoding.

emFG44 

FG44; IW44 variant optimized for Foreground compression.

Deprecated:
New applications should use em3Layer instead of this.
em2Layer 

Mask-palette combination, a.k.a. 2 layer. (Using Color JB2).

emColorJB2 

Color JB2; JB2 mask with palette.

Deprecated:
New applications should use em2Layer instead of this.
emPicture 

BG44; IW44 variant optimized for picture compression. (No image separation).

emBitonal 

Black and White JB2; No color is preserved.

emAuto 

Automatic mode.

Deprecated:
New applications should consider use of flexEncodeMode instead of this.
The background of the deprecation is that EncodeMode should be defined as the default encode mode and automatic mode should choose the mode regarding the default mode. Without the default mode, it is sometimes too difficult to choose one from 3-Layer and 2-Layer.
emFG44ColorJB2 

Emit both FG44 and FGbz; the application should remove one of them.

This enumeration is used to specify picture layer encoding method.

Enumerator:
pemIW44 

Use IW44 for picture encoding.

pemJPEG 

Use JPEG for picture encoding.

pemJPX 

Use JPX (JPEG 2000) for picture encoding.


Member Function Documentation

virtual void Celartem::DjVu::DjVuEncoder::addPage ( const u8 *CEL_RESTRICT  inImagePtr,
ssize_t  inImageRowStride,
Photometric  inImagePm,
size_t  inWidth,
size_t  inHeight,
size_t  inDPI,
const Params inParams = NULL,
const u8 *CEL_RESTRICT  inMaskPtr = NULL,
ssize_t  inMaskRowStride = 0,
MaskType  inMaskType = mtUnpacked,
size_t  inPageIndex = 0 
) [pure virtual]

Add a page to encode queue.
This function accepts an image and its separation mask.

Parameters:
inImagePtr Pointer to the first line of the input image.
If you want to encode bitonal image, this can be NULL and inMaskPtr should be a valid mask.
inRowStride The row-stride of the image specified by inImagePtr.
It can be negative if the image is bottom-up.
inImagePm The photometric (type) of the image. It should be one of Photometric.
If this value is pmInvalid, inImagePtr is ignored and inMaskPtr should be a valid mask.
inWidth The width of the image.
inHeight The height of the image.
inDPI The resolution of the image in [pixel/inch].
inParams [Advanced Users Only]
Optional parameters which configures the DjVu encoder settings. With this option, you can configure the quality and the size of encoded result. For more information, see Params.
inMaskPtr [Optional] Pointer to the first line of the mask image.
In this mask, 0 means the foreground (black) and 1 (0xff for unpacked case) does the background (white).
inMaskRowStride [Optional] The row-stride of the image specified by inMaskPtr.
It can be negative if the mask is bottom-up.
It is ignored if inMaskPtr is NULL.
inMaskType [Optional] The type of the mask. This should be one of MaskType enumeration.
It is ignored if inMaskPtr is NULL.
inPageIndex For parallel page conversion, this specifies the index of the page (0-based index of the page) to encode on this call; otherwise this parameter is ignored.
See also:
finalizeSession, reset
virtual void Celartem::DjVu::DjVuEncoder::appendChunkToLastPage ( Chunk inChunk  )  [pure virtual]

This method appends a chunk to the last page queued by addPage method.

Parameters:
inChunk A Chunk instance to be appended to the page.
static AutoPtr<DjVuEncoder> Celartem::DjVu::DjVuEncoder::create ( DictionaryType  inUseDictionary = dtUseSharedDict,
size_t  inAutoDictFlushFreq = 20,
const Params inParams = NULL,
Helper inHelper = NULL 
) [static]

Initialize a new DjVuEncoder instance.

Parameters:
inUseDictionary Determines whether it uses shared dictionary or not. This should be one of DictionaryType enumeration values. If this value is dtNoSharedDict, inAutoDictFlushFreq is ignored.
The default is dtUseSharedDict. The parameter overrides the value specified in inParams.
inAutoDictFlushFreq Determines how many pages share a dictionary; in other words, this is the frequency of the flushing the dictionary.
DjVuEncoder instance automatically flushes the dictionary if the number of pages specified by inAutoDictFlushFreq is encoded.
If 0 is specified, the automatic flush feature is disabled and you should call finalizeSession manually.
Even with inAutoDictFlushFreq value not equal to 0, you can manually call finalizeSession and then the dictionary is flushed immediately regardless of inAutoDictFlushFreq value. The parameter overrides the value specified in inParams.
inParams Parameters for page encoding. This can be NULL and then the default parameters are used.
The parameters can be overwritten lately by explict parameter to each addPage call.
inHelper Optional parameter to specify encoder helper.
Returns:
Pointer to the newly created DjVuEncoder instance.
static AutoPtr<DjVuEncoder> Celartem::DjVu::DjVuEncoder::create ( const Params inParams,
Helper inHelper = NULL 
) [static]

Initialize a new DjVuEncoder instance.

Parameters:
inParams Parameters for page encoding.
The parameters can be overwritten lately by explict parameter to each addPage call.
inHelper Optional parameter to specify encoder helper.
Returns:
Pointer to the newly created DjVuEncoder instance.
static AutoPtr<DjVuEncoder> Celartem::DjVu::DjVuEncoder::create ( const Profile inProfile,
Helper inHelper = NULL 
) [static]

Initialize a new DjVuEncoder instance.

Parameters:
inProfile Pointer to a Profile instance with which DjVuEncoder instance will be initialized.
inHelper Optional parameter to specify encoder helper.
Returns:
Pointer to the newly created DjVuEncoder instance.
virtual AutoPtr<Chunk> Celartem::DjVu::DjVuEncoder::finalizeSession (  )  [pure virtual]

This method finalizes the current encoding session.
If the encoding uses dictionary, the dictionary is finalized on this call.
This method can be called any times. This method always returns the pages encoded by any previous encoding sessions.
If you want to reset all the queued pages, call reset.

addPage(...);
addPage(...);
finalizeSession() // returns 2 pages

addPage(...);
addPage(...);
finalizeSession() // return 4 pages

reset();
addPage(...);
finalizeSession() // return 1 pages
Returns:
The current encoding result. This can be a valid IFF (DjVu) structure, which can be passed to IFF::serialize method.
See also:
addPage, reset, IFF::serialize
virtual size_t Celartem::DjVu::DjVuEncoder::getFullPageCount (  )  const [pure virtual]

This method returns the number of pages which is already encoded.

Returns:
The number of pages encoded.
See also:
getQueuedPageCount
virtual size_t Celartem::DjVu::DjVuEncoder::getQueuedPageCount (  )  const [pure virtual]

This method returns the number of pages which is queued by addPage and still in the encoder queue.

Returns:
The number of pages in the encoder queue.
See also:
addPage, getFullPageCount
virtual void Celartem::DjVu::DjVuEncoder::reset (  )  [pure virtual]

Reset all the internal status.
All the pages encoded is purged.

virtual void Celartem::DjVu::DjVuEncoder::startParallel ( size_t  inPagesInParallel  )  [pure virtual]

Starts parallel page conversion.
Pages can be converted concurrently with threads if starts with this function.
After call of this function, addPage function can be called concurrently in threads. finalizeSession function should be called after all the threads (addPage call) finished.
Please note that auto-dict-flush is disabled for parallel conversion and you should explicitly call finalizeSession function after the conversion.

Parameters:
inPagesInParallel How many pages are encoded in parallel using threads.

The documentation for this class was generated from the following file:

This document is made with doxygen 1.7.1 at Thu Feb 17 2011 15:40:20.
Caminova Logo