[FFmpeg-devel] ByteIOContext probe + img2 patch

Justin Foutts jmfoutts at yahoo.com
Mon Sep 5 05:09:21 CEST 2011

Update: Sorry!  The previous patch was wrong.  I have attached a new patch.
I ended up downgrading to a ffmpeg version that still uses av_open_input_stream and av_open_input_file, while applying an equivalent patch to img2.c.  I use av_open_input_file on windows,linux,osx,iphone and av_open_input_stream with a custom ByteIOContext on android.  I'm not sure why I can't get a custom ByteIOContext to work on all platforms.
--- On Sun, 9/4/11, Justin Foutts <jmfoutts at yahoo.com> wrote:

From: Justin Foutts <jmfoutts at yahoo.com>
Subject: Re: [FFmpeg-devel] ByteIOContext probe + img2 patch
To: "FFmpeg development discussions and patches" <ffmpeg-devel at ffmpeg.org>, "Michael Niedermayer" <michaelni at gmx.at>
Date: Sunday, September 4, 2011, 2:34 PM

Hi Michael
Ok, sorry! I've attached the patch to this message.
It's not working on windows, probably due to an unrelated issue.  (No avformat_open_input is working for me on windows, where as on OSX and Linux, .wav was working and the patch fixed .png)
I'm trying to use one version of ffmpeg on windows, linux, osx, iphone, and android.  I use ffmpeg for things like png/jpg loading and wav/mp3 decoding, in addition to FFTs, resampling, image conversion, and lame/x264 flv encoding.
Unfortunately this has proved difficult and for the moment I am downgrading ffmpeg to a version that I previously had working on all platforms but android.

--- On Sun, 9/4/11, Michael Niedermayer <michaelni at gmx.at> wrote:

From: Michael Niedermayer <michaelni at gmx.at>
Subject: Re: [FFmpeg-devel] ByteIOContext probe + img2 patch
To: "FFmpeg development discussions and patches" <ffmpeg-devel at ffmpeg.org>, "Justin Foutts" <jmfoutts at yahoo.com>
Date: Sunday, September 4, 2011, 12:24 PM

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: diff
Type: application/octet-stream
Size: 2155 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110904/7a0fbb79/attachment.obj>

More information about the ffmpeg-devel mailing list