[FFmpeg-devel] & vs. &&

Benoit Fouet benoit.fouet
Mon Oct 19 16:28:15 CEST 2009


On Mon, 19 Oct 2009 15:44:19 +0200 Michael Niedermayer wrote:

> On Mon, Oct 19, 2009 at 10:47:52AM +0200, Benoit Fouet wrote:
> > On 2009-10-16 14:13, Michael Niedermayer wrote:
> > > On Tue, Oct 13, 2009 at 02:42:57PM +0200, Benoit Fouet wrote:
> > >> On 2009-10-13 14:04, Reimar D?ffinger wrote:
> > >>> On Tue, Oct 13, 2009 at 01:54:42PM +0200, Benoit Fouet wrote:
> > >>>> So my guess is that url_open_dyn_buf_internal is buggy.
> > >>>> I don't know what to do, but hope that helps knowledgeable people :)
> > >>> My suggestion is to "fix" url_resetbuf to make it do what it already
> > >>> does now, ignoring what it may be supposed to do.
> > >>> The h->flags stuff IMO is only to check against programming errors but
> > >>> obviously adds more errors that it avoids.
> > >>> So I suggest to change the whole thing to
> > >>> assert(flags == URL_WRONLY || flags == URL_RDONLY)
> > >> sample patch to do that, now 'make test' passes:
> > >>
> > >> Index: libavformat/aviobuf.c
> > >> ===================================================================
> > >> --- libavformat/aviobuf.c       (revision 20220)
> > >> +++ libavformat/aviobuf.c       (working copy)
> > >> @@ -585,9 +585,7 @@ int url_setbufsize(ByteIOContext *s, int
> > >>
> > >>  int url_resetbuf(ByteIOContext *s, int flags)
> > >>  {
> > >> -    URLContext *h = s->opaque;
> > >> -    if ((flags & URL_RDWR) || (h && h->flags != flags && !h->flags &
> > >> URL_RDWR))
> > >> -        return AVERROR(EINVAL);
> > >> +    assert(flags == URL_WRONLY || flags == URL_RDONLY);
> > > 
> > > if url_resetbuf where static i wouldnt mind the assert ... btw why is it
> > > not static ?
> > > 
> > 
> > dunno... what do we do ? make it static, and change the API ?
> 
> add static under #if version > X
> 

something like that ?

Index: libavformat/avio.h
===================================================================
--- libavformat/avio.h  (revision 20310)
+++ libavformat/avio.h  (working copy)
@@ -333,11 +333,13 @@ int url_fdopen(ByteIOContext **s, URLCon

 /** @warning must be called before any I/O */
 int url_setbufsize(ByteIOContext *s, int buf_size);
+#if LIBAVFORMAT_VERSION_MAJOR < 53
 /** Reset the buffer for reading or writing.
  * @note Will drop any data currently in the buffer without transmitting it.
  * @param flags URL_RDONLY to set up the buffer for reading, or URL_WRONLY
  *        to set up the buffer for writing. */
 int url_resetbuf(ByteIOContext *s, int flags);
+#endif

 /** @note when opened as read/write, the buffers are only used for
     writing */
Index: libavformat/aviobuf.c
===================================================================
--- libavformat/aviobuf.c       (revision 20310)
+++ libavformat/aviobuf.c       (working copy)
@@ -583,11 +583,19 @@ int url_setbufsize(ByteIOContext *s, int
     return 0;
 }

+#if LIBAVFORMAT_VERSION_MAJOR < 53
 int url_resetbuf(ByteIOContext *s, int flags)
+#else
+static int url_resetbuf(ByteIOContext *s, int flags)
+#endif
 {
+#if LIBAVFORMAT_VERSION_MAJOR < 53
     URLContext *h = s->opaque;
     if ((flags & URL_RDWR) || (h && h->flags != flags && !h->flags & URL_RDWR))
         return AVERROR(EINVAL);
+#else
+    assert(flags == URL_WRONLY || flags == URL_RDONLY);
+#endif

     if (flags & URL_WRONLY) {
         s->buf_end = s->buffer + s->buffer_size;



More information about the ffmpeg-devel mailing list