[FFmpeg-devel] [libav-devel] [PATCH] Change behviour of empty AVFilterFormats lists
Stefano Sabatini
stefano.sabatini-lala at poste.it
Wed Jun 8 18:52:37 CEST 2011
On date Wednesday 2011-06-08 01:55:53 +0200, Stefano Sabatini encoded:
> On date Tuesday 2011-06-07 17:51:27 +0300, Mina Nagy Zaki encoded:
> > This makes an empty list mean 'all formats supported'. This will simplify some
> > things for the format negotiation later on. Before the patch, returning an
> > empty list in query_formats() would simply mean no format supported, which is
> > non-sensical. This way a lot of unnecessary merging of 'all formats' lists is
> > avoided.
> >
> >
> > --
> > Mina
>
> > From 46347d6ded4272430a386696065af5a6f9993abb Mon Sep 17 00:00:00 2001
> > From: Mina Nagy Zaki <mnzaki at gmail.com>
> > Date: Tue, 7 Jun 2011 17:42:32 +0300
> > Subject: [PATCH 1/2] lavfi: Make avfilter_make_format_list handle NULL lists.
> >
> > ---
> > libavfilter/avfilter.h | 3 ++-
> > libavfilter/formats.c | 13 ++++++++-----
> > 2 files changed, 10 insertions(+), 6 deletions(-)
> >
> > diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
> > index 9b1ea2d..0375a38 100644
> > --- a/libavfilter/avfilter.h
> > +++ b/libavfilter/avfilter.h
> > @@ -233,7 +233,8 @@ typedef struct AVFilterFormats {
> > * Create a list of supported formats. This is intended for use in
> > * AVFilter->query_formats().
> > *
> > - * @param fmts list of media formats, terminated by -1
> > + * @param fmts list of media formats, terminated by -1. If NULL an
> > + * empty list is created.
> > * @return the format list, with no existing references
> > */
> > AVFilterFormats *avfilter_make_format_list(const int *fmts);
> > diff --git a/libavfilter/formats.c b/libavfilter/formats.c
> > index 101ef09..ec7fca3 100644
> > --- a/libavfilter/formats.c
> > +++ b/libavfilter/formats.c
> > @@ -73,15 +73,18 @@ AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b)
> > AVFilterFormats *avfilter_make_format_list(const int *fmts)
> > {
> > AVFilterFormats *formats;
> > - int count;
> > + int count = 0;
> >
> > - for (count = 0; fmts[count] != -1; count++)
> > - ;
> > + if (fmts)
> > + for (count = 0; fmts[count] != -1; count++)
> > + ;
> >
> > formats = av_mallocz(sizeof(AVFilterFormats));
> > - formats->formats = av_malloc(sizeof(*formats->formats) * count);
> > formats->format_count = count;
> > - memcpy(formats->formats, fmts, sizeof(*formats->formats) * count);
> > + if (count) {
> > + formats->formats = av_malloc(sizeof(*formats->formats) * count);
> > + memcpy(formats->formats, fmts, sizeof(*formats->formats) * count);
> > + }
> >
> > return formats;
> > }
> > --
> > 1.7.4.4
>
> Makes sense, I'll apply it tomorrow if I see no objections.
Pushed.
--
FFmpeg = Fostering and Frenzy Mind-dumbing Pitiless Elegant Glue
More information about the ffmpeg-devel
mailing list