Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/libs/jxr/image/sys/strcodec.h
4393 views
1
//*@@@+++@@@@******************************************************************
2
//
3
// Copyright © Microsoft Corp.
4
// All rights reserved.
5
//
6
// Redistribution and use in source and binary forms, with or without
7
// modification, are permitted provided that the following conditions are met:
8
//
9
// • Redistributions of source code must retain the above copyright notice,
10
// this list of conditions and the following disclaimer.
11
// • Redistributions in binary form must reproduce the above copyright notice,
12
// this list of conditions and the following disclaimer in the documentation
13
// and/or other materials provided with the distribution.
14
//
15
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25
// POSSIBILITY OF SUCH DAMAGE.
26
//
27
//*@@@---@@@@******************************************************************
28
#pragma once
29
30
#include <stddef.h>
31
32
#include "windowsmediaphoto.h"
33
#include "common.h"
34
// #include "xplatform_image.h"
35
36
// added for Xcode PK universal binary
37
#ifdef __ppc__
38
#define _BIG__ENDIAN_
39
#endif
40
41
//================================================================
42
#ifdef ENABLE_OPTIMIZATIONS
43
#if defined(WIN32) && !defined(_WIN64)
44
#define WMP_OPT_SSE2
45
46
#define WMP_OPT_CC_ENC
47
//#define WMP_OPT_TRFM_ENC
48
//#define WMP_OPT_QT
49
50
#define WMP_OPT_CC_DEC
51
#define WMP_OPT_TRFM_DEC
52
53
#define X86OPT_INLINE
54
55
#endif
56
#endif // ENABLE_OPTIMIZATIONS
57
58
//================================================================
59
//#ifdef WIN32
60
#if defined(WIN32) && !defined(UNDER_CE) // WIN32 seems to be defined always in VS2005 for ARM platform
61
#define PLATFORM_X86
62
#include "../x86/x86.h"
63
#endif
64
65
#ifndef UNREFERENCED_PARAMETER
66
#define UNREFERENCED_PARAMETER(P) { (P) = (P); }
67
#endif
68
69
#ifdef UNDER_CE
70
#define PLATFORM_WCE
71
#include "arm.h"
72
#endif
73
74
#ifdef __ANSI__
75
#define PLATFORM_ANSI
76
#include "ansi.h"
77
#endif
78
79
//================================================================
80
81
#ifdef PLATFORM_ANSI
82
typedef unsigned long long U64;
83
#else // PLATFORM_ANSI
84
typedef unsigned __int64 U64;
85
#endif // PLATFORM_ANSI
86
87
//================================================================
88
#define MARKERCOUNT (PACKETLENGTH * 2)
89
90
// The following macros depend on UINTPTR_T and INTPTR_T being properly defined
91
// so that they are equal to pointer width. Confirm and fail if our assumptions are wrong.
92
CT_ASSERT(sizeof(UINTPTR_T) == sizeof(void*), strcodec1);
93
CT_ASSERT(sizeof(INTPTR_T) == sizeof(void*), strcodec2);
94
95
// wrap around pointer, s=pow(2,n), p wraps aligned to s
96
#define WRAPPTR(p, s) ((void*)((UINTPTR_T)(p) & ~(UINTPTR_T)(s)))
97
98
// mask certain bit inside a pointer, simulate wrap around
99
#define MASKPTR(p, m) ((void*)((UINTPTR_T)(p) & (INTPTR_T)(m)))
100
101
// test for more than 1 packet data
102
#define PACKET1(ps, pc, s) (((INTPTR_T)(ps) ^ (INTPTR_T)(pc)) & ((UINTPTR_T)(s)))
103
104
// alternate pointer p between 2 values aligned to s, s=pow(2,n)
105
//#define ALTPTR(p, s) ((void*)((uintptr_t)(p) ^ (s)))
106
107
// align point, s=pow(2,n), p aligns to s
108
#define ALIGNUP(p, s) ((void*)(((UINTPTR_T)(p) + ((UINTPTR_T)(s) - 1)) & ~((UINTPTR_T)(s) - 1)))
109
#define ALIGNDOWN(p, s) ((void*)((UINTPTR_T)(p) & ~((UINTPTR_T)(s) - 1)))
110
111
//================================================================
112
// timer support
113
//================================================================
114
115
#define TraceResult(a)
116
117
//================================================================
118
typedef enum tagPacketType
119
{
120
PK_NULL = 0,
121
PK_DC = 1, PK_AD, PK_AC, PK_CP,
122
PK_MAX,
123
} PACKETTYPE;
124
125
typedef struct tagIOContext
126
{
127
U8 P0[PACKETLENGTH]; // packet circular buffer 0
128
U8 P1[PACKETLENGTH]; // packet circular buffer 1
129
130
union
131
{
132
U8 P2[PACKETLENGTH];
133
struct
134
{
135
U32 uiShadow; // shadow of P0[0]-P0[3]
136
137
U32 uiAccumulator; // 32bit acc as bit field cache
138
U32 cBitsUsed; // # of bits used of acc, [0,16)
139
140
U8* pbPacket; // packet pointer
141
U8* pbCurrent; // current pointer
142
143
struct WMPStream* pWS; // pointer to WMPStream
144
long offPacket; // byte offset into stream
145
146
//ULARGE_INTEGER u64Acc;
147
148
//========================================
149
// index packet, used for packet retrieval
150
//========================================
151
U32 cIndex; // current index for index packet
152
long offIndex; // byte offset into stream for index packet
153
}State;
154
}P2Info;
155
U8 P3[PACKETLENGTH]; // index packet buffer
156
} IOContext;
157
158
typedef struct tagMemReadState
159
{
160
U8* pbBuf;
161
size_t cbBuf;
162
size_t cbCur;
163
} MemReadState;
164
165
typedef struct tagBitIOInfo
166
{
167
U32 uiShadow; // shadow of first 4B of circular buffer
168
169
U32 uiAccumulator; // 32bit acc as bit field cache
170
U32 cBitsUsed; // # of bits used of acc, [0,16)
171
#ifdef ARMOPT_BITIO
172
U32 cBitsUnused; // # of bits remain unused in acc, [0,32]
173
#endif
174
175
I32 iMask; // mask used simulate pointer wrap around
176
177
U8* pbStart; // start pointer
178
#ifndef ARMOPT_BITIO
179
U8* pbCurrent; // current pointer
180
#else
181
U32* pbCurrent; // current pointer
182
#endif
183
184
struct WMPStream* pWS; // pointer to WMPStream
185
size_t offRef; // reference offset on IStream,
186
// for read, it moves along the stream
187
// for write, it stays at the attach point
188
} BitIOInfo;
189
190
//================================================================
191
typedef struct tagCWMIQuantizer {
192
U8 iIndex;
193
I32 iQP;
194
I32 iOffset;
195
I32 iMan;
196
I32 iExp;
197
#if defined(WMP_OPT_QT)
198
float f1_QP;
199
double d1_QP;
200
#endif
201
} CWMIQuantizer;
202
203
/* temporary bridge between old APIs and streaming APIs */
204
typedef struct tagCWMIMBInfo {
205
I32 iBlockDC[MAX_CHANNELS][16];
206
I32 iOrientation;
207
Int iCBP[MAX_CHANNELS];
208
Int iDiffCBP[MAX_CHANNELS];
209
U8 iQIndexLP; // 0 - 15
210
U8 iQIndexHP; // 0 - 15
211
} CWMIMBInfo;
212
213
struct CWMImageStrCodec;
214
215
typedef Int (*ImageDataProc)(struct CWMImageStrCodec*);
216
217
/** scan model **/
218
typedef struct CAdaptiveScan {
219
U32 uTotal;
220
U32 uScan;
221
} CAdaptiveScan;
222
223
/** Adaptive context model **/
224
typedef struct CCodingContext {
225
BitIOInfo * m_pIODC;
226
BitIOInfo * m_pIOLP;
227
BitIOInfo * m_pIOAC;
228
BitIOInfo * m_pIOFL;
229
230
/** adaptive huffman structs **/
231
CAdaptiveHuffman *m_pAdaptHuffCBPCY;
232
CAdaptiveHuffman *m_pAdaptHuffCBPCY1;
233
CAdaptiveHuffman *m_pAHexpt[NUMVLCTABLES];
234
235
/** 4x4 zigzag patterns */
236
CAdaptiveScan m_aScanLowpass[16];
237
CAdaptiveScan m_aScanHoriz[16];
238
CAdaptiveScan m_aScanVert[16];
239
240
/** Adaptive bit reduction model **/
241
CAdaptiveModel m_aModelAC;
242
CAdaptiveModel m_aModelLP;
243
CAdaptiveModel m_aModelDC;
244
245
/** Adaptive lowpass CBP model **/
246
Int m_iCBPCountZero;
247
Int m_iCBPCountMax;
248
249
/** Adaptive AC CBP model **/
250
CCBPModel m_aCBPModel;
251
252
/** Trim flex bits - externally set **/
253
Int m_iTrimFlexBits;
254
255
Bool m_bInROI; // inside ROI (for region decode and compressed domain cropping)?
256
} CCodingContext;
257
258
// Following stuff used to be in strPredQuant.h
259
/* circulant buffer for 2 MB rows: current row and previous row */
260
typedef struct tagCWMIPredInfo {
261
Int iQPIndex; // QP Index
262
Int iCBP; // coded block pattern
263
PixelI iDC; // DC of MB
264
PixelI iAD[6];
265
PixelI * piAD; // AC of DC block: [2] 420UV [4] 422UV [6] elsewhere
266
}CWMIPredInfo;
267
268
// the following is used on decode side while reading image info
269
typedef struct CWMImageStrCodecParameters {
270
size_t cVersion;
271
size_t cSubVersion;
272
COLORFORMAT cfColorFormat; // color format
273
Bool bRBSwapped; // blue and red shall be swapped in BGR555,565,101010
274
Bool bAlphaChannel; // alpha channel present
275
Bool bScaledArith; // lossless mode
276
Bool bIndexTable; // index table present
277
Bool bTrimFlexbitsFlag; // trimmed flexbits indicated in packet header
278
Bool bUseHardTileBoundaries; //default is soft tile boundaries
279
size_t cNumChannels;
280
size_t cExtraPixelsTop;
281
size_t cExtraPixelsLeft;
282
size_t cExtraPixelsBottom;
283
size_t cExtraPixelsRight;
284
Bool bTranscode; // transcoding flag
285
U32 uQPMode; // 0/1: no dquant/with dquant, first bit for DC, second bit for LP, third bit for HP
286
U8 uiQPIndexDC[MAX_CHANNELS];
287
U8 uiQPIndexLP[MAX_CHANNELS];
288
U8 uiQPIndexHP[MAX_CHANNELS];
289
}CCoreParameters;
290
291
typedef struct CWMITile
292
{
293
CWMIQuantizer * pQuantizerDC[MAX_CHANNELS];
294
CWMIQuantizer * pQuantizerLP[MAX_CHANNELS];
295
CWMIQuantizer * pQuantizerHP[MAX_CHANNELS];
296
U8 cNumQPLP;
297
U8 cNumQPHP;
298
U8 cBitsLP;
299
U8 cBitsHP;
300
301
Bool bUseDC;
302
Bool bUseLP;
303
U8 cChModeDC;
304
U8 cChModeLP[16];
305
U8 cChModeHP[16];
306
} CWMITile;
307
308
#ifdef ARMOPT_COLORCONVERSION_C
309
#include "ARM_InvColorConversion.h"
310
#endif
311
312
struct tagPostProcInfo{
313
Int iMBDC; // DC of MB
314
U8 ucMBTexture; // MB texture : 0(flat) 1(horizontal) 2(vertical) 3(bumpy)
315
Int iBlockDC[4][4]; // DC of block
316
U8 ucBlockTexture[4][4]; // block texture: 0(flat) 1(horizontal) 2(vertical) 3(bumpy)
317
};
318
319
typedef struct CWMImageStrCodec {
320
#ifdef ARMOPT_COLORCONVERSION_C
321
CWMImageStrInvCCParam InvCCParam;
322
#endif
323
324
size_t cbStruct;
325
326
CWMImageInfo WMII;
327
CWMIStrCodecParam WMISCP;
328
CWMImageBufferInfo WMIBI;
329
CWMIMBInfo MBInfo;
330
331
/** core parameters **/
332
CCoreParameters m_param;
333
334
struct CWMDecoderParameters *m_Dparam; // this is specified thru pointer because the same set of parameters may be used by multiple image planes
335
336
U8 cSB;
337
338
Bool m_bUVResolutionChange;
339
340
Bool bTileExtraction;
341
342
BitIOInfo * pIOHeader;
343
344
Bool bUseHardTileBoundaries; //default is soft tile boundaries
345
346
PixelI * pInterU;
347
PixelI * pInterV;
348
349
//============== tile related info begins here ===========
350
// index table
351
size_t *pIndexTable;
352
353
// current tile position
354
size_t cTileRow;
355
size_t cTileColumn;
356
357
// tile boundary
358
Bool m_bCtxLeft;
359
Bool m_bCtxTop;
360
361
Bool m_bResetRGITotals;
362
Bool m_bResetContext;
363
364
CWMITile * pTile;
365
366
// BitIOs
367
BitIOInfo ** m_ppBitIO;
368
size_t cNumBitIO;
369
size_t cHeaderSize;
370
371
// coding contexts
372
struct CCodingContext *m_pCodingContext;
373
size_t cNumCodingContext;
374
375
//============== tile related info ends here ===========
376
377
size_t cNumOfQPIndex; // number of QP indexes
378
U8 cBitsDQUANT; // number of bits to encode DQUANT
379
380
size_t cRow; // row for current macro block
381
size_t cColumn; // column for current macro block
382
383
size_t cmbWidth; // macro block/image width
384
size_t cmbHeight; // macro block/image height
385
386
size_t cbChannel; // byte/channel
387
388
size_t mbX, mbY;
389
size_t tileX, tileY;
390
Bool bVertTileBoundary, bHoriTileBoundary;
391
Bool bOneMBLeftVertTB, bOneMBRightVertTB; //Macroblock to the left and to the right of tile boundaries
392
393
PixelI iPredBefore[2][2];
394
PixelI iPredAfter[2][2];
395
396
//================================
397
// input data into
398
// macro block 3 of 2x2 working widow
399
//================================
400
ImageDataProc Load;
401
//ImageDataProc Load2;
402
ImageDataProc Transform;
403
ImageDataProc TransformCenter;
404
405
//================================
406
ImageDataProc Quantize;
407
//ImageDataProc QuantizeLuma;
408
//ImageDataProc QuantizeChroma;
409
410
//================================
411
// process and store data from
412
// macro block 0 of 2x2 working window
413
//================================
414
ImageDataProc ProcessTopLeft;
415
ImageDataProc ProcessTop;
416
ImageDataProc ProcessTopRight;
417
ImageDataProc ProcessLeft;
418
ImageDataProc ProcessCenter;
419
ImageDataProc ProcessRight;
420
ImageDataProc ProcessBottomLeft;
421
ImageDataProc ProcessBottom;
422
ImageDataProc ProcessBottomRight;
423
424
425
//================================
426
// 2 MB working window for encoder
427
//================================
428
PixelI *pPlane[MAX_CHANNELS];
429
430
//================================
431
// 2 rows of MB buffer
432
//================================
433
PixelI *a0MBbuffer[MAX_CHANNELS]; // pointer to start of previous MB row
434
PixelI *a1MBbuffer[MAX_CHANNELS]; // pointer to start of current MB row
435
PixelI *p0MBbuffer[MAX_CHANNELS]; // working pointer to start of previous row MB
436
PixelI *p1MBbuffer[MAX_CHANNELS]; // working pointer to start of current row MB
437
438
//================================
439
// downsampling buffer for UV
440
//================================
441
PixelI * pResU;
442
PixelI * pResV;
443
444
//================================
445
// circular buffer for 2 MB rows: current row and previous row
446
//================================
447
CWMIPredInfo *PredInfo[MAX_CHANNELS];
448
CWMIPredInfo *PredInfoPrevRow[MAX_CHANNELS];
449
CWMIPredInfo *pPredInfoMemory;
450
451
struct WMPStream ** ppWStream;
452
453
#ifdef _WINDOWS_
454
TCHAR **ppTempFile;
455
#else
456
char **ppTempFile;
457
#endif
458
459
// interleaved alpha support - linked structure for Alpha channel
460
struct CWMImageStrCodec *m_pNextSC;
461
Bool m_bSecondary;
462
463
//================================
464
// Perf Timers
465
//================================
466
#ifndef DISABLE_PERF_MEASUREMENT
467
Bool m_fMeasurePerf;
468
struct PERFTIMERSTATE *m_ptEndToEndPerf; // Measures from Init to Term, including I/O
469
struct PERFTIMERSTATE *m_ptEncDecPerf; // Measures time spent in ImageStrEncEncode/ImageStrDecDecode, excluding I/O
470
#endif // DISABLE_PERF_MEASUREMENT
471
472
// postproc information for 2 MB rows: 0(previous row) 1(current row)
473
struct tagPostProcInfo * pPostProcInfo[MAX_CHANNELS][2];
474
} CWMImageStrCodec;
475
476
477
//================================================================
478
ERR WMPAlloc(void** ppv, size_t cb);
479
ERR WMPFree(void** ppv);
480
481
//================================================================
482
Void initMRPtr(CWMImageStrCodec*);
483
Void advanceMRPtr(CWMImageStrCodec*);
484
Void swapMRPtr(CWMImageStrCodec*);
485
486
Int IDPEmpty(CWMImageStrCodec*);
487
488
//================================================================
489
extern const int dctIndex[3][16];
490
extern const int blkOffset[16];
491
extern const int blkOffsetUV[4];
492
extern const int blkOffsetUV_422[8];
493
494
extern const U8 idxCC[16][16];
495
extern const U8 idxCC_420[8][8];
496
497
extern const Char gGDISignature[];
498
499
//================================================================
500
Int allocatePredInfo(CWMImageStrCodec*);
501
Void freePredInfo(CWMImageStrCodec*);
502
Void advanceOneMBRow(CWMImageStrCodec*);
503
504
//================================================================
505
// bit I/O
506
//================================================================
507
Int allocateBitIOInfo(CWMImageStrCodec*);
508
Int setBitIOPointers(CWMImageStrCodec* pSC);
509
510
#ifndef ARMOPT_BITIO
511
U32 peekBit16(BitIOInfo* pIO, U32 cBits);
512
U32 flushBit16(BitIOInfo* pIO, U32 cBits);
513
U32 getBit16(BitIOInfo* pIO, U32 cBits);
514
U32 getBool16(BitIOInfo* pIO);
515
I32 getBit16s(BitIOInfo* pIO, U32 cBits);
516
U32 getBit32(BitIOInfo* pIO, U32 cBits);
517
U32 flushToByte(BitIOInfo* pIO);
518
#endif // ARMOPT_BITIO
519
520
Void putBit16z(BitIOInfo* pIO, U32 uiBits, U32 cBits);
521
Void putBit16(BitIOInfo* pIO, U32 uiBits, U32 cBits);
522
Void putBit32(BitIOInfo* pIO, U32 uiBits, U32 cBits);
523
Void fillToByte(BitIOInfo* pIO);
524
525
U32 getSizeRead(BitIOInfo* pIO);
526
U32 getSizeWrite(BitIOInfo* pIO);
527
528
U32 getPosRead(BitIOInfo* pIO);
529
530
// safe function, solely for the convenience of test code
531
#ifndef ARMOPT_BITIO
532
U32 getBit16_S(CWMImageStrCodec* pSC, BitIOInfo* pIO, U32 cBits);
533
#endif // ARMOPT_BITIO
534
535
//================================================================
536
// packet I/O
537
//================================================================
538
ERR attachISRead(BitIOInfo* pIO, struct WMPStream* pWS, CWMImageStrCodec* pSC);
539
ERR readIS(CWMImageStrCodec* pSC, BitIOInfo* pIO);
540
ERR detachISRead(CWMImageStrCodec* pSC, BitIOInfo* pIO);
541
542
ERR attachISWrite(BitIOInfo* pIO, struct WMPStream* pWS);
543
ERR writeIS(CWMImageStrCodec* pSC, BitIOInfo* pIO);
544
ERR detachISWrite(CWMImageStrCodec* pSC, BitIOInfo* pIO);
545
546
547
//================================================================
548
// post processing for decoder
549
//================================================================
550
Int initPostProc(struct tagPostProcInfo * strPostProcInfo[MAX_CHANNELS][2], size_t mbWidth, size_t iNumChannels);
551
Void termPostProc(struct tagPostProcInfo * strPostProcInfo[MAX_CHANNELS][2], size_t iNumChannels);
552
Void slideOneMBRow(struct tagPostProcInfo * strPostProcInfo[MAX_CHANNELS][2], size_t iNumChannels, size_t mbWidth, Bool top, Bool bottom);
553
Void updatePostProcInfo(struct tagPostProcInfo * strPostProcInfo[MAX_CHANNELS][2], PixelI * p, size_t mbX, size_t cc);
554
Void postProcMB(struct tagPostProcInfo * strPostProcInfo[MAX_CHANNELS][2], PixelI * p0, PixelI * p1, size_t mbX, size_t cc, Int threshold);
555
Void postProcBlock(struct tagPostProcInfo * strPostProcInfo[MAX_CHANNELS][2], PixelI * p0, PixelI * p1, size_t mbX, size_t cc, Int threshold);
556
557
//================================================================
558
// Simple BitIO access functions
559
//================================================================
560
typedef struct tagSimpleBitIO
561
{
562
struct WMPStream* pWS;
563
U32 cbRead;
564
U8 bAccumulator;
565
U32 cBitLeft;
566
} SimpleBitIO;
567
568
ERR attach_SB(SimpleBitIO* pSB, struct WMPStream* pWS);
569
U32 getBit32_SB(SimpleBitIO* pSB, U32 cBits);
570
Void flushToByte_SB(SimpleBitIO* pSB);
571
U32 getByteRead_SB(SimpleBitIO* pSB);
572
ERR detach_SB(SimpleBitIO* pSB);
573
574
//----------------------------------------------------------------
575
EXTERN_C Bool EOSWS_File(struct WMPStream* pWS);
576
577
EXTERN_C ERR ReadWS_File(struct WMPStream* pWS, void* pv, size_t cb);
578
EXTERN_C ERR WriteWS_File(struct WMPStream* pWS, const void* pv, size_t cb);
579
//EXTERN_C ERR GetLineWS_File(struct WMPStream* pWS, void* pv, size_t cb);
580
581
EXTERN_C ERR SetPosWS_File(struct WMPStream* pWS, size_t offPos);
582
EXTERN_C ERR GetPosWS_File(struct WMPStream* pWS, size_t* poffPos);
583
584
//----------------------------------------------------------------
585
EXTERN_C Bool EOSWS_Memory(struct WMPStream* pWS);
586
587
EXTERN_C ERR ReadWS_Memory(struct WMPStream* pWS, void* pv, size_t cb);
588
EXTERN_C ERR WriteWS_Memory(struct WMPStream* pWS, const void* pv, size_t cb);
589
//EXTERN_C ERR GetLineWS_Memory(struct WMPStream* pWS, void* pv, size_t cb);
590
591
EXTERN_C ERR SetPosWS_Memory(struct WMPStream* pWS, size_t offPos);
592
EXTERN_C ERR GetPosWS_Memory(struct WMPStream* pWS, size_t* poffPos);
593
594
//EXTERN_C ERR GetPtrWS_Memory(struct WMPStream* pWS, size_t align, U8** ppb);
595
//----------------------------------------------------------------
596
EXTERN_C Bool EOSWS_List(struct WMPStream* pWS);
597
598
EXTERN_C ERR ReadWS_List(struct WMPStream* pWS, void* pv, size_t cb);
599
EXTERN_C ERR WriteWS_List(struct WMPStream* pWS, const void* pv, size_t cb);
600
601
EXTERN_C ERR SetPosWS_List(struct WMPStream* pWS, size_t offPos);
602
EXTERN_C ERR GetPosWS_List(struct WMPStream* pWS, size_t* poffPos);
603
604
EXTERN_C ERR CreateWS_List(struct WMPStream** ppWS);
605
EXTERN_C ERR CloseWS_List(struct WMPStream** ppWS);
606
607
/********************************************************************/
608
// Stuff related to scale/spatial ordering
609
typedef struct PacketInfo
610
{
611
BAND m_iBand;
612
size_t m_iSize;
613
size_t m_iOffset;
614
struct PacketInfo *m_pNext;
615
} PacketInfo;
616
/********************************************************************/
617
618
/********************************************************************/
619
const static Int blkIdxByRow[4][4] = {{0, 1, 4, 5}, {2, 3, 6, 7}, {8, 9, 12, 13}, {10, 11, 14, 15}};
620
const static Int blkIdxByColumn[4][4] = {{0, 2, 8, 10}, {1, 3, 9, 11},{4, 6, 12, 14},{5, 7, 13, 15}};
621
622
Int getACPredMode(CWMIMBInfo *, COLORFORMAT);
623
Int getDCACPredMode(CWMImageStrCodec *, size_t);
624
Void updatePredInfo(CWMImageStrCodec* pSC, CWMIMBInfo *, size_t, COLORFORMAT);
625
626
Int AllocateCodingContextDec(struct CWMImageStrCodec *pSC, Int iNumContexts);
627
Void ResetCodingContext(CCodingContext *pContext);
628
Void getTilePos(CWMImageStrCodec* pSC, size_t mbX, size_t mbY);
629
Void InitZigzagScan(CCodingContext * pSC);
630
Int checkImageBuffer(CWMImageStrCodec *, size_t, size_t);
631
632
//U32 log2(U32);
633
634
//DQUANT stuff
635
EXTERN_C Void remapQP(CWMIQuantizer *, I32, Bool);
636
Int allocateTileInfo(CWMImageStrCodec *);
637
Void freeTileInfo(CWMImageStrCodec *);
638
Int allocateQuantizer(CWMIQuantizer * pQuantizer[MAX_CHANNELS], size_t, size_t);
639
Void freeQuantizer(CWMIQuantizer * pQuantizer[MAX_CHANNELS]);
640
Void setUniformQuantizer(CWMImageStrCodec *, size_t);
641
Void useDCQuantizer(CWMImageStrCodec *, size_t);
642
Void useLPQuantizer(CWMImageStrCodec *, size_t, size_t);
643
Void formatQuantizer(CWMIQuantizer * pQuantizer[MAX_CHANNELS], U8, size_t, size_t, Bool, Bool);
644
U8 dquantBits(U8);
645
646
#ifdef ARMOPT_BITIO
647
#define peekBit16 peekBits
648
#define flushBit16 flushBits
649
#define getBit16 getBits
650
#define getBit32 getBits
651
#define getBit16s getBitsS
652
#define getBool16(pIO) getBits(pIO, 1)
653
654
U32 peekBits(BitIOInfo* pIO, U32 cBits);
655
void flushBits(BitIOInfo* pIO, U32 cBits);
656
U32 getBits(BitIOInfo* pIO, U32 cBits);
657
U32 getBitsS(BitIOInfo* pIO, U32 cBits);
658
void flushToByte(BitIOInfo* pIO);
659
#endif // ARMOPT_BITIO
660
661
/*************************************************************************
662
Bitio defines
663
*************************************************************************/
664
#define PEEKBIT16(pIO, cBits) \
665
assert(0 <= (I32)cBits && cBits <= 16);\
666
return (pIO->uiAccumulator >> (32 - cBits/* - pIO->cBitsUsed*/));
667
668
#define FLUSHBIT16(pIO, cBits) \
669
assert(0 <= (I32)cBits && cBits <= 16);\
670
assert((pIO->iMask & 1) == 0);\
671
pIO->cBitsUsed += cBits;\
672
pIO->pbCurrent = MASKPTR(pIO->pbCurrent + ((pIO->cBitsUsed >> 3)/* & 2*/), pIO->iMask);\
673
pIO->cBitsUsed &= 16 - 1;\
674
pIO->uiAccumulator = LOAD16(pIO->pbCurrent) << pIO->cBitsUsed;\
675
return 0;
676
// pIO->uiAccumulator = LOAD16(pIO->pbCurrent) & ((U32)(-1) >> pIO->cBitsUsed);\
677
678
void OutputPerfTimerReport(CWMImageStrCodec *pState);
679
680