39 static char rcsid[] =
"$Header: /l/spencer/src/urt/cnv/rletoabA62/RCS/rletoabA62.c,v 3.0.1.1 1992/04/30 14:15:19 spencer Exp $";
84 extern void rasterInit(
int fd,
int width,
int height);
85 extern void rasterRowGet(
unsigned char *red,
unsigned char *green,
unsigned char *blue);
86 extern void rasterDone(
void);
87 extern void filterY(
float *yVal,
float c0,
float c1,
float c2);
88 extern void filterIQ(
float *iqVal,
float c0,
float c1,
float c2,
int start,
int stride);
89 extern void dump1(
register yiq_t **raster,
int start);
90 extern void dump2(
register yiq_t **raster,
int start);
92 extern void rasterInit();
93 extern void rasterRowGet(), rasterDone();
94 extern void filterY();
95 extern void filterIQ();
111 float rTOy[256], gTOy[256], bTOy[256];
112 float rTOi[256], gTOi[256], bTOi[256];
113 float rTOq[256], gTOq[256], bTOq[256];
114 float *iVal, *yVal, *qVal, *tmpVal;
115 unsigned char *red, *green, *blue;
126 while ((c = getopt(argc, argv,
"Nn:f:w:h:d:D:b")) != EOF) {
156 fprintf(stderr,
"Usage: %s [-n] [-D debug-level] [file]\n", argv[0]);
160 if ((file = open(argv[
optind], 0)) == -1) {
185 red = (
unsigned char *) calloc(
Width,
sizeof *red);
186 green = (
unsigned char *) calloc(
Width,
sizeof *green);
187 blue = (
unsigned char *) calloc(
Width,
sizeof *blue);
189 tmpVal = (
float *) calloc(
Width + 8,
sizeof *yVal);
191 tmpVal = (
float *) calloc(
Width + 4,
sizeof *iVal);
193 tmpVal = (
float *) calloc(
Width + 4,
sizeof *qVal);
201 raster = (yiq_t **) calloc(
Height,
sizeof *raster);
202 for (i = 0; i <
Height; i++) {
203 raster[i] = (yiq_t *) calloc(
Width,
sizeof **raster);
211 for (i = 0; i < 256; i++) {
212 rTOy[i] = ((
float) i / 255.0 * 0.925 + 0.075) * 0.299;
213 gTOy[i] = ((
float) i / 255.0 * 0.925 + 0.075) * 0.587;
214 bTOy[i] = ((
float) i / 255.0 * 0.925 + 0.075) * 0.114;
216 rTOi[i] = ((
float) i / 255.0 * 0.925 + 0.075) * 0.596;
217 gTOi[i] = ((
float) i / 255.0 * 0.925 + 0.075) * -0.274;
218 bTOi[i] = ((
float) i / 255.0 * 0.925 + 0.075) * -0.322;
220 rTOq[i] = ((
float) i / 255.0 * 0.925 + 0.075) * 0.211;
221 gTOq[i] = ((
float) i / 255.0 * 0.925 + 0.075) * -0.523;
222 bTOq[i] = ((
float) i / 255.0 * 0.925 + 0.075) * 0.312;
229 for (i = 0; i <
Height; i++) {
230 rasterRowGet(red, green, blue);
231 yVal[-4] = yVal[-3] = yVal[-2] = yVal[-1] = 0;
232 iVal[-2] = iVal[-1] = 0;
233 qVal[-2] = qVal[-1] = 0;
243 for (j = 0; j <
Width; j++) {
247 yVal[j] = rTOy[r] + gTOy[g] + bTOy[b];
248 iVal[j] = rTOi[r] + gTOi[g] + bTOi[b];
249 qVal[j] = rTOq[r] + gTOq[g] + bTOq[b];
252 filterY(yVal, 0.62232, 0.21732, -0.02848);
253 filterIQ(iVal, 0.42354, 0.25308, 0.03515, 0, 2);
254 filterIQ(qVal, 0.34594, 0.25122, 0.07581, 1, 2);
260 for (j = 0; j <
Width; j++) {
261 raster[
Height - i - 1][j]
.y = yVal[j] * 140.0;
262 raster[
Height - i - 1][j]
.i = iVal[j] * 140.0;
263 raster[
Height - i - 1][j]
.q = qVal[j] * 140.0;
278 switch ((i +
Frame - 1) % 4 + 1) {
307 filterY(yVal, c0, c1, c2)
308 float *yVal, c0, c1, c2;
310 static float *m0 = NULL;
311 static float *m1 = NULL;
312 static float *m2 = NULL;
316 m0 = (
float *) calloc(
Width + 8,
sizeof(
float));
317 m1 = (
float *) calloc(
Width + 8,
sizeof(
float));
318 m2 = (
float *) calloc(
Width + 8,
sizeof(
float));
320 for (i = -4; i <
Width + 4; i++) {
321 m0[i] = c0 * yVal[i];
322 m1[i] = c1 * yVal[i];
323 m2[i] = c2 * yVal[i];
325 for (i = 0; i <
Width; i++) {
326 yVal[i] = m2[i - 4] + m1[i - 3] + m0[i - 2] + m1[i - 1] + m2[i];
345 filterIQ(iqVal, c0, c1, c2, start, stride)
346 float *iqVal, c0, c1, c2;
349 static float *m0 = NULL;
350 static float *m1 = NULL;
351 static float *m2 = NULL;
355 m0 = (
float *) calloc(
Width + 4,
sizeof(
float));
356 m1 = (
float *) calloc(
Width + 4,
sizeof(
float));
357 m2 = (
float *) calloc(
Width + 4,
sizeof(
float));
359 for (i = -2; i <
Width + 2; i++) {
360 m0[i] = c0 * iqVal[i];
361 m1[i] = c1 * iqVal[i];
362 m2[i] = c2 * iqVal[i];
364 for (i = start; i <
Width; i += stride) {
365 iqVal[i] = m2[i - 2] + m1[i - 1] + m0[i] + m1[i + 1] + m2[i + 2];
378 #define OUT(y, OP, iq) putc
((char) (raster[i][j + 0
].y OP raster[i][j + 0
].iq + 60
), stdout
);
381 register yiq_t **raster;
386 for (i = start; i <
Height; i += 4) {
387 for (j = 0; j <
Width; j += 4) {
388 putc((
char) (raster[i][j + 0]
.y + raster[i][j + 0]
.i + 60), stdout);
389 putc((
char) (raster[i][j + 1]
.y + raster[i][j + 1]
.q + 60), stdout);
390 putc((
char) (raster[i][j + 2]
.y - raster[i][j + 2]
.i + 60), stdout);
391 putc((
char) (raster[i][j + 3]
.y - raster[i][j + 3]
.q + 60), stdout);
393 for (j = 0; j <
Width; j += 4) {
394 putc((
char) (raster[i + 2][j + 0]
.y - raster[i + 2][j + 0]
.i + 60), stdout);
395 putc((
char) (raster[i + 2][j + 1]
.y - raster[i + 2][j + 1]
.q + 60), stdout);
396 putc((
char) (raster[i + 2][j + 2]
.y + raster[i + 2][j + 2]
.i + 60), stdout);
397 putc((
char) (raster[i + 2][j + 3]
.y + raster[i + 2][j + 3]
.q + 60), stdout);
413 register yiq_t **raster;
418 for (i = start; i <
Height; i += 4) {
419 for (j = 0; j <
Width; j += 4) {
420 putc((
char) (raster[i][j + 0]
.y - raster[i][j + 0]
.i + 60), stdout);
421 putc((
char) (raster[i][j + 1]
.y - raster[i][j + 1]
.q + 60), stdout);
422 putc((
char) (raster[i][j + 2]
.y + raster[i][j + 2]
.i + 60), stdout);
423 putc((
char) (raster[i][j + 3]
.y + raster[i][j + 3]
.q + 60), stdout);
425 for (j = 0; j <
Width; j += 4) {
426 putc((
char) (raster[i + 2][j + 0]
.y + raster[i + 2][j + 0]
.i + 60), stdout);
427 putc((
char) (raster[i + 2][j + 1]
.y + raster[i + 2][j + 1]
.q + 60), stdout);
428 putc((
char) (raster[i + 2][j + 2]
.y - raster[i + 2][j + 2]
.i + 60), stdout);
429 putc((
char) (raster[i + 2][j + 3]
.y - raster[i + 2][j + 3]
.q + 60), stdout);
void main(int argc, char **argv)