1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
/*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#undef _GNU_SOURCE
#include "avutil.h"
#include "avstring.h"
struct error_entry {
int num;
const char *tag;
const char *str;
};
#define ERROR_TAG(tag) AVERROR_##tag, #tag
struct error_entry error_entries[] = {
{ ERROR_TAG(BSF_NOT_FOUND), "Bitstream filter not found" },
{ ERROR_TAG(BUG), "Internal bug, should not have happened" },
{ ERROR_TAG(BUG2), "Internal bug, should not have happened" },
{ ERROR_TAG(BUFFER_TOO_SMALL), "Buffer too small" },
{ ERROR_TAG(DECODER_NOT_FOUND), "Decoder not found" },
{ ERROR_TAG(DEMUXER_NOT_FOUND), "Demuxer not found" },
{ ERROR_TAG(ENCODER_NOT_FOUND), "Encoder not found" },
{ ERROR_TAG(EOF), "End of file" },
{ ERROR_TAG(EXIT), "Immediate exit requested" },
{ ERROR_TAG(EXTERNAL), "Generic error in an external library" },
{ ERROR_TAG(FILTER_NOT_FOUND), "Filter not found" },
{ ERROR_TAG(INVALIDDATA), "Invalid data found when processing input" },
{ ERROR_TAG(MUXER_NOT_FOUND), "Muxer not found" },
{ ERROR_TAG(OPTION_NOT_FOUND), "Option not found" },
{ ERROR_TAG(PATCHWELCOME), "Not yet implemented in FFmpeg, patches welcome" },
{ ERROR_TAG(PROTOCOL_NOT_FOUND), "Protocol not found" },
{ ERROR_TAG(STREAM_NOT_FOUND), "Stream not found" },
{ ERROR_TAG(UNKNOWN), "Unknown error occurred" },
};
int av_strerror(int errnum, char *errbuf, size_t errbuf_size)
{
int ret = 0, i;
struct error_entry *entry = NULL;
for (i = 0; i < FF_ARRAY_ELEMS(error_entries); i++) {
if (errnum == error_entries[i].num) {
entry = &error_entries[i];
break;
}
}
if (entry) {
av_strlcpy(errbuf, entry->str, errbuf_size);
} else {
#if HAVE_STRERROR_R
ret = AVERROR(strerror_r(AVUNERROR(errnum), errbuf, errbuf_size));
#else
ret = -1;
#endif
if (ret < 0)
snprintf(errbuf, errbuf_size, "Error number %d occurred", errnum);
}
return ret;
}
#ifdef TEST
#undef printf
int main(void)
{
int i;
for (i = 0; i < FF_ARRAY_ELEMS(error_entries); i++) {
struct error_entry *entry = &error_entries[i];
printf("%d: %s [%s]\n", entry->num, av_err2str(entry->num), entry->tag);
}
for (i = 0; i < 256; i++) {
printf("%d: %s\n", -i, av_err2str(-i));
}
return 0;
}
#endif /* TEST */
|