vl/buffers: extract vl_video_buffer_adjust_size helper
authorChristian König <christian.koenig@amd.com>
Tue, 15 Dec 2015 10:51:44 +0000 (11:51 +0100)
committerChristian König <christian.koenig@amd.com>
Tue, 12 Jan 2016 12:28:16 +0000 (13:28 +0100)
Useful for the state trackers as well.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
src/gallium/auxiliary/vl/vl_video_buffer.c
src/gallium/auxiliary/vl/vl_video_buffer.h

index e8cd24dec8129b78159b083925323efbb3f7418b..462fdcb08823409b04366932b1936bd1204bd550 100644 (file)
@@ -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
index 488c3cc4eac29f9fd99051fc324e913e75d707e4..8a1c0773fc9a84e7bc6b9ea0868ebaec147fb5bc 100644 (file)
@@ -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
  */