• 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

Revisiond966272b0b4dd9161eb9f69c07dcbdd1476e7886 (tree)
Time2015-03-19 11:01:29
AuthorQu,Pengfei <Pengfei.Qu@inte...>
CommiterXiang, Haihao

Log Message

HEVC ENC:Added HEVC support in API function

Signed-off-by: Qu,Pengfei <Pengfei.Qu@intel.com>
(cherry picked from commit d4f1087a0606c7c8d2d5fd65d9f46990f41ce93a)

Change Summary

Incremental Difference

--- a/src/i965_device_info.c
+++ b/src/i965_device_info.c
@@ -345,6 +345,7 @@ static struct hw_codec_info skl_hw_codec_info = {
345345 .has_vp8_encoding = 1,
346346 .has_h264_mvc_encoding = 1,
347347 .has_hevc_decoding = 1,
348+ .has_hevc_encoding = 1,
348349
349350 .num_filters = 5,
350351 .filters = {
--- a/src/i965_drv_video.c
+++ b/src/i965_drv_video.c
@@ -1,5 +1,5 @@
11 /*
2- * Copyright © 2009 Intel Corporation
2+ * Copyright ?2009 Intel Corporation
33 *
44 * Permission is hereby granted, free of charge, to any person obtaining a
55 * copy of this software and associated documentation files (the
@@ -102,6 +102,9 @@
102102 #define HAS_HEVC_DECODING(ctx) ((ctx)->codec_info->has_hevc_decoding && \
103103 (ctx)->intel.has_bsd)
104104
105+#define HAS_HEVC_ENCODING(ctx) ((ctx)->codec_info->has_hevc_encoding && \
106+ (ctx)->intel.has_bsd)
107+
105108 static int get_sampling_from_fourcc(unsigned int fourcc);
106109
107110 /* Check whether we are rendering to X11 (VA/X11 or VA/GLX API) */
@@ -374,7 +377,10 @@ is_image_busy(struct i965_driver_data *i965, struct object_image *obj_image)
374377 }
375378
376379 #define I965_PACKED_HEADER_BASE 0
377-#define I965_PACKED_MISC_HEADER_BASE 3
380+#define I965_SEQ_PACKED_HEADER_BASE 0
381+#define I965_SEQ_PACKED_HEADER_END 2
382+#define I965_PIC_PACKED_HEADER_BASE 2
383+#define I965_PACKED_MISC_HEADER_BASE 4
378384
379385 int
380386 va_enc_packed_type_to_idx(int packed_type)
@@ -391,15 +397,15 @@ va_enc_packed_type_to_idx(int packed_type)
391397
392398 switch (packed_type) {
393399 case VAEncPackedHeaderSequence:
394- idx = I965_PACKED_HEADER_BASE + 0;
400+ idx = I965_SEQ_PACKED_HEADER_BASE + 0;
395401 break;
396402
397403 case VAEncPackedHeaderPicture:
398- idx = I965_PACKED_HEADER_BASE + 1;
404+ idx = I965_PIC_PACKED_HEADER_BASE + 0;
399405 break;
400406
401407 case VAEncPackedHeaderSlice:
402- idx = I965_PACKED_HEADER_BASE + 2;
408+ idx = I965_PIC_PACKED_HEADER_BASE + 1;
403409 break;
404410
405411 default:
@@ -409,7 +415,7 @@ va_enc_packed_type_to_idx(int packed_type)
409415 }
410416 }
411417
412- ASSERT_RET(idx < 4, 0);
418+ ASSERT_RET(idx < 5, 0);
413419 return idx;
414420 }
415421
@@ -463,7 +469,8 @@ i965_QueryConfigProfiles(VADriverContextP ctx,
463469 profile_list[i++] = VAProfileH264StereoHigh;
464470 }
465471
466- if (HAS_HEVC_DECODING(i965)) {
472+ if (HAS_HEVC_DECODING(i965)||
473+ HAS_HEVC_ENCODING(i965)) {
467474 profile_list[i++] = VAProfileHEVCMain;
468475 }
469476
@@ -546,6 +553,9 @@ i965_QueryConfigEntrypoints(VADriverContextP ctx,
546553 if (HAS_HEVC_DECODING(i965))
547554 entrypoint_list[n++] = VAEntrypointVLD;
548555
556+ if (HAS_HEVC_ENCODING(i965))
557+ entrypoint_list[n++] = VAEntrypointEncSlice;
558+
549559 break;
550560
551561 default:
@@ -637,7 +647,8 @@ i965_validate_config(VADriverContextP ctx, VAProfile profile,
637647 break;
638648
639649 case VAProfileHEVCMain:
640- if (HAS_HEVC_DECODING(i965) && (entrypoint == VAEntrypointVLD))
650+ if ((HAS_HEVC_DECODING(i965) && (entrypoint == VAEntrypointVLD))||
651+ (HAS_HEVC_ENCODING(i965) && (entrypoint == VAEntrypointEncSlice)))
641652 va_status = VA_STATUS_SUCCESS;
642653 else
643654 va_status = VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;
@@ -729,7 +740,8 @@ i965_GetConfigAttributes(VADriverContextP ctx,
729740 profile == VAProfileH264Main ||
730741 profile == VAProfileH264High ||
731742 profile == VAProfileH264StereoHigh ||
732- profile == VAProfileH264MultiviewHigh) {
743+ profile == VAProfileH264MultiviewHigh ||
744+ profile == VAProfileHEVCMain) {
733745 attrib_list[i].value |= (VA_ENC_PACKED_HEADER_RAW_DATA |
734746 VA_ENC_PACKED_HEADER_SLICE);
735747 }
@@ -1886,6 +1898,8 @@ i965_CreateContext(VADriverContextP ctx,
18861898 obj_context->codec_state.encode.slice_header_index =
18871899 calloc(obj_context->codec_state.encode.max_slice_num, sizeof(int));
18881900
1901+ obj_context->codec_state.encode.vps_sps_seq_index = 0;
1902+
18891903 obj_context->codec_state.encode.slice_index = 0;
18901904 packed_attrib = i965_lookup_config_attribute(obj_config, VAConfigAttribEncPackedHeaders);
18911905 if (packed_attrib)
@@ -1972,6 +1986,20 @@ i965_create_buffer_internal(VADriverContextP ctx,
19721986 struct object_buffer *obj_buffer = NULL;
19731987 struct buffer_store *buffer_store = NULL;
19741988 int bufferID;
1989+ struct object_context *obj_context = NULL;
1990+ struct object_config *obj_config = NULL;
1991+ VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;
1992+
1993+ if (i965->current_context_id == VA_INVALID_ID)
1994+ return vaStatus;
1995+
1996+ obj_context = CONTEXT(i965->current_context_id);
1997+
1998+ if (!obj_context)
1999+ return vaStatus;
2000+
2001+ obj_config = obj_context->obj_config;
2002+ assert(obj_config);
19752003
19762004 /* Validate type */
19772005 switch (type) {
@@ -2045,7 +2073,11 @@ i965_create_buffer_internal(VADriverContextP ctx,
20452073 struct i965_coded_buffer_segment *coded_buffer_segment;
20462074
20472075 dri_bo_map(buffer_store->bo, 1);
2048- coded_buffer_segment = (struct i965_coded_buffer_segment *)buffer_store->bo->virtual;
2076+ if(obj_config->profile == VAProfileHEVCMain){
2077+ coded_buffer_segment = (struct i965_coded_buffer_segment *)(buffer_store->bo->virtual + ALIGN(size - 0x1000, 0x1000));
2078+ }else {
2079+ coded_buffer_segment = (struct i965_coded_buffer_segment *)buffer_store->bo->virtual;
2080+ }
20492081 coded_buffer_segment->base.size = size - I965_CODEDBUFFER_HEADER_SIZE;
20502082 coded_buffer_segment->base.bit_offset = 0;
20512083 coded_buffer_segment->base.status = 0;
@@ -2123,9 +2155,22 @@ i965_MapBuffer(VADriverContextP ctx,
21232155 void **pbuf) /* out */
21242156 {
21252157 struct i965_driver_data *i965 = i965_driver_data(ctx);
2158+ struct object_context *obj_context = NULL;
2159+ struct object_config *obj_config = NULL;
21262160 struct object_buffer *obj_buffer = BUFFER(buf_id);
21272161 VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;
21282162
2163+ if (i965->current_context_id == VA_INVALID_ID)
2164+ return vaStatus;
2165+
2166+ obj_context = CONTEXT(i965->current_context_id);
2167+
2168+ if (!obj_context)
2169+ return vaStatus;
2170+
2171+ obj_config = obj_context->obj_config;
2172+ assert(obj_config);
2173+
21292174 ASSERT_RET(obj_buffer && obj_buffer->buffer_store, VA_STATUS_ERROR_INVALID_BUFFER);
21302175 ASSERT_RET(obj_buffer->buffer_store->bo || obj_buffer->buffer_store->buffer, VA_STATUS_ERROR_INVALID_BUFFER);
21312176 ASSERT_RET(!(obj_buffer->buffer_store->bo && obj_buffer->buffer_store->buffer), VA_STATUS_ERROR_INVALID_BUFFER);
@@ -2149,6 +2194,7 @@ i965_MapBuffer(VADriverContextP ctx,
21492194 if (obj_buffer->type == VAEncCodedBufferType) {
21502195 int i;
21512196 unsigned char *buffer = NULL;
2197+ unsigned int header_offset = I965_CODEDBUFFER_HEADER_SIZE;
21522198 struct i965_coded_buffer_segment *coded_buffer_segment = (struct i965_coded_buffer_segment *)(obj_buffer->buffer_store->bo->virtual);
21532199
21542200 if (!coded_buffer_segment->mapped) {
@@ -2173,12 +2219,18 @@ i965_MapBuffer(VADriverContextP ctx,
21732219 //In JPEG End of Image (EOI = 0xDDF9) marker can be used for delimiter.
21742220 delimiter0 = 0xFF;
21752221 delimiter1 = 0xD9;
2222+ } else if (coded_buffer_segment->codec == CODEC_HEVC) {
2223+ delimiter0 = HEVC_DELIMITER0;
2224+ delimiter1 = HEVC_DELIMITER1;
2225+ delimiter2 = HEVC_DELIMITER2;
2226+ delimiter3 = HEVC_DELIMITER3;
2227+ delimiter4 = HEVC_DELIMITER4;
21762228 } else if (coded_buffer_segment->codec != CODEC_VP8) {
21772229 ASSERT_RET(0, VA_STATUS_ERROR_UNSUPPORTED_PROFILE);
21782230 }
21792231
21802232 if(coded_buffer_segment->codec == CODEC_JPEG) {
2181- for(i = 0; i < obj_buffer->size_element - I965_CODEDBUFFER_HEADER_SIZE - 1 - 0x1000; i++) {
2233+ for(i = 0; i < obj_buffer->size_element - header_offset - 1 - 0x1000; i++) {
21822234 if( (buffer[i] == 0xFF) && (buffer[i + 1] == 0xD9)) {
21832235 break;
21842236 }
@@ -2187,22 +2239,22 @@ i965_MapBuffer(VADriverContextP ctx,
21872239 } else if (coded_buffer_segment->codec != CODEC_VP8) {
21882240 /* vp8 coded buffer size can be told by vp8 internal statistics buffer,
21892241 so it don't need to traversal the coded buffer */
2190- for (i = 0; i < obj_buffer->size_element - I965_CODEDBUFFER_HEADER_SIZE - 3 - 0x1000; i++) {
2242+ for (i = 0; i < obj_buffer->size_element - header_offset - 3 - 0x1000; i++) {
21912243 if ((buffer[i] == delimiter0) &&
21922244 (buffer[i + 1] == delimiter1) &&
21932245 (buffer[i + 2] == delimiter2) &&
21942246 (buffer[i + 3] == delimiter3) &&
21952247 (buffer[i + 4] == delimiter4))
21962248 break;
2197- }
2249+ }
21982250
2199- if (i == obj_buffer->size_element - I965_CODEDBUFFER_HEADER_SIZE - 3 - 0x1000) {
2200- coded_buffer_segment->base.status |= VA_CODED_BUF_STATUS_SLICE_OVERFLOW_MASK;
2201- }
2251+ if (i == obj_buffer->size_element - header_offset - 3 - 0x1000) {
2252+ coded_buffer_segment->base.status |= VA_CODED_BUF_STATUS_SLICE_OVERFLOW_MASK;
2253+ }
22022254 coded_buffer_segment->base.size = i;
22032255 }
22042256
2205- if (coded_buffer_segment->base.size >= obj_buffer->size_element - I965_CODEDBUFFER_HEADER_SIZE - 0x1000) {
2257+ if (coded_buffer_segment->base.size >= obj_buffer->size_element - header_offset - 0x1000) {
22062258 coded_buffer_segment->base.status |= VA_CODED_BUF_STATUS_SLICE_OVERFLOW_MASK;
22072259 }
22082260
@@ -2376,6 +2428,7 @@ i965_BeginPicture(VADriverContextP ctx,
23762428 obj_context->codec_state.encode.num_packed_header_params_ext = 0;
23772429 obj_context->codec_state.encode.num_packed_header_data_ext = 0;
23782430 obj_context->codec_state.encode.slice_index = 0;
2431+ obj_context->codec_state.encode.vps_sps_seq_index = 0;
23792432 } else {
23802433 obj_context->codec_state.decode.current_render_target = render_target;
23812434 i965_release_buffer_store(&obj_context->codec_state.decode.pic_param);
@@ -2579,11 +2632,14 @@ i965_encoder_render_picture(VADriverContextP ctx,
25792632 {
25802633 struct i965_driver_data *i965 = i965_driver_data(ctx);
25812634 struct object_context *obj_context = CONTEXT(context);
2635+ struct object_config *obj_config;
25822636 VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;
25832637 struct encode_state *encode;
25842638 int i;
25852639
25862640 ASSERT_RET(obj_context, VA_STATUS_ERROR_INVALID_CONTEXT);
2641+ obj_config = obj_context->obj_config;
2642+ ASSERT_RET(obj_config, VA_STATUS_ERROR_INVALID_CONFIG);
25872643
25882644 encode = &obj_context->codec_state.encode;
25892645 for (i = 0; i < num_buffers; i++) {
@@ -2657,6 +2713,12 @@ i965_encoder_render_picture(VADriverContextP ctx,
26572713 if ((param->type == VAEncPackedHeaderRawData) ||
26582714 (param->type == VAEncPackedHeaderSlice)) {
26592715 vaStatus = I965_RENDER_ENCODE_BUFFER(packed_header_params_ext);
2716+ } else if((obj_config->profile == VAProfileHEVCMain)&&
2717+ (encode->last_packed_header_type == VAEncPackedHeaderSequence)) {
2718+ vaStatus = i965_encoder_render_packed_header_parameter_buffer(ctx,
2719+ obj_context,
2720+ obj_buffer,
2721+ va_enc_packed_type_to_idx(encode->last_packed_header_type) + encode->vps_sps_seq_index);
26602722 } else {
26612723 vaStatus = i965_encoder_render_packed_header_parameter_buffer(ctx,
26622724 obj_context,
@@ -2744,10 +2806,22 @@ i965_encoder_render_picture(VADriverContextP ctx,
27442806 (((encode->last_packed_header_type & VAEncPackedHeaderMiscMask) == VAEncPackedHeaderMiscMask) &&
27452807 ((encode->last_packed_header_type & (~VAEncPackedHeaderMiscMask)) != 0)),
27462808 VA_STATUS_ERROR_ENCODING_ERROR);
2747- vaStatus = i965_encoder_render_packed_header_data_buffer(ctx,
2748- obj_context,
2749- obj_buffer,
2750- va_enc_packed_type_to_idx(encode->last_packed_header_type));
2809+
2810+ if((obj_config->profile == VAProfileHEVCMain)&&
2811+ (encode->last_packed_header_type == VAEncPackedHeaderSequence)) {
2812+
2813+ vaStatus = i965_encoder_render_packed_header_data_buffer(ctx,
2814+ obj_context,
2815+ obj_buffer,
2816+ va_enc_packed_type_to_idx(encode->last_packed_header_type) + encode->vps_sps_seq_index);
2817+ encode->vps_sps_seq_index = (encode->vps_sps_seq_index + 1) % I965_SEQ_PACKED_HEADER_END;
2818+ }else{
2819+ vaStatus = i965_encoder_render_packed_header_data_buffer(ctx,
2820+ obj_context,
2821+ obj_buffer,
2822+ va_enc_packed_type_to_idx(encode->last_packed_header_type));
2823+
2824+ }
27512825 }
27522826 encode->last_packed_header_type = 0;
27532827 break;