Make aspect adjustment calculation simpler and more flexible.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@25949 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
reimar 2008-02-02 17:21:19 +00:00
parent a2670cc5a4
commit 949787e410
1 changed files with 19 additions and 24 deletions

View File

@ -66,44 +66,27 @@ void aspect_save_screenres(int scrw, int scrh){
* resolution, that the scaled image should fit into * resolution, that the scaled image should fit into
*/ */
void aspect(int *srcw, int *srch, int zoom){ void aspect_fit(int *srcw, int *srch, int fitw, int fith){
int tmpw; int tmpw;
if( !zoom && geometry_wh_changed ) {
#ifdef ASPECT_DEBUG #ifdef ASPECT_DEBUG
printf("aspect(0) no aspect forced!\n"); printf("aspect(0) fitin: %dx%d screenaspect: %.2f\n",aspdat.scrw,aspdat.scrh,
#endif monitor_aspect);
return; // the user doesn't want to fix aspect
}
#ifdef ASPECT_DEBUG
printf("aspect(0) fitin: %dx%d zoom: %d screenaspect: %.2f\n",aspdat.scrw,aspdat.scrh,
zoom,monitor_aspect);
printf("aspect(1) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat.prew,aspdat.preh); printf("aspect(1) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat.prew,aspdat.preh);
#endif #endif
if(zoom){ *srcw = fitw;
*srcw = aspdat.scrw; *srch = (int)(((float)fitw / (float)aspdat.prew * (float)aspdat.preh)
*srch = (int)(((float)aspdat.scrw / (float)aspdat.prew * (float)aspdat.preh)
* ((float)aspdat.scrh / ((float)aspdat.scrw / monitor_aspect))); * ((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 *srch+= *srch%2; // round
#ifdef ASPECT_DEBUG #ifdef ASPECT_DEBUG
printf("aspect(2) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat.prew,aspdat.preh); printf("aspect(2) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat.prew,aspdat.preh);
#endif #endif
if(*srch>aspdat.scrh || *srch<aspdat.orgh){ if(*srch>aspdat.scrh || *srch<aspdat.orgh){
if(zoom) tmpw = (int)(((float)fith / (float)aspdat.preh * (float)aspdat.prew)
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)))); * ((float)aspdat.scrw / ((float)aspdat.scrh / (1.0/monitor_aspect))));
tmpw+= tmpw%2; // round tmpw+= tmpw%2; // round
if(tmpw<=aspdat.scrw /*&& tmpw>=aspdat.orgw*/){ if(tmpw<=aspdat.scrw /*&& tmpw>=aspdat.orgw*/){
*srch = zoom?aspdat.scrh:aspdat.preh; *srch = fith;
*srcw = tmpw; *srcw = tmpw;
}else{ }else{
#ifndef ASPECT_TEST #ifndef ASPECT_TEST
@ -119,6 +102,18 @@ void aspect(int *srcw, int *srch, int zoom){
#endif #endif
} }
void aspect(int *srcw, int *srch, int zoom){
int fitw = zoom ? aspdat.scrw : aspdat.prew;
int fith = zoom ? aspdat.scrh : aspdat.preh;
if( !zoom && geometry_wh_changed ) {
#ifdef ASPECT_DEBUG
printf("aspect(0) no aspect forced!\n");
#endif
return; // the user doesn't want to fix aspect
}
aspect_fit(srcw, srch, fitw, fith);
}
void panscan_init( void ) void panscan_init( void )
{ {
vo_panscan_x=0; vo_panscan_x=0;