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