ref: 48e202712769741daf7806b0bbc6cd0d2fd5a50b
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; \ 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 += Y_stride; RGB += RGB_stride; ONE; Y -= 1; RGB -= 3; ONE; Y -= Y_stride; RGB -= RGB_stride - 6; Y += 2; U += 1; V += 1; } Y += Y_stride*2 - x; U += UV_stride - x/2; V += UV_stride - x/2; RGB += RGB_stride*2 - 3*x; } }