forked from mia/Aegisub
Optimized the YV12->RGB32 conversion in AegiVideoFrame
Originally committed to SVN as r987.
This commit is contained in:
parent
16ac9e6e21
commit
29923cb8e1
1 changed files with 7 additions and 15 deletions
|
@ -288,28 +288,20 @@ void AegiVideoFrame::ConvertFrom(const AegiVideoFrame &source) {
|
||||||
const int src_delta2 = source.pitch[1]-w/2;
|
const int src_delta2 = source.pitch[1]-w/2;
|
||||||
const int src_delta3 = source.pitch[2]-w/2;
|
const int src_delta3 = source.pitch[2]-w/2;
|
||||||
const int dst_delta = pitch[0]-w*4;
|
const int dst_delta = pitch[0]-w*4;
|
||||||
int r,g,b,y,u,v,c,d,e;
|
register int y,u,v;
|
||||||
|
|
||||||
// Loop
|
// Loop
|
||||||
for (unsigned int py=0;py<h;py++) {
|
for (unsigned int py=0;py<h;py++) {
|
||||||
for (unsigned int px=0;px<w/2;px++) {
|
for (unsigned int px=0;px<w/2;px++) {
|
||||||
u = *src_u++;
|
u = *src_u++ - 128;
|
||||||
v = *src_v++;
|
v = *src_v++ - 128;
|
||||||
for (unsigned int i=0;i<2;i++) {
|
for (unsigned int i=0;i<2;i++) {
|
||||||
y = *src_y++;
|
y = (*src_y++ - 16) * 298;
|
||||||
|
|
||||||
// Convert
|
|
||||||
c = y - 16;
|
|
||||||
d = u - 128;
|
|
||||||
e = v - 128;
|
|
||||||
r = MID(0,( 298 * c + 409 * e + 128) >> 8,255);
|
|
||||||
g = MID(0,( 298 * c - 100 * d - 208 * e + 128) >> 8,255);
|
|
||||||
b = MID(0,( 298 * c + 516 * d + 128) >> 8,255);
|
|
||||||
|
|
||||||
// Assign
|
// Assign
|
||||||
*dst++ = b;
|
*dst++ = MID(0,(y + 516 * u + 128) >> 8,255); // Blue
|
||||||
*dst++ = g;
|
*dst++ = MID(0,(y - 100 * u - 208 * v + 128) >> 8,255); // Green
|
||||||
*dst++ = r;
|
*dst++ = MID(0,(y + 409 * v + 128) >> 8,255); // Red
|
||||||
*dst++ = 0;
|
*dst++ = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue