1 /* Stuff for correct aspect scaling. */
11 #if defined(ASPECT_DEBUG) || defined(ASPECT_TEST)
17 float vo_panscan_amount
= 0;
18 float vo_panscanrange
= 1.0;
20 #include "video_out.h"
22 float monitor_aspect
=4.0/3.0;
23 float monitor_pixel_aspect
=0;
24 extern float movie_aspect
;
27 int orgw
; // real width
28 int orgh
; // real height
29 int prew
; // prescaled width
30 int preh
; // prescaled height
31 int scrw
; // horizontal resolution
32 int scrh
; // vertical resolution
36 void aspect_save_orig(int orgw
, int orgh
){
38 printf("aspect_save_orig %dx%d \n",orgw
,orgh
);
44 void aspect_save_prescale(int prew
, int preh
){
46 printf("aspect_save_prescale %dx%d \n",prew
,preh
);
52 void aspect_save_screenres(int scrw
, int scrh
){
54 printf("aspect_save_screenres %dx%d \n",scrw
,scrh
);
58 if (monitor_pixel_aspect
)
59 monitor_aspect
= monitor_pixel_aspect
* scrw
/ scrh
;
62 /* aspect is called with the source resolution and the
63 * resolution, that the scaled image should fit into
66 void aspect(int *srcw
, int *srch
, int zoom
){
69 if( !zoom
&& geometry_wh_changed
) {
71 printf("aspect(0) no aspect forced!\n");
73 return; // the user doesn't want to fix aspect
77 printf("aspect(0) fitin: %dx%d zoom: %d screenaspect: %.2f\n",aspdat
.scrw
,aspdat
.scrh
,
79 printf("aspect(1) wh: %dx%d (org: %dx%d)\n",*srcw
,*srch
,aspdat
.prew
,aspdat
.preh
);
83 *srch
= (int)(((float)aspdat
.scrw
/ (float)aspdat
.prew
* (float)aspdat
.preh
)
84 * ((float)aspdat
.scrh
/ ((float)aspdat
.scrw
/ monitor_aspect
)));
87 *srch
= (int)((float)aspdat
.preh
88 * ((float)aspdat
.scrh
/ ((float)aspdat
.scrw
/ monitor_aspect
)));
90 *srch
+= *srch
%2; // round
92 printf("aspect(2) wh: %dx%d (org: %dx%d)\n",*srcw
,*srch
,aspdat
.prew
,aspdat
.preh
);
94 if(*srch
>aspdat
.scrh
|| *srch
<aspdat
.orgh
){
96 tmpw
= (int)(((float)aspdat
.scrh
/ (float)aspdat
.preh
* (float)aspdat
.prew
)
97 * ((float)aspdat
.scrw
/ ((float)aspdat
.scrh
/ (1.0/monitor_aspect
))));
99 tmpw
= (int)((float)aspdat
.prew
100 * ((float)aspdat
.scrw
/ ((float)aspdat
.scrh
/ (1.0/monitor_aspect
))));
101 tmpw
+= tmpw
%2; // round
102 if(tmpw
<=aspdat
.scrw
/*&& tmpw>=aspdat.orgw*/){
103 *srch
= zoom
?aspdat
.scrh
:aspdat
.preh
;
107 mp_msg(MSGT_VO
,MSGL_WARN
,MSGTR_LIBVO_ASPECT_NoSuitableNewResFound
);
109 mp_msg(MSGT_VO
,MSGL_WARN
,MSGTR_LIBVO_ASPECT_NoNewSizeFoundThatFitsIntoRes
);
113 aspdat
.asp
=*srcw
/ (float)*srch
;
115 printf("aspect(3) wh: %dx%d (org: %dx%d)\n",*srcw
,*srch
,aspdat
.prew
,aspdat
.preh
);
119 void panscan_init( void )
123 vo_panscan_amount
=0.0f
;
126 void panscan_calc( void )
131 if (vo_panscanrange
> 0) {
132 aspect(&fwidth
,&fheight
,A_ZOOM
);
133 vo_panscan_area
= (aspdat
.scrh
-fheight
);
134 vo_panscan_area
*= vo_panscanrange
;
136 vo_panscan_area
= -vo_panscanrange
* aspdat
.scrh
;
138 vo_panscan_amount
= vo_fs
? vo_panscan
: 0;
139 vo_panscan_x
= vo_panscan_area
* vo_panscan_amount
* aspdat
.asp
;
140 vo_panscan_y
= vo_panscan_area
* vo_panscan_amount
;