[Libva] [Libva-intel-driver][PATCH 2/2] Encode/VP9: Don't use hardcoded offsets
Zhao Yakui
yakui.zhao at intel.com
Fri Aug 19 02:28:08 UTC 2016
On 08/15/2016 10:46 AM, Xiang, Haihao wrote:
> codec_private_data in struct i965_coded_buffer_segment is used to store
> codec related data. Add 'struct vp9_encode_status' for the data that will
> be written into codec_private_data
>
> Signed-off-by: Xiang, Haihao<haihao.xiang at intel.com>
This looks good to me.
Add: Reviewed-by: Zhao Yakui <yakui.zhao at intel.com>
Thanks
Yakui
> ---
> src/gen9_vp9_encoder.c | 26 ++++++++------------------
> src/gen9_vp9_encoder.h | 12 ++++++++----
> 2 files changed, 16 insertions(+), 22 deletions(-)
>
> diff --git a/src/gen9_vp9_encoder.c b/src/gen9_vp9_encoder.c
> index edfbda6..76cd1d7 100644
> --- a/src/gen9_vp9_encoder.c
> +++ b/src/gen9_vp9_encoder.c
> @@ -5985,15 +5985,16 @@ gen9_vp9_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *en
> /* the definition of status buffer offset for VP9 */
> {
> struct vp9_encode_status_buffer_internal *status_buffer;
> + uint32_t base_offset = offsetof(struct i965_coded_buffer_segment, codec_private_data);
>
> status_buffer =&vp9_state->status_buffer;
> memset(status_buffer, 0,
> sizeof(struct vp9_encode_status_buffer_internal));
>
> - status_buffer->bs_byte_count_offset = 2048;
> - status_buffer->image_status_mask_offset = 2052;
> - status_buffer->image_status_ctrl_offset = 2056;
> - status_buffer->media_index_offset = 2060;
> + status_buffer->bs_byte_count_offset = base_offset + offsetof(struct vp9_encode_status, bs_byte_count);
> + status_buffer->image_status_mask_offset = base_offset + offsetof(struct vp9_encode_status, image_status_mask);
> + status_buffer->image_status_ctrl_offset = base_offset + offsetof(struct vp9_encode_status, image_status_ctrl);
> + status_buffer->media_index_offset = base_offset + offsetof(struct vp9_encode_status, media_index);
>
> status_buffer->vp9_bs_frame_reg_offset = 0x1E9E0;
> status_buffer->vp9_image_mask_reg_offset = 0x1E9F0;
> @@ -6014,24 +6015,13 @@ gen9_vp9_get_coded_status(VADriverContextP ctx,
> struct intel_encoder_context *encoder_context,
> struct i965_coded_buffer_segment *coded_buf_seg)
> {
> - struct gen9_vp9_state *vp9_state = NULL;
> - struct vp9_encode_status_buffer_internal *status_buffer;
> - unsigned int *buf_ptr;
> + struct vp9_encode_status *vp9_encode_status;
>
> if (!encoder_context || !coded_buf_seg)
> return VA_STATUS_ERROR_INVALID_BUFFER;
>
> - vp9_state = (struct gen9_vp9_state *)(encoder_context->enc_priv_state);
> -
> - if (!vp9_state)
> - return VA_STATUS_ERROR_INVALID_BUFFER;
> -
> - status_buffer =&vp9_state->status_buffer;
> -
> - buf_ptr = (unsigned int *)((char *)coded_buf_seg + status_buffer->bs_byte_count_offset);
> -
> - /* the stream size is writen into the bs_byte_count_offset address of buffer */
> - coded_buf_seg->base.size = *buf_ptr;
> + vp9_encode_status = (struct vp9_encode_status *)coded_buf_seg->codec_private_data;
> + coded_buf_seg->base.size = vp9_encode_status->bs_byte_count;
>
> /* One VACodedBufferSegment for VP9 will be added later.
> * It will be linked to the next element of coded_buf_seg->base.next
> diff --git a/src/gen9_vp9_encoder.h b/src/gen9_vp9_encoder.h
> index 8034240..ad2d875 100644
> --- a/src/gen9_vp9_encoder.h
> +++ b/src/gen9_vp9_encoder.h
> @@ -1849,15 +1849,19 @@ enum INTEL_ENC_VP9_TU_MODE
> #define VP9_GOLDEN_REF 0x02
> #define VP9_ALT_REF 0x04
>
> -/* the vp9_encode_status_buffer is the shadow
> - * of vp9_encode_status_buffer_internal.
> - */
> +struct vp9_encode_status
> +{
> + uint32_t bs_byte_count;
> + uint32_t image_status_mask;
> + uint32_t image_status_ctrl;
> + uint32_t media_index;
> +};
> +
> struct vp9_encode_status_buffer_internal
> {
> uint32_t bs_byte_count_offset;
> uint32_t reserved[15];
>
> - /* the above is shared with the gen9_encode_status_buffer */
> uint32_t image_status_mask_offset;
> uint32_t image_status_ctrl_offset;
>
More information about the Libva
mailing list