1
0

macroblock.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /*!
  2. ************************************************************************
  3. * \file macroblock.h
  4. *
  5. * \brief
  6. * Arrays for macroblock encoding
  7. *
  8. * \author
  9. * Inge Lille-Langoy <[email protected]>
  10. * Copyright (C) 1999 Telenor Satellite Services, Norway
  11. ************************************************************************
  12. */
  13. #ifndef _MACROBLOCK_H_
  14. #define _MACROBLOCK_H_
  15. #include "global.h"
  16. #include "mbuffer.h"
  17. #include "block.h"
  18. //! single scan pattern
  19. static const byte SNGL_SCAN[16][2] =
  20. {
  21. {0,0},{1,0},{0,1},{0,2},
  22. {1,1},{2,0},{3,0},{2,1},
  23. {1,2},{0,3},{1,3},{2,2},
  24. {3,1},{3,2},{2,3},{3,3}
  25. };
  26. static const byte SNGL_SCAN_1D[16] = { 0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15};
  27. static const byte SNGL_SCAN_DC[16] = { 0, 1, 2, 8, 3, 4, 5, 6, 9, 10, 11, 12, 7, 13, 14, 15};
  28. //! field scan pattern
  29. static const byte FIELD_SCAN[16][2] =
  30. {
  31. {0,0},{0,1},{1,0},{0,2},
  32. {0,3},{1,1},{1,2},{1,3},
  33. {2,0},{2,1},{2,2},{2,3},
  34. {3,0},{3,1},{3,2},{3,3}
  35. };
  36. static const byte FIELD_SCAN_1D[16] = {0, 4, 1, 8, 12, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15};
  37. static const byte FIELD_SCAN_DC[16] = {0, 2, 1, 8, 10, 3, 9, 11, 4, 6, 12, 14, 5, 7, 13, 15};
  38. //! used to control block sizes : Not used/16x16/16x8/8x16/8x8/8x4/4x8/4x4
  39. static const int BLOCK_STEP[8][2]=
  40. {
  41. {0,0},{4,4},{4,2},{2,4},{2,2},{2,1},{1,2},{1,1}
  42. };
  43. //! single scan pattern
  44. static const byte SNGL_SCAN8x8[64][2] = {
  45. {0,0}, {1,0}, {0,1}, {0,2}, {1,1}, {2,0}, {3,0}, {2,1}, {1,2}, {0,3}, {0,4}, {1,3}, {2,2}, {3,1}, {4,0}, {5,0},
  46. {4,1}, {3,2}, {2,3}, {1,4}, {0,5}, {0,6}, {1,5}, {2,4}, {3,3}, {4,2}, {5,1}, {6,0}, {7,0}, {6,1}, {5,2}, {4,3},
  47. {3,4}, {2,5}, {1,6}, {0,7}, {1,7}, {2,6}, {3,5}, {4,4}, {5,3}, {6,2}, {7,1}, {7,2}, {6,3}, {5,4}, {4,5}, {3,6},
  48. {2,7}, {3,7}, {4,6}, {5,5}, {6,4}, {7,3}, {7,4}, {6,5}, {5,6}, {4,7}, {5,7}, {6,6}, {7,5}, {7,6}, {6,7}, {7,7}
  49. };
  50. static const byte SNGL_SCAN8x8_1D[64] =
  51. {
  52. 0, 1, 8, 16, 9, 2, 3, 10,
  53. 17, 24, 32, 25, 18, 11, 4, 5,
  54. 12, 19, 26, 33, 40, 48, 41, 34,
  55. 27, 20, 13, 6, 7, 14, 21, 28,
  56. 35, 42, 49, 56, 57, 50, 43, 36,
  57. 29, 22, 15, 23, 30, 37, 44, 51,
  58. 58, 59, 52, 45, 38, 31, 39, 46,
  59. 53, 60, 61, 54, 47, 55, 62, 63
  60. };
  61. //! field scan pattern
  62. static const byte FIELD_SCAN8x8[64][2] = { // 8x8
  63. {0,0}, {0,1}, {0,2}, {1,0}, {1,1}, {0,3}, {0,4}, {1,2}, {2,0}, {1,3}, {0,5}, {0,6}, {0,7}, {1,4}, {2,1}, {3,0},
  64. {2,2}, {1,5}, {1,6}, {1,7}, {2,3}, {3,1}, {4,0}, {3,2}, {2,4}, {2,5}, {2,6}, {2,7}, {3,3}, {4,1}, {5,0}, {4,2},
  65. {3,4}, {3,5}, {3,6}, {3,7}, {4,3}, {5,1}, {6,0}, {5,2}, {4,4}, {4,5}, {4,6}, {4,7}, {5,3}, {6,1}, {6,2}, {5,4},
  66. {5,5}, {5,6}, {5,7}, {6,3}, {7,0}, {7,1}, {6,4}, {6,5}, {6,6}, {6,7}, {7,2}, {7,3}, {7,4}, {7,5}, {7,6}, {7,7}
  67. };
  68. static const byte FIELD_SCAN8x8_1D[64] =
  69. {
  70. 0, 8, 16, 1, 9, 24, 32, 17,
  71. 2, 25, 40, 48, 56, 33, 10, 3,
  72. 18, 41, 49, 57, 26, 11, 4, 19,
  73. 34, 42, 50, 58, 27, 12, 5, 20,
  74. 35, 43, 51, 59, 28, 13, 6, 21,
  75. 36, 44, 52, 60, 29, 14, 22, 37,
  76. 45, 53, 61, 30, 7, 15, 38, 46,
  77. 54, 62, 23, 31, 39, 47, 55, 63
  78. };
  79. //! single scan pattern
  80. static const byte SCAN_YUV422[8][2] =
  81. {
  82. {0,0},{0,1},
  83. {1,0},{0,2},
  84. {0,3},{1,1},
  85. {1,2},{1,3}
  86. };
  87. static const unsigned char cbp_blk_chroma[8][4] =
  88. { {16, 17, 18, 19},
  89. {20, 21, 22, 23},
  90. {24, 25, 26, 27},
  91. {28, 29, 30, 31},
  92. {32, 33, 34, 35},
  93. {36, 37, 38, 39},
  94. {40, 41, 42, 43},
  95. {44, 45, 46, 47}
  96. };
  97. static const unsigned char cofuv_blk_x[3][8][4] =
  98. { { {0, 1, 0, 1},
  99. {0, 1, 0, 1},
  100. {0, 0, 0, 0},
  101. {0, 0, 0, 0},
  102. {0, 0, 0, 0},
  103. {0, 0, 0, 0},
  104. {0, 0, 0, 0},
  105. {0, 0, 0, 0} },
  106. { {0, 1, 0, 1},
  107. {0, 1, 0, 1},
  108. {0, 1, 0, 1},
  109. {0, 1, 0, 1},
  110. {0, 0, 0, 0},
  111. {0, 0, 0, 0},
  112. {0, 0, 0, 0},
  113. {0, 0, 0, 0} },
  114. { {0, 1, 0, 1},
  115. {2, 3, 2, 3},
  116. {0, 1, 0, 1},
  117. {2, 3, 2, 3},
  118. {0, 1, 0, 1},
  119. {2, 3, 2, 3},
  120. {0, 1, 0, 1},
  121. {2, 3, 2, 3} }
  122. };
  123. static const unsigned char cofuv_blk_y[3][8][4] =
  124. {
  125. { { 0, 0, 1, 1},
  126. { 0, 0, 1, 1},
  127. { 0, 0, 0, 0},
  128. { 0, 0, 0, 0},
  129. { 0, 0, 0, 0},
  130. { 0, 0, 0, 0},
  131. { 0, 0, 0, 0},
  132. { 0, 0, 0, 0} },
  133. { { 0, 0, 1, 1},
  134. { 2, 2, 3, 3},
  135. { 0, 0, 1, 1},
  136. { 2, 2, 3, 3},
  137. { 0, 0, 0, 0},
  138. { 0, 0, 0, 0},
  139. { 0, 0, 0, 0},
  140. { 0, 0, 0, 0} },
  141. { { 0, 0, 1, 1},
  142. { 0, 0, 1, 1},
  143. { 2, 2, 3, 3},
  144. { 2, 2, 3, 3},
  145. { 0, 0, 1, 1},
  146. { 0, 0, 1, 1},
  147. { 2, 2, 3, 3},
  148. { 2, 2, 3, 3}}
  149. };
  150. extern void setup_slice_methods(Slice *currSlice);
  151. extern void get_neighbors(Macroblock *currMB, PixelPos *block, int mb_x, int mb_y, int blockshape_x);
  152. extern void get_neighbors0016(Macroblock *currMB, PixelPos *block);
  153. extern void start_macroblock (Slice *currSlice, Macroblock **currMB);
  154. extern int decode_one_macroblock(Macroblock *currMB, StorablePicture *dec_picture);
  155. extern Boolean exit_macroblock (Slice *currSlice, int eos_bit);
  156. #endif