mqc.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * MQ-coder: structures, common and decoder 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. #ifndef AVCODEC_MQC_H
  22. #define AVCODEC_MQC_H
  23. /**
  24. * MQ-coder
  25. * @file
  26. * @author Kamil Nowosad
  27. */
  28. #include <stdint.h>
  29. #define MQC_CX_UNI 17
  30. #define MQC_CX_RL 18
  31. extern uint16_t ff_mqc_qe[2 * 47];
  32. extern uint8_t ff_mqc_nlps[2 * 47];
  33. extern uint8_t ff_mqc_nmps[2 * 47];
  34. typedef struct MqcState {
  35. uint8_t *bp, *bpstart;
  36. unsigned int a;
  37. unsigned int c;
  38. unsigned int ct;
  39. uint8_t cx_states[19];
  40. int raw;
  41. } MqcState;
  42. /* encoder */
  43. /** initialize the encoder */
  44. void ff_mqc_initenc(MqcState *mqc, uint8_t *bp);
  45. /** code bit d with context cx */
  46. void ff_mqc_encode(MqcState *mqc, uint8_t *cxstate, int d);
  47. /** number of encoded bytes */
  48. int ff_mqc_length(MqcState *mqc);
  49. /** flush the encoder [returns number of bytes encoded] */
  50. int ff_mqc_flush(MqcState *mqc);
  51. int ff_mqc_flush_to(MqcState *mqc, uint8_t *dst, int *dst_len);
  52. /* decoder */
  53. /**
  54. * Initialize MQ-decoder.
  55. * @param mqc MQ decoder state
  56. * @param bp byte pointer
  57. * @param raw raw mode
  58. * @param reset reset states
  59. */
  60. void ff_mqc_initdec(MqcState *mqc, uint8_t *bp, int raw, int reset);
  61. /**
  62. * MQ decoder.
  63. * @param mqc MQ decoder state
  64. * @param cxstate Context
  65. * @return Decision (0 to 1)
  66. */
  67. int ff_mqc_decode(MqcState *mqc, uint8_t *cxstate);
  68. /* common */
  69. /**
  70. * MQ-coder Initialize context tables (QE, NLPS, NMPS)
  71. */
  72. void ff_mqc_init_context_tables(void);
  73. /**
  74. * MQ-coder context initialisations.
  75. * @param mqc MQ-coder context
  76. */
  77. void ff_mqc_init_contexts(MqcState *mqc);
  78. #endif /* AVCODEC_MQC_H */