annotate libvo/aspect.c @ 37195:ac6c37d85d65 default tip

configure: Fix initialization of variable def_local_aligned_32 It contiained the #define of HAVE_LOCAL_ALIGNED_16 instead of HAVE_LOCAL_ALIGNED_32.
author al
date Sun, 28 Sep 2014 18:38:41 +0000
parents 153031444853
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28446
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25917
diff changeset
1 /*
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25917
diff changeset
2 * This file is part of MPlayer.
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25917
diff changeset
3 *
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25917
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25917
diff changeset
5 * it under the terms of the GNU General Public License as published by
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25917
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25917
diff changeset
7 * (at your option) any later version.
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25917
diff changeset
8 *
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25917
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25917
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25917
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25917
diff changeset
12 * GNU General Public License for more details.
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25917
diff changeset
13 *
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25917
diff changeset
14 * You should have received a copy of the GNU General Public License along
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25917
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25917
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25917
diff changeset
17 */
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25917
diff changeset
18
2053
720ca9249e4e Monitor aspect stuff.
atmos4
parents:
diff changeset
19 /* 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
20 #include "aspect.h"
11125
d9478c8e5ffe fix aspect hack
attila
parents: 11000
diff changeset
21 #include "geometry.h"
18234
a107276371a8 Part 5 and final of otvos attila's oattila AT chello-hu mp_msg changes, with lots of corrections
reynaldo
parents: 18105
diff changeset
22 //#ifndef ASPECT_TEST
13787
e047e70a9767 Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents: 11125
diff changeset
23 #include "mp_msg.h"
20765
dd41a1fc9000 MSGTRs for libvo/aspect.c and libvo/vo_xv.c
kraymer
parents: 18234
diff changeset
24 #include "help_mp.h"
18234
a107276371a8 Part 5 and final of otvos attila's oattila AT chello-hu mp_msg changes, with lots of corrections
reynaldo
parents: 18105
diff changeset
25 //#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
26
2250
d7923c09dd46 Eeeh :) time to sleep!
atmos4
parents: 2249
diff changeset
27 //#define ASPECT_DEBUG
2071
7f27b212e07b Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents: 2058
diff changeset
28
6087
8be92a9b30a4 Fix a bug in the aspect coden (roudning at wrong point) and allow donwscaling in second pass.
atmos4
parents: 2250
diff changeset
29 #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
30 #include <stdio.h>
7f27b212e07b Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents: 2058
diff changeset
31 #endif
2053
720ca9249e4e Monitor aspect stuff.
atmos4
parents:
diff changeset
32
6307
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
33 int vo_panscan_x = 0;
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
34 int vo_panscan_y = 0;
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
35 float vo_panscan_amount = 0;
16607
971ff1108066 Add -panscanrange option
reimar
parents: 13787
diff changeset
36 float vo_panscanrange = 1.0;
6307
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
37
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
38 #include "video_out.h"
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
39
23876
b38974c30ed6 Use a new variable for user-supplied monitor-aspect so we can overwrite
reimar
parents: 23136
diff changeset
40 float force_monitor_aspect=0;
23136
7753555efb15 Make -monitorpixelaspect 1 the default.
cehoyos
parents: 20765
diff changeset
41 float monitor_aspect=0;
7753555efb15 Make -monitorpixelaspect 1 the default.
cehoyos
parents: 20765
diff changeset
42 float monitor_pixel_aspect=1;
2053
720ca9249e4e Monitor aspect stuff.
atmos4
parents:
diff changeset
43
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 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
45 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
46 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
47 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
48 int preh; // prescaled height
36171
94979f661d38 Add support for rotating the video via OpenGL.
reimar
parents: 32395
diff changeset
49 int orgw_norot;
94979f661d38 Add support for rotating the video via OpenGL.
reimar
parents: 32395
diff changeset
50 int orgh_norot;
94979f661d38 Add support for rotating the video via OpenGL.
reimar
parents: 32395
diff changeset
51 int prew_norot;
94979f661d38 Add support for rotating the video via OpenGL.
reimar
parents: 32395
diff changeset
52 int preh_norot;
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
53 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
54 int scrh; // vertical resolution
6307
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
55 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
56 } 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
57
36171
94979f661d38 Add support for rotating the video via OpenGL.
reimar
parents: 32395
diff changeset
58 static void aspect_rotate(void) {
94979f661d38 Add support for rotating the video via OpenGL.
reimar
parents: 32395
diff changeset
59 if (vo_rotate & 1) {
94979f661d38 Add support for rotating the video via OpenGL.
reimar
parents: 32395
diff changeset
60 aspdat.orgw = aspdat.orgh_norot;
94979f661d38 Add support for rotating the video via OpenGL.
reimar
parents: 32395
diff changeset
61 aspdat.orgh = aspdat.orgw_norot;
94979f661d38 Add support for rotating the video via OpenGL.
reimar
parents: 32395
diff changeset
62 aspdat.prew = aspdat.preh_norot;
94979f661d38 Add support for rotating the video via OpenGL.
reimar
parents: 32395
diff changeset
63 aspdat.preh = aspdat.prew_norot;
94979f661d38 Add support for rotating the video via OpenGL.
reimar
parents: 32395
diff changeset
64 } else {
94979f661d38 Add support for rotating the video via OpenGL.
reimar
parents: 32395
diff changeset
65 aspdat.orgw = aspdat.orgw_norot;
94979f661d38 Add support for rotating the video via OpenGL.
reimar
parents: 32395
diff changeset
66 aspdat.orgh = aspdat.orgh_norot;
94979f661d38 Add support for rotating the video via OpenGL.
reimar
parents: 32395
diff changeset
67 aspdat.prew = aspdat.prew_norot;
94979f661d38 Add support for rotating the video via OpenGL.
reimar
parents: 32395
diff changeset
68 aspdat.preh = aspdat.preh_norot;
94979f661d38 Add support for rotating the video via OpenGL.
reimar
parents: 32395
diff changeset
69 }
94979f661d38 Add support for rotating the video via OpenGL.
reimar
parents: 32395
diff changeset
70 }
94979f661d38 Add support for rotating the video via OpenGL.
reimar
parents: 32395
diff changeset
71
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 void aspect_save_orig(int orgw, int orgh){
8936
7c28736ebf2c debug++
atmos4
parents: 6382
diff changeset
73 #ifdef ASPECT_DEBUG
7c28736ebf2c debug++
atmos4
parents: 6382
diff changeset
74 printf("aspect_save_orig %dx%d \n",orgw,orgh);
7c28736ebf2c debug++
atmos4
parents: 6382
diff changeset
75 #endif
36171
94979f661d38 Add support for rotating the video via OpenGL.
reimar
parents: 32395
diff changeset
76 aspdat.orgw_norot = orgw;
94979f661d38 Add support for rotating the video via OpenGL.
reimar
parents: 32395
diff changeset
77 aspdat.orgh_norot = orgh;
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 }
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
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 void aspect_save_prescale(int prew, int preh){
8936
7c28736ebf2c debug++
atmos4
parents: 6382
diff changeset
81 #ifdef ASPECT_DEBUG
7c28736ebf2c debug++
atmos4
parents: 6382
diff changeset
82 printf("aspect_save_prescale %dx%d \n",prew,preh);
7c28736ebf2c debug++
atmos4
parents: 6382
diff changeset
83 #endif
36171
94979f661d38 Add support for rotating the video via OpenGL.
reimar
parents: 32395
diff changeset
84 aspdat.prew_norot = prew;
94979f661d38 Add support for rotating the video via OpenGL.
reimar
parents: 32395
diff changeset
85 aspdat.preh_norot = preh;
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
86 }
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
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 void aspect_save_screenres(int scrw, int scrh){
8936
7c28736ebf2c debug++
atmos4
parents: 6382
diff changeset
89 #ifdef ASPECT_DEBUG
7c28736ebf2c debug++
atmos4
parents: 6382
diff changeset
90 printf("aspect_save_screenres %dx%d \n",scrw,scrh);
7c28736ebf2c debug++
atmos4
parents: 6382
diff changeset
91 #endif
32395
aca925e56969 Fix handling of invalid values in aspect_save_screenres to not overwrite
reimar
parents: 32366
diff changeset
92 if (scrw <= 0 && scrh <= 0)
32366
3a6a61ffbb34 Add fallback values to aspect_save_screenres to avoid division by 0
reimar
parents: 29529
diff changeset
93 scrw = 1024;
32395
aca925e56969 Fix handling of invalid values in aspect_save_screenres to not overwrite
reimar
parents: 32366
diff changeset
94 if (scrh <= 0)
32366
3a6a61ffbb34 Add fallback values to aspect_save_screenres to avoid division by 0
reimar
parents: 29529
diff changeset
95 scrh = (scrw * 3 + 3) / 4;
32395
aca925e56969 Fix handling of invalid values in aspect_save_screenres to not overwrite
reimar
parents: 32366
diff changeset
96 if (scrw <= 0)
32366
3a6a61ffbb34 Add fallback values to aspect_save_screenres to avoid division by 0
reimar
parents: 29529
diff changeset
97 scrw = (scrh * 4 + 2) / 3;
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
98 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
99 aspdat.scrh = scrh;
23876
b38974c30ed6 Use a new variable for user-supplied monitor-aspect so we can overwrite
reimar
parents: 23136
diff changeset
100 if (force_monitor_aspect)
b38974c30ed6 Use a new variable for user-supplied monitor-aspect so we can overwrite
reimar
parents: 23136
diff changeset
101 monitor_aspect = force_monitor_aspect;
b38974c30ed6 Use a new variable for user-supplied monitor-aspect so we can overwrite
reimar
parents: 23136
diff changeset
102 else
18105
954eac69b532 new monitorpixelaspect option, esp. useful for xinerama setups with upcoming patch
reimar
parents: 16607
diff changeset
103 monitor_aspect = monitor_pixel_aspect * scrw / scrh;
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
104 }
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
105
2053
720ca9249e4e Monitor aspect stuff.
atmos4
parents:
diff changeset
106 /* aspect is called with the source resolution and the
720ca9249e4e Monitor aspect stuff.
atmos4
parents:
diff changeset
107 * resolution, that the scaled image should fit into
720ca9249e4e Monitor aspect stuff.
atmos4
parents:
diff changeset
108 */
720ca9249e4e Monitor aspect stuff.
atmos4
parents:
diff changeset
109
25917
afd170654f62 Make aspect adjustment calculation simpler and more flexible.
reimar
parents: 25782
diff changeset
110 void aspect_fit(int *srcw, int *srch, int fitw, int fith){
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
111 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
112
36171
94979f661d38 Add support for rotating the video via OpenGL.
reimar
parents: 32395
diff changeset
113 aspect_rotate();
2071
7f27b212e07b Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents: 2058
diff changeset
114 #ifdef ASPECT_DEBUG
25917
afd170654f62 Make aspect adjustment calculation simpler and more flexible.
reimar
parents: 25782
diff changeset
115 printf("aspect(0) fitin: %dx%d screenaspect: %.2f\n",aspdat.scrw,aspdat.scrh,
afd170654f62 Make aspect adjustment calculation simpler and more flexible.
reimar
parents: 25782
diff changeset
116 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
117 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
118 #endif
25917
afd170654f62 Make aspect adjustment calculation simpler and more flexible.
reimar
parents: 25782
diff changeset
119 *srcw = fitw;
afd170654f62 Make aspect adjustment calculation simpler and more flexible.
reimar
parents: 25782
diff changeset
120 *srch = (int)(((float)fitw / (float)aspdat.prew * (float)aspdat.preh)
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
121 * ((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
122 *srch+= *srch%2; // round
2071
7f27b212e07b Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents: 2058
diff changeset
123 #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
124 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
125 #endif
29516
87897065b7d7 Fix aspect_fit to work correctly when borders need to be added on top and
reimar
parents: 29515
diff changeset
126 if(*srch>fith || *srch<aspdat.orgh){
25917
afd170654f62 Make aspect adjustment calculation simpler and more flexible.
reimar
parents: 25782
diff changeset
127 tmpw = (int)(((float)fith / (float)aspdat.preh * (float)aspdat.prew)
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
128 * ((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
129 tmpw+= tmpw%2; // round
29516
87897065b7d7 Fix aspect_fit to work correctly when borders need to be added on top and
reimar
parents: 29515
diff changeset
130 if(tmpw<=fitw /*&& tmpw>=aspdat.orgw*/){
25917
afd170654f62 Make aspect adjustment calculation simpler and more flexible.
reimar
parents: 25782
diff changeset
131 *srch = fith;
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
132 *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
133 }else{
8be92a9b30a4 Fix a bug in the aspect coden (roudning at wrong point) and allow donwscaling in second pass.
atmos4
parents: 2250
diff changeset
134 #ifndef ASPECT_TEST
20765
dd41a1fc9000 MSGTRs for libvo/aspect.c and libvo/vo_xv.c
kraymer
parents: 18234
diff changeset
135 mp_msg(MSGT_VO,MSGL_WARN,MSGTR_LIBVO_ASPECT_NoSuitableNewResFound);
6087
8be92a9b30a4 Fix a bug in the aspect coden (roudning at wrong point) and allow donwscaling in second pass.
atmos4
parents: 2250
diff changeset
136 #else
20765
dd41a1fc9000 MSGTRs for libvo/aspect.c and libvo/vo_xv.c
kraymer
parents: 18234
diff changeset
137 mp_msg(MSGT_VO,MSGL_WARN,MSGTR_LIBVO_ASPECT_NoNewSizeFoundThatFitsIntoRes);
6087
8be92a9b30a4 Fix a bug in the aspect coden (roudning at wrong point) and allow donwscaling in second pass.
atmos4
parents: 2250
diff changeset
138 #endif
2213
a98d5300f5e9 Add downscaling as a last resort.
atmos4
parents: 2071
diff changeset
139 }
2053
720ca9249e4e Monitor aspect stuff.
atmos4
parents:
diff changeset
140 }
6307
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
141 aspdat.asp=*srcw / (float)*srch;
2071
7f27b212e07b Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents: 2058
diff changeset
142 #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
143 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
144 #endif
2053
720ca9249e4e Monitor aspect stuff.
atmos4
parents:
diff changeset
145 }
720ca9249e4e Monitor aspect stuff.
atmos4
parents:
diff changeset
146
29518
24b40e352024 Make panscan cover the same range in -wid -fs mode as in normal mode.
reimar
parents: 29516
diff changeset
147 static void get_max_dims(int *w, int *h, int zoom)
24b40e352024 Make panscan cover the same range in -wid -fs mode as in normal mode.
reimar
parents: 29516
diff changeset
148 {
24b40e352024 Make panscan cover the same range in -wid -fs mode as in normal mode.
reimar
parents: 29516
diff changeset
149 *w = zoom ? aspdat.scrw : aspdat.prew;
24b40e352024 Make panscan cover the same range in -wid -fs mode as in normal mode.
reimar
parents: 29516
diff changeset
150 *h = zoom ? aspdat.scrh : aspdat.preh;
29515
d3700065005f Forgotten changes to aspect code to handle -wid with -fs.
reimar
parents: 28446
diff changeset
151 if (zoom && WinID >= 0) zoom = A_WINZOOM;
d3700065005f Forgotten changes to aspect code to handle -wid with -fs.
reimar
parents: 28446
diff changeset
152 if (zoom == A_WINZOOM) {
29518
24b40e352024 Make panscan cover the same range in -wid -fs mode as in normal mode.
reimar
parents: 29516
diff changeset
153 *w = vo_dwidth;
24b40e352024 Make panscan cover the same range in -wid -fs mode as in normal mode.
reimar
parents: 29516
diff changeset
154 *h = vo_dheight;
29515
d3700065005f Forgotten changes to aspect code to handle -wid with -fs.
reimar
parents: 28446
diff changeset
155 }
29518
24b40e352024 Make panscan cover the same range in -wid -fs mode as in normal mode.
reimar
parents: 29516
diff changeset
156 }
24b40e352024 Make panscan cover the same range in -wid -fs mode as in normal mode.
reimar
parents: 29516
diff changeset
157
24b40e352024 Make panscan cover the same range in -wid -fs mode as in normal mode.
reimar
parents: 29516
diff changeset
158 void aspect(int *srcw, int *srch, int zoom){
24b40e352024 Make panscan cover the same range in -wid -fs mode as in normal mode.
reimar
parents: 29516
diff changeset
159 int fitw;
24b40e352024 Make panscan cover the same range in -wid -fs mode as in normal mode.
reimar
parents: 29516
diff changeset
160 int fith;
36171
94979f661d38 Add support for rotating the video via OpenGL.
reimar
parents: 32395
diff changeset
161 aspect_rotate();
29518
24b40e352024 Make panscan cover the same range in -wid -fs mode as in normal mode.
reimar
parents: 29516
diff changeset
162 get_max_dims(&fitw, &fith, zoom);
25917
afd170654f62 Make aspect adjustment calculation simpler and more flexible.
reimar
parents: 25782
diff changeset
163 if( !zoom && geometry_wh_changed ) {
afd170654f62 Make aspect adjustment calculation simpler and more flexible.
reimar
parents: 25782
diff changeset
164 #ifdef ASPECT_DEBUG
afd170654f62 Make aspect adjustment calculation simpler and more flexible.
reimar
parents: 25782
diff changeset
165 printf("aspect(0) no aspect forced!\n");
afd170654f62 Make aspect adjustment calculation simpler and more flexible.
reimar
parents: 25782
diff changeset
166 #endif
afd170654f62 Make aspect adjustment calculation simpler and more flexible.
reimar
parents: 25782
diff changeset
167 return; // the user doesn't want to fix aspect
afd170654f62 Make aspect adjustment calculation simpler and more flexible.
reimar
parents: 25782
diff changeset
168 }
afd170654f62 Make aspect adjustment calculation simpler and more flexible.
reimar
parents: 25782
diff changeset
169 aspect_fit(srcw, srch, fitw, fith);
afd170654f62 Make aspect adjustment calculation simpler and more flexible.
reimar
parents: 25782
diff changeset
170 }
afd170654f62 Make aspect adjustment calculation simpler and more flexible.
reimar
parents: 25782
diff changeset
171
6307
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
172 void panscan_init( void )
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
173 {
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
174 vo_panscan_x=0;
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
175 vo_panscan_y=0;
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
176 vo_panscan_amount=0.0f;
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
177 }
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
178
29524
b1a437cdc60d Add infrastructure and test code to enable aspect scaling and panscan in windowed mode.
reimar
parents: 29518
diff changeset
179 static void panscan_calc_internal(int zoom)
6307
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
180 {
6382
86d5fc5b54e2 fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents: 6335
diff changeset
181 int fwidth,fheight;
86d5fc5b54e2 fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents: 6335
diff changeset
182 int vo_panscan_area;
29518
24b40e352024 Make panscan cover the same range in -wid -fs mode as in normal mode.
reimar
parents: 29516
diff changeset
183 int max_w, max_h;
36171
94979f661d38 Add support for rotating the video via OpenGL.
reimar
parents: 32395
diff changeset
184 aspect_rotate();
29524
b1a437cdc60d Add infrastructure and test code to enable aspect scaling and panscan in windowed mode.
reimar
parents: 29518
diff changeset
185 get_max_dims(&max_w, &max_h, zoom);
6382
86d5fc5b54e2 fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents: 6335
diff changeset
186
16607
971ff1108066 Add -panscanrange option
reimar
parents: 13787
diff changeset
187 if (vo_panscanrange > 0) {
29524
b1a437cdc60d Add infrastructure and test code to enable aspect scaling and panscan in windowed mode.
reimar
parents: 29518
diff changeset
188 aspect(&fwidth,&fheight,zoom);
29518
24b40e352024 Make panscan cover the same range in -wid -fs mode as in normal mode.
reimar
parents: 29516
diff changeset
189 vo_panscan_area = max_h - fheight;
25782
aac51b420d89 -panscan should also work for right and left borders
reimar
parents: 25781
diff changeset
190 if (!vo_panscan_area)
29518
24b40e352024 Make panscan cover the same range in -wid -fs mode as in normal mode.
reimar
parents: 29516
diff changeset
191 vo_panscan_area = max_w - fwidth;
16607
971ff1108066 Add -panscanrange option
reimar
parents: 13787
diff changeset
192 vo_panscan_area *= vo_panscanrange;
971ff1108066 Add -panscanrange option
reimar
parents: 13787
diff changeset
193 } else
29518
24b40e352024 Make panscan cover the same range in -wid -fs mode as in normal mode.
reimar
parents: 29516
diff changeset
194 vo_panscan_area = -vo_panscanrange * max_h;
6382
86d5fc5b54e2 fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents: 6335
diff changeset
195
29524
b1a437cdc60d Add infrastructure and test code to enable aspect scaling and panscan in windowed mode.
reimar
parents: 29518
diff changeset
196 vo_panscan_amount = vo_fs || zoom == A_WINZOOM ? vo_panscan : 0;
6307
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
197 vo_panscan_x = vo_panscan_area * vo_panscan_amount * aspdat.asp;
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
198 vo_panscan_y = vo_panscan_area * vo_panscan_amount;
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
199 }
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
200
29524
b1a437cdc60d Add infrastructure and test code to enable aspect scaling and panscan in windowed mode.
reimar
parents: 29518
diff changeset
201 void panscan_calc(void)
b1a437cdc60d Add infrastructure and test code to enable aspect scaling and panscan in windowed mode.
reimar
parents: 29518
diff changeset
202 {
b1a437cdc60d Add infrastructure and test code to enable aspect scaling and panscan in windowed mode.
reimar
parents: 29518
diff changeset
203 panscan_calc_internal(A_ZOOM);
b1a437cdc60d Add infrastructure and test code to enable aspect scaling and panscan in windowed mode.
reimar
parents: 29518
diff changeset
204 }
b1a437cdc60d Add infrastructure and test code to enable aspect scaling and panscan in windowed mode.
reimar
parents: 29518
diff changeset
205
b1a437cdc60d Add infrastructure and test code to enable aspect scaling and panscan in windowed mode.
reimar
parents: 29518
diff changeset
206 /**
b1a437cdc60d Add infrastructure and test code to enable aspect scaling and panscan in windowed mode.
reimar
parents: 29518
diff changeset
207 * vos that set vo_dwidth and v_dheight correctly should call this to update
b1a437cdc60d Add infrastructure and test code to enable aspect scaling and panscan in windowed mode.
reimar
parents: 29518
diff changeset
208 * vo_panscan_x and vo_panscan_y
b1a437cdc60d Add infrastructure and test code to enable aspect scaling and panscan in windowed mode.
reimar
parents: 29518
diff changeset
209 */
b1a437cdc60d Add infrastructure and test code to enable aspect scaling and panscan in windowed mode.
reimar
parents: 29518
diff changeset
210 void panscan_calc_windowed(void)
b1a437cdc60d Add infrastructure and test code to enable aspect scaling and panscan in windowed mode.
reimar
parents: 29518
diff changeset
211 {
b1a437cdc60d Add infrastructure and test code to enable aspect scaling and panscan in windowed mode.
reimar
parents: 29518
diff changeset
212 panscan_calc_internal(A_WINZOOM);
b1a437cdc60d Add infrastructure and test code to enable aspect scaling and panscan in windowed mode.
reimar
parents: 29518
diff changeset
213 }