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 force_monitor_aspect
=0;
23 float monitor_aspect
=0;
24 float monitor_pixel_aspect
=1;
25 extern float movie_aspect
;
28 int orgw
; // real width
29 int orgh
; // real height
30 int prew
; // prescaled width
31 int preh
; // prescaled height
32 int scrw
; // horizontal resolution
33 int scrh
; // vertical resolution
37 void aspect_save_orig(int orgw
, int orgh
){
39 printf("aspect_save_orig %dx%d \n",orgw
,orgh
);
45 void aspect_save_prescale(int prew
, int preh
){
47 printf("aspect_save_prescale %dx%d \n",prew
,preh
);
53 void aspect_save_screenres(int scrw
, int scrh
){
55 printf("aspect_save_screenres %dx%d \n",scrw
,scrh
);
59 if (force_monitor_aspect
)
60 monitor_aspect
= force_monitor_aspect
;
62 monitor_aspect
= monitor_pixel_aspect
* scrw
/ scrh
;
65 /* aspect is called with the source resolution and the
66 * resolution, that the scaled image should fit into
69 void aspect(int *srcw
, int *srch
, int zoom
){
72 if( !zoom
&& geometry_wh_changed
) {
74 printf("aspect(0) no aspect forced!\n");
76 return; // the user doesn't want to fix aspect
80 printf("aspect(0) fitin: %dx%d zoom: %d screenaspect: %.2f\n",aspdat
.scrw
,aspdat
.scrh
,
82 printf("aspect(1) wh: %dx%d (org: %dx%d)\n",*srcw
,*srch
,aspdat
.prew
,aspdat
.preh
);
86 *srch
= (int)(((float)aspdat
.scrw
/ (float)aspdat
.prew
* (float)aspdat
.preh
)
87 * ((float)aspdat
.scrh
/ ((float)aspdat
.scrw
/ monitor_aspect
)));
90 *srch
= (int)((float)aspdat
.preh
91 * ((float)aspdat
.scrh
/ ((float)aspdat
.scrw
/ monitor_aspect
)));
93 *srch
+= *srch
%2; // round
95 printf("aspect(2) wh: %dx%d (org: %dx%d)\n",*srcw
,*srch
,aspdat
.prew
,aspdat
.preh
);
97 if(*srch
>aspdat
.scrh
|| *srch
<aspdat
.orgh
){
99 tmpw
= (int)(((float)aspdat
.scrh
/ (float)aspdat
.preh
* (float)aspdat
.prew
)
100 * ((float)aspdat
.scrw
/ ((float)aspdat
.scrh
/ (1.0/monitor_aspect
))));
102 tmpw
= (int)((float)aspdat
.prew
103 * ((float)aspdat
.scrw
/ ((float)aspdat
.scrh
/ (1.0/monitor_aspect
))));
104 tmpw
+= tmpw
%2; // round
105 if(tmpw
<=aspdat
.scrw
/*&& tmpw>=aspdat.orgw*/){
106 *srch
= zoom
?aspdat
.scrh
:aspdat
.preh
;
110 mp_msg(MSGT_VO
,MSGL_WARN
,MSGTR_LIBVO_ASPECT_NoSuitableNewResFound
);
112 mp_msg(MSGT_VO
,MSGL_WARN
,MSGTR_LIBVO_ASPECT_NoNewSizeFoundThatFitsIntoRes
);
116 aspdat
.asp
=*srcw
/ (float)*srch
;
118 printf("aspect(3) wh: %dx%d (org: %dx%d)\n",*srcw
,*srch
,aspdat
.prew
,aspdat
.preh
);
122 void panscan_init( void )
126 vo_panscan_amount
=0.0f
;
129 void panscan_calc( void )
134 if (vo_panscanrange
> 0) {
135 aspect(&fwidth
,&fheight
,A_ZOOM
);
136 vo_panscan_area
= (aspdat
.scrh
-fheight
);
137 vo_panscan_area
*= vo_panscanrange
;
139 vo_panscan_area
= -vo_panscanrange
* aspdat
.scrh
;
141 vo_panscan_amount
= vo_fs
? vo_panscan
: 0;
142 vo_panscan_x
= vo_panscan_area
* vo_panscan_amount
* aspdat
.asp
;
143 vo_panscan_y
= vo_panscan_area
* vo_panscan_amount
;