2001-10-03 14:41:53 +00:00
|
|
|
/* Stuff for correct aspect scaling. */
|
2001-10-18 02:42:20 +00:00
|
|
|
#include "aspect.h"
|
2003-10-15 15:17:09 +00:00
|
|
|
#include "geometry.h"
|
2006-04-24 04:23:53 +00:00
|
|
|
//#ifndef ASPECT_TEST
|
2004-10-28 01:15:53 +00:00
|
|
|
#include "mp_msg.h"
|
2006-11-08 14:55:37 +00:00
|
|
|
#include "help_mp.h"
|
2006-04-24 04:23:53 +00:00
|
|
|
//#endif
|
2001-10-18 02:42:20 +00:00
|
|
|
|
2001-10-18 02:43:33 +00:00
|
|
|
//#define ASPECT_DEBUG
|
2001-10-04 11:42:21 +00:00
|
|
|
|
2002-05-14 00:22:03 +00:00
|
|
|
#if defined(ASPECT_DEBUG) || defined(ASPECT_TEST)
|
2001-10-04 11:42:21 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#endif
|
2001-10-03 14:41:53 +00:00
|
|
|
|
2002-06-05 19:35:54 +00:00
|
|
|
int vo_panscan_x = 0;
|
|
|
|
int vo_panscan_y = 0;
|
|
|
|
float vo_panscan_amount = 0;
|
2005-09-27 08:32:37 +00:00
|
|
|
float vo_panscanrange = 1.0;
|
2002-06-05 19:35:54 +00:00
|
|
|
|
|
|
|
#include "video_out.h"
|
|
|
|
|
2007-07-28 22:42:20 +00:00
|
|
|
float force_monitor_aspect=0;
|
2007-04-27 23:16:45 +00:00
|
|
|
float monitor_aspect=0;
|
|
|
|
float monitor_pixel_aspect=1;
|
2003-09-21 11:56:09 +00:00
|
|
|
extern float movie_aspect;
|
2001-10-03 14:41:53 +00:00
|
|
|
|
2001-10-18 02:42:20 +00:00
|
|
|
static struct {
|
|
|
|
int orgw; // real width
|
|
|
|
int orgh; // real height
|
|
|
|
int prew; // prescaled width
|
|
|
|
int preh; // prescaled height
|
|
|
|
int scrw; // horizontal resolution
|
|
|
|
int scrh; // vertical resolution
|
2002-06-05 19:35:54 +00:00
|
|
|
float asp;
|
2001-10-18 02:42:20 +00:00
|
|
|
} aspdat;
|
|
|
|
|
|
|
|
void aspect_save_orig(int orgw, int orgh){
|
2003-01-13 01:50:20 +00:00
|
|
|
#ifdef ASPECT_DEBUG
|
|
|
|
printf("aspect_save_orig %dx%d \n",orgw,orgh);
|
|
|
|
#endif
|
2001-10-18 02:42:20 +00:00
|
|
|
aspdat.orgw = orgw;
|
|
|
|
aspdat.orgh = orgh;
|
|
|
|
}
|
|
|
|
|
|
|
|
void aspect_save_prescale(int prew, int preh){
|
2003-01-13 01:50:20 +00:00
|
|
|
#ifdef ASPECT_DEBUG
|
|
|
|
printf("aspect_save_prescale %dx%d \n",prew,preh);
|
|
|
|
#endif
|
2001-10-18 02:42:20 +00:00
|
|
|
aspdat.prew = prew;
|
|
|
|
aspdat.preh = preh;
|
|
|
|
}
|
|
|
|
|
|
|
|
void aspect_save_screenres(int scrw, int scrh){
|
2003-01-13 01:50:20 +00:00
|
|
|
#ifdef ASPECT_DEBUG
|
|
|
|
printf("aspect_save_screenres %dx%d \n",scrw,scrh);
|
|
|
|
#endif
|
2001-10-18 02:42:20 +00:00
|
|
|
aspdat.scrw = scrw;
|
|
|
|
aspdat.scrh = scrh;
|
2007-07-28 22:42:20 +00:00
|
|
|
if (force_monitor_aspect)
|
|
|
|
monitor_aspect = force_monitor_aspect;
|
|
|
|
else
|
2006-04-15 20:50:33 +00:00
|
|
|
monitor_aspect = monitor_pixel_aspect * scrw / scrh;
|
2001-10-18 02:42:20 +00:00
|
|
|
}
|
|
|
|
|
2001-10-03 14:41:53 +00:00
|
|
|
/* aspect is called with the source resolution and the
|
|
|
|
* resolution, that the scaled image should fit into
|
|
|
|
*/
|
|
|
|
|
2001-10-18 02:42:20 +00:00
|
|
|
void aspect(int *srcw, int *srch, int zoom){
|
|
|
|
int tmpw;
|
|
|
|
|
2003-10-15 15:17:09 +00:00
|
|
|
if( !zoom && geometry_wh_changed ) {
|
2003-09-21 15:34:51 +00:00
|
|
|
#ifdef ASPECT_DEBUG
|
|
|
|
printf("aspect(0) no aspect forced!\n");
|
|
|
|
#endif
|
2003-10-04 17:29:08 +00:00
|
|
|
return; // the user doesn't want to fix aspect
|
2003-09-21 15:34:51 +00:00
|
|
|
}
|
2003-10-15 15:17:09 +00:00
|
|
|
|
2001-10-04 11:42:21 +00:00
|
|
|
#ifdef ASPECT_DEBUG
|
2003-01-13 01:50:20 +00:00
|
|
|
printf("aspect(0) fitin: %dx%d zoom: %d screenaspect: %.2f\n",aspdat.scrw,aspdat.scrh,
|
|
|
|
zoom,monitor_aspect);
|
2001-10-18 02:42:20 +00:00
|
|
|
printf("aspect(1) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat.prew,aspdat.preh);
|
2001-10-04 11:42:21 +00:00
|
|
|
#endif
|
2001-10-18 02:42:20 +00:00
|
|
|
if(zoom){
|
|
|
|
*srcw = aspdat.scrw;
|
|
|
|
*srch = (int)(((float)aspdat.scrw / (float)aspdat.prew * (float)aspdat.preh)
|
|
|
|
* ((float)aspdat.scrh / ((float)aspdat.scrw / monitor_aspect)));
|
|
|
|
}else{
|
|
|
|
*srcw = aspdat.prew;
|
|
|
|
*srch = (int)((float)aspdat.preh
|
|
|
|
* ((float)aspdat.scrh / ((float)aspdat.scrw / monitor_aspect)));
|
|
|
|
}
|
|
|
|
*srch+= *srch%2; // round
|
2001-10-04 11:42:21 +00:00
|
|
|
#ifdef ASPECT_DEBUG
|
2001-10-18 02:42:20 +00:00
|
|
|
printf("aspect(2) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat.prew,aspdat.preh);
|
2001-10-04 11:42:21 +00:00
|
|
|
#endif
|
2001-10-18 02:42:20 +00:00
|
|
|
if(*srch>aspdat.scrh || *srch<aspdat.orgh){
|
|
|
|
if(zoom)
|
|
|
|
tmpw = (int)(((float)aspdat.scrh / (float)aspdat.preh * (float)aspdat.prew)
|
|
|
|
* ((float)aspdat.scrw / ((float)aspdat.scrh / (1.0/monitor_aspect))));
|
|
|
|
else
|
|
|
|
tmpw = (int)((float)aspdat.prew
|
|
|
|
* ((float)aspdat.scrw / ((float)aspdat.scrh / (1.0/monitor_aspect))));
|
2002-05-14 00:22:03 +00:00
|
|
|
tmpw+= tmpw%2; // round
|
|
|
|
if(tmpw<=aspdat.scrw /*&& tmpw>=aspdat.orgw*/){
|
2001-10-18 02:42:20 +00:00
|
|
|
*srch = zoom?aspdat.scrh:aspdat.preh;
|
|
|
|
*srcw = tmpw;
|
2002-05-14 00:22:03 +00:00
|
|
|
}else{
|
|
|
|
#ifndef ASPECT_TEST
|
2006-11-08 14:55:37 +00:00
|
|
|
mp_msg(MSGT_VO,MSGL_WARN,MSGTR_LIBVO_ASPECT_NoSuitableNewResFound);
|
2002-05-14 00:22:03 +00:00
|
|
|
#else
|
2006-11-08 14:55:37 +00:00
|
|
|
mp_msg(MSGT_VO,MSGL_WARN,MSGTR_LIBVO_ASPECT_NoNewSizeFoundThatFitsIntoRes);
|
2002-05-14 00:22:03 +00:00
|
|
|
#endif
|
2001-10-15 17:22:41 +00:00
|
|
|
}
|
2001-10-03 14:41:53 +00:00
|
|
|
}
|
2002-06-05 19:35:54 +00:00
|
|
|
aspdat.asp=*srcw / (float)*srch;
|
2001-10-04 11:42:21 +00:00
|
|
|
#ifdef ASPECT_DEBUG
|
2001-10-18 02:42:20 +00:00
|
|
|
printf("aspect(3) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat.prew,aspdat.preh);
|
2001-10-04 11:42:21 +00:00
|
|
|
#endif
|
2001-10-03 14:41:53 +00:00
|
|
|
}
|
|
|
|
|
2002-06-05 19:35:54 +00:00
|
|
|
void panscan_init( void )
|
|
|
|
{
|
|
|
|
vo_panscan_x=0;
|
|
|
|
vo_panscan_y=0;
|
|
|
|
vo_panscan_amount=0.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
void panscan_calc( void )
|
|
|
|
{
|
2002-06-10 18:40:19 +00:00
|
|
|
int fwidth,fheight;
|
|
|
|
int vo_panscan_area;
|
|
|
|
|
2005-09-27 08:32:37 +00:00
|
|
|
if (vo_panscanrange > 0) {
|
2008-01-19 18:10:06 +00:00
|
|
|
aspect(&fwidth,&fheight,A_ZOOM);
|
|
|
|
vo_panscan_area = (aspdat.scrh-fheight);
|
2005-09-27 08:32:37 +00:00
|
|
|
vo_panscan_area *= vo_panscanrange;
|
|
|
|
} else
|
|
|
|
vo_panscan_area = -vo_panscanrange * aspdat.scrh;
|
2002-06-10 18:40:19 +00:00
|
|
|
|
2002-06-05 19:35:54 +00:00
|
|
|
vo_panscan_amount = vo_fs ? vo_panscan : 0;
|
|
|
|
vo_panscan_x = vo_panscan_area * vo_panscan_amount * aspdat.asp;
|
|
|
|
vo_panscan_y = vo_panscan_area * vo_panscan_amount;
|
|
|
|
}
|
|
|
|
|