2 * Copyright © 2010 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
22 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 * Zhou Chang <chang.zhou@intel.com>
34 #include "intel_batchbuffer.h"
35 #include "intel_driver.h"
37 #include "i965_defines.h"
38 #include "i965_drv_video.h"
39 #include "i965_encoder.h"
44 extern Bool gen6_mfc_context_init(VADriverContextP ctx, struct intel_encoder_context *encoder_context);
45 extern Bool gen6_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *encoder_context);
46 extern Bool gen7_mfc_context_init(VADriverContextP ctx, struct intel_encoder_context *encoder_context);
47 extern Bool gen9_hcpe_context_init(VADriverContextP ctx, struct intel_encoder_context *encoder_context);
50 intel_encoder_check_yuv_surface(VADriverContextP ctx,
52 struct encode_state *encode_state,
53 struct intel_encoder_context *encoder_context)
55 struct i965_driver_data *i965 = i965_driver_data(ctx);
56 struct i965_surface src_surface, dst_surface;
57 struct object_surface *obj_surface;
61 /* releae the temporary surface */
62 if (encoder_context->is_tmp_id) {
63 i965_DestroySurfaces(ctx, &encoder_context->input_yuv_surface, 1);
64 encode_state->input_yuv_object = NULL;
67 encoder_context->is_tmp_id = 0;
68 obj_surface = SURFACE(encode_state->current_render_target);
69 assert(obj_surface && obj_surface->bo);
71 if (!obj_surface || !obj_surface->bo)
72 return VA_STATUS_ERROR_INVALID_PARAMETER;
74 if (obj_surface->fourcc == VA_FOURCC_NV12) {
75 unsigned int tiling = 0, swizzle = 0;
77 dri_bo_get_tiling(obj_surface->bo, &tiling, &swizzle);
79 if (tiling == I915_TILING_Y) {
80 encoder_context->input_yuv_surface = encode_state->current_render_target;
81 encode_state->input_yuv_object = obj_surface;
82 return VA_STATUS_SUCCESS;
88 rect.width = obj_surface->orig_width;
89 rect.height = obj_surface->orig_height;
91 src_surface.base = (struct object_base *)obj_surface;
92 src_surface.type = I965_SURFACE_TYPE_SURFACE;
93 src_surface.flags = I965_SURFACE_FLAG_FRAME;
95 status = i965_CreateSurfaces(ctx,
96 obj_surface->orig_width,
97 obj_surface->orig_height,
100 &encoder_context->input_yuv_surface);
101 assert(status == VA_STATUS_SUCCESS);
103 if (status != VA_STATUS_SUCCESS)
106 obj_surface = SURFACE(encoder_context->input_yuv_surface);
107 encode_state->input_yuv_object = obj_surface;
109 i965_check_alloc_surface_bo(ctx, obj_surface, 1, VA_FOURCC_NV12, SUBSAMPLE_YUV420);
111 dst_surface.base = (struct object_base *)obj_surface;
112 dst_surface.type = I965_SURFACE_TYPE_SURFACE;
113 dst_surface.flags = I965_SURFACE_FLAG_FRAME;
115 status = i965_image_processing(ctx,
120 assert(status == VA_STATUS_SUCCESS);
122 encoder_context->is_tmp_id = 1;
124 return VA_STATUS_SUCCESS;
129 intel_encoder_check_jpeg_yuv_surface(VADriverContextP ctx,
131 struct encode_state *encode_state,
132 struct intel_encoder_context *encoder_context)
134 struct i965_driver_data *i965 = i965_driver_data(ctx);
135 struct i965_surface src_surface, dst_surface;
136 struct object_surface *obj_surface;
139 int format=0, fourcc=0, subsample=0;
141 /* releae the temporary surface */
142 if (encoder_context->is_tmp_id) {
143 i965_DestroySurfaces(ctx, &encoder_context->input_yuv_surface, 1);
144 encode_state->input_yuv_object = NULL;
147 encoder_context->is_tmp_id = 0;
148 obj_surface = SURFACE(encode_state->current_render_target);
149 assert(obj_surface && obj_surface->bo);
151 if (!obj_surface || !obj_surface->bo)
152 return VA_STATUS_ERROR_INVALID_PARAMETER;
154 unsigned int tiling = 0, swizzle = 0;
156 dri_bo_get_tiling(obj_surface->bo, &tiling, &swizzle);
158 if (tiling == I915_TILING_Y) {
159 if( (obj_surface->fourcc==VA_FOURCC_NV12) || (obj_surface->fourcc==VA_FOURCC_UYVY) ||
160 (obj_surface->fourcc==VA_FOURCC_YUY2) || (obj_surface->fourcc==VA_FOURCC_Y800) ||
161 (obj_surface->fourcc==VA_FOURCC_RGBA) || (obj_surface->fourcc==VA_FOURCC_444P) ) {
162 encoder_context->input_yuv_surface = encode_state->current_render_target;
163 encode_state->input_yuv_object = obj_surface;
164 return VA_STATUS_SUCCESS;
170 rect.width = obj_surface->orig_width;
171 rect.height = obj_surface->orig_height;
173 src_surface.base = (struct object_base *)obj_surface;
174 src_surface.type = I965_SURFACE_TYPE_SURFACE;
175 src_surface.flags = I965_SURFACE_FLAG_FRAME;
177 switch( obj_surface->fourcc) {
180 fourcc = VA_FOURCC_YUY2;
181 format = VA_RT_FORMAT_YUV422;
182 subsample = SUBSAMPLE_YUV422H;
186 fourcc = VA_FOURCC_UYVY;
187 format = VA_RT_FORMAT_YUV422;
188 subsample = SUBSAMPLE_YUV422H;
192 fourcc = VA_FOURCC_Y800;
193 format = VA_RT_FORMAT_YUV400;
194 subsample = SUBSAMPLE_YUV400;
198 fourcc = VA_FOURCC_444P;
199 format = VA_RT_FORMAT_YUV444;
200 subsample = SUBSAMPLE_YUV444;
204 fourcc = VA_FOURCC_RGBA;
205 format = VA_RT_FORMAT_RGB32;
206 subsample = SUBSAMPLE_RGBX;
209 default: //All other scenarios will have NV12 format
210 fourcc = VA_FOURCC_NV12;
211 format = VA_RT_FORMAT_YUV420;
212 subsample = SUBSAMPLE_YUV420;
216 status = i965_CreateSurfaces(ctx,
217 obj_surface->orig_width,
218 obj_surface->orig_height,
221 &encoder_context->input_yuv_surface);
222 assert(status == VA_STATUS_SUCCESS);
224 if (status != VA_STATUS_SUCCESS)
227 obj_surface = SURFACE(encoder_context->input_yuv_surface);
228 encode_state->input_yuv_object = obj_surface;
230 i965_check_alloc_surface_bo(ctx, obj_surface, 1, fourcc, subsample);
232 dst_surface.base = (struct object_base *)obj_surface;
233 dst_surface.type = I965_SURFACE_TYPE_SURFACE;
234 dst_surface.flags = I965_SURFACE_FLAG_FRAME;
236 //The Y800 format is expected to be tiled.
237 //Linear Y800 is a corner case and needs code in the i965_image_processing.
238 if(obj_surface->fourcc != VA_FOURCC_Y800){
239 status = i965_image_processing(ctx,
244 assert(status == VA_STATUS_SUCCESS);
247 encoder_context->is_tmp_id = 1;
249 return VA_STATUS_SUCCESS;
253 intel_encoder_check_misc_parameter(VADriverContextP ctx,
254 struct encode_state *encode_state,
255 struct intel_encoder_context *encoder_context)
258 if (encode_state->misc_param[VAEncMiscParameterTypeQualityLevel] &&
259 encode_state->misc_param[VAEncMiscParameterTypeQualityLevel]->buffer) {
260 VAEncMiscParameterBuffer* pMiscParam = (VAEncMiscParameterBuffer*)encode_state->misc_param[VAEncMiscParameterTypeQualityLevel]->buffer;
261 VAEncMiscParameterBufferQualityLevel* param_quality_level = (VAEncMiscParameterBufferQualityLevel*)pMiscParam->data;
262 encoder_context->quality_level = param_quality_level->quality_level;
264 if (encoder_context->quality_level == 0)
265 encoder_context->quality_level = ENCODER_DEFAULT_QUALITY;
266 else if (encoder_context->quality_level > encoder_context->quality_range)
270 return VA_STATUS_SUCCESS;
273 return VA_STATUS_ERROR_INVALID_PARAMETER;
277 intel_encoder_check_avc_parameter(VADriverContextP ctx,
278 struct encode_state *encode_state,
279 struct intel_encoder_context *encoder_context)
281 struct i965_driver_data *i965 = i965_driver_data(ctx);
282 struct object_surface *obj_surface;
283 struct object_buffer *obj_buffer;
284 VAEncPictureParameterBufferH264 *pic_param = (VAEncPictureParameterBufferH264 *)encode_state->pic_param_ext->buffer;
287 assert(!(pic_param->CurrPic.flags & VA_PICTURE_H264_INVALID));
289 if (pic_param->CurrPic.flags & VA_PICTURE_H264_INVALID)
292 obj_surface = SURFACE(pic_param->CurrPic.picture_id);
293 assert(obj_surface); /* It is possible the store buffer isn't allocated yet */
298 encode_state->reconstructed_object = obj_surface;
299 obj_buffer = BUFFER(pic_param->coded_buf);
300 assert(obj_buffer && obj_buffer->buffer_store && obj_buffer->buffer_store->bo);
302 if (!obj_buffer || !obj_buffer->buffer_store || !obj_buffer->buffer_store->bo)
305 encode_state->coded_buf_object = obj_buffer;
307 for (i = 0; i < 16; i++) {
308 if (pic_param->ReferenceFrames[i].flags & VA_PICTURE_H264_INVALID ||
309 pic_param->ReferenceFrames[i].picture_id == VA_INVALID_SURFACE)
312 obj_surface = SURFACE(pic_param->ReferenceFrames[i].picture_id);
319 encode_state->reference_objects[i] = obj_surface;
321 encode_state->reference_objects[i] = NULL; /* FIXME: Warning or Error ??? */
326 encode_state->reference_objects[i] = NULL;
328 return VA_STATUS_SUCCESS;
331 return VA_STATUS_ERROR_INVALID_PARAMETER;
335 intel_encoder_check_mpeg2_parameter(VADriverContextP ctx,
336 struct encode_state *encode_state,
337 struct intel_encoder_context *encoder_context)
339 struct i965_driver_data *i965 = i965_driver_data(ctx);
340 VAEncPictureParameterBufferMPEG2 *pic_param = (VAEncPictureParameterBufferMPEG2 *)encode_state->pic_param_ext->buffer;
341 struct object_surface *obj_surface;
342 struct object_buffer *obj_buffer;
345 obj_surface = SURFACE(pic_param->reconstructed_picture);
346 assert(obj_surface); /* It is possible the store buffer isn't allocated yet */
351 encode_state->reconstructed_object = obj_surface;
352 obj_buffer = BUFFER(pic_param->coded_buf);
353 assert(obj_buffer && obj_buffer->buffer_store && obj_buffer->buffer_store->bo);
355 if (!obj_buffer || !obj_buffer->buffer_store || !obj_buffer->buffer_store->bo)
358 encode_state->coded_buf_object = obj_buffer;
360 if (pic_param->picture_type == VAEncPictureTypeIntra) {
361 } else if (pic_param->picture_type == VAEncPictureTypePredictive) {
362 assert(pic_param->forward_reference_picture != VA_INVALID_SURFACE);
363 obj_surface = SURFACE(pic_param->forward_reference_picture);
364 assert(obj_surface && obj_surface->bo);
366 if (!obj_surface || !obj_surface->bo)
369 encode_state->reference_objects[i++] = obj_surface;
370 } else if (pic_param->picture_type == VAEncPictureTypeBidirectional) {
371 assert(pic_param->forward_reference_picture != VA_INVALID_SURFACE);
372 obj_surface = SURFACE(pic_param->forward_reference_picture);
373 assert(obj_surface && obj_surface->bo);
375 if (!obj_surface || !obj_surface->bo)
378 encode_state->reference_objects[i++] = obj_surface;
380 assert(pic_param->backward_reference_picture != VA_INVALID_SURFACE);
381 obj_surface = SURFACE(pic_param->backward_reference_picture);
382 assert(obj_surface && obj_surface->bo);
384 if (!obj_surface || !obj_surface->bo)
387 encode_state->reference_objects[i++] = obj_surface;
392 encode_state->reference_objects[i] = NULL;
394 return VA_STATUS_SUCCESS;
397 return VA_STATUS_ERROR_INVALID_PARAMETER;
401 intel_encoder_check_jpeg_parameter(VADriverContextP ctx,
402 struct encode_state *encode_state,
403 struct intel_encoder_context *encoder_context)
405 struct i965_driver_data *i965 = i965_driver_data(ctx);
406 struct object_buffer *obj_buffer;
407 VAEncPictureParameterBufferJPEG *pic_param = (VAEncPictureParameterBufferJPEG *)encode_state->pic_param_ext->buffer;
410 assert(!(pic_param->pic_flags.bits.profile)); //Baseline profile is 0.
412 obj_buffer = BUFFER(pic_param->coded_buf);
413 assert(obj_buffer && obj_buffer->buffer_store && obj_buffer->buffer_store->bo);
415 if (!obj_buffer || !obj_buffer->buffer_store || !obj_buffer->buffer_store->bo)
418 encode_state->coded_buf_object = obj_buffer;
420 return VA_STATUS_SUCCESS;
423 return VA_STATUS_ERROR_INVALID_PARAMETER;
427 intel_encoder_check_vp8_parameter(VADriverContextP ctx,
428 struct encode_state *encode_state,
429 struct intel_encoder_context *encoder_context)
431 struct i965_driver_data *i965 = i965_driver_data(ctx);
432 VAEncPictureParameterBufferVP8 *pic_param = (VAEncPictureParameterBufferVP8 *)encode_state->pic_param_ext->buffer;
433 struct object_surface *obj_surface;
434 struct object_buffer *obj_buffer;
436 int is_key_frame = !pic_param->pic_flags.bits.frame_type;
438 obj_surface = SURFACE(pic_param->reconstructed_frame);
439 assert(obj_surface); /* It is possible the store buffer isn't allocated yet */
444 encode_state->reconstructed_object = obj_surface;
445 obj_buffer = BUFFER(pic_param->coded_buf);
446 assert(obj_buffer && obj_buffer->buffer_store && obj_buffer->buffer_store->bo);
448 if (!obj_buffer || !obj_buffer->buffer_store || !obj_buffer->buffer_store->bo)
451 encode_state->coded_buf_object = obj_buffer;
454 assert(pic_param->ref_last_frame != VA_INVALID_SURFACE);
455 obj_surface = SURFACE(pic_param->ref_last_frame);
456 assert(obj_surface && obj_surface->bo);
458 if (!obj_surface || !obj_surface->bo)
461 encode_state->reference_objects[i++] = obj_surface;
463 assert(pic_param->ref_gf_frame != VA_INVALID_SURFACE);
464 obj_surface = SURFACE(pic_param->ref_gf_frame);
465 assert(obj_surface && obj_surface->bo);
467 if (!obj_surface || !obj_surface->bo)
470 encode_state->reference_objects[i++] = obj_surface;
472 assert(pic_param->ref_arf_frame != VA_INVALID_SURFACE);
473 obj_surface = SURFACE(pic_param->ref_arf_frame);
474 assert(obj_surface && obj_surface->bo);
476 if (!obj_surface || !obj_surface->bo)
479 encode_state->reference_objects[i++] = obj_surface;
483 encode_state->reference_objects[i] = NULL;
485 return VA_STATUS_SUCCESS;
488 return VA_STATUS_ERROR_INVALID_PARAMETER;
492 intel_encoder_check_hevc_parameter(VADriverContextP ctx,
493 struct encode_state *encode_state,
494 struct intel_encoder_context *encoder_context)
496 struct i965_driver_data *i965 = i965_driver_data(ctx);
497 struct object_surface *obj_surface;
498 struct object_buffer *obj_buffer;
499 VAEncPictureParameterBufferHEVC *pic_param = (VAEncPictureParameterBufferHEVC *)encode_state->pic_param_ext->buffer;
500 VAEncSliceParameterBufferHEVC *slice_param;
503 assert(!(pic_param->decoded_curr_pic.flags & VA_PICTURE_HEVC_INVALID));
505 if (pic_param->decoded_curr_pic.flags & VA_PICTURE_HEVC_INVALID)
508 obj_surface = SURFACE(pic_param->decoded_curr_pic.picture_id);
509 assert(obj_surface); /* It is possible the store buffer isn't allocated yet */
514 encode_state->reconstructed_object = obj_surface;
515 obj_buffer = BUFFER(pic_param->coded_buf);
516 assert(obj_buffer && obj_buffer->buffer_store && obj_buffer->buffer_store->bo);
518 if (!obj_buffer || !obj_buffer->buffer_store || !obj_buffer->buffer_store->bo)
521 encode_state->coded_buf_object = obj_buffer;
523 for (i = 0; i < 15; i++) {
524 if (pic_param->reference_frames[i].flags & VA_PICTURE_HEVC_INVALID ||
525 pic_param->reference_frames[i].picture_id == VA_INVALID_SURFACE)
528 obj_surface = SURFACE(pic_param->reference_frames[i].picture_id);
535 encode_state->reference_objects[i] = obj_surface;
537 encode_state->reference_objects[i] = NULL; /* FIXME: Warning or Error ??? */
542 encode_state->reference_objects[i] = NULL;
544 for (i = 0; i < encode_state->num_slice_params_ext; i++) {
545 slice_param = (VAEncSliceParameterBufferHEVC *)encode_state->slice_params_ext[i]->buffer;
547 if (slice_param->slice_type != HEVC_SLICE_I &&
548 slice_param->slice_type != HEVC_SLICE_P &&
549 slice_param->slice_type != HEVC_SLICE_B)
552 /* TODO: add more check here */
555 return VA_STATUS_SUCCESS;
558 return VA_STATUS_ERROR_INVALID_PARAMETER;
561 intel_encoder_sanity_check_input(VADriverContextP ctx,
563 struct encode_state *encode_state,
564 struct intel_encoder_context *encoder_context)
569 case VAProfileH264ConstrainedBaseline:
570 case VAProfileH264Main:
571 case VAProfileH264High:
572 case VAProfileH264MultiviewHigh:
573 case VAProfileH264StereoHigh: {
574 vaStatus = intel_encoder_check_avc_parameter(ctx, encode_state, encoder_context);
575 if (vaStatus != VA_STATUS_SUCCESS)
577 vaStatus = intel_encoder_check_yuv_surface(ctx, profile, encode_state, encoder_context);
581 case VAProfileMPEG2Simple:
582 case VAProfileMPEG2Main: {
583 vaStatus = intel_encoder_check_mpeg2_parameter(ctx, encode_state, encoder_context);
584 if (vaStatus != VA_STATUS_SUCCESS)
586 vaStatus = intel_encoder_check_yuv_surface(ctx, profile, encode_state, encoder_context);
590 case VAProfileJPEGBaseline: {
591 vaStatus = intel_encoder_check_jpeg_parameter(ctx, encode_state, encoder_context);
592 if (vaStatus != VA_STATUS_SUCCESS)
594 vaStatus = intel_encoder_check_jpeg_yuv_surface(ctx, profile, encode_state, encoder_context);
598 case VAProfileVP8Version0_3: {
599 vaStatus = intel_encoder_check_vp8_parameter(ctx, encode_state, encoder_context);
600 if (vaStatus != VA_STATUS_SUCCESS)
602 vaStatus = intel_encoder_check_yuv_surface(ctx, profile, encode_state, encoder_context);
606 case VAProfileHEVCMain: {
607 vaStatus = intel_encoder_check_hevc_parameter(ctx, encode_state, encoder_context);
608 if (vaStatus != VA_STATUS_SUCCESS)
610 vaStatus = intel_encoder_check_yuv_surface(ctx, profile, encode_state, encoder_context);
614 vaStatus = VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
618 if (vaStatus == VA_STATUS_SUCCESS)
619 vaStatus = intel_encoder_check_misc_parameter(ctx, encode_state, encoder_context);
626 intel_encoder_end_picture(VADriverContextP ctx,
628 union codec_state *codec_state,
629 struct hw_context *hw_context)
631 struct intel_encoder_context *encoder_context = (struct intel_encoder_context *)hw_context;
632 struct encode_state *encode_state = &codec_state->encode;
635 vaStatus = intel_encoder_sanity_check_input(ctx, profile, encode_state, encoder_context);
637 if (vaStatus != VA_STATUS_SUCCESS)
640 encoder_context->mfc_brc_prepare(encode_state, encoder_context);
642 if((encoder_context->vme_context && encoder_context->vme_pipeline)) {
643 vaStatus = encoder_context->vme_pipeline(ctx, profile, encode_state, encoder_context);
646 if (vaStatus == VA_STATUS_SUCCESS)
647 encoder_context->mfc_pipeline(ctx, profile, encode_state, encoder_context);
648 return VA_STATUS_SUCCESS;
652 intel_encoder_context_destroy(void *hw_context)
654 struct intel_encoder_context *encoder_context = (struct intel_encoder_context *)hw_context;
656 encoder_context->mfc_context_destroy(encoder_context->mfc_context);
658 if (encoder_context->vme_context_destroy && encoder_context->vme_context)
659 encoder_context->vme_context_destroy(encoder_context->vme_context);
661 intel_batchbuffer_free(encoder_context->base.batch);
662 free(encoder_context);
667 intel_encoder_get_status(VADriverContextP ctx, struct hw_context *hw_context, void *buffer)
669 struct intel_encoder_context *encoder_context = (struct intel_encoder_context *)hw_context;
670 struct i965_coded_buffer_segment *coded_buffer_segment = (struct i965_coded_buffer_segment *)buffer;
672 if (encoder_context->get_status)
673 return encoder_context->get_status(ctx, encoder_context, coded_buffer_segment);
675 return VA_STATUS_ERROR_UNIMPLEMENTED;
678 typedef Bool (* hw_init_func)(VADriverContextP, struct intel_encoder_context *);
680 static struct hw_context *
681 intel_enc_hw_context_init(VADriverContextP ctx,
682 struct object_config *obj_config,
683 hw_init_func vme_context_init,
684 hw_init_func mfc_context_init)
686 struct intel_driver_data *intel = intel_driver_data(ctx);
687 struct intel_encoder_context *encoder_context = calloc(1, sizeof(struct intel_encoder_context));
690 assert(encoder_context);
691 encoder_context->base.destroy = intel_encoder_context_destroy;
692 encoder_context->base.run = intel_encoder_end_picture;
693 encoder_context->base.get_status = intel_encoder_get_status;
694 encoder_context->base.batch = intel_batchbuffer_new(intel, I915_EXEC_RENDER, 0);
695 encoder_context->input_yuv_surface = VA_INVALID_SURFACE;
696 encoder_context->is_tmp_id = 0;
697 encoder_context->rate_control_mode = VA_RC_NONE;
698 encoder_context->quality_level = ENCODER_DEFAULT_QUALITY;
699 encoder_context->quality_range = 1;
701 switch (obj_config->profile) {
702 case VAProfileMPEG2Simple:
703 case VAProfileMPEG2Main:
704 encoder_context->codec = CODEC_MPEG2;
707 case VAProfileH264ConstrainedBaseline:
708 case VAProfileH264Main:
709 case VAProfileH264High:
710 encoder_context->codec = CODEC_H264;
711 encoder_context->quality_range = ENCODER_QUALITY_RANGE;
714 case VAProfileH264StereoHigh:
715 case VAProfileH264MultiviewHigh:
716 encoder_context->codec = CODEC_H264_MVC;
719 case VAProfileJPEGBaseline:
720 encoder_context->codec = CODEC_JPEG;
723 case VAProfileVP8Version0_3:
724 encoder_context->codec = CODEC_VP8;
727 case VAProfileHEVCMain:
728 encoder_context->codec = CODEC_HEVC;
737 for (i = 0; i < obj_config->num_attribs; i++) {
738 if (obj_config->attrib_list[i].type == VAConfigAttribRateControl) {
739 encoder_context->rate_control_mode = obj_config->attrib_list[i].value;
741 if (encoder_context->codec == CODEC_MPEG2 &&
742 encoder_context->rate_control_mode & VA_RC_CBR) {
743 WARN_ONCE("Don't support CBR for MPEG-2 encoding\n");
744 encoder_context->rate_control_mode &= ~VA_RC_CBR;
751 vme_context_init(ctx, encoder_context);
752 if(obj_config->profile != VAProfileJPEGBaseline) {
753 assert(encoder_context->vme_context);
754 assert(encoder_context->vme_context_destroy);
755 assert(encoder_context->vme_pipeline);
758 mfc_context_init(ctx, encoder_context);
759 assert(encoder_context->mfc_context);
760 assert(encoder_context->mfc_context_destroy);
761 assert(encoder_context->mfc_pipeline);
763 return (struct hw_context *)encoder_context;
767 gen6_enc_hw_context_init(VADriverContextP ctx, struct object_config *obj_config)
769 return intel_enc_hw_context_init(ctx, obj_config, gen6_vme_context_init, gen6_mfc_context_init);
773 gen7_enc_hw_context_init(VADriverContextP ctx, struct object_config *obj_config)
776 return intel_enc_hw_context_init(ctx, obj_config, gen7_vme_context_init, gen7_mfc_context_init);
780 gen75_enc_hw_context_init(VADriverContextP ctx, struct object_config *obj_config)
782 return intel_enc_hw_context_init(ctx, obj_config, gen75_vme_context_init, gen75_mfc_context_init);
786 gen8_enc_hw_context_init(VADriverContextP ctx, struct object_config *obj_config)
788 return intel_enc_hw_context_init(ctx, obj_config, gen8_vme_context_init, gen8_mfc_context_init);
792 gen9_enc_hw_context_init(VADriverContextP ctx, struct object_config *obj_config)
794 if (obj_config->profile == VAProfileHEVCMain) {
795 return intel_enc_hw_context_init(ctx, obj_config, gen9_vme_context_init, gen9_hcpe_context_init);
796 } else if (obj_config->profile == VAProfileJPEGBaseline)
797 return intel_enc_hw_context_init(ctx, obj_config, gen8_vme_context_init, gen8_mfc_context_init);
799 return intel_enc_hw_context_init(ctx, obj_config, gen9_vme_context_init, gen9_mfc_context_init);