annotate libvo/aspect.c @ 9229:334a2d73e612

extended teh soundcard table by max channels and max opens (concurrent playbacks), and added sb 128 pci, and moved GUS to the other GUSes
author arpi
date Sun, 02 Feb 2003 22:23:10 +0000
parents 7c28736ebf2c
children d4ec1e1c8dc8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2053
720ca9249e4e Monitor aspect stuff.
atmos4
parents:
diff changeset
1 /* Stuff for correct aspect scaling. */
2249
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
2 #include "aspect.h"
6087
8be92a9b30a4 Fix a bug in the aspect coden (roudning at wrong point) and allow donwscaling in second pass.
atmos4
parents: 2250
diff changeset
3 #ifndef ASPECT_TEST
8be92a9b30a4 Fix a bug in the aspect coden (roudning at wrong point) and allow donwscaling in second pass.
atmos4
parents: 2250
diff changeset
4 #include "../mp_msg.h"
8be92a9b30a4 Fix a bug in the aspect coden (roudning at wrong point) and allow donwscaling in second pass.
atmos4
parents: 2250
diff changeset
5 #endif
2249
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
6
2250
d7923c09dd46 Eeeh :) time to sleep!
atmos4
parents: 2249
diff changeset
7 //#define ASPECT_DEBUG
2071
7f27b212e07b Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents: 2058
diff changeset
8
6087
8be92a9b30a4 Fix a bug in the aspect coden (roudning at wrong point) and allow donwscaling in second pass.
atmos4
parents: 2250
diff changeset
9 #if defined(ASPECT_DEBUG) || defined(ASPECT_TEST)
2071
7f27b212e07b Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents: 2058
diff changeset
10 #include <stdio.h>
7f27b212e07b Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents: 2058
diff changeset
11 #endif
2053
720ca9249e4e Monitor aspect stuff.
atmos4
parents:
diff changeset
12
6307
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
13 int vo_panscan_x = 0;
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
14 int vo_panscan_y = 0;
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
15 float vo_panscan_amount = 0;
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
16
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
17 #include "video_out.h"
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
18
2053
720ca9249e4e Monitor aspect stuff.
atmos4
parents:
diff changeset
19 float monitor_aspect=4.0/3.0;
720ca9249e4e Monitor aspect stuff.
atmos4
parents:
diff changeset
20
2249
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
21 static struct {
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
22 int orgw; // real width
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
23 int orgh; // real height
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
24 int prew; // prescaled width
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
25 int preh; // prescaled height
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
26 int scrw; // horizontal resolution
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
27 int scrh; // vertical resolution
6307
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
28 float asp;
2249
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
29 } aspdat;
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
30
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
31 void aspect_save_orig(int orgw, int orgh){
8936
7c28736ebf2c debug++
atmos4
parents: 6382
diff changeset
32 #ifdef ASPECT_DEBUG
7c28736ebf2c debug++
atmos4
parents: 6382
diff changeset
33 printf("aspect_save_orig %dx%d \n",orgw,orgh);
7c28736ebf2c debug++
atmos4
parents: 6382
diff changeset
34 #endif
2249
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
35 aspdat.orgw = orgw;
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
36 aspdat.orgh = orgh;
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
37 }
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
38
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
39 void aspect_save_prescale(int prew, int preh){
8936
7c28736ebf2c debug++
atmos4
parents: 6382
diff changeset
40 #ifdef ASPECT_DEBUG
7c28736ebf2c debug++
atmos4
parents: 6382
diff changeset
41 printf("aspect_save_prescale %dx%d \n",prew,preh);
7c28736ebf2c debug++
atmos4
parents: 6382
diff changeset
42 #endif
2249
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
43 aspdat.prew = prew;
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
44 aspdat.preh = preh;
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
45 }
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
46
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
47 void aspect_save_screenres(int scrw, int scrh){
8936
7c28736ebf2c debug++
atmos4
parents: 6382
diff changeset
48 #ifdef ASPECT_DEBUG
7c28736ebf2c debug++
atmos4
parents: 6382
diff changeset
49 printf("aspect_save_screenres %dx%d \n",scrw,scrh);
7c28736ebf2c debug++
atmos4
parents: 6382
diff changeset
50 #endif
2249
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
51 aspdat.scrw = scrw;
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
52 aspdat.scrh = scrh;
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
53 }
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
54
2053
720ca9249e4e Monitor aspect stuff.
atmos4
parents:
diff changeset
55 /* aspect is called with the source resolution and the
720ca9249e4e Monitor aspect stuff.
atmos4
parents:
diff changeset
56 * resolution, that the scaled image should fit into
720ca9249e4e Monitor aspect stuff.
atmos4
parents:
diff changeset
57 */
720ca9249e4e Monitor aspect stuff.
atmos4
parents:
diff changeset
58
2249
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
59 void aspect(int *srcw, int *srch, int zoom){
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
60 int tmpw;
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
61
2071
7f27b212e07b Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents: 2058
diff changeset
62 #ifdef ASPECT_DEBUG
8936
7c28736ebf2c debug++
atmos4
parents: 6382
diff changeset
63 printf("aspect(0) fitin: %dx%d zoom: %d screenaspect: %.2f\n",aspdat.scrw,aspdat.scrh,
7c28736ebf2c debug++
atmos4
parents: 6382
diff changeset
64 zoom,monitor_aspect);
2249
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
65 printf("aspect(1) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat.prew,aspdat.preh);
2071
7f27b212e07b Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents: 2058
diff changeset
66 #endif
2249
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
67 if(zoom){
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
68 *srcw = aspdat.scrw;
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
69 *srch = (int)(((float)aspdat.scrw / (float)aspdat.prew * (float)aspdat.preh)
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
70 * ((float)aspdat.scrh / ((float)aspdat.scrw / monitor_aspect)));
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
71 }else{
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
72 *srcw = aspdat.prew;
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
73 *srch = (int)((float)aspdat.preh
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
74 * ((float)aspdat.scrh / ((float)aspdat.scrw / monitor_aspect)));
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
75 }
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
76 *srch+= *srch%2; // round
2071
7f27b212e07b Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents: 2058
diff changeset
77 #ifdef ASPECT_DEBUG
2249
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
78 printf("aspect(2) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat.prew,aspdat.preh);
2071
7f27b212e07b Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents: 2058
diff changeset
79 #endif
2249
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
80 if(*srch>aspdat.scrh || *srch<aspdat.orgh){
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
81 if(zoom)
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
82 tmpw = (int)(((float)aspdat.scrh / (float)aspdat.preh * (float)aspdat.prew)
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
83 * ((float)aspdat.scrw / ((float)aspdat.scrh / (1.0/monitor_aspect))));
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
84 else
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
85 tmpw = (int)((float)aspdat.prew
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
86 * ((float)aspdat.scrw / ((float)aspdat.scrh / (1.0/monitor_aspect))));
6087
8be92a9b30a4 Fix a bug in the aspect coden (roudning at wrong point) and allow donwscaling in second pass.
atmos4
parents: 2250
diff changeset
87 tmpw+= tmpw%2; // round
8be92a9b30a4 Fix a bug in the aspect coden (roudning at wrong point) and allow donwscaling in second pass.
atmos4
parents: 2250
diff changeset
88 if(tmpw<=aspdat.scrw /*&& tmpw>=aspdat.orgw*/){
2249
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
89 *srch = zoom?aspdat.scrh:aspdat.preh;
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
90 *srcw = tmpw;
6087
8be92a9b30a4 Fix a bug in the aspect coden (roudning at wrong point) and allow donwscaling in second pass.
atmos4
parents: 2250
diff changeset
91 }else{
8be92a9b30a4 Fix a bug in the aspect coden (roudning at wrong point) and allow donwscaling in second pass.
atmos4
parents: 2250
diff changeset
92 #ifndef ASPECT_TEST
8be92a9b30a4 Fix a bug in the aspect coden (roudning at wrong point) and allow donwscaling in second pass.
atmos4
parents: 2250
diff changeset
93 mp_msg(MSGT_VO,MSGL_WARN,"aspect: Warning: no suitable new res found!\n");
8be92a9b30a4 Fix a bug in the aspect coden (roudning at wrong point) and allow donwscaling in second pass.
atmos4
parents: 2250
diff changeset
94 #else
8be92a9b30a4 Fix a bug in the aspect coden (roudning at wrong point) and allow donwscaling in second pass.
atmos4
parents: 2250
diff changeset
95 printf("error: no new size found that fits into res!\n");
8be92a9b30a4 Fix a bug in the aspect coden (roudning at wrong point) and allow donwscaling in second pass.
atmos4
parents: 2250
diff changeset
96 #endif
2213
a98d5300f5e9 Add downscaling as a last resort.
atmos4
parents: 2071
diff changeset
97 }
2053
720ca9249e4e Monitor aspect stuff.
atmos4
parents:
diff changeset
98 }
6307
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
99 aspdat.asp=*srcw / (float)*srch;
2071
7f27b212e07b Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents: 2058
diff changeset
100 #ifdef ASPECT_DEBUG
2249
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2213
diff changeset
101 printf("aspect(3) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat.prew,aspdat.preh);
2071
7f27b212e07b Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents: 2058
diff changeset
102 #endif
2053
720ca9249e4e Monitor aspect stuff.
atmos4
parents:
diff changeset
103 }
720ca9249e4e Monitor aspect stuff.
atmos4
parents:
diff changeset
104
6307
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
105 void panscan_init( void )
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
106 {
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
107 vo_panscan_x=0;
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
108 vo_panscan_y=0;
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
109 vo_panscan_amount=0.0f;
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
110 }
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
111
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
112 void panscan_calc( void )
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
113 {
6382
86d5fc5b54e2 fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents: 6335
diff changeset
114 int fwidth,fheight;
86d5fc5b54e2 fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents: 6335
diff changeset
115 int vo_panscan_area;
86d5fc5b54e2 fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents: 6335
diff changeset
116
86d5fc5b54e2 fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents: 6335
diff changeset
117 aspect(&fwidth,&fheight,A_ZOOM);
86d5fc5b54e2 fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents: 6335
diff changeset
118 vo_panscan_area = (aspdat.scrh-fheight);
86d5fc5b54e2 fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents: 6335
diff changeset
119
6307
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
120 vo_panscan_amount = vo_fs ? vo_panscan : 0;
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
121 vo_panscan_x = vo_panscan_area * vo_panscan_amount * aspdat.asp;
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
122 vo_panscan_y = vo_panscan_area * vo_panscan_amount;
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
123 }
72c87b2ec779 added panscan support for xmga/xvidix
pontscho
parents: 6087
diff changeset
124