fastest way to get yuv table in firmware developing

Hi, I am developing ntsc/pal shield. And writing driver in C.

I have done everything, except to send yuv table.

the vs23 chip need VUY 224 streaming,(other format 8bit is OK by setting the chip).

I don’t know how to get YUV is the most convenient and most efficient.

https://github.com/openmv/openmv/blob/master/tools/gen_rgb2yuv.py ?

https://github.com/openmv/openmv/blob/master/src/omv/img/yuv_tab.c ?

Um, the best way to send data to the chip is to fb _alloc a large array of bytes for the image size (3 bytes per pixel) and then send that buffer using SPI to the chip. See the py_lcd.c file (under src/omv/py) to see what to do. It’s pretty straight forward. The LUT is already on chip with our firmware so just use (for RGB565 image only):

COLOR_RGB565_TO_Y(pixel)
COLOR_RGB565_TO_U(pixel)
COLOR_RGB565_TO_V(pixel)

And you’d put the values in the order they need to be in the buffer and then call the SPI write method to send them in one blast.

my code:

uint8_t pixel = IM_GET_GS_PIXEL(arg_img, x, y);
uint8_t y = COLOR_RGB565_TO_Y(pixel);
uint8_t u = COLOR_RGB565_TO_U(pixel);
uint8_t v = COLOR_RGB565_TO_V(pixel);
uint8_t v2 = (v>>0)&0b11000000;        //this maybe wrong
uint8_t u2 = (u>>2)&0b00110000;
uint8_t y4 = (y>>4)&0b00001111;
uint8_t color = y4+u2+v2;
SpiSendReceiveByte(color);

COLOR_RGB565_TO_Y function is a macro.
Maybe the process of packaging yuv into a byte is wrong. :open_mouth:

I solved it.
TV can already display the image, then I will adjust the color, and optimize the efficiency :smiley:
Thanks.

            uint16_t pixel = IM_GET_RGB565_PIXEL(arg_img, x, y);
            //uint8_t pixel = IM_GET_GS_PIXEL(arg_img, x, y);
            int8_t y8 = COLOR_RGB565_TO_Y(pixel);
            int8_t u8 = COLOR_RGB565_TO_U(pixel);
            int8_t v8 = COLOR_RGB565_TO_V(pixel);
            uint8_t y4 = (y8+128)>>4;
            uint8_t v2 = v8>>6;
            uint8_t u2 = u8>>6;
            int8_t color = y4+(u2<<6)+(v2<<4);
            SpiSendReceiveByte(color);

Post a video.

I used a 16bit color and it was slower. The color is wrong and the red color will be displayed in green.
IMG_3704.mov (5.31 MB)

Mmm, the SPI freq seems to slow?