2 * This file is part of FFmpeg.
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.
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.
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
20 #define _XOPEN_SOURCE 600 /* XSI-compliant version of strerror_r */
31 #define ERROR_TAG(tag) AVERROR_##tag, #tag
32 #define AVERROR_INPUT_AND_OUTPUT_CHANGED (AVERROR_INPUT_CHANGED | AVERROR_OUTPUT_CHANGED)
33 static const struct error_entry error_entries[] = {
34 { ERROR_TAG(BSF_NOT_FOUND), "Bitstream filter not found" },
35 { ERROR_TAG(BUG), "Internal bug, should not have happened" },
36 { ERROR_TAG(BUG2), "Internal bug, should not have happened" },
37 { ERROR_TAG(BUFFER_TOO_SMALL), "Buffer too small" },
38 { ERROR_TAG(DECODER_NOT_FOUND), "Decoder not found" },
39 { ERROR_TAG(DEMUXER_NOT_FOUND), "Demuxer not found" },
40 { ERROR_TAG(ENCODER_NOT_FOUND), "Encoder not found" },
41 { ERROR_TAG(EOF), "End of file" },
42 { ERROR_TAG(EXIT), "Immediate exit requested" },
43 { ERROR_TAG(EXTERNAL), "Generic error in an external library" },
44 { ERROR_TAG(FILTER_NOT_FOUND), "Filter not found" },
45 { ERROR_TAG(INPUT_CHANGED), "Input changed" },
46 { ERROR_TAG(INVALIDDATA), "Invalid data found when processing input" },
47 { ERROR_TAG(MUXER_NOT_FOUND), "Muxer not found" },
48 { ERROR_TAG(OPTION_NOT_FOUND), "Option not found" },
49 { ERROR_TAG(OUTPUT_CHANGED), "Output changed" },
50 { ERROR_TAG(PATCHWELCOME), "Not yet implemented in FFmpeg, patches welcome" },
51 { ERROR_TAG(PROTOCOL_NOT_FOUND), "Protocol not found" },
52 { ERROR_TAG(STREAM_NOT_FOUND), "Stream not found" },
53 { ERROR_TAG(UNKNOWN), "Unknown error occurred" },
54 { ERROR_TAG(EXPERIMENTAL), "Experimental feature" },
55 { ERROR_TAG(INPUT_AND_OUTPUT_CHANGED), "Input and output changed" },
58 int av_strerror(int errnum, char *errbuf, size_t errbuf_size)
61 const struct error_entry *entry = NULL;
63 for (i = 0; i < FF_ARRAY_ELEMS(error_entries); i++) {
64 if (errnum == error_entries[i].num) {
65 entry = &error_entries[i];
70 av_strlcpy(errbuf, entry->str, errbuf_size);
73 ret = AVERROR(strerror_r(AVUNERROR(errnum), errbuf, errbuf_size));
78 snprintf(errbuf, errbuf_size, "Error number %d occurred", errnum);
92 for (i = 0; i < FF_ARRAY_ELEMS(error_entries); i++) {
93 const struct error_entry *entry = &error_entries[i];
94 printf("%d: %s [%s]\n", entry->num, av_err2str(entry->num), entry->tag);
97 for (i = 0; i < 256; i++) {
98 printf("%d: %s\n", -i, av_err2str(-i));