error.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 #undef _GNU_SOURCE
20 #include "avutil.h"
21 #include "avstring.h"
22 #include "common.h"
23 
24 struct error_entry {
25  int num;
26  const char *tag;
27  const char *str;
28 };
29 
30 #define ERROR_TAG(tag) AVERROR_##tag, #tag
31 static const struct error_entry error_entries[] = {
32  { ERROR_TAG(BSF_NOT_FOUND), "Bitstream filter not found" },
33  { ERROR_TAG(BUG), "Internal bug, should not have happened" },
34  { ERROR_TAG(BUG2), "Internal bug, should not have happened" },
35  { ERROR_TAG(BUFFER_TOO_SMALL), "Buffer too small" },
36  { ERROR_TAG(DECODER_NOT_FOUND), "Decoder not found" },
37  { ERROR_TAG(DEMUXER_NOT_FOUND), "Demuxer not found" },
38  { ERROR_TAG(ENCODER_NOT_FOUND), "Encoder not found" },
39  { ERROR_TAG(EOF), "End of file" },
40  { ERROR_TAG(EXIT), "Immediate exit requested" },
41  { ERROR_TAG(EXTERNAL), "Generic error in an external library" },
42  { ERROR_TAG(FILTER_NOT_FOUND), "Filter not found" },
43  { ERROR_TAG(INVALIDDATA), "Invalid data found when processing input" },
44  { ERROR_TAG(MUXER_NOT_FOUND), "Muxer not found" },
45  { ERROR_TAG(OPTION_NOT_FOUND), "Option not found" },
46  { ERROR_TAG(PATCHWELCOME), "Not yet implemented in FFmpeg, patches welcome" },
47  { ERROR_TAG(PROTOCOL_NOT_FOUND), "Protocol not found" },
48  { ERROR_TAG(STREAM_NOT_FOUND), "Stream not found" },
49  { ERROR_TAG(UNKNOWN), "Unknown error occurred" },
50  { ERROR_TAG(EXPERIMENTAL), "Experimental feature" },
51 };
52 
53 int av_strerror(int errnum, char *errbuf, size_t errbuf_size)
54 {
55  int ret = 0, i;
56  const struct error_entry *entry = NULL;
57 
58  for (i = 0; i < FF_ARRAY_ELEMS(error_entries); i++) {
59  if (errnum == error_entries[i].num) {
60  entry = &error_entries[i];
61  break;
62  }
63  }
64  if (entry) {
65  av_strlcpy(errbuf, entry->str, errbuf_size);
66  } else {
67 #if HAVE_STRERROR_R
68  ret = AVERROR(strerror_r(AVUNERROR(errnum), errbuf, errbuf_size));
69 #else
70  ret = -1;
71 #endif
72  if (ret < 0)
73  snprintf(errbuf, errbuf_size, "Error number %d occurred", errnum);
74  }
75 
76  return ret;
77 }
78 
79 #ifdef TEST
80 
81 #undef printf
82 
83 int main(void)
84 {
85  int i;
86 
87  for (i = 0; i < FF_ARRAY_ELEMS(error_entries); i++) {
88  const struct error_entry *entry = &error_entries[i];
89  printf("%d: %s [%s]\n", entry->num, av_err2str(entry->num), entry->tag);
90  }
91 
92  for (i = 0; i < 256; i++) {
93  printf("%d: %s\n", -i, av_err2str(-i));
94  }
95 
96  return 0;
97 }
98 
99 #endif /* TEST */
external API header
#define FF_ARRAY_ELEMS(a)
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
Definition: avstring.c:82
Definition: error.c:24
ret
Definition: avfilter.c:821
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition: error.h:110
const char * tag
Definition: error.c:26
NULL
Definition: eval.c:55
static const struct error_entry error_entries[]
Definition: error.c:31
const char * str
Definition: error.c:27
synthesis window for stochastic i
#define snprintf
Definition: snprintf.h:34
#define ERROR_TAG(tag)
Definition: error.c:30
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFilterBuffer structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later.That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another.Buffer references ownership and permissions
int num
Definition: error.c:25
int av_strerror(int errnum, char *errbuf, size_t errbuf_size)
Put a description of the AVERROR code errnum in errbuf.
Definition: error.c:53
common internal and external API header
#define AVUNERROR(e)
Definition: error.h:44
printf("static const uint8_t my_array[100] = {\n")
int main(int argc, char **argv)
Definition: main.c:22