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