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