Add Cineform HD Decoder
[libav.git] / libavcodec / cfhd.h
1 /*
2 * Copyright (c) 2015 Kieran Kunhya
3 *
4 * This file is part of Libav.
5 *
6 * Libav 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 * Libav 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 Libav; 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 "avcodec.h"
27 #include "bitstream.h"
28
29 #define VLC_BITS 9
30 #define SUBBAND_COUNT 10
31
32 typedef struct CFHD_RL_VLC_ELEM {
33 int16_t level;
34 int8_t len;
35 uint16_t run;
36 } CFHD_RL_VLC_ELEM;
37
38 #define DWT_LEVELS 3
39
40 typedef struct SubBand {
41 int level;
42 int orientation;
43 ptrdiff_t stride;
44 int a_width;
45 int width;
46 int a_height;
47 int height;
48 int pshift;
49 int quant;
50 uint8_t *ibuf;
51 } SubBand;
52
53 typedef struct Plane {
54 int width;
55 int height;
56 ptrdiff_t stride;
57
58 int16_t *idwt_buf;
59 int16_t *idwt_tmp;
60
61 /* TODO: merge this into SubBand structure */
62 int16_t *subband[SUBBAND_COUNT];
63 int16_t *l_h[8];
64
65 SubBand band[DWT_LEVELS][4];
66 } Plane;
67
68 typedef struct CFHDContext {
69 AVCodecContext *avctx;
70
71 CFHD_RL_VLC_ELEM table_9_rl_vlc[2088];
72 VLC vlc_9;
73
74 CFHD_RL_VLC_ELEM table_18_rl_vlc[4572];
75 VLC vlc_18;
76
77 BitstreamContext bc;
78
79 int coded_width;
80 int coded_height;
81 int cropped_height;
82 enum AVPixelFormat coded_format;
83
84 int a_width;
85 int a_height;
86 int a_format;
87
88 int bpc; // bits per channel/component
89 int channel_cnt;
90 int subband_cnt;
91 int channel_num;
92 uint8_t lowpass_precision;
93 uint16_t quantisation;
94 int wavelet_depth;
95 int pshift;
96
97 int codebook;
98 int subband_num;
99 int level;
100 int subband_num_actual;
101
102 uint8_t prescale_shift[3];
103 Plane plane[4];
104 } CFHDContext;
105
106 int ff_cfhd_init_vlcs(CFHDContext *s);
107
108 #endif /* AVCODEC_CFHD_H */