2 * Copyright © 2009 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sub license, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
19 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
20 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25 * Zhou Chang <chang.zhou@intel.com>
35 #include <intel_bufmgr.h>
37 #include "i965_gpe_utils.h"
39 #define INTRA_VME_OUTPUT_IN_BYTES 16 /* in bytes */
40 #define INTRA_VME_OUTPUT_IN_DWS (INTRA_VME_OUTPUT_IN_BYTES / 4)
41 #define INTER_VME_OUTPUT_IN_BYTES 160 /* the first 128 bytes for MVs and the last 32 bytes for other info */
42 #define INTER_VME_OUTPUT_IN_DWS (INTER_VME_OUTPUT_IN_BYTES / 4)
44 #define MAX_INTERFACE_DESC_GEN6 MAX_GPE_KERNELS
45 #define MAX_MEDIA_SURFACES_GEN6 34
47 #define GEN6_VME_KERNEL_NUMBER 3
49 #define INTEL_COST_TABLE_OFFSET 8
52 struct intel_encoder_context;
54 struct gen6_vme_context
56 struct i965_gpe_context gpe_context;
62 struct i965_buffer_surface vme_output;
63 struct i965_buffer_surface vme_batchbuffer;
66 void (*vme_surface2_setup)(VADriverContextP ctx,
67 struct i965_gpe_context *gpe_context,
68 struct object_surface *obj_surface,
69 unsigned long binding_table_offset,
70 unsigned long surface_state_offset);
71 void (*vme_media_rw_surface_setup)(VADriverContextP ctx,
72 struct i965_gpe_context *gpe_context,
73 struct object_surface *obj_surface,
74 unsigned long binding_table_offset,
75 unsigned long surface_state_offset,
77 void (*vme_buffer_suface_setup)(VADriverContextP ctx,
78 struct i965_gpe_context *gpe_context,
79 struct i965_buffer_surface *buffer_surface,
80 unsigned long binding_table_offset,
81 unsigned long surface_state_offset);
82 void (*vme_media_chroma_surface_setup)(VADriverContextP ctx,
83 struct i965_gpe_context *gpe_context,
84 struct object_surface *obj_surface,
85 unsigned long binding_table_offset,
86 unsigned long surface_state_offset,
88 void *vme_state_message;
89 unsigned int h264_level;
90 unsigned int hevc_level;
91 unsigned int video_coding_type;
92 unsigned int vme_kernel_sum;
93 unsigned int mpeg2_level;
95 struct object_surface *used_reference_objects[2];
96 void *used_references[2];
97 unsigned int ref_index_in_mb[2];
99 dri_bo *i_qp_cost_table;
100 dri_bo *p_qp_cost_table;
101 dri_bo *b_qp_cost_table;
104 /* one buffer define qp per mb. one byte for every mb.
105 * If it needs to be accessed by GPU, it will be changed to dri_bo.
109 int saved_width_mbs, saved_height_mbs;
112 #define MPEG2_PIC_WIDTH_HEIGHT 30
113 #define MPEG2_MV_RANGE 29
114 #define MPEG2_LEVEL_MASK 0x0f
115 #define MPEG2_LEVEL_LOW 0x0a
116 #define MPEG2_LEVEL_MAIN 0x08
117 #define MPEG2_LEVEL_HIGH 0x04
119 Bool gen6_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *encoder_context);
120 Bool gen75_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *encoder_context);
122 extern void intel_vme_update_mbmv_cost(VADriverContextP ctx,
123 struct encode_state *encode_state,
124 struct intel_encoder_context *encoder_context);
126 void intel_vme_vp8_update_mbmv_cost(VADriverContextP ctx,
127 struct encode_state *encode_state,
128 struct intel_encoder_context *encoder_context);
130 Bool gen7_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *encoder_context);
132 #define MODE_INTRA_NONPRED 0
133 #define MODE_INTRA_16X16 1
134 #define MODE_INTRA_8X8 2
135 #define MODE_INTRA_4X4 3
136 #define MODE_INTER_16X8 4
137 #define MODE_INTER_8X16 4
138 #define MODE_INTER_8X8 5
139 #define MODE_INTER_8X4 6
140 #define MODE_INTER_4X8 6
141 #define MODE_INTER_4X4 7
142 #define MODE_INTER_16X16 8
143 #define MODE_INTER_BWD 9
144 #define MODE_REFID_COST 10
145 #define MODE_CHROMA_INTRA 11
147 #define MODE_INTER_MV0 12
148 #define MODE_INTER_MV1 13
149 #define MODE_INTER_MV2 14
151 #define MODE_INTER_MV3 15
152 #define MODE_INTER_MV4 16
153 #define MODE_INTER_MV5 17
154 #define MODE_INTER_MV6 18
155 #define MODE_INTER_MV7 19
157 #define INTRA_PRED_AVAIL_FLAG_AE 0x60
158 #define INTRA_PRED_AVAIL_FLAG_B 0x10
159 #define INTRA_PRED_AVAIL_FLAG_C 0x8
160 #define INTRA_PRED_AVAIL_FLAG_D 0x4
161 #define INTRA_PRED_AVAIL_FLAG_BCD_MASK 0x1C
164 gen7_vme_walker_fill_vme_batchbuffer(VADriverContextP ctx,
165 struct encode_state *encode_state,
166 int mb_width, int mb_height,
168 int transform_8x8_mode_flag,
169 struct intel_encoder_context *encoder_context);
172 gen7_vme_scoreboard_init(VADriverContextP ctx, struct gen6_vme_context *vme_context);
175 intel_vme_mpeg2_state_setup(VADriverContextP ctx,
176 struct encode_state *encode_state,
177 struct intel_encoder_context *encoder_context);
180 gen7_vme_mpeg2_walker_fill_vme_batchbuffer(VADriverContextP ctx,
181 struct encode_state *encode_state,
182 int mb_width, int mb_height,
184 struct intel_encoder_context *encoder_context);
187 intel_avc_vme_reference_state(VADriverContextP ctx,
188 struct encode_state *encode_state,
189 struct intel_encoder_context *encoder_context,
192 void (* vme_source_surface_state)(
193 VADriverContextP ctx,
195 struct object_surface *obj_surface,
196 struct intel_encoder_context *encoder_context));
200 intel_hevc_vme_reference_state(VADriverContextP ctx,
201 struct encode_state *encode_state,
202 struct intel_encoder_context *encoder_context,
205 void (* vme_source_surface_state)(
206 VADriverContextP ctx,
208 struct object_surface *obj_surface,
209 struct intel_encoder_context *encoder_context));
211 void intel_vme_hevc_update_mbmv_cost(VADriverContextP ctx,
212 struct encode_state *encode_state,
213 struct intel_encoder_context *encoder_context);
216 extern Bool gen8_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *encoder_context);
218 extern Bool gen9_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *encoder_context);
221 intel_h264_initialize_mbmv_cost(VADriverContextP ctx,
222 struct encode_state *encode_state,
223 struct intel_encoder_context *encoder_context);
226 intel_h264_setup_cost_surface(VADriverContextP ctx,
227 struct encode_state *encode_state,
228 struct intel_encoder_context *encoder_context,
229 unsigned long binding_table_offset,
230 unsigned long surface_state_offset);
233 intel_h264_enc_roi_config(VADriverContextP ctx,
234 struct encode_state *encode_state,
235 struct intel_encoder_context *encoder_context);
237 #endif /* _GEN6_VME_H_ */