FFmpeg
Loading...
Searching...
No Matches
packet_side_data_handle.c
Go to the documentation of this file.
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"
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 */
40int main(void)
41{
42 const char *handles[AV_PKT_DATA_NB] = { NULL };
43 int ret = 0;
44
46
47 for (int type = 0; type < AV_PKT_DATA_NB; type++) {
48 printf("%2d: %s\n", type, handles[type] ? handles[type] : "(none)");
49 if (!handles[type])
50 ret = 1;
51 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 for (int other = 0; handles[type] && other < type; other++) {
57 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 return ret;
65}
#define NULL
Definition coverity.c:32
__device__ int printf(const char *,...)
int ret
Definition ffplay.c:391
@ AV_PKT_DATA_NB
The number of side data types.
Definition packet.h:401
enum MPFType type
Definition jpegmpfenc.c:55
#define FF_PACKET_SIDE_DATA_HANDLES(HANDLE)
The handle of each side data type: a short, stable name made of lower case letters,...
#define SET_HANDLE(type, handle)
#define HANDLE_CHARS
int main(void)