From 849944ca7983362dd064ca81a707220a38d1540f Mon Sep 17 00:00:00 2001 From: jp9000 Date: Thu, 28 Sep 2017 15:07:22 -0700 Subject: [PATCH] libobs/media-io: Fix decompress_420 function This function had a number of bugs and just wasn't working properly at all. This function is currently not used in public builds because GPU is used for color conversion instead (hence why it had probably not really been tested), but a need came up where CPU conversion was useful for the sake of testing something else in the back-end, and it needed to be fixed before CPU conversion could be used. --- libobs/media-io/format-conversion.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libobs/media-io/format-conversion.c b/libobs/media-io/format-conversion.c index 99f366c6c..1c6d34105 100644 --- a/libobs/media-io/format-conversion.c +++ b/libobs/media-io/format-conversion.c @@ -208,7 +208,7 @@ void decompress_420( uint8_t *output, uint32_t out_linesize) { uint32_t start_y_d2 = start_y/2; - uint32_t width_d2 = min_uint32(in_linesize[0], out_linesize)/2; + uint32_t width_d2 = in_linesize[0]/2; uint32_t height_d2 = end_y/2; uint32_t y; @@ -221,18 +221,18 @@ void decompress_420( lum0 = input[0] + y * 2 * in_linesize[0]; lum1 = lum0 + in_linesize[0]; - output0 = (uint32_t*)(output + y * 2 * in_linesize[0]); - output1 = (uint32_t*)((uint8_t*)output0 + in_linesize[0]); + output0 = (uint32_t*)(output + y * 2 * out_linesize); + output1 = (uint32_t*)((uint8_t*)output0 + out_linesize); for (x = 0; x < width_d2; x++) { uint32_t out; - out = (*(chroma0++) << 8) | (*(chroma1++) << 16); + out = (*(chroma0++) << 8) | *(chroma1++); - *(output0++) = *(lum0++) | out; - *(output0++) = *(lum0++) | out; + *(output0++) = (*(lum0++) << 16) | out; + *(output0++) = (*(lum0++) << 16) | out; - *(output1++) = *(lum1++) | out; - *(output1++) = *(lum1++) | out; + *(output1++) = (*(lum1++) << 16) | out; + *(output1++) = (*(lum1++) << 16) | out; } } }