ref: 66d57ced36e86949df7793fe4c21826951934fea
parent: 66c086c68d190935c0113735278a99b100bf07da
author: Sigrid Haflínudóttir <[email protected]>
date: Wed Sep 23 11:08:56 EDT 2020
YUV: reformat
--- a/misc.h
+++ b/misc.h
@@ -1,9 +1,10 @@
int str2fmt(char *s);
uvlong nanosec(void);
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);
+ int width, int height,
+ u8int *y, u8int *u, u8int *v,
+ u32int ystride, u32int uvstride,
+ u8int *rgb, u32int rgbstride);
extern int nproc;
extern int debug;
--- a/yuv.c
+++ b/yuv.c
@@ -1,43 +1,44 @@
#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)
+ int width, int height,
+ u8int *y, u8int *u, u8int *v,
+ u32int ystride, u32int uvstride,
+ u8int *rgb, u32int rgbstride)
{
- u32int x, y;
- int yy1, cb1, cr1;
- int r, g, b, go;
+ u32int w, h;
+ int r, g, b;
+ int yy1, cb1, cr1, go;
- for(y = 0; y < height-1; y += 2){
- for(x = 0; x < width-1; x += 2){
- cb1 = *U - 0x80;
- cr1 = *V - 0x80;
+ 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; \
+ yy1 = *y * 0x10101; \
b = yy1 + 116130*cb1; \
- RGB[0] = (b >> 24) ? ~(b >> 31) : (b>>16); \
+ rgb[0] = (b >> 24) ? ~(b >> 31) : (b>>16); \
g = yy1 - go; \
- RGB[1] = (g >> 24) ? ~(g >> 31) : (g>>16); \
+ rgb[1] = (g >> 24) ? ~(g >> 31) : (g>>16); \
r = yy1 + 91881*cr1; \
- RGB[2] = (r >> 24) ? ~(r >> 31) : (r>>16); \
+ 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;
+ 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 += 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;
+ y += ystride*2 - w;
+ u += uvstride - w/2;
+ v += uvstride - w/2;
+ rgb += rgbstride*2 - 3*w;
}
}