Browse Source

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.
jp9000 8 năm trước cách đây
mục cha
commit
849944ca79
1 tập tin đã thay đổi với 8 bổ sung8 xóa
  1. 8 8
      libobs/media-io/format-conversion.c

+ 8 - 8
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;
 		}
 	}
 }