hardware/intel/intel-driver
Revisión | 0c1319692f8be32e90afd80861c40a449df160a2 (tree) |
---|---|
Tiempo | 2016-05-09 17:52:22 |
Autor | Xiang, Haihao <haihao.xiang@inte...> |
Commiter | Xiang, Haihao |
Add support for VAEntrypointEncSliceLP
VAEntrypointEncSliceLP is used to expose low power variant of slice level
encoding entrypoint and we will implement low power encoding on SKL
Signed-off-by: Xiang, Haihao <haihao.xiang@intel.com>
Reviewed-By: Sean V Kelley <sean.v.kelley@intel.com>
@@ -67,6 +67,9 @@ | ||
67 | 67 | #define HAS_H264_ENCODING(ctx) ((ctx)->codec_info->has_h264_encoding && \ |
68 | 68 | (ctx)->intel.has_bsd) |
69 | 69 | |
70 | +#define HAS_LP_H264_ENCODING(ctx) ((ctx)->codec_info->has_lp_h264_encoding && \ | |
71 | + (ctx)->intel.has_bsd) | |
72 | + | |
70 | 73 | #define HAS_VC1_DECODING(ctx) ((ctx)->codec_info->has_vc1_decoding && \ |
71 | 74 | (ctx)->intel.has_bsd) |
72 | 75 |
@@ -559,7 +562,8 @@ i965_QueryConfigProfiles(VADriverContextP ctx, | ||
559 | 562 | } |
560 | 563 | |
561 | 564 | if (HAS_H264_DECODING(i965) || |
562 | - HAS_H264_ENCODING(i965)) { | |
565 | + HAS_H264_ENCODING(i965) || | |
566 | + HAS_LP_H264_ENCODING(i965)) { | |
563 | 567 | profile_list[i++] = VAProfileH264ConstrainedBaseline; |
564 | 568 | profile_list[i++] = VAProfileH264Main; |
565 | 569 | profile_list[i++] = VAProfileH264High; |
@@ -663,6 +667,9 @@ i965_QueryConfigEntrypoints(VADriverContextP ctx, | ||
663 | 667 | if (HAS_H264_ENCODING(i965)) |
664 | 668 | entrypoint_list[n++] = VAEntrypointEncSlice; |
665 | 669 | |
670 | + if (HAS_LP_H264_ENCODING(i965)) | |
671 | + entrypoint_list[n++] = VAEntrypointEncSliceLP; | |
672 | + | |
666 | 673 | break; |
667 | 674 | case VAProfileH264MultiviewHigh: |
668 | 675 | case VAProfileH264StereoHigh: |
@@ -770,7 +777,8 @@ i965_validate_config(VADriverContextP ctx, VAProfile profile, | ||
770 | 777 | case VAProfileH264Main: |
771 | 778 | case VAProfileH264High: |
772 | 779 | if ((HAS_H264_DECODING(i965) && entrypoint == VAEntrypointVLD) || |
773 | - (HAS_H264_ENCODING(i965) && entrypoint == VAEntrypointEncSlice)) { | |
780 | + (HAS_H264_ENCODING(i965) && entrypoint == VAEntrypointEncSlice) || | |
781 | + (HAS_LP_H264_ENCODING(i965) && entrypoint == VAEntrypointEncSliceLP)) { | |
774 | 782 | va_status = VA_STATUS_SUCCESS; |
775 | 783 | } else { |
776 | 784 | va_status = VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT; |
@@ -941,11 +949,24 @@ i965_GetConfigAttributes(VADriverContextP ctx, | ||
941 | 949 | profile != VAProfileMPEG2Simple) |
942 | 950 | attrib_list[i].value |= VA_RC_CBR; |
943 | 951 | break; |
944 | - } | |
952 | + } else if (entrypoint == VAEntrypointEncSliceLP) { | |
953 | + struct i965_driver_data * const i965 = i965_driver_data(ctx); | |
954 | + | |
955 | + /* Support low power encoding for H.264 only by now */ | |
956 | + if (profile == VAProfileH264ConstrainedBaseline || | |
957 | + profile == VAProfileH264Main || | |
958 | + profile == VAProfileH264High) | |
959 | + attrib_list[i].value = i965->codec_info->lp_h264_brc_mode; | |
960 | + else | |
961 | + attrib_list[i].value = VA_ATTRIB_NOT_SUPPORTED; | |
962 | + } else | |
963 | + attrib_list[i].value = VA_ATTRIB_NOT_SUPPORTED; | |
964 | + | |
945 | 965 | break; |
946 | 966 | |
947 | 967 | case VAConfigAttribEncPackedHeaders: |
948 | - if (entrypoint == VAEntrypointEncSlice) { | |
968 | + if (entrypoint == VAEntrypointEncSlice || | |
969 | + entrypoint == VAEntrypointEncSliceLP) { | |
949 | 970 | attrib_list[i].value = VA_ENC_PACKED_HEADER_SEQUENCE | VA_ENC_PACKED_HEADER_PICTURE | VA_ENC_PACKED_HEADER_MISC; |
950 | 971 | if (profile == VAProfileH264ConstrainedBaseline || |
951 | 972 | profile == VAProfileH264Main || |
@@ -965,14 +986,23 @@ i965_GetConfigAttributes(VADriverContextP ctx, | ||
965 | 986 | break; |
966 | 987 | |
967 | 988 | case VAConfigAttribEncMaxRefFrames: |
968 | - if (entrypoint == VAEntrypointEncSlice) { | |
989 | + if (entrypoint == VAEntrypointEncSlice) | |
969 | 990 | attrib_list[i].value = (1 << 16) | (1 << 0); |
970 | - break; | |
991 | + else if (entrypoint == VAEntrypointEncSliceLP) { | |
992 | + /* Don't support B frame for low power mode */ | |
993 | + if (profile == VAProfileH264ConstrainedBaseline || | |
994 | + profile == VAProfileH264Main || | |
995 | + profile == VAProfileH264High) | |
996 | + attrib_list[i].value = (1 << 0); | |
997 | + else | |
998 | + attrib_list[i].value = VA_ATTRIB_NOT_SUPPORTED; | |
971 | 999 | } |
1000 | + | |
972 | 1001 | break; |
973 | 1002 | |
974 | 1003 | case VAConfigAttribEncQualityRange: |
975 | - if (entrypoint == VAEntrypointEncSlice) { | |
1004 | + if (entrypoint == VAEntrypointEncSlice || | |
1005 | + entrypoint == VAEntrypointEncSliceLP) { | |
976 | 1006 | attrib_list[i].value = 1; |
977 | 1007 | if (profile == VAProfileH264ConstrainedBaseline || |
978 | 1008 | profile == VAProfileH264Main || |
@@ -1000,6 +1030,17 @@ i965_GetConfigAttributes(VADriverContextP ctx, | ||
1000 | 1030 | attrib_list[i].value = VA_DEC_SLICE_MODE_NORMAL; |
1001 | 1031 | break; |
1002 | 1032 | |
1033 | + case VAConfigAttribEncROI: | |
1034 | + if ((entrypoint == VAEntrypointEncSliceLP) && | |
1035 | + (profile == VAProfileH264ConstrainedBaseline || | |
1036 | + profile == VAProfileH264Main || | |
1037 | + profile == VAProfileH264High)) | |
1038 | + attrib_list[i].value = 3; | |
1039 | + else | |
1040 | + attrib_list[i].value = 0; | |
1041 | + | |
1042 | + break; | |
1043 | + | |
1003 | 1044 | default: |
1004 | 1045 | /* Do nothing */ |
1005 | 1046 | attrib_list[i].value = VA_ATTRIB_NOT_SUPPORTED; |
@@ -2142,7 +2183,8 @@ i965_CreateContext(VADriverContextP ctx, | ||
2142 | 2183 | assert(i965->codec_info->proc_hw_context_init); |
2143 | 2184 | obj_context->hw_context = i965->codec_info->proc_hw_context_init(ctx, obj_config); |
2144 | 2185 | } else if ((VAEntrypointEncSlice == obj_config->entrypoint) || |
2145 | - (VAEntrypointEncPicture == obj_config->entrypoint)) { /*encode routine only*/ | |
2186 | + (VAEntrypointEncPicture == obj_config->entrypoint) || | |
2187 | + (VAEntrypointEncSliceLP == obj_config->entrypoint)) { | |
2146 | 2188 | VAConfigAttrib *packed_attrib; |
2147 | 2189 | obj_context->codec_type = CODEC_ENC; |
2148 | 2190 | memset(&obj_context->codec_state.encode, 0, sizeof(obj_context->codec_state.encode)); |
@@ -3361,7 +3403,8 @@ i965_RenderPicture(VADriverContextP ctx, | ||
3361 | 3403 | if (VAEntrypointVideoProc == obj_config->entrypoint) { |
3362 | 3404 | vaStatus = i965_proc_render_picture(ctx, context, buffers, num_buffers); |
3363 | 3405 | } else if ((VAEntrypointEncSlice == obj_config->entrypoint ) || |
3364 | - (VAEntrypointEncPicture == obj_config->entrypoint)) { | |
3406 | + (VAEntrypointEncPicture == obj_config->entrypoint) || | |
3407 | + (VAEntrypointEncSliceLP == obj_config->entrypoint)) { | |
3365 | 3408 | vaStatus = i965_encoder_render_picture(ctx, context, buffers, num_buffers); |
3366 | 3409 | } else { |
3367 | 3410 | vaStatus = i965_decoder_render_picture(ctx, context, buffers, num_buffers); |
@@ -3384,7 +3427,10 @@ i965_EndPicture(VADriverContextP ctx, VAContextID context) | ||
3384 | 3427 | if (obj_context->codec_type == CODEC_PROC) { |
3385 | 3428 | ASSERT_RET(VAEntrypointVideoProc == obj_config->entrypoint, VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT); |
3386 | 3429 | } else if (obj_context->codec_type == CODEC_ENC) { |
3387 | - ASSERT_RET(((VAEntrypointEncSlice == obj_config->entrypoint) || (VAEntrypointEncPicture == obj_config->entrypoint)), VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT); | |
3430 | + ASSERT_RET(((VAEntrypointEncSlice == obj_config->entrypoint) || | |
3431 | + (VAEntrypointEncPicture == obj_config->entrypoint) || | |
3432 | + (VAEntrypointEncSliceLP == obj_config->entrypoint)), | |
3433 | + VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT); | |
3388 | 3434 | |
3389 | 3435 | if (obj_context->codec_state.encode.num_packed_header_params_ext != |
3390 | 3436 | obj_context->codec_state.encode.num_packed_header_data_ext) { |
@@ -5318,7 +5364,8 @@ i965_GetSurfaceAttributes( | ||
5318 | 5364 | IS_GEN8(i965->intel.device_info) || |
5319 | 5365 | IS_GEN9(i965->intel.device_info)) { |
5320 | 5366 | if (obj_config->entrypoint == VAEntrypointEncSlice || |
5321 | - obj_config->entrypoint == VAEntrypointVideoProc) { | |
5367 | + obj_config->entrypoint == VAEntrypointVideoProc || | |
5368 | + obj_config->entrypoint == VAEntrypointEncSliceLP) { | |
5322 | 5369 | switch (attrib_list[i].value.value.i) { |
5323 | 5370 | case VA_FOURCC_NV12: |
5324 | 5371 | case VA_FOURCC_I420: |
@@ -5668,7 +5715,8 @@ i965_QuerySurfaceAttributes(VADriverContextP ctx, | ||
5668 | 5715 | i++; |
5669 | 5716 | } |
5670 | 5717 | } else if (obj_config->entrypoint == VAEntrypointEncSlice || /* encode */ |
5671 | - obj_config->entrypoint == VAEntrypointVideoProc) { /* vpp */ | |
5718 | + obj_config->entrypoint == VAEntrypointVideoProc || | |
5719 | + obj_config->entrypoint == VAEntrypointEncSliceLP) { | |
5672 | 5720 | |
5673 | 5721 | if (obj_config->profile == VAProfileHEVCMain10) { |
5674 | 5722 | attribs[i].type = VASurfaceAttribPixelFormat; |
@@ -73,6 +73,8 @@ | ||
73 | 73 | #define ENCODER_HIGH_QUALITY ENCODER_DEFAULT_QUALITY |
74 | 74 | #define ENCODER_LOW_QUALITY 2 |
75 | 75 | |
76 | +#define ENCODER_LP_QUALITY_RANGE 8 | |
77 | + | |
76 | 78 | struct i965_surface |
77 | 79 | { |
78 | 80 | struct object_base *base; |
@@ -396,6 +398,9 @@ struct hw_codec_info | ||
396 | 398 | unsigned int has_hevc10_decoding:1; |
397 | 399 | unsigned int has_vp9_decoding:1; |
398 | 400 | unsigned int has_vpp_p010:1; |
401 | + unsigned int has_lp_h264_encoding:1; | |
402 | + | |
403 | + unsigned int lp_h264_brc_mode; | |
399 | 404 | |
400 | 405 | unsigned int num_filters; |
401 | 406 | struct i965_filter filters[VAProcFilterCount]; |
@@ -694,6 +694,7 @@ intel_enc_hw_context_init(VADriverContextP ctx, | ||
694 | 694 | encoder_context->base.batch = intel_batchbuffer_new(intel, I915_EXEC_RENDER, 0); |
695 | 695 | encoder_context->input_yuv_surface = VA_INVALID_SURFACE; |
696 | 696 | encoder_context->is_tmp_id = 0; |
697 | + encoder_context->low_power_mode = 0; | |
697 | 698 | encoder_context->rate_control_mode = VA_RC_NONE; |
698 | 699 | encoder_context->quality_level = ENCODER_DEFAULT_QUALITY; |
699 | 700 | encoder_context->quality_range = 1; |
@@ -708,7 +709,11 @@ intel_enc_hw_context_init(VADriverContextP ctx, | ||
708 | 709 | case VAProfileH264Main: |
709 | 710 | case VAProfileH264High: |
710 | 711 | encoder_context->codec = CODEC_H264; |
711 | - encoder_context->quality_range = ENCODER_QUALITY_RANGE; | |
712 | + | |
713 | + if (obj_config->entrypoint == VAEntrypointEncSliceLP) | |
714 | + encoder_context->quality_range = ENCODER_LP_QUALITY_RANGE; | |
715 | + else | |
716 | + encoder_context->quality_range = ENCODER_QUALITY_RANGE; | |
712 | 717 | break; |
713 | 718 | |
714 | 719 | case VAProfileH264StereoHigh: |
@@ -748,11 +753,16 @@ intel_enc_hw_context_init(VADriverContextP ctx, | ||
748 | 753 | } |
749 | 754 | } |
750 | 755 | |
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); | |
756 | + if (vme_context_init) { | |
757 | + vme_context_init(ctx, encoder_context); | |
758 | + | |
759 | + if (obj_config->profile != VAProfileJPEGBaseline) { | |
760 | + assert(encoder_context->vme_context); | |
761 | + assert(encoder_context->vme_context_destroy); | |
762 | + assert(encoder_context->vme_pipeline); | |
763 | + } | |
764 | + } else { | |
765 | + encoder_context->low_power_mode = 1; | |
756 | 766 | } |
757 | 767 | |
758 | 768 | mfc_context_init(ctx, encoder_context); |
@@ -41,12 +41,15 @@ struct intel_encoder_context | ||
41 | 41 | struct hw_context base; |
42 | 42 | int codec; |
43 | 43 | VASurfaceID input_yuv_surface; |
44 | - int is_tmp_id; | |
45 | 44 | unsigned int rate_control_mode; |
46 | 45 | unsigned int quality_level; |
47 | 46 | unsigned int quality_range; |
48 | 47 | void *vme_context; |
49 | 48 | void *mfc_context; |
49 | + | |
50 | + unsigned int is_tmp_id:1; | |
51 | + unsigned int low_power_mode:1; | |
52 | + | |
50 | 53 | void (*vme_context_destroy)(void *vme_context); |
51 | 54 | VAStatus (*vme_pipeline)(VADriverContextP ctx, |
52 | 55 | VAProfile profile, |