~ubuntu-dev/mplayer/ubuntu-feisty

« back to all changes in this revision

Viewing changes to libvo/video_out.c

  • Committer: Reinhard Tartler
  • Date: 2006-07-08 08:45:33 UTC
  • Revision ID: siretart@tauware.de-20060708084533-dbc155bde7122e78
imported mplayer_0.99+1.0pre7try2+cvs20060117

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/* this file contains libvo's common functions, variables used by 
 
3
   many/all drivers. */
 
4
 
 
5
#include <stdio.h>
 
6
#include <stdlib.h>
 
7
#include <string.h>
 
8
 
 
9
#include <unistd.h>
 
10
//#include <sys/mman.h>
 
11
 
 
12
#include "config.h"
 
13
#include "video_out.h"
 
14
 
 
15
#include "mp_msg.h"
 
16
#include "help_mp.h"
 
17
 
 
18
#include "osdep/shmem.h"
 
19
 
 
20
//int vo_flags=0;
 
21
 
 
22
// currect resolution/bpp on screen:  (should be autodetected by vo_init())
 
23
int vo_depthonscreen=0;
 
24
int vo_screenwidth=0;
 
25
int vo_screenheight=0;
 
26
 
 
27
int vo_config_count=0;
 
28
 
 
29
// requested resolution/bpp:  (-x -y -bpp options)
 
30
int vo_dx=0;
 
31
int vo_dy=0;
 
32
int vo_dwidth=0;
 
33
int vo_dheight=0;
 
34
int vo_dbpp=0;
 
35
 
 
36
int vo_nomouse_input = 0;
 
37
int vo_grabpointer = 1;
 
38
int vo_doublebuffering = 1;
 
39
int vo_vsync = 0;
 
40
int vo_fs = 0;
 
41
int vo_fsmode = 0;
 
42
float vo_panscan = 0.0f;
 
43
int vo_ontop = 0;
 
44
int vo_adapter_num=0;
 
45
int vo_refresh_rate=0;
 
46
int vo_keepaspect=1;
 
47
int vo_rootwin=0;
 
48
int vo_border=1;
 
49
int WinID = -1;
 
50
 
 
51
int vo_pts=0; // for hw decoding
 
52
float vo_fps=0; // for mp1e rte
 
53
 
 
54
char *vo_subdevice = NULL;
 
55
int vo_directrendering=0;
 
56
 
 
57
int vo_colorkey = 0x0000ff00; // default colorkey is green
 
58
                              // (0xff000000 means that colorkey has been disabled)
 
59
 
 
60
//
 
61
// Externally visible list of all vo drivers
 
62
//
 
63
extern vo_functions_t video_out_mga;
 
64
extern vo_functions_t video_out_xmga;
 
65
extern vo_functions_t video_out_x11;
 
66
extern vo_functions_t video_out_xover;
 
67
extern vo_functions_t video_out_xvmc;
 
68
extern vo_functions_t video_out_xv;
 
69
extern vo_functions_t video_out_gl;
 
70
extern vo_functions_t video_out_gl2;
 
71
extern vo_functions_t video_out_dga;
 
72
extern vo_functions_t video_out_fsdga;
 
73
extern vo_functions_t video_out_sdl;
 
74
extern vo_functions_t video_out_3dfx;
 
75
extern vo_functions_t video_out_tdfxfb;
 
76
extern vo_functions_t video_out_null;
 
77
//extern vo_functions_t video_out_odivx;
 
78
extern vo_functions_t video_out_zr;
 
79
extern vo_functions_t video_out_zr2;
 
80
extern vo_functions_t video_out_bl;
 
81
extern vo_functions_t video_out_syncfb;
 
82
extern vo_functions_t video_out_fbdev;
 
83
extern vo_functions_t video_out_fbdev2;
 
84
extern vo_functions_t video_out_svga;
 
85
extern vo_functions_t video_out_png;
 
86
extern vo_functions_t video_out_ggi;
 
87
extern vo_functions_t video_out_aa;
 
88
extern vo_functions_t video_out_caca;
 
89
extern vo_functions_t video_out_mpegpes;
 
90
extern vo_functions_t video_out_yuv4mpeg;
 
91
#ifdef HAVE_DIRECTX
 
92
extern vo_functions_t video_out_directx;
 
93
#endif
 
94
#ifdef HAVE_DXR2
 
95
extern vo_functions_t video_out_dxr2;
 
96
#endif
 
97
extern vo_functions_t video_out_dxr3;
 
98
#ifdef HAVE_JPEG
 
99
extern vo_functions_t video_out_jpeg;
 
100
#endif
 
101
#ifdef HAVE_GIF
 
102
extern vo_functions_t video_out_gif89a;
 
103
#endif
 
104
#ifdef HAVE_VESA
 
105
extern vo_functions_t video_out_vesa;
 
106
#endif
 
107
#ifdef HAVE_DIRECTFB
 
108
extern vo_functions_t video_out_directfb;
 
109
#if DIRECTFBVERSION >= 915
 
110
extern vo_functions_t video_out_dfbmga;
 
111
#endif
 
112
#endif
 
113
#ifdef CONFIG_VIDIX
 
114
extern vo_functions_t video_out_xvidix;
 
115
extern vo_functions_t video_out_winvidix;
 
116
extern vo_functions_t video_out_cvidix;
 
117
#endif
 
118
#ifdef HAVE_TDFX_VID
 
119
extern vo_functions_t video_out_tdfx_vid;
 
120
#endif
 
121
#ifdef HAVE_TGA
 
122
extern vo_functions_t video_out_tga;
 
123
#endif
 
124
#ifdef MACOSX
 
125
#ifdef MACOSX_COREVIDEO
 
126
extern vo_functions_t video_out_macosx;
 
127
#endif
 
128
extern vo_functions_t video_out_quartz;
 
129
#endif
 
130
#ifdef HAVE_PNM
 
131
extern vo_functions_t video_out_pnm;
 
132
#endif
 
133
#ifdef HAVE_MD5SUM
 
134
extern vo_functions_t video_out_md5sum;
 
135
#endif
 
136
 
 
137
vo_functions_t* video_out_drivers[] =
 
138
{
 
139
#ifdef HAVE_TDFX_VID
 
140
        &video_out_tdfx_vid,
 
141
#endif
 
142
#ifdef HAVE_DIRECTX
 
143
        &video_out_directx,
 
144
#endif
 
145
#ifdef MACOSX
 
146
#ifdef MACOSX_COREVIDEO
 
147
        &video_out_macosx,
 
148
#endif
 
149
        &video_out_quartz,
 
150
#endif
 
151
#ifdef HAVE_XMGA
 
152
        &video_out_xmga,
 
153
#endif
 
154
#ifdef HAVE_MGA
 
155
        &video_out_mga,
 
156
#endif
 
157
#ifdef HAVE_SYNCFB
 
158
        &video_out_syncfb,
 
159
#endif
 
160
#ifdef HAVE_TDFXFB
 
161
        &video_out_tdfxfb,
 
162
#endif
 
163
#ifdef HAVE_3DFX
 
164
        &video_out_3dfx,
 
165
#endif
 
166
#ifdef HAVE_XVMC
 
167
        &video_out_xvmc,
 
168
#endif
 
169
#ifdef HAVE_XV
 
170
        &video_out_xv,
 
171
#endif
 
172
#ifdef HAVE_X11
 
173
        &video_out_x11,
 
174
        &video_out_xover,
 
175
#endif
 
176
#ifdef HAVE_GL
 
177
                &video_out_gl,
 
178
        &video_out_gl2,
 
179
#endif
 
180
#ifdef HAVE_DGA
 
181
        &video_out_dga,
 
182
//        &video_out_fsdga,
 
183
#endif
 
184
#ifdef HAVE_SDL
 
185
        &video_out_sdl,
 
186
#endif
 
187
#ifdef HAVE_GGI
 
188
        &video_out_ggi,
 
189
#endif
 
190
#ifdef HAVE_FBDEV
 
191
        &video_out_fbdev,
 
192
        &video_out_fbdev2,
 
193
#endif
 
194
#ifdef HAVE_SVGALIB
 
195
        &video_out_svga,
 
196
#endif
 
197
#ifdef HAVE_AA
 
198
        &video_out_aa,
 
199
#endif
 
200
#ifdef HAVE_CACA
 
201
        &video_out_caca,
 
202
#endif
 
203
#ifdef HAVE_DXR2
 
204
        &video_out_dxr2,
 
205
#endif
 
206
#ifdef HAVE_DXR3
 
207
        &video_out_dxr3,
 
208
#endif
 
209
#ifdef HAVE_ZR
 
210
        &video_out_zr,
 
211
        &video_out_zr2,
 
212
#endif
 
213
#ifdef HAVE_BL
 
214
        &video_out_bl,
 
215
#endif
 
216
#ifdef HAVE_VESA
 
217
        &video_out_vesa,
 
218
#endif
 
219
#ifdef HAVE_DIRECTFB
 
220
        &video_out_directfb,
 
221
#if DIRECTFBVERSION >= 915
 
222
        &video_out_dfbmga,
 
223
#endif
 
224
#endif
 
225
#ifdef CONFIG_VIDIX
 
226
#ifdef HAVE_X11
 
227
        &video_out_xvidix,
 
228
#endif
 
229
#ifdef WIN32
 
230
    &video_out_winvidix,
 
231
#endif
 
232
    &video_out_cvidix,
 
233
#endif
 
234
        &video_out_null,
 
235
        // should not be auto-selected
 
236
        &video_out_mpegpes,
 
237
        &video_out_yuv4mpeg,
 
238
#ifdef HAVE_PNG
 
239
        &video_out_png,
 
240
#endif  
 
241
#ifdef HAVE_JPEG
 
242
        &video_out_jpeg,
 
243
#endif
 
244
#ifdef HAVE_GIF
 
245
        &video_out_gif89a,
 
246
#endif
 
247
#ifdef HAVE_TGA
 
248
        &video_out_tga,
 
249
#endif
 
250
#ifdef HAVE_PNM
 
251
    &video_out_pnm,
 
252
#endif
 
253
#ifdef HAVE_MD5SUM
 
254
    &video_out_md5sum,
 
255
#endif
 
256
        NULL
 
257
};
 
258
 
 
259
void list_video_out(){
 
260
      int i=0;
 
261
      mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_AvailableVideoOutputDrivers);
 
262
      if (identify)
 
263
        mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_VIDEO_OUTPUTS\n");
 
264
      while (video_out_drivers[i]) {
 
265
        const vo_info_t *info = video_out_drivers[i++]->info;
 
266
        printf("\t%s\t%s\n", info->short_name, info->name);
 
267
      }
 
268
      printf("\n");
 
269
}
 
270
 
 
271
vo_functions_t* init_best_video_out(char** vo_list){
 
272
    int i;
 
273
    // first try the preferred drivers, with their optional subdevice param:
 
274
    if(vo_list && vo_list[0])
 
275
      while(vo_list[0][0]){
 
276
        char* vo=strdup(vo_list[0]);
 
277
        vo_subdevice=strchr(vo,':');
 
278
        if (!strcmp(vo, "pgm"))
 
279
            mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_VO_PGM_HasBeenReplaced);
 
280
        if (!strcmp(vo, "md5"))
 
281
            mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_VO_MD5_HasBeenReplaced);
 
282
        if(vo_subdevice){
 
283
            vo_subdevice[0]=0;
 
284
            ++vo_subdevice;
 
285
        }
 
286
        for(i=0;video_out_drivers[i];i++){
 
287
            vo_functions_t* video_driver=video_out_drivers[i];
 
288
            const vo_info_t *info = video_driver->info;
 
289
            if(!strcmp(info->short_name,vo)){
 
290
                // name matches, try it
 
291
                if(!video_driver->preinit(vo_subdevice))
 
292
                {
 
293
                    free(vo);
 
294
                    return video_driver; // success!
 
295
                }
 
296
            }
 
297
        }
 
298
        // continue...
 
299
        free(vo);
 
300
        ++vo_list;
 
301
        if(!(vo_list[0])) return NULL; // do NOT fallback to others
 
302
      }
 
303
    // now try the rest...
 
304
    vo_subdevice=NULL;
 
305
    for(i=0;video_out_drivers[i];i++){
 
306
        vo_functions_t* video_driver=video_out_drivers[i];
 
307
        if(!video_driver->preinit(vo_subdevice))
 
308
            return video_driver; // success!
 
309
    }
 
310
    return NULL;
 
311
}
 
312
 
 
313
 
 
314
#if defined(HAVE_FBDEV)||defined(HAVE_VESA)  
 
315
/* Borrowed from vo_fbdev.c 
 
316
Monitor ranges related functions*/
 
317
 
 
318
char *monitor_hfreq_str = NULL;
 
319
char *monitor_vfreq_str = NULL;
 
320
char *monitor_dotclock_str = NULL;
 
321
 
 
322
float range_max(range_t *r)
 
323
{
 
324
float max = 0;
 
325
 
 
326
        for (/* NOTHING */; (r->min != -1 && r->max != -1); r++)
 
327
                if (max < r->max) max = r->max;
 
328
        return max;
 
329
}
 
330
 
 
331
 
 
332
int in_range(range_t *r, float f)
 
333
{
 
334
        for (/* NOTHING */; (r->min != -1 && r->max != -1); r++)
 
335
                if (f >= r->min && f <= r->max)
 
336
                        return 1;
 
337
        return 0;
 
338
}
 
339
 
 
340
range_t *str2range(char *s)
 
341
{
 
342
        float tmp_min, tmp_max;
 
343
        char *endptr = s;       // to start the loop
 
344
        range_t *r = NULL;
 
345
        int i;
 
346
 
 
347
        if (!s)
 
348
                return NULL;
 
349
        for (i = 0; *endptr; i++) {
 
350
                if (*s == ',')
 
351
                        goto out_err;
 
352
                if (!(r = (range_t *) realloc(r, sizeof(*r) * (i + 2)))) {
 
353
                        printf("can't realloc 'r'\n");
 
354
                        return NULL;
 
355
                }
 
356
                tmp_min = strtod(s, &endptr);
 
357
                if (*endptr == 'k' || *endptr == 'K') {
 
358
                        tmp_min *= 1000.0;
 
359
                        endptr++;
 
360
                } else if (*endptr == 'm' || *endptr == 'M') {
 
361
                        tmp_min *= 1000000.0;
 
362
                        endptr++;
 
363
                }
 
364
                if (*endptr == '-') {
 
365
                        tmp_max = strtod(endptr + 1, &endptr);
 
366
                        if (*endptr == 'k' || *endptr == 'K') {
 
367
                                tmp_max *= 1000.0;
 
368
                                endptr++;
 
369
                        } else if (*endptr == 'm' || *endptr == 'M') {
 
370
                                tmp_max *= 1000000.0;
 
371
                                endptr++;
 
372
                        }
 
373
                        if (*endptr != ',' && *endptr)
 
374
                                goto out_err;
 
375
                } else if (*endptr == ',' || !*endptr) {
 
376
                        tmp_max = tmp_min;
 
377
                } else
 
378
                        goto out_err;
 
379
                r[i].min = tmp_min;
 
380
                r[i].max = tmp_max;
 
381
                if (r[i].min < 0 || r[i].max < 0)
 
382
                        goto out_err;
 
383
                s = endptr + 1;
 
384
        }
 
385
        r[i].min = r[i].max = -1;
 
386
        return r;
 
387
out_err:
 
388
        if (r)
 
389
                free(r);
 
390
        return NULL;
 
391
}
 
392
 
 
393
/* Borrowed from vo_fbdev.c END */
 
394
#endif
 
395