summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2012-05-30 15:01:03 -0400
committerKristian Høgsberg <krh@bitplanet.net>2012-05-30 15:01:03 -0400
commitf7a69642a9993e17fa045b12cab55b0493a7f6db (patch)
tree0b5e275cd43219a023a6849f5e2405b4ff09d664
parent86aa5fbbe69220667b450628b312da9e75250561 (diff)
wcap: Convert argb to yv12 using integer math instead
Drop from 8% in the profile to 1.8%.
-rw-r--r--wcap/vpxenc.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/wcap/vpxenc.c b/wcap/vpxenc.c
index 793b73f..5e9e34d 100644
--- a/wcap/vpxenc.c
+++ b/wcap/vpxenc.c
@@ -335,27 +335,29 @@ static inline int rgb_to_yuv(uint32_t format, uint32_t p, int *u, int *v)
break;
}
- y = 0.299 * r + 0.587 * g + 0.114 * b;
+ y = (19595 * r + 38469 * g + 7472 * b) >> 16;
if (y > 255)
y = 255;
- *u += 0.713 * (r - y);
- *v += 0.564 * (b - y);
+ *u += 46727 * (r - y);
+ *v += 36962 * (b - y);
return y;
}
static inline int clamp_uv(int u)
{
- if (u < -512)
+ int clamp = (u >> 18) + 128;
+
+ if (clamp < 0)
return 0;
- else if (u > 511)
+ else if (clamp > 255)
return 255;
else
- return u / 4 + 128;
+ return clamp;
}
-static void convert_to_yv12(struct wcap_decoder *wcap, vpx_image_t *img)
+void convert_to_yv12(struct wcap_decoder *wcap, vpx_image_t *img)
{
unsigned char *y1, *y2, *u, *v;
uint32_t *p1, *p2, *end;