descampsa / yuv2rgb

C99 library for fast image conversion between yuv420p and rgb24
BSD 3-Clause "New" or "Revised" License
170 stars 62 forks source link

Problem if the height value is odd #13

Open krolikor opened 4 years ago

krolikor commented 4 years ago

Hello

It's a very good and fast code, but there is one problem. If the height value is odd, then the resulting image has the wrong last line of pixels. Or maybe I do something wrong? To test it you just need to reduce the test1.ppm file by one line to size: 80x69 A sample code: ` uint8_t out_buf = (uint8_t )malloc(width height 3);

uint8_t *YUV = NULL, *Y = NULL, *U = NULL, *V = NULL;

YUV = (uint8_t *)malloc(width * height * 3 / 2);

Y = YUV;
U = YUV + width * height;
V = YUV + width * height + ((width + 1) / 2)*((height + 1) / 2);

//convert to yuv and back to rgb
rgb24_yuv420_std(width, height, test1_80_69_bmp, width * 3, Y, U, V, width, (width + 1) / 2, YCBCR_601);

yuv420_rgb24_std(width, height, Y, U, V, width, (width + 1) / 2, out_buf, width * 3, YCBCR_601);`