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

#include <djv_jb2encoder.h>

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

Classes

struct  Params
 
struct  RegionRecognitionParams
 

Public Types

typedef bool(* OptimizationCallback )(void *inContext, Shape *inCurrentShape, size_t inCurrentIndex, size_t inEndIndex)
 

Public Member Functions

virtual void startParallel (size_t inPagesInParallel)=0
 
virtual bool addPage (const u8 *inMaskPtr, ssize_t inMaskRowStride, MaskType inMaskType, size_t inWidth, size_t inHeight, const u8 *inImagePtr=NULL, ssize_t inImageRowStride=0, Photometric inImagePm=pmRGB8, const Params *inParams=NULL, size_t inPageIndex=0, OptimizationCallback inCallback=NULL, void *inContext=NULL, size_t *outPageIndex=NULL)=0
 
virtual size_t getPageCount () const =0
 
virtual AutoPtr< const JB2PagegetPage (size_t inIndex) const =0
 
virtual AutoPtr< JB2PagegetPage (size_t inIndex)=0
 
virtual void finalize (JB2Page::Array &outPages, OptimizationCallback inCallback=NULL, void *inContext=NULL)=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< JB2Encodercreate (const Params *inParams=NULL, bool inUseDictionary=true)
 
- Static Public Member Functions inherited from Celartem::Referable
static void dumpDbgAllRefCount ()
 

Detailed Description

This class provides a way to encode images with JB2 encoding.
This interface is provided for advanced purpose and you had better use DjVuEncoder for the normal purpose.
This class generates the data of the following chunks:

Member Typedef Documentation

typedef bool(* Celartem::DjVu::JB2Encoder::OptimizationCallback)(void *inContext, Shape *inCurrentShape, size_t inCurrentIndex, size_t inEndIndex)

Callback definition used on addPage and finalize method.

Parameters
inContextThe context specified on the method call.
inCurrentShapeThe shape, which will be optimized on this iteration. It is NULL if inCurrentIndex is equal to inEndIndex.
inCurrentIndexCurrent progress. It is no more than inEndIndex.
inEndIndexProgress maximum. When the method tries to notify the process is complete (100%), inCurrentIndex is set to the value equal to inEndIndex and inCurrentShape is set to NULL.
Returns
If the callback function returns true, the shape will be processed (will be the target of optimization); otherwise if the function returns false, the shape is not processed.

Member Function Documentation

virtual bool Celartem::DjVu::JB2Encoder::addPage ( const u8 inMaskPtr,
ssize_t  inMaskRowStride,
MaskType  inMaskType,
size_t  inWidth,
size_t  inHeight,
const u8 inImagePtr = NULL,
ssize_t  inImageRowStride = 0,
Photometric  inImagePm = pmRGB8,
const Params inParams = NULL,
size_t  inPageIndex = 0,
OptimizationCallback  inCallback = NULL,
void *  inContext = NULL,
size_t *  outPageIndex = NULL 
)
pure virtual

Add a page to JB2Encoder work area.
This method only stores the specified image into the internal work area and returns immediately.
This method should not be called after calling one of encodeDjbz, encodeSjbz and encodeFGbz.

Parameters
inMaskPtrThe pointer to the "first line" of the image mask.
The following formula correctly calculate the pointer to each line:

mask[n] = inMaskPtr + inMaskRowStride * n;

The image should be accessible until the encoding finishes.
In this mask, 0 means the foreground and 1 (0xff for unpacked case) does the background.
inMaskRowStrideThe row-stride in bytes of the mask specified by inMask. It can be negative if the image is bottom-up.
inMaskTypeThe type of the mask. It should be one of MaskType enumeration.
inWidthThe width of the image specified by inImagePtr and inMaskPtr.
inHeightThe height of the image specified by inImagePtr and inMaskPtr.
inImagePtrThe pointer to the "first line" of the image.
The following formula correctly calculate the pointer to each line:

line[n] = inImagePtr + inImageRowStride * n;

The image should be accessible until the encoding finishes.
It can be NULL if the image is bi-tonal (black and white 1bit) or the color of the foreground is encoded by other method (i.e. FG44).
inImageRowStrideThe row-stride in bytes of the image specified by inImagePtr. It can be negative if the image is bottom-up.
It can be 0 if the image is bi-tonal (black and white 1bit).
inImagePmThe photometric of the image specified by inImagePtr. It is ignored if inImagePtr is NULL.
inParamsParameters fof JB2 encoding.
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.
outPageIndexOptional; the resulting page index in the encoder.
Returns
true if the JB2 encoder modifies the input mask for optimization purpose. The mask encoded to Sjbz is different from the input mask and user code should update the mask accroding to the shapes for the page.
false if no such optimization.
static AutoPtr<JB2Encoder> Celartem::DjVu::JB2Encoder::create ( const Params inParams = NULL,
bool  inUseDictionary = true 
)
static

Create a new instance of JB2Encoder.

Parameters
inParamsParameters fof JB2 encoding. This can be NULL and the default parameters are used.
These parameters can be overwritten lately by the parameters explicitly passed to each addPage call.
inUseDictionaryWhether to use dictionary or not for the JB2 page encoding.
Returns
Pointer to the newly created JB2Encoder instance.
virtual void Celartem::DjVu::JB2Encoder::finalize ( JB2Page::Array outPages,
OptimizationCallback  inCallback = NULL,
void *  inContext = NULL 
)
pure virtual

Finalize JB2 encoding.
After calling this method, the JB2Encoder instance is clears all the internal data and it can be reused to encode other pages.

Parameters
outPagesReturns array of pages encoded.
inCallbackCallback function called during optimizing JB2 shapes.
inContextContext for the callback.
virtual AutoPtr<const JB2Page> Celartem::DjVu::JB2Encoder::getPage ( size_t  inIndex) const
pure virtual

Get access to the added page on the specified index.
This method is provided for advanced operations.

Parameters
inIndexPage index.
Returns
Pointer to the page.
virtual AutoPtr<JB2Page> Celartem::DjVu::JB2Encoder::getPage ( size_t  inIndex)
pure virtual

Get access to the added page on the specified index.
This method is provided for advanced operations.

Parameters
inIndexPage index.
Returns
Pointer to the page.
virtual size_t Celartem::DjVu::JB2Encoder::getPageCount ( ) const
pure virtual

Get the number of pages added to this JB2Encoder instance.

Returns
The number of pages in the JB2Encoder instance.
See Also
encodeSjbz, encodeFGbz
virtual void Celartem::DjVu::JB2Encoder::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. finalize function should be called after all the threads (addPage call) finished.

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