]> git.sesse.net Git - ffmpeg/blob - libavcodec/vp9.h
Merge commit '1f84b008bf2b1eaca473937c48788cb4e4ce1aea'
[ffmpeg] / libavcodec / vp9.h
1 /*
2  * VP9 compatible video decoder
3  *
4  * Copyright (C) 2013 Ronald S. Bultje <rsbultje gmail com>
5  * Copyright (C) 2013 Clément Bœsch <u pkh me>
6  *
7  * This file is part of FFmpeg.
8  *
9  * FFmpeg is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * FFmpeg is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with FFmpeg; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  */
23
24 #ifndef AVCODEC_VP9_H
25 #define AVCODEC_VP9_H
26
27 #include <stdint.h>
28
29 #include "thread.h"
30 #include "vp56.h"
31
32 enum BlockLevel {
33     BL_64X64,
34     BL_32X32,
35     BL_16X16,
36     BL_8X8,
37 };
38
39 enum BlockPartition {
40     PARTITION_NONE,    // [ ] <-.
41     PARTITION_H,       // [-]   |
42     PARTITION_V,       // [|]   |
43     PARTITION_SPLIT,   // [+] --'
44 };
45
46 enum BlockSize {
47     BS_64x64,
48     BS_64x32,
49     BS_32x64,
50     BS_32x32,
51     BS_32x16,
52     BS_16x32,
53     BS_16x16,
54     BS_16x8,
55     BS_8x16,
56     BS_8x8,
57     BS_8x4,
58     BS_4x8,
59     BS_4x4,
60     N_BS_SIZES,
61 };
62
63 enum TxfmMode {
64     TX_4X4,
65     TX_8X8,
66     TX_16X16,
67     TX_32X32,
68     N_TXFM_SIZES,
69     TX_SWITCHABLE = N_TXFM_SIZES,
70     N_TXFM_MODES
71 };
72
73 enum TxfmType {
74     DCT_DCT,
75     DCT_ADST,
76     ADST_DCT,
77     ADST_ADST,
78     N_TXFM_TYPES
79 };
80
81 enum IntraPredMode {
82     VERT_PRED,
83     HOR_PRED,
84     DC_PRED,
85     DIAG_DOWN_LEFT_PRED,
86     DIAG_DOWN_RIGHT_PRED,
87     VERT_RIGHT_PRED,
88     HOR_DOWN_PRED,
89     VERT_LEFT_PRED,
90     HOR_UP_PRED,
91     TM_VP8_PRED,
92     LEFT_DC_PRED,
93     TOP_DC_PRED,
94     DC_128_PRED,
95     DC_127_PRED,
96     DC_129_PRED,
97     N_INTRA_PRED_MODES
98 };
99
100 enum InterPredMode {
101     NEARESTMV = 10,
102     NEARMV = 11,
103     ZEROMV = 12,
104     NEWMV = 13,
105 };
106
107 enum FilterMode {
108     FILTER_8TAP_SMOOTH,
109     FILTER_8TAP_REGULAR,
110     FILTER_8TAP_SHARP,
111     FILTER_BILINEAR,
112     FILTER_SWITCHABLE,
113 };
114
115 enum CompPredMode {
116     PRED_SINGLEREF,
117     PRED_COMPREF,
118     PRED_SWITCHABLE,
119 };
120
121 struct VP9mvrefPair {
122     VP56mv mv[2];
123     int8_t ref[2];
124 };
125
126 typedef struct VP9Frame {
127     ThreadFrame tf;
128     AVBufferRef *extradata;
129     uint8_t *segmentation_map;
130     struct VP9mvrefPair *mv;
131     int uses_2pass;
132 } VP9Frame;
133
134 typedef struct VP9BitstreamHeader {
135     // bitstream header
136     uint8_t profile;
137     uint8_t keyframe;
138     uint8_t invisible;
139     uint8_t errorres;
140     uint8_t intraonly;
141     uint8_t resetctx;
142     uint8_t refreshrefmask;
143     uint8_t highprecisionmvs;
144     enum FilterMode filtermode;
145     uint8_t allowcompinter;
146     uint8_t refreshctx;
147     uint8_t parallelmode;
148     uint8_t framectxid;
149     uint8_t use_last_frame_mvs;
150     uint8_t refidx[3];
151     uint8_t signbias[3];
152     uint8_t fixcompref;
153     uint8_t varcompref[2];
154     struct {
155         uint8_t level;
156         int8_t sharpness;
157     } filter;
158     struct {
159         uint8_t enabled;
160         uint8_t updated;
161         int8_t mode[2];
162         int8_t ref[4];
163     } lf_delta;
164     uint8_t yac_qi;
165     int8_t ydc_qdelta, uvdc_qdelta, uvac_qdelta;
166     uint8_t lossless;
167 #define MAX_SEGMENT 8
168     struct {
169         uint8_t enabled;
170         uint8_t temporal;
171         uint8_t absolute_vals;
172         uint8_t update_map;
173         uint8_t prob[7];
174         uint8_t pred_prob[3];
175         struct {
176             uint8_t q_enabled;
177             uint8_t lf_enabled;
178             uint8_t ref_enabled;
179             uint8_t skip_enabled;
180             uint8_t ref_val;
181             int16_t q_val;
182             int8_t lf_val;
183             int16_t qmul[2][2];
184             uint8_t lflvl[4][2];
185         } feat[MAX_SEGMENT];
186     } segmentation;
187     enum TxfmMode txfmmode;
188     enum CompPredMode comppredmode;
189     struct {
190         unsigned log2_tile_cols, log2_tile_rows;
191         unsigned tile_cols, tile_rows;
192     } tiling;
193
194     int uncompressed_header_size;
195     int compressed_header_size;
196 } VP9BitstreamHeader;
197
198 typedef struct VP9SharedContext {
199     VP9BitstreamHeader h;
200
201     ThreadFrame refs[8];
202 #define CUR_FRAME 0
203 #define REF_FRAME_MVPAIR 1
204 #define REF_FRAME_SEGMAP 2
205     VP9Frame frames[3];
206 } VP9SharedContext;
207
208 #endif /* AVCODEC_VP9_H */