cfhd.h 4.3 KB

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