1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-27 01:22:30 +00:00

VO: clean up aspect.c, remove aspecttest tool

Clean up aspect.c code and simplify it somewhat (without changing the
overall logic). Replace debug output printf calls under #ifdef with
mp_msg() debug output (somewhat modified).

Remove the file aspecttest.c which created a binary to test aspect.c
functionality. It did not compile and would not be particularly useful
anyway. Remove some support lines from aspect.c and Makefile.
This commit is contained in:
Uoti Urpala 2011-07-05 00:26:14 +03:00
parent 8ff5b2b889
commit 677e78f278
3 changed files with 44 additions and 136 deletions

View File

@ -752,14 +752,12 @@ codec-cfg-test$(EXESUF): codec-cfg.c codecs.conf.h $(TEST_OBJS)
codecs2html$(EXESUF): codec-cfg.c $(TEST_OBJS)
$(CC) -I. -DCODECS2HTML -o $@ $^
libvo/aspecttest$(EXESUF): libvo/aspect.o libvo/geometry.o $(TEST_OBJS)
LOADER_TEST_OBJS = $(SRCS_WIN32_EMULATION:.c=.o) $(SRCS_QTX_EMULATION:.S=.o) libavutil/libavutil.a osdep/mmap_anon.o cpudetect.o path.o $(TEST_OBJS)
loader/qtx/list$(EXESUF) loader/qtx/qtxload$(EXESUF): CFLAGS += -g
loader/qtx/list$(EXESUF) loader/qtx/qtxload$(EXESUF): $(LOADER_TEST_OBJS)
TESTS = codecs2html codec-cfg-test libvo/aspecttest
TESTS = codecs2html codec-cfg-test
ifdef ARCH_X86
TESTS += loader/qtx/list loader/qtx/qtxload

View File

@ -20,42 +20,28 @@
#include "aspect.h"
#include "geometry.h"
#include "video_out.h"
//#ifndef ASPECT_TEST
#include "mp_msg.h"
#include "options.h"
//#endif
//#define ASPECT_DEBUG
#if defined(ASPECT_DEBUG) || defined(ASPECT_TEST)
#include <stdio.h>
#endif
#include "video_out.h"
void aspect_save_orig(struct vo *vo, int orgw, int orgh)
{
#ifdef ASPECT_DEBUG
printf("aspect_save_orig %dx%d \n",orgw,orgh);
#endif
mp_msg(MSGT_VO, MSGL_DBG2, "aspect_save_orig %dx%d\n", orgw, orgh);
vo->aspdat.orgw = orgw;
vo->aspdat.orgh = orgh;
}
void aspect_save_prescale(struct vo *vo, int prew, int preh)
{
#ifdef ASPECT_DEBUG
printf("aspect_save_prescale %dx%d \n",prew,preh);
#endif
mp_msg(MSGT_VO, MSGL_DBG2, "aspect_save_prescale %dx%d\n", prew, preh);
vo->aspdat.prew = prew;
vo->aspdat.preh = preh;
}
void aspect_save_screenres(struct vo *vo, int scrw, int scrh)
{
#ifdef ASPECT_DEBUG
printf("aspect_save_screenres %dx%d \n",scrw,scrh);
#endif
mp_msg(MSGT_VO, MSGL_DBG2, "aspect_save_screenres %dx%d\n", scrw, scrh);
struct MPOpts *opts = vo->opts;
if (scrw <= 0 && scrh <= 0)
scrw = 1024;
@ -78,39 +64,29 @@ void aspect_save_screenres(struct vo *vo, int scrw, int scrh)
void aspect_fit(struct vo *vo, int *srcw, int *srch, int fitw, int fith)
{
struct aspect_data *aspdat = &vo->aspdat;
int tmpw;
float pixelaspect = vo->monitor_aspect * aspdat->scrh / aspdat->scrw;
#ifdef ASPECT_DEBUG
printf("aspect(0) fitin: %dx%d screenaspect: %.2f\n",aspdat->scrw,aspdat->scrh,
monitor_aspect);
printf("aspect(1) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat->prew,aspdat->preh);
#endif
mp_msg(MSGT_VO, MSGL_DBG2, "aspect(0) fitin: %dx%d screenaspect: %.2f\n",
fitw, fith, vo->monitor_aspect);
*srcw = fitw;
*srch = (int)(((float)fitw / (float)aspdat->prew * (float)aspdat->preh)
* ((float)aspdat->scrh / ((float)aspdat->scrw / vo->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>fith || *srch<aspdat->orgh){
tmpw = (int)(((float)fith / (float)aspdat->preh * (float)aspdat->prew)
* ((float)aspdat->scrw / ((float)aspdat->scrh / (1.0/vo->monitor_aspect))));
tmpw+= tmpw%2; // round
if(tmpw<=fitw /*&& tmpw>=aspdat->orgw*/){
*srch = (float)fitw / aspdat->prew * aspdat->preh * pixelaspect;
*srch += *srch % 2; // round
mp_msg(MSGT_VO, MSGL_DBG2, "aspect(1) wh: %dx%d (org: %dx%d)\n",
*srcw, *srch, aspdat->prew, aspdat->preh);
if (*srch > fith || *srch < aspdat->orgh) {
int tmpw = (float)fith / aspdat->preh * aspdat->prew / pixelaspect;
tmpw += tmpw % 2; // round
if (tmpw <= fitw) {
*srch = fith;
*srcw = tmpw;
}else{
#ifndef ASPECT_TEST
mp_tmsg(MSGT_VO,MSGL_WARN,"[ASPECT] Warning: No suitable new res found!\n");
#else
mp_tmsg(MSGT_VO,MSGL_WARN,"[ASPECT] Error: No new size found that fits into res!\n");
#endif
} else {
mp_tmsg(MSGT_VO, MSGL_WARN,
"[ASPECT] Warning: No suitable new res found!\n");
}
}
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
aspdat->asp = *srcw / (float)*srch;
mp_msg(MSGT_VO, MSGL_DBG2, "aspect(2) wh: %dx%d (org: %dx%d)\n",
*srcw, *srch, aspdat->prew, aspdat->preh);
}
static void get_max_dims(struct vo *vo, int *w, int *h, int zoom)
@ -118,7 +94,8 @@ static void get_max_dims(struct vo *vo, int *w, int *h, int zoom)
struct aspect_data *aspdat = &vo->aspdat;
*w = zoom ? aspdat->scrw : aspdat->prew;
*h = zoom ? aspdat->scrh : aspdat->preh;
if (zoom && WinID >= 0) zoom = A_WINZOOM;
if (zoom && WinID >= 0)
zoom = A_WINZOOM;
if (zoom == A_WINZOOM) {
*w = vo->dwidth;
*h = vo->dheight;
@ -130,10 +107,8 @@ void aspect(struct vo *vo, int *srcw, int *srch, int zoom)
int fitw;
int fith;
get_max_dims(vo, &fitw, &fith, zoom);
if( !zoom && geometry_wh_changed ) {
#ifdef ASPECT_DEBUG
printf("aspect(0) no aspect forced!\n");
#endif
if (!zoom && geometry_wh_changed) {
mp_msg(MSGT_VO, MSGL_DBG2, "aspect(0) no aspect forced!\n");
return; // the user doesn't want to fix aspect
}
aspect_fit(vo, srcw, srch, fitw, fith);
@ -148,7 +123,7 @@ void panscan_init(struct vo *vo)
static void panscan_calc_internal(struct vo *vo, int zoom)
{
int fwidth,fheight;
int fwidth, fheight;
int vo_panscan_area;
int max_w, max_h;
get_max_dims(vo, &max_w, &max_h, zoom);

View File

@ -1,65 +0,0 @@
/*
* test app for aspect.[ch] by Atmos
*
* This file is part of MPlayer.
*
* MPlayer is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* MPlayer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "aspect.h"
/* default zoom state 0 off, 1 on */
#define DEF_ZOOM 1
extern float monitor_aspect;
int vo_dheight;
int vo_dwidth;
int vo_fs;
float vo_panscan;
int64_t WinID = -1;
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 <screenw> <screenh> <origw> <origh>\n[<prescalew> "
"<prescaleh>] [<screenaspectw> <screenaspecth>] [<zoom 0/1>]\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;
}