[FFmpeg-devel] ByteIOContext probe + img2 patch

Michael Niedermayer michaelni at gmx.at
Sun Sep 4 21:24:13 CEST 2011


Hi Justin

Please resubmit this patch as an attachment, something messed it up
its full of 0xa0

On Sat, Sep 03, 2011 at 09:52:48PM -0700, Justin Foutts wrote:
> All of these changes were necessary for me to avformat_open_input() .png's with custom ByteIOContext.  WARNING: I have swapped the img2 is_pipe logic but only verified the is_pipe case!
> diff --git a/libavformat/img2.c b/libavformat/img2.cindex 77145cb..f3fea4a 100644--- a/libavformat/img2.c+++ b/libavformat/img2.c@@ -248,7 +248,7 @@ static int read_header(AVFormatContext *s1, AVFormatParameters *ap)     s->img_count = 0;      /* find format */-    if (s1->iformat->flags & AVFMT_NOFILE)+    if (s1->iformat->flags & AVFMT_NOFILE == 0)         s->is_pipe = 0;     else{         s->is_pipe = 1;@@ -330,7 +330,7 @@ static int read_packet(AVFormatContext *s1, AVPacket *pkt)         f[0] = s1->pb;         if (url_feof(f[0]))             return AVERROR(EIO);-        size[0]= 4096;+        size[0]= avio_size(f[0]);     }      av_new_packet(pkt, size[0] + size[1] + size[2]);@@ -371,7 +371,7 @@ static int write_header(AVFormatContext *s)     av_strlcpy(img->path, s->filename, sizeof(img->path));      /* find format */-    if (s->oformat->flags & AVFMT_NOFILE)+    if
>  (s->oformat->flags & AVFMT_NOFILE == 0)         img->is_pipe = 0;     else         img->is_pipe = 1;diff --git a/libavformat/utils.c b/libavformat/utils.cindex 1017d52..a035a7e 100644--- a/libavformat/utils.c+++ b/libavformat/utils.c@@ -601,8 +601,14 @@ static int init_input(AVFormatContext *s, const char *filename)     int ret;     AVProbeData pd = {filename, NULL, 0}; -    if (s->pb) {+    if (s->pb)         s->flags |= AVFMT_FLAG_CUSTOM_IO;++    if ( (s->iformat && s->iformat->flags & AVFMT_NOFILE) ||+        (!s->iformat && (s->iformat = av_probe_input_format(&pd, 0))))+        return 0;++    if (s->pb) {         if (!s->iformat)             return av_probe_input_buffer(s->pb, &s->iformat, filename, s, 0, 0);         else if (s->iformat->flags & AVFMT_NOFILE)@@ -611,10 +617,6 @@ static int init_input(AVFormatContext *s, const char *filename)         return 0;     } -    if (
>  (s->iformat && s->iformat->flags & AVFMT_NOFILE) ||-        (!s->iformat && (s->iformat = av_probe_input_format(&pd, 0))))-        return 0;-     if ((ret = avio_open(&s->pb, filename, AVIO_FLAG_READ)) < 0)         return ret;     if (s->iformat) 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110904/d375fe4a/attachment.asc>


More information about the ffmpeg-devel mailing list