kopia lustrzana https://github.com/xdsopl/robot36
moved yuv into seperate files
rodzic
60233b8fa7
commit
b97d1bda33
2
Makefile
2
Makefile
|
@ -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
|
||||
|
||||
|
|
16
decode.c
16
decode.c
|
@ -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
|
||||
|
|
|
@ -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))));
|
||||
}
|
||||
|
|
@ -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
|
Ładowanie…
Reference in New Issue