| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * Copyright (c) 2018 Yingming Fan <yingmingfan@gmail.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 | |||
| 26 | #include "libavcodec/hevc/dsp.h" | ||
| 27 | |||
| 28 | #include "checkasm.h" | ||
| 29 | |||
| 30 | static const uint32_t pixel_mask[3] = { 0xffffffff, 0x03ff03ff, 0x0fff0fff }; | ||
| 31 | static const uint32_t sao_size[5] = {8, 16, 32, 48, 64}; | ||
| 32 | |||
| 33 | #define SIZEOF_PIXEL ((bit_depth + 7) / 8) | ||
| 34 | #define PIXEL_STRIDE (2*MAX_PB_SIZE + AV_INPUT_BUFFER_PADDING_SIZE) //same with sao_edge src_stride | ||
| 35 | #define BUF_SIZE (PIXEL_STRIDE * (64+2) * 2) //+2 for top and bottom row, *2 for high bit depth | ||
| 36 | #define OFFSET_THRESH (1 << (bit_depth - 5)) | ||
| 37 | #define OFFSET_LENGTH 5 | ||
| 38 | |||
| 39 | #define randomize_buffers(buf0, buf1, size) \ | ||
| 40 | do { \ | ||
| 41 | uint32_t mask = pixel_mask[(bit_depth - 8) >> 1]; \ | ||
| 42 | int k; \ | ||
| 43 | for (k = 0; k < size; k += 4) { \ | ||
| 44 | uint32_t r = rnd() & mask; \ | ||
| 45 | AV_WN32A(buf0 + k, r); \ | ||
| 46 | AV_WN32A(buf1 + k, r); \ | ||
| 47 | } \ | ||
| 48 | } while (0) | ||
| 49 | |||
| 50 | #define randomize_buffers2(buf, size) \ | ||
| 51 | do { \ | ||
| 52 | uint32_t max_offset = OFFSET_THRESH; \ | ||
| 53 | int k; \ | ||
| 54 | if (bit_depth == 8) { \ | ||
| 55 | for (k = 0; k < size; k++) { \ | ||
| 56 | uint8_t r = rnd() % max_offset; \ | ||
| 57 | buf[k] = r; \ | ||
| 58 | } \ | ||
| 59 | } else { \ | ||
| 60 | for (k = 0; k < size; k++) { \ | ||
| 61 | uint16_t r = rnd() % max_offset; \ | ||
| 62 | buf[k] = r; \ | ||
| 63 | } \ | ||
| 64 | } \ | ||
| 65 | } while (0) | ||
| 66 | |||
| 67 | 42 | static void check_sao_band(HEVCDSPContext *h, int bit_depth) | |
| 68 | { | ||
| 69 | int i; | ||
| 70 | 42 | PIXEL_RECT(dst0, MAX_PB_SIZE, MAX_PB_SIZE); | |
| 71 | 42 | PIXEL_RECT(dst1, MAX_PB_SIZE, MAX_PB_SIZE); | |
| 72 | 42 | LOCAL_ALIGNED_32(uint8_t, src0, [BUF_SIZE]); | |
| 73 | 42 | LOCAL_ALIGNED_32(uint8_t, src1, [BUF_SIZE]); | |
| 74 | int16_t offset_val[OFFSET_LENGTH]; | ||
| 75 | 42 | int left_class = rnd()%32; | |
| 76 | 42 | const int walign = 16; | |
| 77 | |||
| 78 |
2/2✓ Branch 0 taken 210 times.
✓ Branch 1 taken 42 times.
|
252 | for (i = 0; i <= 4; i++) { |
| 79 | 210 | int block_size = sao_size[i]; | |
| 80 |
2/2✓ Branch 0 taken 168 times.
✓ Branch 1 taken 42 times.
|
210 | int prev_size = i > 0 ? sao_size[i - 1] : 0; |
| 81 | 210 | ptrdiff_t stride = PIXEL_STRIDE*SIZEOF_PIXEL; | |
| 82 | 210 | declare_func(void, uint8_t *dst, const uint8_t *src, ptrdiff_t dst_stride, ptrdiff_t src_stride, | |
| 83 | const int16_t *sao_offset_val, int sao_left_class, int width, int height); | ||
| 84 | |||
| 85 |
2/2✓ Branch 3 taken 60 times.
✓ Branch 4 taken 150 times.
|
210 | if (check_func(h->sao_band_filter[i], "hevc_sao_band_%d_%d", block_size, bit_depth)) { |
| 86 | |||
| 87 |
2/2✓ Branch 0 taken 192 times.
✓ Branch 1 taken 60 times.
|
252 | for (int w = prev_size + 4; w <= block_size; w += 4) { |
| 88 |
2/2✓ Branch 1 taken 1216512 times.
✓ Branch 2 taken 192 times.
|
1216704 | randomize_buffers(src0, src1, BUF_SIZE); |
| 89 |
6/6✓ Branch 0 taken 64 times.
✓ Branch 1 taken 128 times.
✓ Branch 3 taken 320 times.
✓ Branch 4 taken 64 times.
✓ Branch 6 taken 640 times.
✓ Branch 7 taken 128 times.
|
1152 | randomize_buffers2(offset_val, OFFSET_LENGTH); |
| 90 | 192 | CLEAR_PIXEL_RECT(dst0); | |
| 91 | 192 | CLEAR_PIXEL_RECT(dst1); | |
| 92 | |||
| 93 | 192 | call_ref(dst0, src0, dst0_stride, stride, offset_val, left_class, w, block_size); | |
| 94 | 192 | call_new(dst1, src1, dst1_stride, stride, offset_val, left_class, w, block_size); | |
| 95 |
2/2✓ Branch 0 taken 128 times.
✓ Branch 1 taken 64 times.
|
192 | checkasm_check_pixel_padded_align(dst0, dst0_stride, dst1, dst1_stride, w, block_size, "dst", walign, 1); |
| 96 | } | ||
| 97 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 60 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.
|
60 | bench_new(dst1, src1, dst1_stride, stride, offset_val, left_class, block_size, block_size); |
| 98 | } | ||
| 99 | } | ||
| 100 | 42 | } | |
| 101 | |||
| 102 | 42 | static void check_sao_edge(HEVCDSPContext *h, int bit_depth) | |
| 103 | { | ||
| 104 | int i; | ||
| 105 | 42 | PIXEL_RECT(dst0, MAX_PB_SIZE, MAX_PB_SIZE); | |
| 106 | 42 | PIXEL_RECT(dst1, MAX_PB_SIZE, MAX_PB_SIZE); | |
| 107 | 42 | LOCAL_ALIGNED_32(uint8_t, src0, [BUF_SIZE]); | |
| 108 | 42 | LOCAL_ALIGNED_32(uint8_t, src1, [BUF_SIZE]); | |
| 109 | int16_t offset_val[OFFSET_LENGTH]; | ||
| 110 | 42 | int eo = rnd()%4; | |
| 111 | 42 | const int walign = 16; | |
| 112 | |||
| 113 |
2/2✓ Branch 0 taken 210 times.
✓ Branch 1 taken 42 times.
|
252 | for (i = 0; i <= 4; i++) { |
| 114 | 210 | int block_size = sao_size[i]; | |
| 115 |
2/2✓ Branch 0 taken 168 times.
✓ Branch 1 taken 42 times.
|
210 | int prev_size = i > 0 ? sao_size[i - 1] : 0; |
| 116 | 210 | int offset = (AV_INPUT_BUFFER_PADDING_SIZE + PIXEL_STRIDE)*SIZEOF_PIXEL; | |
| 117 | 210 | declare_func(void, uint8_t *dst, const uint8_t *src, ptrdiff_t stride_dst, | |
| 118 | const int16_t *sao_offset_val, int eo, int width, int height); | ||
| 119 | |||
| 120 |
2/2✓ Branch 3 taken 43 times.
✓ Branch 4 taken 167 times.
|
210 | if (check_func(h->sao_edge_filter[i], "hevc_sao_edge_%d_%d", block_size, bit_depth)) { |
| 121 |
2/2✓ Branch 0 taken 140 times.
✓ Branch 1 taken 43 times.
|
183 | for (int w = prev_size + 4; w <= block_size; w += 4) { |
| 122 |
2/2✓ Branch 1 taken 887040 times.
✓ Branch 2 taken 140 times.
|
887180 | randomize_buffers(src0, src1, BUF_SIZE); |
| 123 |
6/6✓ Branch 0 taken 44 times.
✓ Branch 1 taken 96 times.
✓ Branch 3 taken 220 times.
✓ Branch 4 taken 44 times.
✓ Branch 6 taken 480 times.
✓ Branch 7 taken 96 times.
|
840 | randomize_buffers2(offset_val, OFFSET_LENGTH); |
| 124 | 140 | CLEAR_PIXEL_RECT(dst0); | |
| 125 | 140 | CLEAR_PIXEL_RECT(dst1); | |
| 126 | |||
| 127 | 140 | call_ref(dst0, src0 + offset, dst0_stride, offset_val, eo, w, block_size); | |
| 128 | 140 | call_new(dst1, src1 + offset, dst1_stride, offset_val, eo, w, block_size); | |
| 129 |
2/2✓ Branch 0 taken 96 times.
✓ Branch 1 taken 44 times.
|
140 | checkasm_check_pixel_padded_align(dst0, dst0_stride, dst1, dst1_stride, w, block_size, "dst", walign, 1); |
| 130 | } | ||
| 131 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 43 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.
|
43 | bench_new(dst1, src1 + offset, dst1_stride, offset_val, eo, block_size, block_size); |
| 132 | } | ||
| 133 | } | ||
| 134 | 42 | } | |
| 135 | |||
| 136 | 14 | void checkasm_check_hevc_sao(void) | |
| 137 | { | ||
| 138 | int bit_depth; | ||
| 139 | |||
| 140 |
2/2✓ Branch 0 taken 42 times.
✓ Branch 1 taken 14 times.
|
56 | for (bit_depth = 8; bit_depth <= 12; bit_depth += 2) { |
| 141 | HEVCDSPContext h; | ||
| 142 | |||
| 143 | 42 | ff_hevc_dsp_init(&h, bit_depth); | |
| 144 | 42 | check_sao_band(&h, bit_depth); | |
| 145 | } | ||
| 146 | 14 | report("sao_band"); | |
| 147 | |||
| 148 |
2/2✓ Branch 0 taken 42 times.
✓ Branch 1 taken 14 times.
|
56 | for (bit_depth = 8; bit_depth <= 12; bit_depth += 2) { |
| 149 | HEVCDSPContext h; | ||
| 150 | |||
| 151 | 42 | ff_hevc_dsp_init(&h, bit_depth); | |
| 152 | 42 | check_sao_edge(&h, bit_depth); | |
| 153 | } | ||
| 154 | 14 | report("sao_edge"); | |
| 155 | 14 | } | |
| 156 |