]> git.sesse.net Git - ffmpeg/blob - libavcodec/cfhd.h
avcodec/cfhd: add 3d transform support
[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     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     BandSecondPass   =  82,
82     PrescaleTable    =  83,
83     EncodedFormat    =  84,
84     ChannelWidth     = 104,
85     ChannelHeight    = 105,
86     PrescaleShift    = 109,
87 };
88
89 #define VLC_BITS       9
90 #define SUBBAND_COUNT 10
91 #define SUBBAND_COUNT_3D 17
92
93 typedef struct CFHD_RL_VLC_ELEM {
94     int16_t level;
95     int8_t len;
96     uint16_t run;
97 } CFHD_RL_VLC_ELEM;
98
99 #define DWT_LEVELS 3
100 #define DWT_LEVELS_3D 6
101
102 typedef struct SubBand {
103     ptrdiff_t stride;
104     int a_width;
105     int width;
106     int a_height;
107     int height;
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     int      idwt_size;
118
119     /* TODO: merge this into SubBand structure */
120     int16_t *subband[SUBBAND_COUNT_3D];
121     int16_t *l_h[10];
122
123     SubBand band[DWT_LEVELS_3D][4];
124 } Plane;
125
126 typedef struct Peak {
127     int level;
128     int offset;
129     GetByteContext base;
130 } Peak;
131
132 typedef struct CFHDContext {
133     AVCodecContext *avctx;
134
135     CFHD_RL_VLC_ELEM table_9_rl_vlc[2088];
136     VLC vlc_9;
137
138     CFHD_RL_VLC_ELEM table_18_rl_vlc[4572];
139     VLC vlc_18;
140
141     int lut[2][256];
142
143     GetBitContext gb;
144
145     int planes;
146     int frame_type;
147     int frame_index;
148     int sample_type;
149     int transform_type;
150     int coded_width;
151     int coded_height;
152     int cropped_height;
153     enum AVPixelFormat coded_format;
154     int progressive;
155
156     int a_width;
157     int a_height;
158     int a_format;
159
160     int bpc; // bits per channel/component
161     int channel_cnt;
162     int subband_cnt;
163     int band_encoding;
164     int channel_num;
165     uint8_t lowpass_precision;
166     uint16_t quantisation;
167
168     int codebook;
169     int difference_coding;
170     int subband_num;
171     int level;
172     int subband_num_actual;
173
174     uint8_t prescale_shift[3];
175     Plane plane[4];
176     Peak peak;
177 } CFHDContext;
178
179 int ff_cfhd_init_vlcs(CFHDContext *s);
180
181 #endif /* AVCODEC_CFHD_H */