../../../ffmpeg/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
11 / 16
68.8%
Branches:
54 / 104
51.9%
Functions:
1 / 1
100.0%

libavcodec/tests/packet_side_data_handle.c
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 <stdio.h>
20 #include <string.h>
21
22 #include "libavcodec/packet.h"
23 #include "libavcodec/packet_internal.h"
24
25 #define HANDLE_CHARS "abcdefghijklmnopqrstuvwxyz0123456789_"
26
27 #define SET_HANDLE(type, handle) \
28 if (handles[AV_PKT_DATA_ ## type]) { \
29 printf("%s: second handle %s\n", #type, handle); \
30 ret = 1; \
31 } \
32 handles[AV_PKT_DATA_ ## type] = handle;
33
34 /*
35 * Every side data type needs exactly one handle, and no two types may share
36 * one. A handle is typed in options, where '+' and '-' have a meaning, so it
37 * is made of [a-z0-9_] only. The handles are printed and compared with the
38 * reference, since a released handle must not change.
39 */
40 1 int main(void)
41 {
42 1 const char *handles[AV_PKT_DATA_NB] = { NULL };
43 1 int ret = 0;
44
45
44/88
✗ Branch 2 → 3 not taken.
✓ Branch 2 → 5 taken 1 time.
✗ Branch 5 → 6 not taken.
✓ Branch 5 → 8 taken 1 time.
✗ Branch 8 → 9 not taken.
✓ Branch 8 → 11 taken 1 time.
✗ Branch 11 → 12 not taken.
✓ Branch 11 → 14 taken 1 time.
✗ Branch 14 → 15 not taken.
✓ Branch 14 → 17 taken 1 time.
✗ Branch 17 → 18 not taken.
✓ Branch 17 → 20 taken 1 time.
✗ Branch 20 → 21 not taken.
✓ Branch 20 → 23 taken 1 time.
✗ Branch 23 → 24 not taken.
✓ Branch 23 → 26 taken 1 time.
✗ Branch 26 → 27 not taken.
✓ Branch 26 → 29 taken 1 time.
✗ Branch 29 → 30 not taken.
✓ Branch 29 → 32 taken 1 time.
✗ Branch 32 → 33 not taken.
✓ Branch 32 → 35 taken 1 time.
✗ Branch 35 → 36 not taken.
✓ Branch 35 → 38 taken 1 time.
✗ Branch 38 → 39 not taken.
✓ Branch 38 → 41 taken 1 time.
✗ Branch 41 → 42 not taken.
✓ Branch 41 → 44 taken 1 time.
✗ Branch 44 → 45 not taken.
✓ Branch 44 → 47 taken 1 time.
✗ Branch 47 → 48 not taken.
✓ Branch 47 → 50 taken 1 time.
✗ Branch 50 → 51 not taken.
✓ Branch 50 → 53 taken 1 time.
✗ Branch 53 → 54 not taken.
✓ Branch 53 → 56 taken 1 time.
✗ Branch 56 → 57 not taken.
✓ Branch 56 → 59 taken 1 time.
✗ Branch 59 → 60 not taken.
✓ Branch 59 → 62 taken 1 time.
✗ Branch 62 → 63 not taken.
✓ Branch 62 → 65 taken 1 time.
✗ Branch 65 → 66 not taken.
✓ Branch 65 → 68 taken 1 time.
✗ Branch 68 → 69 not taken.
✓ Branch 68 → 71 taken 1 time.
✗ Branch 71 → 72 not taken.
✓ Branch 71 → 74 taken 1 time.
✗ Branch 74 → 75 not taken.
✓ Branch 74 → 77 taken 1 time.
✗ Branch 77 → 78 not taken.
✓ Branch 77 → 80 taken 1 time.
✗ Branch 80 → 81 not taken.
✓ Branch 80 → 83 taken 1 time.
✗ Branch 83 → 84 not taken.
✓ Branch 83 → 86 taken 1 time.
✗ Branch 86 → 87 not taken.
✓ Branch 86 → 89 taken 1 time.
✗ Branch 89 → 90 not taken.
✓ Branch 89 → 92 taken 1 time.
✗ Branch 92 → 93 not taken.
✓ Branch 92 → 95 taken 1 time.
✗ Branch 95 → 96 not taken.
✓ Branch 95 → 98 taken 1 time.
✗ Branch 98 → 99 not taken.
✓ Branch 98 → 101 taken 1 time.
✗ Branch 101 → 102 not taken.
✓ Branch 101 → 104 taken 1 time.
✗ Branch 104 → 105 not taken.
✓ Branch 104 → 107 taken 1 time.
✗ Branch 107 → 108 not taken.
✓ Branch 107 → 110 taken 1 time.
✗ Branch 110 → 111 not taken.
✓ Branch 110 → 113 taken 1 time.
✗ Branch 113 → 114 not taken.
✓ Branch 113 → 116 taken 1 time.
✗ Branch 116 → 117 not taken.
✓ Branch 116 → 119 taken 1 time.
✗ Branch 119 → 120 not taken.
✓ Branch 119 → 122 taken 1 time.
✗ Branch 122 → 123 not taken.
✓ Branch 122 → 125 taken 1 time.
✗ Branch 125 → 126 not taken.
✓ Branch 125 → 128 taken 1 time.
✗ Branch 128 → 129 not taken.
✓ Branch 128 → 131 taken 1 time.
✗ Branch 131 → 132 not taken.
✓ Branch 131 → 134 taken 1 time.
1 FF_PACKET_SIDE_DATA_HANDLES(SET_HANDLE)
46
47
2/2
✓ Branch 153 → 135 taken 44 times.
✓ Branch 153 → 154 taken 1 time.
45 for (int type = 0; type < AV_PKT_DATA_NB; type++) {
48
1/2
✓ Branch 135 → 136 taken 44 times.
✗ Branch 135 → 137 not taken.
44 printf("%2d: %s\n", type, handles[type] ? handles[type] : "(none)");
49
1/2
✗ Branch 139 → 140 not taken.
✓ Branch 139 → 141 taken 44 times.
44 if (!handles[type])
50 ✗ ret = 1;
51
1/2
✗ Branch 141 → 142 not taken.
✓ Branch 141 → 144 taken 44 times.
44 else if (strspn(handles[type], HANDLE_CHARS) != strlen(handles[type])) {
52 ✗ printf("%2d: character outside of [a-z0-9_]\n", type);
53 ✗ ret = 1;
54 }
55
56
3/4
✓ Branch 150 → 151 taken 990 times.
✗ Branch 150 → 152 not taken.
✓ Branch 151 → 145 taken 946 times.
✓ Branch 151 → 152 taken 44 times.
990 for (int other = 0; handles[type] && other < type; other++) {
57
2/4
✓ Branch 145 → 146 taken 946 times.
✗ Branch 145 → 149 not taken.
✗ Branch 146 → 147 not taken.
✓ Branch 146 → 149 taken 946 times.
946 if (handles[other] && !strcmp(handles[type], handles[other])) {
58 ✗ printf("%2d: handle of type %d\n", type, other);
59 ✗ ret = 1;
60 }
61 }
62 }
63
64 1 return ret;
65 }
66