[Mesa-dev] [PATCH] st/va: use provided sizes and coords for getimage

Boyuan Zhang boyzhang at amd.com
Tue Oct 9 17:59:19 UTC 2018


Hi ilia,

I saw the function 
u_box_clip_2d(https://cgit.freedesktop.org/mesa/mesa/tree/src/gallium/auxiliary/util/u_box.h#n74).

But I still don't quite understand why we need to do this? Or say, what 
will happen if we don't do this box clipping here? Can you provide more 
information about this please?


Regards,

Boyuan


On 2018-10-05 12:11 PM, Ilia Mirkin wrote:
> This is an improvement, but I think you need to clip the box to
>
> 1. Size of the surface
> 2. Size of the image
>
> I think that there are clipping helpers available to do that (maybe
> pipe_box_clip or so? I forget, check the auxiliary dir). Christian -
> does that make sense to you?
>
> Cheers,
>
>    -ilia
> On Fri, Oct 5, 2018 at 12:01 PM <boyuan.zhang at amd.com> wrote:
>> From: Boyuan Zhang <boyuan.zhang at amd.com>
>>
>> vlVaGetImage should respect the width, height, and coordinates x and y that
>> passed in. Therefore, pipe_box should be created with the passed in values
>> instead of surface width/height.
>>
>> Signed-off-by: Boyuan Zhang <boyuan.zhang at amd.com>
>> ---
>>   src/gallium/state_trackers/va/image.c | 9 ++++++---
>>   1 file changed, 6 insertions(+), 3 deletions(-)
>>
>> diff --git a/src/gallium/state_trackers/va/image.c b/src/gallium/state_trackers/va/image.c
>> index 3f892c9..c9f6f18 100644
>> --- a/src/gallium/state_trackers/va/image.c
>> +++ b/src/gallium/state_trackers/va/image.c
>> @@ -400,11 +400,14 @@ vlVaGetImage(VADriverContextP ctx, VASurfaceID surface, int x, int y,
>>      }
>>
>>      for (i = 0; i < vaimage->num_planes; i++) {
>> -      unsigned width, height;
>> +      unsigned w = align(width, 2);
>> +      unsigned h = align(height, 2);
>>         if (!views[i]) continue;
>> -      vlVaVideoSurfaceSize(surf, i, &width, &height);
>> +      vl_video_buffer_adjust_size(&w, &h, i,
>> +                                  surf->templat.chroma_format,
>> +                                  surf->templat.interlaced);
>>         for (j = 0; j < views[i]->texture->array_size; ++j) {
>> -         struct pipe_box box = {0, 0, j, width, height, 1};
>> +         struct pipe_box box = {x, y, j, w, h, 1};
>>            struct pipe_transfer *transfer;
>>            uint8_t *map;
>>            map = drv->pipe->transfer_map(drv->pipe, views[i]->texture, 0,
>> --
>> 2.7.4
>>



More information about the mesa-dev mailing list