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