[FFmpeg-devel] [PATCH] avformat/img2dec: add non pipe AVInputFormats

wm4 nfxjfg at googlemail.com
Sat Jul 5 14:53:23 CEST 2014


On Sat, 5 Jul 2014 14:18:23 +0200
Michael Niedermayer <michaelni at gmx.at> wrote:

> On Sat, Jul 05, 2014 at 01:16:40PM +0200, wm4 wrote:
> > On Fri,  4 Jul 2014 17:01:49 +0200
> > Michael Niedermayer <michaelni at gmx.at> wrote:
> > 
> > > These currently do not get autoselected, as they have no probe functions nor
> > > list file extensions
> > 
> > Why not? Does enabling probing break something?
> 
> no, but someone has to write probe functions that either work without
> having access to the files content or somehow "evaluate" the
> wildcards in the filename to be able to open a file at probing stage
> somewhere
> 
> 
> > 
> > > Suggested-by: wm4
> > > Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> > > ---
> > >  libavformat/allformats.c |    9 +++++++++
> > >  libavformat/img2dec.c    |   21 +++++++++++++++++++--
> > >  2 files changed, 28 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/libavformat/allformats.c b/libavformat/allformats.c
> > > index c07fbd1..6348f28 100644
> > > --- a/libavformat/allformats.c
> > > +++ b/libavformat/allformats.c
> > > @@ -319,6 +319,15 @@ void av_register_all(void)
> > >      REGISTER_MUXDEMUX(YUV4MPEGPIPE,     yuv4mpegpipe);
> > >  
> > >      /* image demuxers */
> > > +    REGISTER_DEMUXER (IMAGE_BMP,             image_bmp);
> > > +    REGISTER_DEMUXER (IMAGE_DPX,             image_dpx);
> > > +    REGISTER_DEMUXER (IMAGE_EXR,             image_exr);
> > > +    REGISTER_DEMUXER (IMAGE_J2K,             image_j2k);
> > > +    REGISTER_DEMUXER (IMAGE_PICTOR,          image_pictor);
> > > +    REGISTER_DEMUXER (IMAGE_PNG,             image_png);
> > > +    REGISTER_DEMUXER (IMAGE_SGI,             image_sgi);
> > > +    REGISTER_DEMUXER (IMAGE_SUNRAST,         image_sunrast);
> > > +    REGISTER_DEMUXER (IMAGE_TIFF,            image_tiff);
> > >      REGISTER_DEMUXER (IMAGE_BMP_PIPE,        image_bmp_pipe);
> > >      REGISTER_DEMUXER (IMAGE_DPX_PIPE,        image_dpx_pipe);
> > >      REGISTER_DEMUXER (IMAGE_EXR_PIPE,        image_exr_pipe);
> > > diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
> > > index cda4996..52bc201 100644
> > > --- a/libavformat/img2dec.c
> > > +++ b/libavformat/img2dec.c
> > > @@ -658,8 +658,8 @@ static int tiff_probe(AVProbeData *p)
> > >  }
> > >  
> > >  #define IMAGEAUTO_DEMUXER(imgname, codecid)\
> > > -static const AVClass imgname ## _class = {\
> > > -    .class_name = AV_STRINGIFY(imgname) " demuxer",\
> > > +static const AVClass imgname ## _pipe_class = {\
> > > +    .class_name = AV_STRINGIFY(imgname) "pipe demuxer",\
> > >      .item_name  = av_default_item_name,\
> > >      .option     = options,\
> > >      .version    = LIBAVUTIL_VERSION_INT,\
> > > @@ -670,6 +670,23 @@ AVInputFormat ff_image_ ## imgname ## _pipe_demuxer = {\
> > >      .read_probe     = imgname ## _probe,\
> > >      .read_header    = ff_img_read_header,\
> > >      .read_packet    = ff_img_read_packet,\
> > > +    .priv_class     = & imgname ## _pipe_class,\
> > > +    .raw_codec_id   = codecid,\
> > > +};\
> > > +static const AVClass imgname ## _class = {\
> > > +    .class_name = AV_STRINGIFY(imgname) " demuxer",\
> > > +    .item_name  = av_default_item_name,\
> > > +    .option     = options,\
> > > +    .version    = LIBAVUTIL_VERSION_INT,\
> > > +};\
> > > +AVInputFormat ff_image_ ## imgname ## _demuxer = {\
> > > +    .name           = AV_STRINGIFY(imgname),\
> > > +    .priv_data_size = sizeof(VideoDemuxData),\
> > > +    .read_header    = ff_img_read_header,\
> > > +    .read_packet    = ff_img_read_packet,\
> > > +    .read_close     = img_read_close,\
> > > +    .read_seek      = img_read_seek,\
> > > +    .flags          = AVFMT_NOFILE,\
> > 
> > I'd say eventually, there should be a demuxer for each image format,
> 
> > and these demuxer should work like all others.
> 
> well, they work with "%d" and such and multiple files, so they arent
> like other demuxers
> 
> 
> > 
> > Why NOFILE? Maybe I'm misunderstanding the purpose of this function,
> > and it's still somehow for matching multiple files with a filename
> > pattern?
> 
> yes, the filename thats passed to them cannot be opened as a URL
> as it contains stuff like "%05d" which need to be filled in first

Oh right. I guess the *_pipe demuxers already take care of opening
image files like any "normal" demuxer, and the demuxers added with this
patch are merely for forcing a specific format with the demuxer that
opens patterns of files.

Adding probing to this probably doesn't make much sense then.


More information about the ffmpeg-devel mailing list