Mercurial > mplayer.hg
annotate libvo/aspect.c @ 10607:a17ebe817e33
Fixed a long standing issue: if configured a not available (not existing, permission denied, ...) skin, the gui never ever started again. Now it reverts to 'default' if it can't open the selected skin, if 'default' fails too, the gui exits with error.
author | alex |
---|---|
date | Thu, 14 Aug 2003 01:54:27 +0000 |
parents | 7c28736ebf2c |
children | d4ec1e1c8dc8 |
rev | line source |
---|---|
2053 | 1 /* Stuff for correct aspect scaling. */ |
2249
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
2 #include "aspect.h" |
6087
8be92a9b30a4
Fix a bug in the aspect coden (roudning at wrong point) and allow donwscaling in second pass.
atmos4
parents:
2250
diff
changeset
|
3 #ifndef ASPECT_TEST |
8be92a9b30a4
Fix a bug in the aspect coden (roudning at wrong point) and allow donwscaling in second pass.
atmos4
parents:
2250
diff
changeset
|
4 #include "../mp_msg.h" |
8be92a9b30a4
Fix a bug in the aspect coden (roudning at wrong point) and allow donwscaling in second pass.
atmos4
parents:
2250
diff
changeset
|
5 #endif |
2249
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
6 |
2250 | 7 //#define ASPECT_DEBUG |
2071
7f27b212e07b
Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents:
2058
diff
changeset
|
8 |
6087
8be92a9b30a4
Fix a bug in the aspect coden (roudning at wrong point) and allow donwscaling in second pass.
atmos4
parents:
2250
diff
changeset
|
9 #if defined(ASPECT_DEBUG) || defined(ASPECT_TEST) |
2071
7f27b212e07b
Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents:
2058
diff
changeset
|
10 #include <stdio.h> |
7f27b212e07b
Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents:
2058
diff
changeset
|
11 #endif |
2053 | 12 |
6307 | 13 int vo_panscan_x = 0; |
14 int vo_panscan_y = 0; | |
15 float vo_panscan_amount = 0; | |
16 | |
17 #include "video_out.h" | |
18 | |
2053 | 19 float monitor_aspect=4.0/3.0; |
20 | |
2249
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
21 static struct { |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
22 int orgw; // real width |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
23 int orgh; // real height |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
24 int prew; // prescaled width |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
25 int preh; // prescaled height |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
26 int scrw; // horizontal resolution |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
27 int scrh; // vertical resolution |
6307 | 28 float asp; |
2249
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
29 } aspdat; |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
30 |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
31 void aspect_save_orig(int orgw, int orgh){ |
8936 | 32 #ifdef ASPECT_DEBUG |
33 printf("aspect_save_orig %dx%d \n",orgw,orgh); | |
34 #endif | |
2249
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
35 aspdat.orgw = orgw; |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
36 aspdat.orgh = orgh; |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
37 } |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
38 |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
39 void aspect_save_prescale(int prew, int preh){ |
8936 | 40 #ifdef ASPECT_DEBUG |
41 printf("aspect_save_prescale %dx%d \n",prew,preh); | |
42 #endif | |
2249
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
43 aspdat.prew = prew; |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
44 aspdat.preh = preh; |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
45 } |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
46 |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
47 void aspect_save_screenres(int scrw, int scrh){ |
8936 | 48 #ifdef ASPECT_DEBUG |
49 printf("aspect_save_screenres %dx%d \n",scrw,scrh); | |
50 #endif | |
2249
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
51 aspdat.scrw = scrw; |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
52 aspdat.scrh = scrh; |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
53 } |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
54 |
2053 | 55 /* aspect is called with the source resolution and the |
56 * resolution, that the scaled image should fit into | |
57 */ | |
58 | |
2249
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
59 void aspect(int *srcw, int *srch, int zoom){ |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
60 int tmpw; |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
61 |
2071
7f27b212e07b
Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents:
2058
diff
changeset
|
62 #ifdef ASPECT_DEBUG |
8936 | 63 printf("aspect(0) fitin: %dx%d zoom: %d screenaspect: %.2f\n",aspdat.scrw,aspdat.scrh, |
64 zoom,monitor_aspect); | |
2249
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
65 printf("aspect(1) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat.prew,aspdat.preh); |
2071
7f27b212e07b
Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents:
2058
diff
changeset
|
66 #endif |
2249
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
67 if(zoom){ |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
68 *srcw = aspdat.scrw; |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
69 *srch = (int)(((float)aspdat.scrw / (float)aspdat.prew * (float)aspdat.preh) |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
70 * ((float)aspdat.scrh / ((float)aspdat.scrw / monitor_aspect))); |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
71 }else{ |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
72 *srcw = aspdat.prew; |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
73 *srch = (int)((float)aspdat.preh |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
74 * ((float)aspdat.scrh / ((float)aspdat.scrw / monitor_aspect))); |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
75 } |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
76 *srch+= *srch%2; // round |
2071
7f27b212e07b
Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents:
2058
diff
changeset
|
77 #ifdef ASPECT_DEBUG |
2249
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
78 printf("aspect(2) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat.prew,aspdat.preh); |
2071
7f27b212e07b
Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents:
2058
diff
changeset
|
79 #endif |
2249
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
80 if(*srch>aspdat.scrh || *srch<aspdat.orgh){ |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
81 if(zoom) |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
82 tmpw = (int)(((float)aspdat.scrh / (float)aspdat.preh * (float)aspdat.prew) |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
83 * ((float)aspdat.scrw / ((float)aspdat.scrh / (1.0/monitor_aspect)))); |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
84 else |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
85 tmpw = (int)((float)aspdat.prew |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
86 * ((float)aspdat.scrw / ((float)aspdat.scrh / (1.0/monitor_aspect)))); |
6087
8be92a9b30a4
Fix a bug in the aspect coden (roudning at wrong point) and allow donwscaling in second pass.
atmos4
parents:
2250
diff
changeset
|
87 tmpw+= tmpw%2; // round |
8be92a9b30a4
Fix a bug in the aspect coden (roudning at wrong point) and allow donwscaling in second pass.
atmos4
parents:
2250
diff
changeset
|
88 if(tmpw<=aspdat.scrw /*&& tmpw>=aspdat.orgw*/){ |
2249
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
89 *srch = zoom?aspdat.scrh:aspdat.preh; |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
90 *srcw = tmpw; |
6087
8be92a9b30a4
Fix a bug in the aspect coden (roudning at wrong point) and allow donwscaling in second pass.
atmos4
parents:
2250
diff
changeset
|
91 }else{ |
8be92a9b30a4
Fix a bug in the aspect coden (roudning at wrong point) and allow donwscaling in second pass.
atmos4
parents:
2250
diff
changeset
|
92 #ifndef ASPECT_TEST |
8be92a9b30a4
Fix a bug in the aspect coden (roudning at wrong point) and allow donwscaling in second pass.
atmos4
parents:
2250
diff
changeset
|
93 mp_msg(MSGT_VO,MSGL_WARN,"aspect: Warning: no suitable new res found!\n"); |
8be92a9b30a4
Fix a bug in the aspect coden (roudning at wrong point) and allow donwscaling in second pass.
atmos4
parents:
2250
diff
changeset
|
94 #else |
8be92a9b30a4
Fix a bug in the aspect coden (roudning at wrong point) and allow donwscaling in second pass.
atmos4
parents:
2250
diff
changeset
|
95 printf("error: no new size found that fits into res!\n"); |
8be92a9b30a4
Fix a bug in the aspect coden (roudning at wrong point) and allow donwscaling in second pass.
atmos4
parents:
2250
diff
changeset
|
96 #endif |
2213 | 97 } |
2053 | 98 } |
6307 | 99 aspdat.asp=*srcw / (float)*srch; |
2071
7f27b212e07b
Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents:
2058
diff
changeset
|
100 #ifdef ASPECT_DEBUG |
2249
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
101 printf("aspect(3) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat.prew,aspdat.preh); |
2071
7f27b212e07b
Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents:
2058
diff
changeset
|
102 #endif |
2053 | 103 } |
104 | |
6307 | 105 void panscan_init( void ) |
106 { | |
107 vo_panscan_x=0; | |
108 vo_panscan_y=0; | |
109 vo_panscan_amount=0.0f; | |
110 } | |
111 | |
112 void panscan_calc( void ) | |
113 { | |
6382
86d5fc5b54e2
fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents:
6335
diff
changeset
|
114 int fwidth,fheight; |
86d5fc5b54e2
fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents:
6335
diff
changeset
|
115 int vo_panscan_area; |
86d5fc5b54e2
fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents:
6335
diff
changeset
|
116 |
86d5fc5b54e2
fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents:
6335
diff
changeset
|
117 aspect(&fwidth,&fheight,A_ZOOM); |
86d5fc5b54e2
fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents:
6335
diff
changeset
|
118 vo_panscan_area = (aspdat.scrh-fheight); |
86d5fc5b54e2
fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents:
6335
diff
changeset
|
119 |
6307 | 120 vo_panscan_amount = vo_fs ? vo_panscan : 0; |
121 vo_panscan_x = vo_panscan_area * vo_panscan_amount * aspdat.asp; | |
122 vo_panscan_y = vo_panscan_area * vo_panscan_amount; | |
123 } | |
124 |