cfhd.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * Copyright (c) 2015 Kieran Kunhya
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #ifndef AVCODEC_CFHD_H
  21. #define AVCODEC_CFHD_H
  22. #include <stdint.h>
  23. #include "libavutil/avassert.h"
  24. #include "avcodec.h"
  25. #include "bytestream.h"
  26. #include "get_bits.h"
  27. #include "vlc.h"
  28. #define VLC_BITS 9
  29. #define SUBBAND_COUNT 10
  30. typedef struct CFHD_RL_VLC_ELEM {
  31. int16_t level;
  32. int8_t len;
  33. uint16_t run;
  34. } CFHD_RL_VLC_ELEM;
  35. #define DWT_LEVELS 3
  36. typedef struct SubBand {
  37. int level;
  38. int orientation;
  39. ptrdiff_t stride;
  40. int a_width;
  41. int width;
  42. int a_height;
  43. int height;
  44. int pshift;
  45. int quant;
  46. uint8_t *ibuf;
  47. } SubBand;
  48. typedef struct Plane {
  49. int width;
  50. int height;
  51. ptrdiff_t stride;
  52. int16_t *idwt_buf;
  53. int16_t *idwt_tmp;
  54. /* TODO: merge this into SubBand structure */
  55. int16_t *subband[SUBBAND_COUNT];
  56. int16_t *l_h[8];
  57. SubBand band[DWT_LEVELS][4];
  58. } Plane;
  59. typedef struct Peak {
  60. int level;
  61. int offset;
  62. GetByteContext base;
  63. } Peak;
  64. typedef struct CFHDContext {
  65. AVCodecContext *avctx;
  66. CFHD_RL_VLC_ELEM table_9_rl_vlc[2088];
  67. VLC vlc_9;
  68. CFHD_RL_VLC_ELEM table_18_rl_vlc[4572];
  69. VLC vlc_18;
  70. GetBitContext gb;
  71. int coded_width;
  72. int coded_height;
  73. int cropped_height;
  74. enum AVPixelFormat coded_format;
  75. int progressive;
  76. int a_width;
  77. int a_height;
  78. int a_format;
  79. int bpc; // bits per channel/component
  80. int channel_cnt;
  81. int subband_cnt;
  82. int channel_num;
  83. uint8_t lowpass_precision;
  84. uint16_t quantisation;
  85. int wavelet_depth;
  86. int pshift;
  87. int codebook;
  88. int difference_coding;
  89. int subband_num;
  90. int level;
  91. int subband_num_actual;
  92. uint8_t prescale_shift[3];
  93. Plane plane[4];
  94. Peak peak;
  95. } CFHDContext;
  96. int ff_cfhd_init_vlcs(CFHDContext *s);
  97. #endif /* AVCODEC_CFHD_H */