decode.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. #ifndef WMI_DECODE_H
  29. #define WMI_DECODE_H
  30. typedef struct CWMDecoderParameters {
  31. /** ROI decode **/
  32. Bool bDecodeFullFrame;
  33. Bool bDecodeFullWidth;
  34. /** thumbnail decode **/
  35. Bool bSkipFlexbits;
  36. size_t cThumbnailScale; // 1: cThumbnailScale thumbnail, only supports cThumbnailScale = 2^m for now
  37. Bool bDecodeHP;
  38. Bool bDecodeLP;
  39. // Region of interest decoding
  40. size_t cROILeftX;
  41. size_t cROIRightX;
  42. size_t cROITopY;
  43. size_t cROIBottomY;
  44. // table lookups for rotation and flip
  45. size_t * pOffsetX;
  46. size_t * pOffsetY;
  47. } CWMDecoderParameters;
  48. Void predCBPDec(CWMImageStrCodec *, CCodingContext *);
  49. Void predDCACDec(CWMImageStrCodec *);
  50. Void predACDec(CWMImageStrCodec *);
  51. Int dequantizeMacroblock(CWMImageStrCodec *);
  52. Int invTransformMacroblock(CWMImageStrCodec * pSC);
  53. Int invTransformMacroblock_alteredOperators_hard(CWMImageStrCodec * pSC);
  54. Int DecodeMacroblockDC(CWMImageStrCodec * pSC, CCodingContext *pContext, Int iMBX, Int iMBY);
  55. Int DecodeMacroblockLowpass(CWMImageStrCodec * pSC, CCodingContext *pContext, Int iMBX, Int iMBY);
  56. Int DecodeMacroblockHighpass(CWMImageStrCodec * pSC, CCodingContext *pContext, Int iMBX, Int iMBY);
  57. Int AdaptLowpassDec(struct CCodingContext *);
  58. Int AdaptHighpassDec(struct CCodingContext *);
  59. Void ResetCodingContextDec(CCodingContext *pContext);
  60. Void FreeCodingContextDec(struct CWMImageStrCodec *pSC);
  61. /*************************************************************************/
  62. // Inverse transform functions
  63. // 2-point post filter for boundaries (only used in 420 UV DC subband)
  64. Void strPost2(PixelI *, PixelI *);
  65. // 2x2 post filter (only used in 420 UV DC subband)
  66. Void strPost2x2(PixelI *, PixelI *, PixelI *, PixelI *);
  67. /** 4-point post filter for boundaries **/
  68. Void strPost4(PixelI *, PixelI *, PixelI *, PixelI *);
  69. /** data allocation in working buffer (first stage) **/
  70. /** Y, 444 U and V **/
  71. /** 0 1 2 3 **/
  72. /** 32 33 34 35 **/
  73. /** 64 65 66 67 **/
  74. /** 96 97 98 99 **/
  75. /** 420 U and V **/
  76. /** 0 2 4 6 **/
  77. /** 64 66 68 70 **/
  78. /** 128 130 132 134 **/
  79. /** 192 194 196 198 **/
  80. /** 4x4 inverse DCT for first stage **/
  81. Void strIDCT4x4FirstStage(PixelI *);
  82. Void strIDCT4x4Stage1(PixelI*);
  83. Void strIDCT4x4FirstStage420UV(PixelI *);
  84. /** 4x4 post filter for first stage **/
  85. Void strPost4x4FirstStage(PixelI *);
  86. Void strPost4x4Stage1Split(PixelI*, PixelI*, Int, Int, Bool);
  87. Void strPost4x4Stage1(PixelI*, Int, Int, Bool);
  88. Void strPost4x4Stage1Split_alternate(PixelI*, PixelI*, Int);
  89. Void strPost4x4Stage1_alternate(PixelI*, Int);
  90. //Void strPost4x4Stage1Split_420(PixelI*, PixelI*);
  91. //Void strPost4x4Stage1_420(PixelI*);
  92. Void strPost4x4FirstStage420UV(PixelI *);
  93. /** data allocation in working buffer (second stage)**/
  94. /** Y, 444 U and V **/
  95. /** 0 4 8 12 **/
  96. /** 128 132 136 140 **/
  97. /** 256 260 264 268 **/
  98. /** 384 388 392 396 **/
  99. /** 420 U and V **/
  100. /** 0 8 **/
  101. /** 256 264 **/
  102. /** 4x4 invesr DCT for second stage **/
  103. //Void strIDCT4x4SecondStage(PixelI *);
  104. Void strIDCT4x4Stage2(PixelI*);
  105. Void strNormalizeDec(PixelI*, Bool);
  106. Void strDCT2x2dnDec(PixelI *, PixelI *, PixelI *, PixelI *);
  107. /** 4x4 post filter for second stage **/
  108. Void strPost4x4SecondStage(PixelI *);
  109. Void strPost4x4Stage2Split(PixelI*, PixelI*);
  110. Void strPost4x4Stage2Split_alternate(PixelI*, PixelI*);
  111. /** Huffman decode related defines **/
  112. #define HUFFMAN_DECODE_ROOT_BITS_LOG 3
  113. #define HUFFMAN_DECODE_ROOT_BITS (5)
  114. Int getHuff(const short *pDecodeTable, BitIOInfo* pIO);
  115. #endif // WMI_DECODE_H