wcap: Support the other pixel format we may write

dev
Kristian Høgsberg 13 years ago
parent b2aa91c164
commit 2255eb0816
  1. 31
      wcap/vpxenc.c
  2. 1
      wcap/wcap-decode.c
  3. 1
      wcap/wcap-decode.h

@ -316,12 +316,22 @@ struct input_state
struct wcap_decoder *wcap; struct wcap_decoder *wcap;
}; };
static inline int rgb_to_yuv(uint32_t p, int *u, int *v) static inline int rgb_to_yuv(uint32_t format, uint32_t p, int *u, int *v)
{ {
int r = (p >> 16) & 0xff; int r, g, b, y;
int g = (p >> 8) & 0xff;
int b = (p >> 0) & 0xff; switch (format) {
int y; case WCAP_FORMAT_XRGB8888:
r = (p >> 16) & 0xff;
g = (p >> 8) & 0xff;
b = (p >> 0) & 0xff;
break;
case WCAP_FORMAT_XBGR8888:
r = (p >> 0) & 0xff;
g = (p >> 8) & 0xff;
b = (p >> 16) & 0xff;
break;
}
y = 0.299 * r + 0.587 * g + 0.114 * b; y = 0.299 * r + 0.587 * g + 0.114 * b;
if (y > 255) if (y > 255)
@ -348,6 +358,7 @@ static void convert_to_yv12(struct wcap_decoder *wcap, vpx_image_t *img)
unsigned char *y1, *y2, *u, *v; unsigned char *y1, *y2, *u, *v;
uint32_t *p1, *p2, *end; uint32_t *p1, *p2, *end;
int i, u_accum, v_accum; int i, u_accum, v_accum;
uint32_t format = wcap->format;
for (i = 0; i < wcap->height; i += 2) { for (i = 0; i < wcap->height; i += 2) {
y1 = img->planes[0] + img->stride[0] * i; y1 = img->planes[0] + img->stride[0] * i;
@ -361,10 +372,10 @@ static void convert_to_yv12(struct wcap_decoder *wcap, vpx_image_t *img)
while (p1 < end) { while (p1 < end) {
u_accum = 0; u_accum = 0;
v_accum = 0; v_accum = 0;
y1[0] = rgb_to_yuv(p1[0], &u_accum, &v_accum); y1[0] = rgb_to_yuv(format, p1[0], &u_accum, &v_accum);
y1[1] = rgb_to_yuv(p1[1], &u_accum, &v_accum); y1[1] = rgb_to_yuv(format, p1[1], &u_accum, &v_accum);
y2[0] = rgb_to_yuv(p2[0], &u_accum, &v_accum); y2[0] = rgb_to_yuv(format, p2[0], &u_accum, &v_accum);
y2[1] = rgb_to_yuv(p2[1], &u_accum, &v_accum); y2[1] = rgb_to_yuv(format, p2[1], &u_accum, &v_accum);
u[0] = clamp_uv(u_accum); u[0] = clamp_uv(u_accum);
v[0] = clamp_uv(v_accum); v[0] = clamp_uv(v_accum);

@ -120,6 +120,7 @@ wcap_decoder_create(const char *filename)
PROT_READ, MAP_PRIVATE, decoder->fd, 0); PROT_READ, MAP_PRIVATE, decoder->fd, 0);
header = decoder->map; header = decoder->map;
decoder->format = header->format;
decoder->width = header->width; decoder->width = header->width;
decoder->height = header->height; decoder->height = header->height;
decoder->p = header + 1; decoder->p = header + 1;

@ -50,6 +50,7 @@ struct wcap_decoder {
size_t size; size_t size;
void *map, *p, *end; void *map, *p, *end;
uint32_t *frame; uint32_t *frame;
uint32_t format;
int width, height; int width, height;
}; };

Loading…
Cancel
Save