annotate ffmpeg/libavutil/error.h @ 13:844d341cf643 tip

Back up before ISMIR
author Yading Song <yading.song@eecs.qmul.ac.uk>
date Thu, 31 Oct 2013 13:17:06 +0000
parents f445c3017523
children
rev   line source
yading@11 1 /*
yading@11 2 * This file is part of FFmpeg.
yading@11 3 *
yading@11 4 * FFmpeg is free software; you can redistribute it and/or
yading@11 5 * modify it under the terms of the GNU Lesser General Public
yading@11 6 * License as published by the Free Software Foundation; either
yading@11 7 * version 2.1 of the License, or (at your option) any later version.
yading@11 8 *
yading@11 9 * FFmpeg is distributed in the hope that it will be useful,
yading@11 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
yading@11 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
yading@11 12 * Lesser General Public License for more details.
yading@11 13 *
yading@11 14 * You should have received a copy of the GNU Lesser General Public
yading@11 15 * License along with FFmpeg; if not, write to the Free Software
yading@11 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
yading@11 17 */
yading@11 18
yading@11 19 /**
yading@11 20 * @file
yading@11 21 * error code definitions
yading@11 22 */
yading@11 23
yading@11 24 #ifndef AVUTIL_ERROR_H
yading@11 25 #define AVUTIL_ERROR_H
yading@11 26
yading@11 27 #include <errno.h>
yading@11 28 #include <stddef.h>
yading@11 29
yading@11 30 /**
yading@11 31 * @addtogroup lavu_error
yading@11 32 *
yading@11 33 * @{
yading@11 34 */
yading@11 35
yading@11 36
yading@11 37 /* error handling */
yading@11 38 #if EDOM > 0
yading@11 39 #define AVERROR(e) (-(e)) ///< Returns a negative error code from a POSIX error code, to return from library functions.
yading@11 40 #define AVUNERROR(e) (-(e)) ///< Returns a POSIX error code from a library function error return value.
yading@11 41 #else
yading@11 42 /* Some platforms have E* and errno already negated. */
yading@11 43 #define AVERROR(e) (e)
yading@11 44 #define AVUNERROR(e) (e)
yading@11 45 #endif
yading@11 46
yading@11 47 #define FFERRTAG(a, b, c, d) (-(int)MKTAG(a, b, c, d))
yading@11 48
yading@11 49 #define AVERROR_BSF_NOT_FOUND FFERRTAG(0xF8,'B','S','F') ///< Bitstream filter not found
yading@11 50 #define AVERROR_BUG FFERRTAG( 'B','U','G','!') ///< Internal bug, also see AVERROR_BUG2
yading@11 51 #define AVERROR_BUFFER_TOO_SMALL FFERRTAG( 'B','U','F','S') ///< Buffer too small
yading@11 52 #define AVERROR_DECODER_NOT_FOUND FFERRTAG(0xF8,'D','E','C') ///< Decoder not found
yading@11 53 #define AVERROR_DEMUXER_NOT_FOUND FFERRTAG(0xF8,'D','E','M') ///< Demuxer not found
yading@11 54 #define AVERROR_ENCODER_NOT_FOUND FFERRTAG(0xF8,'E','N','C') ///< Encoder not found
yading@11 55 #define AVERROR_EOF FFERRTAG( 'E','O','F',' ') ///< End of file
yading@11 56 #define AVERROR_EXIT FFERRTAG( 'E','X','I','T') ///< Immediate exit was requested; the called function should not be restarted
yading@11 57 #define AVERROR_EXTERNAL FFERRTAG( 'E','X','T',' ') ///< Generic error in an external library
yading@11 58 #define AVERROR_FILTER_NOT_FOUND FFERRTAG(0xF8,'F','I','L') ///< Filter not found
yading@11 59 #define AVERROR_INVALIDDATA FFERRTAG( 'I','N','D','A') ///< Invalid data found when processing input
yading@11 60 #define AVERROR_MUXER_NOT_FOUND FFERRTAG(0xF8,'M','U','X') ///< Muxer not found
yading@11 61 #define AVERROR_OPTION_NOT_FOUND FFERRTAG(0xF8,'O','P','T') ///< Option not found
yading@11 62 #define AVERROR_PATCHWELCOME FFERRTAG( 'P','A','W','E') ///< Not yet implemented in FFmpeg, patches welcome
yading@11 63 #define AVERROR_PROTOCOL_NOT_FOUND FFERRTAG(0xF8,'P','R','O') ///< Protocol not found
yading@11 64
yading@11 65 #define AVERROR_STREAM_NOT_FOUND FFERRTAG(0xF8,'S','T','R') ///< Stream not found
yading@11 66 /**
yading@11 67 * This is semantically identical to AVERROR_BUG
yading@11 68 * it has been introduced in Libav after our AVERROR_BUG and with a modified value.
yading@11 69 */
yading@11 70 #define AVERROR_BUG2 FFERRTAG( 'B','U','G',' ')
yading@11 71 #define AVERROR_UNKNOWN FFERRTAG( 'U','N','K','N') ///< Unknown error, typically from an external library
yading@11 72 #define AVERROR_EXPERIMENTAL (-0x2bb2afa8) ///< Requested feature is flagged experimental. Set strict_std_compliance if you really want to use it.
yading@11 73
yading@11 74 #define AV_ERROR_MAX_STRING_SIZE 64
yading@11 75
yading@11 76 /**
yading@11 77 * Put a description of the AVERROR code errnum in errbuf.
yading@11 78 * In case of failure the global variable errno is set to indicate the
yading@11 79 * error. Even in case of failure av_strerror() will print a generic
yading@11 80 * error message indicating the errnum provided to errbuf.
yading@11 81 *
yading@11 82 * @param errnum error code to describe
yading@11 83 * @param errbuf buffer to which description is written
yading@11 84 * @param errbuf_size the size in bytes of errbuf
yading@11 85 * @return 0 on success, a negative value if a description for errnum
yading@11 86 * cannot be found
yading@11 87 */
yading@11 88 int av_strerror(int errnum, char *errbuf, size_t errbuf_size);
yading@11 89
yading@11 90 /**
yading@11 91 * Fill the provided buffer with a string containing an error string
yading@11 92 * corresponding to the AVERROR code errnum.
yading@11 93 *
yading@11 94 * @param errbuf a buffer
yading@11 95 * @param errbuf_size size in bytes of errbuf
yading@11 96 * @param errnum error code to describe
yading@11 97 * @return the buffer in input, filled with the error description
yading@11 98 * @see av_strerror()
yading@11 99 */
yading@11 100 static inline char *av_make_error_string(char *errbuf, size_t errbuf_size, int errnum)
yading@11 101 {
yading@11 102 av_strerror(errnum, errbuf, errbuf_size);
yading@11 103 return errbuf;
yading@11 104 }
yading@11 105
yading@11 106 /**
yading@11 107 * Convenience macro, the return value should be used only directly in
yading@11 108 * function arguments but never stand-alone.
yading@11 109 */
yading@11 110 #define av_err2str(errnum) \
yading@11 111 av_make_error_string((char[AV_ERROR_MAX_STRING_SIZE]){0}, AV_ERROR_MAX_STRING_SIZE, errnum)
yading@11 112
yading@11 113 /**
yading@11 114 * @}
yading@11 115 */
yading@11 116
yading@11 117 #endif /* AVUTIL_ERROR_H */