hardware/intel/intel-driver
Revision | 4f0df22066c00528f463a0eb6f5c0b6f95e09b05 (tree) |
---|---|
Time | 2015-03-19 11:01:29 |
Author | Zhong Li <zhong.li@inte...> |
Commiter | Xiang, Haihao |
VP8 HWEnc: Build vp8 gen9 encoding vme pipeline
Signed-off-by: Zhong Li <zhong.li@intel.com>
(cherry picked from commit d8588862d85414ef412fd5e7ae1fb9ca78b69e84)
Conflicts:
src/i965_device_info.c
@@ -120,6 +120,31 @@ static struct i965_kernel gen9_vme_mpeg2_kernels[] = { | ||
120 | 120 | }, |
121 | 121 | }; |
122 | 122 | |
123 | +static const uint32_t gen9_vme_vp8_intra_frame[][4] = { | |
124 | +#include "shaders/vme/vp8_intra_frame_gen9.g9b" | |
125 | +}; | |
126 | + | |
127 | +static const uint32_t gen9_vme_vp8_inter_frame[][4] = { | |
128 | +#include "shaders/vme/inter_frame_gen9.g9b" | |
129 | +}; | |
130 | + | |
131 | +static struct i965_kernel gen9_vme_vp8_kernels[] = { | |
132 | + { | |
133 | + "VME Intra Frame", | |
134 | + VME_INTRA_SHADER, /*index*/ | |
135 | + gen9_vme_vp8_intra_frame, | |
136 | + sizeof(gen9_vme_vp8_intra_frame), | |
137 | + NULL | |
138 | + }, | |
139 | + { | |
140 | + "VME inter Frame", | |
141 | + VME_INTER_SHADER, | |
142 | + gen9_vme_vp8_inter_frame, | |
143 | + sizeof(gen9_vme_vp8_inter_frame), | |
144 | + NULL | |
145 | + }, | |
146 | +}; | |
147 | + | |
123 | 148 | /* only used for VME source surface state */ |
124 | 149 | static void |
125 | 150 | gen9_vme_source_surface_state(VADriverContextP ctx, |
@@ -170,16 +195,14 @@ static void | ||
170 | 195 | gen9_vme_output_buffer_setup(VADriverContextP ctx, |
171 | 196 | struct encode_state *encode_state, |
172 | 197 | int index, |
173 | - struct intel_encoder_context *encoder_context) | |
198 | + struct intel_encoder_context *encoder_context, | |
199 | + int is_intra, | |
200 | + int width_in_mbs, | |
201 | + int height_in_mbs) | |
174 | 202 | |
175 | 203 | { |
176 | 204 | struct i965_driver_data *i965 = i965_driver_data(ctx); |
177 | 205 | struct gen6_vme_context *vme_context = encoder_context->vme_context; |
178 | - VAEncSequenceParameterBufferH264 *pSequenceParameter = (VAEncSequenceParameterBufferH264 *)encode_state->seq_param_ext->buffer; | |
179 | - VAEncSliceParameterBufferH264 *pSliceParameter = (VAEncSliceParameterBufferH264 *)encode_state->slice_params_ext[0]->buffer; | |
180 | - int is_intra = pSliceParameter->slice_type == SLICE_TYPE_I; | |
181 | - int width_in_mbs = pSequenceParameter->picture_width_in_mbs; | |
182 | - int height_in_mbs = pSequenceParameter->picture_height_in_mbs; | |
183 | 206 | |
184 | 207 | vme_context->vme_output.num_blocks = width_in_mbs * height_in_mbs; |
185 | 208 | vme_context->vme_output.pitch = 16; /* in bytes, always 16 */ |
@@ -207,17 +230,31 @@ gen9_vme_output_buffer_setup(VADriverContextP ctx, | ||
207 | 230 | } |
208 | 231 | |
209 | 232 | static void |
233 | +gen9_vme_avc_output_buffer_setup(VADriverContextP ctx, | |
234 | + struct encode_state *encode_state, | |
235 | + int index, | |
236 | + struct intel_encoder_context *encoder_context) | |
237 | +{ | |
238 | + VAEncSequenceParameterBufferH264 *pSequenceParameter = (VAEncSequenceParameterBufferH264 *)encode_state->seq_param_ext->buffer; | |
239 | + VAEncSliceParameterBufferH264 *pSliceParameter = (VAEncSliceParameterBufferH264 *)encode_state->slice_params_ext[0]->buffer; | |
240 | + int is_intra = pSliceParameter->slice_type == SLICE_TYPE_I; | |
241 | + int width_in_mbs = pSequenceParameter->picture_width_in_mbs; | |
242 | + int height_in_mbs = pSequenceParameter->picture_height_in_mbs; | |
243 | + | |
244 | + gen9_vme_output_buffer_setup(ctx, encode_state, index, encoder_context, is_intra, width_in_mbs, height_in_mbs); | |
245 | + | |
246 | +} | |
247 | + | |
248 | +static void | |
210 | 249 | gen9_vme_output_vme_batchbuffer_setup(VADriverContextP ctx, |
211 | 250 | struct encode_state *encode_state, |
212 | 251 | int index, |
213 | - struct intel_encoder_context *encoder_context) | |
214 | - | |
252 | + struct intel_encoder_context *encoder_context, | |
253 | + int width_in_mbs, | |
254 | + int height_in_mbs) | |
215 | 255 | { |
216 | 256 | struct i965_driver_data *i965 = i965_driver_data(ctx); |
217 | 257 | struct gen6_vme_context *vme_context = encoder_context->vme_context; |
218 | - VAEncSequenceParameterBufferH264 *pSequenceParameter = (VAEncSequenceParameterBufferH264 *)encode_state->seq_param_ext->buffer; | |
219 | - int width_in_mbs = pSequenceParameter->picture_width_in_mbs; | |
220 | - int height_in_mbs = pSequenceParameter->picture_height_in_mbs; | |
221 | 258 | |
222 | 259 | vme_context->vme_batchbuffer.num_blocks = width_in_mbs * height_in_mbs + 1; |
223 | 260 | vme_context->vme_batchbuffer.size_block = 64; /* 4 OWORDs */ |
@@ -226,15 +263,27 @@ gen9_vme_output_vme_batchbuffer_setup(VADriverContextP ctx, | ||
226 | 263 | "VME batchbuffer", |
227 | 264 | vme_context->vme_batchbuffer.num_blocks * vme_context->vme_batchbuffer.size_block, |
228 | 265 | 0x1000); |
229 | - /* | |
230 | 266 | vme_context->vme_buffer_suface_setup(ctx, |
231 | 267 | &vme_context->gpe_context, |
232 | 268 | &vme_context->vme_batchbuffer, |
233 | 269 | BINDING_TABLE_OFFSET(index), |
234 | 270 | SURFACE_STATE_OFFSET(index)); |
235 | - */ | |
236 | 271 | } |
237 | 272 | |
273 | +static void | |
274 | +gen9_vme_avc_output_vme_batchbuffer_setup(VADriverContextP ctx, | |
275 | + struct encode_state *encode_state, | |
276 | + int index, | |
277 | + struct intel_encoder_context *encoder_context) | |
278 | +{ | |
279 | + VAEncSequenceParameterBufferH264 *pSequenceParameter = (VAEncSequenceParameterBufferH264 *)encode_state->seq_param_ext->buffer; | |
280 | + int width_in_mbs = pSequenceParameter->picture_width_in_mbs; | |
281 | + int height_in_mbs = pSequenceParameter->picture_height_in_mbs; | |
282 | + | |
283 | + gen9_vme_output_vme_batchbuffer_setup(ctx, encode_state, index, encoder_context, width_in_mbs, height_in_mbs); | |
284 | +} | |
285 | + | |
286 | + | |
238 | 287 | static VAStatus |
239 | 288 | gen9_vme_surface_setup(VADriverContextP ctx, |
240 | 289 | struct encode_state *encode_state, |
@@ -264,8 +313,8 @@ gen9_vme_surface_setup(VADriverContextP ctx, | ||
264 | 313 | } |
265 | 314 | |
266 | 315 | /* VME output */ |
267 | - gen9_vme_output_buffer_setup(ctx, encode_state, 3, encoder_context); | |
268 | - gen9_vme_output_vme_batchbuffer_setup(ctx, encode_state, 5, encoder_context); | |
316 | + gen9_vme_avc_output_buffer_setup(ctx, encode_state, 3, encoder_context); | |
317 | + gen9_vme_avc_output_vme_batchbuffer_setup(ctx, encode_state, 5, encoder_context); | |
269 | 318 | |
270 | 319 | return VA_STATUS_SUCCESS; |
271 | 320 | } |
@@ -727,35 +776,11 @@ gen9_vme_mpeg2_output_buffer_setup(VADriverContextP ctx, | ||
727 | 776 | struct intel_encoder_context *encoder_context) |
728 | 777 | |
729 | 778 | { |
730 | - struct i965_driver_data *i965 = i965_driver_data(ctx); | |
731 | - struct gen6_vme_context *vme_context = encoder_context->vme_context; | |
732 | 779 | VAEncSequenceParameterBufferMPEG2 *seq_param = (VAEncSequenceParameterBufferMPEG2 *)encode_state->seq_param_ext->buffer; |
733 | 780 | int width_in_mbs = ALIGN(seq_param->picture_width, 16) / 16; |
734 | 781 | int height_in_mbs = ALIGN(seq_param->picture_height, 16) / 16; |
735 | 782 | |
736 | - vme_context->vme_output.num_blocks = width_in_mbs * height_in_mbs; | |
737 | - vme_context->vme_output.pitch = 16; /* in bytes, always 16 */ | |
738 | - | |
739 | - if (is_intra) | |
740 | - vme_context->vme_output.size_block = INTRA_VME_OUTPUT_IN_BYTES * 2; | |
741 | - else | |
742 | - vme_context->vme_output.size_block = INTRA_VME_OUTPUT_IN_BYTES * 24; | |
743 | - /* | |
744 | - * Inter MV . 32-byte Intra search + 16 IME info + 128 IME MV + 32 IME Ref | |
745 | - * + 16 FBR Info + 128 FBR MV + 32 FBR Ref. | |
746 | - * 16 * (2 + 2 * (1 + 8 + 2))= 16 * 24. | |
747 | - */ | |
748 | - | |
749 | - vme_context->vme_output.bo = dri_bo_alloc(i965->intel.bufmgr, | |
750 | - "VME output buffer", | |
751 | - vme_context->vme_output.num_blocks * vme_context->vme_output.size_block, | |
752 | - 0x1000); | |
753 | - assert(vme_context->vme_output.bo); | |
754 | - vme_context->vme_buffer_suface_setup(ctx, | |
755 | - &vme_context->gpe_context, | |
756 | - &vme_context->vme_output, | |
757 | - BINDING_TABLE_OFFSET(index), | |
758 | - SURFACE_STATE_OFFSET(index)); | |
783 | + gen9_vme_output_buffer_setup(ctx, encode_state, index, encoder_context, is_intra, width_in_mbs, height_in_mbs); | |
759 | 784 | } |
760 | 785 | |
761 | 786 | static void |
@@ -765,24 +790,11 @@ gen9_vme_mpeg2_output_vme_batchbuffer_setup(VADriverContextP ctx, | ||
765 | 790 | struct intel_encoder_context *encoder_context) |
766 | 791 | |
767 | 792 | { |
768 | - struct i965_driver_data *i965 = i965_driver_data(ctx); | |
769 | - struct gen6_vme_context *vme_context = encoder_context->vme_context; | |
770 | 793 | VAEncSequenceParameterBufferMPEG2 *seq_param = (VAEncSequenceParameterBufferMPEG2 *)encode_state->seq_param_ext->buffer; |
771 | 794 | int width_in_mbs = ALIGN(seq_param->picture_width, 16) / 16; |
772 | 795 | int height_in_mbs = ALIGN(seq_param->picture_height, 16) / 16; |
773 | 796 | |
774 | - vme_context->vme_batchbuffer.num_blocks = width_in_mbs * height_in_mbs + 1; | |
775 | - vme_context->vme_batchbuffer.size_block = 64; /* 4 OWORDs */ | |
776 | - vme_context->vme_batchbuffer.pitch = 16; | |
777 | - vme_context->vme_batchbuffer.bo = dri_bo_alloc(i965->intel.bufmgr, | |
778 | - "VME batchbuffer", | |
779 | - vme_context->vme_batchbuffer.num_blocks * vme_context->vme_batchbuffer.size_block, | |
780 | - 0x1000); | |
781 | - vme_context->vme_buffer_suface_setup(ctx, | |
782 | - &vme_context->gpe_context, | |
783 | - &vme_context->vme_batchbuffer, | |
784 | - BINDING_TABLE_OFFSET(index), | |
785 | - SURFACE_STATE_OFFSET(index)); | |
797 | + gen9_vme_output_vme_batchbuffer_setup(ctx, encode_state, index, encoder_context, width_in_mbs, height_in_mbs); | |
786 | 798 | } |
787 | 799 | |
788 | 800 | static VAStatus |
@@ -1131,6 +1143,141 @@ gen9_vme_mpeg2_pipeline(VADriverContextP ctx, | ||
1131 | 1143 | } |
1132 | 1144 | |
1133 | 1145 | static void |
1146 | +gen9_vme_vp8_output_buffer_setup(VADriverContextP ctx, | |
1147 | + struct encode_state *encode_state, | |
1148 | + int index, | |
1149 | + int is_intra, | |
1150 | + struct intel_encoder_context *encoder_context) | |
1151 | +{ | |
1152 | + VAEncSequenceParameterBufferVP8 *seq_param = (VAEncSequenceParameterBufferVP8 *)encode_state->seq_param_ext->buffer; | |
1153 | + int width_in_mbs = ALIGN(seq_param->frame_width, 16) / 16; | |
1154 | + int height_in_mbs = ALIGN(seq_param->frame_height, 16) / 16; | |
1155 | + | |
1156 | + gen9_vme_output_buffer_setup(ctx, encode_state, index, encoder_context, is_intra, width_in_mbs, height_in_mbs); | |
1157 | +} | |
1158 | + | |
1159 | +static void | |
1160 | +gen9_vme_vp8_output_vme_batchbuffer_setup(VADriverContextP ctx, | |
1161 | + struct encode_state *encode_state, | |
1162 | + int index, | |
1163 | + struct intel_encoder_context *encoder_context) | |
1164 | +{ | |
1165 | + VAEncSequenceParameterBufferVP8 *seq_param = (VAEncSequenceParameterBufferVP8 *)encode_state->seq_param_ext->buffer; | |
1166 | + int width_in_mbs = ALIGN(seq_param->frame_width, 16) / 16; | |
1167 | + int height_in_mbs = ALIGN(seq_param->frame_height, 16) / 16; | |
1168 | + | |
1169 | + gen9_vme_output_vme_batchbuffer_setup(ctx, encode_state, index, encoder_context, width_in_mbs, height_in_mbs); | |
1170 | +} | |
1171 | + | |
1172 | +static VAStatus | |
1173 | +gen9_vme_vp8_surface_setup(VADriverContextP ctx, | |
1174 | + struct encode_state *encode_state, | |
1175 | + int is_intra, | |
1176 | + struct intel_encoder_context *encoder_context) | |
1177 | +{ | |
1178 | + struct object_surface *obj_surface; | |
1179 | + | |
1180 | + /*Setup surfaces state*/ | |
1181 | + /* current picture for encoding */ | |
1182 | + obj_surface = encode_state->input_yuv_object; | |
1183 | + gen9_vme_source_surface_state(ctx, 0, obj_surface, encoder_context); | |
1184 | + gen9_vme_media_source_surface_state(ctx, 4, obj_surface, encoder_context); | |
1185 | + gen9_vme_media_chroma_source_surface_state(ctx, 6, obj_surface, encoder_context); | |
1186 | + | |
1187 | + if (!is_intra) { | |
1188 | + /* reference 0 */ | |
1189 | + obj_surface = encode_state->reference_objects[0]; | |
1190 | + | |
1191 | + if (obj_surface->bo != NULL) | |
1192 | + gen9_vme_source_surface_state(ctx, 1, obj_surface, encoder_context); | |
1193 | + | |
1194 | + /* reference 1 */ | |
1195 | + obj_surface = encode_state->reference_objects[1]; | |
1196 | + | |
1197 | + if (obj_surface && obj_surface->bo != NULL) | |
1198 | + gen9_vme_source_surface_state(ctx, 2, obj_surface, encoder_context); | |
1199 | + } | |
1200 | + | |
1201 | + /* VME output */ | |
1202 | + gen9_vme_vp8_output_buffer_setup(ctx, encode_state, 3, is_intra, encoder_context); | |
1203 | + gen9_vme_vp8_output_vme_batchbuffer_setup(ctx, encode_state, 5, encoder_context); | |
1204 | + | |
1205 | + return VA_STATUS_SUCCESS; | |
1206 | +} | |
1207 | + | |
1208 | +static void | |
1209 | +gen9_vme_vp8_pipeline_programing(VADriverContextP ctx, | |
1210 | + struct encode_state *encode_state, | |
1211 | + int is_intra, | |
1212 | + struct intel_encoder_context *encoder_context) | |
1213 | +{ | |
1214 | + struct gen6_vme_context *vme_context = encoder_context->vme_context; | |
1215 | + struct intel_batchbuffer *batch = encoder_context->base.batch; | |
1216 | + VAEncSequenceParameterBufferVP8 *seq_param = (VAEncSequenceParameterBufferVP8 *)encode_state->seq_param_ext->buffer; | |
1217 | + int width_in_mbs = ALIGN(seq_param->frame_width, 16) / 16; | |
1218 | + int height_in_mbs = ALIGN(seq_param->frame_height, 16) / 16; | |
1219 | + int kernel_shader = (is_intra ? VME_INTRA_SHADER : VME_INTER_SHADER); | |
1220 | + | |
1221 | + gen9wa_vme_mpeg2_walker_fill_vme_batchbuffer(ctx, | |
1222 | + encode_state, | |
1223 | + width_in_mbs, height_in_mbs, | |
1224 | + kernel_shader, | |
1225 | + encoder_context); | |
1226 | + | |
1227 | + intel_batchbuffer_start_atomic(batch, 0x1000); | |
1228 | + gen9_gpe_pipeline_setup(ctx, &vme_context->gpe_context, batch); | |
1229 | + BEGIN_BATCH(batch, 4); | |
1230 | + OUT_BATCH(batch, MI_BATCH_BUFFER_START | (1 << 8) | (1 << 0)); | |
1231 | + OUT_RELOC(batch, | |
1232 | + vme_context->vme_batchbuffer.bo, | |
1233 | + I915_GEM_DOMAIN_COMMAND, 0, | |
1234 | + 0); | |
1235 | + OUT_BATCH(batch, 0); | |
1236 | + OUT_BATCH(batch, 0); | |
1237 | + ADVANCE_BATCH(batch); | |
1238 | + | |
1239 | + gen9_gpe_pipeline_end(ctx, &vme_context->gpe_context, batch); | |
1240 | + | |
1241 | + intel_batchbuffer_end_atomic(batch); | |
1242 | +} | |
1243 | + | |
1244 | +static VAStatus gen9_vme_vp8_prepare(VADriverContextP ctx, | |
1245 | + struct encode_state *encode_state, | |
1246 | + struct intel_encoder_context *encoder_context) | |
1247 | +{ | |
1248 | + VAStatus vaStatus = VA_STATUS_SUCCESS; | |
1249 | + VAEncPictureParameterBufferVP8 *pPicParameter = (VAEncPictureParameterBufferVP8 *)encode_state->pic_param_ext->buffer; | |
1250 | + int is_intra = !pPicParameter->pic_flags.bits.frame_type; | |
1251 | + | |
1252 | + /* add update vp8 mbmv cost later */ | |
1253 | + //intel_vme_update_mbmv_cost(ctx, encode_state, encoder_context); | |
1254 | + | |
1255 | + /*Setup all the memory object*/ | |
1256 | + gen9_vme_vp8_surface_setup(ctx, encode_state, is_intra, encoder_context); | |
1257 | + gen9_vme_interface_setup(ctx, encode_state, encoder_context); | |
1258 | + gen9_vme_constant_setup(ctx, encode_state, encoder_context); | |
1259 | + | |
1260 | + /*Programing media pipeline*/ | |
1261 | + gen9_vme_vp8_pipeline_programing(ctx, encode_state, is_intra, encoder_context); | |
1262 | + | |
1263 | + return vaStatus; | |
1264 | +} | |
1265 | + | |
1266 | +static VAStatus | |
1267 | +gen9_vme_vp8_pipeline(VADriverContextP ctx, | |
1268 | + VAProfile profile, | |
1269 | + struct encode_state *encode_state, | |
1270 | + struct intel_encoder_context *encoder_context) | |
1271 | +{ | |
1272 | + gen9_vme_media_init(ctx, encoder_context); | |
1273 | + gen9_vme_vp8_prepare(ctx, encode_state, encoder_context); | |
1274 | + gen9_vme_run(ctx, encode_state, encoder_context); | |
1275 | + gen9_vme_stop(ctx, encode_state, encoder_context); | |
1276 | + | |
1277 | + return VA_STATUS_SUCCESS; | |
1278 | +} | |
1279 | + | |
1280 | +static void | |
1134 | 1281 | gen9_vme_context_destroy(void *context) |
1135 | 1282 | { |
1136 | 1283 | struct gen6_vme_context *vme_context = context; |
@@ -1172,7 +1319,12 @@ Bool gen9_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *e | ||
1172 | 1319 | vme_kernel_list = gen9_vme_mpeg2_kernels; |
1173 | 1320 | encoder_context->vme_pipeline = gen9_vme_mpeg2_pipeline; |
1174 | 1321 | i965_kernel_num = sizeof(gen9_vme_mpeg2_kernels) / sizeof(struct i965_kernel); |
1322 | + break; | |
1175 | 1323 | |
1324 | + case CODEC_VP8: | |
1325 | + vme_kernel_list = gen9_vme_vp8_kernels; | |
1326 | + encoder_context->vme_pipeline = gen9_vme_vp8_pipeline; | |
1327 | + i965_kernel_num = sizeof(gen9_vme_vp8_kernels) / sizeof(struct i965_kernel); | |
1176 | 1328 | break; |
1177 | 1329 | |
1178 | 1330 | default: |
@@ -341,6 +341,7 @@ static struct hw_codec_info skl_hw_codec_info = { | ||
341 | 341 | .has_di_motion_adptive = 1, |
342 | 342 | .has_di_motion_compensated = 1, |
343 | 343 | .has_vp8_decoding = 1, |
344 | + .has_vp8_encoding = 1, | |
344 | 345 | .has_h264_mvc_encoding = 1, |
345 | 346 | .has_hevc_decoding = 1, |
346 | 347 |
@@ -34,6 +34,7 @@ | ||
34 | 34 | #include <va/va_enc_h264.h> |
35 | 35 | #include <va/va_enc_mpeg2.h> |
36 | 36 | #include <va/va_enc_jpeg.h> |
37 | +#include <va/va_enc_vp8.h> | |
37 | 38 | #include <va/va_vpp.h> |
38 | 39 | #include <va/va_backend.h> |
39 | 40 | #include <va/va_backend_vpp.h> |
@@ -453,6 +454,7 @@ va_enc_packed_type_to_idx(int packed_type); | ||
453 | 454 | #define CODEC_MPEG2 1 |
454 | 455 | #define CODEC_H264_MVC 2 |
455 | 456 | #define CODEC_JPEG 3 |
457 | +#define CODEC_VP8 4 | |
456 | 458 | |
457 | 459 | #define H264_DELIMITER0 0x00 |
458 | 460 | #define H264_DELIMITER1 0x00 |
@@ -554,6 +554,10 @@ intel_enc_hw_context_init(VADriverContextP ctx, | ||
554 | 554 | encoder_context->codec = CODEC_JPEG; |
555 | 555 | break; |
556 | 556 | |
557 | + case VAProfileVP8Version0_3: | |
558 | + encoder_context->codec = CODEC_VP8; | |
559 | + break; | |
560 | + | |
557 | 561 | default: |
558 | 562 | /* Never get here */ |
559 | 563 | assert(0); |