You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 lines
2.9KB

  1. /*
  2. * MQ-coder encoder and decoder common functions
  3. * Copyright (c) 2007 Kamil Nowosad
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. /**
  22. * MQ-coder ecoder and decoder common functions
  23. * @file
  24. * @author Kamil Nowosad
  25. */
  26. #include "mqc.h"
  27. typedef struct {
  28. uint16_t qe;
  29. uint8_t nmps;
  30. uint8_t nlps;
  31. uint8_t sw;
  32. } MqcCxState;
  33. const static MqcCxState cx_states[47] = {
  34. {0x5601, 1, 1, 1},
  35. {0x3401, 2, 6, 0},
  36. {0x1801, 3, 9, 0},
  37. {0x0AC1, 4, 12, 0},
  38. {0x0521, 5, 29, 0},
  39. {0x0221, 38, 33, 0},
  40. {0x5601, 7, 6, 1},
  41. {0x5401, 8, 14, 0},
  42. {0x4801, 9, 14, 0},
  43. {0x3801, 10, 14, 0},
  44. {0x3001, 11, 17, 0},
  45. {0x2401, 12, 18, 0},
  46. {0x1C01, 13, 20, 0},
  47. {0x1601, 29, 21, 0},
  48. {0x5601, 15, 14, 1},
  49. {0x5401, 16, 14, 0},
  50. {0x5101, 17, 15, 0},
  51. {0x4801, 18, 16, 0},
  52. {0x3801, 19, 17, 0},
  53. {0x3401, 20, 18, 0},
  54. {0x3001, 21, 19, 0},
  55. {0x2801, 22, 19, 0},
  56. {0x2401, 23, 20, 0},
  57. {0x2201, 24, 21, 0},
  58. {0x1C01, 25, 22, 0},
  59. {0x1801, 26, 23, 0},
  60. {0x1601, 27, 24, 0},
  61. {0x1401, 28, 25, 0},
  62. {0x1201, 29, 26, 0},
  63. {0x1101, 30, 27, 0},
  64. {0x0AC1, 31, 28, 0},
  65. {0x09C1, 32, 29, 0},
  66. {0x08A1, 33, 30, 0},
  67. {0x0521, 34, 31, 0},
  68. {0x0441, 35, 32, 0},
  69. {0x02A1, 36, 33, 0},
  70. {0x0221, 37, 34, 0},
  71. {0x0141, 38, 35, 0},
  72. {0x0111, 39, 36, 0},
  73. {0x0085, 40, 37, 0},
  74. {0x0049, 41, 38, 0},
  75. {0x0025, 42, 39, 0},
  76. {0x0015, 43, 40, 0},
  77. {0x0009, 44, 41, 0},
  78. {0x0005, 45, 42, 0},
  79. {0x0001, 45, 43, 0},
  80. {0x5601, 46, 46, 0}
  81. };
  82. uint16_t ff_mqc_qe [2*47];
  83. uint8_t ff_mqc_nlps[2*47];
  84. uint8_t ff_mqc_nmps[2*47];
  85. void ff_mqc_init_contexts(MqcState *mqc)
  86. {
  87. int i;
  88. memset(mqc->cx_states, 0, sizeof(mqc->cx_states));
  89. mqc->cx_states[MQC_CX_UNI] = 2 * 46;
  90. mqc->cx_states[MQC_CX_RL] = 2 * 3;
  91. mqc->cx_states[0] = 2 * 4;
  92. for (i = 0; i < 47; i++){
  93. ff_mqc_qe[2*i ] =
  94. ff_mqc_qe[2*i+1] = cx_states[i].qe;
  95. ff_mqc_nlps[2*i ] = 2*cx_states[i].nlps + cx_states[i].sw;
  96. ff_mqc_nlps[2*i+1] = 2*cx_states[i].nlps + 1 - cx_states[i].sw;
  97. ff_mqc_nmps[2*i ] = 2*cx_states[i].nmps;
  98. ff_mqc_nmps[2*i+1] = 2*cx_states[i].nmps + 1;
  99. }
  100. }