diff options
author | Zhao, Yakui <yakui.zhao@intel.com> | 2014-05-26 08:40:15 +0800 |
---|---|---|
committer | Xiang, Haihao <haihao.xiang@intel.com> | 2014-06-16 11:53:35 +0800 |
commit | 89507c06c7ed03d829cf2526e621d844e174c90c (patch) | |
tree | 52816c0e5a076d7bae585a4ab8c54439d41e999f /src/i965_drv_video.c | |
parent | 558e904bc5c471795b09f6c2dcf65ba31590b19b (diff) | |
download | libva-intel-driver-89507c06c7ed03d829cf2526e621d844e174c90c.tar.gz libva-intel-driver-89507c06c7ed03d829cf2526e621d844e174c90c.tar.bz2 libva-intel-driver-89507c06c7ed03d829cf2526e621d844e174c90c.zip |
H264_encoding: Add the support of inserting the packed raw data passed from user
Under some encoding scenario, the user-space application hopes that the driver
can insert the passed packed rawdata into the coded clip. This is to allow the
insertion of packed rawdata passed from user. As the position of packed rawdata
is related with the slice. So the following restrictions are added:
1. the packed rawdata header type/data should be paired.
2. the packed rawdata data is inserted by following the passed order
3. the packed rawdata header type/data is split by using VAEncSliceParameterBuffer.
That is to say: The packed rawdata for slice 0 should be passed before the first
VAEncSliceParameterBuffer. After one VAEncSliceParameterBuffer is parsed,
the subseuquent packed rawdata is for another new slice. The subsequent
packed rawdata after the last VAEncSliceParameterBuffer is ignored.
4. it does not change the rule for the packed data of SPS/PPS/MISC type.
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
(cherry picked from commit 974597ef64dc9a283d4787e1484a75d1610414f4)
Conflicts:
src/gen75_mfc.c
src/gen8_mfc.c
Diffstat (limited to 'src/i965_drv_video.c')
-rwxr-xr-x | src/i965_drv_video.c | 62 |
1 files changed, 55 insertions, 7 deletions
diff --git a/src/i965_drv_video.c b/src/i965_drv_video.c index db0440c..d8b50dc 100755 --- a/src/i965_drv_video.c +++ b/src/i965_drv_video.c @@ -655,6 +655,12 @@ i965_GetConfigAttributes(VADriverContextP ctx, case VAConfigAttribEncPackedHeaders: if (entrypoint == VAEntrypointEncSlice) { attrib_list[i].value = VA_ENC_PACKED_HEADER_SEQUENCE | VA_ENC_PACKED_HEADER_PICTURE | VA_ENC_PACKED_HEADER_MISC; + if (profile == VAProfileH264ConstrainedBaseline || + profile == VAProfileH264Main || + profile == VAProfileH264High || + profile == VAProfileH264MultiviewHigh) { + attrib_list[i].value |= VA_ENC_PACKED_HEADER_RAW_DATA; + } break; } @@ -2367,6 +2373,9 @@ DEF_RENDER_ENCODE_SINGLE_BUFFER_FUNC(picture_parameter_ext, pic_param_ext) // DEF_RENDER_ENCODE_MULTI_BUFFER_FUNC(slice_parameter, slice_params) DEF_RENDER_ENCODE_MULTI_BUFFER_FUNC(slice_parameter_ext, slice_params_ext) +DEF_RENDER_ENCODE_MULTI_BUFFER_FUNC(packed_header_params_ext, packed_header_params_ext) +DEF_RENDER_ENCODE_MULTI_BUFFER_FUNC(packed_header_data_ext, packed_header_data_ext) + static VAStatus i965_encoder_render_packed_header_parameter_buffer(VADriverContextP ctx, struct object_context *obj_context, @@ -2430,10 +2439,12 @@ i965_encoder_render_picture(VADriverContextP ctx, struct i965_driver_data *i965 = i965_driver_data(ctx); struct object_context *obj_context = CONTEXT(context); VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN; + struct encode_state *encode; int i; ASSERT_RET(obj_context, VA_STATUS_ERROR_INVALID_CONTEXT); + encode = &obj_context->codec_state.encode; for (i = 0; i < num_buffers; i++) { struct object_buffer *obj_buffer = BUFFER(buffers[i]); @@ -2459,35 +2470,67 @@ i965_encoder_render_picture(VADriverContextP ctx, case VAEncSliceParameterBufferType: vaStatus = I965_RENDER_ENCODE_BUFFER(slice_parameter_ext); + if (vaStatus == VA_STATUS_SUCCESS) { + /* When the max number of slices is updated, it also needs + * to reallocate the arrays that is used to store + * the packed data index/count for the slice + */ + if (encode->max_slice_params_ext > encode->slice_num) { + encode->slice_num = encode->max_slice_params_ext; + encode->slice_rawdata_index = realloc(encode->slice_rawdata_index, + encode->slice_num * sizeof(int)); + encode->slice_rawdata_count = realloc(encode->slice_rawdata_count, + encode->slice_num * sizeof(int)); + if ((encode->slice_rawdata_index == NULL) || + (encode->slice_rawdata_count == NULL)) { + vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; + return vaStatus; + } + } + } break; case VAEncPackedHeaderParameterBufferType: { - struct encode_state *encode = &obj_context->codec_state.encode; VAEncPackedHeaderParameterBuffer *param = (VAEncPackedHeaderParameterBuffer *)obj_buffer->buffer_store->buffer; encode->last_packed_header_type = param->type; - vaStatus = i965_encoder_render_packed_header_parameter_buffer(ctx, + if (param->type == VAEncPackedHeaderRawData) { + vaStatus = I965_RENDER_ENCODE_BUFFER(packed_header_params_ext); + } else { + vaStatus = i965_encoder_render_packed_header_parameter_buffer(ctx, obj_context, obj_buffer, va_enc_packed_type_to_idx(encode->last_packed_header_type)); + } break; } case VAEncPackedHeaderDataBufferType: { - struct encode_state *encode = &obj_context->codec_state.encode; - ASSERT_RET(encode->last_packed_header_type == VAEncPackedHeaderSequence || - encode->last_packed_header_type == VAEncPackedHeaderPicture || - encode->last_packed_header_type == VAEncPackedHeaderSlice || + if (encode->last_packed_header_type == VAEncPackedHeaderRawData) { + vaStatus = I965_RENDER_ENCODE_BUFFER(packed_header_data_ext); + if (vaStatus == VA_STATUS_SUCCESS) { + /* store the first index of the packed header data for current slice */ + if (encode->slice_rawdata_index[encode->num_slice_params_ext] == 0) { + encode->slice_rawdata_index[encode->num_slice_params_ext] = + SLICE_PACKED_DATA_INDEX_TYPE | (encode->num_packed_header_data_ext - 1); + } + encode->slice_rawdata_count[encode->num_slice_params_ext]++; + } + } else { + ASSERT_RET(encode->last_packed_header_type == VAEncPackedHeaderSequence || + encode->last_packed_header_type == VAEncPackedHeaderPicture || + encode->last_packed_header_type == VAEncPackedHeaderSlice || (((encode->last_packed_header_type & VAEncPackedHeaderMiscMask) == VAEncPackedHeaderMiscMask) && ((encode->last_packed_header_type & (~VAEncPackedHeaderMiscMask)) != 0)), VA_STATUS_ERROR_ENCODING_ERROR); - vaStatus = i965_encoder_render_packed_header_data_buffer(ctx, + vaStatus = i965_encoder_render_packed_header_data_buffer(ctx, obj_context, obj_buffer, va_enc_packed_type_to_idx(encode->last_packed_header_type)); + } break; } @@ -2591,6 +2634,11 @@ i965_EndPicture(VADriverContextP ctx, VAContextID context) } else if (obj_context->codec_type == CODEC_ENC) { ASSERT_RET(VAEntrypointEncSlice == obj_config->entrypoint, VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT); + if (obj_context->codec_state.encode.num_packed_header_params_ext != + obj_context->codec_state.encode.num_packed_header_data_ext) { + WARN_ONCE("the packed header/data is not paired for encoding!\n"); + return VA_STATUS_ERROR_INVALID_PARAMETER; + } if (!(obj_context->codec_state.encode.pic_param || obj_context->codec_state.encode.pic_param_ext)) { return VA_STATUS_ERROR_INVALID_PARAMETER; |