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

CMJ2DecT Class Reference

Simple implementation of a Threaded CMJ2Dec. More...

#include <iMJ2Dec.h>

Inheritance diagram for CMJ2DecT:

Inheritance graph
Collaboration diagram for CMJ2DecT:

Collaboration graph

Public Member Functions

 CMJ2DecT (BOOL bInterlaced, DWORD dwIdealProcessor, const GUID *pOEM_LIC)
 Constructor.
 ~CMJ2DecT ()
 Destructor.
virtual int prepare (JPEG2000INFOHEADER2 *jp2, int argc, char **argv, BYTE *in, int in_size, int in_width, int in_height, DWORD in_fcc, int in_bits, BYTE *out, int out_size, int out_ofs, int out_row, int out_width, int out_height, DWORD out_fcc, int out_bits)
 Prepare decoding.
virtual HANDLE start ()
 Create the thread and start it.
virtual int sync ()
 Wait for completion of the threaded decoding.

Protected Member Functions

virtual int decode (JPEG2000INFOHEADER2 *jp2, int argc, char **argv, BYTE *in, int in_size, int in_width, int in_height, DWORD in_fcc, int in_bits, BYTE *out, int out_size, int out_ofs, int out_row, int out_width, int out_height, DWORD out_fcc, int out_bits)
 Decode 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 CMJ2DecT().
DWORD m_read_size
 Decoded field or frame size.
DECODE_PARAM m_dp
 Decoding parameters.

Private Member Functions

void decodeT ()
 Instanciated thread method.

Static Private Member Functions

static void __cdecl decodeT (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 CMJ2Dec.

This class decodes 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

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

Constructor.

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

CMJ2DecT::~CMJ2DecT  )  [inline]
 

Destructor.


Member Function Documentation

virtual int CMJ2DecT::prepare JPEG2000INFOHEADER2 jp2,
int  argc,
char **  argv,
BYTE *  in,
int  in_size,
int  in_width,
int  in_height,
DWORD  in_fcc,
int  in_bits,
BYTE *  out,
int  out_size,
int  out_ofs,
int  out_row,
int  out_width,
int  out_height,
DWORD  out_fcc,
int  out_bits
[inline, virtual]
 

Prepare decoding.

Parameters:
see IMJ2Dec::decode().
Returns:
  • 0 on success.

virtual HANDLE CMJ2DecT::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 decoding thread.

Run the thread on the CPU specified by m_dwIdealProcessor.

Here is the call graph for this function:

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

Wait for completion of the threaded decoding.

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

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

virtual int CMJ2DecT::decode JPEG2000INFOHEADER2 jp2,
int  argc,
char **  argv,
BYTE *  in,
int  in_size,
int  in_width,
int  in_height,
DWORD  in_fcc,
int  in_bits,
BYTE *  out,
int  out_size,
int  out_ofs,
int  out_row,
int  out_width,
int  out_height,
DWORD  out_fcc,
int  out_bits
[inline, protected, virtual]
 

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

Parameters:
see IMJ2Dec::decode().
Returns:
Nothing (see remarks).

The size in bytes of the field or frame decoded is stored in m_read_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_read_size); 
We don't make decode() returning void because it could be overriden, for instance in a class where the thread is not created/destroyed for each field or frame decoded. At this time return statement is only present to avoid a warning at compilation time.

Reimplemented from IMJ2Dec.

Here is the call graph for this function:

static void __cdecl CMJ2DecT::decodeT void *  param  )  [inline, static, private]
 

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

void CMJ2DecT::decodeT  )  [inline, private]
 

Instanciated thread method.

It calls decode().

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 CMJ2DecT::m_pSetThreadIdealProcessor [protected]
 

HANDLE CMJ2DecT::m_hThread [protected]
 

Thread handle.

HANDLE CMJ2DecT::m_hEvent [protected]
 

Completion event.

DWORD CMJ2DecT::m_dwIdealProcessor [protected]
 

Store dwIdealProcessor passed to constructor CMJ2DecT().

DWORD CMJ2DecT::m_read_size [protected]
 

Decoded field or frame size.

DECODE_PARAM CMJ2DecT::m_dp [protected]
 

Decoding parameters.


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

   

© Morgan Multimedia 1990-2005