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.

178 lines
4.0KB

  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. enum CFHDParam {
  29. SampleType = 1,
  30. SampleIndexTable = 2,
  31. BitstreamMarker = 4,
  32. TransformType = 10,
  33. NumFrames = 11,
  34. ChannelCount = 12,
  35. WaveletCount = 13,
  36. SubbandCount = 14,
  37. NumSpatial = 15,
  38. FirstWavelet = 16,
  39. GroupTrailer = 18,
  40. ImageWidth = 20,
  41. ImageHeight = 21,
  42. LowpassSubband = 25,
  43. NumLevels = 26,
  44. LowpassWidth = 27,
  45. LowpassHeight = 28,
  46. PixelOffset = 33,
  47. LowpassQuantization=34,
  48. LowpassPrecision = 35,
  49. WaveletType = 37,
  50. WaveletNumber = 38,
  51. WaveletLevel = 39,
  52. NumBands = 40,
  53. HighpassWidth = 41,
  54. HighpassHeight = 42,
  55. LowpassBorder = 43,
  56. HighpassBorder = 44,
  57. LowpassScale = 45,
  58. LowpassDivisor = 46,
  59. SubbandNumber = 48,
  60. BandWidth = 49,
  61. BandHeight = 50,
  62. SubbandBand = 51,
  63. BandEncoding = 52,
  64. Quantization = 53,
  65. BandScale = 54,
  66. BandHeader = 55,
  67. BandTrailer = 56,
  68. ChannelNumber = 62,
  69. SampleFlags = 68,
  70. FrameNumber = 69,
  71. Precision = 70,
  72. InputFormat = 71,
  73. BandCodingFlags = 72,
  74. PrescaleTable = 83,
  75. EncodedFormat = 84,
  76. BitsPerComponent = 101,
  77. ChannelWidth = 104,
  78. ChannelHeight = 105,
  79. PrescaleShift = 109,
  80. };
  81. #define VLC_BITS 9
  82. #define SUBBAND_COUNT 10
  83. typedef struct CFHD_RL_VLC_ELEM {
  84. int16_t level;
  85. int8_t len;
  86. uint16_t run;
  87. } CFHD_RL_VLC_ELEM;
  88. #define DWT_LEVELS 3
  89. typedef struct SubBand {
  90. int level;
  91. int orientation;
  92. ptrdiff_t stride;
  93. int a_width;
  94. int width;
  95. int a_height;
  96. int height;
  97. int pshift;
  98. int quant;
  99. uint8_t *ibuf;
  100. } SubBand;
  101. typedef struct Plane {
  102. int width;
  103. int height;
  104. ptrdiff_t stride;
  105. int16_t *idwt_buf;
  106. int16_t *idwt_tmp;
  107. /* TODO: merge this into SubBand structure */
  108. int16_t *subband[SUBBAND_COUNT];
  109. int16_t *l_h[8];
  110. SubBand band[DWT_LEVELS][4];
  111. } Plane;
  112. typedef struct Peak {
  113. int level;
  114. int offset;
  115. GetByteContext base;
  116. } Peak;
  117. typedef struct CFHDContext {
  118. AVCodecContext *avctx;
  119. CFHD_RL_VLC_ELEM table_9_rl_vlc[2088];
  120. VLC vlc_9;
  121. CFHD_RL_VLC_ELEM table_18_rl_vlc[4572];
  122. VLC vlc_18;
  123. int lut[2][256];
  124. GetBitContext gb;
  125. int coded_width;
  126. int coded_height;
  127. int cropped_height;
  128. enum AVPixelFormat coded_format;
  129. int progressive;
  130. int a_width;
  131. int a_height;
  132. int a_format;
  133. int bpc; // bits per channel/component
  134. int channel_cnt;
  135. int subband_cnt;
  136. int channel_num;
  137. uint8_t lowpass_precision;
  138. uint16_t quantisation;
  139. int wavelet_depth;
  140. int pshift;
  141. int codebook;
  142. int difference_coding;
  143. int subband_num;
  144. int level;
  145. int subband_num_actual;
  146. uint8_t prescale_shift[3];
  147. Plane plane[4];
  148. Peak peak;
  149. } CFHDContext;
  150. int ff_cfhd_init_vlcs(CFHDContext *s);
  151. #endif /* AVCODEC_CFHD_H */