| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * This file is part of FFmpeg. | ||
| 3 | * | ||
| 4 | * FFmpeg is free software; you can redistribute it and/or modify | ||
| 5 | * it under the terms of the GNU General Public License as published by | ||
| 6 | * the Free Software Foundation; either version 2 of the License, or | ||
| 7 | * (at your option) any later version. | ||
| 8 | * | ||
| 9 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | * GNU General Public License for more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU General Public License along | ||
| 15 | * with FFmpeg; if not, write to the Free Software Foundation, Inc., | ||
| 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 17 | */ | ||
| 18 | |||
| 19 | #include <string.h> | ||
| 20 | |||
| 21 | #include "libavutil/common.h" | ||
| 22 | #include "libavutil/intreadwrite.h" | ||
| 23 | #include "libavutil/mem_internal.h" | ||
| 24 | #include "libavutil/pixdesc.h" | ||
| 25 | |||
| 26 | #include "libswscale/swscale.h" | ||
| 27 | #include "libswscale/swscale_internal.h" | ||
| 28 | |||
| 29 | #include "checkasm.h" | ||
| 30 | |||
| 31 | #define randomize_buffers(buf, size) \ | ||
| 32 | do { \ | ||
| 33 | for (int j = 0; j < size; j += 4) \ | ||
| 34 | AV_WN32(buf + j, rnd()); \ | ||
| 35 | } while (0) | ||
| 36 | |||
| 37 | 14 | static void check_semiplanar(int dst_pix_fmt) | |
| 38 | { | ||
| 39 | static const int src_fmts[] = { | ||
| 40 | AV_PIX_FMT_NV24, | ||
| 41 | AV_PIX_FMT_NV42, | ||
| 42 | }; | ||
| 43 | 14 | const AVPixFmtDescriptor *dst_desc = av_pix_fmt_desc_get(dst_pix_fmt); | |
| 44 | #define NUM_LINES 4 | ||
| 45 | #define MAX_LINE_SIZE 1920 | ||
| 46 | static const int input_sizes[] = {8, 128, 1080, MAX_LINE_SIZE}; | ||
| 47 | |||
| 48 | 14 | declare_func(int, SwsInternal *c, const uint8_t *const src[], | |
| 49 | const int srcStride[], int srcSliceY, int srcSliceH, | ||
| 50 | uint8_t *const dstParam[], const int dstStride[]); | ||
| 51 | |||
| 52 | 14 | LOCAL_ALIGNED_8(uint8_t, src_y, [MAX_LINE_SIZE * NUM_LINES]); | |
| 53 | 14 | LOCAL_ALIGNED_8(uint8_t, src_uv, [MAX_LINE_SIZE * NUM_LINES * 2]); | |
| 54 | 14 | const uint8_t *src[4] = { src_y, src_uv }; | |
| 55 | |||
| 56 | 14 | LOCAL_ALIGNED_8(uint8_t, dst0_y, [MAX_LINE_SIZE * NUM_LINES]); | |
| 57 | 14 | LOCAL_ALIGNED_8(uint8_t, dst0_u, [MAX_LINE_SIZE * NUM_LINES / 2]); | |
| 58 | 14 | LOCAL_ALIGNED_8(uint8_t, dst0_v, [MAX_LINE_SIZE * NUM_LINES / 2]); | |
| 59 | 14 | uint8_t *dst0[4] = { dst0_y, dst0_u, dst0_v }; | |
| 60 | |||
| 61 | 14 | LOCAL_ALIGNED_8(uint8_t, dst1_y, [MAX_LINE_SIZE * NUM_LINES]); | |
| 62 | 14 | LOCAL_ALIGNED_8(uint8_t, dst1_u, [MAX_LINE_SIZE * NUM_LINES / 2]); | |
| 63 | 14 | LOCAL_ALIGNED_8(uint8_t, dst1_v, [MAX_LINE_SIZE * NUM_LINES / 2]); | |
| 64 | 14 | uint8_t *dst1[4] = { dst1_y, dst1_u, dst1_v }; | |
| 65 | |||
| 66 |
2/2✓ Branch 1 taken 26880 times.
✓ Branch 2 taken 14 times.
|
26894 | randomize_buffers(src_y, MAX_LINE_SIZE * NUM_LINES); |
| 67 |
2/2✓ Branch 1 taken 53760 times.
✓ Branch 2 taken 14 times.
|
53774 | randomize_buffers(src_uv, MAX_LINE_SIZE * NUM_LINES * 2); |
| 68 | |||
| 69 |
2/2✓ Branch 0 taken 28 times.
✓ Branch 1 taken 14 times.
|
42 | for (int sfi = 0; sfi < FF_ARRAY_ELEMS(src_fmts); sfi++) { |
| 70 | 28 | int src_pix_fmt = src_fmts[sfi]; | |
| 71 | 28 | const AVPixFmtDescriptor *src_desc = av_pix_fmt_desc_get(src_pix_fmt); | |
| 72 |
2/2✓ Branch 0 taken 112 times.
✓ Branch 1 taken 28 times.
|
140 | for (int isi = 0; isi < FF_ARRAY_ELEMS(input_sizes); isi++) { |
| 73 | SwsContext *sws; | ||
| 74 | SwsInternal *c; | ||
| 75 | int log_level; | ||
| 76 | 112 | int width = input_sizes[isi]; | |
| 77 | 112 | int srcSliceY = 0; | |
| 78 | 112 | int srcSliceH = NUM_LINES; | |
| 79 | 112 | int srcStride[4] = { | |
| 80 | MAX_LINE_SIZE, | ||
| 81 | MAX_LINE_SIZE * 2, | ||
| 82 | }; | ||
| 83 | 112 | int dstStride[4] = { | |
| 84 | MAX_LINE_SIZE, | ||
| 85 | 112 | MAX_LINE_SIZE >> dst_desc->log2_chroma_w, | |
| 86 | 112 | MAX_LINE_SIZE >> dst_desc->log2_chroma_w, | |
| 87 | }; | ||
| 88 | |||
| 89 | // override log level to prevent spamming of the message | ||
| 90 | // "No accelerated colorspace conversion found from %s to %s" | ||
| 91 | 112 | log_level = av_log_get_level(); | |
| 92 | 112 | av_log_set_level(AV_LOG_ERROR); | |
| 93 | 112 | sws = sws_getContext(width, srcSliceH, src_pix_fmt, | |
| 94 | width, srcSliceH, dst_pix_fmt, | ||
| 95 | 0, NULL, NULL, NULL); | ||
| 96 | 112 | av_log_set_level(log_level); | |
| 97 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
|
112 | if (!sws) |
| 98 | ✗ | fail(); | |
| 99 | |||
| 100 | 112 | c = sws_internal(sws); | |
| 101 |
2/2✓ Branch 3 taken 8 times.
✓ Branch 4 taken 104 times.
|
112 | if (check_func(c->convert_unscaled, "%s_%s_%d", src_desc->name, dst_desc->name, width)) { |
| 102 | 8 | memset(dst0_y, 0xFF, MAX_LINE_SIZE * NUM_LINES); | |
| 103 | 8 | memset(dst0_u, 0xFF, MAX_LINE_SIZE * NUM_LINES / 2); | |
| 104 | 8 | memset(dst0_v, 0xFF, MAX_LINE_SIZE * NUM_LINES / 2); | |
| 105 | 8 | memset(dst1_y, 0xFF, MAX_LINE_SIZE * NUM_LINES); | |
| 106 | 8 | memset(dst1_u, 0xFF, MAX_LINE_SIZE * NUM_LINES / 2); | |
| 107 | 8 | memset(dst1_v, 0xFF, MAX_LINE_SIZE * NUM_LINES / 2); | |
| 108 | |||
| 109 | 8 | call_ref(c, src, srcStride, srcSliceY, | |
| 110 | srcSliceH, dst0, dstStride); | ||
| 111 | 8 | call_new(c, src, srcStride, srcSliceY, | |
| 112 | srcSliceH, dst1, dstStride); | ||
| 113 | |||
| 114 |
1/2✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
8 | if (memcmp(dst0_y, dst1_y, MAX_LINE_SIZE * NUM_LINES) || |
| 115 |
1/2✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
8 | memcmp(dst0_u, dst1_u, MAX_LINE_SIZE * NUM_LINES / 2) || |
| 116 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
|
8 | memcmp(dst0_v, dst1_v, MAX_LINE_SIZE * NUM_LINES / 2)) |
| 117 | ✗ | fail(); | |
| 118 | |||
| 119 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 8 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.
|
8 | bench_new(c, src, srcStride, srcSliceY, |
| 120 | srcSliceH, dst0, dstStride); | ||
| 121 | } | ||
| 122 | 112 | sws_freeContext(sws); | |
| 123 | } | ||
| 124 | } | ||
| 125 | 14 | } | |
| 126 | |||
| 127 | #undef NUM_LINES | ||
| 128 | #undef MAX_LINE_SIZE | ||
| 129 | |||
| 130 | 14 | void checkasm_check_sw_yuv2yuv(void) | |
| 131 | { | ||
| 132 | 14 | check_semiplanar(AV_PIX_FMT_YUV420P); | |
| 133 | 14 | report("yuv420p"); | |
| 134 | 14 | } | |
| 135 |