From 3e85b7e4fbc1e59ea78d5c9394e511b66337adfe Mon Sep 17 00:00:00 2001 From: atmos4 Date: Tue, 14 May 2002 00:22:03 +0000 Subject: [PATCH] Fix a bug in the aspect coden (roudning at wrong point) and allow donwscaling in second pass. Also add a testapp for the aspect code. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@6088 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/aspect.c | 15 ++++++++++++--- libvo/aspecttest.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 libvo/aspecttest.c diff --git a/libvo/aspect.c b/libvo/aspect.c index bafa2e15fb..463f3bfe09 100644 --- a/libvo/aspect.c +++ b/libvo/aspect.c @@ -1,9 +1,12 @@ /* Stuff for correct aspect scaling. */ #include "aspect.h" +#ifndef ASPECT_TEST +#include "../mp_msg.h" +#endif //#define ASPECT_DEBUG -#ifdef ASPECT_DEBUG +#if defined(ASPECT_DEBUG) || defined(ASPECT_TEST) #include #endif @@ -64,10 +67,16 @@ void aspect(int *srcw, int *srch, int zoom){ else tmpw = (int)((float)aspdat.prew * ((float)aspdat.scrw / ((float)aspdat.scrh / (1.0/monitor_aspect)))); - if(tmpw<=aspdat.scrw && tmpw>=aspdat.orgw){ + tmpw+= tmpw%2; // round + if(tmpw<=aspdat.scrw /*&& tmpw>=aspdat.orgw*/){ *srch = zoom?aspdat.scrh:aspdat.preh; *srcw = tmpw; - *srcw+= *srcw%2; // round + }else{ +#ifndef ASPECT_TEST + mp_msg(MSGT_VO,MSGL_WARN,"aspect: Warning: no suitable new res found!\n"); +#else + printf("error: no new size found that fits into res!\n"); +#endif } } #ifdef ASPECT_DEBUG diff --git a/libvo/aspecttest.c b/libvo/aspecttest.c new file mode 100644 index 0000000000..ef4fa5a453 --- /dev/null +++ b/libvo/aspecttest.c @@ -0,0 +1,43 @@ +/* testapp for aspect.[ch] by Atmos + * gcc aspecttest.c aspect.c -o aspecttest -DASPECT_TEST [-DASPECT_DEBUG] + */ + +#include + +#include "aspect.h" + +/* default zoom state 0 off, 1 on */ +#define DEF_ZOOM 1 + +extern float monitor_aspect; + +int main(int argc, char *argv[]) { + int w,h,z=DEF_ZOOM; + //printf("argc: %d\n",argc); + switch(argc) { + case 10: + z = atoi(argv[9]); + case 9: + monitor_aspect = (float)atoi(argv[7])/(float)atoi(argv[8]); + case 7: + aspect_save_prescale(atoi(argv[5]),atoi(argv[6])); + printf("prescale size: %sx%s\n",argv[5],argv[6]); + case 5: + aspect_save_screenres(atoi(argv[1]),atoi(argv[2])); + printf("screenres: %sx%s\n",argv[1],argv[2]); + aspect_save_orig(atoi(argv[3]),atoi(argv[4])); + printf("original size: %sx%s\n",argv[3],argv[4]); + w=atoi(argv[3]); h=atoi(argv[4]); + break; + default: + printf("USAGE: %s \n[ " + "] [ ] []\n", + argv[0]); + return 1; + } + printf("monitor_aspect: %f\n",monitor_aspect); + aspect(&w,&h,z); + printf("new size: %dx%d\n",w,h); + return 0; +} +