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