]> git.sesse.net Git - ffmpeg/blob - libavcodec/cfhd.h
Merge commit '1e56173515826aa4d680d3b216d80a3879ed1c68'
[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 #define VLC_BITS       9
34 #define SUBBAND_COUNT 10
35
36 typedef struct CFHD_RL_VLC_ELEM {
37     int16_t level;
38     int8_t len;
39     uint16_t run;
40 } CFHD_RL_VLC_ELEM;
41
42 #define DWT_LEVELS 3
43
44 typedef struct SubBand {
45     int level;
46     int orientation;
47     ptrdiff_t stride;
48     int a_width;
49     int width;
50     int a_height;
51     int height;
52     int pshift;
53     int quant;
54     uint8_t *ibuf;
55 } SubBand;
56
57 typedef struct Plane {
58     int width;
59     int height;
60     ptrdiff_t stride;
61
62     int16_t *idwt_buf;
63     int16_t *idwt_tmp;
64
65     /* TODO: merge this into SubBand structure */
66     int16_t *subband[SUBBAND_COUNT];
67     int16_t *l_h[8];
68
69     SubBand band[DWT_LEVELS][4];
70 } Plane;
71
72 typedef struct Peak {
73     int level;
74     int offset;
75     GetByteContext base;
76 } Peak;
77
78 typedef struct CFHDContext {
79     AVCodecContext *avctx;
80
81     CFHD_RL_VLC_ELEM table_9_rl_vlc[2088];
82     VLC vlc_9;
83
84     CFHD_RL_VLC_ELEM table_18_rl_vlc[4572];
85     VLC vlc_18;
86
87     GetBitContext gb;
88
89     int coded_width;
90     int coded_height;
91     int cropped_height;
92     enum AVPixelFormat coded_format;
93     int progressive;
94
95     int a_width;
96     int a_height;
97     int a_format;
98
99     int bpc; // bits per channel/component
100     int channel_cnt;
101     int subband_cnt;
102     int channel_num;
103     uint8_t lowpass_precision;
104     uint16_t quantisation;
105     int wavelet_depth;
106     int pshift;
107
108     int codebook;
109     int difference_coding;
110     int subband_num;
111     int level;
112     int subband_num_actual;
113
114     uint8_t prescale_shift[3];
115     Plane plane[4];
116     Peak peak;
117 } CFHDContext;
118
119 int ff_cfhd_init_vlcs(CFHDContext *s);
120
121 #endif /* AVCODEC_CFHD_H */