| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * Copyright (c) 2025 Arpad Panyik <Arpad.Panyik@arm.com> | ||
| 3 | * | ||
| 4 | * This file is part of FFmpeg. | ||
| 5 | * | ||
| 6 | * FFmpeg is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2 of the License, or | ||
| 9 | * (at your option) any later version. | ||
| 10 | * | ||
| 11 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License along | ||
| 17 | * with FFmpeg; if not, write to the Free Software Foundation, Inc., | ||
| 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 19 | */ | ||
| 20 | |||
| 21 | #include <string.h> | ||
| 22 | |||
| 23 | #include "libavutil/intreadwrite.h" | ||
| 24 | #include "libavutil/mem_internal.h" | ||
| 25 | #include "libavutil/pixdesc.h" | ||
| 26 | #include "libavutil/pixfmt.h" | ||
| 27 | |||
| 28 | #include "libswscale/swscale.h" | ||
| 29 | #include "libswscale/swscale_internal.h" | ||
| 30 | |||
| 31 | #include "checkasm.h" | ||
| 32 | |||
| 33 | #define NUM_LINES 4 | ||
| 34 | #define MAX_LINE_SIZE 1920 | ||
| 35 | |||
| 36 | #define randomize_buffers(buf, size) \ | ||
| 37 | do { \ | ||
| 38 | for (int j = 0; j < size; j += 2) \ | ||
| 39 | AV_WN32(buf + j, rnd()); \ | ||
| 40 | } while (0) | ||
| 41 | |||
| 42 | 14 | static void check_xyz12Torgb48le(void) | |
| 43 | { | ||
| 44 | static const int input_sizes[] = {1, 2, 3, 4, 5, 6, 7, 8, 16, 17, 21, 31, | ||
| 45 | 32, 64, 128, 256, 512, 1024, | ||
| 46 | MAX_LINE_SIZE}; | ||
| 47 | |||
| 48 | 14 | const int src_stride = 3 * sizeof(uint16_t) * MAX_LINE_SIZE; | |
| 49 | 14 | const int dst_stride = src_stride; | |
| 50 | |||
| 51 | 14 | const int src_pix_fmt = AV_PIX_FMT_XYZ12LE; | |
| 52 | 14 | const int dst_pix_fmt = AV_PIX_FMT_RGB48LE; | |
| 53 | |||
| 54 | 14 | const AVPixFmtDescriptor *src_desc = av_pix_fmt_desc_get(src_pix_fmt); | |
| 55 | 14 | const AVPixFmtDescriptor *dst_desc = av_pix_fmt_desc_get(dst_pix_fmt); | |
| 56 | |||
| 57 | 14 | LOCAL_ALIGNED_8(uint16_t, src, [3 * MAX_LINE_SIZE * NUM_LINES]); | |
| 58 | 14 | LOCAL_ALIGNED_8(uint16_t, dst_ref, [3 * MAX_LINE_SIZE * NUM_LINES]); | |
| 59 | 14 | LOCAL_ALIGNED_8(uint16_t, dst_new, [3 * MAX_LINE_SIZE * NUM_LINES]); | |
| 60 | |||
| 61 | 14 | declare_func(void, const SwsInternal *, uint8_t *, int, const uint8_t *, | |
| 62 | int, int, int); | ||
| 63 | |||
| 64 | SwsInternal c; | ||
| 65 | 14 | memset(&c, 0, sizeof(c)); | |
| 66 | 14 | c.opts.src_format = src_pix_fmt; | |
| 67 | 14 | ff_sws_init_xyzdsp(&c); | |
| 68 | 14 | ff_sws_fill_xyztables(&c); | |
| 69 | |||
| 70 |
2/2✓ Branch 1 taken 161280 times.
✓ Branch 2 taken 14 times.
|
161294 | randomize_buffers(src, 3 * MAX_LINE_SIZE * NUM_LINES); |
| 71 | |||
| 72 |
2/2✓ Branch 0 taken 56 times.
✓ Branch 1 taken 14 times.
|
70 | for (int height = 1; height <= NUM_LINES; height++) { |
| 73 |
2/2✓ Branch 0 taken 1064 times.
✓ Branch 1 taken 56 times.
|
1120 | for (int isi = 0; isi < FF_ARRAY_ELEMS(input_sizes); isi++) { |
| 74 | 1064 | int width = input_sizes[isi]; | |
| 75 | |||
| 76 |
2/2✓ Branch 3 taken 76 times.
✓ Branch 4 taken 988 times.
|
1064 | if (check_func(c.xyz12Torgb48, "%s_%s_%dx%d", src_desc->name, |
| 77 | dst_desc->name, width, height)) { | ||
| 78 | 76 | memset(dst_ref, 0xFE, | |
| 79 | 3 * sizeof(uint16_t) * MAX_LINE_SIZE * NUM_LINES); | ||
| 80 | 76 | memset(dst_new, 0xFE, | |
| 81 | 3 * sizeof(uint16_t) * MAX_LINE_SIZE * NUM_LINES); | ||
| 82 | |||
| 83 | 76 | call_ref(&c, (uint8_t *)dst_ref, dst_stride, | |
| 84 | (const uint8_t *)src, src_stride, width, height); | ||
| 85 | 76 | call_new(&c, (uint8_t *)dst_new, dst_stride, | |
| 86 | (const uint8_t *)src, src_stride, width, height); | ||
| 87 | |||
| 88 | 76 | checkasm_check(uint16_t, dst_ref, dst_stride, dst_new, | |
| 89 | dst_stride, width, height, "dst_rgb"); | ||
| 90 | |||
| 91 |
4/4✓ Branch 0 taken 40 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 30 times.
|
76 | if (!(width & 3) && height == NUM_LINES) { |
| 92 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
|
10 | bench_new(&c, (uint8_t *)dst_new, |
| 93 | dst_stride, (const uint8_t *)src, src_stride, | ||
| 94 | width, height); | ||
| 95 | } | ||
| 96 | } | ||
| 97 | } | ||
| 98 | } | ||
| 99 | 14 | } | |
| 100 | |||
| 101 | #undef NUM_LINES | ||
| 102 | #undef MAX_LINE_SIZE | ||
| 103 | |||
| 104 | 14 | void checkasm_check_sw_xyz2rgb(void) | |
| 105 | { | ||
| 106 | 14 | check_xyz12Torgb48le(); | |
| 107 | 14 | report("xyz12Torgb48le"); | |
| 108 | 14 | } | |
| 109 |