summaryrefslogtreecommitdiff
path: root/libavfilter/formats.c
diff options
context:
space:
mode:
authorStefano Sabatini <stefano.sabatini-lala@poste.it>2010-01-06 16:19:13 +0000
committerStefano Sabatini <stefano.sabatini-lala@poste.it>2010-01-06 16:19:13 +0000
commitc1d662fd88db783d505c45fca4c35c625cd10f20 (patch)
tree220c4c30e6ecd7d786c5f32f531d981ab55434f8 /libavfilter/formats.c
parent7659712749500d2307c24abb188766f8a96d87be (diff)
Change avfilter_add_colorspace() to make it accept **avff rather than
*avff, so that an AVFilterFormats struct is created and returned by the function if *avff is NULL. Make the function use more convenient. Originally committed as revision 21035 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavfilter/formats.c')
-rw-r--r--libavfilter/formats.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index a289a1233d..e558195a1d 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -86,28 +86,31 @@ AVFilterFormats *avfilter_make_format_list(const enum PixelFormat *pix_fmts)
return formats;
}
-int avfilter_add_colorspace(AVFilterFormats *avff, enum PixelFormat pix_fmt)
+int avfilter_add_colorspace(AVFilterFormats **avff, enum PixelFormat pix_fmt)
{
- enum PixelFormat *pix_fmts =
- av_realloc(avff->formats, sizeof(avff->formats) * (avff->format_count+1));
+ enum PixelFormat *pix_fmts;
+ if (!(*avff) && !(*avff = av_mallocz(sizeof(AVFilterFormats))))
+ return AVERROR(ENOMEM);
+
+ pix_fmts = av_realloc((*avff)->formats,
+ sizeof((*avff)->formats) * ((*avff)->format_count+1));
if (!pix_fmts)
return AVERROR(ENOMEM);
- avff->formats = pix_fmts;
- avff->formats[avff->format_count++] = pix_fmt;
+ (*avff)->formats = pix_fmts;
+ (*avff)->formats[(*avff)->format_count++] = pix_fmt;
return 0;
}
AVFilterFormats *avfilter_all_colorspaces(void)
{
- AVFilterFormats *ret;
+ AVFilterFormats *ret = NULL;
enum PixelFormat pix_fmt;
- ret = av_mallocz(sizeof(AVFilterFormats));
for (pix_fmt = 0; pix_fmt < PIX_FMT_NB; pix_fmt++)
if (!(av_pix_fmt_descriptors[pix_fmt].flags & PIX_FMT_HWACCEL))
- avfilter_add_colorspace(ret, pix_fmt);
+ avfilter_add_colorspace(&ret, pix_fmt);
return ret;
}