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