diff options
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r-- | src/gallium/auxiliary/vl/vl_context.c | 41 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vl_mpeg12_decoder.c | 45 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vl_video_buffer.c | 60 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vl_video_buffer.h | 24 |
4 files changed, 91 insertions, 79 deletions
diff --git a/src/gallium/auxiliary/vl/vl_context.c b/src/gallium/auxiliary/vl/vl_context.c index b685e91d23e..fec227dc01f 100644 --- a/src/gallium/auxiliary/vl/vl_context.c +++ b/src/gallium/auxiliary/vl/vl_context.c @@ -74,46 +74,6 @@ vl_context_create_decoder(struct pipe_video_context *context, return NULL; } -static struct pipe_video_buffer * -vl_context_create_buffer(struct pipe_video_context *context, - enum pipe_format buffer_format, - enum pipe_video_chroma_format chroma_format, - unsigned width, unsigned height) -{ - struct vl_context *ctx = (struct vl_context*)context; - const enum pipe_format *resource_formats; - struct pipe_video_buffer *result; - unsigned buffer_width, buffer_height; - bool pot_buffers; - - assert(context); - assert(width > 0 && height > 0); - - pot_buffers = !ctx->base.screen->get_video_param - ( - ctx->base.screen, - PIPE_VIDEO_PROFILE_UNKNOWN, - PIPE_VIDEO_CAP_NPOT_TEXTURES - ); - - resource_formats = vl_video_buffer_formats(ctx->pipe->screen, 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); - - result = vl_video_buffer_init(context, ctx->pipe, - buffer_width, buffer_height, 1, - chroma_format, - resource_formats, - PIPE_USAGE_STATIC); - if (result) // TODO move format handling into vl_video_buffer - result->buffer_format = buffer_format; - - return result; -} - struct pipe_video_context * vl_create_context(struct pipe_context *pipe) { @@ -128,7 +88,6 @@ vl_create_context(struct pipe_context *pipe) ctx->base.destroy = vl_context_destroy; ctx->base.create_decoder = vl_context_create_decoder; - ctx->base.create_buffer = vl_context_create_buffer; ctx->pipe = pipe; diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c index eacb49e83c0..c2ddd2cb2ce 100644 --- a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c +++ b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c @@ -92,11 +92,14 @@ init_zscan_buffer(struct vl_mpeg12_buffer *buffer) dec = (struct vl_mpeg12_decoder*)buffer->base.decoder; formats[0] = formats[1] = formats[2] = dec->zscan_source_format; - buffer->zscan_source = vl_video_buffer_init(dec->base.context, dec->pipe, - dec->blocks_per_line * BLOCK_WIDTH * BLOCK_HEIGHT, - align(dec->num_blocks, dec->blocks_per_line) / dec->blocks_per_line, - 1, PIPE_VIDEO_CHROMA_FORMAT_444, - formats, PIPE_USAGE_STATIC); + buffer->zscan_source = vl_video_buffer_create_ex + ( + dec->pipe, + dec->blocks_per_line * BLOCK_WIDTH * BLOCK_HEIGHT, + align(dec->num_blocks, dec->blocks_per_line) / dec->blocks_per_line, + 1, PIPE_VIDEO_CHROMA_FORMAT_444, formats, PIPE_USAGE_STATIC + ); + if (!buffer->zscan_source) goto error_source; @@ -718,19 +721,22 @@ 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; - dec->idct_source = vl_video_buffer_init(dec->base.context, dec->pipe, - dec->base.width / 4, dec->base.height, 1, - dec->base.chroma_format, - formats, PIPE_USAGE_STATIC); + dec->idct_source = vl_video_buffer_create_ex + ( + dec->pipe, dec->base.width / 4, dec->base.height, 1, + dec->base.chroma_format, formats, PIPE_USAGE_STATIC + ); + if (!dec->idct_source) goto error_idct_source; formats[0] = formats[1] = formats[2] = format_config->mc_source_format; - dec->mc_source = vl_video_buffer_init(dec->base.context, dec->pipe, - 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->mc_source = vl_video_buffer_create_ex + ( + dec->pipe, 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 + ); if (!dec->mc_source) goto error_mc_source; @@ -772,11 +778,12 @@ init_mc_source_widthout_idct(struct vl_mpeg12_decoder *dec, const struct format_ enum pipe_format formats[3]; formats[0] = formats[1] = formats[2] = format_config->mc_source_format; - dec->mc_source = vl_video_buffer_init(dec->base.context, dec->pipe, - dec->base.width, dec->base.height, 1, - dec->base.chroma_format, - formats, PIPE_USAGE_STATIC); - + dec->mc_source = vl_video_buffer_create_ex + ( + dec->pipe, dec->base.width, dec->base.height, 1, + dec->base.chroma_format, formats, 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 9b7bab47484..49b7b50cfee 100644 --- a/src/gallium/auxiliary/vl/vl_video_buffer.c +++ b/src/gallium/auxiliary/vl/vl_video_buffer.c @@ -114,7 +114,7 @@ vl_video_buffer_sampler_view_planes(struct pipe_video_buffer *buffer) assert(buf); - pipe = buf->pipe; + pipe = buf->base.context; for (i = 0; i < buf->num_planes; ++i ) { if (!buf->sampler_view_planes[i]) { @@ -149,7 +149,7 @@ vl_video_buffer_sampler_view_components(struct pipe_video_buffer *buffer) assert(buf); - pipe = buf->pipe; + pipe = buf->base.context; for (component = 0, i = 0; i < buf->num_planes; ++i ) { unsigned nr_components = util_format_get_nr_components(buf->resources[i]->format); @@ -188,7 +188,7 @@ vl_video_buffer_surfaces(struct pipe_video_buffer *buffer) assert(buf); - pipe = buf->pipe; + pipe = buf->base.context; for (i = 0; i < buf->num_planes; ++i ) { if (!buf->surfaces[i]) { @@ -211,21 +211,60 @@ error: } struct pipe_video_buffer * -vl_video_buffer_init(struct pipe_video_context *context, - struct pipe_context *pipe, - unsigned width, unsigned height, unsigned depth, - enum pipe_video_chroma_format chroma_format, - const enum pipe_format resource_formats[VL_MAX_PLANES], - unsigned usage) +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 enum pipe_format *resource_formats; + struct pipe_video_buffer *result; + unsigned buffer_width, buffer_height; + bool pot_buffers; + + assert(pipe); + assert(width > 0 && height > 0); + + pot_buffers = !pipe->screen->get_video_param + ( + pipe->screen, + PIPE_VIDEO_PROFILE_UNKNOWN, + PIPE_VIDEO_CAP_NPOT_TEXTURES + ); + + resource_formats = vl_video_buffer_formats(pipe->screen, 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); + + result = vl_video_buffer_create_ex + ( + pipe, buffer_width, buffer_height, 1, + chroma_format, resource_formats, 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 enum pipe_format resource_formats[VL_MAX_PLANES], + unsigned usage) { struct vl_video_buffer *buffer; struct pipe_resource templ; unsigned i; - assert(context && pipe); + assert(pipe); buffer = CALLOC_STRUCT(vl_video_buffer); + 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; @@ -233,7 +272,6 @@ vl_video_buffer_init(struct pipe_video_context *context, buffer->base.chroma_format = chroma_format; buffer->base.width = width; buffer->base.height = height; - buffer->pipe = pipe; buffer->num_planes = 1; memset(&templ, 0, sizeof(templ)); diff --git a/src/gallium/auxiliary/vl/vl_video_buffer.h b/src/gallium/auxiliary/vl/vl_video_buffer.h index 8755c54dc73..172f332712b 100644 --- a/src/gallium/auxiliary/vl/vl_video_buffer.h +++ b/src/gallium/auxiliary/vl/vl_video_buffer.h @@ -41,7 +41,6 @@ struct vl_video_buffer { struct pipe_video_buffer base; - struct pipe_context *pipe; unsigned num_planes; struct pipe_resource *resources[VL_MAX_PLANES]; struct pipe_sampler_view *sampler_view_planes[VL_MAX_PLANES]; @@ -63,15 +62,24 @@ boolean vl_video_buffer_is_format_supported(struct pipe_screen *screen, enum pipe_format format, enum pipe_video_profile profile); + +/** + * creates a video buffer, can be used as a standard implementation for pipe->create_video_buffer + */ +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); /** - * initialize a buffer, creating its resources + * extended create function, gets depth, usage and formats for each plane seperately */ struct pipe_video_buffer * -vl_video_buffer_init(struct pipe_video_context *context, - struct pipe_context *pipe, - unsigned width, unsigned height, unsigned depth, - enum pipe_video_chroma_format chroma_format, - const enum pipe_format resource_formats[VL_MAX_PLANES], - unsigned usage); +vl_video_buffer_create_ex(struct pipe_context *pipe, + unsigned width, unsigned height, unsigned depth, + enum pipe_video_chroma_format chroma_format, + const enum pipe_format resource_formats[VL_MAX_PLANES], + unsigned usage); + #endif /* vl_ycbcr_buffer_h */ |