Mesa (master): vdpau: fix -Wabsolute-value warning
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Jan 5 11:47:38 UTC 2021
Module: Mesa
Branch: master
Commit: cd1ac36ddde6eaf758d1cbb7a501369f5d60d330
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=cd1ac36ddde6eaf758d1cbb7a501369f5d60d330
Author: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Date: Wed Nov 25 15:32:36 2020 +0100
vdpau: fix -Wabsolute-value warning
vdpau specifies that top-left is x0/y0, bottom-right is x1/y1 and that x0/y0 are
inclusive while x1/y1 are exclusive.
This commit remove the abs() usage and instead verifies that the VdpRects passed
by the user matche the documentation. When they don't they're treated as empty
rectangles.
Reviewed-by: Michel Dänzer <mdaenzer at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7846>
---
src/gallium/frontends/vdpau/output.c | 14 ++++++++++----
src/gallium/frontends/vdpau/vdpau_private.h | 14 ++++++++++----
2 files changed, 20 insertions(+), 8 deletions(-)
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;
More information about the mesa-commit
mailing list