ref: 28ef2a222c95ee8826d9eed152964bfcc90e30a7
dir: /yuv.c/
#include <u.h> void yuv420_rgb24( int width, int height, u8int *y, u8int *u, u8int *v, u32int ystride, u32int uvstride, u8int *rgb, u32int rgbstride) { u32int w, h; int r, g, b; int yy1, cb1, cr1, go; for(h = 0; h < height-1; h += 2){ for(w = 0; w < width-1; w += 2){ cb1 = *u - 0x80; cr1 = *v - 0x80; go = 22554*cb1 + 46802*cr1; #define ONE do{ \ yy1 = *y * 0x10101; \ b = yy1 + 116130*cb1; \ rgb[0] = (b >> 24) ? ~(b >> 31) : (b>>16); \ g = yy1 - go; \ rgb[1] = (g >> 24) ? ~(g >> 31) : (g>>16); \ r = yy1 + 91881*cr1; \ rgb[2] = (r >> 24) ? ~(r >> 31) : (r>>16); \ }while(0) ONE; y += 1; rgb += 3; ONE; y += ystride; rgb += rgbstride; ONE; y -= 1; rgb -= 3; ONE; y -= ystride; rgb -= rgbstride - 6; y += 2; u += 1; v += 1; } y += ystride*2 - w; u += uvstride - w/2; v += uvstride - w/2; rgb += rgbstride*2 - 3*w; } }