1 /* Stuff for correct aspect scaling. */
10 #if defined(ASPECT_DEBUG) || defined(ASPECT_TEST)
16 float vo_panscan_amount
= 0;
17 float vo_panscanrange
= 1.0;
19 #include "video_out.h"
21 float monitor_aspect
=4.0/3.0;
22 float monitor_pixel_aspect
=0;
23 extern float movie_aspect
;
26 int orgw
; // real width
27 int orgh
; // real height
28 int prew
; // prescaled width
29 int preh
; // prescaled height
30 int scrw
; // horizontal resolution
31 int scrh
; // vertical resolution
35 void aspect_save_orig(int orgw
, int orgh
){
37 printf("aspect_save_orig %dx%d \n",orgw
,orgh
);
43 void aspect_save_prescale(int prew
, int preh
){
45 printf("aspect_save_prescale %dx%d \n",prew
,preh
);
51 void aspect_save_screenres(int scrw
, int scrh
){
53 printf("aspect_save_screenres %dx%d \n",scrw
,scrh
);
57 if (monitor_pixel_aspect
)
58 monitor_aspect
= monitor_pixel_aspect
* scrw
/ scrh
;
61 /* aspect is called with the source resolution and the
62 * resolution, that the scaled image should fit into
65 void aspect(int *srcw
, int *srch
, int zoom
){
68 if( !zoom
&& geometry_wh_changed
) {
70 printf("aspect(0) no aspect forced!\n");
72 return; // the user doesn't want to fix aspect
76 printf("aspect(0) fitin: %dx%d zoom: %d screenaspect: %.2f\n",aspdat
.scrw
,aspdat
.scrh
,
78 printf("aspect(1) wh: %dx%d (org: %dx%d)\n",*srcw
,*srch
,aspdat
.prew
,aspdat
.preh
);
82 *srch
= (int)(((float)aspdat
.scrw
/ (float)aspdat
.prew
* (float)aspdat
.preh
)
83 * ((float)aspdat
.scrh
/ ((float)aspdat
.scrw
/ monitor_aspect
)));
86 *srch
= (int)((float)aspdat
.preh
87 * ((float)aspdat
.scrh
/ ((float)aspdat
.scrw
/ monitor_aspect
)));
89 *srch
+= *srch
%2; // round
91 printf("aspect(2) wh: %dx%d (org: %dx%d)\n",*srcw
,*srch
,aspdat
.prew
,aspdat
.preh
);
93 if(*srch
>aspdat
.scrh
|| *srch
<aspdat
.orgh
){
95 tmpw
= (int)(((float)aspdat
.scrh
/ (float)aspdat
.preh
* (float)aspdat
.prew
)
96 * ((float)aspdat
.scrw
/ ((float)aspdat
.scrh
/ (1.0/monitor_aspect
))));
98 tmpw
= (int)((float)aspdat
.prew
99 * ((float)aspdat
.scrw
/ ((float)aspdat
.scrh
/ (1.0/monitor_aspect
))));
100 tmpw
+= tmpw
%2; // round
101 if(tmpw
<=aspdat
.scrw
/*&& tmpw>=aspdat.orgw*/){
102 *srch
= zoom
?aspdat
.scrh
:aspdat
.preh
;
106 mp_msg(MSGT_VO
,MSGL_WARN
,"aspect: Warning: no suitable new res found!\n");
108 mp_msg(MSGT_VO
,MSGL_WARN
,"error: no new size found that fits into res!\n");
112 aspdat
.asp
=*srcw
/ (float)*srch
;
114 printf("aspect(3) wh: %dx%d (org: %dx%d)\n",*srcw
,*srch
,aspdat
.prew
,aspdat
.preh
);
118 void panscan_init( void )
122 vo_panscan_amount
=0.0f
;
125 void panscan_calc( void )
130 if (vo_panscanrange
> 0) {
131 aspect(&fwidth
,&fheight
,A_ZOOM
);
132 vo_panscan_area
= (aspdat
.scrh
-fheight
);
133 vo_panscan_area
*= vo_panscanrange
;
135 vo_panscan_area
= -vo_panscanrange
* aspdat
.scrh
;
137 vo_panscan_amount
= vo_fs
? vo_panscan
: 0;
138 vo_panscan_x
= vo_panscan_area
* vo_panscan_amount
* aspdat
.asp
;
139 vo_panscan_y
= vo_panscan_area
* vo_panscan_amount
;