Unified · Split
| @@ -182,6 +182,80 @@ static void check_interleave_bytes(void) · 181 unmodified lines | |||
| 182 | } | 182 | } |
| 183 | } | 183 | } |
| 184 | 184 | ||
| 185 | static void check_deinterleave_bytes(void) | ||
| 186 | { | ||
| 187 | LOCAL_ALIGNED_16(uint8_t, src_buf, [2*MAX_STRIDE*MAX_HEIGHT+2]); | ||
| 188 | LOCAL_ALIGNED_16(uint8_t, dst0_u_buf, [MAX_STRIDE*MAX_HEIGHT+1]); | ||
| 189 | LOCAL_ALIGNED_16(uint8_t, dst0_v_buf, [MAX_STRIDE*MAX_HEIGHT+1]); | ||
| 190 | LOCAL_ALIGNED_16(uint8_t, dst1_u_buf, [MAX_STRIDE*MAX_HEIGHT+1]); | ||
| 191 | LOCAL_ALIGNED_16(uint8_t, dst1_v_buf, [MAX_STRIDE*MAX_HEIGHT+1]); | ||
| 192 | // Intentionally using unaligned buffers, as this function doesn't have | ||
| 193 | // any alignment requirements. | ||
| 194 | uint8_t *src = src_buf + 2; | ||
| 195 | uint8_t *dst0_u = dst0_u_buf + 1; | ||
| 196 | uint8_t *dst0_v = dst0_v_buf + 1; | ||
| 197 | uint8_t *dst1_u = dst1_u_buf + 1; | ||
| 198 | uint8_t *dst1_v = dst1_v_buf + 1; | ||
| 199 | |||
| 200 | declare_func(void, const uint8_t *src, uint8_t *dst1, uint8_t *dst2, | ||
| 201 | int width, int height, int srcStride, | ||
| 202 | int dst1Stride, int dst2Stride); | ||
| 203 | |||
| 204 | randomize_buffers(src, 2*MAX_STRIDE*MAX_HEIGHT+2); | ||
| 205 | |||
| 206 | if (check_func(deinterleaveBytes, "deinterleave_bytes")) { | ||
| 207 | for (int i = 0; i <= 16; i++) { | ||
| 208 | // Try all widths [1,16], and try one random width. | ||
| 209 | |||
| 210 | int w = i > 0 ? i : (1 + (rnd() % (MAX_STRIDE-2))); | ||
| 211 | int h = 1 + (rnd() % (MAX_HEIGHT-2)); | ||
| 212 | |||
| 213 | int src_offset = 0, src_stride = 2 * MAX_STRIDE; | ||
| 214 | int dst_u_offset = 0, dst_u_stride = MAX_STRIDE; | ||
| 215 | int dst_v_offset = 0, dst_v_stride = MAX_STRIDE; | ||
| 216 | |||
| 217 | memset(dst0_u, 0, MAX_STRIDE * MAX_HEIGHT); | ||
| 218 | memset(dst0_v, 0, MAX_STRIDE * MAX_HEIGHT); | ||
| 219 | memset(dst1_u, 0, MAX_STRIDE * MAX_HEIGHT); | ||
| 220 | memset(dst1_v, 0, MAX_STRIDE * MAX_HEIGHT); | ||
| 221 | |||
| 222 | // Try different combinations of negative strides | ||
| 223 | if (i & 1) { | ||
| 224 | src_offset = (h-1)*src_stride; | ||
| 225 | src_stride = -src_stride; | ||
| 226 | } | ||
| 227 | if (i & 2) { | ||
| 228 | dst_u_offset = (h-1)*dst_u_stride; | ||
| 229 | dst_u_stride = -dst_u_stride; | ||
| 230 | } | ||
| 231 | if (i & 4) { | ||
| 232 | dst_v_offset = (h-1)*dst_v_stride; | ||
| 233 | dst_v_stride = -dst_v_stride; | ||
| 234 | } | ||
| 235 | |||
| 236 | call_ref(src + src_offset, dst0_u + dst_u_offset, dst0_v + dst_v_offset, | ||
| 237 | w, h, src_stride, dst_u_stride, dst_v_stride); | ||
| 238 | call_new(src + src_offset, dst1_u + dst_u_offset, dst1_v + dst_v_offset, | ||
| 239 | w, h, src_stride, dst_u_stride, dst_v_stride); | ||
| 240 | // Check a one pixel-pair edge around the destination area, | ||
| 241 | // to catch overwrites past the end. | ||
| 242 | checkasm_check(uint8_t, dst0_u, MAX_STRIDE, dst1_u, MAX_STRIDE, | ||
| 243 | w + 1, h + 1, "dst_u"); | ||
| 244 | checkasm_check(uint8_t, dst0_v, MAX_STRIDE, dst1_v, MAX_STRIDE, | ||
| 245 | w + 1, h + 1, "dst_v"); | ||
| 246 | } | ||
| 247 | |||
| 248 | bench_new(src, dst1_u, dst1_v, 127, MAX_HEIGHT, | ||
| 249 | 2*MAX_STRIDE, MAX_STRIDE, MAX_STRIDE); | ||
| 250 | } | ||
| 251 | if (check_func(deinterleaveBytes, "deinterleave_bytes_aligned")) { | ||
| 252 | // Bench the function in a more typical case, with aligned | ||
| 253 | // buffers and widths. | ||
| 254 | bench_new(src_buf, dst1_u_buf, dst1_v_buf, 128, MAX_HEIGHT, | ||
| 255 | 2*MAX_STRIDE, MAX_STRIDE, MAX_STRIDE); | ||
| 256 | } | ||
| 257 | } | ||
| 258 | |||
| 185 | #define MAX_LINE_SIZE 1920 | 259 | #define MAX_LINE_SIZE 1920 |
| 186 | static const int input_sizes[] = {8, 128, 1080, MAX_LINE_SIZE}; | 260 | static const int input_sizes[] = {8, 128, 1080, MAX_LINE_SIZE}; |
| 187 | static const enum AVPixelFormat rgb_formats[] = { | 261 | static const enum AVPixelFormat rgb_formats[] = { |
| @@ -315,6 +389,9 @@ void checkasm_check_sw_rgb(void) · 127 unmodified lines | |||
| 315 | check_interleave_bytes(); | 389 | check_interleave_bytes(); |
| 316 | report("interleave_bytes"); | 390 | report("interleave_bytes"); |
| 317 | 391 | ||
| 392 | check_deinterleave_bytes(); | ||
| 393 | report("deinterleave_bytes"); | ||
| 394 | |||
| 318 | ctx = sws_getContext(MAX_LINE_SIZE, MAX_LINE_SIZE, AV_PIX_FMT_RGB24, | 395 | ctx = sws_getContext(MAX_LINE_SIZE, MAX_LINE_SIZE, AV_PIX_FMT_RGB24, |
| 319 | MAX_LINE_SIZE, MAX_LINE_SIZE, AV_PIX_FMT_YUV420P, | 396 | MAX_LINE_SIZE, MAX_LINE_SIZE, AV_PIX_FMT_YUV420P, |
| 320 | SWS_ACCURATE_RND | SWS_BITEXACT, NULL, NULL, NULL); | 397 | SWS_ACCURATE_RND | SWS_BITEXACT, NULL, NULL, NULL); |