Mercurial > mplayer.hg
annotate libvo/aspect.c @ 11000:6e35326c742f
many small typo and grammar fixes
Based on Bernard Leak's mail <bernard 4t brenda-arkle.demon.co.uk>
author | gabucino |
---|---|
date | Sat, 04 Oct 2003 17:29:08 +0000 |
parents | d2dc9562422e |
children | d9478c8e5ffe |
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; |
10907 | 20 extern float movie_aspect; |
2053 | 21 |
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
|
22 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
|
23 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
|
24 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
|
25 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
|
26 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
|
27 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
|
28 int scrh; // vertical resolution |
6307 | 29 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
|
30 } 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
|
31 |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
32 void aspect_save_orig(int orgw, int orgh){ |
8936 | 33 #ifdef ASPECT_DEBUG |
34 printf("aspect_save_orig %dx%d \n",orgw,orgh); | |
35 #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
|
36 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
|
37 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
|
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 |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
40 void aspect_save_prescale(int prew, int preh){ |
8936 | 41 #ifdef ASPECT_DEBUG |
42 printf("aspect_save_prescale %dx%d \n",prew,preh); | |
43 #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
|
44 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
|
45 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
|
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 |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
48 void aspect_save_screenres(int scrw, int scrh){ |
8936 | 49 #ifdef ASPECT_DEBUG |
50 printf("aspect_save_screenres %dx%d \n",scrw,scrh); | |
51 #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
|
52 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
|
53 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
|
54 } |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2213
diff
changeset
|
55 |
2053 | 56 /* aspect is called with the source resolution and the |
57 * resolution, that the scaled image should fit into | |
58 */ | |
59 | |
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
|
60 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
|
61 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
|
62 |
10918
d2dc9562422e
temporary fix for attilas 10l, until better solution is found
atmos4
parents:
10907
diff
changeset
|
63 if(!zoom && movie_aspect == 0) { |
d2dc9562422e
temporary fix for attilas 10l, until better solution is found
atmos4
parents:
10907
diff
changeset
|
64 #ifdef ASPECT_DEBUG |
d2dc9562422e
temporary fix for attilas 10l, until better solution is found
atmos4
parents:
10907
diff
changeset
|
65 printf("aspect(0) no aspect forced!\n"); |
d2dc9562422e
temporary fix for attilas 10l, until better solution is found
atmos4
parents:
10907
diff
changeset
|
66 #endif |
11000 | 67 return; // the user doesn't want to fix aspect |
10918
d2dc9562422e
temporary fix for attilas 10l, until better solution is found
atmos4
parents:
10907
diff
changeset
|
68 } |
2071
7f27b212e07b
Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents:
2058
diff
changeset
|
69 #ifdef ASPECT_DEBUG |
8936 | 70 printf("aspect(0) fitin: %dx%d zoom: %d screenaspect: %.2f\n",aspdat.scrw,aspdat.scrh, |
71 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
|
72 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
|
73 #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
|
74 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
|
75 *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
|
76 *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
|
77 * ((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
|
78 }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
|
79 *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
|
80 *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
|
81 * ((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
|
82 } |
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 *srch+= *srch%2; // round |
2071
7f27b212e07b
Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents:
2058
diff
changeset
|
84 #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
|
85 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
|
86 #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
|
87 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
|
88 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
|
89 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
|
90 * ((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
|
91 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
|
92 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
|
93 * ((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
|
94 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
|
95 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
|
96 *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
|
97 *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
|
98 }else{ |
8be92a9b30a4
Fix a bug in the aspect coden (roudning at wrong point) and allow donwscaling in second pass.
atmos4
parents:
2250
diff
changeset
|
99 #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
|
100 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
|
101 #else |
8be92a9b30a4
Fix a bug in the aspect coden (roudning at wrong point) and allow donwscaling in second pass.
atmos4
parents:
2250
diff
changeset
|
102 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
|
103 #endif |
2213 | 104 } |
2053 | 105 } |
6307 | 106 aspdat.asp=*srcw / (float)*srch; |
2071
7f27b212e07b
Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents:
2058
diff
changeset
|
107 #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
|
108 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
|
109 #endif |
2053 | 110 } |
111 | |
6307 | 112 void panscan_init( void ) |
113 { | |
114 vo_panscan_x=0; | |
115 vo_panscan_y=0; | |
116 vo_panscan_amount=0.0f; | |
117 } | |
118 | |
119 void panscan_calc( void ) | |
120 { | |
6382
86d5fc5b54e2
fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents:
6335
diff
changeset
|
121 int fwidth,fheight; |
86d5fc5b54e2
fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents:
6335
diff
changeset
|
122 int vo_panscan_area; |
86d5fc5b54e2
fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents:
6335
diff
changeset
|
123 |
86d5fc5b54e2
fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents:
6335
diff
changeset
|
124 aspect(&fwidth,&fheight,A_ZOOM); |
86d5fc5b54e2
fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents:
6335
diff
changeset
|
125 vo_panscan_area = (aspdat.scrh-fheight); |
86d5fc5b54e2
fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents:
6335
diff
changeset
|
126 |
6307 | 127 vo_panscan_amount = vo_fs ? vo_panscan : 0; |
128 vo_panscan_x = vo_panscan_area * vo_panscan_amount * aspdat.asp; | |
129 vo_panscan_y = vo_panscan_area * vo_panscan_amount; | |
130 } | |
131 |