Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
Celartem::DjVu::DjVuEncoder Class Referenceabstract

#include <djv_djvuencoder.h>

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

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,
  efFgMaskErosion = 16
}
 
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, JB2Encoder::OptimizationCallback inCallback=NULL, void *inContext=0)=0
 
virtual void appendChunkToLastPage (Chunk *inChunk)=0
 
virtual size_t getQueuedPageCount () const =0
 
virtual size_t getFullPageCount () const =0
 
virtual AutoPtr< ChunkfinalizeSession (JB2Encoder::OptimizationCallback inCallback=NULL, void *inContext=0)=0
 
virtual void reset ()=0
 
- Public Member Functions inherited from Celartem::Referable
 Referable ()
 
void addRef () const
 
void releaseRef () const
 
size_t getReferenceCount () const
 

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)
 
- Static Public Member Functions inherited from Celartem::Referable
static void dumpDbgAllRefCount ()
 

Detailed Description

DjVuEncoder encodes DjVu files.

Warning
Without setting appropriate license script, encoding function (DjVuEncode feature) will stop working after 2 weeks from the its built time. See License System for more information.

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.

efFgMaskErosion 

Erode mask for foreground subsampling.

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,
JB2Encoder::OptimizationCallback  inCallback = NULL,
void *  inContext = 0 
)
pure virtual

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

Parameters
inImagePtrPointer 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.
inRowStrideThe row-stride of the image specified by inImagePtr.
It can be negative if the image is bottom-up.
inImagePmThe 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.
inWidthThe width of the image.
inHeightThe height of the image.
inDPIThe 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.
inPageIndexFor 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.
inCallbackCallback function called during optimizing JB2 shapes.
inContextContext for the callback.
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
inChunkA 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
inUseDictionaryDetermines 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.
inAutoDictFlushFreqDetermines 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.
inParamsParameters 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.
inHelperOptional 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
inParamsParameters for page encoding.
The parameters can be overwritten lately by explict parameter to each addPage call.
inHelperOptional 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
inProfilePointer to a Profile instance with which DjVuEncoder instance will be initialized.
inHelperOptional parameter to specify encoder helper.
Returns
Pointer to the newly created DjVuEncoder instance.
virtual AutoPtr<Chunk> Celartem::DjVu::DjVuEncoder::finalizeSession ( JB2Encoder::OptimizationCallback  inCallback = NULL,
void *  inContext = 0 
)
pure virtual
        This method finalizes the current encoding session.\n
        If the encoding uses dictionary, the dictionary is finalized on
        this call.\n
        This method can be called any times. This method always returns
        the pages encoded by any previous encoding sessions.\n
        If you want to reset all the queued pages, call \ref reset.
addPage(...);
addPage(...);
finalizeSession() // returns 2 pages
addPage(...);
addPage(...);
finalizeSession() // return 4 pages
addPage(...);
finalizeSession() // return 1 pages
Parameters
inCallbackCallback function called during optimizing JB2 shapes.
inContextContext for the callback.
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
inPagesInParallelHow many pages are encoded in parallel using threads.

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

Cuminas DjVu SDK 3.0.33103
This document is made with doxygen 1.8.5 at Sun Dec 15 2013 19:38:07.
Cuminas Logo