| 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); \ | ||
| 36 | } \ | ||
| 37 | } while (0) | ||
| 38 | |||
| 39 | 42 | static void check_idct(HEVCDSPContext *h, int bit_depth) | |
| 40 | { | ||
| 41 | int i; | ||
| 42 | 42 | LOCAL_ALIGNED(32, int16_t, coeffs0, [32 * 32]); | |
| 43 | 42 | LOCAL_ALIGNED(32, int16_t, coeffs1, [32 * 32]); | |
| 44 | |||
| 45 |
2/2✓ Branch 0 taken 168 times.
✓ Branch 1 taken 42 times.
|
210 | for (i = 2; i <= 5; i++) { |
| 46 | 168 | int block_size = 1 << i; | |
| 47 | 168 | int size = block_size * block_size; | |
| 48 | 168 | int col_limit = block_size; | |
| 49 | 168 | declare_func(void, int16_t *coeffs, int col_limit); | |
| 50 | |||
| 51 |
2/2✓ Branch 1 taken 57120 times.
✓ Branch 2 taken 168 times.
|
57288 | randomize_buffers(coeffs0, size); |
| 52 | 168 | memcpy(coeffs1, coeffs0, sizeof(*coeffs0) * size); | |
| 53 |
2/2✓ Branch 3 taken 28 times.
✓ Branch 4 taken 140 times.
|
168 | if (check_func(h->idct[i - 2], "hevc_idct_%dx%d_%d", block_size, block_size, bit_depth)) { |
| 54 | 28 | call_ref(coeffs0, col_limit); | |
| 55 | 28 | call_new(coeffs1, col_limit); | |
| 56 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
|
28 | if (memcmp(coeffs0, coeffs1, sizeof(*coeffs0) * size)) |
| 57 | ✗ | fail(); | |
| 58 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 28 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.
|
28 | bench_new(coeffs1, col_limit); |
| 59 | } | ||
| 60 | } | ||
| 61 | 42 | } | |
| 62 | |||
| 63 | 42 | static void check_idct_dc(HEVCDSPContext *h, int bit_depth) | |
| 64 | { | ||
| 65 | int i; | ||
| 66 | 42 | LOCAL_ALIGNED(32, int16_t, coeffs0, [32 * 32]); | |
| 67 | 42 | LOCAL_ALIGNED(32, int16_t, coeffs1, [32 * 32]); | |
| 68 | |||
| 69 |
2/2✓ Branch 0 taken 168 times.
✓ Branch 1 taken 42 times.
|
210 | for (i = 2; i <= 5; i++) { |
| 70 | 168 | int block_size = 1 << i; | |
| 71 | 168 | int size = block_size * block_size; | |
| 72 | 168 | declare_func(void, int16_t *coeffs); | |
| 73 | |||
| 74 |
2/2✓ Branch 1 taken 57120 times.
✓ Branch 2 taken 168 times.
|
57288 | randomize_buffers(coeffs0, size); |
| 75 | 168 | memcpy(coeffs1, coeffs0, sizeof(*coeffs0) * size); | |
| 76 | |||
| 77 |
2/2✓ Branch 3 taken 30 times.
✓ Branch 4 taken 138 times.
|
168 | if (check_func(h->idct_dc[i - 2], "hevc_idct_%dx%d_dc_%d", block_size, block_size, bit_depth)) { |
| 78 | 30 | call_ref(coeffs0); | |
| 79 | 30 | call_new(coeffs1); | |
| 80 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
|
30 | if (memcmp(coeffs0, coeffs1, sizeof(*coeffs0) * size)) |
| 81 | ✗ | fail(); | |
| 82 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 30 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.
|
30 | bench_new(coeffs1); |
| 83 | } | ||
| 84 | } | ||
| 85 | 42 | } | |
| 86 | |||
| 87 | 42 | static void check_transform_luma(HEVCDSPContext *h, int bit_depth) | |
| 88 | { | ||
| 89 | 42 | LOCAL_ALIGNED(32, int16_t, coeffs0, [32 * 32]); | |
| 90 | 42 | LOCAL_ALIGNED(32, int16_t, coeffs1, [32 * 32]); | |
| 91 | |||
| 92 | 42 | int block_size = 4; | |
| 93 | 42 | int size = block_size * block_size; | |
| 94 | 42 | declare_func(void, int16_t *coeffs); | |
| 95 | |||
| 96 |
2/2✓ Branch 1 taken 672 times.
✓ Branch 2 taken 42 times.
|
714 | randomize_buffers(coeffs0, size); |
| 97 | 42 | memcpy(coeffs1, coeffs0, sizeof(*coeffs0) * size); | |
| 98 | |||
| 99 |
2/2✓ Branch 3 taken 3 times.
✓ Branch 4 taken 39 times.
|
42 | if (check_func(h->transform_4x4_luma, "hevc_transform_luma_4x4_%d", bit_depth)) { |
| 100 | 3 | call_ref(coeffs0); | |
| 101 | 3 | call_new(coeffs1); | |
| 102 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (memcmp(coeffs0, coeffs1, sizeof(*coeffs0) * size)) |
| 103 | ✗ | fail(); | |
| 104 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 3 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.
|
3 | bench_new(coeffs1); |
| 105 | } | ||
| 106 | 42 | } | |
| 107 | |||
| 108 | 14 | void checkasm_check_hevc_idct(void) | |
| 109 | { | ||
| 110 | int bit_depth; | ||
| 111 | |||
| 112 |
2/2✓ Branch 0 taken 42 times.
✓ Branch 1 taken 14 times.
|
56 | for (bit_depth = 8; bit_depth <= 12; bit_depth += 2) { |
| 113 | HEVCDSPContext h; | ||
| 114 | |||
| 115 | 42 | ff_hevc_dsp_init(&h, bit_depth); | |
| 116 | 42 | check_idct_dc(&h, bit_depth); | |
| 117 | } | ||
| 118 | 14 | report("idct_dc"); | |
| 119 | |||
| 120 |
2/2✓ Branch 0 taken 42 times.
✓ Branch 1 taken 14 times.
|
56 | for (bit_depth = 8; bit_depth <= 12; bit_depth += 2) { |
| 121 | HEVCDSPContext h; | ||
| 122 | |||
| 123 | 42 | ff_hevc_dsp_init(&h, bit_depth); | |
| 124 | 42 | check_idct(&h, bit_depth); | |
| 125 | } | ||
| 126 | 14 | report("idct"); | |
| 127 | |||
| 128 |
2/2✓ Branch 0 taken 42 times.
✓ Branch 1 taken 14 times.
|
56 | for (bit_depth = 8; bit_depth <= 12; bit_depth += 2) { |
| 129 | HEVCDSPContext h; | ||
| 130 | |||
| 131 | 42 | ff_hevc_dsp_init(&h, bit_depth); | |
| 132 | 42 | check_transform_luma(&h, bit_depth); | |
| 133 | } | ||
| 134 | 14 | report("transform_luma"); | |
| 135 | 14 | } | |
| 136 |