[FFmpeg-devel] [PATCH] make av_get_packet return AVERROR_EOF if appropriate

Michael Niedermayer michaelni
Thu Oct 1 21:20:54 CEST 2009


On Thu, Oct 01, 2009 at 07:15:06PM +0200, Reimar D?ffinger wrote:
> On Thu, Oct 01, 2009 at 06:44:04PM +0200, Reimar D?ffinger wrote:
> > On Thu, Oct 01, 2009 at 06:25:13PM +0200, Reimar D?ffinger wrote:
> > > Hello,
> > > I think av_get_packet should return an error (AVERROR_EOF) when it read nothing
> > > at all due to reaching EOF.
> > > I think this will also simplify my attempts to clean up the raw read
> > > functions to be more consistent/whatever.
> > 
> > This is the actual change:
> > Index: libavformat/utils.c
> > ===================================================================
> > --- libavformat/utils.c (revision 20105)
> > +++ libavformat/utils.c (working copy)
> > @@ -269,6 +269,8 @@
> >      pkt->pos= url_ftell(s);
> >  
> >      ret= get_buffer(s, pkt->data, size);
> > +    if (!ret && url_feof(s))
> > +        ret = AVERROR_EOF;
> >      if(ret<=0)
> >          av_free_packet(pkt);
> >      else
> >  
> > This seems to also change seek tests, I still have to find out if the
> > changes are as intended.
> > Another question is if maybe get_buffer should be changed to behave like
> > this...
> 
> I propose this change to get_buffer:
> Index: libavformat/aviobuf.c
> ===================================================================
> --- libavformat/aviobuf.c       (revision 20105)
> +++ libavformat/aviobuf.c       (working copy)
> @@ -415,6 +415,8 @@
>              size -= len;
>          }
>      }
> +    if (size1 == size && url_feof(s))
> +        return AVERROR_EOF;
>      return size1 - size;
>  }
>  

this would return EOF even if EIO happened
url_ferror() should maybe be considered or eof not set in case of other
errors

[..]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Observe your enemies, for they first find out your faults. -- Antisthenes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20091001/d57a2009/attachment.pgp>



More information about the ffmpeg-devel mailing list