• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

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

hardware/intel/intel-driver


コミットメタ情報

リビジョン55ce72a89cd21ef22d3a30d9185bf393fa8e9cfe (tree)
日時2016-05-27 14:24:35
作者Zhao Yakui <yakui.zhao@inte...>
コミッターXiang, Haihao

ログメッセージ

Export the Vp9 encoding profile/entrypoint for KBL

Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Reviewed-by: Sean V Kelley <sean.v.kelley@intel.com>

変更サマリ

差分

--- a/src/i965_device_info.c
+++ b/src/i965_device_info.c
@@ -468,6 +468,7 @@ static struct hw_codec_info kbl_hw_codec_info = {
468468 .has_hevc10_decoding = 1,
469469 .has_vp9_decoding = 1,
470470 .has_vpp_p010 = 1,
471+ .has_vp9_encoding = 1,
471472
472473 .num_filters = 5,
473474 .filters = {
--- a/src/i965_drv_video.c
+++ b/src/i965_drv_video.c
@@ -48,6 +48,8 @@
4848 #include "i965_decoder.h"
4949 #include "i965_encoder.h"
5050
51+#include "gen9_vp9_encapi.h"
52+
5153 #define CONFIG_ID_OFFSET 0x01000000
5254 #define CONTEXT_ID_OFFSET 0x02000000
5355 #define SURFACE_ID_OFFSET 0x04000000
@@ -122,6 +124,9 @@
122124 #define HAS_VPP_P010(ctx) ((ctx)->codec_info->has_vpp_p010 && \
123125 (ctx)->intel.has_bsd)
124126
127+#define HAS_VP9_ENCODING(ctx) ((ctx)->codec_info->has_vp9_encoding && \
128+ (ctx)->intel.has_bsd)
129+
125130 static int get_sampling_from_fourcc(unsigned int fourcc);
126131
127132 /* Check whether we are rendering to X11 (VA/X11 or VA/GLX API) */
@@ -604,7 +609,8 @@ i965_QueryConfigProfiles(VADriverContextP ctx,
604609 profile_list[i++] = VAProfileHEVCMain10;
605610 }
606611
607- if(HAS_VP9_DECODING_PROFILE(i965, VAProfileVP9Profile0)) {
612+ if(HAS_VP9_DECODING_PROFILE(i965, VAProfileVP9Profile0) ||
613+ HAS_VP9_ENCODING(i965)) {
608614 profile_list[i++] = VAProfileVP9Profile0;
609615 }
610616
@@ -729,6 +735,9 @@ i965_QueryConfigEntrypoints(VADriverContextP ctx,
729735 if(HAS_VP9_DECODING_PROFILE(i965, profile))
730736 entrypoint_list[n++] = VAEntrypointVLD;
731737
738+ if (HAS_VP9_ENCODING(i965))
739+ entrypoint_list[n++] = VAEntrypointEncSlice;
740+
732741 if(profile == VAProfileVP9Profile0) {
733742 if (i965->wrapper_pdrvctx) {
734743 VAStatus va_status = VA_STATUS_SUCCESS;
@@ -854,6 +863,8 @@ i965_validate_config(VADriverContextP ctx, VAProfile profile,
854863 case VAProfileVP9Profile2:
855864 if ((HAS_VP9_DECODING_PROFILE(i965, profile)) && (entrypoint == VAEntrypointVLD))
856865 va_status = VA_STATUS_SUCCESS;
866+ else if ((HAS_VP9_ENCODING(i965)) && (entrypoint == VAEntrypointEncSlice))
867+ va_status = VA_STATUS_SUCCESS;
857868 else if ((profile == VAProfileVP9Profile0) && i965->wrapper_pdrvctx)
858869 va_status = VA_STATUS_SUCCESS;
859870 else
@@ -977,6 +988,8 @@ i965_GetConfigAttributes(VADriverContextP ctx,
977988 attrib_list[i].value |= (VA_ENC_PACKED_HEADER_RAW_DATA |
978989 VA_ENC_PACKED_HEADER_SLICE);
979990 }
991+ else if (profile == VAProfileVP9Profile0)
992+ attrib_list[i].value = VA_ENC_PACKED_HEADER_RAW_DATA;
980993 break;
981994 }
982995 else if (entrypoint == VAEntrypointEncPicture) {
@@ -2216,9 +2229,12 @@ i965_CreateContext(VADriverContextP ctx,
22162229
22172230 obj_context->codec_state.encode.slice_index = 0;
22182231 packed_attrib = i965_lookup_config_attribute(obj_config, VAConfigAttribEncPackedHeaders);
2219- if (packed_attrib)
2232+ if (packed_attrib) {
22202233 obj_context->codec_state.encode.packed_header_flag = packed_attrib->value;
2221- else {
2234+ if (obj_config->profile == VAProfileVP9Profile0)
2235+ obj_context->codec_state.encode.packed_header_flag =
2236+ packed_attrib->value & VA_ENC_PACKED_HEADER_RAW_DATA;
2237+ } else {
22222238 /* use the default value. SPS/PPS/RAWDATA is passed from user
22232239 * while Slice_header data is generated by driver.
22242240 */
@@ -2226,6 +2242,10 @@ i965_CreateContext(VADriverContextP ctx,
22262242 VA_ENC_PACKED_HEADER_SEQUENCE |
22272243 VA_ENC_PACKED_HEADER_PICTURE |
22282244 VA_ENC_PACKED_HEADER_RAW_DATA;
2245+
2246+ /* it is not used for VP9 */
2247+ if (obj_config->profile == VAProfileVP9Profile0)
2248+ obj_context->codec_state.encode.packed_header_flag = 0;
22292249 }
22302250 assert(i965->codec_info->enc_hw_context_init);
22312251 obj_context->hw_context = i965->codec_info->enc_hw_context_init(ctx, obj_config);
@@ -2601,7 +2621,16 @@ i965_MapBuffer(VADriverContextP ctx,
26012621 coded_buffer_segment->status_support) {
26022622 vaStatus = obj_context->hw_context->get_status(ctx, obj_context->hw_context, coded_buffer_segment);
26032623 } else {
2604- if (coded_buffer_segment->codec == CODEC_H264 ||
2624+
2625+ if (coded_buffer_segment->codec == CODEC_VP9) {
2626+
2627+ if (obj_context == NULL)
2628+ return VA_STATUS_ERROR_ENCODING_ERROR;
2629+
2630+ gen9_vp9_get_coded_status(ctx, (char *)coded_buffer_segment,
2631+ obj_context->hw_context);
2632+ }
2633+ else if (coded_buffer_segment->codec == CODEC_H264 ||
26052634 coded_buffer_segment->codec == CODEC_H264_MVC) {
26062635 delimiter0 = H264_DELIMITER0;
26072636 delimiter1 = H264_DELIMITER1;
@@ -2628,6 +2657,9 @@ i965_MapBuffer(VADriverContextP ctx,
26282657 ASSERT_RET(0, VA_STATUS_ERROR_UNSUPPORTED_PROFILE);
26292658 }
26302659
2660+ if(coded_buffer_segment->codec == CODEC_VP9) {
2661+ /* it is already handled */
2662+ } else
26312663 if(coded_buffer_segment->codec == CODEC_JPEG) {
26322664 for(i = 0; i < obj_buffer->size_element - header_offset - 1 - 0x1000; i++) {
26332665 if( (buffer[i] == 0xFF) && (buffer[i + 1] == 0xD9)) {
@@ -3242,10 +3274,14 @@ i965_encoder_render_picture(VADriverContextP ctx,
32423274 vaStatus = VA_STATUS_ERROR_INVALID_PARAMETER;
32433275 return vaStatus;
32443276 }
3277+
32453278 if (encode->last_packed_header_type == VAEncPackedHeaderRawData ||
32463279 encode->last_packed_header_type == VAEncPackedHeaderSlice) {
32473280 vaStatus = I965_RENDER_ENCODE_BUFFER(packed_header_data_ext);
32483281
3282+ if (obj_config->profile == VAProfileVP9Profile0)
3283+ break;
3284+
32493285 /* When the PACKED_SLICE_HEADER flag is passed, it will use
32503286 * the packed_slice_header as the delimeter to decide how
32513287 * the packed rawdata is inserted for the given slice.
@@ -3455,11 +3491,14 @@ i965_EndPicture(VADriverContextP ctx, VAContextID context)
34553491 if (!(obj_context->codec_state.encode.seq_param ||
34563492 obj_context->codec_state.encode.seq_param_ext) &&
34573493 (VAEntrypointEncPicture != obj_config->entrypoint)) {
3458- return VA_STATUS_ERROR_INVALID_PARAMETER;
3494+ /* The seq_param is not mandatory for VP9 encoding */
3495+ if (obj_config->profile != VAProfileVP9Profile0)
3496+ return VA_STATUS_ERROR_INVALID_PARAMETER;
34593497 }
34603498 if ((obj_context->codec_state.encode.num_slice_params <=0) &&
34613499 (obj_context->codec_state.encode.num_slice_params_ext <=0) &&
3462- (obj_config->profile != VAProfileVP8Version0_3)) {
3500+ ((obj_config->profile != VAProfileVP8Version0_3) &&
3501+ (obj_config->profile != VAProfileVP9Profile0))) {
34633502 return VA_STATUS_ERROR_INVALID_PARAMETER;
34643503 }
34653504
--- a/src/i965_drv_video.h
+++ b/src/i965_drv_video.h
@@ -400,6 +400,7 @@ struct hw_codec_info
400400 unsigned int has_vp9_decoding:1;
401401 unsigned int has_vpp_p010:1;
402402 unsigned int has_lp_h264_encoding:1;
403+ unsigned int has_vp9_encoding:1;
403404
404405 unsigned int lp_h264_brc_mode;
405406
@@ -490,6 +491,7 @@ va_enc_packed_type_to_idx(int packed_type);
490491 #define CODEC_JPEG 3
491492 #define CODEC_VP8 4
492493 #define CODEC_HEVC 5
494+#define CODEC_VP9 6
493495
494496 #define H264_DELIMITER0 0x00
495497 #define H264_DELIMITER1 0x00
--- a/src/i965_encoder.c
+++ b/src/i965_encoder.c
@@ -42,6 +42,8 @@
4242 #include "gen9_mfc.h"
4343 #include "gen9_vdenc.h"
4444
45+#include "gen9_vp9_encapi.h"
46+
4547 extern Bool gen6_mfc_context_init(VADriverContextP ctx, struct intel_encoder_context *encoder_context);
4648 extern Bool gen6_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *encoder_context);
4749 extern Bool gen7_mfc_context_init(VADriverContextP ctx, struct intel_encoder_context *encoder_context);
@@ -558,6 +560,76 @@ intel_encoder_check_hevc_parameter(VADriverContextP ctx,
558560 error:
559561 return VA_STATUS_ERROR_INVALID_PARAMETER;
560562 }
563+
564+static VAStatus
565+intel_encoder_check_vp9_parameter(VADriverContextP ctx,
566+ struct encode_state *encode_state,
567+ struct intel_encoder_context *encoder_context)
568+{
569+ struct i965_driver_data *i965 = i965_driver_data(ctx);
570+ VAEncPictureParameterBufferVP9 *pic_param;
571+ struct object_surface *obj_surface;
572+ struct object_buffer *obj_buffer;
573+ int i = 0;
574+ int is_key_frame = 0;
575+ int index;
576+
577+ if (encode_state->pic_param_ext == NULL ||
578+ encode_state->pic_param_ext->buffer == NULL)
579+ return VA_STATUS_ERROR_INVALID_PARAMETER;
580+
581+ pic_param = (VAEncPictureParameterBufferVP9 *)encode_state->pic_param_ext->buffer;
582+
583+ obj_surface = SURFACE(pic_param->reconstructed_frame);
584+
585+ if (!obj_surface)
586+ goto error;
587+
588+ encode_state->reconstructed_object = obj_surface;
589+ obj_buffer = BUFFER(pic_param->coded_buf);
590+
591+ if (!obj_buffer || !obj_buffer->buffer_store || !obj_buffer->buffer_store->bo)
592+ goto error;
593+
594+ encode_state->coded_buf_object = obj_buffer;
595+
596+ is_key_frame = !pic_param->pic_flags.bits.frame_type;
597+ if (!is_key_frame && !pic_param->pic_flags.bits.intra_only) {
598+ /* slot 0 is for last reference frame */
599+ index = pic_param->ref_flags.bits.ref_last_idx;
600+ obj_surface = SURFACE(pic_param->reference_frames[index]);
601+ if (obj_surface && obj_surface->bo)
602+ encode_state->reference_objects[i++] = obj_surface;
603+ else
604+ encode_state->reference_objects[i++] = NULL;
605+
606+ /* slot 1 is for golden reference frame */
607+ index = pic_param->ref_flags.bits.ref_gf_idx;
608+ obj_surface = SURFACE(pic_param->reference_frames[index]);
609+ if (obj_surface && obj_surface->bo)
610+ encode_state->reference_objects[i++] = obj_surface;
611+ else
612+ encode_state->reference_objects[i++] = NULL;
613+
614+ /* slot 2 is alt reference frame */
615+ index = pic_param->ref_flags.bits.ref_arf_idx;
616+ obj_surface = SURFACE(pic_param->reference_frames[index]);
617+ if (obj_surface && obj_surface->bo)
618+ encode_state->reference_objects[i++] = obj_surface;
619+ else
620+ encode_state->reference_objects[i++] = NULL;
621+ }
622+
623+ for ( ; i < 16; i++)
624+ encode_state->reference_objects[i] = NULL;
625+
626+ return VA_STATUS_SUCCESS;
627+
628+error:
629+ return VA_STATUS_ERROR_INVALID_PARAMETER;
630+}
631+
632+
561633 static VAStatus
562634 intel_encoder_sanity_check_input(VADriverContextP ctx,
563635 VAProfile profile,
@@ -611,6 +683,13 @@ intel_encoder_sanity_check_input(VADriverContextP ctx,
611683 vaStatus = intel_encoder_check_yuv_surface(ctx, profile, encode_state, encoder_context);
612684 break;
613685 }
686+
687+ case VAProfileVP9Profile0: {
688+ vaStatus = intel_encoder_check_vp9_parameter(ctx, encode_state, encoder_context);
689+ if (vaStatus != VA_STATUS_SUCCESS)
690+ goto out;
691+ break;
692+ }
614693 default:
615694 vaStatus = VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
616695 break;
@@ -739,6 +818,10 @@ intel_enc_hw_context_init(VADriverContextP ctx,
739818 encoder_context->codec = CODEC_HEVC;
740819 break;
741820
821+ case VAProfileVP9Profile0:
822+ encoder_context->codec = CODEC_VP9;
823+ break;
824+
742825 default:
743826 /* Never get here */
744827 assert(0);
@@ -814,6 +897,10 @@ gen9_enc_hw_context_init(VADriverContextP ctx, struct object_config *obj_config)
814897 return intel_enc_hw_context_init(ctx, obj_config, gen9_vme_context_init, gen9_hcpe_context_init);
815898 } else if (obj_config->profile == VAProfileJPEGBaseline)
816899 return intel_enc_hw_context_init(ctx, obj_config, gen8_vme_context_init, gen8_mfc_context_init);
900+ else if (obj_config->profile == VAProfileVP9Profile0)
901+ return intel_enc_hw_context_init(ctx, obj_config,
902+ gen9_vp9_vme_context_init,
903+ gen9_vp9_pak_context_init);
817904 else
818905 return intel_enc_hw_context_init(ctx, obj_config, gen9_vme_context_init, gen9_mfc_context_init);
819906 }