Merge remote branch 'origin/master' into pipe-video
[mesa.git] / src / gallium / auxiliary / vl / vl_mpeg12_mc_renderer.h
1 /**************************************************************************
2 *
3 * Copyright 2009 Younes Manton.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 #ifndef vl_mpeg12_mc_renderer_h
29 #define vl_mpeg12_mc_renderer_h
30
31 #include <pipe/p_compiler.h>
32 #include <pipe/p_state.h>
33 #include <pipe/p_video_state.h>
34 #include "vl_types.h"
35 #include "vl_idct.h"
36 #include "vl_vertex_buffers.h"
37
38 struct pipe_context;
39 struct pipe_macroblock;
40 struct keymap;
41
42 /* A slice is video-width (rounded up to a multiple of macroblock width) x macroblock height */
43 enum VL_MPEG12_MC_RENDERER_BUFFER_MODE
44 {
45 VL_MPEG12_MC_RENDERER_BUFFER_SLICE, /* Saves memory at the cost of smaller batches */
46 VL_MPEG12_MC_RENDERER_BUFFER_PICTURE /* Larger batches, more memory */
47 };
48
49 struct vl_mpeg12_mc_renderer
50 {
51 struct pipe_context *pipe;
52 unsigned buffer_width;
53 unsigned buffer_height;
54 enum pipe_video_chroma_format chroma_format;
55 const unsigned (*empty_block_mask)[3][2][2];
56 enum VL_MPEG12_MC_RENDERER_BUFFER_MODE bufmode;
57 unsigned macroblocks_per_batch;
58
59 unsigned vertex_stream_stride;
60
61 struct pipe_viewport_state viewport;
62 struct pipe_framebuffer_state fb_state;
63
64 struct vl_idct idct_luma, idct_chroma;
65
66 void *vertex_elems_state;
67 void *rs_state;
68
69 void *vs, *fs;
70
71 struct pipe_vertex_buffer quad;
72
73 union
74 {
75 void *all[5];
76 struct { void *y, *cb, *cr, *ref[2]; } individual;
77 } samplers;
78
79 struct keymap *texview_map;
80 };
81
82 struct vl_mpeg12_mc_buffer
83 {
84 struct vl_idct_buffer idct_y, idct_cb, idct_cr;
85
86 struct vl_vertex_buffer vertex_stream;
87
88 union
89 {
90 struct pipe_sampler_view *all[5];
91 struct { struct pipe_sampler_view *y, *cb, *cr, *ref[2]; } individual;
92 } sampler_views;
93
94 union
95 {
96 struct pipe_resource *all[5];
97 struct { struct pipe_resource *y, *cb, *cr, *ref[2]; } individual;
98 } textures;
99
100 union
101 {
102 struct pipe_vertex_buffer all[2];
103 struct {
104 struct pipe_vertex_buffer quad, stream;
105 } individual;
106 } vertex_bufs;
107
108 struct pipe_surface *surface, *past, *future;
109 struct pipe_fence_handle **fence;
110 unsigned num_macroblocks;
111 };
112
113 bool vl_mpeg12_mc_renderer_init(struct vl_mpeg12_mc_renderer *renderer,
114 struct pipe_context *pipe,
115 unsigned picture_width,
116 unsigned picture_height,
117 enum pipe_video_chroma_format chroma_format,
118 enum VL_MPEG12_MC_RENDERER_BUFFER_MODE bufmode);
119
120 void vl_mpeg12_mc_renderer_cleanup(struct vl_mpeg12_mc_renderer *renderer);
121
122 bool vl_mpeg12_mc_init_buffer(struct vl_mpeg12_mc_renderer *renderer, struct vl_mpeg12_mc_buffer *buffer);
123
124 void vl_mpeg12_mc_cleanup_buffer(struct vl_mpeg12_mc_renderer *renderer, struct vl_mpeg12_mc_buffer *buffer);
125
126 void vl_mpeg12_mc_map_buffer(struct vl_mpeg12_mc_renderer *renderer, struct vl_mpeg12_mc_buffer *buffer);
127
128 void vl_mpeg12_mc_renderer_render_macroblocks(struct vl_mpeg12_mc_renderer *renderer,
129 struct vl_mpeg12_mc_buffer *buffer,
130 struct pipe_surface *surface,
131 struct pipe_surface *past,
132 struct pipe_surface *future,
133 unsigned num_macroblocks,
134 struct pipe_mpeg12_macroblock *mpeg12_macroblocks,
135 struct pipe_fence_handle **fence);
136
137 void vl_mpeg12_mc_unmap_buffer(struct vl_mpeg12_mc_renderer *renderer, struct vl_mpeg12_mc_buffer *buffer);
138
139 void vl_mpeg12_mc_renderer_flush(struct vl_mpeg12_mc_renderer *renderer, struct vl_mpeg12_mc_buffer *buffer);
140
141 #endif /* vl_mpeg12_mc_renderer_h */