diff options
author | Christian König <[email protected]> | 2012-01-02 14:22:33 +0100 |
---|---|---|
committer | Christian König <[email protected]> | 2012-01-15 12:40:44 +0100 |
commit | e027759336bf49e3f568bd73b9e5f26d56ef6f83 (patch) | |
tree | b82a3cd8c9f0ca6ce718567aa1ec128b14c7c0b3 /src/gallium/auxiliary/vl | |
parent | 39491d1d31d9f03437816fbb4f2872761ae1157c (diff) |
vl/video_buffer: use template style create params
Just like in the rest of gallium, this reduces the
number of parameters significantly.
Signed-off-by: Christian König <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/vl')
-rw-r--r-- | src/gallium/auxiliary/vl/vl_mpeg12_decoder.c | 27 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vl_video_buffer.c | 47 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vl_video_buffer.h | 9 |
3 files changed, 43 insertions, 40 deletions
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c index cb55fa6f611..6341cc1b218 100644 --- a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c +++ b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c @@ -909,6 +909,7 @@ init_idct(struct vl_mpeg12_decoder *dec, const struct format_config* format_conf { unsigned nr_of_idct_render_targets, max_inst; enum pipe_format formats[3]; + struct pipe_video_buffer templat; struct pipe_sampler_view *matrix = NULL; @@ -930,21 +931,28 @@ init_idct(struct vl_mpeg12_decoder *dec, const struct format_config* format_conf nr_of_idct_render_targets = 1; formats[0] = formats[1] = formats[2] = format_config->idct_source_format; + memset(&templat, 0, sizeof(templat)); + templat.width = dec->base.width / 4; + templat.height = dec->base.height; + templat.chroma_format = dec->base.chroma_format; dec->idct_source = vl_video_buffer_create_ex ( - dec->base.context, dec->base.width / 4, dec->base.height, 1, - dec->base.chroma_format, formats, PIPE_USAGE_STATIC + dec->base.context, &templat, + formats, 1, PIPE_USAGE_STATIC ); if (!dec->idct_source) goto error_idct_source; formats[0] = formats[1] = formats[2] = format_config->mc_source_format; + memset(&templat, 0, sizeof(templat)); + templat.width = dec->base.width / nr_of_idct_render_targets; + templat.height = dec->base.height / 4; + templat.chroma_format = dec->base.chroma_format; dec->mc_source = vl_video_buffer_create_ex ( - dec->base.context, dec->base.width / nr_of_idct_render_targets, - dec->base.height / 4, nr_of_idct_render_targets, - dec->base.chroma_format, formats, PIPE_USAGE_STATIC + dec->base.context, &templat, + formats, nr_of_idct_render_targets, PIPE_USAGE_STATIC ); if (!dec->mc_source) @@ -985,12 +993,17 @@ static bool init_mc_source_widthout_idct(struct vl_mpeg12_decoder *dec, const struct format_config* format_config) { enum pipe_format formats[3]; + struct pipe_video_buffer templat; formats[0] = formats[1] = formats[2] = format_config->mc_source_format; + memset(&templat, 0, sizeof(templat)); + templat.width = dec->base.width; + templat.height = dec->base.height; + templat.chroma_format = dec->base.chroma_format; dec->mc_source = vl_video_buffer_create_ex ( - dec->base.context, dec->base.width, dec->base.height, 1, - dec->base.chroma_format, formats, PIPE_USAGE_STATIC + dec->base.context, &templat, + formats, 1, PIPE_USAGE_STATIC ); return dec->mc_source != NULL; diff --git a/src/gallium/auxiliary/vl/vl_video_buffer.c b/src/gallium/auxiliary/vl/vl_video_buffer.c index 8ceb7138479..29d910e69e5 100644 --- a/src/gallium/auxiliary/vl/vl_video_buffer.c +++ b/src/gallium/auxiliary/vl/vl_video_buffer.c @@ -253,17 +253,14 @@ error: struct pipe_video_buffer * vl_video_buffer_create(struct pipe_context *pipe, - enum pipe_format buffer_format, - enum pipe_video_chroma_format chroma_format, - unsigned width, unsigned height) + const struct pipe_video_buffer *tmpl) { const enum pipe_format *resource_formats; - struct pipe_video_buffer *result; - unsigned buffer_width, buffer_height; + struct pipe_video_buffer templat; bool pot_buffers; assert(pipe); - assert(width > 0 && height > 0); + assert(tmpl->width > 0 && tmpl->height > 0); pot_buffers = !pipe->screen->get_video_param ( @@ -272,30 +269,28 @@ vl_video_buffer_create(struct pipe_context *pipe, PIPE_VIDEO_CAP_NPOT_TEXTURES ); - resource_formats = vl_video_buffer_formats(pipe->screen, buffer_format); + resource_formats = vl_video_buffer_formats(pipe->screen, tmpl->buffer_format); if (!resource_formats) return NULL; - buffer_width = pot_buffers ? util_next_power_of_two(width) : align(width, MACROBLOCK_WIDTH); - buffer_height = pot_buffers ? util_next_power_of_two(height) : align(height, MACROBLOCK_HEIGHT); + templat = *tmpl; + templat.width = pot_buffers ? util_next_power_of_two(tmpl->width) + : align(tmpl->width, MACROBLOCK_WIDTH); + templat.height = pot_buffers ? util_next_power_of_two(tmpl->height) + : align(tmpl->height, MACROBLOCK_HEIGHT); - result = vl_video_buffer_create_ex + return vl_video_buffer_create_ex ( - pipe, buffer_width, buffer_height, 1, - chroma_format, resource_formats, PIPE_USAGE_STATIC + pipe, &templat, resource_formats, + 1, PIPE_USAGE_STATIC ); - if (result) - result->buffer_format = buffer_format; - - return result; } struct pipe_video_buffer * vl_video_buffer_create_ex(struct pipe_context *pipe, - unsigned width, unsigned height, unsigned depth, - enum pipe_video_chroma_format chroma_format, + const struct pipe_video_buffer *tmpl, const enum pipe_format resource_formats[VL_MAX_PLANES], - unsigned usage) + unsigned depth, unsigned usage) { struct vl_video_buffer *buffer; struct pipe_resource templ; @@ -305,21 +300,19 @@ vl_video_buffer_create_ex(struct pipe_context *pipe, buffer = CALLOC_STRUCT(vl_video_buffer); + buffer->base = *tmpl; buffer->base.context = pipe; buffer->base.destroy = vl_video_buffer_destroy; buffer->base.get_sampler_view_planes = vl_video_buffer_sampler_view_planes; buffer->base.get_sampler_view_components = vl_video_buffer_sampler_view_components; buffer->base.get_surfaces = vl_video_buffer_surfaces; - buffer->base.chroma_format = chroma_format; - buffer->base.width = width; - buffer->base.height = height; buffer->num_planes = 1; memset(&templ, 0, sizeof(templ)); templ.target = depth > 1 ? PIPE_TEXTURE_3D : PIPE_TEXTURE_2D; templ.format = resource_formats[0]; - templ.width0 = width; - templ.height0 = height; + templ.width0 = tmpl->width; + templ.height0 = tmpl->height; templ.depth0 = depth; templ.array_size = 1; templ.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET; @@ -330,17 +323,17 @@ vl_video_buffer_create_ex(struct pipe_context *pipe, goto error; if (resource_formats[1] == PIPE_FORMAT_NONE) { - assert(chroma_format == PIPE_VIDEO_CHROMA_FORMAT_444); + assert(tmpl->chroma_format == PIPE_VIDEO_CHROMA_FORMAT_444); assert(resource_formats[2] == PIPE_FORMAT_NONE); return &buffer->base; } else buffer->num_planes = 2; templ.format = resource_formats[1]; - if (chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420) { + if (tmpl->chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420) { templ.width0 /= 2; templ.height0 /= 2; - } else if (chroma_format == PIPE_VIDEO_CHROMA_FORMAT_422) { + } else if (tmpl->chroma_format == PIPE_VIDEO_CHROMA_FORMAT_422) { templ.height0 /= 2; } diff --git a/src/gallium/auxiliary/vl/vl_video_buffer.h b/src/gallium/auxiliary/vl/vl_video_buffer.h index e096ccdaac2..e0e29b20f31 100644 --- a/src/gallium/auxiliary/vl/vl_video_buffer.h +++ b/src/gallium/auxiliary/vl/vl_video_buffer.h @@ -90,18 +90,15 @@ vl_video_buffer_get_associated_data(struct pipe_video_buffer *vbuf, */ struct pipe_video_buffer * vl_video_buffer_create(struct pipe_context *pipe, - enum pipe_format buffer_format, - enum pipe_video_chroma_format chroma_format, - unsigned width, unsigned height); + const struct pipe_video_buffer *templat); /** * extended create function, gets depth, usage and formats for each plane seperately */ struct pipe_video_buffer * vl_video_buffer_create_ex(struct pipe_context *pipe, - unsigned width, unsigned height, unsigned depth, - enum pipe_video_chroma_format chroma_format, + const struct pipe_video_buffer *templat, const enum pipe_format resource_formats[VL_MAX_PLANES], - unsigned usage); + unsigned depth, unsigned usage); #endif /* vl_video_buffer_h */ |