]> git.sesse.net Git - ffmpeg/blob - libavcodec/vp9.h
Merge commit '90bc423212396e96a02edc1118982ab7f7766a63'
[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
133     AVBufferRef *hwaccel_priv_buf;
134     void *hwaccel_picture_private;
135 } VP9Frame;
136
137 typedef struct VP9BitstreamHeader {
138     // bitstream header
139     uint8_t profile;
140     uint8_t bpp;
141     uint8_t keyframe;
142     uint8_t invisible;
143     uint8_t errorres;
144     uint8_t intraonly;
145     uint8_t resetctx;
146     uint8_t refreshrefmask;
147     uint8_t highprecisionmvs;
148     enum FilterMode filtermode;
149     uint8_t allowcompinter;
150     uint8_t refreshctx;
151     uint8_t parallelmode;
152     uint8_t framectxid;
153     uint8_t use_last_frame_mvs;
154     uint8_t refidx[3];
155     uint8_t signbias[3];
156     uint8_t fixcompref;
157     uint8_t varcompref[2];
158     struct {
159         uint8_t level;
160         int8_t sharpness;
161     } filter;
162     struct {
163         uint8_t enabled;
164         uint8_t updated;
165         int8_t mode[2];
166         int8_t ref[4];
167     } lf_delta;
168     uint8_t yac_qi;
169     int8_t ydc_qdelta, uvdc_qdelta, uvac_qdelta;
170     uint8_t lossless;
171 #define MAX_SEGMENT 8
172     struct {
173         uint8_t enabled;
174         uint8_t temporal;
175         uint8_t absolute_vals;
176         uint8_t update_map;
177         uint8_t prob[7];
178         uint8_t pred_prob[3];
179         struct {
180             uint8_t q_enabled;
181             uint8_t lf_enabled;
182             uint8_t ref_enabled;
183             uint8_t skip_enabled;
184             uint8_t ref_val;
185             int16_t q_val;
186             int8_t lf_val;
187             int16_t qmul[2][2];
188             uint8_t lflvl[4][2];
189         } feat[MAX_SEGMENT];
190     } segmentation;
191     enum TxfmMode txfmmode;
192     enum CompPredMode comppredmode;
193     struct {
194         unsigned log2_tile_cols, log2_tile_rows;
195         unsigned tile_cols, tile_rows;
196     } tiling;
197
198     int uncompressed_header_size;
199     int compressed_header_size;
200 } VP9BitstreamHeader;
201
202 typedef struct VP9SharedContext {
203     VP9BitstreamHeader h;
204
205     ThreadFrame refs[8];
206 #define CUR_FRAME 0
207 #define REF_FRAME_MVPAIR 1
208 #define REF_FRAME_SEGMAP 2
209     VP9Frame frames[3];
210 } VP9SharedContext;
211
212 #endif /* AVCODEC_VP9_H */