]> git.sesse.net Git - ffmpeg/blob - libavcodec/cfhd.h
avcodec/cfhdenc: also write FrameNumber tag
[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     FrameNumber      =  69,
76     Precision        =  70,
77     InputFormat      =  71,
78     BandCodingFlags  =  72,
79     PrescaleTable    =  83,
80     EncodedFormat    =  84,
81     BitsPerComponent = 101,
82     ChannelWidth     = 104,
83     ChannelHeight    = 105,
84     PrescaleShift    = 109,
85 };
86
87 #define VLC_BITS       9
88 #define SUBBAND_COUNT 10
89
90 typedef struct CFHD_RL_VLC_ELEM {
91     int16_t level;
92     int8_t len;
93     uint16_t run;
94 } CFHD_RL_VLC_ELEM;
95
96 #define DWT_LEVELS 3
97
98 typedef struct SubBand {
99     int level;
100     int orientation;
101     ptrdiff_t stride;
102     int a_width;
103     int width;
104     int a_height;
105     int height;
106     int pshift;
107     int quant;
108     uint8_t *ibuf;
109 } SubBand;
110
111 typedef struct Plane {
112     int width;
113     int height;
114     ptrdiff_t stride;
115
116     int16_t *idwt_buf;
117     int16_t *idwt_tmp;
118
119     /* TODO: merge this into SubBand structure */
120     int16_t *subband[SUBBAND_COUNT];
121     int16_t *l_h[8];
122
123     SubBand band[DWT_LEVELS][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 coded_width;
146     int coded_height;
147     int cropped_height;
148     enum AVPixelFormat coded_format;
149     int progressive;
150
151     int a_width;
152     int a_height;
153     int a_format;
154
155     int bpc; // bits per channel/component
156     int channel_cnt;
157     int subband_cnt;
158     int channel_num;
159     uint8_t lowpass_precision;
160     uint16_t quantisation;
161     int wavelet_depth;
162     int pshift;
163
164     int codebook;
165     int difference_coding;
166     int subband_num;
167     int level;
168     int subband_num_actual;
169
170     uint8_t prescale_shift[3];
171     Plane plane[4];
172     Peak peak;
173 } CFHDContext;
174
175 int ff_cfhd_init_vlcs(CFHDContext *s);
176
177 #endif /* AVCODEC_CFHD_H */