|
Blender
V2.59
|
00001 /* 00002 * $Id: sequencer_scopes.c 35971 2011-04-03 10:04:16Z campbellbarton $ 00003 * 00004 * ***** BEGIN GPL LICENSE BLOCK ***** 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software Foundation, 00018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 * 00020 * Author: Peter Schlaile < peter [at] schlaile [dot] de > 00021 * 00022 * ***** END GPL LICENSE BLOCK ***** 00023 * 00024 */ 00025 00031 #include <math.h> 00032 #include <string.h> 00033 00034 #include "BLI_utildefines.h" 00035 00036 00037 00038 #include "IMB_imbuf_types.h" 00039 #include "IMB_imbuf.h" 00040 00041 #include "sequencer_intern.h" 00042 00043 static void rgb_to_yuv(float rgb[3], float yuv[3]) 00044 { 00045 yuv[0]= 0.299f*rgb[0] + 0.587f*rgb[1] + 0.114f*rgb[2]; 00046 yuv[1]= 0.492f*(rgb[2] - yuv[0]); 00047 yuv[2]= 0.877f*(rgb[0] - yuv[0]); 00048 00049 /* Normalize */ 00050 yuv[1]*= 255.0f/(122*2.0f); 00051 yuv[1]+= 0.5f; 00052 00053 yuv[2]*= 255.0f/(157*2.0f); 00054 yuv[2]+= 0.5f; 00055 } 00056 00057 static void scope_put_pixel(unsigned char* table, unsigned char * pos) 00058 { 00059 char newval = table[*pos]; 00060 pos[0] = pos[1] = pos[2] = newval; 00061 pos[3] = 255; 00062 } 00063 00064 static void scope_put_pixel_single(unsigned char* table, unsigned char * pos, 00065 int col) 00066 { 00067 char newval = table[pos[col]]; 00068 pos[col] = newval; 00069 pos[3] = 255; 00070 } 00071 00072 static void wform_put_line(int w, 00073 unsigned char * last_pos, unsigned char * new_pos) 00074 { 00075 if (last_pos > new_pos) { 00076 unsigned char* temp = new_pos; 00077 new_pos = last_pos; 00078 last_pos = temp; 00079 } 00080 00081 while (last_pos < new_pos) { 00082 if (last_pos[0] == 0) { 00083 last_pos[0] = last_pos[1] = last_pos[2] = 32; 00084 last_pos[3] = 255; 00085 } 00086 last_pos += 4*w; 00087 } 00088 } 00089 00090 static void wform_put_line_single( 00091 int w, unsigned char * last_pos, unsigned char * new_pos, int col) 00092 { 00093 if (last_pos > new_pos) { 00094 unsigned char* temp = new_pos; 00095 new_pos = last_pos; 00096 last_pos = temp; 00097 } 00098 00099 while (last_pos < new_pos) { 00100 if (last_pos[col] == 0) { 00101 last_pos[col] = 32; 00102 last_pos[3] = 255; 00103 } 00104 last_pos += 4*w; 00105 } 00106 } 00107 00108 static void wform_put_border(unsigned char * tgt, int w, int h) 00109 { 00110 int x, y; 00111 00112 for (x = 0; x < w; x++) { 00113 unsigned char * p = tgt + 4 * x; 00114 p[1] = p[3] = 255.0; 00115 p[4 * w + 1] = p[4 * w + 3] = 255.0; 00116 p = tgt + 4 * (w * (h - 1) + x); 00117 p[1] = p[3] = 255.0; 00118 p[-4 * w + 1] = p[-4 * w + 3] = 255.0; 00119 } 00120 00121 for (y = 0; y < h; y++) { 00122 unsigned char * p = tgt + 4 * w * y; 00123 p[1] = p[3] = 255.0; 00124 p[4 + 1] = p[4 + 3] = 255.0; 00125 p = tgt + 4 * (w * y + w - 1); 00126 p[1] = p[3] = 255.0; 00127 p[-4 + 1] = p[-4 + 3] = 255.0; 00128 } 00129 } 00130 00131 static void wform_put_gridrow(unsigned char * tgt, float perc, int w, int h) 00132 { 00133 int i; 00134 00135 tgt += (int) (perc/100.0f * h) * w * 4; 00136 00137 for (i = 0; i < w*2; i++) { 00138 tgt[0] = 255; 00139 00140 tgt += 4; 00141 } 00142 } 00143 00144 static void wform_put_grid(unsigned char * tgt, int w, int h) 00145 { 00146 wform_put_gridrow(tgt, 90.0, w, h); 00147 wform_put_gridrow(tgt, 70.0, w, h); 00148 wform_put_gridrow(tgt, 10.0, w, h); 00149 } 00150 00151 static struct ImBuf *make_waveform_view_from_ibuf_byte(struct ImBuf * ibuf) 00152 { 00153 struct ImBuf * rval = IMB_allocImBuf(ibuf->x + 3, 515, 32, IB_rect); 00154 int x,y; 00155 unsigned char* src = (unsigned char*) ibuf->rect; 00156 unsigned char* tgt = (unsigned char*) rval->rect; 00157 int w = ibuf->x + 3; 00158 int h = 515; 00159 float waveform_gamma = 0.2; 00160 unsigned char wtable[256]; 00161 00162 wform_put_grid(tgt, w, h); 00163 00164 for (x = 0; x < 256; x++) { 00165 wtable[x] = (unsigned char) (pow(((float) x + 1)/256, 00166 waveform_gamma)*255); 00167 } 00168 00169 for (y = 0; y < ibuf->y; y++) { 00170 unsigned char * last_p = NULL; 00171 00172 for (x = 0; x < ibuf->x; x++) { 00173 unsigned char * rgb = src + 4 * (ibuf->x * y + x); 00174 float v = 1.0 * 00175 ( 0.299*rgb[0] 00176 + 0.587*rgb[1] 00177 + 0.114*rgb[2]) / 255.0; 00178 unsigned char * p = tgt; 00179 p += 4 * (w * ((int) (v * (h - 3)) + 1) + x + 1); 00180 00181 scope_put_pixel(wtable, p); 00182 p += 4 * w; 00183 scope_put_pixel(wtable, p); 00184 00185 if (last_p != NULL) { 00186 wform_put_line(w, last_p, p); 00187 } 00188 last_p = p; 00189 } 00190 } 00191 00192 wform_put_border(tgt, w, h); 00193 00194 return rval; 00195 } 00196 00197 static struct ImBuf *make_waveform_view_from_ibuf_float(struct ImBuf * ibuf) 00198 { 00199 struct ImBuf * rval = IMB_allocImBuf(ibuf->x + 3, 515, 32, IB_rect); 00200 int x,y; 00201 float* src = ibuf->rect_float; 00202 unsigned char* tgt = (unsigned char*) rval->rect; 00203 int w = ibuf->x + 3; 00204 int h = 515; 00205 float waveform_gamma = 0.2; 00206 unsigned char wtable[256]; 00207 00208 wform_put_grid(tgt, w, h); 00209 00210 for (x = 0; x < 256; x++) { 00211 wtable[x] = (unsigned char) (pow(((float) x + 1)/256, 00212 waveform_gamma)*255); 00213 } 00214 00215 for (y = 0; y < ibuf->y; y++) { 00216 unsigned char * last_p = NULL; 00217 00218 for (x = 0; x < ibuf->x; x++) { 00219 float * rgb = src + 4 * (ibuf->x * y + x); 00220 float v = 1.0f * 00221 ( 0.299f*rgb[0] 00222 + 0.587f*rgb[1] 00223 + 0.114f*rgb[2]); 00224 unsigned char * p = tgt; 00225 00226 CLAMP(v, 0.0f, 1.0f); 00227 00228 p += 4 * (w * ((int) (v * (h - 3)) + 1) + x + 1); 00229 00230 scope_put_pixel(wtable, p); 00231 p += 4 * w; 00232 scope_put_pixel(wtable, p); 00233 00234 if (last_p != NULL) { 00235 wform_put_line(w, last_p, p); 00236 } 00237 last_p = p; 00238 } 00239 } 00240 00241 wform_put_border(tgt, w, h); 00242 00243 return rval; 00244 } 00245 00246 struct ImBuf *make_waveform_view_from_ibuf(struct ImBuf * ibuf) 00247 { 00248 if (ibuf->rect_float) { 00249 return make_waveform_view_from_ibuf_float(ibuf); 00250 } else { 00251 return make_waveform_view_from_ibuf_byte(ibuf); 00252 } 00253 } 00254 00255 00256 static struct ImBuf *make_sep_waveform_view_from_ibuf_byte(struct ImBuf * ibuf) 00257 { 00258 struct ImBuf * rval = IMB_allocImBuf( 00259 ibuf->x + 3, 515, 32, IB_rect); 00260 int x,y; 00261 unsigned char* src = (unsigned char*) ibuf->rect; 00262 unsigned char* tgt = (unsigned char*) rval->rect; 00263 int w = ibuf->x + 3; 00264 int sw = ibuf->x/3; 00265 int h = 515; 00266 float waveform_gamma = 0.2; 00267 unsigned char wtable[256]; 00268 00269 wform_put_grid(tgt, w, h); 00270 00271 for (x = 0; x < 256; x++) { 00272 wtable[x] = (unsigned char) (pow(((float) x + 1)/256, 00273 waveform_gamma)*255); 00274 } 00275 00276 for (y = 0; y < ibuf->y; y++) { 00277 unsigned char *last_p[3] = {NULL, NULL, NULL}; 00278 00279 for (x = 0; x < ibuf->x; x++) { 00280 int c; 00281 unsigned char * rgb = src + 4 * (ibuf->x * y + x); 00282 for (c = 0; c < 3; c++) { 00283 unsigned char * p = tgt; 00284 p += 4 * (w * ((rgb[c] * (h - 3))/255 + 1) 00285 + c * sw + x/3 + 1); 00286 00287 scope_put_pixel_single(wtable, p, c); 00288 p += 4 * w; 00289 scope_put_pixel_single(wtable, p, c); 00290 00291 if (last_p[c] != NULL) { 00292 wform_put_line_single( 00293 w, last_p[c], p, c); 00294 } 00295 last_p[c] = p; 00296 } 00297 } 00298 } 00299 00300 wform_put_border(tgt, w, h); 00301 00302 return rval; 00303 } 00304 00305 static struct ImBuf *make_sep_waveform_view_from_ibuf_float( 00306 struct ImBuf * ibuf) 00307 { 00308 struct ImBuf * rval = IMB_allocImBuf( 00309 ibuf->x + 3, 515, 32, IB_rect); 00310 int x,y; 00311 float* src = ibuf->rect_float; 00312 unsigned char* tgt = (unsigned char*) rval->rect; 00313 int w = ibuf->x + 3; 00314 int sw = ibuf->x/3; 00315 int h = 515; 00316 float waveform_gamma = 0.2; 00317 unsigned char wtable[256]; 00318 00319 wform_put_grid(tgt, w, h); 00320 00321 for (x = 0; x < 256; x++) { 00322 wtable[x] = (unsigned char) (pow(((float) x + 1)/256, 00323 waveform_gamma)*255); 00324 } 00325 00326 for (y = 0; y < ibuf->y; y++) { 00327 unsigned char *last_p[3] = {NULL, NULL, NULL}; 00328 00329 for (x = 0; x < ibuf->x; x++) { 00330 int c; 00331 float * rgb = src + 4 * (ibuf->x * y + x); 00332 for (c = 0; c < 3; c++) { 00333 unsigned char * p = tgt; 00334 float v = rgb[c]; 00335 00336 CLAMP(v, 0.0f, 1.0f); 00337 00338 p += 4 * (w * ((int) (v * (h - 3)) + 1) 00339 + c * sw + x/3 + 1); 00340 00341 scope_put_pixel_single(wtable, p, c); 00342 p += 4 * w; 00343 scope_put_pixel_single(wtable, p, c); 00344 00345 if (last_p[c] != NULL) { 00346 wform_put_line_single( 00347 w, last_p[c], p, c); 00348 } 00349 last_p[c] = p; 00350 } 00351 } 00352 } 00353 00354 wform_put_border(tgt, w, h); 00355 00356 return rval; 00357 } 00358 00359 struct ImBuf *make_sep_waveform_view_from_ibuf(struct ImBuf * ibuf) 00360 { 00361 if (ibuf->rect_float) { 00362 return make_sep_waveform_view_from_ibuf_float(ibuf); 00363 } else { 00364 return make_sep_waveform_view_from_ibuf_byte(ibuf); 00365 } 00366 } 00367 00368 static void draw_zebra_byte(struct ImBuf * src,struct ImBuf * ibuf, float perc) 00369 { 00370 unsigned int limit = 255.0f * perc / 100.0f; 00371 unsigned char * p = (unsigned char*) src->rect; 00372 unsigned char * o = (unsigned char*) ibuf->rect; 00373 int x; 00374 int y; 00375 00376 for (y = 0; y < ibuf->y; y++) { 00377 for (x = 0; x < ibuf->x; x++) { 00378 unsigned char r = *p++; 00379 unsigned char g = *p++; 00380 unsigned char b = *p++; 00381 unsigned char a = *p++; 00382 00383 if (r >= limit || g >= limit || b >= limit) { 00384 if (((x + y) & 0x08) != 0) { 00385 r = 255 - r; 00386 g = 255 - g; 00387 b = 255 - b; 00388 } 00389 } 00390 *o++ = r; 00391 *o++ = g; 00392 *o++ = b; 00393 *o++ = a; 00394 } 00395 } 00396 } 00397 00398 00399 static void draw_zebra_float(struct ImBuf * src,struct ImBuf * ibuf,float perc) 00400 { 00401 float limit = perc / 100.0f; 00402 float * p = src->rect_float; 00403 unsigned char * o = (unsigned char*) ibuf->rect; 00404 int x; 00405 int y; 00406 00407 for (y = 0; y < ibuf->y; y++) { 00408 for (x = 0; x < ibuf->x; x++) { 00409 float r = *p++; 00410 float g = *p++; 00411 float b = *p++; 00412 float a = *p++; 00413 00414 if (r >= limit || g >= limit || b >= limit) { 00415 if (((x + y) & 0x08) != 0) { 00416 r = -r; 00417 g = -g; 00418 b = -b; 00419 } 00420 } 00421 00422 *o++ = FTOCHAR(r); 00423 *o++ = FTOCHAR(g); 00424 *o++ = FTOCHAR(b); 00425 *o++ = FTOCHAR(a); 00426 } 00427 } 00428 } 00429 00430 struct ImBuf * make_zebra_view_from_ibuf(struct ImBuf * src, float perc) 00431 { 00432 struct ImBuf * ibuf = IMB_allocImBuf(src->x, src->y, 32, IB_rect); 00433 00434 if (src->rect_float) { 00435 draw_zebra_float(src, ibuf, perc); 00436 } else { 00437 draw_zebra_byte(src, ibuf, perc); 00438 } 00439 return ibuf; 00440 } 00441 00442 static void draw_histogram_marker(struct ImBuf * ibuf, int x) 00443 { 00444 unsigned char * p = (unsigned char*) ibuf->rect; 00445 int barh = ibuf->y * 0.1; 00446 int i; 00447 00448 p += 4 * (x + ibuf->x * (ibuf->y - barh + 1)); 00449 00450 for (i = 0; i < barh-1; i++) { 00451 p[0] = p[1] = p[2] = 255; 00452 p += ibuf->x * 4; 00453 } 00454 } 00455 00456 static void draw_histogram_bar(struct ImBuf * ibuf, int x,float val, int col) 00457 { 00458 unsigned char * p = (unsigned char*) ibuf->rect; 00459 int barh = ibuf->y * val * 0.9f; 00460 int i; 00461 00462 p += 4 * (x + ibuf->x); 00463 00464 for (i = 0; i < barh; i++) { 00465 p[col] = 255; 00466 p += ibuf->x * 4; 00467 } 00468 } 00469 00470 static struct ImBuf *make_histogram_view_from_ibuf_byte( 00471 struct ImBuf * ibuf) 00472 { 00473 struct ImBuf * rval = IMB_allocImBuf(515, 128, 32, IB_rect); 00474 int c,x,y; 00475 unsigned int n; 00476 unsigned char* src = (unsigned char*) ibuf->rect; 00477 00478 unsigned int bins[3][256]; 00479 00480 memset(bins, 0, 3 * 256* sizeof(unsigned int)); 00481 00482 for (y = 0; y < ibuf->y; y++) { 00483 for (x = 0; x < ibuf->x; x++) { 00484 bins[0][*src++]++; 00485 bins[1][*src++]++; 00486 bins[2][*src++]++; 00487 src++; 00488 } 00489 } 00490 00491 n = 0; 00492 for (c = 0; c < 3; c++) { 00493 for (x = 0; x < 256; x++) { 00494 if (bins[c][x] > n) { 00495 n = bins[c][x]; 00496 } 00497 } 00498 } 00499 00500 for (c = 0; c < 3; c++) { 00501 for (x = 0; x < 256; x++) { 00502 draw_histogram_bar(rval, x*2+1, 00503 ((float) bins[c][x])/n, c); 00504 draw_histogram_bar(rval, x*2+2, 00505 ((float) bins[c][x])/n, c); 00506 } 00507 } 00508 00509 wform_put_border((unsigned char*) rval->rect, rval->x, rval->y); 00510 00511 return rval; 00512 } 00513 00514 static int get_bin_float(float f) 00515 { 00516 if (f < -0.25f) { 00517 f = -0.25f; 00518 } else if (f > 1.25f) { 00519 f = 1.25f; 00520 } 00521 00522 return (int) (((f + 0.25f) / 1.5f) * 512); 00523 } 00524 00525 static struct ImBuf *make_histogram_view_from_ibuf_float( 00526 struct ImBuf * ibuf) 00527 { 00528 struct ImBuf * rval = IMB_allocImBuf(515, 128, 32, IB_rect); 00529 int n,c,x,y; 00530 float* src = ibuf->rect_float; 00531 00532 unsigned int bins[3][512]; 00533 00534 memset(bins, 0, 3 * 256* sizeof(unsigned int)); 00535 00536 for (y = 0; y < ibuf->y; y++) { 00537 for (x = 0; x < ibuf->x; x++) { 00538 bins[0][get_bin_float(*src++)]++; 00539 bins[1][get_bin_float(*src++)]++; 00540 bins[2][get_bin_float(*src++)]++; 00541 src++; 00542 } 00543 } 00544 00545 draw_histogram_marker(rval, get_bin_float(0.0)); 00546 draw_histogram_marker(rval, get_bin_float(1.0)); 00547 00548 n = 0; 00549 for (c = 0; c < 3; c++) { 00550 for (x = 0; x < 512; x++) { 00551 if (bins[c][x] > n) { 00552 n = bins[c][x]; 00553 } 00554 } 00555 } 00556 for (c = 0; c < 3; c++) { 00557 for (x = 0; x < 512; x++) { 00558 draw_histogram_bar(rval, x+1, (float) bins[c][x]/n, c); 00559 } 00560 } 00561 00562 wform_put_border((unsigned char*) rval->rect, rval->x, rval->y); 00563 00564 return rval; 00565 } 00566 00567 struct ImBuf *make_histogram_view_from_ibuf(struct ImBuf * ibuf) 00568 { 00569 if (ibuf->rect_float) { 00570 return make_histogram_view_from_ibuf_float(ibuf); 00571 } else { 00572 return make_histogram_view_from_ibuf_byte(ibuf); 00573 } 00574 } 00575 00576 static void vectorscope_put_cross(unsigned char r, unsigned char g, 00577 unsigned char b, 00578 char * tgt, int w, int h, int size) 00579 { 00580 float rgb[3], yuv[3]; 00581 char * p; 00582 int x = 0; 00583 int y = 0; 00584 00585 rgb[0]= (float)r/255.0f; 00586 rgb[1]= (float)g/255.0f; 00587 rgb[2]= (float)b/255.0f; 00588 rgb_to_yuv(rgb, yuv); 00589 00590 p = tgt + 4 * (w * (int) ((yuv[2] * (h - 3) + 1)) 00591 + (int) ((yuv[1] * (w - 3) + 1))); 00592 00593 if (r == 0 && g == 0 && b == 0) { 00594 r = 255; 00595 } 00596 00597 for (y = -size; y <= size; y++) { 00598 for (x = -size; x <= size; x++) { 00599 char * q = p + 4 * (y * w + x); 00600 q[0] = r; q[1] = g; q[2] = b; q[3] = 255; 00601 } 00602 } 00603 } 00604 00605 static struct ImBuf *make_vectorscope_view_from_ibuf_byte(struct ImBuf * ibuf) 00606 { 00607 struct ImBuf * rval = IMB_allocImBuf(515, 515, 32, IB_rect); 00608 int x,y; 00609 char* src = (char*) ibuf->rect; 00610 char* tgt = (char*) rval->rect; 00611 float rgb[3], yuv[3]; 00612 int w = 515; 00613 int h = 515; 00614 float scope_gamma = 0.2; 00615 unsigned char wtable[256]; 00616 00617 for (x = 0; x < 256; x++) { 00618 wtable[x] = (unsigned char) (pow(((float) x + 1)/256, 00619 scope_gamma)*255); 00620 } 00621 00622 for (x = 0; x <= 255; x++) { 00623 vectorscope_put_cross(255 , 0,255 - x, tgt, w, h, 1); 00624 vectorscope_put_cross(255 , x, 0, tgt, w, h, 1); 00625 vectorscope_put_cross(255- x, 255, 0, tgt, w, h, 1); 00626 vectorscope_put_cross(0, 255, x, tgt, w, h, 1); 00627 vectorscope_put_cross(0, 255 - x, 255, tgt, w, h, 1); 00628 vectorscope_put_cross(x, 0, 255, tgt, w, h, 1); 00629 } 00630 00631 for (y = 0; y < ibuf->y; y++) { 00632 for (x = 0; x < ibuf->x; x++) { 00633 char * src1 = src + 4 * (ibuf->x * y + x); 00634 char * p; 00635 00636 rgb[0]= (float)src1[0]/255.0f; 00637 rgb[1]= (float)src1[1]/255.0f; 00638 rgb[2]= (float)src1[2]/255.0f; 00639 rgb_to_yuv(rgb, yuv); 00640 00641 p = tgt + 4 * (w * (int) ((yuv[2] * (h - 3) + 1)) 00642 + (int) ((yuv[1] * (w - 3) + 1))); 00643 scope_put_pixel(wtable, (unsigned char*)p); 00644 } 00645 } 00646 00647 vectorscope_put_cross(0, 0, 0, tgt, w, h, 3); 00648 00649 return rval; 00650 } 00651 00652 static struct ImBuf *make_vectorscope_view_from_ibuf_float(struct ImBuf * ibuf) 00653 { 00654 struct ImBuf * rval = IMB_allocImBuf(515, 515, 32, IB_rect); 00655 int x,y; 00656 float* src = ibuf->rect_float; 00657 char* tgt = (char*) rval->rect; 00658 float rgb[3], yuv[3]; 00659 int w = 515; 00660 int h = 515; 00661 float scope_gamma = 0.2; 00662 unsigned char wtable[256]; 00663 00664 for (x = 0; x < 256; x++) { 00665 wtable[x] = (unsigned char) (pow(((float) x + 1)/256, 00666 scope_gamma)*255); 00667 } 00668 00669 for (x = 0; x <= 255; x++) { 00670 vectorscope_put_cross(255 , 0,255 - x, tgt, w, h, 1); 00671 vectorscope_put_cross(255 , x, 0, tgt, w, h, 1); 00672 vectorscope_put_cross(255- x, 255, 0, tgt, w, h, 1); 00673 vectorscope_put_cross(0, 255, x, tgt, w, h, 1); 00674 vectorscope_put_cross(0, 255 - x, 255, tgt, w, h, 1); 00675 vectorscope_put_cross(x, 0, 255, tgt, w, h, 1); 00676 } 00677 00678 for (y = 0; y < ibuf->y; y++) { 00679 for (x = 0; x < ibuf->x; x++) { 00680 float * src1 = src + 4 * (ibuf->x * y + x); 00681 char * p; 00682 00683 memcpy(rgb, src1, 3 * sizeof(float)); 00684 00685 CLAMP(rgb[0], 0.0f, 1.0f); 00686 CLAMP(rgb[1], 0.0f, 1.0f); 00687 CLAMP(rgb[2], 0.0f, 1.0f); 00688 00689 rgb_to_yuv(rgb, yuv); 00690 00691 p = tgt + 4 * (w * (int) ((yuv[2] * (h - 3) + 1)) 00692 + (int) ((yuv[1] * (w - 3) + 1))); 00693 scope_put_pixel(wtable, (unsigned char*)p); 00694 } 00695 } 00696 00697 vectorscope_put_cross(0, 0, 0, tgt, w, h, 3); 00698 00699 return rval; 00700 } 00701 00702 struct ImBuf *make_vectorscope_view_from_ibuf(struct ImBuf * ibuf) 00703 { 00704 if (ibuf->rect_float) { 00705 return make_vectorscope_view_from_ibuf_float(ibuf); 00706 } else { 00707 return make_vectorscope_view_from_ibuf_byte(ibuf); 00708 } 00709 }