• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

hardware/intel/intel-driver


Commit MetaInfo

Revision4f0df22066c00528f463a0eb6f5c0b6f95e09b05 (tree)
Time2015-03-19 11:01:29
AuthorZhong Li <zhong.li@inte...>
CommiterXiang, Haihao

Log Message

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

Change Summary

Incremental Difference

--- a/src/gen9_vme.c
+++ b/src/gen9_vme.c
@@ -120,6 +120,31 @@ static struct i965_kernel gen9_vme_mpeg2_kernels[] = {
120120 },
121121 };
122122
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+
123148 /* only used for VME source surface state */
124149 static void
125150 gen9_vme_source_surface_state(VADriverContextP ctx,
@@ -170,16 +195,14 @@ static void
170195 gen9_vme_output_buffer_setup(VADriverContextP ctx,
171196 struct encode_state *encode_state,
172197 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)
174202
175203 {
176204 struct i965_driver_data *i965 = i965_driver_data(ctx);
177205 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;
183206
184207 vme_context->vme_output.num_blocks = width_in_mbs * height_in_mbs;
185208 vme_context->vme_output.pitch = 16; /* in bytes, always 16 */
@@ -207,17 +230,31 @@ gen9_vme_output_buffer_setup(VADriverContextP ctx,
207230 }
208231
209232 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
210249 gen9_vme_output_vme_batchbuffer_setup(VADriverContextP ctx,
211250 struct encode_state *encode_state,
212251 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)
215255 {
216256 struct i965_driver_data *i965 = i965_driver_data(ctx);
217257 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;
221258
222259 vme_context->vme_batchbuffer.num_blocks = width_in_mbs * height_in_mbs + 1;
223260 vme_context->vme_batchbuffer.size_block = 64; /* 4 OWORDs */
@@ -226,15 +263,27 @@ gen9_vme_output_vme_batchbuffer_setup(VADriverContextP ctx,
226263 "VME batchbuffer",
227264 vme_context->vme_batchbuffer.num_blocks * vme_context->vme_batchbuffer.size_block,
228265 0x1000);
229- /*
230266 vme_context->vme_buffer_suface_setup(ctx,
231267 &vme_context->gpe_context,
232268 &vme_context->vme_batchbuffer,
233269 BINDING_TABLE_OFFSET(index),
234270 SURFACE_STATE_OFFSET(index));
235- */
236271 }
237272
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+
238287 static VAStatus
239288 gen9_vme_surface_setup(VADriverContextP ctx,
240289 struct encode_state *encode_state,
@@ -264,8 +313,8 @@ gen9_vme_surface_setup(VADriverContextP ctx,
264313 }
265314
266315 /* 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);
269318
270319 return VA_STATUS_SUCCESS;
271320 }
@@ -727,35 +776,11 @@ gen9_vme_mpeg2_output_buffer_setup(VADriverContextP ctx,
727776 struct intel_encoder_context *encoder_context)
728777
729778 {
730- struct i965_driver_data *i965 = i965_driver_data(ctx);
731- struct gen6_vme_context *vme_context = encoder_context->vme_context;
732779 VAEncSequenceParameterBufferMPEG2 *seq_param = (VAEncSequenceParameterBufferMPEG2 *)encode_state->seq_param_ext->buffer;
733780 int width_in_mbs = ALIGN(seq_param->picture_width, 16) / 16;
734781 int height_in_mbs = ALIGN(seq_param->picture_height, 16) / 16;
735782
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);
759784 }
760785
761786 static void
@@ -765,24 +790,11 @@ gen9_vme_mpeg2_output_vme_batchbuffer_setup(VADriverContextP ctx,
765790 struct intel_encoder_context *encoder_context)
766791
767792 {
768- struct i965_driver_data *i965 = i965_driver_data(ctx);
769- struct gen6_vme_context *vme_context = encoder_context->vme_context;
770793 VAEncSequenceParameterBufferMPEG2 *seq_param = (VAEncSequenceParameterBufferMPEG2 *)encode_state->seq_param_ext->buffer;
771794 int width_in_mbs = ALIGN(seq_param->picture_width, 16) / 16;
772795 int height_in_mbs = ALIGN(seq_param->picture_height, 16) / 16;
773796
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);
786798 }
787799
788800 static VAStatus
@@ -1131,6 +1143,141 @@ gen9_vme_mpeg2_pipeline(VADriverContextP ctx,
11311143 }
11321144
11331145 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
11341281 gen9_vme_context_destroy(void *context)
11351282 {
11361283 struct gen6_vme_context *vme_context = context;
@@ -1172,7 +1319,12 @@ Bool gen9_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *e
11721319 vme_kernel_list = gen9_vme_mpeg2_kernels;
11731320 encoder_context->vme_pipeline = gen9_vme_mpeg2_pipeline;
11741321 i965_kernel_num = sizeof(gen9_vme_mpeg2_kernels) / sizeof(struct i965_kernel);
1322+ break;
11751323
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);
11761328 break;
11771329
11781330 default:
--- a/src/i965_device_info.c
+++ b/src/i965_device_info.c
@@ -341,6 +341,7 @@ static struct hw_codec_info skl_hw_codec_info = {
341341 .has_di_motion_adptive = 1,
342342 .has_di_motion_compensated = 1,
343343 .has_vp8_decoding = 1,
344+ .has_vp8_encoding = 1,
344345 .has_h264_mvc_encoding = 1,
345346 .has_hevc_decoding = 1,
346347
--- a/src/i965_drv_video.h
+++ b/src/i965_drv_video.h
@@ -34,6 +34,7 @@
3434 #include <va/va_enc_h264.h>
3535 #include <va/va_enc_mpeg2.h>
3636 #include <va/va_enc_jpeg.h>
37+#include <va/va_enc_vp8.h>
3738 #include <va/va_vpp.h>
3839 #include <va/va_backend.h>
3940 #include <va/va_backend_vpp.h>
@@ -453,6 +454,7 @@ va_enc_packed_type_to_idx(int packed_type);
453454 #define CODEC_MPEG2 1
454455 #define CODEC_H264_MVC 2
455456 #define CODEC_JPEG 3
457+#define CODEC_VP8 4
456458
457459 #define H264_DELIMITER0 0x00
458460 #define H264_DELIMITER1 0x00
--- a/src/i965_encoder.c
+++ b/src/i965_encoder.c
@@ -554,6 +554,10 @@ intel_enc_hw_context_init(VADriverContextP ctx,
554554 encoder_context->codec = CODEC_JPEG;
555555 break;
556556
557+ case VAProfileVP8Version0_3:
558+ encoder_context->codec = CODEC_VP8;
559+ break;
560+
557561 default:
558562 /* Never get here */
559563 assert(0);