diff --git a/src/gallium/frontends/vdpau/output.c b/src/gallium/frontends/vdpau/output.c index fa902705109..f33bc8de515 100644 --- a/src/gallium/frontends/vdpau/output.c +++ b/src/gallium/frontends/vdpau/output.c @@ -334,8 +334,11 @@ vlVdpOutputSurfacePutBitsIndexed(VdpOutputSurface surface, res_tmpl.format = index_format; if (destination_rect) { - res_tmpl.width0 = abs(destination_rect->x0-destination_rect->x1); - res_tmpl.height0 = abs(destination_rect->y0-destination_rect->y1); + if (destination_rect->x1 > destination_rect->x0 && + destination_rect->y1 > destination_rect->y0) { + res_tmpl.width0 = destination_rect->x1 - destination_rect->x0; + res_tmpl.height0 = destination_rect->y1 - destination_rect->y0; + } } else { res_tmpl.width0 = vlsurface->surface->texture->width0; res_tmpl.height0 = vlsurface->surface->texture->height0; @@ -467,8 +470,11 @@ vlVdpOutputSurfacePutBitsYCbCr(VdpOutputSurface surface, vtmpl.buffer_format = format; if (destination_rect) { - vtmpl.width = abs(destination_rect->x0-destination_rect->x1); - vtmpl.height = abs(destination_rect->y0-destination_rect->y1); + if (destination_rect->x1 > destination_rect->x0 && + destination_rect->y1 > destination_rect->y0) { + vtmpl.width = destination_rect->x1 - destination_rect->x0; + vtmpl.height = destination_rect->y1 - destination_rect->y0; + } } else { vtmpl.width = vlsurface->surface->texture->width0; vtmpl.height = vlsurface->surface->texture->height0; diff --git a/src/gallium/frontends/vdpau/vdpau_private.h b/src/gallium/frontends/vdpau/vdpau_private.h index f69458445c2..05d8059eb1f 100644 --- a/src/gallium/frontends/vdpau/vdpau_private.h +++ b/src/gallium/frontends/vdpau/vdpau_private.h @@ -349,10 +349,16 @@ RectToPipeBox(const VdpRect *rect, struct pipe_resource *res) box.depth = 1; if (rect) { - box.x = MIN2(rect->x0, rect->x1); - box.y = MIN2(rect->y0, rect->y1); - box.width = abs(rect->x1 - rect->x0); - box.height = abs(rect->y1 - rect->y0); + if (rect->x1 > rect->x0 && + rect->y1 > rect->y0) { + box.x = rect->x0; + box.y = rect->y0; + box.width = rect->x1 - box.x; + box.height = rect->y1 - box.y; + } else { + box.width = 0; + box.height = 0; + } } return box;