summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian König <[email protected]>2012-03-24 13:11:25 +0100
committerChristian König <[email protected]>2012-03-26 12:39:40 +0200
commit7f6af4909241de7197e774dee988f574cb576a3b (patch)
treeae3722ad204b302bd3987e12e88ded1b07af7785
parent9f777699ed39e1c326938f84fc8f54198990cfa1 (diff)
st/vdpau: clear video surface at least once
So if anything goes wrong we won't display a random image. v2: flush before using the surface with the decoder. Signed-off-by: Christian König <[email protected]>
-rw-r--r--src/gallium/state_trackers/vdpau/decode.c1
-rw-r--r--src/gallium/state_trackers/vdpau/surface.c29
-rw-r--r--src/gallium/state_trackers/vdpau/vdpau_private.h1
3 files changed, 31 insertions, 0 deletions
diff --git a/src/gallium/state_trackers/vdpau/decode.c b/src/gallium/state_trackers/vdpau/decode.c
index 6ffd17652b7..61b10e0db33 100644
--- a/src/gallium/state_trackers/vdpau/decode.c
+++ b/src/gallium/state_trackers/vdpau/decode.c
@@ -484,6 +484,7 @@ vlVdpDecoderRender(VdpDecoder decoder,
pipe_mutex_unlock(vlsurf->device->mutex);
return VDP_STATUS_NO_IMPLEMENTATION;
}
+ vlVdpVideoSurfaceClear(vlsurf);
}
for (i = 0; i < bitstream_buffer_count; ++i) {
diff --git a/src/gallium/state_trackers/vdpau/surface.c b/src/gallium/state_trackers/vdpau/surface.c
index c829c1ff7de..ab6960732f7 100644
--- a/src/gallium/state_trackers/vdpau/surface.c
+++ b/src/gallium/state_trackers/vdpau/surface.c
@@ -33,6 +33,7 @@
#include "util/u_memory.h"
#include "util/u_debug.h"
#include "util/u_rect.h"
+#include "vl/vl_defines.h"
#include "vdpau_private.h"
@@ -91,6 +92,7 @@ vlVdpVideoSurfaceCreate(VdpDevice device, VdpChromaType chroma_type,
PIPE_VIDEO_CAP_PREFERS_INTERLACED
);
p_surf->video_buffer = pipe->create_video_buffer(pipe, &p_surf->templat);
+ vlVdpVideoSurfaceClear(p_surf);
pipe_mutex_unlock(dev->mutex);
*surface = vlAddDataHTAB(p_surf);
@@ -282,6 +284,7 @@ vlVdpVideoSurfacePutBitsYCbCr(VdpVideoSurface surface,
pipe_mutex_unlock(p_surf->device->mutex);
return VDP_STATUS_NO_IMPLEMENTATION;
}
+ vlVdpVideoSurfaceClear(p_surf);
}
sampler_views = p_surf->video_buffer->get_sampler_view_planes(p_surf->video_buffer);
@@ -311,3 +314,29 @@ vlVdpVideoSurfacePutBitsYCbCr(VdpVideoSurface surface,
return VDP_STATUS_OK;
}
+
+/**
+ * Helper function to initially clear the VideoSurface after (re-)creation
+ */
+void
+vlVdpVideoSurfaceClear(vlVdpSurface *vlsurf)
+{
+ struct pipe_context *pipe = vlsurf->device->context;
+ struct pipe_surface **surfaces;
+ unsigned i;
+
+ if (!vlsurf->video_buffer)
+ return;
+
+ surfaces = vlsurf->video_buffer->get_surfaces(vlsurf->video_buffer);
+ for (i = 0; i < VL_MAX_SURFACES; ++i) {
+ union pipe_color_union black = {};
+
+ if (!surfaces[i])
+ continue;
+
+ pipe->clear_render_target(pipe, surfaces[i], &black, 0, 0,
+ surfaces[i]->width, surfaces[i]->height);
+ }
+ pipe->flush(pipe, NULL);
+}
diff --git a/src/gallium/state_trackers/vdpau/vdpau_private.h b/src/gallium/state_trackers/vdpau/vdpau_private.h
index b0272d7c938..a54fcdcf2ae 100644
--- a/src/gallium/state_trackers/vdpau/vdpau_private.h
+++ b/src/gallium/state_trackers/vdpau/vdpau_private.h
@@ -435,6 +435,7 @@ VdpVideoSurfaceDestroy vlVdpVideoSurfaceDestroy;
VdpVideoSurfaceGetParameters vlVdpVideoSurfaceGetParameters;
VdpVideoSurfaceGetBitsYCbCr vlVdpVideoSurfaceGetBitsYCbCr;
VdpVideoSurfacePutBitsYCbCr vlVdpVideoSurfacePutBitsYCbCr;
+void vlVdpVideoSurfaceClear(vlVdpSurface *vlsurf);
VdpDecoderCreate vlVdpDecoderCreate;
VdpDecoderDestroy vlVdpDecoderDestroy;
VdpDecoderGetParameters vlVdpDecoderGetParameters;