| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * Copyright (c) 2016 Alexandra Hájková | ||
| 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 | |||
| 26 | #include "libavcodec/hevc/dsp.h" | ||
| 27 | |||
| 28 | #include "checkasm.h" | ||
| 29 | |||
| 30 | #define randomize_buffers(buf, size) \ | ||
| 31 | do { \ | ||
| 32 | int j; \ | ||
| 33 | for (j = 0; j < size; j++) { \ | ||
| 34 | int16_t r = rnd(); \ | ||
| 35 | AV_WN16A(buf + j, r >> 3); \ | ||
| 36 | } \ | ||
| 37 | } while (0) | ||
| 38 | |||
| 39 | #define randomize_buffers2(buf, size, mask) \ | ||
| 40 | do { \ | ||
| 41 | int j; \ | ||
| 42 | for (j = 0; j < size; j++) \ | ||
| 43 | AV_WN16A(buf + j * 2, rnd() & mask); \ | ||
| 44 | } while (0) | ||
| 45 | |||
| 46 | 62 | static void compare_add_res(int size, ptrdiff_t stride, int overflow_test, int mask) | |
| 47 | { | ||
| 48 | 62 | LOCAL_ALIGNED_32(int16_t, res0, [32 * 32]); | |
| 49 | 62 | LOCAL_ALIGNED_32(int16_t, res1, [32 * 32]); | |
| 50 | 62 | LOCAL_ALIGNED_32(uint8_t, dst0, [32 * 32 * 2]); | |
| 51 | 62 | LOCAL_ALIGNED_32(uint8_t, dst1, [32 * 32 * 2]); | |
| 52 | |||
| 53 |
2/2✓ Branch 1 taken 22 times.
✓ Branch 2 taken 40 times.
|
62 | declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, const int16_t *res, ptrdiff_t stride); |
| 54 | |||
| 55 |
2/2✓ Branch 1 taken 23648 times.
✓ Branch 2 taken 62 times.
|
23710 | randomize_buffers(res0, size); |
| 56 |
2/2✓ Branch 1 taken 23648 times.
✓ Branch 2 taken 62 times.
|
23710 | randomize_buffers2(dst0, size, mask); |
| 57 |
2/2✓ Branch 0 taken 31 times.
✓ Branch 1 taken 31 times.
|
62 | if (overflow_test) |
| 58 | 31 | res0[0] = 0x8000; | |
| 59 | 62 | memcpy(res1, res0, sizeof(*res0) * size); | |
| 60 | 62 | memcpy(dst1, dst0, sizeof(int16_t) * size); | |
| 61 | |||
| 62 | 62 | call_ref(dst0, res0, stride); | |
| 63 | 62 | call_new(dst1, res1, stride); | |
| 64 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
|
62 | if (memcmp(dst0, dst1, size)) |
| 65 | ✗ | fail(); | |
| 66 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 62 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.
|
62 | bench_new(dst1, res1, stride); |
| 67 | 62 | } | |
| 68 | |||
| 69 | 70 | static void check_add_res(HEVCDSPContext *h, int bit_depth) | |
| 70 | { | ||
| 71 | int i; | ||
| 72 |
4/4✓ Branch 0 taken 56 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 42 times.
|
70 | int mask = bit_depth == 8 ? 0xFFFF : bit_depth == 10 ? 0x03FF : 0x07FF; |
| 73 | |||
| 74 |
2/2✓ Branch 0 taken 280 times.
✓ Branch 1 taken 70 times.
|
350 | for (i = 2; i <= 5; i++) { |
| 75 | 280 | int block_size = 1 << i; | |
| 76 | 280 | int size = block_size * block_size; | |
| 77 | 280 | ptrdiff_t stride = block_size << (bit_depth > 8); | |
| 78 | |||
| 79 |
2/2✓ Branch 3 taken 31 times.
✓ Branch 4 taken 249 times.
|
280 | if (check_func(h->add_residual[i - 2], "hevc_add_res_%dx%d_%d", block_size, block_size, bit_depth)) { |
| 80 | 31 | compare_add_res(size, stride, 0, mask); | |
| 81 | // overflow test for res = -32768 | ||
| 82 | 31 | compare_add_res(size, stride, 1, mask); | |
| 83 | } | ||
| 84 | } | ||
| 85 | 70 | } | |
| 86 | |||
| 87 | 14 | void checkasm_check_hevc_add_res(void) | |
| 88 | { | ||
| 89 | int bit_depth; | ||
| 90 | |||
| 91 |
2/2✓ Branch 0 taken 70 times.
✓ Branch 1 taken 14 times.
|
84 | for (bit_depth = 8; bit_depth <= 12; bit_depth++) { |
| 92 | HEVCDSPContext h; | ||
| 93 | |||
| 94 | 70 | ff_hevc_dsp_init(&h, bit_depth); | |
| 95 | 70 | check_add_res(&h, bit_depth); | |
| 96 | } | ||
| 97 | 14 | report("add_residual"); | |
| 98 | 14 | } | |
| 99 |