Alien-FreeImage

 view release on metacpan or  search on metacpan

src/Source/LibJXR/image/sys/strcodec.h  view on Meta::CPAN

    U8 P0[PACKETLENGTH];        // packet circular buffer 0
    U8 P1[PACKETLENGTH];        // packet circular buffer 1

    union
    {
        U8 P2[PACKETLENGTH];
        struct
        {
            U32 uiShadow;   // shadow of P0[0]-P0[3]

            U32 uiAccumulator;  // 32bit acc as bit field cache
            U32 cBitsUsed;  // # of bits used of acc, [0,16)

            U8* pbPacket;   // packet pointer
            U8* pbCurrent;  // current pointer

            struct WMPStream* pWS;    // pointer to WMPStream
            long offPacket; // byte offset into stream

            //ULARGE_INTEGER u64Acc; 

    //========================================
    // index packet, used for packet retrieval
    //========================================
            U32 cIndex; // current index for index packet
            long offIndex;  // byte offset into stream for index packet
        }State;
    }P2Info;
    U8 P3[PACKETLENGTH];    // index packet buffer
} IOContext;

typedef struct tagMemReadState
{    
    U8* pbBuf;
    size_t cbBuf;
    size_t cbCur;
} MemReadState;

typedef struct tagBitIOInfo
{
    U32 uiShadow;   // shadow of first 4B of circular buffer

    U32 uiAccumulator;  // 32bit acc as bit field cache
    U32 cBitsUsed;  // # of bits used of acc, [0,16)
#ifdef ARMOPT_BITIO
    U32 cBitsUnused;  // # of bits remain unused in acc, [0,32]
#endif

    I32 iMask;  // mask used simulate pointer wrap around

    U8* pbStart;    // start pointer
#ifndef ARMOPT_BITIO
    U8* pbCurrent;  // current pointer
#else
    U32* pbCurrent;  // current pointer
#endif

    struct WMPStream* pWS;  // pointer to WMPStream
    size_t offRef;  // reference offset on IStream,
                            // for read, it moves along the stream
                            // for write, it stays at the attach point
} BitIOInfo;

//================================================================
typedef struct tagCWMIQuantizer {
    U8 iIndex;
    I32 iQP;
    I32 iOffset;
    I32 iMan;
    I32 iExp;
#if defined(WMP_OPT_QT)
    float f1_QP;
    double d1_QP;
#endif    
} CWMIQuantizer;

/* temporary bridge between old APIs and streaming APIs */
typedef struct tagCWMIMBInfo {
    I32 iBlockDC[MAX_CHANNELS][16];
    I32 iOrientation;
    Int iCBP[MAX_CHANNELS];
    Int iDiffCBP[MAX_CHANNELS];
    U8 iQIndexLP; // 0 - 15
    U8 iQIndexHP; // 0 - 15
} CWMIMBInfo;

struct CWMImageStrCodec;

typedef Int (*ImageDataProc)(struct CWMImageStrCodec*);

/** scan model **/
typedef struct CAdaptiveScan {
    U32		uTotal;
    U32		uScan;
} CAdaptiveScan;

/** Adaptive context model **/
typedef struct CCodingContext {
    BitIOInfo * m_pIODC;
    BitIOInfo * m_pIOLP;
    BitIOInfo * m_pIOAC;
    BitIOInfo * m_pIOFL;

    /** adaptive huffman structs **/
    CAdaptiveHuffman *m_pAdaptHuffCBPCY;
    CAdaptiveHuffman *m_pAdaptHuffCBPCY1;
    CAdaptiveHuffman *m_pAHexpt[NUMVLCTABLES];

    /** 4x4 zigzag patterns */
    CAdaptiveScan m_aScanLowpass[16];
    CAdaptiveScan m_aScanHoriz[16];
    CAdaptiveScan m_aScanVert[16];

    /** Adaptive bit reduction model **/
    CAdaptiveModel m_aModelAC;
    CAdaptiveModel m_aModelLP;
    CAdaptiveModel m_aModelDC;

    /** Adaptive lowpass CBP model **/
    Int     m_iCBPCountZero;
    Int     m_iCBPCountMax;

src/Source/LibJXR/image/sys/strcodec.h  view on Meta::CPAN

ERR WMPAlloc(void** ppv, size_t cb);
ERR WMPFree(void** ppv);

//================================================================
Void initMRPtr(CWMImageStrCodec*);
Void advanceMRPtr(CWMImageStrCodec*);
Void swapMRPtr(CWMImageStrCodec*);

Int IDPEmpty(CWMImageStrCodec*);

//================================================================
extern const int dctIndex[3][16];
extern const int blkOffset[16];
extern const int blkOffsetUV[4];
extern const int blkOffsetUV_422[8];

extern const U8 idxCC[16][16];
extern const U8 idxCC_420[8][8];

extern const Char gGDISignature[];

//================================================================
Int allocatePredInfo(CWMImageStrCodec*);
Void freePredInfo(CWMImageStrCodec*);
Void advanceOneMBRow(CWMImageStrCodec*);

//================================================================
// bit I/O
//================================================================
Int allocateBitIOInfo(CWMImageStrCodec*);
Int setBitIOPointers(CWMImageStrCodec* pSC);

#ifndef ARMOPT_BITIO
U32 peekBit16(BitIOInfo* pIO, U32 cBits);
U32 flushBit16(BitIOInfo* pIO, U32 cBits);
U32 getBit16(BitIOInfo* pIO, U32 cBits);
U32 getBool16(BitIOInfo* pIO);
I32 getBit16s(BitIOInfo* pIO, U32 cBits);
U32 getBit32(BitIOInfo* pIO, U32 cBits);
U32 flushToByte(BitIOInfo* pIO);
#endif  // ARMOPT_BITIO

Void putBit16z(BitIOInfo* pIO, U32 uiBits, U32 cBits);
Void putBit16(BitIOInfo* pIO, U32 uiBits, U32 cBits);
Void putBit32(BitIOInfo* pIO, U32 uiBits, U32 cBits);
Void fillToByte(BitIOInfo* pIO);

U32 getSizeRead(BitIOInfo* pIO);
U32 getSizeWrite(BitIOInfo* pIO);

U32 getPosRead(BitIOInfo* pIO);

// safe function, solely for the convenience of test code
#ifndef ARMOPT_BITIO
U32 getBit16_S(CWMImageStrCodec* pSC, BitIOInfo* pIO, U32 cBits);
#endif  // ARMOPT_BITIO

//================================================================
// packet I/O
//================================================================
ERR attachISRead(BitIOInfo* pIO, struct WMPStream* pWS, CWMImageStrCodec* pSC);
ERR readIS(CWMImageStrCodec* pSC, BitIOInfo* pIO);
ERR detachISRead(CWMImageStrCodec* pSC, BitIOInfo* pIO);

ERR attachISWrite(BitIOInfo* pIO, struct WMPStream* pWS);
ERR writeIS(CWMImageStrCodec* pSC, BitIOInfo* pIO);
ERR detachISWrite(CWMImageStrCodec* pSC, BitIOInfo* pIO);


//================================================================
// post processing for decoder
//================================================================
Int initPostProc(struct tagPostProcInfo * strPostProcInfo[MAX_CHANNELS][2], size_t mbWidth, size_t iNumChannels);
Void termPostProc(struct tagPostProcInfo * strPostProcInfo[MAX_CHANNELS][2], size_t iNumChannels);
Void slideOneMBRow(struct tagPostProcInfo * strPostProcInfo[MAX_CHANNELS][2], size_t iNumChannels, size_t mbWidth, Bool top, Bool bottom);
Void updatePostProcInfo(struct tagPostProcInfo * strPostProcInfo[MAX_CHANNELS][2], PixelI * p, size_t mbX, size_t cc);
Void postProcMB(struct tagPostProcInfo * strPostProcInfo[MAX_CHANNELS][2], PixelI * p0, PixelI * p1, size_t mbX, size_t cc, Int threshold);
Void postProcBlock(struct tagPostProcInfo * strPostProcInfo[MAX_CHANNELS][2], PixelI * p0, PixelI * p1, size_t mbX, size_t cc, Int threshold);

//================================================================
// Simple BitIO access functions
//================================================================
typedef struct tagSimpleBitIO
{
    struct WMPStream* pWS;
    U32 cbRead;
    U8 bAccumulator;
    U32 cBitLeft;
} SimpleBitIO;

ERR attach_SB(SimpleBitIO* pSB, struct WMPStream* pWS);
U32 getBit32_SB(SimpleBitIO* pSB, U32 cBits);
Void flushToByte_SB(SimpleBitIO* pSB);
U32 getByteRead_SB(SimpleBitIO* pSB);
ERR detach_SB(SimpleBitIO* pSB);

//----------------------------------------------------------------
EXTERN_C Bool EOSWS_File(struct WMPStream* pWS);

EXTERN_C ERR ReadWS_File(struct WMPStream* pWS, void* pv, size_t cb);
EXTERN_C ERR WriteWS_File(struct WMPStream* pWS, const void* pv, size_t cb);
//EXTERN_C ERR GetLineWS_File(struct WMPStream* pWS, void* pv, size_t cb);

EXTERN_C ERR SetPosWS_File(struct WMPStream* pWS, size_t offPos);
EXTERN_C ERR GetPosWS_File(struct WMPStream* pWS, size_t* poffPos);

//----------------------------------------------------------------
EXTERN_C Bool EOSWS_Memory(struct WMPStream* pWS);

EXTERN_C ERR ReadWS_Memory(struct WMPStream* pWS, void* pv, size_t cb);
EXTERN_C ERR WriteWS_Memory(struct WMPStream* pWS, const void* pv, size_t cb);
//EXTERN_C ERR GetLineWS_Memory(struct WMPStream* pWS, void* pv, size_t cb);

EXTERN_C ERR SetPosWS_Memory(struct WMPStream* pWS, size_t offPos);
EXTERN_C ERR GetPosWS_Memory(struct WMPStream* pWS, size_t* poffPos);

//EXTERN_C ERR GetPtrWS_Memory(struct WMPStream* pWS, size_t align, U8** ppb);
//----------------------------------------------------------------
EXTERN_C Bool EOSWS_List(struct WMPStream* pWS);

EXTERN_C ERR ReadWS_List(struct WMPStream* pWS, void* pv, size_t cb);
EXTERN_C ERR WriteWS_List(struct WMPStream* pWS, const void* pv, size_t cb);

EXTERN_C ERR SetPosWS_List(struct WMPStream* pWS, size_t offPos);
EXTERN_C ERR GetPosWS_List(struct WMPStream* pWS, size_t* poffPos);

EXTERN_C ERR CreateWS_List(struct WMPStream** ppWS);
EXTERN_C ERR CloseWS_List(struct WMPStream** ppWS);

/********************************************************************/
// Stuff related to scale/spatial ordering
typedef struct PacketInfo
{
    BAND    m_iBand;
    size_t  m_iSize;
    size_t  m_iOffset;
    struct PacketInfo *m_pNext;
} PacketInfo;
/********************************************************************/

/********************************************************************/
const static Int blkIdxByRow[4][4] = {{0, 1, 4, 5}, {2, 3, 6, 7}, {8, 9, 12, 13}, {10, 11, 14, 15}};
const static Int blkIdxByColumn[4][4] = {{0, 2, 8, 10}, {1, 3, 9, 11},{4, 6, 12, 14},{5, 7, 13, 15}};

Int getACPredMode(CWMIMBInfo *, COLORFORMAT);
Int getDCACPredMode(CWMImageStrCodec *, size_t);
Void updatePredInfo(CWMImageStrCodec* pSC, CWMIMBInfo *, size_t, COLORFORMAT);

Int AllocateCodingContextDec(struct CWMImageStrCodec *pSC, Int iNumContexts);
Void ResetCodingContext(CCodingContext *pContext);
Void getTilePos(CWMImageStrCodec* pSC, size_t mbX, size_t mbY);



( run in 2.146 seconds using v1.01-cache-2.11-cpan-4991d5b9bd9 )