View Full Version : YV12-filter with only 1 loop possible?
E-Male
13th July 2004, 22:16
i got a problem with yv12 filter writing:
these filters need 2-3 loops
but what if i for example wanna check the luma of a pixel and then change luma and chroma of that pixel based on the result
i would have to do it one loop, right? but how?
thx for any help
E-Male
Wilbert
13th July 2004, 22:53
Something like this:
unsigned char* srcp = src->GetWritePtr();
unsigned char* srcpV = src->GetWritePtr();
unsigned char* srcpU = src->GetWritePtr();
const int src_pitch = src->GetPitch();
const int src_width = src->GetRowSize();
const int src_height = src->GetHeight();
if (vi.IsYV12()) {
const int src_pitchUV = src->GetPitch(PLANAR_U);
const int src_row_sizeUV = src->GetRowSize(PLANAR_U);
const int src_heightUV = src->GetHeight(PLANAR_U);
srcp = src->GetWritePtr(PLANAR_Y);
srcpV = src->GetWritePtr(PLANAR_V);
srcpU = src->GetWritePtr(PLANAR_U);
for (int h=0; h < src_height;h++) {
for (int x = 0; x < src_width; x+=2) {
// red: Y=82, U=90 and V=240
if (srcp[x] < min_luma) {
srcp[x] = 82;
srcp[x+1] = 82;
srcpV[x/2] = 240;
srcpU[x/2] = 90;
}
if (srcp[x] > max_luma) {
// green: Y=145, U=54 and V=34
srcp[x] = 145;
srcp[x+1] = 145;
srcpV[x/2] = 34;
srcpU[x/2] = 54;
}
}
srcp += src_pitch;
if (h%2==1) {
srcpV += src_pitchUV;
srcpU += src_pitchUV;
}
}
}
Here the values srcpV and srcpU are assigned twice, but you get the idea.
E-Male
14th July 2004, 05:13
thx, i'll read through it carefulyl tonight, but seems exactly what i was looking for
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.