| 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 <stdint.h> | ||
| 20 | |||
| 21 | #include "checkasm.h" | ||
| 22 | |||
| 23 | #include "libavutil/attributes.h" | ||
| 24 | #include "libavutil/mem_internal.h" | ||
| 25 | #include "libavcodec/apv_dsp.h" | ||
| 26 | |||
| 27 | |||
| 28 | 2 | static void check_decode_transquant_8(void) | |
| 29 | { | ||
| 30 | 2 | LOCAL_ALIGNED_16(int16_t, input, [64]); | |
| 31 | 2 | LOCAL_ALIGNED_16(int16_t, qmatrix, [64]); | |
| 32 | 2 | LOCAL_ALIGNED_16(uint8_t, new_output, [64]); | |
| 33 | 2 | LOCAL_ALIGNED_16(uint8_t, ref_output, [64]); | |
| 34 | |||
| 35 | 2 | declare_func(void, | |
| 36 | void *output, | ||
| 37 | ptrdiff_t pitch, | ||
| 38 | const int16_t *input, | ||
| 39 | const int16_t *qmatrix, | ||
| 40 | int bit_depth, | ||
| 41 | int qp_shift); | ||
| 42 | |||
| 43 |
2/2✓ Branch 0 taken 128 times.
✓ Branch 1 taken 2 times.
|
130 | for (int i = 0; i < 64; i++) { |
| 44 | // Any signed 12-bit integer. | ||
| 45 | 128 | input[i] = rnd() % 2048 - 1024; | |
| 46 | |||
| 47 | // qmatrix input is premultiplied by level_scale, so | ||
| 48 | // range is 1 to 255 * 71. Interesting values are all | ||
| 49 | // at the low end of that, though. | ||
| 50 | 128 | qmatrix[i] = rnd() % 16 + 16; | |
| 51 | } | ||
| 52 | |||
| 53 | 2 | call_ref(ref_output, 8, input, qmatrix, 8, 4); | |
| 54 | 2 | call_new(new_output, 8, input, qmatrix, 8, 4); | |
| 55 | |||
| 56 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (memcmp(new_output, ref_output, 64 * sizeof(*ref_output))) |
| 57 | ✗ | fail(); | |
| 58 | |||
| 59 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 2 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.
|
2 | bench_new(new_output, 8, input, qmatrix, 8, 4); |
| 60 | 2 | } | |
| 61 | |||
| 62 | 2 | static void check_decode_transquant_10(void) | |
| 63 | { | ||
| 64 | 2 | LOCAL_ALIGNED_16( int16_t, input, [64]); | |
| 65 | 2 | LOCAL_ALIGNED_16( int16_t, qmatrix, [64]); | |
| 66 | 2 | LOCAL_ALIGNED_16(uint16_t, new_output, [64]); | |
| 67 | 2 | LOCAL_ALIGNED_16(uint16_t, ref_output, [64]); | |
| 68 | |||
| 69 | 2 | declare_func(void, | |
| 70 | void *output, | ||
| 71 | ptrdiff_t pitch, | ||
| 72 | const int16_t *input, | ||
| 73 | const int16_t *qmatrix, | ||
| 74 | int bit_depth, | ||
| 75 | int qp_shift); | ||
| 76 | |||
| 77 |
2/2✓ Branch 0 taken 128 times.
✓ Branch 1 taken 2 times.
|
130 | for (int i = 0; i < 64; i++) { |
| 78 | // Any signed 14-bit integer. | ||
| 79 | 128 | input[i] = rnd() % 16384 - 8192; | |
| 80 | |||
| 81 | // qmatrix input is premultiplied by level_scale, so | ||
| 82 | // range is 1 to 255 * 71. Interesting values are all | ||
| 83 | // at the low end of that, though. | ||
| 84 | 128 | qmatrix[i] = 16; //rnd() % 16 + 16; | |
| 85 | } | ||
| 86 | |||
| 87 | 2 | call_ref(ref_output, 16, input, qmatrix, 10, 4); | |
| 88 | 2 | call_new(new_output, 16, input, qmatrix, 10, 4); | |
| 89 | |||
| 90 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (memcmp(new_output, ref_output, 64 * sizeof(*ref_output))) |
| 91 | ✗ | fail(); | |
| 92 | |||
| 93 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 2 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.
|
2 | bench_new(new_output, 16, input, qmatrix, 10, 4); |
| 94 | 2 | } | |
| 95 | |||
| 96 | 13 | void checkasm_check_apv_dsp(void) | |
| 97 | { | ||
| 98 | APVDSPContext dsp; | ||
| 99 | |||
| 100 | 13 | ff_apv_dsp_init(&dsp); | |
| 101 | |||
| 102 |
2/2✓ Branch 3 taken 2 times.
✓ Branch 4 taken 11 times.
|
13 | if (check_func(dsp.decode_transquant, "decode_transquant_8")) |
| 103 | 2 | check_decode_transquant_8(); | |
| 104 | |||
| 105 |
2/2✓ Branch 3 taken 2 times.
✓ Branch 4 taken 11 times.
|
13 | if (check_func(dsp.decode_transquant, "decode_transquant_10")) |
| 106 | 2 | check_decode_transquant_10(); | |
| 107 | |||
| 108 | 13 | report("decode_transquant"); | |
| 109 | 13 | } | |
| 110 |