+unsigned
+vl_video_buffer_max_size(struct pipe_screen *screen)
+{
+ uint32_t max_2d_texture_level;
+
+ max_2d_texture_level = screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS);
+
+ return 1 << (max_2d_texture_level-1);
+}
+
+void
+vl_video_buffer_set_associated_data(struct pipe_video_buffer *vbuf,
+ struct pipe_video_codec *vcodec,
+ void *associated_data,
+ void (*destroy_associated_data)(void *))
+{
+ vbuf->codec = vcodec;
+
+ if (vbuf->associated_data == associated_data)
+ return;
+
+ if (vbuf->associated_data)
+ vbuf->destroy_associated_data(vbuf->associated_data);
+
+ vbuf->associated_data = associated_data;
+ vbuf->destroy_associated_data = destroy_associated_data;
+}
+
+void *
+vl_video_buffer_get_associated_data(struct pipe_video_buffer *vbuf,
+ struct pipe_video_codec *vcodec)
+{
+ if (vbuf->codec == vcodec)
+ return vbuf->associated_data;
+ else
+ return NULL;
+}
+
+void
+vl_video_buffer_template(struct pipe_resource *templ,
+ const struct pipe_video_buffer *tmpl,
+ enum pipe_format resource_format,
+ unsigned depth, unsigned array_size,
+ unsigned usage, unsigned plane)
+{
+ memset(templ, 0, sizeof(*templ));
+ if (depth > 1)
+ templ->target = PIPE_TEXTURE_3D;
+ else if (array_size > 1)
+ templ->target = PIPE_TEXTURE_2D_ARRAY;
+ else
+ templ->target = PIPE_TEXTURE_2D;
+ templ->format = resource_format;
+ templ->width0 = tmpl->width;
+ templ->height0 = tmpl->height;
+ templ->depth0 = depth;
+ templ->array_size = array_size;
+ 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;
+ }
+ }
+}
+