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 pipe_video_decoder;
46 struct pipe_video_buffer;
47
48 struct pipe_sampler_view;
49 struct pipe_fence_handle;
50
51 typedef struct
52 {
53 struct vl_screen *vscreen;
54 struct pipe_context *pipe;
55 struct pipe_video_decoder *decoder;
56
57 enum VL_CSC_COLOR_STANDARD color_standard;
58 struct vl_procamp procamp;
59 struct vl_compositor compositor;
60 struct vl_compositor_state cstate;
61
62 unsigned short subpicture_max_width;
63 unsigned short subpicture_max_height;
64
65 } XvMCContextPrivate;
66
67 typedef struct
68 {
69 struct pipe_video_buffer *video_buffer;
70
71 /* nonzero if this picture is already being decoded */
72 int picture_structure;
73
74 XvMCSurface *ref[2];
75
76 struct pipe_fence_handle *fence;
77
78 /* The subpicture associated with this surface, if any. */
79 XvMCSubpicture *subpicture;
80
81 /* Some XvMC functions take a surface but not a context,
82 so we keep track of which context each surface belongs to. */
83 XvMCContext *context;
84 } XvMCSurfacePrivate;
85
86 typedef struct
87 {
88 struct pipe_sampler_view *sampler;
89
90 /* optional palette for this subpicture */
91 struct pipe_sampler_view *palette;
92
93 struct u_rect src_rect;
94 struct u_rect dst_rect;
95
96 /* The surface this subpicture is currently associated with, if any. */
97 XvMCSurface *surface;
98
99 /* Some XvMC functions take a subpicture but not a context,
100 so we keep track of which context each subpicture belongs to. */
101 XvMCContext *context;
102 } XvMCSubpicturePrivate;
103
104 #define XVMC_OUT 0
105 #define XVMC_ERR 1
106 #define XVMC_WARN 2
107 #define XVMC_TRACE 3
108
XVMC_MSG(unsigned int level,const char * fmt,...)109 static INLINE void XVMC_MSG(unsigned int level, const char *fmt, ...)
110 {
111 static int debug_level = -1;
112
113 if (debug_level == -1) {
114 debug_level = MAX2(debug_get_num_option("XVMC_DEBUG", 0), 0);
115 }
116
117 if (level <= debug_level) {
118 va_list ap;
119 va_start(ap, fmt);
120 _debug_vprintf(fmt, ap);
121 va_end(ap);
122 }
123 }
124
125 #endif /* xvmc_private_h */
126