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_fit(int *srcw
, int *srch
, int fitw
, int fith
){
73 printf("aspect(0) fitin: %dx%d screenaspect: %.2f\n",aspdat
.scrw
,aspdat
.scrh
,
75 printf("aspect(1) wh: %dx%d (org: %dx%d)\n",*srcw
,*srch
,aspdat
.prew
,aspdat
.preh
);
78 *srch
= (int)(((float)fitw
/ (float)aspdat
.prew
* (float)aspdat
.preh
)
79 * ((float)aspdat
.scrh
/ ((float)aspdat
.scrw
/ monitor_aspect
)));
80 *srch
+= *srch
%2; // round
82 printf("aspect(2) wh: %dx%d (org: %dx%d)\n",*srcw
,*srch
,aspdat
.prew
,aspdat
.preh
);
84 if(*srch
>aspdat
.scrh
|| *srch
<aspdat
.orgh
){
85 tmpw
= (int)(((float)fith
/ (float)aspdat
.preh
* (float)aspdat
.prew
)
86 * ((float)aspdat
.scrw
/ ((float)aspdat
.scrh
/ (1.0/monitor_aspect
))));
87 tmpw
+= tmpw
%2; // round
88 if(tmpw
<=aspdat
.scrw
/*&& tmpw>=aspdat.orgw*/){
93 mp_msg(MSGT_VO
,MSGL_WARN
,MSGTR_LIBVO_ASPECT_NoSuitableNewResFound
);
95 mp_msg(MSGT_VO
,MSGL_WARN
,MSGTR_LIBVO_ASPECT_NoNewSizeFoundThatFitsIntoRes
);
99 aspdat
.asp
=*srcw
/ (float)*srch
;
101 printf("aspect(3) wh: %dx%d (org: %dx%d)\n",*srcw
,*srch
,aspdat
.prew
,aspdat
.preh
);
105 void aspect(int *srcw
, int *srch
, int zoom
){
106 int fitw
= zoom
? aspdat
.scrw
: aspdat
.prew
;
107 int fith
= zoom
? aspdat
.scrh
: aspdat
.preh
;
108 if( !zoom
&& geometry_wh_changed
) {
110 printf("aspect(0) no aspect forced!\n");
112 return; // the user doesn't want to fix aspect
114 aspect_fit(srcw
, srch
, fitw
, fith
);
117 void panscan_init( void )
121 vo_panscan_amount
=0.0f
;
124 void panscan_calc( void )
129 if (vo_panscanrange
> 0) {
130 aspect(&fwidth
,&fheight
,A_ZOOM
);
131 vo_panscan_area
= (aspdat
.scrh
-fheight
);
132 if (!vo_panscan_area
)
133 vo_panscan_area
= aspdat
.scrw
- fwidth
;
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
;