Message ID | 20170508044654.53299-2-atomnuker@gmail.com |
---|---|
State | Accepted |
Commit | f68ea92833474d7f0e493c6009eb533cb9c8bc90 |
Headers | show |
On 8 May 2017 at 05:46, Rostislav Pehlivanov <atomnuker@gmail.com> wrote: > Only checks the extension and MIME type, since determining whether > a file is SVG is difficult since they're just XML files. > > Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com> > --- > libavformat/Makefile | 1 + > libavformat/allformats.c | 1 + > libavformat/img2dec.c | 20 ++++++++++++++++++++ > 3 files changed, 22 insertions(+) > > diff --git a/libavformat/Makefile b/libavformat/Makefile > index 4e169fdce5..bfba0c1cb4 100644 > --- a/libavformat/Makefile > +++ b/libavformat/Makefile > @@ -237,6 +237,7 @@ OBJS-$(CONFIG_IMAGE_PPM_PIPE_DEMUXER) += > img2dec.o img2.o > OBJS-$(CONFIG_IMAGE_PSD_PIPE_DEMUXER) += img2dec.o img2.o > OBJS-$(CONFIG_IMAGE_QDRAW_PIPE_DEMUXER) += img2dec.o img2.o > OBJS-$(CONFIG_IMAGE_SGI_PIPE_DEMUXER) += img2dec.o img2.o > +OBJS-$(CONFIG_IMAGE_SVG_PIPE_DEMUXER) += img2dec.o img2.o > OBJS-$(CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER) += img2dec.o img2.o > OBJS-$(CONFIG_IMAGE_TIFF_PIPE_DEMUXER) += img2dec.o img2.o > OBJS-$(CONFIG_IMAGE_WEBP_PIPE_DEMUXER) += img2dec.o img2.o > diff --git a/libavformat/allformats.c b/libavformat/allformats.c > index 09e62c3cfc..62661d14a4 100644 > --- a/libavformat/allformats.c > +++ b/libavformat/allformats.c > @@ -369,6 +369,7 @@ static void register_all(void) > REGISTER_DEMUXER (IMAGE_PSD_PIPE, image_psd_pipe); > REGISTER_DEMUXER (IMAGE_QDRAW_PIPE, image_qdraw_pipe); > REGISTER_DEMUXER (IMAGE_SGI_PIPE, image_sgi_pipe); > + REGISTER_DEMUXER (IMAGE_SVG_PIPE, image_svg_pipe); > REGISTER_DEMUXER (IMAGE_SUNRAST_PIPE, image_sunrast_pipe); > REGISTER_DEMUXER (IMAGE_TIFF_PIPE, image_tiff_pipe); > REGISTER_DEMUXER (IMAGE_WEBP_PIPE, image_webp_pipe); > diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c > index b454071168..1d532e9343 100644 > --- a/libavformat/img2dec.c > +++ b/libavformat/img2dec.c > @@ -971,6 +971,26 @@ AVInputFormat ff_image_ ## imgname ## _pipe_demuxer = > {\ > .raw_codec_id = codecid,\ > }; > > +static const AVClass svg_class = { > + .class_name = "svg demuxer", > + .item_name = av_default_item_name, > + .option = ff_img_options, > + .version = LIBAVUTIL_VERSION_INT, > +}; > + > +AVInputFormat ff_image_svg_pipe_demuxer = { > + .name = "svg_pipe", > + .long_name = NULL_IF_CONFIG_SMALL("piped svg sequence"), > + .priv_data_size = sizeof(VideoDemuxData), > + .read_header = ff_img_read_header, > + .read_packet = ff_img_read_packet, > + .priv_class = &svg_class, > + .mime_type = "image/svg+xml", > + .extensions = "svg,svgz", > + .flags = AVFMT_GENERIC_INDEX, > + .raw_codec_id = AV_CODEC_ID_SVG, > +}; > + > IMAGEAUTO_DEMUXER(bmp, AV_CODEC_ID_BMP) > IMAGEAUTO_DEMUXER(dds, AV_CODEC_ID_DDS) > IMAGEAUTO_DEMUXER(dpx, AV_CODEC_ID_DPX) > -- > 2.13.0.rc1.294.g07d810a77f > > Pushed
2017-05-08 6:46 GMT+02:00 Rostislav Pehlivanov <atomnuker@gmail.com>: > Only checks the extension and MIME type, since determining whether > a file is SVG is difficult since they're just XML files. Why didn't you just add svg and svgz to the image2 extensions? Carl Eugen
On 16 May 2017 at 11:57, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote: > 2017-05-08 6:46 GMT+02:00 Rostislav Pehlivanov <atomnuker@gmail.com>: > > Only checks the extension and MIME type, since determining whether > > a file is SVG is difficult since they're just XML files. > > Why didn't you just add svg and svgz to the image2 extensions? > > Carl Eugen > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > image2 doesn't use extensions, it probes. Hence why I couldn't use the macro, since it doesn't actually make lavf check the extension and probing svg is difficult (and librsvg doesn't offer support for probing).
2017-05-16 13:25 GMT+02:00 Rostislav Pehlivanov <atomnuker@gmail.com>: > On 16 May 2017 at 11:57, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote: > >> 2017-05-08 6:46 GMT+02:00 Rostislav Pehlivanov <atomnuker@gmail.com>: >> > Only checks the extension and MIME type, since determining whether >> > a file is SVG is difficult since they're just XML files. >> >> Why didn't you just add svg and svgz to the image2 extensions? > image2 doesn't use extensions, it probes. The image2 demuxer only "probes" by looking at extensions. Carl Eugen
On 16 May 2017 at 12:34, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote: > 2017-05-16 13:25 GMT+02:00 Rostislav Pehlivanov <atomnuker@gmail.com>: > > On 16 May 2017 at 11:57, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote: > > > >> 2017-05-08 6:46 GMT+02:00 Rostislav Pehlivanov <atomnuker@gmail.com>: > >> > Only checks the extension and MIME type, since determining whether > >> > a file is SVG is difficult since they're just XML files. > >> > >> Why didn't you just add svg and svgz to the image2 extensions? > > > image2 doesn't use extensions, it probes. > > The image2 demuxer only "probes" by looking at extensions. > > Carl Eugen > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > I see what you mean now, pushed a patch to use the same way of probing as the rest of img2dec.
2017-05-16 13:48 GMT+02:00 Rostislav Pehlivanov <atomnuker@gmail.com>: > On 16 May 2017 at 12:34, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote: > >> 2017-05-16 13:25 GMT+02:00 Rostislav Pehlivanov <atomnuker@gmail.com>: >> > On 16 May 2017 at 11:57, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote: >> > >> >> 2017-05-08 6:46 GMT+02:00 Rostislav Pehlivanov <atomnuker@gmail.com>: >> >> > Only checks the extension and MIME type, since determining whether >> >> > a file is SVG is difficult since they're just XML files. >> >> >> >> Why didn't you just add svg and svgz to the image2 extensions? >> >> > image2 doesn't use extensions, it probes. >> >> The image2 demuxer only "probes" by looking at extensions. > I see what you mean now, pushed a patch to use the same way of > probing as the rest of img2dec. What I meant was: "Why didn't you add svg to the file libavformat/img2.c?" Carl Eugen
diff --git a/libavformat/Makefile b/libavformat/Makefile index 4e169fdce5..bfba0c1cb4 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -237,6 +237,7 @@ OBJS-$(CONFIG_IMAGE_PPM_PIPE_DEMUXER) += img2dec.o img2.o OBJS-$(CONFIG_IMAGE_PSD_PIPE_DEMUXER) += img2dec.o img2.o OBJS-$(CONFIG_IMAGE_QDRAW_PIPE_DEMUXER) += img2dec.o img2.o OBJS-$(CONFIG_IMAGE_SGI_PIPE_DEMUXER) += img2dec.o img2.o +OBJS-$(CONFIG_IMAGE_SVG_PIPE_DEMUXER) += img2dec.o img2.o OBJS-$(CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER) += img2dec.o img2.o OBJS-$(CONFIG_IMAGE_TIFF_PIPE_DEMUXER) += img2dec.o img2.o OBJS-$(CONFIG_IMAGE_WEBP_PIPE_DEMUXER) += img2dec.o img2.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index 09e62c3cfc..62661d14a4 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -369,6 +369,7 @@ static void register_all(void) REGISTER_DEMUXER (IMAGE_PSD_PIPE, image_psd_pipe); REGISTER_DEMUXER (IMAGE_QDRAW_PIPE, image_qdraw_pipe); REGISTER_DEMUXER (IMAGE_SGI_PIPE, image_sgi_pipe); + REGISTER_DEMUXER (IMAGE_SVG_PIPE, image_svg_pipe); REGISTER_DEMUXER (IMAGE_SUNRAST_PIPE, image_sunrast_pipe); REGISTER_DEMUXER (IMAGE_TIFF_PIPE, image_tiff_pipe); REGISTER_DEMUXER (IMAGE_WEBP_PIPE, image_webp_pipe); diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c index b454071168..1d532e9343 100644 --- a/libavformat/img2dec.c +++ b/libavformat/img2dec.c @@ -971,6 +971,26 @@ AVInputFormat ff_image_ ## imgname ## _pipe_demuxer = {\ .raw_codec_id = codecid,\ }; +static const AVClass svg_class = { + .class_name = "svg demuxer", + .item_name = av_default_item_name, + .option = ff_img_options, + .version = LIBAVUTIL_VERSION_INT, +}; + +AVInputFormat ff_image_svg_pipe_demuxer = { + .name = "svg_pipe", + .long_name = NULL_IF_CONFIG_SMALL("piped svg sequence"), + .priv_data_size = sizeof(VideoDemuxData), + .read_header = ff_img_read_header, + .read_packet = ff_img_read_packet, + .priv_class = &svg_class, + .mime_type = "image/svg+xml", + .extensions = "svg,svgz", + .flags = AVFMT_GENERIC_INDEX, + .raw_codec_id = AV_CODEC_ID_SVG, +}; + IMAGEAUTO_DEMUXER(bmp, AV_CODEC_ID_BMP) IMAGEAUTO_DEMUXER(dds, AV_CODEC_ID_DDS) IMAGEAUTO_DEMUXER(dpx, AV_CODEC_ID_DPX)
Only checks the extension and MIME type, since determining whether a file is SVG is difficult since they're just XML files. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com> --- libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/img2dec.c | 20 ++++++++++++++++++++ 3 files changed, 22 insertions(+)