FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/tests/checkasm/h264chroma.c
Date: 2024-05-03 15:42:48
Exec Total Coverage
Lines: 16 16 100.0%
Functions: 2 2 100.0%
Branches: 28 44 63.6%

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*2; i++) \
34 src[i] = rnd() & 0x3; \
35 } else { \
36 for (int i = 0; i < 16*18; i += 2) \
37 AV_WN16(&src[i], rnd() & 0xFF); \
38 } \
39 } while (0)
40
41 13 static void check_chroma_mc(void)
42 {
43 H264ChromaContext h;
44 13 LOCAL_ALIGNED_32(uint8_t, src, [16 * 18 * 2]);
45 13 LOCAL_ALIGNED_32(uint8_t, dst0, [16 * 18 * 2]);
46 13 LOCAL_ALIGNED_32(uint8_t, dst1, [16 * 18 * 2]);
47
48
2/2
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 1 times.
13 declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, const uint8_t *src,
49 ptrdiff_t stride, int h, int x, int y);
50
51
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 13 times.
52 for (int bit_depth = 8; bit_depth <= 10; bit_depth++) {
52 39 ff_h264chroma_init(&h, bit_depth);
53
6/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 26 times.
✓ Branch 3 taken 7488 times.
✓ Branch 4 taken 13 times.
✓ Branch 6 taken 3744 times.
✓ Branch 7 taken 26 times.
11271 randomize_buffers(bit_depth);
54
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 39 times.
195 for (int size = 0; size < 4; size++) {
55
56 #define CHECK_CHROMA_MC(name) \
57 do { \
58 if (check_func(h.name## _pixels_tab[size], #name "_mc%d_%d", 1 << size, bit_depth)) { \
59 for (int x = 0; x < 2; x++) { \
60 for (int y = 0; y < 2; y++) { \
61 memcpy(dst0, src, 16 * 18 * SIZEOF_PIXEL); \
62 memcpy(dst1, src, 16 * 18 * SIZEOF_PIXEL); \
63 call_ref(dst0, src, 16 * SIZEOF_PIXEL, 16, x, y); \
64 call_new(dst1, src, 16 * SIZEOF_PIXEL, 16, x, y); \
65 if (memcmp(dst0, dst1, 16 * 16 * SIZEOF_PIXEL)) { \
66 fprintf(stderr, #name ": x:%i, y:%i\n", x, y); \
67 fail(); \
68 } \
69 bench_new(dst1, src, 16 * SIZEOF_PIXEL, 16, x, y); \
70 } \
71 } \
72 } \
73 } while (0)
74
75
8/16
✓ Branch 3 taken 25 times.
✓ Branch 4 taken 131 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 100 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 100 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✓ Branch 36 taken 100 times.
✓ Branch 37 taken 50 times.
✓ Branch 38 taken 50 times.
✓ Branch 39 taken 25 times.
306 CHECK_CHROMA_MC(put_h264_chroma);
76
8/16
✓ Branch 3 taken 25 times.
✓ Branch 4 taken 131 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 100 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 100 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✓ Branch 36 taken 100 times.
✓ Branch 37 taken 50 times.
✓ Branch 38 taken 50 times.
✓ Branch 39 taken 25 times.
306 CHECK_CHROMA_MC(avg_h264_chroma);
77 }
78 }
79 13 }
80
81 13 void checkasm_check_h264chroma(void)
82 {
83 13 check_chroma_mc();
84 13 report("chroma_mc");
85 13 }
86