Discussion:
[Libva-intel-driver][PATCH] Initialize some buffers to 0 when created
(too old to reply)
Xiang, Haihao
2016-12-30 08:06:19 UTC
Permalink
Sometimes user doesn't assign a proper value to each field in a buffer
when calling vaRenderPicture(), which will result in random issues
if we want to use these fields in the future. E.g. recently we used
window_size in VAEncMiscParameterRateControl for bitrate control.

Signed-off-by: Xiang, Haihao <***@intel.com>
---
src/i965_drv_video.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/i965_drv_video.c b/src/i965_drv_video.c
index 15920f5..51a708c 100644
--- a/src/i965_drv_video.c
+++ b/src/i965_drv_video.c
@@ -2519,8 +2519,12 @@ i965_create_buffer_internal(VADriverContextP ctx,
buffer_store->buffer = malloc(msize * num_elements);
assert(buffer_store->buffer);

- if (data && (!wrapper_flag))
- memcpy(buffer_store->buffer, data, size * num_elements);
+ if (!wrapper_flag) {
+ if (data)
+ memcpy(buffer_store->buffer, data, size * num_elements);
+ else
+ memset(buffer_store->buffer, 0, size * num_elements);
+ }
}

buffer_store->num_elements = obj_buffer->num_elements;
--
1.9.1
Zhao Yakui
2016-12-30 08:13:31 UTC
Permalink
Post by Xiang, Haihao
Sometimes user doesn't assign a proper value to each field in a buffer
when calling vaRenderPicture(), which will result in random issues
if we want to use these fields in the future. E.g. recently we used
window_size in VAEncMiscParameterRateControl for bitrate control.
This looks good to me.
Post by Xiang, Haihao
---
src/i965_drv_video.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/i965_drv_video.c b/src/i965_drv_video.c
index 15920f5..51a708c 100644
--- a/src/i965_drv_video.c
+++ b/src/i965_drv_video.c
@@ -2519,8 +2519,12 @@ i965_create_buffer_internal(VADriverContextP ctx,
buffer_store->buffer = malloc(msize * num_elements);
assert(buffer_store->buffer);
- if (data&& (!wrapper_flag))
- memcpy(buffer_store->buffer, data, size * num_elements);
+ if (!wrapper_flag) {
+ if (data)
+ memcpy(buffer_store->buffer, data, size * num_elements);
+ else
+ memset(buffer_store->buffer, 0, size * num_elements);
+ }
}
buffer_store->num_elements = obj_buffer->num_elements;
Loading...