ref: 27154e7406931d7e676dbf6267865c87e3b6dfbe
dir: /yuv.c/
#include <u.h> void yuv420_rgb24( u32int width, u32int height, const u8int *Y, const u8int *U, const u8int *V, u32int Y_stride, u32int UV_stride, u8int *RGB, u32int RGB_stride) { u32int x, y; int yy1, cb1, cr1; int r, g, b, go; for(y = 0; y < height-1; y += 2){ for(x = 0; x < width-1; x += 2){ cb1 = (int)*U - 0x80; cr1 = (int)*V - 0x80; go = 22554*cb1 - 46802*cr1; #define ONE do{ \ yy1 = (int)*Y * 0x10101; \ r = yy1 + 91881*cr1; \ r = (r & 0xff000000) ? ~(r >> 31) : (r>>16); \ g = yy1 - go; \ g = (g & 0xff000000) ? ~(g >> 31) : (g>>16); \ b = yy1 + 116130*cb1; \ b = (b & 0xff000000) ? ~(b >> 31) : (b>>16); \ RGB[2] = r; \ RGB[1] = g; \ RGB[0] = b; \ }while(0) ONE; Y += 1; RGB += 3; ONE; Y += Y_stride; RGB += RGB_stride; ONE; Y -= 1; RGB -= 3; ONE; Y -= Y_stride; RGB -= RGB_stride; Y += 2; U += 1; V += 1; RGB += 6; } Y += 2*Y_stride - x; U += UV_stride - x/2; V += UV_stride - x/2; RGB += 2*RGB_stride - 3*x; } }