| 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.h" | ||
| 26 | |||
| 27 | #include "libavcodec/huffyuvdsp.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++) \ | ||
| 35 | buf[j] = rnd() & 0xFFFF; \ | ||
| 36 | } while (0) | ||
| 37 | |||
| 38 | 26 | static void check_add_int16(HuffYUVDSPContext *c, unsigned mask, int width, const char * name) | |
| 39 | { | ||
| 40 | 26 | uint16_t *src0 = av_mallocz(width * sizeof(uint16_t)); | |
| 41 | 26 | uint16_t *src1 = av_mallocz(width * sizeof(uint16_t)); | |
| 42 | 26 | uint16_t *dst0 = av_mallocz(width * sizeof(uint16_t)); | |
| 43 | 26 | uint16_t *dst1 = av_mallocz(width * sizeof(uint16_t)); | |
| 44 | |||
| 45 | 26 | declare_func(void, uint16_t *dst, const uint16_t *src, unsigned mask, int w); | |
| 46 | |||
| 47 |
4/8✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 26 times.
|
26 | if (!src0 || !src1 || !dst0 || !dst1) |
| 48 | ✗ | fail(); | |
| 49 | |||
| 50 |
2/2✓ Branch 1 taken 40704 times.
✓ Branch 2 taken 26 times.
|
40730 | randomize_buffers(src0, width); |
| 51 | 26 | memcpy(src1, src0, width * sizeof(uint16_t)); | |
| 52 | |||
| 53 |
2/2✓ Branch 3 taken 6 times.
✓ Branch 4 taken 20 times.
|
26 | if (check_func(c->add_int16, "%s", name)) { |
| 54 | 6 | call_ref(dst0, src0, mask, width); | |
| 55 | 6 | call_new(dst1, src1, mask, width); | |
| 56 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if (memcmp(dst0, dst1, width * sizeof(uint16_t))) |
| 57 | ✗ | fail(); | |
| 58 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 6 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.
|
6 | bench_new(dst1, src1, mask, width); |
| 59 | } | ||
| 60 | |||
| 61 | 26 | av_free(src0); | |
| 62 | 26 | av_free(src1); | |
| 63 | 26 | av_free(dst0); | |
| 64 | 26 | av_free(dst1); | |
| 65 | 26 | } | |
| 66 | |||
| 67 | 13 | static void check_add_hfyu_left_pred_bgr32(HuffYUVDSPContext *c) | |
| 68 | { | ||
| 69 | #define BUF_SIZE 1080 | ||
| 70 | uint8_t src[4 * BUF_SIZE], dst0[4 * BUF_SIZE], dst1[4 * BUF_SIZE]; | ||
| 71 | uint8_t left[4], left0[4], left1[4]; | ||
| 72 | |||
| 73 | 13 | declare_func(void, uint8_t *d, const uint8_t *s, intptr_t w, uint8_t *l); | |
| 74 | |||
| 75 |
2/2✓ Branch 1 taken 56160 times.
✓ Branch 2 taken 13 times.
|
56173 | randomize_buffers(src, sizeof (src)); |
| 76 |
2/2✓ Branch 1 taken 52 times.
✓ Branch 2 taken 13 times.
|
65 | randomize_buffers(left, sizeof (left)); |
| 77 | 13 | memcpy(left0, left, sizeof (left)); | |
| 78 | 13 | memcpy(left1, left, sizeof (left)); | |
| 79 | |||
| 80 |
2/2✓ Branch 3 taken 2 times.
✓ Branch 4 taken 11 times.
|
13 | if (check_func(c->add_hfyu_left_pred_bgr32, "add_hfyu_left_pred_bgr32")) { |
| 81 | 2 | call_ref(dst0, src, BUF_SIZE, left0); | |
| 82 | 2 | call_new(dst1, src, BUF_SIZE, left1); | |
| 83 | |||
| 84 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if (memcmp(dst0, dst1, sizeof (dst0)) != 0 || |
| 85 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | memcmp(left0, left1, sizeof (left0)) != 0) { |
| 86 | ✗ | fail(); | |
| 87 | } | ||
| 88 | |||
| 89 |
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(dst1, src, BUF_SIZE, left); |
| 90 | } | ||
| 91 | |||
| 92 | 13 | report("add_hfyu_left_pred_bgr32"); | |
| 93 | 13 | } | |
| 94 | |||
| 95 | 13 | void checkasm_check_huffyuvdsp(void) | |
| 96 | { | ||
| 97 | HuffYUVDSPContext c; | ||
| 98 | 13 | int width = 16 * av_clip(rnd(), 16, 128); | |
| 99 | |||
| 100 | 13 | ff_huffyuvdsp_init(&c, AV_PIX_FMT_YUV422P); | |
| 101 | |||
| 102 | /*! test width not multiple of mmsize */ | ||
| 103 | 13 | check_add_int16(&c, 65535, width, "add_int16_rnd_width"); | |
| 104 | 13 | report("add_int16_rnd_width"); | |
| 105 | |||
| 106 | /*! test always with the same size (for perf test) */ | ||
| 107 | 13 | check_add_int16(&c, 65535, 16*128, "add_int16_128"); | |
| 108 | 13 | report("add_int16_128"); | |
| 109 | |||
| 110 | 13 | check_add_hfyu_left_pred_bgr32(&c); | |
| 111 | 13 | } | |
| 112 |