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
pull/126/head
François Revol 18 years ago
parent bcdf0d2697
commit 8fa36ae09d
  1. 8
      ffmpeg.c
  2. 21
      libavcodec/avcodec.h
  3. 4
      libavcodec/dv.c
  4. 2
      libavcodec/g726.c
  5. 2
      libavcodec/gifdec.c
  6. 2
      libavcodec/sonic.c
  7. 2
      libavformat/audio.c
  8. 12
      libavformat/avformat.h
  9. 10
      libavformat/avio.c
  10. 4
      libavformat/avio.h
  11. 10
      libavformat/aviobuf.c
  12. 22
      libavformat/beosaudio.cpp
  13. 8
      libavformat/ffm.c
  14. 2
      libavformat/file.c
  15. 8
      libavformat/framehook.c
  16. 6
      libavformat/gifdec.c
  17. 2
      libavformat/grab.c
  18. 6
      libavformat/grab_bktr.c
  19. 2
      libavformat/http.c
  20. 2
      libavformat/img2.c
  21. 2
      libavformat/mpeg.c
  22. 2
      libavformat/mpegts.c
  23. 2
      libavformat/rtpproto.c
  24. 2
      libavformat/smacker.c
  25. 2
      libavformat/sol.c
  26. 23
      libavformat/tcp.c
  27. 2
      libavformat/udp.c
  28. 6
      libavformat/utils.c
  29. 2
      libavformat/v4l2.c
  30. 2
      libavformat/wv.c
  31. 4
      libavformat/x11grab.c
  32. 6
      libavutil/common.h

@ -1797,12 +1797,12 @@ static int av_encode(AVFormatContext **output_files,
int in_file_index = meta_data_maps[i].in_file; int in_file_index = meta_data_maps[i].in_file;
if ( out_file_index < 0 || out_file_index >= nb_output_files ) { if ( out_file_index < 0 || out_file_index >= nb_output_files ) {
fprintf(stderr, "Invalid output file index %d map_meta_data(%d,%d)\n", out_file_index, out_file_index, in_file_index); fprintf(stderr, "Invalid output file index %d map_meta_data(%d,%d)\n", out_file_index, out_file_index, in_file_index);
ret = -EINVAL; ret = AVERROR(EINVAL);
goto fail; goto fail;
} }
if ( in_file_index < 0 || in_file_index >= nb_input_files ) { if ( in_file_index < 0 || in_file_index >= nb_input_files ) {
fprintf(stderr, "Invalid input file index %d map_meta_data(%d,%d)\n", in_file_index, out_file_index, in_file_index); fprintf(stderr, "Invalid input file index %d map_meta_data(%d,%d)\n", in_file_index, out_file_index, in_file_index);
ret = -EINVAL; ret = AVERROR(EINVAL);
goto fail; goto fail;
} }
@ -1824,7 +1824,7 @@ static int av_encode(AVFormatContext **output_files,
os = output_files[i]; os = output_files[i];
if (av_write_header(os) < 0) { if (av_write_header(os) < 0) {
fprintf(stderr, "Could not write header for output file #%d (incorrect codec parameters ?)\n", i); fprintf(stderr, "Could not write header for output file #%d (incorrect codec parameters ?)\n", i);
ret = -EINVAL; ret = AVERROR(EINVAL);
goto fail; goto fail;
} }
} }
@ -2027,7 +2027,7 @@ static int av_encode(AVFormatContext **output_files,
} }
return ret; return ret;
fail: fail:
ret = -ENOMEM; ret = AVERROR(ENOMEM);
goto fail1; goto fail1;
} }

@ -37,8 +37,8 @@ extern "C" {
#define AV_STRINGIFY(s) AV_TOSTRING(s) #define AV_STRINGIFY(s) AV_TOSTRING(s)
#define AV_TOSTRING(s) #s #define AV_TOSTRING(s) #s
#define LIBAVCODEC_VERSION_INT ((51<<16)+(32<<8)+0) #define LIBAVCODEC_VERSION_INT ((51<<16)+(33<<8)+0)
#define LIBAVCODEC_VERSION 51.32.0 #define LIBAVCODEC_VERSION 51.33.0
#define LIBAVCODEC_BUILD LIBAVCODEC_VERSION_INT #define LIBAVCODEC_BUILD LIBAVCODEC_VERSION_INT
#define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION) #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); 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 #ifdef __cplusplus
} }
#endif #endif

@ -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)); 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) if (!dv_vlc_map)
return -ENOMEM; return AVERROR(ENOMEM);
/* dv_anchor lets each thread know its Id */ /* dv_anchor lets each thread know its Id */
for (i=0; i<DV_ANCHOR_SIZE; i++) 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)); dv_rl_vlc = av_mallocz_static(dv_vlc.table_size * sizeof(RL_VLC_ELEM));
if (!dv_rl_vlc) if (!dv_rl_vlc)
return -ENOMEM; return AVERROR(ENOMEM);
for(i = 0; i < dv_vlc.table_size; i++){ for(i = 0; i < dv_vlc.table_size; i++){
int code= dv_vlc.table[i][0]; int code= dv_vlc.table[i][0];

@ -341,7 +341,7 @@ static int g726_init(AVCodecContext * avctx)
avctx->coded_frame = avcodec_alloc_frame(); avctx->coded_frame = avcodec_alloc_frame();
if (!avctx->coded_frame) if (!avctx->coded_frame)
return -ENOMEM; return AVERROR(ENOMEM);
avctx->coded_frame->key_frame = 1; avctx->coded_frame->key_frame = 1;
return 0; return 0;

@ -87,7 +87,7 @@ static int gif_read_image(GifState *s)
/* verify that all the image is inside the screen dimensions */ /* verify that all the image is inside the screen dimensions */
if (left + width > s->screen_width || if (left + width > s->screen_width ||
top + height > s->screen_height) top + height > s->screen_height)
return -EINVAL; return AVERROR(EINVAL);
/* build the palette */ /* build the palette */
n = (1 << bits_per_pixel); n = (1 << bits_per_pixel);

@ -601,7 +601,7 @@ static int sonic_encode_init(AVCodecContext *avctx)
avctx->coded_frame = avcodec_alloc_frame(); avctx->coded_frame = avcodec_alloc_frame();
if (!avctx->coded_frame) if (!avctx->coded_frame)
return -ENOMEM; return AVERROR(ENOMEM);
avctx->coded_frame->key_frame = 1; avctx->coded_frame->key_frame = 1;
avctx->frame_size = s->block_align*s->downsampling; avctx->frame_size = s->block_align*s->downsampling;

@ -224,7 +224,7 @@ static int audio_read_header(AVFormatContext *s1, AVFormatParameters *ap)
st = av_new_stream(s1, 0); st = av_new_stream(s1, 0);
if (!st) { if (!st) {
return -ENOMEM; return AVERROR(ENOMEM);
} }
s->sample_rate = ap->sample_rate; s->sample_rate = ap->sample_rate;
s->channels = ap->channels; s->channels = ap->channels;

@ -25,8 +25,8 @@
extern "C" { extern "C" {
#endif #endif
#define LIBAVFORMAT_VERSION_INT ((51<<16)+(9<<8)+0) #define LIBAVFORMAT_VERSION_INT ((51<<16)+(10<<8)+0)
#define LIBAVFORMAT_VERSION 51.9.0 #define LIBAVFORMAT_VERSION 51.10.0
#define LIBAVFORMAT_BUILD LIBAVFORMAT_VERSION_INT #define LIBAVFORMAT_BUILD LIBAVFORMAT_VERSION_INT
#define LIBAVFORMAT_IDENT "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION) #define LIBAVFORMAT_IDENT "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION)
@ -433,14 +433,6 @@ int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
/* no av_open for output, so applications will need this: */ /* no av_open for output, so applications will need this: */
AVFormatContext *av_alloc_format_context(void); AVFormatContext *av_alloc_format_context(void);
#define AVERROR_UNKNOWN (-1) /* unknown error */
#define AVERROR_IO (-2) /* i/o error */
#define AVERROR_NUMEXPECTED (-3) /* number syntax expected in filename */
#define AVERROR_INVALIDDATA (-4) /* invalid data found */
#define AVERROR_NOMEM (-5) /* not enough memory */
#define AVERROR_NOFMT (-6) /* unknown format */
#define AVERROR_NOTSUPP (-7) /* operation not supported */
int av_find_stream_info(AVFormatContext *ic); int av_find_stream_info(AVFormatContext *ic);
int av_read_packet(AVFormatContext *s, AVPacket *pkt); int av_read_packet(AVFormatContext *s, AVPacket *pkt);
int av_read_frame(AVFormatContext *s, AVPacket *pkt); int av_read_frame(AVFormatContext *s, AVPacket *pkt);

@ -67,12 +67,12 @@ int url_open(URLContext **puc, const char *filename, int flags)
goto found; goto found;
up = up->next; up = up->next;
} }
err = -ENOENT; err = AVERROR(ENOENT);
goto fail; goto fail;
found: found:
uc = av_malloc(sizeof(URLContext) + strlen(filename) + 1); uc = av_malloc(sizeof(URLContext) + strlen(filename) + 1);
if (!uc) { if (!uc) {
err = -ENOMEM; err = AVERROR(ENOMEM);
goto fail; goto fail;
} }
#if LIBAVFORMAT_VERSION_INT >= (52<<16) #if LIBAVFORMAT_VERSION_INT >= (52<<16)
@ -124,7 +124,7 @@ offset_t url_seek(URLContext *h, offset_t pos, int whence)
offset_t ret; offset_t ret;
if (!h->prot->url_seek) if (!h->prot->url_seek)
return -EPIPE; return AVERROR(EPIPE);
ret = h->prot->url_seek(h, pos, whence); ret = h->prot->url_seek(h, pos, whence);
return ret; return ret;
} }
@ -188,8 +188,8 @@ static int default_interrupt_cb(void)
/** /**
* The callback is called in blocking functions to test regulary if * The callback is called in blocking functions to test regulary if
* asynchronous interruption is needed. -EINTR is returned in this * asynchronous interruption is needed. AVERROR(EINTR) is returned
* case by the interrupted function. 'NULL' means no interrupt * in this case by the interrupted function. 'NULL' means no interrupt
* callback is given. * callback is given.
*/ */
void url_set_interrupt_cb(URLInterruptCB *interrupt_cb) void url_set_interrupt_cb(URLInterruptCB *interrupt_cb)

@ -65,8 +65,8 @@ int url_get_max_packet_size(URLContext *h);
void url_get_filename(URLContext *h, char *buf, int buf_size); void url_get_filename(URLContext *h, char *buf, int buf_size);
/* the callback is called in blocking functions to test regulary if /* the callback is called in blocking functions to test regulary if
asynchronous interruption is needed. -EINTR is returned in this asynchronous interruption is needed. AVERROR(EINTR) is returned
case by the interrupted function. 'NULL' means no interrupt in this case by the interrupted function. 'NULL' means no interrupt
callback is given. */ callback is given. */
void url_set_interrupt_cb(URLInterruptCB *interrupt_cb); void url_set_interrupt_cb(URLInterruptCB *interrupt_cb);

@ -117,7 +117,7 @@ offset_t url_fseek(ByteIOContext *s, offset_t offset, int whence)
offset_t pos= s->pos - (s->write_flag ? 0 : (s->buf_end - s->buffer)); offset_t pos= s->pos - (s->write_flag ? 0 : (s->buf_end - s->buffer));
if (whence != SEEK_CUR && whence != SEEK_SET) if (whence != SEEK_CUR && whence != SEEK_SET)
return -EINVAL; return AVERROR(EINVAL);
if (whence == SEEK_CUR) { if (whence == SEEK_CUR) {
offset1 = pos + (s->buf_ptr - s->buffer); offset1 = pos + (s->buf_ptr - s->buffer);
@ -136,7 +136,7 @@ offset_t url_fseek(ByteIOContext *s, offset_t offset, int whence)
fill_buffer(s); fill_buffer(s);
s->buf_ptr = s->buf_end + offset - s->pos; s->buf_ptr = s->buf_end + offset - s->pos;
} else { } else {
offset_t res = -EPIPE; offset_t res = AVERROR(EPIPE);
#if defined(CONFIG_MUXERS) || defined(CONFIG_NETWORK) #if defined(CONFIG_MUXERS) || defined(CONFIG_NETWORK)
if (s->write_flag) { if (s->write_flag) {
@ -171,7 +171,7 @@ offset_t url_fsize(ByteIOContext *s)
offset_t size; offset_t size;
if (!s->seek) if (!s->seek)
return -EPIPE; return AVERROR(EPIPE);
size = s->seek(s->opaque, 0, AVSEEK_SIZE); size = s->seek(s->opaque, 0, AVSEEK_SIZE);
if(size<0){ if(size<0){
if ((size = s->seek(s->opaque, -1, SEEK_END)) < 0) if ((size = s->seek(s->opaque, -1, SEEK_END)) < 0)
@ -511,7 +511,7 @@ int url_fdopen(ByteIOContext *s, URLContext *h)
} }
buffer = av_malloc(buffer_size); buffer = av_malloc(buffer_size);
if (!buffer) if (!buffer)
return -ENOMEM; return AVERROR(ENOMEM);
if (init_put_byte(s, buffer, buffer_size, if (init_put_byte(s, buffer, buffer_size,
(h->flags & URL_WRONLY || h->flags & URL_RDWR), h, (h->flags & URL_WRONLY || h->flags & URL_RDWR), h,
@ -530,7 +530,7 @@ int url_setbufsize(ByteIOContext *s, int buf_size)
uint8_t *buffer; uint8_t *buffer;
buffer = av_malloc(buf_size); buffer = av_malloc(buf_size);
if (!buffer) if (!buffer)
return -ENOMEM; return AVERROR(ENOMEM);
av_free(s->buffer); av_free(s->buffer);
s->buffer = buffer; s->buffer = buffer;

@ -194,15 +194,15 @@ static int audio_open(AudioData *s, int is_output, const char *audio_device)
#ifndef HAVE_BSOUNDRECORDER #ifndef HAVE_BSOUNDRECORDER
if (!is_output) if (!is_output)
return -EIO; /* not for now */ return AVERROR(EIO); /* not for now */
#endif #endif
s->input_sem = create_sem(AUDIO_BUFFER_SIZE, "ffmpeg_ringbuffer_input"); s->input_sem = create_sem(AUDIO_BUFFER_SIZE, "ffmpeg_ringbuffer_input");
if (s->input_sem < B_OK) if (s->input_sem < B_OK)
return -EIO; return AVERROR(EIO);
s->output_sem = create_sem(0, "ffmpeg_ringbuffer_output"); s->output_sem = create_sem(0, "ffmpeg_ringbuffer_output");
if (s->output_sem < B_OK) { if (s->output_sem < B_OK) {
delete_sem(s->input_sem); delete_sem(s->input_sem);
return -EIO; return AVERROR(EIO);
} }
s->input_index = 0; s->input_index = 0;
s->output_index = 0; s->output_index = 0;
@ -226,7 +226,7 @@ static int audio_open(AudioData *s, int is_output, const char *audio_device)
delete_sem(s->input_sem); delete_sem(s->input_sem);
if (s->output_sem) if (s->output_sem)
delete_sem(s->output_sem); delete_sem(s->output_sem);
return -EIO; return AVERROR(EIO);
} }
s->codec_id = (iformat.byte_order == B_MEDIA_LITTLE_ENDIAN)?CODEC_ID_PCM_S16LE:CODEC_ID_PCM_S16BE; s->codec_id = (iformat.byte_order == B_MEDIA_LITTLE_ENDIAN)?CODEC_ID_PCM_S16LE:CODEC_ID_PCM_S16BE;
s->channels = iformat.channel_count; s->channels = iformat.channel_count;
@ -252,7 +252,7 @@ static int audio_open(AudioData *s, int is_output, const char *audio_device)
delete_sem(s->input_sem); delete_sem(s->input_sem);
if (s->output_sem) if (s->output_sem)
delete_sem(s->output_sem); delete_sem(s->output_sem);
return -EIO; return AVERROR(EIO);
} }
s->player->SetCookie(s); s->player->SetCookie(s);
s->player->SetVolume(1.0); s->player->SetVolume(1.0);
@ -293,7 +293,7 @@ static int audio_write_header(AVFormatContext *s1)
s->channels = st->codec->channels; s->channels = st->codec->channels;
ret = audio_open(s, 1, NULL); ret = audio_open(s, 1, NULL);
if (ret < 0) if (ret < 0)
return -EIO; return AVERROR(EIO);
return 0; return 0;
} }
@ -315,7 +315,7 @@ lat1 = s->player->Latency();
int amount; int amount;
len = MIN(size, AUDIO_BLOCK_SIZE); len = MIN(size, AUDIO_BLOCK_SIZE);
if (acquire_sem_etc(s->input_sem, len, B_CAN_INTERRUPT, 0LL) < B_OK) if (acquire_sem_etc(s->input_sem, len, B_CAN_INTERRUPT, 0LL) < B_OK)
return -EIO; return AVERROR(EIO);
amount = MIN(len, (AUDIO_BUFFER_SIZE - s->input_index)); amount = MIN(len, (AUDIO_BUFFER_SIZE - s->input_index));
memcpy(&s->buffer[s->input_index], buf, amount); memcpy(&s->buffer[s->input_index], buf, amount);
s->input_index += amount; s->input_index += amount;
@ -356,7 +356,7 @@ static int audio_read_header(AVFormatContext *s1, AVFormatParameters *ap)
st = av_new_stream(s1, 0); st = av_new_stream(s1, 0);
if (!st) { if (!st) {
return -ENOMEM; return AVERROR(ENOMEM);
} }
s->sample_rate = ap->sample_rate; s->sample_rate = ap->sample_rate;
s->channels = ap->channels; s->channels = ap->channels;
@ -364,7 +364,7 @@ static int audio_read_header(AVFormatContext *s1, AVFormatParameters *ap)
ret = audio_open(s, 0, ap->device); ret = audio_open(s, 0, ap->device);
if (ret < 0) { if (ret < 0) {
av_free(st); av_free(st);
return -EIO; return AVERROR(EIO);
} }
/* take real parameters */ /* take real parameters */
st->codec->codec_type = CODEC_TYPE_AUDIO; st->codec->codec_type = CODEC_TYPE_AUDIO;
@ -384,7 +384,7 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt)
status_t err; status_t err;
if (av_new_packet(pkt, s->frame_size) < 0) if (av_new_packet(pkt, s->frame_size) < 0)
return -EIO; return AVERROR(EIO);
buf = (unsigned char *)pkt->data; buf = (unsigned char *)pkt->data;
size = pkt->size; size = pkt->size;
while (size > 0) { while (size > 0) {
@ -393,7 +393,7 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt)
while ((err=acquire_sem_etc(s->output_sem, len, B_CAN_INTERRUPT, 0LL)) == B_INTERRUPTED); while ((err=acquire_sem_etc(s->output_sem, len, B_CAN_INTERRUPT, 0LL)) == B_INTERRUPTED);
if (err < B_OK) { if (err < B_OK) {
av_free_packet(pkt); av_free_packet(pkt);
return -EIO; return AVERROR(EIO);
} }
amount = MIN(len, (AUDIO_BUFFER_SIZE - s->output_index)); amount = MIN(len, (AUDIO_BUFFER_SIZE - s->output_index));
memcpy(buf, &s->buffer[s->output_index], amount); memcpy(buf, &s->buffer[s->output_index], amount);

@ -579,7 +579,7 @@ static int ffm_read_packet(AVFormatContext *s, AVPacket *pkt)
switch(ffm->read_state) { switch(ffm->read_state) {
case READ_HEADER: case READ_HEADER:
if (!ffm_is_avail_data(s, FRAME_HEADER_SIZE)) { if (!ffm_is_avail_data(s, FRAME_HEADER_SIZE)) {
return -EAGAIN; return AVERROR(EAGAIN);
} }
#if 0 #if 0
printf("pos=%08"PRIx64" spos=%"PRIx64", write_index=%"PRIx64" size=%"PRIx64"\n", printf("pos=%08"PRIx64" spos=%"PRIx64", write_index=%"PRIx64" size=%"PRIx64"\n",
@ -587,7 +587,7 @@ static int ffm_read_packet(AVFormatContext *s, AVPacket *pkt)
#endif #endif
if (ffm_read_data(s, ffm->header, FRAME_HEADER_SIZE, 1) != if (ffm_read_data(s, ffm->header, FRAME_HEADER_SIZE, 1) !=
FRAME_HEADER_SIZE) FRAME_HEADER_SIZE)
return -EAGAIN; return AVERROR(EAGAIN);
#if 0 #if 0
{ {
int i; int i;
@ -601,7 +601,7 @@ static int ffm_read_packet(AVFormatContext *s, AVPacket *pkt)
case READ_DATA: case READ_DATA:
size = (ffm->header[2] << 16) | (ffm->header[3] << 8) | ffm->header[4]; size = (ffm->header[2] << 16) | (ffm->header[3] << 8) | ffm->header[4];
if (!ffm_is_avail_data(s, size)) { if (!ffm_is_avail_data(s, size)) {
return -EAGAIN; return AVERROR(EAGAIN);
} }
duration = (ffm->header[5] << 16) | (ffm->header[6] << 8) | ffm->header[7]; duration = (ffm->header[5] << 16) | (ffm->header[6] << 8) | ffm->header[7];
@ -616,7 +616,7 @@ static int ffm_read_packet(AVFormatContext *s, AVPacket *pkt)
if (ffm_read_data(s, pkt->data, size, 0) != size) { if (ffm_read_data(s, pkt->data, size, 0) != size) {
/* bad case: desynchronized packet. we cancel all the packet loading */ /* bad case: desynchronized packet. we cancel all the packet loading */
av_free_packet(pkt); av_free_packet(pkt);
return -EAGAIN; return AVERROR(EAGAIN);
} }
if (ffm->first_frame_in_packet) if (ffm->first_frame_in_packet)
{ {

@ -45,7 +45,7 @@ static int file_open(URLContext *h, const char *filename, int flags)
#endif #endif
fd = open(filename, access, 0666); fd = open(filename, access, 0666);
if (fd < 0) if (fd < 0)
return -ENOENT; return AVERROR(ENOENT);
h->priv_data = (void *)(size_t)fd; h->priv_data = (void *)(size_t)fd;
return 0; return 0;
} }

@ -57,7 +57,7 @@ int frame_hook_add(int argc, char *argv[])
fhe = av_mallocz(sizeof(*fhe)); fhe = av_mallocz(sizeof(*fhe));
if (!fhe) { if (!fhe) {
return -ENOMEM; return AVERROR(ENOMEM);
} }
fhe->Configure = dlsym(loaded, "Configure"); fhe->Configure = dlsym(loaded, "Configure");
@ -66,18 +66,18 @@ int frame_hook_add(int argc, char *argv[])
if (!fhe->Process) { if (!fhe->Process) {
av_log(NULL, AV_LOG_ERROR, "Failed to find Process entrypoint in %s\n", argv[0]); av_log(NULL, AV_LOG_ERROR, "Failed to find Process entrypoint in %s\n", argv[0]);
return -1; return AVERROR(ENOENT);
} }
if (!fhe->Configure && argc > 1) { if (!fhe->Configure && argc > 1) {
av_log(NULL, AV_LOG_ERROR, "Failed to find Configure entrypoint in %s\n", argv[0]); av_log(NULL, AV_LOG_ERROR, "Failed to find Configure entrypoint in %s\n", argv[0]);
return -1; return AVERROR(ENOENT);
} }
if (argc > 1 || fhe->Configure) { if (argc > 1 || fhe->Configure) {
if (fhe->Configure(&fhe->ctx, argc, argv)) { if (fhe->Configure(&fhe->ctx, argc, argv)) {
av_log(NULL, AV_LOG_ERROR, "Failed to Configure %s\n", argv[0]); av_log(NULL, AV_LOG_ERROR, "Failed to Configure %s\n", argv[0]);
return -1; return AVERROR(EINVAL);
} }
} }

@ -305,13 +305,13 @@ static int gif_read_image(GifState *s)
/* verify that all the image is inside the screen dimensions */ /* verify that all the image is inside the screen dimensions */
if (left + width > s->screen_width || if (left + width > s->screen_width ||
top + height > s->screen_height) top + height > s->screen_height)
return -EINVAL; return AVERROR(EINVAL);
/* build the palette */ /* build the palette */
if (s->pix_fmt == PIX_FMT_RGB24) { if (s->pix_fmt == PIX_FMT_RGB24) {
line = av_malloc(width); line = av_malloc(width);
if (!line) if (!line)
return -ENOMEM; return AVERROR(ENOMEM);
} else { } else {
n = (1 << bits_per_pixel); n = (1 << bits_per_pixel);
spal = palette; spal = palette;
@ -537,7 +537,7 @@ static int gif_read_header(AVFormatContext * s1,
s->image_linesize = s->screen_width * 3; s->image_linesize = s->screen_width * 3;
s->image_buf = av_malloc(s->screen_height * s->image_linesize); s->image_buf = av_malloc(s->screen_height * s->image_linesize);
if (!s->image_buf) if (!s->image_buf)
return -ENOMEM; return AVERROR(ENOMEM);
s->pix_fmt = PIX_FMT_RGB24; s->pix_fmt = PIX_FMT_RGB24;
/* now we are ready: build format streams */ /* now we are ready: build format streams */
st = av_new_stream(s1, 0); st = av_new_stream(s1, 0);

@ -92,7 +92,7 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
st = av_new_stream(s1, 0); st = av_new_stream(s1, 0);
if (!st) if (!st)
return -ENOMEM; return AVERROR(ENOMEM);
av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */ av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
s->width = width; s->width = width;

@ -225,7 +225,7 @@ static int grab_read_packet(AVFormatContext *s1, AVPacket *pkt)
VideoData *s = s1->priv_data; VideoData *s = s1->priv_data;
if (av_new_packet(pkt, video_buf_size) < 0) if (av_new_packet(pkt, video_buf_size) < 0)
return -EIO; return AVERROR(EIO);
bktr_getframe(s->per_frame); bktr_getframe(s->per_frame);
@ -259,7 +259,7 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
st = av_new_stream(s1, 0); st = av_new_stream(s1, 0);
if (!st) if (!st)
return -ENOMEM; return AVERROR(ENOMEM);
av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in use */ av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in use */
s->width = width; s->width = width;
@ -287,7 +287,7 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
if (bktr_init(video_device, width, height, format, if (bktr_init(video_device, width, height, format,
&(s->video_fd), &(s->tuner_fd), -1, 0.0) < 0) &(s->video_fd), &(s->tuner_fd), -1, 0.0) < 0)
return -EIO; return AVERROR(EIO);
nsignals = 0; nsignals = 0;
last_frame_time = 0; last_frame_time = 0;

@ -120,7 +120,7 @@ static int http_open(URLContext *h, const char *uri, int flags)
s = av_malloc(sizeof(HTTPContext)); s = av_malloc(sizeof(HTTPContext));
if (!s) { if (!s) {
return -ENOMEM; return AVERROR(ENOMEM);
} }
h->priv_data = s; h->priv_data = s;
s->filesize = -1; s->filesize = -1;

@ -177,7 +177,7 @@ static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap)
st = av_new_stream(s1, 0); st = av_new_stream(s1, 0);
if (!st) { if (!st) {
return -ENOMEM; return AVERROR(ENOMEM);
} }
pstrcpy(s->path, sizeof(s->path), s1->filename); pstrcpy(s->path, sizeof(s->path), s1->filename);

@ -513,7 +513,7 @@ static int mpeg_mux_init(AVFormatContext *ctx)
for(i=0;i<ctx->nb_streams;i++) { for(i=0;i<ctx->nb_streams;i++) {
av_free(ctx->streams[i]->priv_data); av_free(ctx->streams[i]->priv_data);
} }
return -ENOMEM; return AVERROR(ENOMEM);
} }
static inline void put_timestamp(ByteIOContext *pb, int id, int64_t timestamp) static inline void put_timestamp(ByteIOContext *pb, int id, int64_t timestamp)

@ -1357,7 +1357,7 @@ static int mpegts_raw_read_packet(AVFormatContext *s,
uint8_t pcr_buf[12]; uint8_t pcr_buf[12];
if (av_new_packet(pkt, TS_PACKET_SIZE) < 0) if (av_new_packet(pkt, TS_PACKET_SIZE) < 0)
return -ENOMEM; return AVERROR(ENOMEM);
pkt->pos= url_ftell(&s->pb); pkt->pos= url_ftell(&s->pb);
ret = read_packet(&s->pb, pkt->data, ts->raw_packet_size); ret = read_packet(&s->pb, pkt->data, ts->raw_packet_size);
if (ret < 0) { if (ret < 0) {

@ -113,7 +113,7 @@ static int rtp_open(URLContext *h, const char *uri, int flags)
s = av_mallocz(sizeof(RTPContext)); s = av_mallocz(sizeof(RTPContext));
if (!s) if (!s)
return -ENOMEM; return AVERROR(ENOMEM);
h->priv_data = s; h->priv_data = s;
url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &port, url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &port,

@ -226,7 +226,7 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt)
int pos; int pos;
if (url_feof(&s->pb) || smk->cur_frame >= smk->frames) if (url_feof(&s->pb) || smk->cur_frame >= smk->frames)
return -EIO; return AVERROR(EIO);
/* if we demuxed all streams, pass another frame */ /* if we demuxed all streams, pass another frame */
if(smk->curstream < 0) { if(smk->curstream < 0) {

@ -133,7 +133,7 @@ static int sol_read_packet(AVFormatContext *s,
int ret; int ret;
if (url_feof(&s->pb)) if (url_feof(&s->pb))
return -EIO; return AVERROR(EIO);
ret= av_get_packet(&s->pb, pkt, MAX_SIZE); ret= av_get_packet(&s->pb, pkt, MAX_SIZE);
pkt->stream_index = 0; pkt->stream_index = 0;

@ -62,7 +62,7 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
s = av_malloc(sizeof(TCPContext)); s = av_malloc(sizeof(TCPContext));
if (!s) if (!s)
return -ENOMEM; return AVERROR(ENOMEM);
h->priv_data = s; h->priv_data = s;
if (port <= 0 || port >= 65536) if (port <= 0 || port >= 65536)
@ -90,7 +90,7 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
/* wait until we are connected or until abort */ /* wait until we are connected or until abort */
for(;;) { for(;;) {
if (url_interrupt_cb()) { if (url_interrupt_cb()) {
ret = -EINTR; ret = AVERROR(EINTR);
goto fail1; goto fail1;
} }
fd_max = fd; fd_max = fd;
@ -130,7 +130,7 @@ static int tcp_read(URLContext *h, uint8_t *buf, int size)
for (;;) { for (;;) {
if (url_interrupt_cb()) if (url_interrupt_cb())
return -EINTR; return AVERROR(EINTR);
fd_max = s->fd; fd_max = s->fd;
FD_ZERO(&rfds); FD_ZERO(&rfds);
FD_SET(s->fd, &rfds); FD_SET(s->fd, &rfds);
@ -141,11 +141,7 @@ static int tcp_read(URLContext *h, uint8_t *buf, int size)
len = recv(s->fd, buf, size, 0); len = recv(s->fd, buf, size, 0);
if (len < 0) { if (len < 0) {
if (errno != EINTR && errno != EAGAIN) if (errno != EINTR && errno != EAGAIN)
#ifdef __BEOS__ return AVERROR(errno);
return errno;
#else
return -errno;
#endif
} else return len; } else return len;
} else if (ret < 0) { } else if (ret < 0) {
return -1; return -1;
@ -163,7 +159,7 @@ static int tcp_write(URLContext *h, uint8_t *buf, int size)
size1 = size; size1 = size;
while (size > 0) { while (size > 0) {
if (url_interrupt_cb()) if (url_interrupt_cb())
return -EINTR; return AVERROR(EINTR);
fd_max = s->fd; fd_max = s->fd;
FD_ZERO(&wfds); FD_ZERO(&wfds);
FD_SET(s->fd, &wfds); FD_SET(s->fd, &wfds);
@ -173,13 +169,8 @@ static int tcp_write(URLContext *h, uint8_t *buf, int size)
if (ret > 0 && FD_ISSET(s->fd, &wfds)) { if (ret > 0 && FD_ISSET(s->fd, &wfds)) {
len = send(s->fd, buf, size, 0); len = send(s->fd, buf, size, 0);
if (len < 0) { if (len < 0) {
if (errno != EINTR && errno != EAGAIN) { if (errno != EINTR && errno != EAGAIN)
#ifdef __BEOS__ return AVERROR(errno);
return errno;
#else
return -errno;
#endif
}
continue; continue;
} }
size -= len; size -= len;

@ -295,7 +295,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
s = av_malloc(sizeof(UDPContext)); s = av_malloc(sizeof(UDPContext));
if (!s) if (!s)
return -ENOMEM; return AVERROR(ENOMEM);
h->priv_data = s; h->priv_data = s;
s->ttl = 16; s->ttl = 16;

@ -478,7 +478,7 @@ int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
/* read probe data */ /* read probe data */
pd->buf= av_realloc(pd->buf, probe_size); pd->buf= av_realloc(pd->buf, probe_size);
pd->buf_size = get_buffer(pb, pd->buf, probe_size); pd->buf_size = get_buffer(pb, pd->buf, probe_size);
if (url_fseek(pb, 0, SEEK_SET) == (offset_t)-EPIPE) { if (url_fseek(pb, 0, SEEK_SET) == (offset_t)AVERROR(EPIPE)) {
url_fclose(pb); url_fclose(pb);
if (url_fopen(pb, filename, URL_RDONLY) < 0) { if (url_fopen(pb, filename, URL_RDONLY) < 0) {
file_opened = 0; file_opened = 0;
@ -805,7 +805,7 @@ static int av_read_frame_internal(AVFormatContext *s, AVPacket *pkt)
/* read next packet */ /* read next packet */
ret = av_read_packet(s, &s->cur_pkt); ret = av_read_packet(s, &s->cur_pkt);
if (ret < 0) { if (ret < 0) {
if (ret == -EAGAIN) if (ret == AVERROR(EAGAIN))
return ret; return ret;
/* return the last frames, if any */ /* return the last frames, if any */
for(i = 0; i < s->nb_streams; i++) { for(i = 0; i < s->nb_streams; i++) {
@ -916,7 +916,7 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt)
AVPacketList **plast_pktl= &s->packet_buffer; AVPacketList **plast_pktl= &s->packet_buffer;
int ret= av_read_frame_internal(s, pkt); int ret= av_read_frame_internal(s, pkt);
if(ret<0){ if(ret<0){
if(pktl && ret != -EAGAIN){ if(pktl && ret != AVERROR(EAGAIN)){
eof=1; eof=1;
continue; continue;
}else }else

@ -415,7 +415,7 @@ static int v4l2_read_header(AVFormatContext *s1, AVFormatParameters *ap)
st = av_new_stream(s1, 0); st = av_new_stream(s1, 0);
if (!st) { if (!st) {
return -ENOMEM; return AVERROR(ENOMEM);
} }
av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */ av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */

@ -170,7 +170,7 @@ static int wv_read_packet(AVFormatContext *s,
int ret; int ret;
if (url_feof(&s->pb)) if (url_feof(&s->pb))
return -EIO; return AVERROR(EIO);
if(wc->block_parsed){ if(wc->block_parsed){
if(wv_read_block_header(s, &s->pb) < 0) if(wv_read_block_header(s, &s->pb) < 0)
return -1; return -1;

@ -130,7 +130,7 @@ x11grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
st = av_new_stream(s1, 0); st = av_new_stream(s1, 0);
if (!st) { if (!st) {
return -ENOMEM; return AVERROR(ENOMEM);
} }
av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */ av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
@ -151,7 +151,7 @@ x11grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
IPC_CREAT|0777); IPC_CREAT|0777);
if (x11grab->shminfo.shmid == -1) { if (x11grab->shminfo.shmid == -1) {
av_log(s1, AV_LOG_ERROR, "Fatal: Can't get shared memory!\n"); av_log(s1, AV_LOG_ERROR, "Fatal: Can't get shared memory!\n");
return -ENOMEM; return AVERROR(ENOMEM);
} }
x11grab->shminfo.shmaddr = image->data = shmat(x11grab->shminfo.shmid, 0, 0); x11grab->shminfo.shmaddr = image->data = shmat(x11grab->shminfo.shmid, 0, 0);
x11grab->shminfo.readOnly = False; x11grab->shminfo.readOnly = False;

@ -37,11 +37,7 @@
# include <string.h> # include <string.h>
# include <ctype.h> # include <ctype.h>
# include <limits.h> # include <limits.h>
# ifndef __BEOS__ # include <errno.h>
# include <errno.h>
# else
# include "berrno.h"
# endif
# include <math.h> # include <math.h>
#endif /* HAVE_AV_CONFIG_H */ #endif /* HAVE_AV_CONFIG_H */

Loading…
Cancel
Save