Mercurial > mplayer.hg
view libvo/aspect.c @ 7743:a280cc3087ea
All right: The patch adresses two issues which I found, when I analyzed
the input from some DVDs with known subtitle-dropouts:
1. The packet-size at the beginning of the packet, which is used to
check, whether we got all fragments, is sometimes one byte too long. It
seems to be always padded to an even number, while the actual size can
be odd.
2. The original algorythm used to assemble the fragments relies on the
timestamps to check, whether a new packet begins. This has proven to be
unrelieable on some disks. So instead, I use the timestamp only to
check, whether it's been too long (defined as 0,01sec) since the last
fragment, which is probably indicating a broken packet, and normaly
starting a new packet when the last one has been finished.
patch by Christof Buergi <christof@buergi.lugs.ch>
author | arpi |
---|---|
date | Tue, 15 Oct 2002 00:47:17 +0000 |
parents | 86d5fc5b54e2 |
children | 7c28736ebf2c |
line wrap: on
line source
/* Stuff for correct aspect scaling. */ #include "aspect.h" #ifndef ASPECT_TEST #include "../mp_msg.h" #endif //#define ASPECT_DEBUG #if defined(ASPECT_DEBUG) || defined(ASPECT_TEST) #include <stdio.h> #endif int vo_panscan_x = 0; int vo_panscan_y = 0; float vo_panscan_amount = 0; #include "video_out.h" float monitor_aspect=4.0/3.0; 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 float asp; } aspdat; void aspect_save_orig(int orgw, int orgh){ aspdat.orgw = orgw; aspdat.orgh = orgh; } void aspect_save_prescale(int prew, int preh){ aspdat.prew = prew; aspdat.preh = preh; } void aspect_save_screenres(int scrw, int scrh){ aspdat.scrw = scrw; aspdat.scrh = scrh; } /* aspect is called with the source resolution and the * resolution, that the scaled image should fit into */ void aspect(int *srcw, int *srch, int zoom){ int tmpw; #ifdef ASPECT_DEBUG printf("aspect(0) fitin: %dx%d zoom: %d \n",aspdat.scrw,aspdat.scrh,zoom); printf("aspect(1) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat.prew,aspdat.preh); #endif 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 #ifdef ASPECT_DEBUG printf("aspect(2) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat.prew,aspdat.preh); #endif 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)))); tmpw+= tmpw%2; // round if(tmpw<=aspdat.scrw /*&& tmpw>=aspdat.orgw*/){ *srch = zoom?aspdat.scrh:aspdat.preh; *srcw = tmpw; }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 } } aspdat.asp=*srcw / (float)*srch; #ifdef ASPECT_DEBUG printf("aspect(3) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat.prew,aspdat.preh); #endif } void panscan_init( void ) { vo_panscan_x=0; vo_panscan_y=0; vo_panscan_amount=0.0f; } void panscan_calc( void ) { int fwidth,fheight; int vo_panscan_area; aspect(&fwidth,&fheight,A_ZOOM); vo_panscan_area = (aspdat.scrh-fheight); 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; }