Mercurial > mplayer.hg
annotate vidix/vidixlib.c @ 22993:5e6fa9cabacc
big surprise.. uau broke gcc 2.95 as usual
author | rfelker |
---|---|
date | Tue, 17 Apr 2007 07:06:44 +0000 |
parents | f34e5d778267 |
children | 82216ef041e0 |
rev | line source |
---|---|
3991 | 1 /* |
2 * vidixlib.c | |
3 * VIDIXLib - Library for VIDeo Interface for *niX | |
4 * This interface is introduced as universal one to MPEG decoder, | |
5 * BES == Back End Scaler and YUV2RGB hw accelerators. | |
6 * In the future it may be expanded up to capturing and audio things. | |
7 * Main goal of this this interface imlpementation is providing DGA | |
8 * everywhere where it's possible (unlike X11 and other). | |
22902 | 9 * Copyright 2002 Nick Kurshev, 2007 Benjamin Zores |
3991 | 10 * Licence: GPL |
11 * This interface is based on v4l2, fbvid.h, mga_vid.h projects | |
12 * and personally my ideas. | |
13 * NOTE: This interface is introduces as APP interface. | |
14 * Don't use it for driver. | |
15 * It provides multistreaming. This mean that APP can handle | |
16 * several streams simultaneously. (Example: Video capturing and video | |
17 * playback or capturing, video playback, audio encoding and so on). | |
18 */ | |
19 #include <stdlib.h> | |
20 #include <stdio.h> | |
21 #include <errno.h> | |
22 #include <string.h> | |
23 | |
24 #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
|
25 #include "drivers.h" |
22905 | 26 #include "config.h" |
27 #include "libavutil/common.h" | |
28 #include "mpbswap.h" | |
3991 | 29 |
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
|
30 extern unsigned int vdlGetVersion( void ) |
3991 | 31 { |
32 return VIDIX_VERSION; | |
33 } | |
34 | |
3995 | 35 VDL_HANDLE vdlOpen(const char *path,const char *name,unsigned cap,int verbose) |
3991 | 36 { |
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
|
37 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
|
38 |
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
|
39 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
|
40 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
|
41 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
|
42 |
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
|
43 /* 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
|
44 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
|
45 |
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 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
|
47 { |
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
|
48 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
|
49 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
|
50 } |
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
|
51 |
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
|
52 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
|
53 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
|
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->drv || !ctx->drv->init) |
3991 | 56 { |
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
|
57 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
|
58 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
|
59 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
|
60 return NULL; |
3991 | 61 } |
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
|
62 |
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 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
|
64 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
|
65 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
|
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 if (ctx->drv->init () !=0) |
4011 | 68 { |
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
|
69 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
|
70 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
|
71 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
|
72 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
|
73 } |
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 |
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 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
|
76 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
|
77 |
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 return ctx; |
3991 | 79 } |
80 | |
22865
441582f3ed87
simplified function prototypes to avoid casts but keep external API compatibility
ben
parents:
22857
diff
changeset
|
81 void vdlClose(VDL_HANDLE ctx) |
3991 | 82 { |
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
|
83 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
|
84 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
|
85 |
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 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
|
87 free (ctx); |
3991 | 88 } |
89 | |
22865
441582f3ed87
simplified function prototypes to avoid casts but keep external API compatibility
ben
parents:
22857
diff
changeset
|
90 int vdlGetCapability(VDL_HANDLE ctx, vidix_capability_t *cap) |
3991 | 91 { |
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
|
92 return ctx->drv->get_caps (cap); |
3991 | 93 } |
94 | |
4539 | 95 #define MPLAYER_IMGFMT_RGB (('R'<<24)|('G'<<16)|('B'<<8)) |
96 #define MPLAYER_IMGFMT_BGR (('B'<<24)|('G'<<16)|('R'<<8)) | |
97 #define MPLAYER_IMGFMT_RGB_MASK 0xFFFFFF00 | |
98 | |
4547 | 99 static uint32_t normalize_fourcc(uint32_t fourcc) |
4539 | 100 { |
101 if((fourcc & MPLAYER_IMGFMT_RGB_MASK) == (MPLAYER_IMGFMT_RGB|0) || | |
102 (fourcc & MPLAYER_IMGFMT_RGB_MASK) == (MPLAYER_IMGFMT_BGR|0)) | |
103 return bswap_32(fourcc); | |
104 else return fourcc; | |
105 } | |
106 | |
22865
441582f3ed87
simplified function prototypes to avoid casts but keep external API compatibility
ben
parents:
22857
diff
changeset
|
107 int vdlQueryFourcc(VDL_HANDLE ctx,vidix_fourcc_t *f) |
3991 | 108 { |
4547 | 109 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
|
110 return ctx->drv->query_fourcc (f); |
3991 | 111 } |
112 | |
22865
441582f3ed87
simplified function prototypes to avoid casts but keep external API compatibility
ben
parents:
22857
diff
changeset
|
113 int vdlConfigPlayback(VDL_HANDLE ctx,vidix_playback_t *p) |
3991 | 114 { |
4547 | 115 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
|
116 return ctx->drv->config_playback (p); |
3991 | 117 } |
118 | |
22865
441582f3ed87
simplified function prototypes to avoid casts but keep external API compatibility
ben
parents:
22857
diff
changeset
|
119 int vdlPlaybackOn(VDL_HANDLE ctx) |
3991 | 120 { |
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
|
121 return ctx->drv->playback_on (); |
3991 | 122 } |
123 | |
22865
441582f3ed87
simplified function prototypes to avoid casts but keep external API compatibility
ben
parents:
22857
diff
changeset
|
124 int vdlPlaybackOff(VDL_HANDLE ctx) |
3991 | 125 { |
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->playback_off (); |
3991 | 127 } |
128 | |
22865
441582f3ed87
simplified function prototypes to avoid casts but keep external API compatibility
ben
parents:
22857
diff
changeset
|
129 int vdlPlaybackFrameSelect(VDL_HANDLE ctx, unsigned frame_idx ) |
3991 | 130 { |
22885 | 131 return ctx->drv->frame_sel ? ctx->drv->frame_sel (frame_idx) : ENOSYS; |
3991 | 132 } |
133 | |
22865
441582f3ed87
simplified function prototypes to avoid casts but keep external API compatibility
ben
parents:
22857
diff
changeset
|
134 int vdlPlaybackGetEq(VDL_HANDLE ctx, vidix_video_eq_t * e) |
3991 | 135 { |
22885 | 136 return ctx->drv->get_eq ? ctx->drv->get_eq (e) : ENOSYS; |
3991 | 137 } |
138 | |
22865
441582f3ed87
simplified function prototypes to avoid casts but keep external API compatibility
ben
parents:
22857
diff
changeset
|
139 int vdlPlaybackSetEq(VDL_HANDLE ctx, const vidix_video_eq_t * e) |
3991 | 140 { |
22885 | 141 return ctx->drv->set_eq ? ctx->drv->set_eq (e) : ENOSYS; |
3991 | 142 } |
143 | |
22865
441582f3ed87
simplified function prototypes to avoid casts but keep external API compatibility
ben
parents:
22857
diff
changeset
|
144 int vdlPlaybackCopyFrame(VDL_HANDLE ctx, const vidix_dma_t * f) |
3991 | 145 { |
22885 | 146 return ctx->drv->copy_frame ? ctx->drv->copy_frame (f) : ENOSYS; |
3991 | 147 } |
4070
b61ba6c256dd
Minor interface changes: color and video keys are moved out from playback configuring
nick
parents:
4011
diff
changeset
|
148 |
22865
441582f3ed87
simplified function prototypes to avoid casts but keep external API compatibility
ben
parents:
22857
diff
changeset
|
149 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
|
150 { |
22885 | 151 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
|
152 } |
b61ba6c256dd
Minor interface changes: color and video keys are moved out from playback configuring
nick
parents:
4011
diff
changeset
|
153 |
22865
441582f3ed87
simplified function prototypes to avoid casts but keep external API compatibility
ben
parents:
22857
diff
changeset
|
154 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
|
155 { |
22885 | 156 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
|
157 } |
4191 | 158 |
22865
441582f3ed87
simplified function prototypes to avoid casts but keep external API compatibility
ben
parents:
22857
diff
changeset
|
159 int vdlPlaybackGetDeint(VDL_HANDLE ctx, vidix_deinterlace_t * d) |
4191 | 160 { |
22885 | 161 return ctx->drv->get_deint ? ctx->drv->get_deint (d) : ENOSYS; |
4191 | 162 } |
163 | |
22865
441582f3ed87
simplified function prototypes to avoid casts but keep external API compatibility
ben
parents:
22857
diff
changeset
|
164 int vdlPlaybackSetDeint(VDL_HANDLE ctx, const vidix_deinterlace_t * d) |
4191 | 165 { |
22885 | 166 return ctx->drv->set_deint ? ctx->drv->set_deint (d) : ENOSYS; |
4191 | 167 } |
168 | |
22865
441582f3ed87
simplified function prototypes to avoid casts but keep external API compatibility
ben
parents:
22857
diff
changeset
|
169 int vdlQueryNumOemEffects(VDL_HANDLE ctx, unsigned * number ) |
4191 | 170 { |
22885 | 171 return ctx->drv->get_num_fx ? ctx->drv->get_num_fx (number) : ENOSYS; |
4191 | 172 } |
173 | |
22865
441582f3ed87
simplified function prototypes to avoid casts but keep external API compatibility
ben
parents:
22857
diff
changeset
|
174 int vdlGetOemEffect(VDL_HANDLE ctx, vidix_oem_fx_t * f) |
4191 | 175 { |
22885 | 176 return ctx->drv->get_fx ? ctx->drv->get_fx (f) : ENOSYS; |
4191 | 177 } |
178 | |
22865
441582f3ed87
simplified function prototypes to avoid casts but keep external API compatibility
ben
parents:
22857
diff
changeset
|
179 int vdlSetOemEffect(VDL_HANDLE ctx, const vidix_oem_fx_t * f) |
4191 | 180 { |
22885 | 181 return ctx->drv->set_fx ? ctx->drv->set_fx (f) : ENOSYS; |
4191 | 182 } |