blob: b9f44899433da3e865a0ec2ce93cade467822037
1 | /* |
2 | * drivers/amvdec_ports/decoder/aml_vp9_parser.h |
3 | * |
4 | * Copyright (C) 2015 Amlogic, Inc. All rights reserved. |
5 | * |
6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by |
8 | * the Free Software Foundation; either version 2 of the License, or |
9 | * (at your option) any later version. |
10 | * |
11 | * This program is distributed in the hope that it will be useful, but WITHOUT |
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
14 | * more details. |
15 | * |
16 | */ |
17 | |
18 | #ifndef AML_VP9_PARSER_H |
19 | #define AML_VP9_PARSER_H |
20 | |
21 | #include "../utils/pixfmt.h" |
22 | #include "../utils/get_bits.h" |
23 | |
24 | #define MAX_SEGMENT 8 |
25 | |
26 | struct VP9BitstreamHeader { |
27 | // bitstream header |
28 | u8 profile; |
29 | u8 bpp; |
30 | u8 keyframe; |
31 | u8 invisible; |
32 | u8 errorres; |
33 | u8 intraonly; |
34 | u8 resetctx; |
35 | u8 refreshrefmask; |
36 | u8 highprecisionmvs; |
37 | u8 allowcompinter; |
38 | u8 refreshctx; |
39 | u8 parallelmode; |
40 | u8 framectxid; |
41 | u8 use_last_frame_mvs; |
42 | u8 refidx[3]; |
43 | u8 signbias[3]; |
44 | u8 fixcompref; |
45 | u8 varcompref[2]; |
46 | struct { |
47 | u8 level; |
48 | char sharpness; |
49 | } filter; |
50 | struct { |
51 | u8 enabled; |
52 | u8 updated; |
53 | char mode[2]; |
54 | char ref[4]; |
55 | } lf_delta; |
56 | u8 yac_qi; |
57 | char ydc_qdelta, uvdc_qdelta, uvac_qdelta; |
58 | u8 lossless; |
59 | struct { |
60 | u8 enabled; |
61 | u8 temporal; |
62 | u8 absolute_vals; |
63 | u8 update_map; |
64 | u8 prob[7]; |
65 | u8 pred_prob[3]; |
66 | struct { |
67 | u8 q_enabled; |
68 | u8 lf_enabled; |
69 | u8 ref_enabled; |
70 | u8 skip_enabled; |
71 | u8 ref_val; |
72 | int16_t q_val; |
73 | char lf_val; |
74 | int16_t qmul[2][2]; |
75 | u8 lflvl[4][2]; |
76 | } feat[MAX_SEGMENT]; |
77 | } segmentation; |
78 | struct { |
79 | u32 log2_tile_cols, log2_tile_rows; |
80 | u32 tile_cols, tile_rows; |
81 | } tiling; |
82 | |
83 | int uncompressed_header_size; |
84 | int compressed_header_size; |
85 | }; |
86 | |
87 | struct VP9SharedContext { |
88 | struct VP9BitstreamHeader h; |
89 | |
90 | //struct ThreadFrame refs[8]; |
91 | #define CUR_FRAME 0 |
92 | #define REF_FRAME_MVPAIR 1 |
93 | #define REF_FRAME_SEGMAP 2 |
94 | //struct VP9Frame frames[3]; |
95 | }; |
96 | |
97 | struct VP9Context { |
98 | struct VP9SharedContext s; |
99 | struct get_bits_context gb; |
100 | int pass, active_tile_cols; |
101 | |
102 | u8 ss_h, ss_v; |
103 | u8 last_bpp, bpp_index, bytesperpixel; |
104 | u8 last_keyframe; |
105 | // sb_cols/rows, rows/cols and last_fmt are used for allocating all internal |
106 | // arrays, and are thus per-thread. w/h and gf_fmt are synced between threads |
107 | // and are therefore per-stream. pix_fmt represents the value in the header |
108 | // of the currently processed frame. |
109 | int width; |
110 | int height; |
111 | |
112 | int render_width; |
113 | int render_height; |
114 | |
115 | enum AVPixelFormat pix_fmt, last_fmt, gf_fmt; |
116 | u32 sb_cols, sb_rows, rows, cols; |
117 | |
118 | struct { |
119 | u8 lim_lut[64]; |
120 | u8 mblim_lut[64]; |
121 | } filter_lut; |
122 | struct { |
123 | u8 coef[4][2][2][6][6][3]; |
124 | } prob_ctx[4]; |
125 | struct { |
126 | u8 coef[4][2][2][6][6][11]; |
127 | } prob; |
128 | |
129 | // contextual (above) cache |
130 | u8 *above_partition_ctx; |
131 | u8 *above_mode_ctx; |
132 | // FIXME maybe merge some of the below in a flags field? |
133 | u8 *above_y_nnz_ctx; |
134 | u8 *above_uv_nnz_ctx[2]; |
135 | u8 *above_skip_ctx; // 1bit |
136 | u8 *above_txfm_ctx; // 2bit |
137 | u8 *above_segpred_ctx; // 1bit |
138 | u8 *above_intra_ctx; // 1bit |
139 | u8 *above_comp_ctx; // 1bit |
140 | u8 *above_ref_ctx; // 2bit |
141 | u8 *above_filter_ctx; |
142 | |
143 | // whole-frame cache |
144 | u8 *intra_pred_data[3]; |
145 | |
146 | // block reconstruction intermediates |
147 | int block_alloc_using_2pass; |
148 | uint16_t mvscale[3][2]; |
149 | u8 mvstep[3][2]; |
150 | }; |
151 | |
152 | struct vp9_superframe_split { |
153 | /*in data*/ |
154 | u8 *data; |
155 | u32 data_size; |
156 | |
157 | /*out data*/ |
158 | int nb_frames; |
159 | int size; |
160 | int next_frame; |
161 | u32 next_frame_offset; |
162 | int prefix_size; |
163 | int sizes[8]; |
164 | }; |
165 | |
166 | struct vp9_param_sets { |
167 | bool head_parsed; |
168 | struct VP9Context ctx; |
169 | }; |
170 | |
171 | int vp9_superframe_split_filter(struct vp9_superframe_split *s); |
172 | int vp9_decode_extradata_ps(u8 *data, int size, struct vp9_param_sets *ps); |
173 | |
174 | #endif //AML_VP9_PARSER_H |
175 |