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