mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
lavu/error: add av_make_error_string() and av_err2str() convenience utilities
These functions are modeled after the corresponding utilities in libavutil/timestamp.h.
This commit is contained in:
parent
5683de00e9
commit
359abb18cf
@ -15,6 +15,10 @@ libavutil: 2011-04-18
|
|||||||
|
|
||||||
API changes, most recent first:
|
API changes, most recent first:
|
||||||
|
|
||||||
|
2012-04-11 - xxxxxxx - lavu 51.58.100 - error.h
|
||||||
|
Add av_make_error_string() and av_err2str() utilities to
|
||||||
|
libavutil/error.h.
|
||||||
|
|
||||||
2012-06-05 - xxxxxxx - lavc 54.24.100
|
2012-06-05 - xxxxxxx - lavc 54.24.100
|
||||||
Add pkt_duration field to AVFrame.
|
Add pkt_duration field to AVFrame.
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define LIBAVUTIL_VERSION_MAJOR 51
|
#define LIBAVUTIL_VERSION_MAJOR 51
|
||||||
#define LIBAVUTIL_VERSION_MINOR 57
|
#define LIBAVUTIL_VERSION_MINOR 58
|
||||||
#define LIBAVUTIL_VERSION_MICRO 100
|
#define LIBAVUTIL_VERSION_MICRO 100
|
||||||
|
|
||||||
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
|
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
|
||||||
|
@ -79,17 +79,14 @@ int av_strerror(int errnum, char *errbuf, size_t errbuf_size)
|
|||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char errbuf[256];
|
|
||||||
|
|
||||||
for (i = 0; i < FF_ARRAY_ELEMS(error_entries); i++) {
|
for (i = 0; i < FF_ARRAY_ELEMS(error_entries); i++) {
|
||||||
struct error_entry *entry = &error_entries[i];
|
struct error_entry *entry = &error_entries[i];
|
||||||
av_strerror(entry->num, errbuf, sizeof(errbuf));
|
printf("%d: %s [%s]\n", entry->num, av_err2str(entry->num), entry->tag);
|
||||||
printf("%d: %s [%s]\n", entry->num, errbuf, entry->tag);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 256; i++) {
|
for (i = 0; i < 256; i++) {
|
||||||
av_strerror(-i, errbuf, sizeof(errbuf));
|
printf("%d: %s\n", -i, av_err2str(-i));
|
||||||
printf("%d: %s\n", -i, errbuf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -68,6 +68,8 @@
|
|||||||
#define AVERROR_BUG2 FFERRTAG( 'B','U','G',' ')
|
#define AVERROR_BUG2 FFERRTAG( 'B','U','G',' ')
|
||||||
#define AVERROR_UNKNOWN FFERRTAG( 'U','N','K','N') ///< Unknown error, typically from an external library
|
#define AVERROR_UNKNOWN FFERRTAG( 'U','N','K','N') ///< Unknown error, typically from an external library
|
||||||
|
|
||||||
|
#define AV_ERROR_MAX_STRING_SIZE 64
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Put a description of the AVERROR code errnum in errbuf.
|
* Put a description of the AVERROR code errnum in errbuf.
|
||||||
* In case of failure the global variable errno is set to indicate the
|
* In case of failure the global variable errno is set to indicate the
|
||||||
@ -82,6 +84,29 @@
|
|||||||
*/
|
*/
|
||||||
int av_strerror(int errnum, char *errbuf, size_t errbuf_size);
|
int av_strerror(int errnum, char *errbuf, size_t errbuf_size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fill the provided buffer with a string containing an error string
|
||||||
|
* corresponding to the AVERROR code errnum.
|
||||||
|
*
|
||||||
|
* @param errbuf a buffer
|
||||||
|
* @param errbuf_size size in bytes of errbuf
|
||||||
|
* @param errnum error code to describe
|
||||||
|
* @return the buffer in input, filled with the error description
|
||||||
|
* @see av_strerror()
|
||||||
|
*/
|
||||||
|
static inline char *av_make_error_string(char *errbuf, size_t errbuf_size, int errnum)
|
||||||
|
{
|
||||||
|
av_strerror(errnum, errbuf, errbuf_size);
|
||||||
|
return errbuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenience macro, the return value should be used only directly in
|
||||||
|
* function arguments but never stand-alone.
|
||||||
|
*/
|
||||||
|
#define av_err2str(errnum) \
|
||||||
|
av_make_error_string((char[AV_ERROR_MAX_STRING_SIZE]){0}, AV_ERROR_MAX_STRING_SIZE, errnum)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user