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;
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) {
161 perror(argv[optind]);
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++) {
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) {
int getopt(int argc, argv, char *optstring)
static unsigned char blue[256]
static unsigned char green[256]
static unsigned char red[256]