diff options
author | François Revol <revol@free.fr> | 2007-02-13 18:26:14 +0000 |
---|---|---|
committer | François Revol <revol@free.fr> | 2007-02-13 18:26:14 +0000 |
commit | 8fa36ae09dddb1b639b4df5d505c0dbcf4e916e4 (patch) | |
tree | 551ead2b59bdc4b1855fb60d6c2ce6a2c7787f15 /libavcodec | |
parent | bcdf0d269748e2059ffa789033cd6e41739891fc (diff) | |
download | ffmpeg-8fa36ae09dddb1b639b4df5d505c0dbcf4e916e4.tar.gz |
This fixes error handling for BeOS, removing the need for some ifdefs.
AVERROR_ defines are moved to avcodec.h as they are needed in there as well. Feel free to move that to avutil/common.h.
Bumped up avcodec/format version numbers as though it's binary compatible we will want to rebuild apps as error values changed.
Please from now on use return AVERROR(EFOO) instead of the ugly return -EFOO in your code.
This also removes the need for berrno.h.
Originally committed as revision 7965 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/avcodec.h | 21 | ||||
-rw-r--r-- | libavcodec/dv.c | 4 | ||||
-rw-r--r-- | libavcodec/g726.c | 2 | ||||
-rw-r--r-- | libavcodec/gifdec.c | 2 | ||||
-rw-r--r-- | libavcodec/sonic.c | 2 |
5 files changed, 24 insertions, 7 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 2773c50ac9..1a86a1d270 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -37,8 +37,8 @@ extern "C" { #define AV_STRINGIFY(s) AV_TOSTRING(s) #define AV_TOSTRING(s) #s -#define LIBAVCODEC_VERSION_INT ((51<<16)+(32<<8)+0) -#define LIBAVCODEC_VERSION 51.32.0 +#define LIBAVCODEC_VERSION_INT ((51<<16)+(33<<8)+0) +#define LIBAVCODEC_VERSION 51.33.0 #define LIBAVCODEC_BUILD LIBAVCODEC_VERSION_INT #define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION) @@ -2699,6 +2699,23 @@ int img_pad(AVPicture *dst, const AVPicture *src, int height, int width, int pix extern unsigned int av_xiphlacing(unsigned char *s, unsigned int v); +/* error handling */ +#if EINVAL > 0 +#define AVERROR(e) (-(e)) /**< returns a negative error code from a POSIX error code, to return from library functions. */ +#define AVUNERROR(e) (-(e)) /**< returns a POSIX error code from a library function error return value. */ +#else +/* some platforms have E* and errno already negated. */ +#define AVERROR(e) (e) +#define AVUNERROR(e) (e) +#endif +#define AVERROR_UNKNOWN AVERROR(EINVAL) /**< unknown error */ +#define AVERROR_IO AVERROR(EIO) /**< i/o error */ +#define AVERROR_NUMEXPECTED AVERROR(EDOM) /**< number syntax expected in filename */ +#define AVERROR_INVALIDDATA AVERROR(EINVAL) /**< invalid data found */ +#define AVERROR_NOMEM AVERROR(ENOMEM) /**< not enough memory */ +#define AVERROR_NOFMT AVERROR(EILSEQ) /**< unknown format */ +#define AVERROR_NOTSUPP AVERROR(ENOSYS) /**< operation not supported */ + #ifdef __cplusplus } #endif diff --git a/libavcodec/dv.c b/libavcodec/dv.c index 505c88d494..b5f15df27a 100644 --- a/libavcodec/dv.c +++ b/libavcodec/dv.c @@ -125,7 +125,7 @@ static int dvvideo_init(AVCodecContext *avctx) dv_vlc_map = av_mallocz_static(DV_VLC_MAP_LEV_SIZE*DV_VLC_MAP_RUN_SIZE*sizeof(struct dv_vlc_pair)); if (!dv_vlc_map) - return -ENOMEM; + return AVERROR(ENOMEM); /* dv_anchor lets each thread know its Id */ for (i=0; i<DV_ANCHOR_SIZE; i++) @@ -157,7 +157,7 @@ static int dvvideo_init(AVCodecContext *avctx) dv_rl_vlc = av_mallocz_static(dv_vlc.table_size * sizeof(RL_VLC_ELEM)); if (!dv_rl_vlc) - return -ENOMEM; + return AVERROR(ENOMEM); for(i = 0; i < dv_vlc.table_size; i++){ int code= dv_vlc.table[i][0]; diff --git a/libavcodec/g726.c b/libavcodec/g726.c index c509292b6a..11417442a2 100644 --- a/libavcodec/g726.c +++ b/libavcodec/g726.c @@ -341,7 +341,7 @@ static int g726_init(AVCodecContext * avctx) avctx->coded_frame = avcodec_alloc_frame(); if (!avctx->coded_frame) - return -ENOMEM; + return AVERROR(ENOMEM); avctx->coded_frame->key_frame = 1; return 0; diff --git a/libavcodec/gifdec.c b/libavcodec/gifdec.c index 5a5712299e..3debe04acb 100644 --- a/libavcodec/gifdec.c +++ b/libavcodec/gifdec.c @@ -87,7 +87,7 @@ static int gif_read_image(GifState *s) /* verify that all the image is inside the screen dimensions */ if (left + width > s->screen_width || top + height > s->screen_height) - return -EINVAL; + return AVERROR(EINVAL); /* build the palette */ n = (1 << bits_per_pixel); diff --git a/libavcodec/sonic.c b/libavcodec/sonic.c index 2f798cc039..f3388589b6 100644 --- a/libavcodec/sonic.c +++ b/libavcodec/sonic.c @@ -601,7 +601,7 @@ static int sonic_encode_init(AVCodecContext *avctx) avctx->coded_frame = avcodec_alloc_frame(); if (!avctx->coded_frame) - return -ENOMEM; + return AVERROR(ENOMEM); avctx->coded_frame->key_frame = 1; avctx->frame_size = s->block_align*s->downsampling; |