From 52ca9a9b8bf9c3991a82d7039d7a35955ad774b8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Christian=20K=C3=B6nig?= Date: Tue, 15 Dec 2015 11:51:44 +0100 Subject: [PATCH] vl/buffers: extract vl_video_buffer_adjust_size helper MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Useful for the state trackers as well. Signed-off-by: Christian König Reviewed-by: Emil Velikov --- src/gallium/auxiliary/vl/vl_video_buffer.c | 10 ++-------- src/gallium/auxiliary/vl/vl_video_buffer.h | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/gallium/auxiliary/vl/vl_video_buffer.c b/src/gallium/auxiliary/vl/vl_video_buffer.c index e8cd24dec81..462fdcb0882 100644 --- a/src/gallium/auxiliary/vl/vl_video_buffer.c +++ b/src/gallium/auxiliary/vl/vl_video_buffer.c @@ -253,14 +253,8 @@ vl_video_buffer_template(struct pipe_resource *templ, templ->bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET; templ->usage = usage; - if (plane > 0) { - if (tmpl->chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420) { - templ->width0 /= 2; - templ->height0 /= 2; - } else if (tmpl->chroma_format == PIPE_VIDEO_CHROMA_FORMAT_422) { - templ->width0 /= 2; - } - } + vl_video_buffer_adjust_size(&templ->width0, &templ->height0, plane, + tmpl->chroma_format, false); } static void diff --git a/src/gallium/auxiliary/vl/vl_video_buffer.h b/src/gallium/auxiliary/vl/vl_video_buffer.h index 488c3cc4eac..8a1c0773fc9 100644 --- a/src/gallium/auxiliary/vl/vl_video_buffer.h +++ b/src/gallium/auxiliary/vl/vl_video_buffer.h @@ -48,6 +48,24 @@ struct vl_video_buffer struct pipe_surface *surfaces[VL_MAX_SURFACES]; }; +static inline void +vl_video_buffer_adjust_size(unsigned *width, unsigned *height, unsigned plane, + enum pipe_video_chroma_format chroma_format, + bool interlaced) +{ + if (interlaced) { + *height /= 2; + } + if (plane > 0) { + if (chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420) { + *width /= 2; + *height /= 2; + } else if (chroma_format == PIPE_VIDEO_CHROMA_FORMAT_422) { + *width /= 2; + } + } +} + /** * get subformats for each plane */ -- 2.30.2