diff options
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r-- | src/gallium/auxiliary/Makefile.sources | 1 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_init.h | 52 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vl_deint_filter.c | 77 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vl_deint_filter.h | 2 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vl_video_buffer.c | 10 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vl_video_buffer.h | 18 |
6 files changed, 76 insertions, 84 deletions
diff --git a/src/gallium/auxiliary/Makefile.sources b/src/gallium/auxiliary/Makefile.sources index d92da3d..5325f97 100644 --- a/src/gallium/auxiliary/Makefile.sources +++ b/src/gallium/auxiliary/Makefile.sources @@ -252,7 +252,6 @@ C_SOURCES := \ util/u_helpers.h \ util/u_index_modify.c \ util/u_index_modify.h \ - util/u_init.h \ util/u_inlines.h \ util/u_keymap.c \ util/u_keymap.h \ diff --git a/src/gallium/auxiliary/util/u_init.h b/src/gallium/auxiliary/util/u_init.h deleted file mode 100644 index 7bc356a..0000000 --- a/src/gallium/auxiliary/util/u_init.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2010 Luca Barbieri - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#ifndef U_INIT_H -#define U_INIT_H - -/* Use UTIL_INIT(f) to have f called at program initialization. - Note that it is only guaranteed to be called if any symbol in the - .c file it is in sis referenced by the program. - - UTIL_INIT functions are called in arbitrary order. -*/ - -#ifdef __cplusplus -/* use a C++ global constructor */ -#define UTIL_INIT(f) struct f##__gctor_t {f##__gctor_t() {x();}} f##__gctor; -#elif defined(_MSC_VER) -/* add a pointer to the section where MSVC stores global constructor pointers */ -/* see http://blogs.msdn.com/vcblog/archive/2006/10/20/crt-initialization.aspx and - http://stackoverflow.com/questions/1113409/attribute-constructor-equivalent-in-vc */ -#pragma section(".CRT$XCU",read) -#define UTIL_INIT(f) static void __cdecl f##__init(void) {f();}; __declspec(allocate(".CRT$XCU")) void (__cdecl* f##__xcu)(void) = f##__init; -#elif defined(__GNUC__) -#define UTIL_INIT(f) static void f##__init(void) __attribute__((constructor)); static void f##__init(void) {f();} -#else -#error Unsupported compiler: please find out how to implement global initializers in C on it -#endif - -#endif - diff --git a/src/gallium/auxiliary/vl/vl_deint_filter.c b/src/gallium/auxiliary/vl/vl_deint_filter.c index 8fa70e8..9e782e5 100644 --- a/src/gallium/auxiliary/vl/vl_deint_filter.c +++ b/src/gallium/auxiliary/vl/vl_deint_filter.c @@ -47,6 +47,7 @@ #include "util/u_draw.h" #include "util/u_memory.h" #include "util/u_math.h" +#include "util/u_format.h" #include "vl_types.h" #include "vl_video_buffer.h" @@ -214,8 +215,9 @@ create_deint_frag_shader(struct vl_deint_filter *filter, unsigned field, ureg_imm4f(shader, -0.02353f, 0, 0, 0)); ureg_MUL(shader, ureg_saturate(ureg_writemask(t_diff, TGSI_WRITEMASK_X)), ureg_src(t_diff), ureg_imm4f(shader, 31.8750f, 0, 0, 0)); - ureg_LRP(shader, ureg_writemask(o_fragment, TGSI_WRITEMASK_X), ureg_src(t_diff), + ureg_LRP(shader, ureg_writemask(t_tex, TGSI_WRITEMASK_X), ureg_src(t_diff), ureg_src(t_linear), ureg_src(t_weave)); + ureg_MOV(shader, o_fragment, ureg_scalar(ureg_src(t_tex), TGSI_SWIZZLE_X)); ureg_release_temporary(shader, t_tex); ureg_release_temporary(shader, t_comp_top); @@ -253,7 +255,13 @@ vl_deint_filter_init(struct vl_deint_filter *filter, struct pipe_context *pipe, /* TODO: handle other than 4:2:0 subsampling */ memset(&templ, 0, sizeof(templ)); - templ.buffer_format = PIPE_FORMAT_YV12; + templ.buffer_format = pipe->screen->get_video_param + ( + pipe->screen, + PIPE_VIDEO_PROFILE_UNKNOWN, + PIPE_VIDEO_ENTRYPOINT_UNKNOWN, + PIPE_VIDEO_CAP_PREFERED_FORMAT + ); templ.chroma_format = PIPE_VIDEO_CHROMA_FORMAT_420; templ.width = video_width; templ.height = video_height; @@ -271,10 +279,20 @@ vl_deint_filter_init(struct vl_deint_filter *filter, struct pipe_context *pipe, goto error_rs_state; memset(&blend, 0, sizeof blend); - blend.rt[0].colormask = PIPE_MASK_RGBA; - filter->blend = pipe->create_blend_state(pipe, &blend); - if (!filter->blend) - goto error_blend; + blend.rt[0].colormask = PIPE_MASK_R; + filter->blend[0] = pipe->create_blend_state(pipe, &blend); + if (!filter->blend[0]) + goto error_blendR; + + blend.rt[0].colormask = PIPE_MASK_G; + filter->blend[1] = pipe->create_blend_state(pipe, &blend); + if (!filter->blend[1]) + goto error_blendG; + + blend.rt[0].colormask = PIPE_MASK_B; + filter->blend[2] = pipe->create_blend_state(pipe, &blend); + if (!filter->blend[2]) + goto error_blendB; memset(&sampler, 0, sizeof(sampler)); sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE; @@ -349,9 +367,15 @@ error_quad: pipe->delete_sampler_state(pipe, filter->sampler); error_sampler: - pipe->delete_blend_state(pipe, filter->blend); + pipe->delete_blend_state(pipe, filter->blend[2]); + +error_blendB: + pipe->delete_blend_state(pipe, filter->blend[1]); + +error_blendG: + pipe->delete_blend_state(pipe, filter->blend[0]); -error_blend: +error_blendR: pipe->delete_rasterizer_state(pipe, filter->rs_state); error_rs_state: @@ -367,7 +391,9 @@ vl_deint_filter_cleanup(struct vl_deint_filter *filter) assert(filter); filter->pipe->delete_sampler_state(filter->pipe, filter->sampler[0]); - filter->pipe->delete_blend_state(filter->pipe, filter->blend); + filter->pipe->delete_blend_state(filter->pipe, filter->blend[0]); + filter->pipe->delete_blend_state(filter->pipe, filter->blend[1]); + filter->pipe->delete_blend_state(filter->pipe, filter->blend[2]); filter->pipe->delete_rasterizer_state(filter->pipe, filter->rs_state); filter->pipe->delete_vertex_elements_state(filter->pipe, filter->ves); pipe_resource_reference(&filter->quad.buffer, NULL); @@ -420,12 +446,14 @@ vl_deint_filter_render(struct vl_deint_filter *filter, struct pipe_sampler_view **next_sv; struct pipe_sampler_view *sampler_views[4]; struct pipe_surface **dst_surfaces; - int j; + const unsigned *plane_order; + int i, j; assert(filter && prevprev && prev && cur && next && field <= 1); /* set up destination and source */ dst_surfaces = filter->video_buffer->get_surfaces(filter->video_buffer); + plane_order = vl_video_buffer_plane_order(filter->video_buffer->buffer_format); cur_sv = cur->get_sampler_view_components(cur); prevprev_sv = prevprev->get_sampler_view_components(prevprev); prev_sv = prev->get_sampler_view_components(prev); @@ -433,7 +461,6 @@ vl_deint_filter_render(struct vl_deint_filter *filter, /* set up pipe state */ filter->pipe->bind_rasterizer_state(filter->pipe, filter->rs_state); - filter->pipe->bind_blend_state(filter->pipe, filter->blend); filter->pipe->set_vertex_buffers(filter->pipe, 0, 1, &filter->quad); filter->pipe->bind_vertex_elements_state(filter->pipe, filter->ves); filter->pipe->bind_vs_state(filter->pipe, filter->vs); @@ -449,12 +476,13 @@ vl_deint_filter_render(struct vl_deint_filter *filter, fb_state.nr_cbufs = 1; /* process each plane separately */ - for (j = 0; j < 3; j++) { - /* select correct YV12 surfaces */ - int k = j == 1 ? 2 : - j == 2 ? 1 : 0; - struct pipe_surface *blit_surf = dst_surfaces[2 * k + field]; - struct pipe_surface *dst_surf = dst_surfaces[2 * k + 1 - field]; + for (i = 0, j = 0; i < VL_NUM_COMPONENTS; ++i) { + struct pipe_surface *blit_surf = dst_surfaces[field]; + struct pipe_surface *dst_surf = dst_surfaces[1 - field]; + int k = plane_order[i]; + + /* bind blend state for this component in the plane */ + filter->pipe->bind_blend_state(filter->pipe, filter->blend[j]); /* update render target state */ viewport.scale[0] = blit_surf->texture->width0; @@ -463,10 +491,10 @@ vl_deint_filter_render(struct vl_deint_filter *filter, fb_state.height = blit_surf->texture->height0; /* update sampler view sources */ - sampler_views[0] = prevprev_sv[j]; - sampler_views[1] = prev_sv[j]; - sampler_views[2] = cur_sv[j]; - sampler_views[3] = next_sv[j]; + sampler_views[0] = prevprev_sv[k]; + sampler_views[1] = prev_sv[k]; + sampler_views[2] = cur_sv[k]; + sampler_views[3] = next_sv[k]; filter->pipe->set_sampler_views(filter->pipe, PIPE_SHADER_FRAGMENT, 0, 4, sampler_views); /* blit current field */ @@ -479,11 +507,16 @@ vl_deint_filter_render(struct vl_deint_filter *filter, /* blit or interpolate other field */ fb_state.cbufs[0] = dst_surf; filter->pipe->set_framebuffer_state(filter->pipe, &fb_state); - if (j > 0 && filter->skip_chroma) { + if (i > 0 && filter->skip_chroma) { util_draw_arrays(filter->pipe, PIPE_PRIM_QUADS, 0, 4); } else { filter->pipe->bind_fs_state(filter->pipe, field ? filter->fs_deint_top : filter->fs_deint_bottom); util_draw_arrays(filter->pipe, PIPE_PRIM_QUADS, 0, 4); } + + if (++j >= util_format_get_nr_components(dst_surf->format)) { + dst_surfaces += 2; + j = 0; + } } } diff --git a/src/gallium/auxiliary/vl/vl_deint_filter.h b/src/gallium/auxiliary/vl/vl_deint_filter.h index 3ca378b..49cc96c 100644 --- a/src/gallium/auxiliary/vl/vl_deint_filter.h +++ b/src/gallium/auxiliary/vl/vl_deint_filter.h @@ -38,7 +38,7 @@ struct vl_deint_filter struct pipe_vertex_buffer quad; void *rs_state; - void *blend; + void *blend[3]; void *sampler[4]; void *ves; void *vs; diff --git a/src/gallium/auxiliary/vl/vl_video_buffer.c b/src/gallium/auxiliary/vl/vl_video_buffer.c index e8cd24d..462fdcb 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 488c3cc..8a1c077 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 */ |