Index: source/blender/blenkernel/intern/colortools.c =================================================================== --- source/blender/blenkernel/intern/colortools.c (révision 28055) +++ source/blender/blenkernel/intern/colortools.c (copie de travail) @@ -899,8 +899,16 @@ return bin; } -DO_INLINE void save_sample_line(Scopes *scopes, const int idx, const float fx, float *rgb, float *ycc, float *ycc709) +DO_INLINE void save_sample_line(Scopes *scopes, const int idx, const float fx, float *rgb, float *ycc) { + float yuv[3]; + + /* vectorscope*/ + rgb_to_yuv(rgb[0], rgb[1], rgb[2], &yuv[0], &yuv[1], &yuv[2]); + scopes->vecscope[idx + 0] = yuv[1]; + scopes->vecscope[idx + 1] = yuv[2]; + + /* waveform */ switch (scopes->wavefrm_mode) { case SCOPES_WAVEFRM_RGB: scopes->waveform_1[idx + 0] = fx; @@ -912,35 +920,17 @@ break; case SCOPES_WAVEFRM_LUM: scopes->waveform_1[idx + 0] = fx; - scopes->waveform_1[idx + 1] = 0.299*rgb[0] + 0.587*rgb[1] + 0.114*rgb[2]; + scopes->waveform_1[idx + 1] = ycc[0]; break; case SCOPES_WAVEFRM_YCC_JPEG: - scopes->waveform_1[idx + 0] = fx; - scopes->waveform_1[idx + 1] = ycc[0] * INV_255; - scopes->waveform_2[idx + 0] = fx; - scopes->waveform_2[idx + 1] = ycc[1] * INV_255; - scopes->waveform_3[idx + 0] = fx; - scopes->waveform_3[idx + 1] = ycc[2] * INV_255; - break; case SCOPES_WAVEFRM_YCC_709: - scopes->waveform_1[idx + 0] = fx; - scopes->waveform_1[idx + 1] = ycc709[0] * INV_255; - scopes->waveform_2[idx + 0] = fx; - scopes->waveform_2[idx + 1] = ycc709[1] * INV_255; - scopes->waveform_3[idx + 0] = fx; - scopes->waveform_3[idx + 1] = ycc709[2] * INV_255; - break; case SCOPES_WAVEFRM_YCC_601: - { - float ycc601[3]; - rgb_to_ycc(rgb[0], rgb[1], rgb[2], &ycc601[0], &ycc601[1], &ycc601[2], BLI_YCC_ITU_BT601); scopes->waveform_1[idx + 0] = fx; - scopes->waveform_1[idx + 1] = ycc601[0] * INV_255; + scopes->waveform_1[idx + 1] = ycc[0]; scopes->waveform_2[idx + 0] = fx; - scopes->waveform_2[idx + 1] = ycc601[1] * INV_255; + scopes->waveform_2[idx + 1] = ycc[1]; scopes->waveform_3[idx + 0] = fx; - scopes->waveform_3[idx + 1] = ycc601[2] * INV_255; - } + scopes->waveform_3[idx + 1] = ycc[2]; break; } } @@ -949,11 +939,12 @@ { int x, y, c, n, nl; double div, divl; - float *rf, *drf; - unsigned char *rc, *drc; + float *rf; + unsigned char *rc; unsigned int *bin_r, *bin_g, *bin_b, *bin_lum; int savedlines, saveline; - float rgb[3], ycc[3], ycc709[3]; + float rgb[3], ycc[3]; + int ycc_mode; if (scopes->ok == 1 ) return; @@ -964,6 +955,22 @@ scopes->hist.channels = 3; scopes->hist.x_resolution = 256; + switch (scopes->wavefrm_mode) { + case SCOPES_WAVEFRM_RGB: + ycc_mode = -1; + break; + case SCOPES_WAVEFRM_LUM: + case SCOPES_WAVEFRM_YCC_JPEG: + ycc_mode = BLI_YCC_JFIF_0_255; + break; + case SCOPES_WAVEFRM_YCC_601: + ycc_mode = BLI_YCC_ITU_BT601; + break; + case SCOPES_WAVEFRM_YCC_709: + ycc_mode = BLI_YCC_ITU_BT709; + break; + } + /* temp table to count pix value for histo */ bin_r = MEM_callocN(256 * sizeof(unsigned int), "temp historgram bins"); bin_g = MEM_callocN(256 * sizeof(unsigned int), "temp historgram bins"); @@ -976,19 +983,11 @@ if (scopes->sample_full) scopes->sample_lines = ibuf->y; - if( scopes->samples_ibuf) { - IMB_freeImBuf(scopes->samples_ibuf); - scopes->samples_ibuf=NULL; - } /* scan the image */ savedlines=0; for (c=0; c<3; c++) { - scopes->rgbminmax[c][0]=100.0f; - scopes->rgbminmax[c][1]=-100.0f; - scopes->yccminmax[c][0]=25500.0f; - scopes->yccminmax[c][1]=-25500.0f; - scopes->ycc709minmax[c][0]=25500.0f; - scopes->ycc709minmax[c][1]=-25500.0f; + scopes->minmax[c][0]=25500.0f; + scopes->minmax[c][1]=-25500.0f; } scopes->waveform_tot = ibuf->x*scopes->sample_lines; @@ -999,114 +998,68 @@ MEM_freeN(scopes->waveform_2); if (scopes->waveform_3) MEM_freeN(scopes->waveform_3); + if (scopes->vecscope) + MEM_freeN(scopes->vecscope); scopes->waveform_1= MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "waveform point channel 1"); scopes->waveform_2= MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "waveform point channel 2"); scopes->waveform_3= MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "waveform point channel 3"); + scopes->vecscope= MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "vectorscope point channel"); - if (ibuf->rect_float) { - scopes->samples_ibuf = IMB_allocImBuf(ibuf->x, scopes->sample_lines, 32, IB_rectfloat, 0 ); + if (ibuf->rect_float) rf = ibuf->rect_float; - drf= scopes->samples_ibuf->rect_float; - - for (y = 0; y < ibuf->y; y++) { - if (savedlinessample_lines && y>=((savedlines)*ibuf->y)/(scopes->sample_lines+1)) { - saveline=1; - } else saveline=0; - for (x = 0; x < ibuf->x; x++) { - + else if (ibuf->rect) + rc = (unsigned char *)ibuf->rect; + + for (y = 0; y < ibuf->y; y++) { + if (savedlinessample_lines && y>=((savedlines)*ibuf->y)/(scopes->sample_lines+1)) { + saveline=1; + } else saveline=0; + for (x = 0; x < ibuf->x; x++) { + + if (ibuf->rect_float) { if (use_color_management) linearrgb_to_srgb_v3_v3(rgb, rf); else copy_v3_v3(rgb, rf); - - rgb_to_ycc(rgb[0],rgb[1],rgb[2],&ycc[0],&ycc[1],&ycc[2],BLI_YCC_JFIF_0_255); - rgb_to_ycc(rgb[0],rgb[1],rgb[2],&ycc709[0],&ycc709[1],&ycc709[2],BLI_YCC_ITU_BT709); - - /* check for min max */ + } + else if (ibuf->rect) { + for (c=0; c<3; c++) + rgb[c] = rc[c] * INV_255; + } + /* check for min max */ + if(ycc_mode == -1 ) { for (c=0; c<3; c++) { - if (rgb[c] < scopes->rgbminmax[c][0]) scopes->rgbminmax[c][0] = rgb[c]; - if (rgb[c] > scopes->rgbminmax[c][1]) scopes->rgbminmax[c][1] = rgb[c]; - if (ycc[c] < scopes->yccminmax[c][0]) scopes->yccminmax[c][0] = ycc[c]; - if (ycc[c] > scopes->yccminmax[c][1]) scopes->yccminmax[c][1] = ycc[c]; - if (ycc709[c] < scopes->ycc709minmax[c][0]) scopes->ycc709minmax[c][0] = ycc709[c]; - if (ycc709[c] > scopes->ycc709minmax[c][1]) scopes->ycc709minmax[c][1] = ycc709[c]; + if (rgb[c] < scopes->minmax[c][0]) scopes->minmax[c][0] = rgb[c]; + if (rgb[c] > scopes->minmax[c][1]) scopes->minmax[c][1] = rgb[c]; } - /* increment count for histo*/ - bin_r[ get_bin_float(rgb[0]) ] += 1; - bin_g[ get_bin_float(rgb[1]) ] += 1; - bin_b[ get_bin_float(rgb[2]) ] += 1; - bin_lum[ get_bin_float(ycc[0] * INV_255) ] += 1; - - /* save sample if needed */ - if(saveline) { - const float fx = (float)x / (float)ibuf->x; - const int idx = 2*(ibuf->x*savedlines+x); - - save_sample_line(scopes, idx, fx, rgb, ycc, ycc709); - - drf[0]=rgb[0]; - drf[1]=rgb[1]; - drf[2]=rgb[2]; - drf+= scopes->samples_ibuf->channels; - } - rf+= ibuf->channels; } - if (saveline) - savedlines +=1; - } - - } - else if (ibuf->rect) { - scopes->samples_ibuf = IMB_allocImBuf(ibuf->x, scopes->sample_lines, 32, IB_rect, 0 ); - rc = (unsigned char *)ibuf->rect; - drc= (unsigned char *) scopes->samples_ibuf->rect; - - for (y = 0; y < ibuf->y; y++) { - if (savedlinessample_lines && y>=((savedlines)*ibuf->y)/(scopes->sample_lines+1)) { - saveline=1; - } else saveline=0; - - for (x = 0; x < ibuf->x; x++) { - - for (c=0; c<3; c++) - rgb[c] = rc[c] * INV_255; - rgb_to_ycc(rgb[0],rgb[1],rgb[2],&ycc[0],&ycc[1],&ycc[2],BLI_YCC_JFIF_0_255); - rgb_to_ycc(rgb[0],rgb[1],rgb[2],&ycc709[0],&ycc709[1],&ycc709[2],BLI_YCC_ITU_BT709); - - /* check for min max */ + else { + rgb_to_ycc(rgb[0],rgb[1],rgb[2],&ycc[0],&ycc[1],&ycc[2], ycc_mode); for (c=0; c<3; c++) { - if (rgb[c] < scopes->rgbminmax[c][0]) scopes->rgbminmax[c][0] = rgb[c]; - if (rgb[c] > scopes->rgbminmax[c][1]) scopes->rgbminmax[c][1] = rgb[c]; - if (ycc[c] < scopes->yccminmax[c][0]) scopes->yccminmax[c][0] = ycc[c]; - if (ycc[c] > scopes->yccminmax[c][1]) scopes->yccminmax[c][1] = ycc[c]; - if (ycc709[c] < scopes->ycc709minmax[c][0]) scopes->ycc709minmax[c][0] = ycc709[c]; - if (ycc709[c] > scopes->ycc709minmax[c][1]) scopes->ycc709minmax[c][1] = ycc709[c]; + ycc[c] *=INV_255; + if (ycc[c] < scopes->minmax[c][0]) scopes->minmax[c][0] = ycc[c]; + if (ycc[c] > scopes->minmax[c][1]) scopes->minmax[c][1] = ycc[c]; } + } + /* increment count for histo*/ + bin_r[ get_bin_float(rgb[0]) ] += 1; + bin_g[ get_bin_float(rgb[1]) ] += 1; + bin_b[ get_bin_float(rgb[2]) ] += 1; + bin_lum[ get_bin_float(ycc[0]) ] += 1; - /* increment count for histo */ - bin_r[ rc[0] ] += 1; - bin_g[ rc[1] ] += 1; - bin_b[ rc[2] ] += 1; - bin_lum[ get_bin_float(ycc[0] * INV_255) ] += 1; - - /* save sample if needed */ - if(saveline) { - const float fx = (float)x / (float)ibuf->x; - const int idx = 2*(ibuf->x*savedlines+x); - - save_sample_line(scopes, idx, fx, rgb, ycc, ycc709); - - drc[0]=rc[0]; - drc[1]=rc[1]; - drc[2]=rc[2]; - drc+= 4; - } - rc += ibuf->channels; + /* save sample if needed */ + if(saveline) { + const float fx = (float)x / (float)ibuf->x; + const int idx = 2*(ibuf->x*savedlines+x); + save_sample_line(scopes, idx, fx, rgb, ycc); } - if (saveline) - savedlines +=1; + + rf+= ibuf->channels; + rc+= ibuf->channels; } + if (saveline) + savedlines +=1; } /* convert hist data to float (proportional to max count) */ @@ -1152,9 +1105,8 @@ MEM_freeN(scopes->waveform_3); scopes->waveform_3 = NULL; } - - if( scopes->samples_ibuf) { - IMB_freeImBuf(scopes->samples_ibuf); - scopes->samples_ibuf=NULL; + if (scopes->vecscope) { + MEM_freeN(scopes->vecscope); + scopes->vecscope = NULL; } -} \ No newline at end of file +} Index: source/blender/makesdna/DNA_color_types.h =================================================================== --- source/blender/makesdna/DNA_color_types.h (révision 28055) +++ source/blender/makesdna/DNA_color_types.h (copie de travail) @@ -122,14 +122,12 @@ int wavefrm_height; float vecscope_alpha; int vecscope_height; - float rgbminmax[3][2]; - float yccminmax[3][2]; - float ycc709minmax[3][2]; - struct ImBuf *samples_ibuf; + float minmax[3][2]; struct Histogram hist; float *waveform_1; float *waveform_2; float *waveform_3; + float *vecscope; int waveform_tot; int pad; } Scopes; Index: source/blender/blenloader/intern/readfile.c =================================================================== --- source/blender/blenloader/intern/readfile.c (révision 28055) +++ source/blender/blenloader/intern/readfile.c (copie de travail) @@ -4837,7 +4837,6 @@ sima->image= restore_pointer_by_name(newmain, (ID *)sima->image, 1); - sima->scopes.samples_ibuf = NULL; sima->scopes.ok = 0; /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data @@ -5111,7 +5110,6 @@ sima->iuser.scene= NULL; sima->iuser.ok= 1; - sima->scopes.samples_ibuf = NULL; sima->scopes.ok = 0; /* WARNING: gpencil data is no longer stored directly in sima after 2.5 Index: source/blender/editors/interface/interface_draw.c =================================================================== --- source/blender/editors/interface/interface_draw.c (révision 28055) +++ source/blender/editors/interface/interface_draw.c (copie de travail) @@ -807,7 +807,7 @@ float min, max; float scaler_x1, scaler_x2; - if (scopes==NULL || scopes->samples_ibuf==NULL) return; + if (scopes==NULL) return; rect.xmin = (float)recti->xmin+1; rect.xmax = (float)recti->xmax-1; @@ -815,9 +815,9 @@ rect.ymax = (float)recti->ymax-1; if (scopes->wavefrm_yfac < 0.5f ) - scopes->wavefrm_yfac =1.0f; + scopes->wavefrm_yfac =0.98f; w = rect.xmax - rect.xmin-7; - h = (rect.ymax - rect.ymin)/scopes->wavefrm_yfac; + h = (rect.ymax - rect.ymin)*scopes->wavefrm_yfac; yofs= rect.ymin + (rect.ymax - rect.ymin -h)/2.0f; w3=w/3.0f; @@ -871,7 +871,9 @@ fdrawline(rect.xmin+3*w3, yofs+h*235.0f/255.0f, rect.xmax+1, yofs+h*235.0f/255.0f); fdrawline(rect.xmin+w3, yofs+h*240.0f/255.0f, rect.xmax+1, yofs+h*240.0f/255.0f); } - + /* 7.5 IRE black point level for NTSC */ + if (scopes->wavefrm_mode== SCOPES_WAVEFRM_LUM) + fdrawline(rect.xmin, yofs+h*0.075f, rect.xmax+1, yofs+h*0.075f); /* LUMA (1 channel) */ glBlendFunc(GL_ONE,GL_ONE); @@ -896,8 +898,8 @@ /* min max */ glColor3f(.5f, .5f, .5f); - min= yofs+scopes->yccminmax[0][0]*h/255.0f; - max= yofs+scopes->yccminmax[0][1]*h/255.0f; + min= yofs+scopes->minmax[0][0]*h; + max= yofs+scopes->minmax[0][1]*h; CLAMP(min, rect.ymin, rect.ymax); CLAMP(max, rect.ymin, rect.ymax); fdrawline(rect.xmax-3,min,rect.xmax-3,max); @@ -939,50 +941,16 @@ /* min max */ - if (scopes->wavefrm_mode == SCOPES_WAVEFRM_RGB) { - for (c=0; c<3; c++) { + for (c=0; c<3; c++) { + if (scopes->wavefrm_mode == SCOPES_WAVEFRM_RGB) glColor3f(colors[c][0]*0.75, colors[c][1]*0.75, colors[c][2]*0.75); - min= yofs+scopes->rgbminmax[c][0]*h; - max= yofs+scopes->rgbminmax[c][1]*h; - CLAMP(min, rect.ymin, rect.ymax); - CLAMP(max, rect.ymin, rect.ymax); - fdrawline(rect.xmin+w+2+c*2,min,rect.xmin+w+2+c*2,max); - } - } else { - if (ELEM(scopes->wavefrm_mode, SCOPES_WAVEFRM_YCC_601, SCOPES_WAVEFRM_YCC_JPEG)) { - for (c=0; c<3; c++) { - glColor3f(colorsycc[c][0]*0.75, colorsycc[c][1]*0.75, colorsycc[c][2]*0.75); - /* we get ITU 601 min max from remapping JPEG*/ - if (scopes->wavefrm_mode== SCOPES_WAVEFRM_YCC_601) { - if(c==0) { - min= yofs+(16+(219*scopes->yccminmax[c][0]/255))*h/255.0f; - max= yofs+(16+(219*scopes->yccminmax[c][1]/255))*h/255.0f; - } - else { - min= yofs+(16+(224*scopes->yccminmax[c][0]/255))*h/255.0f; - max= yofs+(16+(224*scopes->yccminmax[c][1]/255))*h/255.0f; - } - } - /* rescale ycc to 0-1*/ - else { - min= yofs+scopes->yccminmax[c][0]*h/255.0f; - max= yofs+scopes->yccminmax[c][1]*h/255.0f; - } - CLAMP(min, rect.ymin, rect.ymax); - CLAMP(max, rect.ymin, rect.ymax); - fdrawline(rect.xmin+2+w+c*2,min,rect.xmin+2+w+c*2,max); - } - } - else if (scopes->wavefrm_mode== SCOPES_WAVEFRM_YCC_709) { - for (c=0; c<3; c++) { - glColor3f(colorsycc[c][0]*0.75, colorsycc[c][1]*0.75, colorsycc[c][2]*0.75); - min= yofs+scopes->ycc709minmax[c][0]*h/255.0f; - max= yofs+scopes->ycc709minmax[c][1]*h/255.0f; - CLAMP(min, rect.ymin, rect.ymax); - CLAMP(max, rect.ymin, rect.ymax); - fdrawline(rect.xmin+2+w+c*2,min,rect.xmin+2+w+c*2,max); - } - } + else + glColor3f(colorsycc[c][0]*0.75, colorsycc[c][1]*0.75, colorsycc[c][2]*0.75); + min= yofs+scopes->minmax[c][0]*h; + max= yofs+scopes->minmax[c][1]*h; + CLAMP(min, rect.ymin, rect.ymax); + CLAMP(max, rect.ymin, rect.ymax); + fdrawline(rect.xmin+w+2+c*2,min,rect.xmin+w+2+c*2,max); } } @@ -1076,18 +1044,15 @@ { Scopes *scopes = (Scopes *)but->poin; rctf rect; - int i, j, x, y; + int i, j; int skina= 123; /* angle in degree of the skin tone line */ float w, h, centerx, centery, diam; float alpha; float colors[6][3]={{.75,0,0},{.75,.75,0},{0,.75,0},{0,.75,.75},{0,0,.75},{.75,0,.75}}; - unsigned char *rc; - float *rf; GLint scissor[4]; - float u, v; float scaler_x1, scaler_x2; - if (scopes==NULL || scopes->samples_ibuf==NULL) return; + if (scopes==NULL) return; rect.xmin = (float)recti->xmin+1; rect.xmax = (float)recti->xmax-1; @@ -1139,33 +1104,23 @@ /* pixel point cloud */ glBlendFunc(GL_ONE,GL_ONE); - glBegin(GL_POINTS); glColor4f(alpha, alpha, alpha, alpha); - if (scopes->samples_ibuf->rect_float) { - rf = scopes->samples_ibuf->rect_float; - for (y=0; ysamples_ibuf->y; y++) { - for (x=0; xsamples_ibuf->x; x++) { - u=-0.147f*rf[0] - 0.289f*rf[1] + 0.436f*rf[2]; - v= 0.615f*rf[0] - 0.515f*rf[1] - 0.100f*rf[2]; - glVertex2f(centerx+u*diam, centery+v*diam); - rf+=scopes->samples_ibuf->channels; - } - } - } - else if(scopes->samples_ibuf->rect) { - rc = (unsigned char *)(scopes->samples_ibuf->rect); - for (y=0; ysamples_ibuf->y; y++) { - for (x=0; xsamples_ibuf->x; x++) { - u=-0.147f*rc[0]/255.0f - 0.289f*rc[1]/255.0f + 0.436f*rc[2]/255.0f; - v= 0.615f*rc[0]/255.0f - 0.515f*rc[1]/255.0f - 0.100f*rc[2]/255.0f; - glVertex2f(centerx+u*diam, centery+v*diam); - rc+=4; - } - } - } - glEnd(); - + glPushMatrix(); + + glEnableClientState(GL_VERTEX_ARRAY); + + glTranslatef(centerx, centery, 0.f); + glScalef(diam, diam, 0.f); + + glVertexPointer(2, GL_FLOAT, 0, scopes->vecscope); + glDrawArrays(GL_POINTS, 0, scopes->waveform_tot); + + glDisableClientState(GL_VERTEX_ARRAY); + + glPopMatrix(); + + /* restore scissortest */ glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);