moved yuv into seperate files

master
Ahmet Inan 2011-09-08 14:31:11 +02:00
rodzic 60233b8fa7
commit b97d1bda33
4 zmienionych plików z 35 dodań i 16 usunięć

Wyświetl plik

@ -22,5 +22,5 @@ clean:
encode: encode.o mmap_file.o
decode: decode.o mmap_file.o pcm.o wav.o alsa.o window.o ddc.o delay.o
decode: decode.o mmap_file.o pcm.o wav.o alsa.o window.o ddc.o delay.o yuv.c

Wyświetl plik

@ -10,6 +10,7 @@
#include "pcm.h"
#include "ddc.h"
#include "delay.h"
#include "yuv.h"
float lerp(float a, float b, float x)
{
@ -40,21 +41,6 @@ char *string_time(char *fmt)
return s;
}
uint8_t R_YUV(uint8_t Y, uint8_t U, uint8_t V)
{
(void)U;
return limit(0.0, 255.0, 0.003906 * ((298.082 * (Y - 16.0)) + (408.583 * (V - 128))));
}
uint8_t G_YUV(uint8_t Y, uint8_t U, uint8_t V)
{
return limit(0.0, 255.0, 0.003906 * ((298.082 * (Y - 16.0)) + (-100.291 * (U - 128)) + (-208.12 * (V - 128))));
}
uint8_t B_YUV(uint8_t Y, uint8_t U, uint8_t V)
{
(void)V;
return limit(0.0, 255.0, 0.003906 * ((298.082 * (Y - 16.0)) + (516.411 * (U - 128))));
}
void process_line(uint8_t *pixel, uint8_t *y_pixel, uint8_t *uv_pixel, int y_width, int uv_width, int width, int height, int n)
{
// we only process after 2 full lines: on odd lines

24
yuv.c 100644
Wyświetl plik

@ -0,0 +1,24 @@
#include "yuv.h"
uint8_t yuv_limit(float x)
{
float tmp = x < 0.0 ? 0.0 : x;
return tmp > 255.0 ? 255.0 : tmp;
}
uint8_t R_YUV(uint8_t Y, uint8_t U, uint8_t V)
{
(void)U;
return yuv_limit(0.003906 * ((298.082 * (Y - 16.0)) + (408.583 * (V - 128))));
}
uint8_t G_YUV(uint8_t Y, uint8_t U, uint8_t V)
{
return yuv_limit(0.003906 * ((298.082 * (Y - 16.0)) + (-100.291 * (U - 128)) + (-208.12 * (V - 128))));
}
uint8_t B_YUV(uint8_t Y, uint8_t U, uint8_t V)
{
(void)V;
return yuv_limit(0.003906 * ((298.082 * (Y - 16.0)) + (516.411 * (U - 128))));
}

9
yuv.h 100644
Wyświetl plik

@ -0,0 +1,9 @@
#ifndef YUV_H
#define YUV_H
#include <stdint.h>
uint8_t R_YUV(uint8_t, uint8_t, uint8_t);
uint8_t G_YUV(uint8_t, uint8_t, uint8_t);
uint8_t B_YUV(uint8_t, uint8_t, uint8_t);
#endif