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/common.h" | ||
24 | #include "libavutil/intreadwrite.h" | ||
25 | #include "libavutil/mem_internal.h" | ||
26 | |||
27 | #include "libavcodec/lossless_videoencdsp.h" | ||
28 | |||
29 | #include "checkasm.h" | ||
30 | |||
31 | #define randomize_buffers(buf, size) \ | ||
32 | do { \ | ||
33 | int j; \ | ||
34 | for (j = 0; j < size; j+=4) \ | ||
35 | AV_WN32(buf + j, rnd()); \ | ||
36 | } while (0) | ||
37 | |||
38 | static const struct {uint8_t w, h, s;} planes[] = { | ||
39 | {16,16,16}, {21,23,25}, {32,17,48}, {15,128,16}, {128,127,128} | ||
40 | }; | ||
41 | |||
42 | #define MAX_STRIDE 128 | ||
43 | #define MAX_HEIGHT 127 | ||
44 | |||
45 | 13 | static void check_diff_bytes(LLVidEncDSPContext *c) | |
46 | { | ||
47 | int i; | ||
48 | 13 | LOCAL_ALIGNED_32(uint8_t, dst0, [MAX_STRIDE]); | |
49 | 13 | LOCAL_ALIGNED_32(uint8_t, dst1, [MAX_STRIDE]); | |
50 | 13 | LOCAL_ALIGNED_32(uint8_t, src0, [MAX_STRIDE]); | |
51 | 13 | LOCAL_ALIGNED_32(uint8_t, src1, [MAX_STRIDE]); | |
52 | 13 | LOCAL_ALIGNED_32(uint8_t, src2, [MAX_STRIDE]); | |
53 | 13 | LOCAL_ALIGNED_32(uint8_t, src3, [MAX_STRIDE]); | |
54 | |||
55 | 13 | declare_func(void, uint8_t *dst, const uint8_t *src1, | |
56 | const uint8_t *src2, intptr_t w); | ||
57 | |||
58 | 13 | memset(dst0, 0, MAX_STRIDE); | |
59 | 13 | memset(dst1, 0, MAX_STRIDE); | |
60 |
2/2✓ Branch 1 taken 416 times.
✓ Branch 2 taken 13 times.
|
429 | randomize_buffers(src0, MAX_STRIDE); |
61 | 13 | memcpy(src1, src0, MAX_STRIDE); | |
62 |
2/2✓ Branch 1 taken 416 times.
✓ Branch 2 taken 13 times.
|
429 | randomize_buffers(src2, MAX_STRIDE); |
63 | 13 | memcpy(src3, src2, MAX_STRIDE); | |
64 | |||
65 |
2/2✓ Branch 3 taken 3 times.
✓ Branch 4 taken 10 times.
|
13 | if (check_func(c->diff_bytes, "diff_bytes")) { |
66 |
2/2✓ Branch 0 taken 15 times.
✓ Branch 1 taken 3 times.
|
18 | for (i = 0; i < 5; i ++) { |
67 | 15 | call_ref(dst0, src0, src2, planes[i].w); | |
68 | 15 | call_new(dst1, src1, src3, planes[i].w); | |
69 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
|
15 | if (memcmp(dst0, dst1, planes[i].w)) |
70 | ✗ | fail(); | |
71 | } | ||
72 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
|
3 | bench_new(dst1, src0, src2, planes[4].w); |
73 | } | ||
74 | 13 | } | |
75 | |||
76 | 13 | static void check_sub_left_pred(LLVidEncDSPContext *c) | |
77 | { | ||
78 | int i; | ||
79 | 13 | LOCAL_ALIGNED_32(uint8_t, dst0, [MAX_STRIDE * MAX_HEIGHT]); | |
80 | 13 | LOCAL_ALIGNED_32(uint8_t, dst1, [MAX_STRIDE * MAX_HEIGHT]); | |
81 | 13 | LOCAL_ALIGNED_32(uint8_t, src0, [MAX_STRIDE * MAX_HEIGHT]); | |
82 | 13 | LOCAL_ALIGNED_32(uint8_t, src1, [MAX_STRIDE * MAX_HEIGHT]); | |
83 | |||
84 | 13 | declare_func(void, uint8_t *dst, const uint8_t *src, | |
85 | ptrdiff_t stride, ptrdiff_t width, int height); | ||
86 | |||
87 | 13 | memset(dst0, 0, MAX_STRIDE * MAX_HEIGHT); | |
88 | 13 | memset(dst1, 0, MAX_STRIDE * MAX_HEIGHT); | |
89 |
2/2✓ Branch 1 taken 52832 times.
✓ Branch 2 taken 13 times.
|
52845 | randomize_buffers(src0, MAX_STRIDE * MAX_HEIGHT); |
90 | 13 | memcpy(src1, src0, MAX_STRIDE * MAX_HEIGHT); | |
91 | |||
92 |
2/2✓ Branch 3 taken 2 times.
✓ Branch 4 taken 11 times.
|
13 | if (check_func(c->sub_left_predict, "sub_left_predict")) { |
93 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | for (i = 0; i < 5; i ++) { |
94 | 2 | call_ref(dst0, src0, planes[i].s, planes[i].w, planes[i].h); | |
95 | 2 | call_new(dst1, src1, planes[i].s, planes[i].w, planes[i].h); | |
96 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (memcmp(dst0, dst1, planes[i].w * planes[i].h)) |
97 | ✗ | fail(); | |
98 | 2 | break; | |
99 | } | ||
100 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
|
2 | bench_new(dst1, src0, planes[4].s, planes[4].w, planes[4].h); |
101 | } | ||
102 | 13 | } | |
103 | |||
104 | 13 | void checkasm_check_llviddspenc(void) | |
105 | { | ||
106 | LLVidEncDSPContext c; | ||
107 | 13 | ff_llvidencdsp_init(&c); | |
108 | |||
109 | 13 | check_diff_bytes(&c); | |
110 | 13 | report("diff_bytes"); | |
111 | |||
112 | 13 | check_sub_left_pred(&c); | |
113 | 13 | report("sub_left_predict"); | |
114 | 13 | } | |
115 |