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);
76 void (*vme_buffer_suface_setup)(VADriverContextP ctx,
77 struct i965_gpe_context *gpe_context,
78 struct i965_buffer_surface *buffer_surface,
79 unsigned long binding_table_offset,
80 unsigned long surface_state_offset);
81 void (*vme_media_chroma_surface_setup)(VADriverContextP ctx,
82 struct i965_gpe_context *gpe_context,
83 struct object_surface *obj_surface,
84 unsigned long binding_table_offset,
85 unsigned long surface_state_offset);
86 void *vme_state_message;
87 unsigned int h264_level;
88 unsigned int hevc_level;
89 unsigned int video_coding_type;
90 unsigned int vme_kernel_sum;
91 unsigned int mpeg2_level;
93 struct object_surface *used_reference_objects[2];
94 void *used_references[2];
95 unsigned int ref_index_in_mb[2];
97 dri_bo *i_qp_cost_table;
98 dri_bo *p_qp_cost_table;
99 dri_bo *b_qp_cost_table;
102 /* one buffer define qp per mb. one byte for every mb.
103 * If it needs to be accessed by GPU, it will be changed to dri_bo.
107 int saved_width_mbs, saved_height_mbs;
110 #define MPEG2_PIC_WIDTH_HEIGHT 30
111 #define MPEG2_MV_RANGE 29
112 #define MPEG2_LEVEL_MASK 0x0f
113 #define MPEG2_LEVEL_LOW 0x0a
114 #define MPEG2_LEVEL_MAIN 0x08
115 #define MPEG2_LEVEL_HIGH 0x04
118 Bool gen75_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *encoder_context);
120 extern void intel_vme_update_mbmv_cost(VADriverContextP ctx,
121 struct encode_state *encode_state,
122 struct intel_encoder_context *encoder_context);
124 void intel_vme_vp8_update_mbmv_cost(VADriverContextP ctx,
125 struct encode_state *encode_state,
126 struct intel_encoder_context *encoder_context);
128 Bool gen7_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *encoder_context);
130 #define MODE_INTRA_NONPRED 0
131 #define MODE_INTRA_16X16 1
132 #define MODE_INTRA_8X8 2
133 #define MODE_INTRA_4X4 3
134 #define MODE_INTER_16X8 4
135 #define MODE_INTER_8X16 4
136 #define MODE_INTER_8X8 5
137 #define MODE_INTER_8X4 6
138 #define MODE_INTER_4X8 6
139 #define MODE_INTER_4X4 7
140 #define MODE_INTER_16X16 8
141 #define MODE_INTER_BWD 9
142 #define MODE_REFID_COST 10
143 #define MODE_CHROMA_INTRA 11
145 #define MODE_INTER_MV0 12
146 #define MODE_INTER_MV1 13
147 #define MODE_INTER_MV2 14
149 #define MODE_INTER_MV3 15
150 #define MODE_INTER_MV4 16
151 #define MODE_INTER_MV5 17
152 #define MODE_INTER_MV6 18
153 #define MODE_INTER_MV7 19
155 #define INTRA_PRED_AVAIL_FLAG_AE 0x60
156 #define INTRA_PRED_AVAIL_FLAG_B 0x10
157 #define INTRA_PRED_AVAIL_FLAG_C 0x8
158 #define INTRA_PRED_AVAIL_FLAG_D 0x4
159 #define INTRA_PRED_AVAIL_FLAG_BCD_MASK 0x1C
162 gen7_vme_walker_fill_vme_batchbuffer(VADriverContextP ctx,
163 struct encode_state *encode_state,
164 int mb_width, int mb_height,
166 int transform_8x8_mode_flag,
167 struct intel_encoder_context *encoder_context);
170 gen7_vme_scoreboard_init(VADriverContextP ctx, struct gen6_vme_context *vme_context);
173 intel_vme_mpeg2_state_setup(VADriverContextP ctx,
174 struct encode_state *encode_state,
175 struct intel_encoder_context *encoder_context);
178 gen7_vme_mpeg2_walker_fill_vme_batchbuffer(VADriverContextP ctx,
179 struct encode_state *encode_state,
180 int mb_width, int mb_height,
182 struct intel_encoder_context *encoder_context);
185 intel_avc_vme_reference_state(VADriverContextP ctx,
186 struct encode_state *encode_state,
187 struct intel_encoder_context *encoder_context,
190 void (* vme_source_surface_state)(
191 VADriverContextP ctx,
193 struct object_surface *obj_surface,
194 struct intel_encoder_context *encoder_context));
198 intel_hevc_vme_reference_state(VADriverContextP ctx,
199 struct encode_state *encode_state,
200 struct intel_encoder_context *encoder_context,
203 void (* vme_source_surface_state)(
204 VADriverContextP ctx,
206 struct object_surface *obj_surface,
207 struct intel_encoder_context *encoder_context));
209 void intel_vme_hevc_update_mbmv_cost(VADriverContextP ctx,
210 struct encode_state *encode_state,
211 struct intel_encoder_context *encoder_context);
214 extern Bool gen8_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *encoder_context);
216 extern Bool gen9_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *encoder_context);
219 intel_h264_initialize_mbmv_cost(VADriverContextP ctx,
220 struct encode_state *encode_state,
221 struct intel_encoder_context *encoder_context);
224 intel_h264_setup_cost_surface(VADriverContextP ctx,
225 struct encode_state *encode_state,
226 struct intel_encoder_context *encoder_context,
227 unsigned long binding_table_offset,
228 unsigned long surface_state_offset);
231 intel_h264_enc_roi_config(VADriverContextP ctx,
232 struct encode_state *encode_state,
233 struct intel_encoder_context *encoder_context);
235 #endif /* _GEN6_VME_H_ */