2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 /* Stuff for correct aspect scaling. */
27 //#define ASPECT_DEBUG
29 #if defined(ASPECT_DEBUG) || defined(ASPECT_TEST)
35 float vo_panscan_amount
= 0;
36 float vo_panscanrange
= 1.0;
38 #include "video_out.h"
40 float force_monitor_aspect
=0;
41 float monitor_aspect
=0;
42 float monitor_pixel_aspect
=1;
43 extern float movie_aspect
;
46 int orgw
; // real width
47 int orgh
; // real height
48 int prew
; // prescaled width
49 int preh
; // prescaled height
50 int scrw
; // horizontal resolution
51 int scrh
; // vertical resolution
55 void aspect_save_orig(int orgw
, int orgh
){
57 printf("aspect_save_orig %dx%d \n",orgw
,orgh
);
63 void aspect_save_prescale(int prew
, int preh
){
65 printf("aspect_save_prescale %dx%d \n",prew
,preh
);
71 void aspect_save_screenres(int scrw
, int scrh
){
73 printf("aspect_save_screenres %dx%d \n",scrw
,scrh
);
77 if (force_monitor_aspect
)
78 monitor_aspect
= force_monitor_aspect
;
80 monitor_aspect
= monitor_pixel_aspect
* scrw
/ scrh
;
83 /* aspect is called with the source resolution and the
84 * resolution, that the scaled image should fit into
87 void aspect_fit(int *srcw
, int *srch
, int fitw
, int fith
){
91 printf("aspect(0) fitin: %dx%d screenaspect: %.2f\n",aspdat
.scrw
,aspdat
.scrh
,
93 printf("aspect(1) wh: %dx%d (org: %dx%d)\n",*srcw
,*srch
,aspdat
.prew
,aspdat
.preh
);
96 *srch
= (int)(((float)fitw
/ (float)aspdat
.prew
* (float)aspdat
.preh
)
97 * ((float)aspdat
.scrh
/ ((float)aspdat
.scrw
/ monitor_aspect
)));
98 *srch
+= *srch
%2; // round
100 printf("aspect(2) wh: %dx%d (org: %dx%d)\n",*srcw
,*srch
,aspdat
.prew
,aspdat
.preh
);
102 if(*srch
>aspdat
.scrh
|| *srch
<aspdat
.orgh
){
103 tmpw
= (int)(((float)fith
/ (float)aspdat
.preh
* (float)aspdat
.prew
)
104 * ((float)aspdat
.scrw
/ ((float)aspdat
.scrh
/ (1.0/monitor_aspect
))));
105 tmpw
+= tmpw
%2; // round
106 if(tmpw
<=aspdat
.scrw
/*&& tmpw>=aspdat.orgw*/){
111 mp_msg(MSGT_VO
,MSGL_WARN
,MSGTR_LIBVO_ASPECT_NoSuitableNewResFound
);
113 mp_msg(MSGT_VO
,MSGL_WARN
,MSGTR_LIBVO_ASPECT_NoNewSizeFoundThatFitsIntoRes
);
117 aspdat
.asp
=*srcw
/ (float)*srch
;
119 printf("aspect(3) wh: %dx%d (org: %dx%d)\n",*srcw
,*srch
,aspdat
.prew
,aspdat
.preh
);
123 void aspect(int *srcw
, int *srch
, int zoom
){
124 int fitw
= zoom
? aspdat
.scrw
: aspdat
.prew
;
125 int fith
= zoom
? aspdat
.scrh
: aspdat
.preh
;
126 if( !zoom
&& geometry_wh_changed
) {
128 printf("aspect(0) no aspect forced!\n");
130 return; // the user doesn't want to fix aspect
132 aspect_fit(srcw
, srch
, fitw
, fith
);
135 void panscan_init( void )
139 vo_panscan_amount
=0.0f
;
142 void panscan_calc( void )
147 if (vo_panscanrange
> 0) {
148 aspect(&fwidth
,&fheight
,A_ZOOM
);
149 vo_panscan_area
= (aspdat
.scrh
-fheight
);
150 if (!vo_panscan_area
)
151 vo_panscan_area
= aspdat
.scrw
- fwidth
;
152 vo_panscan_area
*= vo_panscanrange
;
154 vo_panscan_area
= -vo_panscanrange
* aspdat
.scrh
;
156 vo_panscan_amount
= vo_fs
? vo_panscan
: 0;
157 vo_panscan_x
= vo_panscan_area
* vo_panscan_amount
* aspdat
.asp
;
158 vo_panscan_y
= vo_panscan_area
* vo_panscan_amount
;