| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * Copyright (c) Lynne | ||
| 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 | #include <stdint.h> | ||
| 23 | #include "checkasm.h" | ||
| 24 | #include "libavcodec/h264chroma.h" | ||
| 25 | #include "libavutil/mem_internal.h" | ||
| 26 | #include "libavutil/intreadwrite.h" | ||
| 27 | |||
| 28 | #define SIZEOF_PIXEL ((bit_depth + 7) / 8) | ||
| 29 | |||
| 30 | #define randomize_buffers(bit_depth) \ | ||
| 31 | do { \ | ||
| 32 | if (bit_depth == 8) { \ | ||
| 33 | for (int i = 0; i < 16*18; i++) \ | ||
| 34 | src[i] = rnd(); \ | ||
| 35 | } else { \ | ||
| 36 | unsigned mask = (1 << bit_depth) - 1;\ | ||
| 37 | for (int i = 0; i < 16*18*2; i += 2) \ | ||
| 38 | AV_WN16A(&src[i], rnd() & mask); \ | ||
| 39 | } \ | ||
| 40 | } while (0) | ||
| 41 | |||
| 42 | 14 | static void check_chroma_mc(void) | |
| 43 | { | ||
| 44 | H264ChromaContext h; | ||
| 45 | DECLARE_ALIGNED_4(uint8_t, src) [16 * 18 * 2]; | ||
| 46 | DECLARE_ALIGNED_16(uint8_t, dst0)[16 * 18 * 2]; | ||
| 47 | DECLARE_ALIGNED_16(uint8_t, dst1)[16 * 18 * 2]; | ||
| 48 | |||
| 49 |
2/2✓ Branch 1 taken 13 times.
✓ Branch 2 taken 1 times.
|
14 | declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, const uint8_t *src, |
| 50 | ptrdiff_t stride, int h, int x, int y); | ||
| 51 | |||
| 52 |
2/2✓ Branch 0 taken 42 times.
✓ Branch 1 taken 14 times.
|
56 | for (int bit_depth = 8; bit_depth <= 10; bit_depth++) { |
| 53 | 42 | ff_h264chroma_init(&h, bit_depth); | |
| 54 |
6/6✓ Branch 0 taken 14 times.
✓ Branch 1 taken 28 times.
✓ Branch 3 taken 4032 times.
✓ Branch 4 taken 14 times.
✓ Branch 6 taken 8064 times.
✓ Branch 7 taken 28 times.
|
12138 | randomize_buffers(bit_depth); |
| 55 |
2/2✓ Branch 0 taken 126 times.
✓ Branch 1 taken 42 times.
|
168 | for (int size = 0; size < 3; size++) { |
| 56 | 126 | int block_size = 8 >> size; | |
| 57 | |||
| 58 | #define CHECK_CHROMA_MC(name) \ | ||
| 59 | do { \ | ||
| 60 | if (check_func(h.name## _pixels_tab[size], #name "_mc%d_%d", 1 << (3-size), bit_depth)) { \ | ||
| 61 | for (int x = 0; x < 2; x++) { \ | ||
| 62 | for (int y = 0; y < 2; y++) { \ | ||
| 63 | memcpy(dst0, src, 16 * 18 * SIZEOF_PIXEL); \ | ||
| 64 | memcpy(dst1, src, 16 * 18 * SIZEOF_PIXEL); \ | ||
| 65 | call_ref(dst0, src, 16 * SIZEOF_PIXEL, block_size, x, y); \ | ||
| 66 | call_new(dst1, src, 16 * SIZEOF_PIXEL, block_size, x, y); \ | ||
| 67 | if (memcmp(dst0, dst1, 16 * 16 * SIZEOF_PIXEL)) { \ | ||
| 68 | fprintf(stderr, #name "_%d: x:%i, y:%i\n", bit_depth, x, y); \ | ||
| 69 | fail(); \ | ||
| 70 | } \ | ||
| 71 | bench_new(dst1, src, 16 * SIZEOF_PIXEL, block_size, x, y); \ | ||
| 72 | } \ | ||
| 73 | } \ | ||
| 74 | } \ | ||
| 75 | } while (0) | ||
| 76 | |||
| 77 |
8/16✓ Branch 3 taken 20 times.
✓ Branch 4 taken 106 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 80 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 80 times.
✗ Branch 56 not taken.
✗ Branch 57 not taken.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
✗ Branch 61 not taken.
✓ Branch 64 taken 80 times.
✓ Branch 65 taken 40 times.
✓ Branch 66 taken 40 times.
✓ Branch 67 taken 20 times.
|
246 | CHECK_CHROMA_MC(put_h264_chroma); |
| 78 |
8/16✓ Branch 3 taken 20 times.
✓ Branch 4 taken 106 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 80 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 80 times.
✗ Branch 56 not taken.
✗ Branch 57 not taken.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
✗ Branch 61 not taken.
✓ Branch 64 taken 80 times.
✓ Branch 65 taken 40 times.
✓ Branch 66 taken 40 times.
✓ Branch 67 taken 20 times.
|
246 | CHECK_CHROMA_MC(avg_h264_chroma); |
| 79 | } | ||
| 80 | } | ||
| 81 | 14 | } | |
| 82 | |||
| 83 | 14 | void checkasm_check_h264chroma(void) | |
| 84 | { | ||
| 85 | 14 | check_chroma_mc(); | |
| 86 | 14 | report("chroma_mc"); | |
| 87 | 14 | } | |
| 88 |