Merge branch 'gallium-polygon-stipple'
[mesa.git] / src / gallium / state_trackers / xorg / xvmc / xvmc_private.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 xvmc_private_h
29 #define xvmc_private_h
30
31 #include <X11/Xlib.h>
32 #include <X11/extensions/XvMClib.h>
33
34 #include <pipe/p_video_state.h>
35
36 #include <util/u_debug.h>
37 #include <util/u_math.h>
38
39 #include <vl/vl_csc.h>
40 #include <vl/vl_compositor.h>
41
42 #define BLOCK_SIZE_SAMPLES 64
43 #define BLOCK_SIZE_BYTES (BLOCK_SIZE_SAMPLES * 2)
44
45 struct vl_context;
46
47 struct pipe_video_decoder;
48 struct pipe_video_decode_buffer;
49 struct pipe_video_buffer;
50
51 struct pipe_sampler_view;
52 struct pipe_fence_handle;
53
54 typedef struct
55 {
56 struct vl_context *vctx;
57 struct pipe_video_decoder *decoder;
58
59 enum VL_CSC_COLOR_STANDARD color_standard;
60 struct vl_procamp procamp;
61 struct vl_compositor compositor;
62
63 unsigned short subpicture_max_width;
64 unsigned short subpicture_max_height;
65
66 struct pipe_video_rect dst_rect;
67 struct pipe_surface *drawable_surface;
68
69 } XvMCContextPrivate;
70
71 typedef struct
72 {
73 struct pipe_video_decode_buffer *decode_buffer;
74 struct pipe_video_buffer *video_buffer;
75
76 bool mapped; // are we still mapped to memory?
77
78 struct {
79 unsigned num_blocks_added;
80 struct pipe_ycbcr_block *stream;
81 short *buffer;
82 } ycbcr[3];
83
84 unsigned mv_stride;
85 struct {
86 XvMCSurface *surface;
87 struct pipe_motionvector *mv;
88 } ref[2];
89
90 struct pipe_fence_handle *fence;
91
92 /* The subpicture associated with this surface, if any. */
93 XvMCSubpicture *subpicture;
94
95 /* Some XvMC functions take a surface but not a context,
96 so we keep track of which context each surface belongs to. */
97 XvMCContext *context;
98 } XvMCSurfacePrivate;
99
100 typedef struct
101 {
102 struct pipe_sampler_view *sampler;
103
104 /* optional palette for this subpicture */
105 struct pipe_sampler_view *palette;
106
107 struct pipe_video_rect src_rect;
108 struct pipe_video_rect dst_rect;
109
110 /* The surface this subpicture is currently associated with, if any. */
111 XvMCSurface *surface;
112
113 /* Some XvMC functions take a subpicture but not a context,
114 so we keep track of which context each subpicture belongs to. */
115 XvMCContext *context;
116 } XvMCSubpicturePrivate;
117
118 #define XVMC_OUT 0
119 #define XVMC_ERR 1
120 #define XVMC_WARN 2
121 #define XVMC_TRACE 3
122
123 static INLINE void XVMC_MSG(unsigned int level, const char *fmt, ...)
124 {
125 static int debug_level = -1;
126
127 if (debug_level == -1) {
128 debug_level = MAX2(debug_get_num_option("XVMC_DEBUG", 0), 0);
129 }
130
131 if (level <= debug_level) {
132 va_list ap;
133 va_start(ap, fmt);
134 _debug_vprintf(fmt, ap);
135 va_end(ap);
136 }
137 }
138
139 #endif /* xvmc_private_h */