On 17 October 2015 at 00:14, Julien Isorce <julien.iso...@gmail.com> wrote: > If formats are not the same it seems to re-create the video > buffer with the right format. > But if the creation of this new video buffer fails the surface > loose its video buffer. > Let's just destroy the previous buffer on success. > The formatting looks strange.
> Signed-off-by: Julien Isorce <j.iso...@samsung.com> > --- > src/gallium/state_trackers/va/image.c | 19 ++++++++++++++----- > 1 file changed, 14 insertions(+), 5 deletions(-) > > diff --git a/src/gallium/state_trackers/va/image.c > b/src/gallium/state_trackers/va/image.c > index c7fbe1a..d3b0cd5 100644 > --- a/src/gallium/state_trackers/va/image.c > +++ b/src/gallium/state_trackers/va/image.c > @@ -338,13 +338,22 @@ vlVaPutImage(VADriverContextP ctx, VASurfaceID surface, > VAImageID image, > if (format == PIPE_FORMAT_NONE) > return VA_STATUS_ERROR_OPERATION_FAILED; > > - if (surf->buffer == NULL || format != surf->buffer->buffer_format) { > + if (format != surf->buffer->buffer_format) { > + struct pipe_video_buffer *tmp_buf = NULL; Please drop the initialiser. > + enum pipe_format old_surf_format = surf->templat.buffer_format; > + > + surf->templat.buffer_format = format; > + tmp_buf = drv->pipe->create_video_buffer(drv->pipe, &surf->templat); > + > + if (!tmp_buf) { > + surf->templat.buffer_format = old_surf_format; > + return VA_STATUS_ERROR_ALLOCATION_FAILED; > + } > + > if (surf->buffer) Drop the if (unconditionally destroy the buffer). We're already checking it before we get here. With the above sorted Reviewed-by: Emil Velikov <emil.l.veli...@gmail.com> -Emil _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev