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>
@@ -468,6 +468,7 @@ static struct hw_codec_info kbl_hw_codec_info = { | ||
468 | 468 | .has_hevc10_decoding = 1, |
469 | 469 | .has_vp9_decoding = 1, |
470 | 470 | .has_vpp_p010 = 1, |
471 | + .has_vp9_encoding = 1, | |
471 | 472 | |
472 | 473 | .num_filters = 5, |
473 | 474 | .filters = { |
@@ -48,6 +48,8 @@ | ||
48 | 48 | #include "i965_decoder.h" |
49 | 49 | #include "i965_encoder.h" |
50 | 50 | |
51 | +#include "gen9_vp9_encapi.h" | |
52 | + | |
51 | 53 | #define CONFIG_ID_OFFSET 0x01000000 |
52 | 54 | #define CONTEXT_ID_OFFSET 0x02000000 |
53 | 55 | #define SURFACE_ID_OFFSET 0x04000000 |
@@ -122,6 +124,9 @@ | ||
122 | 124 | #define HAS_VPP_P010(ctx) ((ctx)->codec_info->has_vpp_p010 && \ |
123 | 125 | (ctx)->intel.has_bsd) |
124 | 126 | |
127 | +#define HAS_VP9_ENCODING(ctx) ((ctx)->codec_info->has_vp9_encoding && \ | |
128 | + (ctx)->intel.has_bsd) | |
129 | + | |
125 | 130 | static int get_sampling_from_fourcc(unsigned int fourcc); |
126 | 131 | |
127 | 132 | /* Check whether we are rendering to X11 (VA/X11 or VA/GLX API) */ |
@@ -604,7 +609,8 @@ i965_QueryConfigProfiles(VADriverContextP ctx, | ||
604 | 609 | profile_list[i++] = VAProfileHEVCMain10; |
605 | 610 | } |
606 | 611 | |
607 | - if(HAS_VP9_DECODING_PROFILE(i965, VAProfileVP9Profile0)) { | |
612 | + if(HAS_VP9_DECODING_PROFILE(i965, VAProfileVP9Profile0) || | |
613 | + HAS_VP9_ENCODING(i965)) { | |
608 | 614 | profile_list[i++] = VAProfileVP9Profile0; |
609 | 615 | } |
610 | 616 |
@@ -729,6 +735,9 @@ i965_QueryConfigEntrypoints(VADriverContextP ctx, | ||
729 | 735 | if(HAS_VP9_DECODING_PROFILE(i965, profile)) |
730 | 736 | entrypoint_list[n++] = VAEntrypointVLD; |
731 | 737 | |
738 | + if (HAS_VP9_ENCODING(i965)) | |
739 | + entrypoint_list[n++] = VAEntrypointEncSlice; | |
740 | + | |
732 | 741 | if(profile == VAProfileVP9Profile0) { |
733 | 742 | if (i965->wrapper_pdrvctx) { |
734 | 743 | VAStatus va_status = VA_STATUS_SUCCESS; |
@@ -854,6 +863,8 @@ i965_validate_config(VADriverContextP ctx, VAProfile profile, | ||
854 | 863 | case VAProfileVP9Profile2: |
855 | 864 | if ((HAS_VP9_DECODING_PROFILE(i965, profile)) && (entrypoint == VAEntrypointVLD)) |
856 | 865 | va_status = VA_STATUS_SUCCESS; |
866 | + else if ((HAS_VP9_ENCODING(i965)) && (entrypoint == VAEntrypointEncSlice)) | |
867 | + va_status = VA_STATUS_SUCCESS; | |
857 | 868 | else if ((profile == VAProfileVP9Profile0) && i965->wrapper_pdrvctx) |
858 | 869 | va_status = VA_STATUS_SUCCESS; |
859 | 870 | else |
@@ -977,6 +988,8 @@ i965_GetConfigAttributes(VADriverContextP ctx, | ||
977 | 988 | attrib_list[i].value |= (VA_ENC_PACKED_HEADER_RAW_DATA | |
978 | 989 | VA_ENC_PACKED_HEADER_SLICE); |
979 | 990 | } |
991 | + else if (profile == VAProfileVP9Profile0) | |
992 | + attrib_list[i].value = VA_ENC_PACKED_HEADER_RAW_DATA; | |
980 | 993 | break; |
981 | 994 | } |
982 | 995 | else if (entrypoint == VAEntrypointEncPicture) { |
@@ -2216,9 +2229,12 @@ i965_CreateContext(VADriverContextP ctx, | ||
2216 | 2229 | |
2217 | 2230 | obj_context->codec_state.encode.slice_index = 0; |
2218 | 2231 | packed_attrib = i965_lookup_config_attribute(obj_config, VAConfigAttribEncPackedHeaders); |
2219 | - if (packed_attrib) | |
2232 | + if (packed_attrib) { | |
2220 | 2233 | 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 { | |
2222 | 2238 | /* use the default value. SPS/PPS/RAWDATA is passed from user |
2223 | 2239 | * while Slice_header data is generated by driver. |
2224 | 2240 | */ |
@@ -2226,6 +2242,10 @@ i965_CreateContext(VADriverContextP ctx, | ||
2226 | 2242 | VA_ENC_PACKED_HEADER_SEQUENCE | |
2227 | 2243 | VA_ENC_PACKED_HEADER_PICTURE | |
2228 | 2244 | 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; | |
2229 | 2249 | } |
2230 | 2250 | assert(i965->codec_info->enc_hw_context_init); |
2231 | 2251 | obj_context->hw_context = i965->codec_info->enc_hw_context_init(ctx, obj_config); |
@@ -2601,7 +2621,16 @@ i965_MapBuffer(VADriverContextP ctx, | ||
2601 | 2621 | coded_buffer_segment->status_support) { |
2602 | 2622 | vaStatus = obj_context->hw_context->get_status(ctx, obj_context->hw_context, coded_buffer_segment); |
2603 | 2623 | } 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 || | |
2605 | 2634 | coded_buffer_segment->codec == CODEC_H264_MVC) { |
2606 | 2635 | delimiter0 = H264_DELIMITER0; |
2607 | 2636 | delimiter1 = H264_DELIMITER1; |
@@ -2628,6 +2657,9 @@ i965_MapBuffer(VADriverContextP ctx, | ||
2628 | 2657 | ASSERT_RET(0, VA_STATUS_ERROR_UNSUPPORTED_PROFILE); |
2629 | 2658 | } |
2630 | 2659 | |
2660 | + if(coded_buffer_segment->codec == CODEC_VP9) { | |
2661 | + /* it is already handled */ | |
2662 | + } else | |
2631 | 2663 | if(coded_buffer_segment->codec == CODEC_JPEG) { |
2632 | 2664 | for(i = 0; i < obj_buffer->size_element - header_offset - 1 - 0x1000; i++) { |
2633 | 2665 | if( (buffer[i] == 0xFF) && (buffer[i + 1] == 0xD9)) { |
@@ -3242,10 +3274,14 @@ i965_encoder_render_picture(VADriverContextP ctx, | ||
3242 | 3274 | vaStatus = VA_STATUS_ERROR_INVALID_PARAMETER; |
3243 | 3275 | return vaStatus; |
3244 | 3276 | } |
3277 | + | |
3245 | 3278 | if (encode->last_packed_header_type == VAEncPackedHeaderRawData || |
3246 | 3279 | encode->last_packed_header_type == VAEncPackedHeaderSlice) { |
3247 | 3280 | vaStatus = I965_RENDER_ENCODE_BUFFER(packed_header_data_ext); |
3248 | 3281 | |
3282 | + if (obj_config->profile == VAProfileVP9Profile0) | |
3283 | + break; | |
3284 | + | |
3249 | 3285 | /* When the PACKED_SLICE_HEADER flag is passed, it will use |
3250 | 3286 | * the packed_slice_header as the delimeter to decide how |
3251 | 3287 | * the packed rawdata is inserted for the given slice. |
@@ -3455,11 +3491,14 @@ i965_EndPicture(VADriverContextP ctx, VAContextID context) | ||
3455 | 3491 | if (!(obj_context->codec_state.encode.seq_param || |
3456 | 3492 | obj_context->codec_state.encode.seq_param_ext) && |
3457 | 3493 | (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; | |
3459 | 3497 | } |
3460 | 3498 | if ((obj_context->codec_state.encode.num_slice_params <=0) && |
3461 | 3499 | (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))) { | |
3463 | 3502 | return VA_STATUS_ERROR_INVALID_PARAMETER; |
3464 | 3503 | } |
3465 | 3504 |
@@ -400,6 +400,7 @@ struct hw_codec_info | ||
400 | 400 | unsigned int has_vp9_decoding:1; |
401 | 401 | unsigned int has_vpp_p010:1; |
402 | 402 | unsigned int has_lp_h264_encoding:1; |
403 | + unsigned int has_vp9_encoding:1; | |
403 | 404 | |
404 | 405 | unsigned int lp_h264_brc_mode; |
405 | 406 |
@@ -490,6 +491,7 @@ va_enc_packed_type_to_idx(int packed_type); | ||
490 | 491 | #define CODEC_JPEG 3 |
491 | 492 | #define CODEC_VP8 4 |
492 | 493 | #define CODEC_HEVC 5 |
494 | +#define CODEC_VP9 6 | |
493 | 495 | |
494 | 496 | #define H264_DELIMITER0 0x00 |
495 | 497 | #define H264_DELIMITER1 0x00 |
@@ -42,6 +42,8 @@ | ||
42 | 42 | #include "gen9_mfc.h" |
43 | 43 | #include "gen9_vdenc.h" |
44 | 44 | |
45 | +#include "gen9_vp9_encapi.h" | |
46 | + | |
45 | 47 | extern Bool gen6_mfc_context_init(VADriverContextP ctx, struct intel_encoder_context *encoder_context); |
46 | 48 | extern Bool gen6_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *encoder_context); |
47 | 49 | 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, | ||
558 | 560 | error: |
559 | 561 | return VA_STATUS_ERROR_INVALID_PARAMETER; |
560 | 562 | } |
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 | + | |
561 | 633 | static VAStatus |
562 | 634 | intel_encoder_sanity_check_input(VADriverContextP ctx, |
563 | 635 | VAProfile profile, |
@@ -611,6 +683,13 @@ intel_encoder_sanity_check_input(VADriverContextP ctx, | ||
611 | 683 | vaStatus = intel_encoder_check_yuv_surface(ctx, profile, encode_state, encoder_context); |
612 | 684 | break; |
613 | 685 | } |
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 | + } | |
614 | 693 | default: |
615 | 694 | vaStatus = VA_STATUS_ERROR_UNSUPPORTED_PROFILE; |
616 | 695 | break; |
@@ -739,6 +818,10 @@ intel_enc_hw_context_init(VADriverContextP ctx, | ||
739 | 818 | encoder_context->codec = CODEC_HEVC; |
740 | 819 | break; |
741 | 820 | |
821 | + case VAProfileVP9Profile0: | |
822 | + encoder_context->codec = CODEC_VP9; | |
823 | + break; | |
824 | + | |
742 | 825 | default: |
743 | 826 | /* Never get here */ |
744 | 827 | assert(0); |
@@ -814,6 +897,10 @@ gen9_enc_hw_context_init(VADriverContextP ctx, struct object_config *obj_config) | ||
814 | 897 | return intel_enc_hw_context_init(ctx, obj_config, gen9_vme_context_init, gen9_hcpe_context_init); |
815 | 898 | } else if (obj_config->profile == VAProfileJPEGBaseline) |
816 | 899 | 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); | |
817 | 904 | else |
818 | 905 | return intel_enc_hw_context_init(ctx, obj_config, gen9_vme_context_init, gen9_mfc_context_init); |
819 | 906 | } |