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