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.

174 lines
3.9KB

  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. Precision = 70,
  71. BandCodingFlags = 72,
  72. PrescaleTable = 83,
  73. EncodedFormat = 84,
  74. BitsPerComponent = 101,
  75. ChannelWidth = 104,
  76. ChannelHeight = 105,
  77. PrescaleShift = 109,
  78. };
  79. #define VLC_BITS 9
  80. #define SUBBAND_COUNT 10
  81. typedef struct CFHD_RL_VLC_ELEM {
  82. int16_t level;
  83. int8_t len;
  84. uint16_t run;
  85. } CFHD_RL_VLC_ELEM;
  86. #define DWT_LEVELS 3
  87. typedef struct SubBand {
  88. int level;
  89. int orientation;
  90. ptrdiff_t stride;
  91. int a_width;
  92. int width;
  93. int a_height;
  94. int height;
  95. int pshift;
  96. int quant;
  97. uint8_t *ibuf;
  98. } SubBand;
  99. typedef struct Plane {
  100. int width;
  101. int height;
  102. ptrdiff_t stride;
  103. int16_t *idwt_buf;
  104. int16_t *idwt_tmp;
  105. /* TODO: merge this into SubBand structure */
  106. int16_t *subband[SUBBAND_COUNT];
  107. int16_t *l_h[8];
  108. SubBand band[DWT_LEVELS][4];
  109. } Plane;
  110. typedef struct Peak {
  111. int level;
  112. int offset;
  113. GetByteContext base;
  114. } Peak;
  115. typedef struct CFHDContext {
  116. AVCodecContext *avctx;
  117. CFHD_RL_VLC_ELEM table_9_rl_vlc[2088];
  118. VLC vlc_9;
  119. CFHD_RL_VLC_ELEM table_18_rl_vlc[4572];
  120. VLC vlc_18;
  121. GetBitContext gb;
  122. int coded_width;
  123. int coded_height;
  124. int cropped_height;
  125. enum AVPixelFormat coded_format;
  126. int progressive;
  127. int a_width;
  128. int a_height;
  129. int a_format;
  130. int bpc; // bits per channel/component
  131. int channel_cnt;
  132. int subband_cnt;
  133. int channel_num;
  134. uint8_t lowpass_precision;
  135. uint16_t quantisation;
  136. int wavelet_depth;
  137. int pshift;
  138. int codebook;
  139. int difference_coding;
  140. int subband_num;
  141. int level;
  142. int subband_num_actual;
  143. uint8_t prescale_shift[3];
  144. Plane plane[4];
  145. Peak peak;
  146. } CFHDContext;
  147. int ff_cfhd_init_vlcs(CFHDContext *s);
  148. #endif /* AVCODEC_CFHD_H */