Mercurial > mplayer.hg
comparison vidix/vidix.c @ 27080:724a953b5179
renamed vidixlib.c to vidix.c
author | ben |
---|---|
date | Fri, 20 Jun 2008 20:17:38 +0000 |
parents | vidix/vidixlib.c@df448e1248b2 |
children | 35039052457d |
comparison
equal
deleted
inserted
replaced
27079:df448e1248b2 | 27080:724a953b5179 |
---|---|
1 /* | |
2 * VIDIX - VIDeo Interface for *niX. | |
3 * | |
4 * This interface is introduced as universal one to MPEG decoder, | |
5 * Back End Scaler (BES) and YUV2RGB hw accelerators. | |
6 * | |
7 * In the future it may be expanded up to capturing and audio things. | |
8 * Main goal of this this interface imlpementation is providing DGA | |
9 * everywhere where it's possible (unlike X11 and other). | |
10 * | |
11 * This interface is based on v4l2, fbvid.h, mga_vid.h projects | |
12 * and personally my ideas. | |
13 * | |
14 * NOTE: This interface is introduced as driver interface. | |
15 * | |
16 * Copyright (C) 2002 Nick Kurshev | |
17 * Copyright (C) 2007 Benjamin Zores <ben@geexbox.org> | |
18 * | |
19 * This file is part of MPlayer. | |
20 * | |
21 * MPlayer is free software; you can redistribute it and/or modify | |
22 * it under the terms of the GNU General Public License as published by | |
23 * the Free Software Foundation; either version 2 of the License, or | |
24 * (at your option) any later version. | |
25 * | |
26 * MPlayer is distributed in the hope that it will be useful, | |
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
29 * GNU General Public License for more details. | |
30 * | |
31 * You should have received a copy of the GNU General Public License along | |
32 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
33 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
34 */ | |
35 | |
36 #include <stdlib.h> | |
37 #include <stdio.h> | |
38 #include <errno.h> | |
39 #include <string.h> | |
40 | |
41 #include "config.h" | |
42 #include "vidix.h" | |
43 #include "drivers.h" | |
44 #include "libavutil/common.h" | |
45 #include "mpbswap.h" | |
46 | |
47 VDL_HANDLE vdlOpen(const char *name,unsigned cap,int verbose) | |
48 { | |
49 VDXContext *ctx; | |
50 | |
51 if (!(ctx = malloc (sizeof (VDXContext)))) | |
52 return NULL; | |
53 memset (ctx, 0, sizeof (VDXContext)); | |
54 | |
55 /* register all drivers */ | |
56 vidix_register_all_drivers (); | |
57 | |
58 if (!vidix_find_driver (ctx, name, cap, verbose)) | |
59 { | |
60 free (ctx); | |
61 return NULL; | |
62 } | |
63 | |
64 if (verbose) | |
65 printf ("vidixlib: will use %s driver\n", ctx->drv->name); | |
66 | |
67 if (!ctx->drv || !ctx->drv->init) | |
68 { | |
69 if (verbose) | |
70 printf ("vidixlib: Can't init driver\n"); | |
71 free (ctx); | |
72 return NULL; | |
73 } | |
74 | |
75 if (verbose) | |
76 printf ("vidixlib: Attempt to initialize driver at: %p\n", | |
77 ctx->drv->init); | |
78 | |
79 if (ctx->drv->init () !=0) | |
80 { | |
81 if (verbose) | |
82 printf ("vidixlib: Can't init driver\n"); | |
83 free (ctx); | |
84 return NULL; | |
85 } | |
86 | |
87 if (verbose) | |
88 printf("vidixlib: '%s'successfully loaded\n", ctx->drv->name); | |
89 | |
90 return ctx; | |
91 } | |
92 | |
93 void vdlClose(VDL_HANDLE ctx) | |
94 { | |
95 if (ctx->drv->destroy) | |
96 ctx->drv->destroy (); | |
97 | |
98 memset (ctx, 0, sizeof (VDXContext)); /* <- it's not stupid */ | |
99 free (ctx); | |
100 } | |
101 | |
102 int vdlGetCapability(VDL_HANDLE ctx, vidix_capability_t *cap) | |
103 { | |
104 return ctx->drv->get_caps (cap); | |
105 } | |
106 | |
107 #define MPLAYER_IMGFMT_RGB (('R'<<24)|('G'<<16)|('B'<<8)) | |
108 #define MPLAYER_IMGFMT_BGR (('B'<<24)|('G'<<16)|('R'<<8)) | |
109 #define MPLAYER_IMGFMT_RGB_MASK 0xFFFFFF00 | |
110 | |
111 static uint32_t normalize_fourcc(uint32_t fourcc) | |
112 { | |
113 if((fourcc & MPLAYER_IMGFMT_RGB_MASK) == (MPLAYER_IMGFMT_RGB|0) || | |
114 (fourcc & MPLAYER_IMGFMT_RGB_MASK) == (MPLAYER_IMGFMT_BGR|0)) | |
115 return bswap_32(fourcc); | |
116 else return fourcc; | |
117 } | |
118 | |
119 int vdlQueryFourcc(VDL_HANDLE ctx,vidix_fourcc_t *f) | |
120 { | |
121 f->fourcc = normalize_fourcc(f->fourcc); | |
122 return ctx->drv->query_fourcc (f); | |
123 } | |
124 | |
125 int vdlConfigPlayback(VDL_HANDLE ctx,vidix_playback_t *p) | |
126 { | |
127 p->fourcc = normalize_fourcc(p->fourcc); | |
128 return ctx->drv->config_playback (p); | |
129 } | |
130 | |
131 int vdlPlaybackOn(VDL_HANDLE ctx) | |
132 { | |
133 return ctx->drv->playback_on (); | |
134 } | |
135 | |
136 int vdlPlaybackOff(VDL_HANDLE ctx) | |
137 { | |
138 return ctx->drv->playback_off (); | |
139 } | |
140 | |
141 int vdlPlaybackFrameSelect(VDL_HANDLE ctx, unsigned frame_idx ) | |
142 { | |
143 return ctx->drv->frame_sel ? ctx->drv->frame_sel (frame_idx) : ENOSYS; | |
144 } | |
145 | |
146 int vdlPlaybackGetEq(VDL_HANDLE ctx, vidix_video_eq_t * e) | |
147 { | |
148 return ctx->drv->get_eq ? ctx->drv->get_eq (e) : ENOSYS; | |
149 } | |
150 | |
151 int vdlPlaybackSetEq(VDL_HANDLE ctx, const vidix_video_eq_t * e) | |
152 { | |
153 return ctx->drv->set_eq ? ctx->drv->set_eq (e) : ENOSYS; | |
154 } | |
155 | |
156 int vdlPlaybackCopyFrame(VDL_HANDLE ctx, const vidix_dma_t * f) | |
157 { | |
158 return ctx->drv->copy_frame ? ctx->drv->copy_frame (f) : ENOSYS; | |
159 } | |
160 | |
161 int vdlGetGrKeys(VDL_HANDLE ctx, vidix_grkey_t * k) | |
162 { | |
163 return ctx->drv->get_gkey ? ctx->drv->get_gkey (k) : ENOSYS; | |
164 } | |
165 | |
166 int vdlSetGrKeys(VDL_HANDLE ctx, const vidix_grkey_t * k) | |
167 { | |
168 return ctx->drv->set_gkey ? ctx->drv->set_gkey (k) : ENOSYS; | |
169 } | |
170 | |
171 int vdlPlaybackGetDeint(VDL_HANDLE ctx, vidix_deinterlace_t * d) | |
172 { | |
173 return ctx->drv->get_deint ? ctx->drv->get_deint (d) : ENOSYS; | |
174 } | |
175 | |
176 int vdlPlaybackSetDeint(VDL_HANDLE ctx, const vidix_deinterlace_t * d) | |
177 { | |
178 return ctx->drv->set_deint ? ctx->drv->set_deint (d) : ENOSYS; | |
179 } | |
180 | |
181 int vdlQueryNumOemEffects(VDL_HANDLE ctx, unsigned * number ) | |
182 { | |
183 return ctx->drv->get_num_fx ? ctx->drv->get_num_fx (number) : ENOSYS; | |
184 } | |
185 | |
186 int vdlGetOemEffect(VDL_HANDLE ctx, vidix_oem_fx_t * f) | |
187 { | |
188 return ctx->drv->get_fx ? ctx->drv->get_fx (f) : ENOSYS; | |
189 } | |
190 | |
191 int vdlSetOemEffect(VDL_HANDLE ctx, const vidix_oem_fx_t * f) | |
192 { | |
193 return ctx->drv->set_fx ? ctx->drv->set_fx (f) : ENOSYS; | |
194 } |