2 Copyright 2006 Chris Tallon
4 This file is part of VOMP.
6 VOMP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 VOMP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with VOMP; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 void Wwss::setFormat(UCHAR tformat)
37 UINT Wwss::gcd(UINT a, UINT b)
49 UINT Wwss::lcm(UINT a, UINT b)
51 return (a / gcd(a, b)) * b;
54 void Wwss::setWide(bool twide)
61 if (format == Video::PAL) drawPAL();
62 // else if (format == Video::NTSC) drawNTSC();
67 // The aspect43 and aspect169 codes are not what they should be according to the docs, but these are what work...
68 // (1 = 111000, = 0 000111)
69 static UCHAR runIn[] = {1,1,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1}; // 29 pos 0
70 static UCHAR startCode[] = {0,0,0,1,1,1,1,0,0,0,1,1,1,1,0,0,0,0,0,1,1,1,1,1}; // 24 pos 29
71 static UCHAR aspect43[] = {0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,1,1,1,0,0,0}; // = 0001 4:3 full frame // 24 pos 53
72 static UCHAR aspect169[] = {1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,0,0,0,1,1,1}; // = 1110 16:9 anamorphic // 24 pos 53
73 static UCHAR theRest[] = {0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1, // 60 pos 77
74 0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,
75 0,0,0,1,1,1,0,0,0,1,1,1};
77 Real PAL pixel frequency: 13.5 MHz
78 WSS element frequency: 5 MHz
79 = 2.7 pal pixels per wss element
80 * 137 wss elements = 369.9 pal pixels (total code width) (round to 370..)
82 There is also a 11us gap at the start of the pal raster, but since I don't really have any
83 idea where our 720 pixels start in the raster I can't calculate an offset.
85 PAL line 23 seems to be MVP line 6.
88 const UINT Ns = 137; // Num pix src
89 const UINT Nd = 370; // Num pix dst 359->395 does something. not the right thing, but something.
90 UINT Nl = lcm(Ns, Nd); // Num pix in lcm
91 UINT Ss = Nl / Ns; // Source split (how many lcm px = 1 src px)
92 UINT Sd = Nl / Nd; // Dst split
95 memcpy(&src[0], runIn, 29);
96 memcpy(&src[29], startCode, 24);
97 if (wide) memcpy(&src[53], aspect169, 24);
98 else memcpy(&src[53], aspect43, 24);
99 memcpy(&src[77], theRest, 60);
104 for(UINT t = 0; t < Nd; t++) // for every destination pixel
107 for(UINT lcmpx = lcmpxbase; lcmpx < (lcmpxbase + Sd); lcmpx++)
109 if (src[lcmpx / Ss]) dst[t] += (float)1/Sd;
117 for(UINT q = 0; q < Nd; q++)
119 value = (UINT)(dst[q] * 182); // Apparently this is a better number than 255 for the colour value
120 c.set(value, value, value);
125 void Wwss::drawNTSC()
128 static UCHAR startCode[] = {1,0,0,0,0,0,0};
129 static UCHAR aspect43[] = {0};
130 static UCHAR aspect169[] = {1};
131 static UCHAR theRest[] = {0,0,0,0,0,0,0,0};
132 static UCHAR crc43[] = {0,0,0,0,0,0};
133 static UCHAR crc169[] = {0,0,1,1,0,0};
136 Real NTSC pixel frequency: 13.5 MHz
137 WSS bit frequency: 447.443125 kHz
138 = 30.1714 NTSC pixels per wss bit
139 * 22 wss bits = 663.7715 NTSC pixels (total code width) (round to 664..)
141 There is also a 11.2us gap at the start of the pal raster, but since I don't really have any
142 idea where our 720 pixels start in the raster I can't calculate an offset.
144 PAL line 23 seems to be MVP line 6.
147 const UINT Ns = 22; // Num pix src
148 const UINT Nd = 664; // Num pix dst
149 // const UINT Nd = 518; // Num pix dst
150 UINT Nl = lcm(Ns, Nd); // Num pix in lcm
151 UINT Ss = Nl / Ns; // Source split (how many lcm px = 1 src px)
152 UINT Sd = Nl / Nd; // Dst split
156 memcpy(&src[0], startCode, 7);
157 if (wide) memcpy(&src[7], aspect169, 1);
158 else memcpy(&src[7], aspect43, 1);
159 memcpy(&src[8], theRest, 8);
160 if (wide) memcpy(&src[16], crc169, 6);
161 else memcpy(&src[16], crc43, 6);
164 static UCHAR src[22] = {1,0, 0,0,0,0,1,1, 0,0,0,0, 0,0,0,0, 0,0,1,0,0,1 };
170 for(UINT t = 0; t < Nd; t++) // for every destination pixel
173 for(UINT lcmpx = lcmpxbase; lcmpx < (lcmpxbase + Sd); lcmpx++)
175 if (src[lcmpx / Ss]) dst[t] += (float)1/Sd;
183 // This one is the real one
185 for(UINT q = 0; q < Nd; q++)
187 value = (UINT)(dst[q] * 182); // Apparently this is a better number than 255 for the colour value
188 c.set(value, value, value);
193 // This one is testing active
194 for(int yy = 0; yy < 100; yy++)
196 for(UINT q = 0; q < Nd; q++)
198 value = (UINT)(dst[q] * 182); // Apparently this is a better number than 255 for the colour value
199 c.set(value, value, value);
200 drawPixel(q+0, yy, c);
211 1x6 + 0x5 + 0x4 + 0x3 + 0x2 + 1x1 + 1x0
218 static UCHAR startCode[] = {1,0};
219 static UCHAR aspect43[] = {0,0};
220 static UCHAR aspect169[] = {1,0};
221 static UCHAR theRest[] = {0,0,0,0,0,0,0,0,0,0,0,0};
222 static UCHAR crc43[] = {0,0,0,0,0,0};
223 static UCHAR crc169[] = {0,0,1,0,0,1};
229 Message 4:3 augmented
231 1000000000000000000000
238 Ho ho, polynomial long division. Yeeeeaaahhh I remember
239 doing *that*. Of course I do. If you know of a faster,
240 easier, more reliable way of doing this, please let me know.
244 ________________________
245 1000011 ) 1000000000000000000000
262 Message 4:3 augmented
264 1010000000000000000000
271 ________________________
272 1000011 ) 1010000000000000000000