mp4tbl.c 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /* ///////////////////////////////////////////////////////////////////////
  2. //
  3. // INTEL CORPORATION PROPRIETARY INFORMATION
  4. // This software is supplied under the terms of a license agreement or
  5. // nondisclosure agreement with Intel Corporation and may not be copied
  6. // or disclosed except in accordance with the terms of that agreement.
  7. // Copyright (c) 2001-2007 Intel Corporation. All Rights Reserved.
  8. //
  9. // Description: MPEG-4 related tables.
  10. //
  11. */
  12. #include "mp4def.h"
  13. #define DI(b) ((1 << 18) + b) / b
  14. const int32_t mp4_DivIntraDivisor[47] = {
  15. DI( 1), DI( 1), DI( 2), DI( 3), DI( 4), DI( 5), DI( 6), DI( 7), DI( 8), DI( 9),
  16. DI(10), DI(11), DI(12), DI(13), DI(14), DI(15), DI(16), DI(17), DI(18), DI(19),
  17. DI(20), DI(21), DI(22), DI(23), DI(24), DI(25), DI(26), DI(27), DI(28), DI(29),
  18. DI(30), DI(31), DI(32), DI(33), DI(34), DI(35), DI(36), DI(37), DI(38), DI(39),
  19. DI(40), DI(41), DI(42), DI(43), DI(44), DI(45), DI(46)
  20. };
  21. #define DCSL(q) (q <= 4) ? 8 : (q <= 8) ? (q << 1) : (q <= 24) ? (q + 8) : ((q << 1) - 16)
  22. const uint8_t mp4_DCScalerLuma[32] = {
  23. DCSL( 0), DCSL( 1), DCSL( 2), DCSL( 3), DCSL( 4), DCSL( 5), DCSL( 6), DCSL( 7),
  24. DCSL( 8), DCSL( 9), DCSL(10), DCSL(11), DCSL(12), DCSL(13), DCSL(14), DCSL(15),
  25. DCSL(16), DCSL(17), DCSL(18), DCSL(19), DCSL(20), DCSL(21), DCSL(22), DCSL(23),
  26. DCSL(24), DCSL(25), DCSL(26), DCSL(27), DCSL(28), DCSL(29), DCSL(30), DCSL(31)
  27. };
  28. #define DCSC(q) (q <= 4) ? 8 : (q <= 24) ? ((q + 13) >> 1) : (q - 6)
  29. const uint8_t mp4_DCScalerChroma[32] = {
  30. DCSC( 0), DCSC( 1), DCSC( 2), DCSC( 3), DCSC( 4), DCSC( 5), DCSC( 6), DCSC( 7),
  31. DCSC( 8), DCSC( 9), DCSC(10), DCSC(11), DCSC(12), DCSC(13), DCSC(14), DCSC(15),
  32. DCSC(16), DCSC(17), DCSC(18), DCSC(19), DCSC(20), DCSC(21), DCSC(22), DCSC(23),
  33. DCSC(24), DCSC(25), DCSC(26), DCSC(27), DCSC(28), DCSC(29), DCSC(30), DCSC(31)
  34. };
  35. const uint8_t mp4_DefaultIntraQuantMatrix[64] = {
  36. 8, 17, 18, 19, 21, 23, 25, 27, 17, 18, 19, 21, 23, 25, 27, 28,
  37. 20, 21, 22, 23, 24, 26, 28, 30, 21, 22, 23, 24, 26, 28, 30, 32,
  38. 22, 23, 24, 26, 28, 30, 32, 35, 23, 24, 26, 28, 30, 32, 35, 38,
  39. 25, 26, 28, 30, 32, 35, 38, 41, 27, 28, 30, 32, 35, 38, 41, 45
  40. };
  41. const uint8_t mp4_DefaultNonIntraQuantMatrix[64] = {
  42. 16, 17, 18, 19, 20, 21, 22, 23, 17, 18, 19, 20, 21, 22, 23, 24,
  43. 18, 19, 20, 21, 22, 23, 24, 25, 19, 20, 21, 22, 23, 24, 26, 27,
  44. 20, 21, 22, 23, 25, 26, 27, 28, 21, 22, 23, 24, 26, 27, 28, 30,
  45. 22, 23, 24, 26, 27, 28, 30, 31, 23, 24, 25, 27, 28, 30, 31, 33
  46. };
  47. const uint8_t mp4_ClassicalZigzag[64] = {
  48. 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5,
  49. 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28,
  50. 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51,
  51. 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63
  52. };
  53. const uint8_t mp4_cCbCrMvRound16[16] = {0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2};
  54. const uint8_t mp4_cCbCrMvRound12[12] = {0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2};
  55. const uint8_t mp4_cCbCrMvRound8[8] = {0, 0, 1, 1, 1, 1, 1, 2};
  56. const uint8_t mp4_cCbCrMvRound4[4] = {0, 1, 1, 1};
  57. const Ipp8s mp4_dquant[4] = {-1, -2, 1, 2};
  58. const mp4_VLC1 mp4_cbpy1[4] = {{0,255},{0,2},{1,1},{1,1}};
  59. const mp4_VLC1 mp4_cbpy2[16] = {{0,255},{0,4},{1,3},{1,3},{2,2},{2,2},{2,2},{2,2},{3,1},{3,1},{3,1},{3,1},{3,1},{3,1},{3,1},{3,1}};
  60. const mp4_VLC1 mp4_cbpy3[64] = {{1,255},{1,6},{2,5},{2,5},{4,5},{4,5},{5,5},{5,5},{6,3},{6,3},{6,3},{6,3},{6,3},{6,3},{6,3},{6,3},{3,3},{3,3},{3,3},{3,3},{3,3},{3,3},{3,3},{3,3},{0,3},{0,3},{0,3},{0,3},{0,3},{0,3},{0,3},{0,3},{7,1},{7,1},{7,1},{7,1},{7,1},{7,1},{7,1},{7,1},{7,1},{7,1},{7,1},{7,1},{7,1},{7,1},{7,1},{7,1},{7,1},{7,1},{7,1},{7,1},{7,1},{7,1},{7,1},{7,1},{7,1},{7,1},{7,1},{7,1},{7,1},{7,1},{7,1},{7,1}};
  61. const mp4_VLC1 mp4_cbpy4[64] = {{16,255},{16,255},{6,6},{9,6},{8,5},{8,5},{4,5},{4,5},{2,5},{2,5},{1,5},{1,5},{0,4},{0,4},{0,4},{0,4},{12,4},{12,4},{12,4},{12,4},{10,4},{10,4},{10,4},{10,4},{14,4},{14,4},{14,4},{14,4},{5,4},{5,4},{5,4},{5,4},{13,4},{13,4},{13,4},{13,4},{3,4},{3,4},{3,4},{3,4},{11,4},{11,4},{11,4},{11,4},{7,4},{7,4},{7,4},{7,4},{15,2},{15,2},{15,2},{15,2},{15,2},{15,2},{15,2},{15,2},{15,2},{15,2},{15,2},{15,2},{15,2},{15,2},{15,2},{15,2}};
  62. const mp4_VLC1* mp4_cbpy_t[4] = {mp4_cbpy1, mp4_cbpy2, mp4_cbpy3, mp4_cbpy4};
  63. const uint8_t mp4_cbpy_b[4] = {2, 4, 6, 6};
  64. const int32_t mp4_DC_vlc_Threshold[8] = {512, 13, 15, 17, 19, 21, 23, 0};
  65. const uint8_t mp4_PVOPmb_type[256] = {255,255,4,4,4,1,3,3,3,3,2,2,3,3,3,3,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
  66. const uint8_t mp4_PVOPmb_cbpc[256] = {0,0,3,2,1,3,2,2,1,1,3,3,3,3,3,3,2,2,2,2,1,1,1,1,2,2,2,2,1,1,1,1,0,0,0,0,0,0,0,0,3,3,3,3,3,3,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,2,2,2,2,2,2,2,2,2,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TYPE_INTERPOLATE, 2}, {IPPVC_MBTYPE_INTERPOLATE, 2}, {IPPVC_MBTYPE_INTERPOLATE, 2}, {IPPVC_MBTYPE_INTERPOLATE, 2},
  71. {IPPVC_MBTYPE_DIRECT, 1}, {IPPVC_MBTYPE_DIRECT, 1}, {IPPVC_MBTYPE_DIRECT, 1}, {IPPVC_MBTYPE_DIRECT, 1},
  72. {IPPVC_MBTYPE_DIRECT, 1}, {IPPVC_MBTYPE_DIRECT, 1}, {IPPVC_MBTYPE_DIRECT, 1}, {IPPVC_MBTYPE_DIRECT, 1}
  73. };
  74. const mp4_VLC1 mp4_MVD_B12_1[] = {
  75. {32,12},{31,12},
  76. {30,11},{30,11},{29,11},{29,11},{28,11},{28,11},
  77. {27,11},{27,11},{26,11},{26,11},{25,11},{25,11},
  78. {24,10},{24,10},{24,10},{24,10},{23,10},{23,10},{23,10},{23,10},
  79. {22,10},{22,10},{22,10},{22,10},{21,10},{21,10},{21,10},{21,10},
  80. {20,10},{20,10},{20,10},{20,10},{19,10},{19,10},{19,10},{19,10},
  81. {18,10},{18,10},{18,10},{18,10},{17,10},{17,10},{17,10},{17,10},
  82. {16,10},{16,10},{16,10},{16,10},{15,10},{15,10},{15,10},{15,10},
  83. {14,10},{14,10},{14,10},{14,10},{13,10},{13,10},{13,10},{13,10},
  84. {12,10},{12,10},{12,10},{12,10},{11,10},{11,10},{11,10},{11,10},
  85. {10, 9},{10, 9},{10, 9},{10, 9},{10, 9},{10, 9},{10, 9},{10, 9},
  86. { 9, 9},{ 9, 9},{ 9, 9},{ 9, 9},{ 9, 9},{ 9, 9},{ 9, 9},{ 9, 9},
  87. { 8, 9},{ 8, 9},{ 8, 9},{ 8, 9},{ 8, 9},{ 8, 9},{ 8, 9},{ 8, 9},
  88. {0x7, 7},{ 7, 7},{ 7, 7},{ 7, 7},{ 7, 7},{ 7, 7},{ 7, 7},{ 7, 7},
  89. {0x7, 7},{ 7, 7},{ 7, 7},{ 7, 7},{ 7, 7},{ 7,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0, 1},
  107. { 0, 1},{ 0, 1},{ 0, 1},{ 0, 1},{ 0, 1},{ 0, 1},{ 0, 1},{ 0, 1},
  108. { 0, 1},{ 0, 1},{ 0, 1},{ 0, 1},{ 0, 1},{ 0, 1},{ 0, 1},{ 0, 1},
  109. { 0, 1},{ 0, 1},{ 0, 1},{ 0, 1},{ 0, 1},{ 0, 1},{ 0, 1},{ 0, 1},
  110. };
  111. const int32_t mp4_H263_width[5] = {128, 176, 352, 704, 1408};
  112. const int32_t mp4_H263_height[5] = {96, 144, 288, 576, 1152};
  113. const int32_t mp4_H263_mbgob[5] = {8, 11, 22, 88, 352};
  114. const int32_t mp4_H263_gobvop[5] = {6, 9, 18, 18, 18};
  115. const int32_t mp4_H263_rowgob[5] = {1, 1, 1, 2, 4};
  116. const uint8_t mp4_aux_comp_count[MP4_SHAPE_EXT_NUM+1] = {1, 1, 2, 2, 3, 1, 2, 1, 1, 2, 3, 2, 3, 0};
  117. const uint8_t mp4_aux_comp_is_alpha[MP4_SHAPE_EXT_NUM+1] = {1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0};
  118. const uint8_t mp4_BABtypeIntra[81][3] = {
  119. 2, 4, 3, 4, 3, 2, 4, 2, 3, 2, 4, 3, 2, 3, 4, 2, 3, 4, 2, 4, 3, 2, 3, 4,
  120. 4, 2, 3, 4, 3, 2, 2, 3, 4, 2, 3, 4, 4, 3, 2, 2, 3, 4, 3, 2, 4, 4, 3, 2,
  121. 2, 3, 4, 2, 3, 4, 4, 2, 3, 2, 3, 4, 4, 3, 2, 4, 2, 3, 2, 3, 4, 4, 3, 2,
  122. 4, 2, 3, 4, 3, 2, 4, 3, 2, 2, 3, 4, 2, 3, 4, 2, 3, 4, 2, 3, 4, 2, 3, 4,
  123. 2, 3, 4, 2, 3, 4, 2, 3, 4, 4, 3, 2, 2, 3, 4, 4, 3, 2, 4, 3, 2, 2, 3, 4,
  124. 3, 4, 2, 4, 3, 2, 2, 3, 4, 3, 4, 2, 4, 3, 2, 2, 3, 4, 4, 3, 2, 4, 2, 3,
  125. 2, 3, 4, 4, 3, 2, 4, 2, 3, 2, 4, 3, 3, 4, 2, 4, 2, 3, 2, 4, 3, 4, 2, 3,
  126. 4, 2, 3, 2, 3, 4, 2, 3, 4, 2, 3, 4, 2, 3, 4, 2, 3, 4, 4, 2, 3, 2, 3, 4,
  127. 4, 3, 2, 4, 3, 2, 4, 2, 3, 3, 4, 2, 3, 4, 2, 4, 2, 3, 3, 4, 2, 4, 3, 2,
  128. 2, 4, 3, 4, 3, 2, 4, 2, 3, 4, 2, 3, 3, 4, 2, 4, 3, 2, 2, 4, 3, 3, 4, 2,
  129. 4, 3, 2
  130. };