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

Michael Niedermayer michaelni
Thu Oct 1 21:22:06 CEST 2009


On Thu, Oct 01, 2009 at 07:50:39PM +0200, Reimar D?ffinger wrote:
> 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 together with a similar change to get_partial_buffer allows for the
> attached patch to be applied, which makes the raw demuxers pass on the error
> values from get_buffer, as a side-effect also returning AVERROR_EOF on EOF
> instead the not-really-correct-but-frequently-used AVERROR(EIO).
> This will change the seek regressions, getting rid of the -5/
> AVERROR(EIO) and, as a side effect, probably fixing FATE/make test on DOS.

>  raw.c |   17 ++++++++---------
>  1 file changed, 8 insertions(+), 9 deletions(-)
> 892ad0c9e68909b374858d3b18132c61f1d9688c  rawcleanup.diff

ok

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

Into a blind darkness they enter who follow after the Ignorance,
they as if into a greater darkness enter who devote themselves
to the Knowledge alone. -- Isha Upanishad
-------------- 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/71bb6c50/attachment.pgp>



More information about the ffmpeg-devel mailing list