summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian König <[email protected]>2012-01-10 14:40:39 +0100
committerChristian König <[email protected]>2012-01-15 12:40:44 +0100
commit4a4811ea178fb158339c1fbfacc58a9ab97058f8 (patch)
tree9a646b354d041c85d0562386609d21ed97b415c0 /src
parent9d9afcb5bac2931d4b8e6d1aa571e941c5110c90 (diff)
st/vdpau: recreate video buffer if format doesn't match
Recreate the video buffer in PutBitsYCbCr if the format doesn't match. Signed-off-by: Christian König <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/state_trackers/vdpau/surface.c54
-rw-r--r--src/gallium/state_trackers/vdpau/vdpau_private.h2
2 files changed, 37 insertions, 19 deletions
diff --git a/src/gallium/state_trackers/vdpau/surface.c b/src/gallium/state_trackers/vdpau/surface.c
index 60cbbed2769..8fdfafcae6d 100644
--- a/src/gallium/state_trackers/vdpau/surface.c
+++ b/src/gallium/state_trackers/vdpau/surface.c
@@ -44,7 +44,7 @@ vlVdpVideoSurfaceCreate(VdpDevice device, VdpChromaType chroma_type,
uint32_t width, uint32_t height,
VdpVideoSurface *surface)
{
- struct pipe_video_buffer tmpl;
+ struct pipe_context *pipe;
vlVdpSurface *p_surf;
VdpStatus ret;
@@ -73,21 +73,19 @@ vlVdpVideoSurfaceCreate(VdpDevice device, VdpChromaType chroma_type,
}
p_surf->device = dev;
- memset(&tmpl, 0, sizeof(tmpl));
- tmpl.buffer_format = dev->context->pipe->screen->get_video_param
+ pipe = dev->context->pipe;
+
+ memset(&p_surf->templat, 0, sizeof(p_surf->templat));
+ p_surf->templat.buffer_format = pipe->screen->get_video_param
(
- dev->context->pipe->screen,
+ pipe->screen,
PIPE_VIDEO_PROFILE_UNKNOWN,
PIPE_VIDEO_CAP_PREFERED_FORMAT
);
- tmpl.chroma_format = ChromaToPipe(chroma_type);
- tmpl.width = width;
- tmpl.height = height;
- p_surf->video_buffer = dev->context->pipe->create_video_buffer
- (
- dev->context->pipe,
- &tmpl
- );
+ p_surf->templat.chroma_format = ChromaToPipe(chroma_type);
+ p_surf->templat.width = width;
+ p_surf->templat.height = height;
+ p_surf->video_buffer = pipe->create_video_buffer(pipe, &p_surf->templat);
*surface = vlAddDataHTAB(p_surf);
if (*surface == 0) {
@@ -143,9 +141,15 @@ vlVdpVideoSurfaceGetParameters(VdpVideoSurface surface,
if (!p_surf)
return VDP_STATUS_INVALID_HANDLE;
- *width = p_surf->video_buffer->width;
- *height = p_surf->video_buffer->height;
- *chroma_type = PipeToChroma(p_surf->video_buffer->chroma_format);
+ if (p_surf->video_buffer) {
+ *width = p_surf->video_buffer->width;
+ *height = p_surf->video_buffer->height;
+ *chroma_type = PipeToChroma(p_surf->video_buffer->chroma_format);
+ } else {
+ *width = p_surf->templat.width;
+ *height = p_surf->templat.height;
+ *chroma_type = PipeToChroma(p_surf->templat.chroma_format);
+ }
return VDP_STATUS_OK;
}
@@ -200,9 +204,23 @@ vlVdpVideoSurfacePutBitsYCbCr(VdpVideoSurface surface,
if (!pipe)
return VDP_STATUS_INVALID_HANDLE;
- if (p_surf->video_buffer == NULL || pformat != p_surf->video_buffer->buffer_format) {
- assert(0); // TODO Recreate resource
- return VDP_STATUS_NO_IMPLEMENTATION;
+ if (p_surf->video_buffer == NULL || p_surf->video_buffer->interlaced ||
+ pformat != p_surf->video_buffer->buffer_format) {
+
+ /* destroy the old one */
+ if (p_surf->video_buffer)
+ p_surf->video_buffer->destroy(p_surf->video_buffer);
+
+ /* adjust the template parameters */
+ p_surf->templat.buffer_format = pformat;
+ p_surf->templat.interlaced = false;
+
+ /* and try to create the video buffer with the new format */
+ p_surf->video_buffer = pipe->create_video_buffer(pipe, &p_surf->templat);
+
+ /* stil no luck? ok forget it we don't support it */
+ if (!p_surf->video_buffer)
+ return VDP_STATUS_NO_IMPLEMENTATION;
}
sampler_views = p_surf->video_buffer->get_sampler_view_planes(p_surf->video_buffer);
diff --git a/src/gallium/state_trackers/vdpau/vdpau_private.h b/src/gallium/state_trackers/vdpau/vdpau_private.h
index 1bbbaa9fbea..912f73d22c9 100644
--- a/src/gallium/state_trackers/vdpau/vdpau_private.h
+++ b/src/gallium/state_trackers/vdpau/vdpau_private.h
@@ -316,7 +316,7 @@ typedef struct
typedef struct
{
vlVdpDevice *device;
- struct pipe_video_buffer *video_buffer;
+ struct pipe_video_buffer templat, *video_buffer;
} vlVdpSurface;
typedef uint64_t vlVdpTime;