Commit cfc8f154 authored by Alexandre Julliard's avatar Alexandre Julliard

libs: Import upstream code from jxrlib 1.1.

parent 9f0cdd2a
......@@ -707,6 +707,8 @@ PNG_PE_LIBS
PNG_PE_CFLAGS
LCMS2_PE_LIBS
LCMS2_PE_CFLAGS
JXR_PE_LIBS
JXR_PE_CFLAGS
JPEG_PE_LIBS
JPEG_PE_CFLAGS
GSM_PE_LIBS
......@@ -1784,6 +1786,7 @@ enable_dxerr9
enable_dxguid
enable_gsm
enable_jpeg
enable_jxr
enable_lcms2
enable_mfuuid
enable_png
......@@ -1930,6 +1933,8 @@ GSM_PE_CFLAGS
GSM_PE_LIBS
JPEG_PE_CFLAGS
JPEG_PE_LIBS
JXR_PE_CFLAGS
JXR_PE_LIBS
LCMS2_PE_CFLAGS
LCMS2_PE_LIBS
PNG_PE_CFLAGS
......@@ -2717,6 +2722,9 @@ Some influential environment variables:
C compiler flags for the PE jpeg, overriding the bundled version
JPEG_PE_LIBS
Linker flags for the PE jpeg, overriding the bundled version
JXR_PE_CFLAGS
C compiler flags for the PE jxr, overriding the bundled version
JXR_PE_LIBS Linker flags for the PE jxr, overriding the bundled version
LCMS2_PE_CFLAGS
C compiler flags for the PE lcms2, overriding the bundled
version
......@@ -10718,6 +10726,19 @@ fi
$as_echo "$as_me:${as_lineno-$LINENO}: jpeg cflags: $JPEG_PE_CFLAGS" >&5
$as_echo "$as_me:${as_lineno-$LINENO}: jpeg libs: $JPEG_PE_LIBS" >&5
if ${JXR_PE_CFLAGS:+false} :; then :
JXR_PE_CFLAGS="-I\$(top_srcdir)/libs/jxr/jxrgluelib -I\$(top_srcdir)/libs/jxr/image/sys"
else
enable_jxr=no
fi
if ${JXR_PE_LIBS:+false} :; then :
JXR_PE_LIBS=jxr
else
enable_jxr=no
fi
$as_echo "$as_me:${as_lineno-$LINENO}: jxr cflags: $JXR_PE_CFLAGS" >&5
$as_echo "$as_me:${as_lineno-$LINENO}: jxr libs: $JXR_PE_LIBS" >&5
if ${LCMS2_PE_CFLAGS:+false} :; then :
LCMS2_PE_CFLAGS="-I\$(top_srcdir)/libs/lcms2/include"
else
......@@ -18942,6 +18963,8 @@ GSM_PE_CFLAGS = $GSM_PE_CFLAGS
GSM_PE_LIBS = $GSM_PE_LIBS
JPEG_PE_CFLAGS = $JPEG_PE_CFLAGS
JPEG_PE_LIBS = $JPEG_PE_LIBS
JXR_PE_CFLAGS = $JXR_PE_CFLAGS
JXR_PE_LIBS = $JXR_PE_LIBS
LCMS2_PE_CFLAGS = $LCMS2_PE_CFLAGS
LCMS2_PE_LIBS = $LCMS2_PE_LIBS
PNG_PE_CFLAGS = $PNG_PE_CFLAGS
......@@ -20238,6 +20261,7 @@ wine_fn_config_makefile libs/dxerr9 enable_dxerr9
wine_fn_config_makefile libs/dxguid enable_dxguid
wine_fn_config_makefile libs/gsm enable_gsm
wine_fn_config_makefile libs/jpeg enable_jpeg
wine_fn_config_makefile libs/jxr enable_jxr
wine_fn_config_makefile libs/lcms2 enable_lcms2
wine_fn_config_makefile libs/mfuuid enable_mfuuid
wine_fn_config_makefile libs/png enable_png
......
......@@ -1056,6 +1056,7 @@ dnl **** External libraries ****
WINE_EXTLIB_FLAGS(GSM, gsm, gsm, "-I\$(top_srcdir)/libs/gsm/inc")
WINE_EXTLIB_FLAGS(JPEG, jpeg, jpeg, "-I\$(top_srcdir)/libs/jpeg")
WINE_EXTLIB_FLAGS(JXR, jxr, jxr, "-I\$(top_srcdir)/libs/jxr/jxrgluelib -I\$(top_srcdir)/libs/jxr/image/sys")
WINE_EXTLIB_FLAGS(LCMS2, lcms2, lcms2, "-I\$(top_srcdir)/libs/lcms2/include")
WINE_EXTLIB_FLAGS(PNG, png, "png \$(ZLIB_PE_LIBS)", "-I\$(top_srcdir)/libs/png")
WINE_EXTLIB_FLAGS(TIFF, tiff, tiff, "-I\$(top_srcdir)/libs/tiff/libtiff")
......@@ -3705,6 +3706,7 @@ WINE_CONFIG_MAKEFILE(libs/dxerr9)
WINE_CONFIG_MAKEFILE(libs/dxguid)
WINE_CONFIG_MAKEFILE(libs/gsm)
WINE_CONFIG_MAKEFILE(libs/jpeg)
WINE_CONFIG_MAKEFILE(libs/jxr)
WINE_CONFIG_MAKEFILE(libs/lcms2)
WINE_CONFIG_MAKEFILE(libs/mfuuid)
WINE_CONFIG_MAKEFILE(libs/png)
......
Copyright © Microsoft Corp.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
• Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
• Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
EXTLIB = libjxr.a
EXTRAINCL = -I$(srcdir)/jxrgluelib -I$(srcdir)/image/sys -DDISABLE_PERF_MEASUREMENT
C_SRCS = \
image/decode/JXRTranscode.c \
image/decode/decode.c \
image/decode/postprocess.c \
image/decode/segdec.c \
image/decode/strInvTransform.c \
image/decode/strPredQuantDec.c \
image/decode/strdec.c \
image/encode/encode.c \
image/encode/segenc.c \
image/encode/strFwdTransform.c \
image/encode/strPredQuantEnc.c \
image/encode/strenc.c \
image/sys/adapthuff.c \
image/sys/image.c \
image/sys/strPredQuant.c \
image/sys/strTransform.c \
image/sys/strcodec.c \
jxrgluelib/JXRGlue.c \
jxrgluelib/JXRGlueJxr.c \
jxrgluelib/JXRGluePFC.c \
jxrgluelib/JXRMeta.c
//*@@@+++@@@@******************************************************************
//
// Copyright © Microsoft Corp.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// • Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// • Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//*@@@---@@@@******************************************************************
/******************************************************************************
Module Name:
decode.c
Abstract:
Defines the entry point for the console application.
Author:
Revision History:
*******************************************************************************/
#include "strcodec.h"
#include "decode.h"
#ifdef MEM_TRACE
#define TRACE_MALLOC 1
#define TRACE_NEW 0
#define TRACE_HEAP 0
#include "memtrace.h"
#endif
/******************************************************************
Free Adaptive Huffman Table
******************************************************************/
static Void CleanAH(CAdaptiveHuffman **ppAdHuff)
{
CAdaptiveHuffman *pAdHuff;
if (NULL != ppAdHuff) {
pAdHuff = *ppAdHuff;
if (NULL != pAdHuff) {
free(pAdHuff);
}
*ppAdHuff = NULL;
}
}
static Void CleanAHDec(CCodingContext * pSC)
{
Int kk;
for (kk = 0; kk < NUMVLCTABLES; kk++) {
CleanAH(&(pSC->m_pAHexpt[kk]));
}
CleanAH(&(pSC->m_pAdaptHuffCBPCY));
CleanAH(&(pSC->m_pAdaptHuffCBPCY1));
}
/*************************************************************************
Initialize an adaptive huffman table
*************************************************************************/
static Int InitializeAH(CAdaptiveHuffman **ppAdHuff, Int iSym)
{
Int iMemStatus = 0;
CAdaptiveHuffman *pAdHuff = Allocate(iSym, DECODER);
if (pAdHuff == NULL) {
iMemStatus = -1; // out of memory
goto ErrorExit;
}
//Adapt(pAdHuff, bFixedTables);
//InitHuffman(pAdHuff->m_pHuffman);
//if (ICERR_OK != initHuff(pAdHuff->m_pHuffman, 1, pAdHuff->m_pTable, NULL)) {
// goto ErrorExit;
//}
*ppAdHuff = pAdHuff;
return ICERR_OK;
ErrorExit:
if (pAdHuff) {
free(pAdHuff);
}
*ppAdHuff = NULL;
if (-1 == iMemStatus) {
printf("Insufficient memory to init decoder.\n");
}
return ICERR_ERROR;
}
/*************************************************************************
Context allocation
*************************************************************************/
Int AllocateCodingContextDec(CWMImageStrCodec *pSC, Int iNumContexts)
{
Int i, iCBPSize, k;
static const Int aAlphabet[] = {5,4,8,7,7, 12,6,6,12,6,6,7,7, 12,6,6,12,6,6,7,7};
if (iNumContexts > MAX_TILES || iNumContexts < 1) // only between 1 and MAX_TILES allowed
return ICERR_ERROR;
if (pSC == NULL)
return ICERR_ERROR;
pSC->m_pCodingContext = malloc (iNumContexts * sizeof (CCodingContext));
if (pSC->m_pCodingContext == NULL) {
pSC->cNumCodingContext = 0;
return ICERR_ERROR;
}
memset (pSC->m_pCodingContext, 0, iNumContexts * sizeof (CCodingContext));
pSC->cNumCodingContext = iNumContexts;
iCBPSize = (pSC->m_param.cfColorFormat == Y_ONLY || pSC->m_param.cfColorFormat == NCOMPONENT
|| pSC->m_param.cfColorFormat == CMYK) ? 5 : 9;
/** allocate / initialize members **/
for (i = 0; i < iNumContexts; i++) {
CCodingContext *pContext = &(pSC->m_pCodingContext[i]);
/** allocate adaptive Huffman encoder **/
if (InitializeAH(&pContext->m_pAdaptHuffCBPCY, iCBPSize) != ICERR_OK) {
return ICERR_ERROR;
}
if (InitializeAH(&pContext->m_pAdaptHuffCBPCY1, 5) != ICERR_OK) {
return ICERR_ERROR;
}
for(k = 0; k < NUMVLCTABLES; k ++){
if (InitializeAH(&pContext->m_pAHexpt[k], aAlphabet[k]) != ICERR_OK) {
return ICERR_ERROR;
}
}
ResetCodingContextDec(pContext);
}
return ICERR_OK;
}
/*************************************************************************
Context reset on encoder
*************************************************************************/
Void ResetCodingContextDec(CCodingContext *pContext)
{
Int k;
/** set flags **/
pContext->m_pAdaptHuffCBPCY->m_bInitialize = FALSE;
pContext->m_pAdaptHuffCBPCY1->m_bInitialize = FALSE;
for(k = 0; k < NUMVLCTABLES; k ++)
pContext->m_pAHexpt[k]->m_bInitialize = FALSE;
// reset VLC tables
AdaptLowpassDec (pContext);
AdaptHighpassDec (pContext);
// reset zigzag patterns, totals
InitZigzagScan(pContext);
// reset bit reduction and cbp models
ResetCodingContext(pContext);
}
/*************************************************************************
Context deletion
*************************************************************************/
Void FreeCodingContextDec(CWMImageStrCodec *pSC)
{
Int iContexts = (Int)(pSC->cNumCodingContext), i, k;
if (iContexts > 0 && pSC->m_pCodingContext) {
for (i = 0; i < iContexts; i++) {
CCodingContext *pContext = &(pSC->m_pCodingContext[i]);
CleanAH (&pContext->m_pAdaptHuffCBPCY);
CleanAH (&pContext->m_pAdaptHuffCBPCY1);
for (k = 0; k < NUMVLCTABLES; k++)
CleanAH (&pContext->m_pAHexpt[k]);
}
free (pSC->m_pCodingContext);
}
}
//*@@@+++@@@@******************************************************************
//
// Copyright © Microsoft Corp.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// • Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// • Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//*@@@---@@@@******************************************************************
#ifndef WMI_DECODE_H
#define WMI_DECODE_H
typedef struct CWMDecoderParameters {
/** ROI decode **/
Bool bDecodeFullFrame;
Bool bDecodeFullWidth;
/** thumbnail decode **/
Bool bSkipFlexbits;
size_t cThumbnailScale; // 1: cThumbnailScale thumbnail, only supports cThumbnailScale = 2^m for now
Bool bDecodeHP;
Bool bDecodeLP;
// Region of interest decoding
size_t cROILeftX;
size_t cROIRightX;
size_t cROITopY;
size_t cROIBottomY;
// table lookups for rotation and flip
size_t * pOffsetX;
size_t * pOffsetY;
} CWMDecoderParameters;
Void predCBPDec(CWMImageStrCodec *, CCodingContext *);
Void predDCACDec(CWMImageStrCodec *);
Void predACDec(CWMImageStrCodec *);
Int dequantizeMacroblock(CWMImageStrCodec *);
Int invTransformMacroblock(CWMImageStrCodec * pSC);
Int invTransformMacroblock_alteredOperators_hard(CWMImageStrCodec * pSC);
Int DecodeMacroblockDC(CWMImageStrCodec * pSC, CCodingContext *pContext, Int iMBX, Int iMBY);
Int DecodeMacroblockLowpass(CWMImageStrCodec * pSC, CCodingContext *pContext, Int iMBX, Int iMBY);
Int DecodeMacroblockHighpass(CWMImageStrCodec * pSC, CCodingContext *pContext, Int iMBX, Int iMBY);
Int AdaptLowpassDec(struct CCodingContext *);
Int AdaptHighpassDec(struct CCodingContext *);
Void ResetCodingContextDec(CCodingContext *pContext);
Void FreeCodingContextDec(struct CWMImageStrCodec *pSC);
/*************************************************************************/
// Inverse transform functions
// 2-point post filter for boundaries (only used in 420 UV DC subband)
Void strPost2(PixelI *, PixelI *);
// 2x2 post filter (only used in 420 UV DC subband)
Void strPost2x2(PixelI *, PixelI *, PixelI *, PixelI *);
/** 4-point post filter for boundaries **/
Void strPost4(PixelI *, PixelI *, PixelI *, PixelI *);
/** data allocation in working buffer (first stage) **/
/** Y, 444 U and V **/
/** 0 1 2 3 **/
/** 32 33 34 35 **/
/** 64 65 66 67 **/
/** 96 97 98 99 **/
/** 420 U and V **/
/** 0 2 4 6 **/
/** 64 66 68 70 **/
/** 128 130 132 134 **/
/** 192 194 196 198 **/
/** 4x4 inverse DCT for first stage **/
Void strIDCT4x4FirstStage(PixelI *);
Void strIDCT4x4Stage1(PixelI*);
Void strIDCT4x4FirstStage420UV(PixelI *);
/** 4x4 post filter for first stage **/
Void strPost4x4FirstStage(PixelI *);
Void strPost4x4Stage1Split(PixelI*, PixelI*, Int, Int, Bool);
Void strPost4x4Stage1(PixelI*, Int, Int, Bool);
Void strPost4x4Stage1Split_alternate(PixelI*, PixelI*, Int);
Void strPost4x4Stage1_alternate(PixelI*, Int);
//Void strPost4x4Stage1Split_420(PixelI*, PixelI*);
//Void strPost4x4Stage1_420(PixelI*);
Void strPost4x4FirstStage420UV(PixelI *);
/** data allocation in working buffer (second stage)**/
/** Y, 444 U and V **/
/** 0 4 8 12 **/
/** 128 132 136 140 **/
/** 256 260 264 268 **/
/** 384 388 392 396 **/
/** 420 U and V **/
/** 0 8 **/
/** 256 264 **/
/** 4x4 invesr DCT for second stage **/
//Void strIDCT4x4SecondStage(PixelI *);
Void strIDCT4x4Stage2(PixelI*);
Void strNormalizeDec(PixelI*, Bool);
Void strDCT2x2dnDec(PixelI *, PixelI *, PixelI *, PixelI *);
/** 4x4 post filter for second stage **/
Void strPost4x4SecondStage(PixelI *);
Void strPost4x4Stage2Split(PixelI*, PixelI*);
Void strPost4x4Stage2Split_alternate(PixelI*, PixelI*);
/** Huffman decode related defines **/
#define HUFFMAN_DECODE_ROOT_BITS_LOG 3
#define HUFFMAN_DECODE_ROOT_BITS (5)
Int getHuff(const short *pDecodeTable, BitIOInfo* pIO);
#endif // WMI_DECODE_H
This source diff could not be displayed because it is too large. You can view the blob instead.
//*@@@+++@@@@******************************************************************
//
// Copyright © Microsoft Corp.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// • Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// • Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//*@@@---@@@@******************************************************************
#include <stdio.h>
#include <stdlib.h>
#include "encode.h"
#include "strcodec.h"
#include "common.h"
#ifdef MEM_TRACE
#define TRACE_MALLOC 1
#define TRACE_NEW 0
#define TRACE_HEAP 0
#include "memtrace.h"
#endif
/*************************************************************************
Context allocation
In theory it is possible to independently set uiTrimFlexBits for
each tile, but for now we assume only one user specified value is
used for the entire image
*************************************************************************/
Int AllocateCodingContextEnc(CWMImageStrCodec *pSC, Int iNumContexts, Int iTrimFlexBits)
{
Int i, iCBPSize, k;
static const Int aAlphabet[] = {5,4,8,7,7, 12,6,6,12,6,6,7,7, 12,6,6,12,6,6,7,7};
if (iTrimFlexBits < 0)
iTrimFlexBits = 0;
else if (iTrimFlexBits > 15)
iTrimFlexBits = 15;
pSC->m_param.bTrimFlexbitsFlag = (iTrimFlexBits > 0);
if (iNumContexts < 1 || iNumContexts > MAX_TILES) // only between 1 and 256 allowed
return ICERR_ERROR;
if (pSC == NULL)
return ICERR_ERROR;
pSC->m_pCodingContext = malloc (iNumContexts * sizeof (CCodingContext));
if (pSC->m_pCodingContext == NULL) {
pSC->cNumCodingContext = 0;
return ICERR_ERROR;
}
memset (pSC->m_pCodingContext, 0, iNumContexts * sizeof (CCodingContext));
pSC->cNumCodingContext = iNumContexts;
iCBPSize = (pSC->m_param.cfColorFormat == Y_ONLY || pSC->m_param.cfColorFormat == NCOMPONENT
|| pSC->m_param.cfColorFormat == CMYK) ? 5 : 9;
/** allocate / initialize members **/
for (i = 0; i < iNumContexts; i++) {
CCodingContext *pContext = &(pSC->m_pCodingContext[i]);
/** allocate adaptive Huffman encoder **/
pContext->m_pAdaptHuffCBPCY = Allocate (iCBPSize, ENCODER);
if(pContext->m_pAdaptHuffCBPCY == NULL) {
return ICERR_ERROR;
}
pContext->m_pAdaptHuffCBPCY1 = Allocate(5, ENCODER);
if(pContext->m_pAdaptHuffCBPCY1 == NULL){
return ICERR_ERROR;
}
for(k = 0; k < NUMVLCTABLES; k ++){
pContext->m_pAHexpt[k] = Allocate(aAlphabet[k], ENCODER);
if(pContext->m_pAHexpt[k] == NULL){
return ICERR_ERROR;
}
}
ResetCodingContextEnc(pContext);
pContext->m_iTrimFlexBits = iTrimFlexBits;
}
return ICERR_OK;
}
/*************************************************************************
Context reset on encoder
*************************************************************************/
Void ResetCodingContextEnc(CCodingContext *pContext)
{
Int k;
/** set flags **/
pContext->m_pAdaptHuffCBPCY->m_bInitialize = FALSE;
pContext->m_pAdaptHuffCBPCY1->m_bInitialize = FALSE;
for(k = 0; k < NUMVLCTABLES; k ++)
pContext->m_pAHexpt[k]->m_bInitialize = FALSE;
// reset VLC tables
AdaptLowpassEnc (pContext);
AdaptHighpassEnc (pContext);
// reset zigzag patterns, totals
InitZigzagScan(pContext);
// reset bit reduction and cbp models
ResetCodingContext(pContext);
}
/*************************************************************************
Context deletion
*************************************************************************/
Void FreeCodingContextEnc(CWMImageStrCodec *pSC)
{
Int iContexts = (Int)(pSC->cNumCodingContext), i, k;
if (iContexts > 0 && pSC->m_pCodingContext) {
for (i = 0; i < iContexts; i++) {
CCodingContext *pContext = &(pSC->m_pCodingContext[i]);
Clean (pContext->m_pAdaptHuffCBPCY);
Clean (pContext->m_pAdaptHuffCBPCY1);
for (k = 0; k < NUMVLCTABLES; k++)
Clean (pContext->m_pAHexpt[k]);
}
free (pSC->m_pCodingContext);
}
}
//*@@@+++@@@@******************************************************************
//
// Copyright © Microsoft Corp.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// • Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// • Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//*@@@---@@@@******************************************************************
#ifndef WMI_ENCODE_H
#define WMI_ENCODE_H
#include "strcodec.h"
/*************************************************************************
struct / class definitions
*************************************************************************/
Int EncodeMacroblockDC(CWMImageStrCodec*, CCodingContext *, Int, Int);
Int EncodeMacroblockLowpass(CWMImageStrCodec*, CCodingContext *, Int, Int);
Int EncodeMacroblockHighpass(CWMImageStrCodec*, CCodingContext *, Int, Int);
Int quantizeMacroblock(CWMImageStrCodec *);
Void transformMacroblock(CWMImageStrCodec *);
Void predMacroblockEnc(CWMImageStrCodec *);
Void AdaptLowpassEnc(CCodingContext *pContext);
Void AdaptHighpassEnc(CCodingContext *pContext);
Void ResetCodingContextEnc(CCodingContext *pContext);
Int AllocateCodingContextEnc(struct CWMImageStrCodec *pSC, Int iNumContexts, Int iTrimFlexBits);
Void FreeCodingContextEnc(struct CWMImageStrCodec *pSC);
Void predCBPEnc(CWMImageStrCodec *pSC, CCodingContext *pContext);
/*************************************************************************
Forward transform definitions
*************************************************************************/
/** 2-point pre filter for boundaries (only used in 420 UV DC subband) **/
Void strPre2(PixelI *, PixelI *);
/** 2x2 pre filter (only used in 420 UV DC subband) **/
Void strPre2x2(PixelI *, PixelI *, PixelI *, PixelI *);
/** 4-point pre filter for boundaries **/
Void strPre4(PixelI *, PixelI *, PixelI *, PixelI *);
/** data allocation in working buffer (first stage) **/
/** Y, 444 U and V **/
/** 0 1 2 3 **/
/** 32 33 34 35 **/
/** 64 65 66 67 **/
/** 96 97 98 99 **/
/** 420 U and V **/
/** 0 2 4 6 **/
/** 64 66 68 70 **/
/** 128 130 132 134 **/
/** 192 194 196 198 **/
/** 4x4 foward DCT for first stage **/
Void strDCT4x4FirstStage(PixelI *);
Void strDCT4x4FirstStage420UV(PixelI *);
Void strDCT4x4Stage1(PixelI*);
/** 4x4 pre filter for first stage **/
Void strPre4x4FirstStage(PixelI *);
Void strPre4x4FirstStage420UV(PixelI *);
Void strPre4x4Stage1Split(PixelI* p0, PixelI* p1, Int iOffset);
Void strPre4x4Stage1(PixelI* p, Int iOffset);
/** data allocation in working buffer (second stage)**/
/** Y, 444 U and V **/
/** 0 4 8 12 **/
/** 128 132 136 140 **/
/** 256 260 264 268 **/
/** 384 388 392 396 **/
/** 420 U and V **/
/** 0 8 **/
/** 256 264 **/
/** 4x4 foward DCT for second stage **/
Void strDCT4x4SecondStage(PixelI *);
Void strNormalizeEnc(PixelI *, Bool);
Void strDCT2x2dnEnc(PixelI *, PixelI *, PixelI *, PixelI *);
/** 4x4 pre filter for second stage **/
Void strPre4x4Stage2Split(PixelI* p0, PixelI* p1);
#endif // ENCODE_H
//*@@@+++@@@@******************************************************************
//
// Copyright © Microsoft Corp.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// • Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// • Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//*@@@---@@@@******************************************************************
#pragma once
//================================
// bitio functions
//================================
#define PACKETLENGTH (1U<<12) // 4kB
#define readIS_L1(pSC, pIO) readIS(pSC, pIO)
#define readIS_L2(pSC, pIO) (void)(pSC, pIO)
#define writeIS_L1(pSC, pIO) writeIS(pSC, pIO)
#define writeIS_L2(pSC, pIO) (void)(pSC, pIO)
//================================
// common defines
//================================
#define FORCE_INLINE
#define CDECL
#if __LP64__
#define UINTPTR_T unsigned long long
#define INTPTR_T long long
#else
#define UINTPTR_T unsigned int
#define INTPTR_T int
#endif
//================================
// quantization optimization
//================================
//#define RECIP_QUANT_OPT
//*@@@+++@@@@******************************************************************
//
// Copyright © Microsoft Corp.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// • Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// • Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//*@@@---@@@@******************************************************************
#ifndef WMI_COMMON_H
#define WMI_COMMON_H
/*************************************************************************
// Common typedef's
*************************************************************************/
typedef enum { ENCODER = 0, DECODER = 1 } CODINGMODE;
typedef enum tagBand
{
BAND_HEADER = 0,
BAND_DC = 1,
BAND_LP = 2,
BAND_AC = 3,
BAND_FL = 4
} BAND;
/*************************************************************************
struct / class definitions
*************************************************************************/
//#define SIGNATURE_BYTES 8 // Bytes for GDI+ signature
#define CODEC_VERSION 1
#define CODEC_SUBVERSION 0
#define CODEC_SUBVERSION_NEWSCALING_SOFT_TILES 1
#define CODEC_SUBVERSION_NEWSCALING_HARD_TILES 9
#define CONTEXTX 8
#define CTDC 5
#define NUMVLCTABLES 21 // CONTEXTX * 2 + CTDC
#define AVG_NDIFF 3
#define MAXTOTAL 32767 // 511 should be enough
/** Quantization related defines **/
#define SHIFTZERO 1 /* >= 0 */
#define QPFRACBITS 2 /* or 0 only supported */
/** adaptive huffman encoding / decoding struct **/
typedef struct CAdaptiveHuffman
{
Int m_iNSymbols;
const Int *m_pTable;
const Int *m_pDelta, *m_pDelta1;
Int m_iTableIndex;
const short *m_hufDecTable;
Bool m_bInitialize;
//Char m_pLabel[8]; // for debugging - label attached to constructor
Int m_iDiscriminant, m_iDiscriminant1;
Int m_iUpperBound;
Int m_iLowerBound;
} CAdaptiveHuffman;
/************************************************************************************
Context structures
************************************************************************************/
typedef struct CAdaptiveModel {
Int m_iFlcState[2];
Int m_iFlcBits[2];
BAND m_band;
} CAdaptiveModel;
typedef struct CCBPModel {
Int m_iCount0[2];
Int m_iCount1[2];
Int m_iState[2];
} CCBPModel;
/*************************************************************************
globals
*************************************************************************/
extern Int grgiZigzagInv4x4_lowpass[];
extern Int grgiZigzagInv4x4H[];
extern Int grgiZigzagInv4x4V[];
extern const Int gSignificantRunBin[];
extern const Int gSignificantRunFixedLength[];
static const Int cblkChromas[] = {0,4,8,16, 16,16,16, 0,0};
/*************************************************************************
function declarations
*************************************************************************/
// common utilities
Void Clean (CAdaptiveHuffman *pAdHuff);
CAdaptiveHuffman *Allocate (Int iNSymbols, CODINGMODE cm);
/* Timing functions */
void reset_timing(double *time);
void report_timing(const char *s, double time);
// static double timeperclock;
/** adaptive model functions **/
Void UpdateModelMB (COLORFORMAT cf, Int iChannels, Int iLaplacianMean[], CAdaptiveModel *m_pModel);
/** adaptive huffman encoder / decoder functions **/
Void Adapt (CAdaptiveHuffman *pAdHuff, Bool bFixedTables);
Void AdaptFixed (CAdaptiveHuffman *pAdHuff);
Void AdaptDiscriminant (CAdaptiveHuffman *pAdHuff);
#ifndef _PREFAST_
#pragma warning(disable:4068)
#endif
#endif // WMI_COMMON_H
//*@@@+++@@@@******************************************************************
//
// Copyright © Microsoft Corp.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// • Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// • Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//*@@@---@@@@******************************************************************
#include "strcodec.h"
// #include "xplatform_image.h"
#ifdef MEM_TRACE
#define TRACE_MALLOC 1
#define TRACE_NEW 0
#define TRACE_HEAP 0
#include "memtrace.h"
#endif
#include <stdlib.h>
#include <string.h>
#if !(defined(__ANSI__))
// Desktop
#include <windows.h>
#else
// ANSI
#include <time.h>
#endif
Int grgiZigzagInv4x4_lowpass [] = {
0, 1, 4, 5, 2, 8, 6, 9,
3, 12, 10, 7, 13, 11, 14, 15
};
Int grgiZigzagInv4x4H [] = {
0, 1, 4, 5, 2, 8, 6, 9,
3, 12, 10, 7, 13, 11, 14, 15
};
Int grgiZigzagInv4x4V [] = {
0, 4, 8, 5, 1, 12, 9, 6, 2, 13, 3, 15, 7, 10, 14, 11
};
const Int gSignificantRunBin[] = {
-1,-1,-1,-1,
2,2,2,
1,1,1,1,
0,0,0,0
};
const Int gSignificantRunFixedLength[] = {
0,0,1,1,3,
0,0,1,1,2,
0,0,0,0,1,
};
/*************************************************************************
UpdateModelMB : update adaptive model at end of macroblock
(for lowest resolution only)
*************************************************************************/
#define MODELWEIGHT 70//90
Void UpdateModelMB (COLORFORMAT cf, Int iChannels, Int iLaplacianMean[], CAdaptiveModel *pModel)
{
Int j;
static const Int aWeight0[3] = { 240/*DC*/, 12/*LP*/, 1 };
static const Int aWeight1[3][MAX_CHANNELS] = {
{ 0,240,120,80, 60,48,40,34, 30,27,24,22, 20,18,17,16 },
{ 0,12,6,4, 3,2,2,2, 2,1,1,1, 1,1,1,1 },
{ 0,16,8,5, 4,3,3,2, 2,2,2,1, 1,1,1,1 }
};
static const Int aWeight2[6] = { 120,37,2,/*420*/ 120,18,1/*422*/ };
iLaplacianMean[0] *= aWeight0[pModel->m_band - BAND_DC];
if (cf == YUV_420) {
iLaplacianMean[1] *= aWeight2[pModel->m_band - BAND_DC];
}
else if (cf == YUV_422) {
iLaplacianMean[1] *= aWeight2[3 + (pModel->m_band) - BAND_DC];
}
else {
iLaplacianMean[1] *= aWeight1[pModel->m_band - BAND_DC][iChannels - 1];
if (pModel->m_band == BAND_AC)
iLaplacianMean[1] >>= 4;
}
for (j = 0; j < 2; j++) {
Int iLM = iLaplacianMean[j];
Int iMS = pModel->m_iFlcState[j];
Int iDelta = (iLM - MODELWEIGHT) >> 2;
if (iDelta <= -8) {
iDelta += 4;
if (iDelta < -16)
iDelta = -16;
iMS += iDelta;
if (iMS < -8) {
if (pModel->m_iFlcBits[j] == 0)
iMS = -8;
else {
iMS = 0;
pModel->m_iFlcBits[j]--;
}
}
}
else if (iDelta >= 8) {
iDelta -= 4;
if (iDelta > 15)
iDelta = 15;
iMS += iDelta;
if (iMS > 8) {
if (pModel->m_iFlcBits[j] >= 15) {
pModel->m_iFlcBits[j] = 15;
iMS = 8;
}
else {
iMS = 0;
pModel->m_iFlcBits[j]++;
}
}
}
pModel->m_iFlcState[j] = iMS;
if (cf == Y_ONLY)
break;
}
}
Void ResetCodingContext(CCodingContext *pContext)
{
// reset bit reduction models
memset (&(pContext->m_aModelAC), 0, sizeof(CAdaptiveModel));
pContext->m_aModelAC.m_band = BAND_AC;
memset (&(pContext->m_aModelLP), 0, sizeof(CAdaptiveModel));
pContext->m_aModelLP.m_band = BAND_LP;
pContext->m_aModelLP.m_iFlcBits[0] = pContext->m_aModelLP.m_iFlcBits[1] = 4;
memset (&(pContext->m_aModelDC), 0, sizeof(CAdaptiveModel));
pContext->m_aModelDC.m_band = BAND_DC;
pContext->m_aModelDC.m_iFlcBits[0] = pContext->m_aModelDC.m_iFlcBits[1] = 8;
// reset CBP models
pContext->m_iCBPCountMax = pContext->m_iCBPCountZero = 1;
pContext->m_aCBPModel.m_iCount0[0] = pContext->m_aCBPModel.m_iCount0[1] = -4;
pContext->m_aCBPModel.m_iCount1[0] = pContext->m_aCBPModel.m_iCount1[1] = 4;
pContext->m_aCBPModel.m_iState[0] = pContext->m_aCBPModel.m_iState[1] = 0;
}
/*************************************************************************
Initialize zigzag scan parameters
*************************************************************************/
Void InitZigzagScan(CCodingContext * pContext)
{
if (NULL != pContext) {
Int i;
for (i=0; i<16; i++) {
pContext->m_aScanLowpass[i].uScan = grgiZigzagInv4x4_lowpass[i];
pContext->m_aScanHoriz[i].uScan = dctIndex[0][grgiZigzagInv4x4H[i]];
pContext->m_aScanVert[i].uScan = dctIndex[0][grgiZigzagInv4x4V[i]];
}
}
}
//*@@@+++@@@@******************************************************************
//
// Copyright © Microsoft Corp.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// • Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// • Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//*@@@---@@@@******************************************************************
#ifndef __PERFTIMER_H_
#define __PERFTIMER_H_
//***************************************************************************
// Description
//
// Performance timer API used to measure codec performance. The underlying
// implementation of this API may vary - from ANSI-C implementation via clock,
// Win32 implementation via QueryPerformanceCounter or GetProcessTimes. At
// present we only support one implementation of this PerfTimer "object".
// You choose the implementation by choosing which one of the many files
// to compile and link with your application.
//***************************************************************************
#ifdef DISABLE_PERF_MEASUREMENT
#define PERFTIMER_ONLY(code)
#define PERFTIMER_NEW(fPerf, ppPerfTimer)
#define PERFTIMER_DELETE(fPerf, ppPerfTimer)
#define PERFTIMER_START(fPerf, pPerfTimer)
#define PERFTIMER_STOP(fPerf, pPerfTimer)
#define PERFTIMER_GETRESULTS(fPerf, pPerfTimer, pResults)
#define PERFTIMER_COPYSTARTTIME(fPerf, pDst, pSrc)
#define PERFTIMER_REPORT(fPerf, pCodec)
#else // DISABLE_PERF_MEASUREMENT
#define PERFTIMER_ONLY(code) code
#define PERFTIMER_NEW(fPerf, ppPerfTimer) if (fPerf) {Bool b = b = PerfTimerNew(ppPerfTimer); assert(b);};
#define PERFTIMER_DELETE(fPerf, pPerfTimer) if (fPerf) {PerfTimerDelete(pPerfTimer);};
#define PERFTIMER_START(fPerf, pPerfTimer) if (fPerf) {Bool b = b = PerfTimerStart(pPerfTimer); assert(b);};
#define PERFTIMER_STOP(fPerf, pPerfTimer) if (fPerf) {Bool b = b = PerfTimerStop(pPerfTimer); assert(b);};
#define PERFTIMER_GETRESULTS(fPerf, pPerfTimer, pResults) \
if (fPerf) {Bool b = b = PerfTimerGetResults((pPerfTimer), (pResults)); assert(b);};
#define PERFTIMER_COPYSTARTTIME(fPerf, pDst, pSrc) \
if (fPerf) {Bool b = b = PerfTimerCopyStartTime((pDst), (pSrc)); assert(b);};
#define PERFTIMER_REPORT(fPerf, pCodec) \
if (fPerf) {OutputPerfTimerReport(pCodec);};
#endif // DISABLE_PERF_MEASUREMENT
//***************************************************************************
// Data Types
//***************************************************************************
typedef U64 PERFTIMERTIME;
typedef struct PERFTIMERRESULTS
{
PERFTIMERTIME iElapsedTime; // In nanoseconds or CPU cycles
PERFTIMERTIME iTicksPerSecond; // Number of ticks per second (clock frequency)
PERFTIMERTIME iZeroTimeIntervals; // Number of zero-time intervals.
// Presence of zero-time intervals may indicate insufficient clock precision
} PERFTIMERRESULTS;
#define NANOSECONDS_PER_SECOND 1000000000
//***************************************************************************
// Data Declarations
//***************************************************************************
typedef enum
{
CS_UNINIT,
CS_RUNNING,
CS_STOPPED,
} CLOCKSTATE;
typedef struct PERFTIMERSTATE
{
CLOCKSTATE eState;
PERFTIMERTIME iElapsedTime;
PERFTIMERTIME iPrevStartTime;
PERFTIMERTIME iZeroTimeIntervals;
} PERFTIMERSTATE;
//***************************************************************************
// Functions and Macros
//***************************************************************************
Bool PerfTimerNew(PERFTIMERSTATE **ppNewPerfTimer);
void PerfTimerDelete(PERFTIMERSTATE *pThisPerfTimer);
Bool PerfTimerStart(PERFTIMERSTATE *pThisPerfTimer);
Bool PerfTimerStop(PERFTIMERSTATE *pThisPerfTimer);
Bool PerfTimerGetResults(PERFTIMERSTATE *pThisPerfTimer,
PERFTIMERRESULTS *pPerfTimerResults);
Bool PerfTimerCopyStartTime(PERFTIMERSTATE *pDestPerfTimer,
PERFTIMERSTATE *pSrcPerfTimer);
#endif // __PERFTIMER_H_
//*@@@+++@@@@******************************************************************
//
// Copyright © Microsoft Corp.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// • Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// • Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//*@@@---@@@@******************************************************************
#include "strTransform.h"
/** need to swap b and c **/
/** rounding behavior: [0 0 0 0] <-> [+ - - -]
[+ + + +] <-> [+3/4 - - -]
[- - - -] <-> [- - - -] **/
Void strDCT2x2dn(PixelI *pa, PixelI *pb, PixelI *pc, PixelI *pd)
{
PixelI a, b, c, d, C, t;
a = *pa;
b = *pb;
C = *pc;
d = *pd;
a += d;
b -= C;
t = ((a - b) >> 1);
c = t - d;
d = t - C;
a -= d;
b += c;
*pa = a;
*pb = b;
*pc = c;
*pd = d;
}
Void strDCT2x2up(PixelI *pa, PixelI *pb, PixelI *pc, PixelI *pd)
{
PixelI a, b, c, d, C, t;
a = *pa;
b = *pb;
C = *pc;
d = *pd;
a += d;
b -= C;
t = ((a - b + 1) >> 1);
c = t - d;
d = t - C;
a -= d;
b += c;
*pa = a;
*pb = b;
*pc = c;
*pd = d;
}
Void FOURBUTTERFLY_HARDCODED1(PixelI *p)
{
strDCT2x2dn(&p[0], &p[4], &p[8], &p[12]);
strDCT2x2dn(&p[1], &p[5], &p[9], &p[13]);
strDCT2x2dn(&p[2], &p[6], &p[10], &p[14]);
strDCT2x2dn(&p[3], &p[7], &p[11], &p[15]);
}
//*@@@+++@@@@******************************************************************
//
// Copyright © Microsoft Corp.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// • Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// • Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//*@@@---@@@@******************************************************************
#ifndef WMI_STRTRANSFORM_H
#define WMI_STRTRANSFORM_H
#include "windowsmediaphoto.h"
#define COMPUTE_CORNER_PRED_DIFF(a, b) (*(a) -= (b))
#define COMPUTE_CORNER_PRED_ADD(a, b) (*(a) += (b))
/** 2x2 foward DCT == 2x2 inverse DCT **/
Void strDCT2x2dn(PixelI *, PixelI *, PixelI *, PixelI *);
Void strDCT2x2up(PixelI *, PixelI *, PixelI *, PixelI *);
Void FOURBUTTERFLY_HARDCODED1(PixelI *p);
/** 2x2 dct of a group of 4**/
#define FOURBUTTERFLY(p, i00, i01, i02, i03, i10, i11, i12, i13,\
i20, i21, i22, i23, i30, i31, i32, i33) \
strDCT2x2dn(&p[i00], &p[i01], &p[i02], &p[i03]); \
strDCT2x2dn(&p[i10], &p[i11], &p[i12], &p[i13]); \
strDCT2x2dn(&p[i20], &p[i21], &p[i22], &p[i23]); \
strDCT2x2dn(&p[i30], &p[i31], &p[i32], &p[i33])
#endif // WMI_STRTRANSFORM_H
//*@@@+++@@@@******************************************************************
//
// Copyright © Microsoft Corp.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// • Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// • Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//*@@@---@@@@******************************************************************
#ifndef XPLATFORM_IMAGE_H
#define XPLATFORM_IMAGE_H
#ifdef __ANSI__
// ANSI
#define FORCE_INLINE
#define CDECL
#define UINTPTR_T unsigned int
#define INTPTR_T int
#define DECLSPEC_ALIGN(bytes)
#endif // __ANSI__
//#if defined(WIN32)
#if defined(WIN32) && !defined(UNDER_CE) // WIN32 seems to be defined always in VS2005 for ARM platform
// x86
//#define CDECL __cdecl
#define DECLSPEC_ALIGN(bytes) __declspec(align(bytes))
#endif // x86
#if defined(_ARM_) || defined(UNDER_CE)
// ARM, WinCE
#define FORCE_INLINE inline
#define CDECL
#define UINTPTR_T unsigned int
#define INTPTR_T int
#define DECLSPEC_ALIGN(bytes)
// parser
#define FULL_PATH_CONFIG_FILE_ENCODE "\\ConfigFile_encode.txt"
#define FULL_PATH_CONFIG_FILE_DECODE "\\ConfigFile_decode.txt"
#define MAX_ARGC 14
#define MaxCharReadCount 10
#define MAX_FNAME 256
#define DELIMITER "filelist:"
#define CODEC_ENCODE "encode"
#define CODEC_DECODE "decode"
#define PHOTON "ptn"
#define OUTRAW "raw"
#define OUTBMP "bmp"
#define OUTPPM "ppm"
#define OUTTIF "tif"
#define OUTHDR "hdr"
#define OUTIYUV "iyuv"
#define OUTYUV422 "yuv422"
#define OUTYUV444 "yuv444"
int XPLATparser(char *pcARGV[], char *pcCodec);
void freeXPLATparser(int iARGC, char *pcARGV[]);
// WinCE intrinsic
#include <Cmnintrin.h>
#endif // ARM, WinCE
#endif // XPLATFORM_IMAGE_H
//*@@@+++@@@@******************************************************************
//
// Copyright © Microsoft Corp.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// • Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// • Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//*@@@---@@@@******************************************************************
#pragma once
#include <assert.h>
#include <windows.h>
//================================
// bitio functions
//================================
#define PACKETLENGTH (1U<<12) // 4kB
#define readIS_L1(pSC, pIO) readIS(pSC, pIO)
#define readIS_L2(pSC, pIO) (void)(pSC, pIO)
#define writeIS_L1(pSC, pIO) writeIS(pSC, pIO)
#define writeIS_L2(pSC, pIO) (void)(pSC, pIO)
//================================
// common defines
//================================
#define FORCE_INLINE __forceinline
#define UINTPTR_T uintptr_t
#define INTPTR_T intptr_t
//================================
// quantization optimization
//================================
#define RECIP_QUANT_OPT
//*@@@+++@@@@******************************************************************
//
// Copyright © Microsoft Corp.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// • Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// • Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//*@@@---@@@@******************************************************************
#pragma once
#include <windowsmediaphoto.h>
#ifndef WIN32
#include <wmspecstring.h>
#endif
#ifndef UNREFERENCED_PARAMETER
#define UNREFERENCED_PARAMETER(P) { (P) = (P); }
#endif
//================================================================
// Container
//================================================================
// Keep these in sort order so that we can easily confirm we are outputting tags in ascending order
#define WMP_tagNull 0
#define WMP_tagDocumentName 0x010d // Descriptive metadata tag
#define WMP_tagImageDescription 0x010e // Descriptive metadata tag
#define WMP_tagCameraMake 0x010f // Descriptive metadata tag
#define WMP_tagCameraModel 0x0110 // Descriptive metadata tag
#define WMP_tagPageName 0x011d // Descriptive metadata tag
#define WMP_tagPageNumber 0x0129 // Descriptive metadata tag
#define WMP_tagSoftware 0x0131 // Descriptive metadata tag
#define WMP_tagDateTime 0x0132 // Descriptive metadata tag
#define WMP_tagArtist 0x013b // Descriptive metadata tag
#define WMP_tagHostComputer 0x013c // Descriptive metadata tag
#define WMP_tagXMPMetadata 0x02bc
#define WMP_tagRatingStars 0x4746 // Descriptive metadata tag
#define WMP_tagRatingValue 0x4749 // Descriptive metadata tag
#define WMP_tagCopyright 0x8298 // Descriptive metadata tag
#define WMP_tagEXIFMetadata 0x8769
#define WMP_tagGPSInfoMetadata 0x8825
#define WMP_tagIPTCNAAMetadata 0x83bb
#define WMP_tagPhotoshopMetadata 0x8649
#define WMP_tagInteroperabilityIFD 0xa005
#define WMP_tagIccProfile 0x8773 // Need to use same tag as TIFF!!
#define WMP_tagCaption 0x9c9b // Descriptive metadata tag
#define WMP_tagPixelFormat 0xbc01
#define WMP_tagTransformation 0xbc02
#define WMP_tagCompression 0xbc03
#define WMP_tagImageType 0xbc04
#define WMP_tagImageWidth 0xbc80
#define WMP_tagImageHeight 0xbc81
#define WMP_tagWidthResolution 0xbc82
#define WMP_tagHeightResolution 0xbc83
#define WMP_tagImageOffset 0xbcc0
#define WMP_tagImageByteCount 0xbcc1
#define WMP_tagAlphaOffset 0xbcc2
#define WMP_tagAlphaByteCount 0xbcc3
#define WMP_tagImageDataDiscard 0xbcc4
#define WMP_tagAlphaDataDiscard 0xbcc5
#define WMP_typBYTE 1
#define WMP_typASCII 2
#define WMP_typSHORT 3
#define WMP_typLONG 4
#define WMP_typRATIONAL 5
#define WMP_typSBYTE 6
#define WMP_typUNDEFINED 7
#define WMP_typSSHORT 8
#define WMP_typSLONG 9
#define WMP_typSRATIONAL 10
#define WMP_typFLOAT 11
#define WMP_typDOUBLE 12
#define WMP_valCompression 0xbc
#define WMP_valWMPhotoID WMP_valCompression
#ifdef WIN32
#define __in_win __in
#define __out_win __out
#endif
//================================================================
typedef enum
{
DPKVT_EMPTY = 0,
DPKVT_UI1 = 17,
DPKVT_UI2 = 18,
DPKVT_UI4 = 19,
DPKVT_LPSTR = 30,
DPKVT_LPWSTR = 31,
DPKVT_BYREF = 0x4000,
} DPKVARTYPE;
typedef struct DPKPROPVARIANT
{
DPKVARTYPE vt;
union
{
U8 bVal; // DPKVT_UI1
U16 uiVal; // DPKVT_UI2
U32 ulVal; // DPKVT_UI4
char *pszVal; // DPKVT_LPSTR
U16 *pwszVal; // DPKVT_LPWSTR
U8 *pbVal; // DPKVT_BYREF | DPKVT_UI1
} VT;
} DPKPROPVARIANT;
typedef struct DESCRIPTIVEMETADATA
{
DPKPROPVARIANT pvarImageDescription; // WMP_tagImageDescription
DPKPROPVARIANT pvarCameraMake; // WMP_tagCameraMake
DPKPROPVARIANT pvarCameraModel; // WMP_tagCameraModel
DPKPROPVARIANT pvarSoftware; // WMP_tagSoftware
DPKPROPVARIANT pvarDateTime; // WMP_tagDateTime
DPKPROPVARIANT pvarArtist; // WMP_tagArtist
DPKPROPVARIANT pvarCopyright; // WMP_tagCopyright
DPKPROPVARIANT pvarRatingStars; // WMP_tagRatingStars
DPKPROPVARIANT pvarRatingValue; // WMP_tagRatingValue
DPKPROPVARIANT pvarCaption; // WMP_tagCaption
DPKPROPVARIANT pvarDocumentName; // WMP_tagDocumentName
DPKPROPVARIANT pvarPageName; // WMP_tagPageName
DPKPROPVARIANT pvarPageNumber; // WMP_tagPageNumber
DPKPROPVARIANT pvarHostComputer; // WMP_tagHostComputer
} DESCRIPTIVEMETADATA;
typedef struct tagWmpDE
{
U16 uTag;
U16 uType;
U32 uCount;
U32 uValueOrOffset;
} WmpDE;
typedef struct tagWmpDEMisc
{
U32 uImageOffset;
U32 uImageByteCount;
U32 uAlphaOffset;
U32 uAlphaByteCount;
U32 uOffPixelFormat;
U32 uOffImageByteCount;
U32 uOffAlphaOffset;
U32 uOffAlphaByteCount;
U32 uColorProfileOffset;
U32 uColorProfileByteCount;
U32 uXMPMetadataOffset;
U32 uXMPMetadataByteCount;
U32 uEXIFMetadataOffset;
U32 uEXIFMetadataByteCount;
U32 uGPSInfoMetadataOffset;
U32 uGPSInfoMetadataByteCount;
U32 uIPTCNAAMetadataOffset;
U32 uIPTCNAAMetadataByteCount;
U32 uPhotoshopMetadataOffset;
U32 uPhotoshopMetadataByteCount;
U32 uDescMetadataOffset;
U32 uDescMetadataByteCount;
} WmpDEMisc;
//================================================================
EXTERN_C ERR GetUShort(
__in_ecount(1) struct WMPStream* pWS,
size_t offPos,
__out_ecount(1) U16* puValue
);
EXTERN_C ERR PutUShort(
__in_ecount(1) struct WMPStream* pWS,
size_t offPos,
U16 uValue
);
EXTERN_C ERR GetULong(
__in_ecount(1) struct WMPStream* pWS,
size_t offPos,
__out_ecount(1) U32* puValue
);
EXTERN_C ERR PutULong(
__in_ecount(1) struct WMPStream* pWS,
size_t offPos,
U32 uValue
);
EXTERN_C ERR WriteWmpDE(
__in_ecount(1) struct WMPStream* pWS,
size_t *pOffPos,
const __in_ecount(1) WmpDE* pDE,
const U8 *pbData,
U32 *pcbDataWrittenToOffset
);
EXTERN_C ERR ReadPropvar(__in_ecount(1) struct WMPStream* pWS,
const __in_win U16 uType,
const __in_win U32 uCount,
const __in_win U32 uValue,
__out_win DPKPROPVARIANT *pvar);
// read and write little endian words/dwords from a buffer on both big and little endian cpu's
// with full buffer overflow checking
#define WMP_INTEL_ENDIAN ('I')
EXTERN_C ERR getbfcpy(U8* pbdest, const U8* pb, size_t cb, size_t ofs, U32 n);
EXTERN_C ERR getbfw(const U8* pb, size_t cb, size_t ofs, U16* pw);
EXTERN_C ERR getbfdw(const U8* pb, size_t cb, size_t ofs, U32* pdw);
EXTERN_C ERR getbfwbig(const U8* pb, size_t cb, size_t ofs, U16* pw);
EXTERN_C ERR getbfdwbig(const U8* pb, size_t cb, size_t ofs, U32* pdw);
EXTERN_C ERR getbfwe(const U8* pb, size_t cb, size_t ofs, U16* pw, U8 endian);
EXTERN_C ERR getbfdwe(const U8* pb, size_t cb, size_t ofs, U32* pdw, U8 endian);
EXTERN_C ERR setbfcpy(U8* pb, size_t cb, size_t ofs, const U8* pbset, size_t cbset);
EXTERN_C ERR setbfw(U8* pb, size_t cb, size_t ofs, U16 dw);
EXTERN_C ERR setbfdw(U8* pb, size_t cb, size_t ofs, U32 dw);
EXTERN_C ERR setbfwbig(U8* pb, size_t cb, size_t ofs, U16 dw);
EXTERN_C ERR setbfdwbig(U8* pb, size_t cb, size_t ofs, U32 dw);
EXTERN_C ERR BufferCalcIFDSize(const U8* pb, size_t cb, U32 uIFDOfs, U8 endian, U32 *pcbifd);
EXTERN_C ERR StreamCalcIFDSize(struct WMPStream* pWS, U32 uIFDOfs, U32 *pcbifd);
EXTERN_C ERR BufferCopyIFD(const U8* pbsrc, U32 cbsrc, U32 ofssrc, U8 endian, U8* pbdest, U32 cbdest, U32* pofsdest);
EXTERN_C ERR StreamCopyIFD(struct WMPStream* pWS, U32 ofssrc, U8* pbdest, U32 cbdest, U32* pofsdest);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment