yading@11: /* yading@11: * This file is part of FFmpeg. yading@11: * yading@11: * FFmpeg is free software; you can redistribute it and/or yading@11: * modify it under the terms of the GNU Lesser General Public yading@11: * License as published by the Free Software Foundation; either yading@11: * version 2.1 of the License, or (at your option) any later version. yading@11: * yading@11: * FFmpeg is distributed in the hope that it will be useful, yading@11: * but WITHOUT ANY WARRANTY; without even the implied warranty of yading@11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU yading@11: * Lesser General Public License for more details. yading@11: * yading@11: * You should have received a copy of the GNU Lesser General Public yading@11: * License along with FFmpeg; if not, write to the Free Software yading@11: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA yading@11: */ yading@11: yading@11: /** yading@11: * @file yading@11: * error code definitions yading@11: */ yading@11: yading@11: #ifndef AVUTIL_ERROR_H yading@11: #define AVUTIL_ERROR_H yading@11: yading@11: #include yading@11: #include yading@11: yading@11: /** yading@11: * @addtogroup lavu_error yading@11: * yading@11: * @{ yading@11: */ yading@11: yading@11: yading@11: /* error handling */ yading@11: #if EDOM > 0 yading@11: #define AVERROR(e) (-(e)) ///< Returns a negative error code from a POSIX error code, to return from library functions. yading@11: #define AVUNERROR(e) (-(e)) ///< Returns a POSIX error code from a library function error return value. yading@11: #else yading@11: /* Some platforms have E* and errno already negated. */ yading@11: #define AVERROR(e) (e) yading@11: #define AVUNERROR(e) (e) yading@11: #endif yading@11: yading@11: #define FFERRTAG(a, b, c, d) (-(int)MKTAG(a, b, c, d)) yading@11: yading@11: #define AVERROR_BSF_NOT_FOUND FFERRTAG(0xF8,'B','S','F') ///< Bitstream filter not found yading@11: #define AVERROR_BUG FFERRTAG( 'B','U','G','!') ///< Internal bug, also see AVERROR_BUG2 yading@11: #define AVERROR_BUFFER_TOO_SMALL FFERRTAG( 'B','U','F','S') ///< Buffer too small yading@11: #define AVERROR_DECODER_NOT_FOUND FFERRTAG(0xF8,'D','E','C') ///< Decoder not found yading@11: #define AVERROR_DEMUXER_NOT_FOUND FFERRTAG(0xF8,'D','E','M') ///< Demuxer not found yading@11: #define AVERROR_ENCODER_NOT_FOUND FFERRTAG(0xF8,'E','N','C') ///< Encoder not found yading@11: #define AVERROR_EOF FFERRTAG( 'E','O','F',' ') ///< End of file yading@11: #define AVERROR_EXIT FFERRTAG( 'E','X','I','T') ///< Immediate exit was requested; the called function should not be restarted yading@11: #define AVERROR_EXTERNAL FFERRTAG( 'E','X','T',' ') ///< Generic error in an external library yading@11: #define AVERROR_FILTER_NOT_FOUND FFERRTAG(0xF8,'F','I','L') ///< Filter not found yading@11: #define AVERROR_INVALIDDATA FFERRTAG( 'I','N','D','A') ///< Invalid data found when processing input yading@11: #define AVERROR_MUXER_NOT_FOUND FFERRTAG(0xF8,'M','U','X') ///< Muxer not found yading@11: #define AVERROR_OPTION_NOT_FOUND FFERRTAG(0xF8,'O','P','T') ///< Option not found yading@11: #define AVERROR_PATCHWELCOME FFERRTAG( 'P','A','W','E') ///< Not yet implemented in FFmpeg, patches welcome yading@11: #define AVERROR_PROTOCOL_NOT_FOUND FFERRTAG(0xF8,'P','R','O') ///< Protocol not found yading@11: yading@11: #define AVERROR_STREAM_NOT_FOUND FFERRTAG(0xF8,'S','T','R') ///< Stream not found yading@11: /** yading@11: * This is semantically identical to AVERROR_BUG yading@11: * it has been introduced in Libav after our AVERROR_BUG and with a modified value. yading@11: */ yading@11: #define AVERROR_BUG2 FFERRTAG( 'B','U','G',' ') yading@11: #define AVERROR_UNKNOWN FFERRTAG( 'U','N','K','N') ///< Unknown error, typically from an external library yading@11: #define AVERROR_EXPERIMENTAL (-0x2bb2afa8) ///< Requested feature is flagged experimental. Set strict_std_compliance if you really want to use it. yading@11: yading@11: #define AV_ERROR_MAX_STRING_SIZE 64 yading@11: yading@11: /** yading@11: * Put a description of the AVERROR code errnum in errbuf. yading@11: * In case of failure the global variable errno is set to indicate the yading@11: * error. Even in case of failure av_strerror() will print a generic yading@11: * error message indicating the errnum provided to errbuf. yading@11: * yading@11: * @param errnum error code to describe yading@11: * @param errbuf buffer to which description is written yading@11: * @param errbuf_size the size in bytes of errbuf yading@11: * @return 0 on success, a negative value if a description for errnum yading@11: * cannot be found yading@11: */ yading@11: int av_strerror(int errnum, char *errbuf, size_t errbuf_size); yading@11: yading@11: /** yading@11: * Fill the provided buffer with a string containing an error string yading@11: * corresponding to the AVERROR code errnum. yading@11: * yading@11: * @param errbuf a buffer yading@11: * @param errbuf_size size in bytes of errbuf yading@11: * @param errnum error code to describe yading@11: * @return the buffer in input, filled with the error description yading@11: * @see av_strerror() yading@11: */ yading@11: static inline char *av_make_error_string(char *errbuf, size_t errbuf_size, int errnum) yading@11: { yading@11: av_strerror(errnum, errbuf, errbuf_size); yading@11: return errbuf; yading@11: } yading@11: yading@11: /** yading@11: * Convenience macro, the return value should be used only directly in yading@11: * function arguments but never stand-alone. yading@11: */ yading@11: #define av_err2str(errnum) \ yading@11: av_make_error_string((char[AV_ERROR_MAX_STRING_SIZE]){0}, AV_ERROR_MAX_STRING_SIZE, errnum) yading@11: yading@11: /** yading@11: * @} yading@11: */ yading@11: yading@11: #endif /* AVUTIL_ERROR_H */