2 * VIDIX - VIDeo Interface for *niX.
4 * This interface is introduced as universal one to MPEG decoder,
5 * Back End Scaler (BES) and YUV2RGB hw accelerators.
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).
11 * This interface is based on v4l2, fbvid.h, mga_vid.h projects
12 * and personally my ideas.
14 * NOTE: This interface is introduced as driver interface.
16 * Copyright (C) 2002 Nick Kurshev
17 * Copyright (C) 2007 Benjamin Zores <ben@geexbox.org>
19 * This file is part of MPlayer.
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.
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.
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.
44 #include "libavutil/common.h"
47 VDXContext
*vdlOpen(const char *name
,unsigned cap
,int verbose
)
51 if (!(ctx
= malloc (sizeof (VDXContext
))))
53 memset (ctx
, 0, sizeof (VDXContext
));
55 /* register all drivers */
56 vidix_register_all_drivers ();
58 if (!vidix_find_driver (ctx
, name
, cap
, verbose
))
65 printf ("vidixlib: will use %s driver\n", ctx
->drv
->name
);
67 if (!ctx
->drv
|| !ctx
->drv
->init
)
70 printf ("vidixlib: Can't init driver\n");
76 printf ("vidixlib: Attempt to initialize driver at: %p\n",
79 if (ctx
->drv
->init () !=0)
82 printf ("vidixlib: Can't init driver\n");
88 printf("vidixlib: '%s'successfully loaded\n", ctx
->drv
->name
);
93 void vdlClose(VDXContext
*ctx
)
95 if (ctx
->drv
->destroy
)
98 memset (ctx
, 0, sizeof (VDXContext
)); /* <- it's not stupid */
102 int vdlGetCapability(VDXContext
*ctx
, vidix_capability_t
*cap
)
104 return ctx
->drv
->get_caps (cap
);
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
111 static uint32_t normalize_fourcc (uint32_t fourcc
)
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
);
119 int vdlQueryFourcc (VDXContext
*ctx
, vidix_fourcc_t
*f
)
121 f
->fourcc
= normalize_fourcc(f
->fourcc
);
122 return ctx
->drv
->query_fourcc (f
);
125 int vdlConfigPlayback (VDXContext
*ctx
, vidix_playback_t
*p
)
127 p
->fourcc
= normalize_fourcc(p
->fourcc
);
128 return ctx
->drv
->config_playback (p
);
131 int vdlPlaybackOn (VDXContext
*ctx
)
133 return ctx
->drv
->playback_on ();
136 int vdlPlaybackOff (VDXContext
*ctx
)
138 return ctx
->drv
->playback_off ();
141 int vdlPlaybackFrameSelect (VDXContext
*ctx
, unsigned frame_idx
)
143 return ctx
->drv
->frame_sel
? ctx
->drv
->frame_sel (frame_idx
) : ENOSYS
;
146 int vdlPlaybackGetEq (VDXContext
*ctx
, vidix_video_eq_t
*e
)
148 return ctx
->drv
->get_eq
? ctx
->drv
->get_eq (e
) : ENOSYS
;
151 int vdlPlaybackSetEq (VDXContext
*ctx
, const vidix_video_eq_t
*e
)
153 return ctx
->drv
->set_eq
? ctx
->drv
->set_eq (e
) : ENOSYS
;
156 int vdlGetGrKeys (VDXContext
*ctx
, vidix_grkey_t
*k
)
158 return ctx
->drv
->get_gkey
? ctx
->drv
->get_gkey (k
) : ENOSYS
;
161 int vdlSetGrKeys (VDXContext
*ctx
, const vidix_grkey_t
*k
)
163 return ctx
->drv
->set_gkey
? ctx
->drv
->set_gkey (k
) : ENOSYS
;
166 int vdlPlaybackGetDeint (VDXContext
*ctx
, vidix_deinterlace_t
*d
)
168 return ctx
->drv
->get_deint
? ctx
->drv
->get_deint (d
) : ENOSYS
;
171 int vdlPlaybackSetDeint (VDXContext
*ctx
, const vidix_deinterlace_t
*d
)
173 return ctx
->drv
->set_deint
? ctx
->drv
->set_deint (d
) : ENOSYS
;