[Libva] [PATCH Libva-intel-driver V2 2/6] H264_Encoding: Prepare some data structures for adding packed raw data
Zhao, Yakui
yakui.zhao at intel.com
Wed May 21 17:51:28 PDT 2014
From: "Zhao, Yakui" <yakui.zhao at intel.com>
Under some encoding scenario, the user-space application hopes that the driver
can insert the passed packed rawdata into the coded clip. But the insertion of
packed rawdata is related with the slice. So some data structures are added so
that it can store how the packed rawdata is inserted into the coded clip
per-slice.
Signed-off-by: Zhao, Yakui <yakui.zhao at intel.com>
---
src/i965_drv_video.c | 43 +++++++++++++++++++++++++++++++++++++++++++
src/i965_drv_video.h | 20 ++++++++++++++++++++
2 files changed, 63 insertions(+)
diff --git a/src/i965_drv_video.c b/src/i965_drv_video.c
index 84f632f..de643b8 100755
--- a/src/i965_drv_video.c
+++ b/src/i965_drv_video.c
@@ -1461,6 +1461,22 @@ i965_destroy_context(struct object_heap *heap, struct object_base *obj)
i965_release_buffer_store(&obj_context->codec_state.encode.slice_params_ext[i]);
free(obj_context->codec_state.encode.slice_params_ext);
+ if (obj_context->codec_state.encode.slice_rawdata_index) {
+ free(obj_context->codec_state.encode.slice_rawdata_index);
+ obj_context->codec_state.encode.slice_rawdata_index = NULL;
+ }
+ if (obj_context->codec_state.encode.slice_rawdata_count) {
+ free(obj_context->codec_state.encode.slice_rawdata_count);
+ obj_context->codec_state.encode.slice_rawdata_count = NULL;
+ }
+ for (i = 0; i < obj_context->codec_state.encode.num_packed_header_params_ext; i++)
+ i965_release_buffer_store(&obj_context->codec_state.encode.packed_header_params_ext[i]);
+ free(obj_context->codec_state.encode.packed_header_params_ext);
+
+ for (i = 0; i < obj_context->codec_state.encode.num_packed_header_data_ext; i++)
+ i965_release_buffer_store(&obj_context->codec_state.encode.packed_header_data_ext[i]);
+ free(obj_context->codec_state.encode.packed_header_data_ext);
+
} else {
assert(obj_context->codec_state.decode.num_slice_params <= obj_context->codec_state.decode.max_slice_params);
assert(obj_context->codec_state.decode.num_slice_datas <= obj_context->codec_state.decode.max_slice_datas);
@@ -1572,6 +1588,22 @@ i965_CreateContext(VADriverContextP ctx,
obj_context->codec_state.encode.max_slice_params = NUM_SLICES;
obj_context->codec_state.encode.slice_params = calloc(obj_context->codec_state.encode.max_slice_params,
sizeof(*obj_context->codec_state.encode.slice_params));
+ obj_context->codec_state.encode.max_packed_header_params_ext = NUM_SLICES;
+ obj_context->codec_state.encode.packed_header_params_ext =
+ calloc(obj_context->codec_state.encode.max_packed_header_params_ext,
+ sizeof(struct buffer_store *));
+
+ obj_context->codec_state.encode.max_packed_header_data_ext = NUM_SLICES;
+ obj_context->codec_state.encode.packed_header_data_ext =
+ calloc(obj_context->codec_state.encode.max_packed_header_data_ext,
+ sizeof(struct buffer_store *));
+
+ obj_context->codec_state.encode.slice_num = NUM_SLICES;
+ obj_context->codec_state.encode.slice_rawdata_index =
+ calloc(obj_context->codec_state.encode.slice_num, sizeof(int));
+ obj_context->codec_state.encode.slice_rawdata_count =
+ calloc(obj_context->codec_state.encode.slice_num, sizeof(int));
+
assert(i965->codec_info->enc_hw_context_init);
obj_context->hw_context = i965->codec_info->enc_hw_context_init(ctx, obj_config);
} else {
@@ -1992,6 +2024,17 @@ i965_BeginPicture(VADriverContextP ctx,
obj_context->codec_state.encode.num_slice_params_ext = 0;
obj_context->codec_state.encode.current_render_target = render_target; /*This is input new frame*/
obj_context->codec_state.encode.last_packed_header_type = 0;
+ memset(obj_context->codec_state.encode.slice_rawdata_index, 0,
+ sizeof(int) * obj_context->codec_state.encode.slice_num);
+ memset(obj_context->codec_state.encode.slice_rawdata_count, 0,
+ sizeof(int) * obj_context->codec_state.encode.slice_num);
+
+ for (i = 0; i < obj_context->codec_state.encode.num_packed_header_params_ext; i++)
+ i965_release_buffer_store(&obj_context->codec_state.encode.packed_header_params_ext[i]);
+ for (i = 0; i < obj_context->codec_state.encode.num_packed_header_data_ext; i++)
+ i965_release_buffer_store(&obj_context->codec_state.encode.packed_header_data_ext[i]);
+ obj_context->codec_state.encode.num_packed_header_params_ext = 0;
+ obj_context->codec_state.encode.num_packed_header_data_ext = 0;
} else {
obj_context->codec_state.decode.current_render_target = render_target;
i965_release_buffer_store(&obj_context->codec_state.decode.pic_param);
diff --git a/src/i965_drv_video.h b/src/i965_drv_video.h
index 6f890f6..15cf637 100644
--- a/src/i965_drv_video.h
+++ b/src/i965_drv_video.h
@@ -120,6 +120,9 @@ struct decode_state
struct object_surface *reference_objects[16]; /* Up to 2 reference surfaces are valid for MPEG-2,*/
};
+#define SLICE_PACKED_DATA_INDEX_TYPE 0x80000000
+#define SLICE_PACKED_DATA_INDEX_MASK 0x00FFFFFF
+
struct encode_state
{
struct buffer_store *seq_param;
@@ -139,6 +142,23 @@ struct encode_state
struct buffer_store **slice_params_ext;
int max_slice_params_ext;
int num_slice_params_ext;
+
+ /* For the packed data that needs to be inserted into video clip */
+ /* currently it is mainly for packed raw data */
+ struct buffer_store **packed_header_params_ext;
+ int max_packed_header_params_ext;
+ int num_packed_header_params_ext;
+ struct buffer_store **packed_header_data_ext;
+ int max_packed_header_data_ext;
+ int num_packed_header_data_ext;
+
+ /* the array is determined by max_slice_params_ext */
+ int slice_num;
+ /* This is to store the first index of packed data for one slice */
+ int *slice_rawdata_index;
+ /* This is to store the number of packed data for one slice */
+ int *slice_rawdata_count;
+
int last_packed_header_type;
struct buffer_store *misc_param[16];
--
1.7.12-rc1
More information about the Libva
mailing list