| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * This file is part of FFmpeg. | ||
| 3 | * | ||
| 4 | * FFmpeg is free software; you can redistribute it and/or | ||
| 5 | * modify it under the terms of the GNU Lesser General Public | ||
| 6 | * License as published by the Free Software Foundation; either | ||
| 7 | * version 2.1 of the License, or (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 GNU | ||
| 12 | * Lesser General Public License for more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU Lesser General Public | ||
| 15 | * License along with FFmpeg; if not, write to the Free Software | ||
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 17 | */ | ||
| 18 | |||
| 19 | #include <string.h> | ||
| 20 | |||
| 21 | #include "checkasm.h" | ||
| 22 | |||
| 23 | #include "libavcodec/proresdsp.h" | ||
| 24 | |||
| 25 | #include "libavutil/common.h" | ||
| 26 | #include "libavutil/internal.h" | ||
| 27 | #include "libavutil/mem_internal.h" | ||
| 28 | |||
| 29 | #define IN_IDCT_DEPTH 16 | ||
| 30 | #define PRORES_ONLY | ||
| 31 | |||
| 32 | #define BIT_DEPTH 12 | ||
| 33 | #include "libavcodec/simple_idct_template.c" | ||
| 34 | #undef BIT_DEPTH | ||
| 35 | #undef IN_IDCT_DEPTH | ||
| 36 | |||
| 37 | #define CLIP_MIN (1 << 2) | ||
| 38 | #define CLIP_MAX_12 ((1 << 12) - CLIP_MIN - 1) | ||
| 39 | |||
| 40 | #define BLOCK_SIZE 64 | ||
| 41 | |||
| 42 | 4 | static void permute_block(int16_t *dst, const int16_t *src, const uint8_t *perm) | |
| 43 | { | ||
| 44 |
2/2✓ Branch 0 taken 256 times.
✓ Branch 1 taken 4 times.
|
260 | for (int i = 0; i < BLOCK_SIZE; i++) |
| 45 | 256 | dst[i] = src[perm[i]]; | |
| 46 | 4 | } | |
| 47 | |||
| 48 | 2 | static void ref_idct_put_12(uint16_t *dst, ptrdiff_t linesize, | |
| 49 | const int16_t *src_block, const int16_t *src_qmat) | ||
| 50 | { | ||
| 51 | int16_t block[BLOCK_SIZE]; | ||
| 52 | |||
| 53 |
2/2✓ Branch 0 taken 128 times.
✓ Branch 1 taken 2 times.
|
130 | for (int i = 0; i < BLOCK_SIZE; i++) |
| 54 | 128 | block[i] = src_block[i] * src_qmat[i]; | |
| 55 | |||
| 56 |
2/2✓ Branch 0 taken 16 times.
✓ Branch 1 taken 2 times.
|
18 | for (int i = 0; i < 8; i++) |
| 57 | 16 | idctRowCondDC_int16_12bit(block + i * 8, 0); | |
| 58 | |||
| 59 |
2/2✓ Branch 0 taken 16 times.
✓ Branch 1 taken 2 times.
|
18 | for (int i = 0; i < 8; i++) { |
| 60 | 16 | block[i] += 8192; | |
| 61 | 16 | idctSparseCol_int16_12bit(block + i); | |
| 62 | } | ||
| 63 | |||
| 64 |
2/2✓ Branch 0 taken 16 times.
✓ Branch 1 taken 2 times.
|
18 | for (int y = 0; y < 8; y++) |
| 65 |
2/2✓ Branch 0 taken 128 times.
✓ Branch 1 taken 16 times.
|
144 | for (int x = 0; x < 8; x++) |
| 66 | 128 | dst[y * (linesize >> 1) + x] = av_clip(block[y * 8 + x], CLIP_MIN, CLIP_MAX_12); | |
| 67 | 2 | } | |
| 68 | |||
| 69 | 14 | void checkasm_check_proresdsp(void) | |
| 70 | { | ||
| 71 | 14 | LOCAL_ALIGNED_32(int16_t, block, [BLOCK_SIZE]); | |
| 72 | 14 | LOCAL_ALIGNED_32(int16_t, qmat, [BLOCK_SIZE]); | |
| 73 | 14 | LOCAL_ALIGNED_16(uint16_t, dst_ref, [BLOCK_SIZE]); | |
| 74 | 14 | LOCAL_ALIGNED_16(uint16_t, dst_new, [BLOCK_SIZE]); | |
| 75 | int16_t src_block[BLOCK_SIZE]; | ||
| 76 | int16_t src_qmat[BLOCK_SIZE]; | ||
| 77 | 14 | ProresDSPContext dsp = { 0 }; | |
| 78 | |||
| 79 | 14 | ff_proresdsp_init(&dsp, 12); | |
| 80 | |||
| 81 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 2 taken 12 times.
|
14 | if (check_func(dsp.idct_put, "prores_idct_put_12")) { |
| 82 | 2 | declare_func(void, uint16_t *dst, ptrdiff_t linesize, int16_t *block, const int16_t *qmat); | |
| 83 | |||
| 84 |
2/2✓ Branch 0 taken 128 times.
✓ Branch 1 taken 2 times.
|
130 | for (int i = 0; i < BLOCK_SIZE; i++) { |
| 85 | 128 | src_qmat[i] = 1 + (rnd() % 255); | |
| 86 | 128 | src_block[i] = (int16_t)rnd(); | |
| 87 | } | ||
| 88 | |||
| 89 | 2 | permute_block(block, src_block, dsp.idct_permutation); | |
| 90 | 2 | permute_block(qmat, src_qmat, dsp.idct_permutation); | |
| 91 | |||
| 92 | 2 | ref_idct_put_12(dst_ref, 16, src_block, src_qmat); | |
| 93 | |||
| 94 | 2 | call_new(dst_new, 16, block, qmat); | |
| 95 | |||
| 96 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (memcmp(dst_ref, dst_new, BLOCK_SIZE * sizeof(*dst_ref))) |
| 97 | ✗ | fail(); | |
| 98 | |||
| 99 |
1/18✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
|
2 | bench_new(dst_new, 16, block, qmat); |
| 100 | } | ||
| 101 | |||
| 102 | 14 | report("prores_idct_put_12"); | |
| 103 | 14 | } | |
| 104 |