mpeg12decdata.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * MPEG1/2 decoder tables
  3. * copyright (c) 2000,2001 Fabrice Bellard
  4. * copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
  5. *
  6. * This file is part of FFmpeg.
  7. *
  8. * FFmpeg is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * FFmpeg is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with FFmpeg; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. /**
  23. * @file libavcodec/mpeg12decdata.h
  24. * MPEG1/2 decoder tables.
  25. */
  26. #ifndef AVCODEC_MPEG12DECDATA_H
  27. #define AVCODEC_MPEG12DECDATA_H
  28. #include <stdint.h>
  29. #include "mpegvideo.h"
  30. #define MB_TYPE_ZERO_MV 0x20000000
  31. #define IS_ZERO_MV(a) ((a)&MB_TYPE_ZERO_MV)
  32. static const uint8_t table_mb_ptype[7][2] = {
  33. { 3, 5 }, // 0x01 MB_INTRA
  34. { 1, 2 }, // 0x02 MB_PAT
  35. { 1, 3 }, // 0x08 MB_FOR
  36. { 1, 1 }, // 0x0A MB_FOR|MB_PAT
  37. { 1, 6 }, // 0x11 MB_QUANT|MB_INTRA
  38. { 1, 5 }, // 0x12 MB_QUANT|MB_PAT
  39. { 2, 5 }, // 0x1A MB_QUANT|MB_FOR|MB_PAT
  40. };
  41. static const uint32_t ptype2mb_type[7] = {
  42. MB_TYPE_INTRA,
  43. MB_TYPE_L0 | MB_TYPE_CBP | MB_TYPE_ZERO_MV | MB_TYPE_16x16,
  44. MB_TYPE_L0,
  45. MB_TYPE_L0 | MB_TYPE_CBP,
  46. MB_TYPE_QUANT | MB_TYPE_INTRA,
  47. MB_TYPE_QUANT | MB_TYPE_L0 | MB_TYPE_CBP | MB_TYPE_ZERO_MV | MB_TYPE_16x16,
  48. MB_TYPE_QUANT | MB_TYPE_L0 | MB_TYPE_CBP,
  49. };
  50. static const uint8_t table_mb_btype[11][2] = {
  51. { 3, 5 }, // 0x01 MB_INTRA
  52. { 2, 3 }, // 0x04 MB_BACK
  53. { 3, 3 }, // 0x06 MB_BACK|MB_PAT
  54. { 2, 4 }, // 0x08 MB_FOR
  55. { 3, 4 }, // 0x0A MB_FOR|MB_PAT
  56. { 2, 2 }, // 0x0C MB_FOR|MB_BACK
  57. { 3, 2 }, // 0x0E MB_FOR|MB_BACK|MB_PAT
  58. { 1, 6 }, // 0x11 MB_QUANT|MB_INTRA
  59. { 2, 6 }, // 0x16 MB_QUANT|MB_BACK|MB_PAT
  60. { 3, 6 }, // 0x1A MB_QUANT|MB_FOR|MB_PAT
  61. { 2, 5 }, // 0x1E MB_QUANT|MB_FOR|MB_BACK|MB_PAT
  62. };
  63. static const uint32_t btype2mb_type[11] = {
  64. MB_TYPE_INTRA,
  65. MB_TYPE_L1,
  66. MB_TYPE_L1 | MB_TYPE_CBP,
  67. MB_TYPE_L0,
  68. MB_TYPE_L0 | MB_TYPE_CBP,
  69. MB_TYPE_L0L1,
  70. MB_TYPE_L0L1 | MB_TYPE_CBP,
  71. MB_TYPE_QUANT | MB_TYPE_INTRA,
  72. MB_TYPE_QUANT | MB_TYPE_L1 | MB_TYPE_CBP,
  73. MB_TYPE_QUANT | MB_TYPE_L0 | MB_TYPE_CBP,
  74. MB_TYPE_QUANT | MB_TYPE_L0L1 | MB_TYPE_CBP,
  75. };
  76. static const uint8_t non_linear_qscale[32] = {
  77. 0, 1, 2, 3, 4, 5, 6, 7,
  78. 8,10,12,14,16,18,20,22,
  79. 24,28,32,36,40,44,48,52,
  80. 56,64,72,80,88,96,104,112,
  81. };
  82. static const uint8_t mpeg2_dc_scale_table1[128]={
  83. // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
  84. 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
  85. 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
  86. 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
  87. 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
  88. };
  89. static const uint8_t mpeg2_dc_scale_table2[128]={
  90. // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
  91. 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,
  92. 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,
  93. 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,
  94. 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,
  95. };
  96. static const uint8_t mpeg2_dc_scale_table3[128]={
  97. // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
  98. 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,
  99. 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,
  100. 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,
  101. 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,
  102. };
  103. static const uint8_t * const mpeg2_dc_scale_table[4]={
  104. ff_mpeg1_dc_scale_table,
  105. mpeg2_dc_scale_table1,
  106. mpeg2_dc_scale_table2,
  107. mpeg2_dc_scale_table3,
  108. };
  109. #endif /* AVCODEC_MPEG12DECDATA_H */