jpegdeccontainer.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. /*------------------------------------------------------------------------------
  2. -- --
  3. -- This software is confidential and proprietary and may be used --
  4. -- only as expressly authorized by a licensing agreement from --
  5. -- --
  6. -- Hantro Products Oy. --
  7. -- --
  8. -- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
  9. -- ALL RIGHTS RESERVED --
  10. -- --
  11. -- The entire notice above must be reproduced --
  12. -- on all copies and should not be removed. --
  13. -- --
  14. --------------------------------------------------------------------------------
  15. --
  16. -- Description : Jpeg Decoder Container
  17. --
  18. --------------------------------------------------------------------------------
  19. --
  20. -- Version control information, please leave untouched.
  21. --
  22. -- $RCSfile: jpegdeccontainer.h,v $
  23. -- $Revision: 1.22 $
  24. -- $Date: 2009/02/16 08:51:06 $
  25. --
  26. ------------------------------------------------------------------------------*/
  27. /*------------------------------------------------------------------------------
  28. Table of contents
  29. 1. Include headers
  30. 2. Module defines
  31. 3. Data types
  32. 4. Function prototypes
  33. ------------------------------------------------------------------------------*/
  34. #ifndef JPEGDECCONT_H
  35. #define JPEGDECCONT_H
  36. /*------------------------------------------------------------------------------
  37. 1. Include headers
  38. ------------------------------------------------------------------------------*/
  39. #include "basetype.h"
  40. #include "jpegdecapi.h"
  41. #include "dwl.h"
  42. #include "deccfg.h"
  43. #include "decppif.h"
  44. /*------------------------------------------------------------------------------
  45. 2. Module defines
  46. ------------------------------------------------------------------------------*/
  47. #ifdef _ASSERT_USED
  48. #include <assert.h>
  49. #endif
  50. /* macro for assertion, used only if compiler flag _ASSERT_USED is defined */
  51. #ifdef _ASSERT_USED
  52. #define ASSERT(expr) assert(expr)
  53. #else
  54. #define ASSERT(expr)
  55. #endif
  56. #define MIN_NUMBER_OF_COMPONENTS 1
  57. #define MAX_NUMBER_OF_COMPONENTS 3
  58. #define JPEGDEC_X170_MIN_BUFFER 5120
  59. #define JPEGDEC_X170_MAX_BUFFER 16776960
  60. #define JPEGDEC_MAX_SLICE_SIZE 4096
  61. #define JPEGDEC_TABLE_SIZE 544
  62. #define JPEGDEC_MIN_WIDTH 48
  63. #define JPEGDEC_MIN_HEIGHT 48
  64. #define JPEGDEC_MAX_WIDTH 4672
  65. #define JPEGDEC_MAX_HEIGHT 4672
  66. #define JPEGDEC_MAX_PIXEL_AMOUNT 16370688
  67. #define JPEGDEC_MAX_WIDTH_8190 8176
  68. #define JPEGDEC_MAX_HEIGHT_8190 8176
  69. #define JPEGDEC_MAX_PIXEL_AMOUNT_8190 66846976
  70. #define JPEGDEC_MAX_SLICE_SIZE_8190 8100
  71. #define JPEGDEC_MAX_WIDTH_TN 256
  72. #define JPEGDEC_MAX_HEIGHT_TN 256
  73. #define JPEGDEC_YUV400 0
  74. #define JPEGDEC_YUV420 2
  75. #define JPEGDEC_YUV422 3
  76. #define JPEGDEC_YUV444 4
  77. #define JPEGDEC_YUV440 5
  78. #define JPEGDEC_YUV411 6
  79. #define JPEGDEC_BASELINE_TABLE_SIZE 544
  80. #define JPEGDEC_PROGRESSIVE_TABLE_SIZE 576
  81. #define JPEGDEC_QP_BASE 32
  82. #define JPEGDEC_AC1_BASE 48
  83. #define JPEGDEC_AC2_BASE 88
  84. #define JPEGDEC_DC1_BASE 129
  85. #define JPEGDEC_DC2_BASE 132
  86. #define JPEGDEC_DC3_BASE 135
  87. /* progressive */
  88. #define JPEGDEC_COEFF_SIZE 96
  89. /*------------------------------------------------------------------------------
  90. 3. Data types
  91. ------------------------------------------------------------------------------*/
  92. typedef struct
  93. {
  94. u32 C; /* Component id */
  95. u32 H; /* Horizontal sampling factor */
  96. u32 V; /* Vertical sampling factor */
  97. u32 Tq; /* Quantization table destination selector */
  98. } Components;
  99. typedef struct
  100. {
  101. u8 *pStartOfStream;
  102. u8 *pCurrPos;
  103. u32 streamBus;
  104. u32 bitPosInByte;
  105. u32 streamLength;
  106. u32 readBits;
  107. u32 appnFlag;
  108. u32 thumbnail;
  109. u32 returnSosMarker;
  110. } StreamStorage;
  111. typedef struct
  112. {
  113. u8 *pStartOfImage;
  114. u8 *pLum;
  115. u8 *pCr;
  116. u8 *pCb;
  117. u32 imageReady;
  118. u32 headerReady;
  119. u32 size;
  120. u32 sizeLuma;
  121. u32 sizeChroma;
  122. u32 ready;
  123. u32 columns[MAX_NUMBER_OF_COMPONENTS];
  124. u32 pixelsPerRow[MAX_NUMBER_OF_COMPONENTS];
  125. } ImageData;
  126. typedef struct
  127. {
  128. u32 Lf;
  129. u32 P;
  130. u32 Y;
  131. u32 hwY;
  132. u32 X;
  133. u32 hwX;
  134. u32 Nf; /* Number of components in frame */
  135. u32 codingType;
  136. u32 numMcuInFrame;
  137. u32 numMcuInRow;
  138. u32 mcuNumber;
  139. u32 nextRstNumber;
  140. u32 Ri;
  141. u32 driPeriod;
  142. u32 block;
  143. u32 row;
  144. u32 col;
  145. u32 cIndex;
  146. u32 *pBuffer;
  147. u32 bufferBus;
  148. i32 *pBufferCb;
  149. i32 *pBufferCr;
  150. DWLLinearMem_t pTableBase;
  151. u32 numBlocks[MAX_NUMBER_OF_COMPONENTS];
  152. u32 blocksPerRow[MAX_NUMBER_OF_COMPONENTS];
  153. u32 useAcOffset[MAX_NUMBER_OF_COMPONENTS];
  154. Components component[MAX_NUMBER_OF_COMPONENTS];
  155. } FrameInfo;
  156. typedef struct
  157. {
  158. u32 Ls;
  159. u32 Ns;
  160. u32 Cs[MAX_NUMBER_OF_COMPONENTS]; /* Scan component selector */
  161. u32 Td[MAX_NUMBER_OF_COMPONENTS]; /* Selects table for DC */
  162. u32 Ta[MAX_NUMBER_OF_COMPONENTS]; /* Selects table for AC */
  163. u32 Ss;
  164. u32 Se;
  165. u32 Ah;
  166. u32 Al;
  167. u32 index;
  168. i32 numIdctRows;
  169. i32 pred[MAX_NUMBER_OF_COMPONENTS];
  170. } ScanInfo;
  171. typedef struct
  172. {
  173. u32 sliceHeight;
  174. u32 amountOfQTables;
  175. u32 yCbCrMode;
  176. u32 yCbCr422;
  177. u32 column;
  178. u32 X;
  179. u32 Y;
  180. u32 memSize;
  181. u32 SliceCount;
  182. u32 SliceReadyForPause;
  183. u32 SliceMBCutValue;
  184. u32 pipeline;
  185. u32 userAllocMem;
  186. u32 sliceMbSetValue;
  187. u32 timeout;
  188. u32 rlcMode;
  189. u32 lumaPos;
  190. u32 chromaPos;
  191. u32 sliceStartCount;
  192. u32 amountOfSlices;
  193. u32 noSliceIrqForUser;
  194. u32 sliceLimitReached;
  195. u32 inputBufferEmpty;
  196. u32 fillRight;
  197. u32 fillBottom;
  198. u32 streamEnd;
  199. u32 streamEndFlag;
  200. u32 inputBufferLen;
  201. u32 inputStreaming;
  202. u32 decodedStreamLen;
  203. u32 init;
  204. u32 initThumb;
  205. u32 initBufferSize;
  206. i32 dcRes[MAX_NUMBER_OF_COMPONENTS];
  207. DWLLinearMem_t outLuma;
  208. DWLLinearMem_t outChroma;
  209. DWLLinearMem_t outChroma2;
  210. DWLLinearMem_t givenOutLuma;
  211. DWLLinearMem_t givenOutChroma;
  212. DWLLinearMem_t givenOutChroma2;
  213. i32 pred[MAX_NUMBER_OF_COMPONENTS];
  214. /* progressive parameters */
  215. u32 nonInterleaved;
  216. u32 componentId;
  217. u32 operationType;
  218. u32 operationTypeThumb;
  219. u32 progressiveScanReady;
  220. u32 nonInterleavedScanReady;
  221. u32 allocated;
  222. u32 yCbCrModeOrig;
  223. u32 getInfoYCbCrMode;
  224. u32 components[MAX_NUMBER_OF_COMPONENTS];
  225. DWLLinearMem_t pCoeffBase;
  226. u32 fillX;
  227. u32 fillY;
  228. u32 progressiveFinish;
  229. u32 pfCompId;
  230. u32 pfNeeded[MAX_NUMBER_OF_COMPONENTS];
  231. DWLLinearMem_t tmpStrm;
  232. } DecInfo;
  233. typedef struct
  234. {
  235. DWLLinearMem_t outLumaBuffer;
  236. DWLLinearMem_t outChromaBuffer;
  237. DWLLinearMem_t outChromaBuffer2;
  238. } JpegAsicBuffers;
  239. typedef struct
  240. {
  241. u32 bits[16];
  242. u32 *vals;
  243. u32 tableLength;
  244. u32 start;
  245. u32 last;
  246. } VlcTable;
  247. typedef struct
  248. {
  249. u32 Lh;
  250. VlcTable acTable0;
  251. VlcTable acTable1;
  252. VlcTable acTable2;
  253. VlcTable acTable3;
  254. VlcTable dcTable0;
  255. VlcTable dcTable1;
  256. VlcTable dcTable2;
  257. VlcTable dcTable3;
  258. VlcTable *table;
  259. } HuffmanTables;
  260. typedef struct
  261. {
  262. u32 Lq; /* Quantization table definition length */
  263. u32 table0[64];
  264. u32 table1[64];
  265. u32 table2[64];
  266. u32 table3[64];
  267. u32 *table;
  268. } QuantTables;
  269. typedef struct
  270. {
  271. u32 jpegRegs[DEC_X170_REGISTERS];
  272. u32 asicRunning;
  273. StreamStorage stream;
  274. FrameInfo frame;
  275. ImageData image;
  276. ScanInfo scan;
  277. DecInfo info;
  278. HuffmanTables vlc;
  279. QuantTables quant;
  280. u32 tmpData[64];
  281. u32 is8190;
  282. u32 fuseBurned;
  283. u32 minSupportedWidth;
  284. u32 minSupportedHeight;
  285. u32 maxSupportedWidth;
  286. u32 maxSupportedHeight;
  287. u32 maxSupportedPixelAmount;
  288. u32 maxSupportedSliceSize;
  289. u32 extensionsSupported;
  290. JpegAsicBuffers asicBuff;
  291. DecPpInterface ppControl;
  292. DecPpQuery ppConfigQuery; /* Decoder asks pp info about setup, info stored here */
  293. u32 ppStatus;
  294. const void *dwl; /* DWL instance */
  295. const void *ppInstance;
  296. void (*PPRun) (const void *, DecPpInterface *);
  297. void (*PPEndCallback) (const void *);
  298. void (*PPConfigQuery) (const void *, DecPpQuery *);
  299. } JpegDecContainer;
  300. /*------------------------------------------------------------------------------
  301. 4. Function prototypes
  302. ------------------------------------------------------------------------------*/
  303. #endif /* #endif JPEGDECDATA_H */