Main Page | Modules | Class Hierarchy | Data Structures | File List | Data Fields | Globals | Related Pages | Examples

CMJ2EncT Class Reference

Simple implementation of a Threaded CMJ2Enc. More...

#include <iMJ2Enc.h>

Inheritance diagram for CMJ2EncT:

Inheritance graph
Collaboration diagram for CMJ2EncT:

Collaboration graph

Public Member Functions

 CMJ2EncT (BOOL bInterlaced, DWORD dwIdealProcessor, const GUID *pOEM_LIC)
 Constructor.
 ~CMJ2EncT ()
 Destructor.
virtual int prepare (JPEG2000INFOHEADER2 *jp2, int argc, char **argv, BYTE *in, int in_size, int in_ofs, int in_row, int in_width, int in_height, DWORD in_fcc, int in_bits, BYTE *out, int out_size, int out_quality, int out_desired_size)
 Prepare encoding.
virtual HANDLE start ()
 Create the thread and start it.
virtual int sync ()
 Wait for completion of the threaded encoding.

Protected Member Functions

virtual int encode (JPEG2000INFOHEADER2 *jp2, int argc, char **argv, BYTE *in, int in_size, int in_ofs, int in_row, int in_width, int in_height, DWORD in_fcc, int in_bits, BYTE *out, int out_size, int out_quality, int out_desired_size)
 Encode one frame or field in the thread created by start().

Protected Attributes

PSetThreadIdealProcessor m_pSetThreadIdealProcessor
HANDLE m_hThread
 Thread handle.
HANDLE m_hEvent
 Completion event.
DWORD m_dwIdealProcessor
 Store dwIdealProcessor passed to constructor CMJ2EncT().
DWORD m_encoded_size
 Encoded field or frame size.
ENCODE_PARAM m_ep
 Encoding parameters.

Private Member Functions

void encodeT ()
 Instanciated thread method.

Static Private Member Functions

static void __cdecl encodeT (void *param)
 Static thread function, it calls instanciated thread method (see below).

Related Functions

(Note that these are not member functions.)

typedef WINBASEAPI DWORD(WINAPI * PSetThreadIdealProcessor )(HANDLE hThread, DWORD dwIdealProcessor)
 Windows' SetThreadIdealProcessor() function pointer type.

Detailed Description

Simple implementation of a Threaded CMJ2Enc.

This class encodes a single frame or field on a thread it creates. It tries to run this thread on a the ideal CPU passed to its constructor.

The calling sequence is :


Constructor & Destructor Documentation

CMJ2EncT::CMJ2EncT BOOL  bInterlaced,
DWORD  dwIdealProcessor,
const GUID *  pOEM_LIC
[inline]
 

Constructor.

Parameters:
bInterlaced Interlace encoding flag (see IMJ2Enc()).
dwIdealProcessor Ideal Processor for field or frame encoding.
pOEM_LIC Pointer to the OEM license GUID (&OEM_LIC).

CMJ2EncT::~CMJ2EncT  )  [inline]
 

Destructor.


Member Function Documentation

virtual int CMJ2EncT::prepare JPEG2000INFOHEADER2 jp2,
int  argc,
char **  argv,
BYTE *  in,
int  in_size,
int  in_ofs,
int  in_row,
int  in_width,
int  in_height,
DWORD  in_fcc,
int  in_bits,
BYTE *  out,
int  out_size,
int  out_quality,
int  out_desired_size
[inline, virtual]
 

Prepare encoding.

Parameters:
see IMJ2Enc::encode().
Returns:
  • 0 on success.

virtual HANDLE CMJ2EncT::start  )  [inline, virtual]
 

Create the thread and start it.

Returns:
  • NULL if prepare() has not been called before.
  • The handle of the thread created.
Reset the completion event.

Create the encoding thread.

Run the thread on the CPU specified by m_dwIdealProcessor.

Here is the call graph for this function:

virtual int CMJ2EncT::sync  )  [inline, virtual]
 

Wait for completion of the threaded encoding.

Returns:
  • NULL if prepare() has not been called before.
  • The size in bytes of the field or frame encoded.

Note:
If you override this method and use _endthreadex(), you must release the thread handle (see Note in encode()):
                    CloseHandle(m_hThread);
                    m_hThread = NULL;

virtual int CMJ2EncT::encode JPEG2000INFOHEADER2 jp2,
int  argc,
char **  argv,
BYTE *  in,
int  in_size,
int  in_ofs,
int  in_row,
int  in_width,
int  in_height,
DWORD  in_fcc,
int  in_bits,
BYTE *  out,
int  out_size,
int  out_quality,
int  out_desired_size
[inline, protected, virtual]
 

Encode one frame or field in the thread created by start().

Parameters:
see IMJ2Enc::encode().
Returns:
Nothing (see remarks).

The size in bytes of the field or frame encoded is stored in m_encoded_size.

Set the completion event.

Self-destroy the thread.

Note:
This method doesn't call CloseHandle(m_hThread) because it uses _endthread() which does it. But if you override this method and use another thread function/API it may not be the case. For instance _endthreadex() does not release the thread handle, so you have to do it after thread termination (for instance in the sync() method).

Remarks:
In fact this method doesn't return anything because at return time the thread doesn't exists anymore ... A class ovirriding this method using _endthreadex(), could use:
 _endthreadex(m_encoded_size); 
We don't make encode() returning void because it could be overriden, for instance in a class where the thread is not created/destroyed for each field or frame encoded. At this time return statement is only present to avoid a warning at compilation time.

Reimplemented from IMJ2Enc.

Here is the call graph for this function:

static void __cdecl CMJ2EncT::encodeT void *  param  )  [inline, static, private]
 

Static thread function, it calls instanciated thread method (see below).

void CMJ2EncT::encodeT  )  [inline, private]
 

Instanciated thread method.

It calls encode().

Here is the call graph for this function:


Friends And Related Function Documentation

typedef WINBASEAPI DWORD(WINAPI* PSetThreadIdealProcessor)(HANDLE hThread, DWORD dwIdealProcessor) [related]
 

Windows' SetThreadIdealProcessor() function pointer type.

Used to dynamically link to SetThreadIdealProcessor() using GetProcAddress() because SetThreadIdealProcessor() isn't available in Win9x/me.


Field Documentation

PSetThreadIdealProcessor CMJ2EncT::m_pSetThreadIdealProcessor [protected]
 

HANDLE CMJ2EncT::m_hThread [protected]
 

Thread handle.

HANDLE CMJ2EncT::m_hEvent [protected]
 

Completion event.

DWORD CMJ2EncT::m_dwIdealProcessor [protected]
 

Store dwIdealProcessor passed to constructor CMJ2EncT().

DWORD CMJ2EncT::m_encoded_size [protected]
 

Encoded field or frame size.

ENCODE_PARAM CMJ2EncT::m_ep [protected]
 

Encoding parameters.


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

   

© Morgan Multimedia 1990-2005