History

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

Stefano Sabatini committed 16 years ago

Commit c1d662f1 parent 76597122 files · +16 −11Browse files

Unified · Split

2 files
  1. libavfilter/avfilter.h +5 −3
  2. libavfilter/formats.c +11 −8
libavfilter/avfilter.h+5−3
@@ -25,7 +25,7 @@ · 24 unmodified lines
2525 #include "libavutil/avutil.h"
2626
2727 #define LIBAVFILTER_VERSION_MAJOR 1
28−#define LIBAVFILTER_VERSION_MINOR 13
28+#define LIBAVFILTER_VERSION_MINOR 14
2929 #define LIBAVFILTER_VERSION_MICRO 0
3030
3131 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
@@ -192,12 +192,14 @@ struct AVFilterFormats · 160 unmodified lines
192192 AVFilterFormats *avfilter_make_format_list(const enum PixelFormat *pix_fmts);
193193
194194 /**
195− * Adds pix_fmt to the list of pixel formats contained in avff.
195+ * Adds pix_fmt to the list of pixel formats contained in *avff.
196+ * If *avff is NULL the function allocates the filter formats struct
197+ * and puts its pointer in *avff.
196198 *
197199 * @return a non negative value in case of success, or a negative
198200 * value corresponding to an AVERROR code in case of error
199201 */
200−int avfilter_add_colorspace(AVFilterFormats *avff, enum PixelFormat pix_fmt);
202+int avfilter_add_colorspace(AVFilterFormats **avff, enum PixelFormat pix_fmt);
201203
202204 /**
203205 * Returns a list of all colorspaces supported by FFmpeg.
libavfilter/formats.c+11−8
@@ -86,28 +86,31 @@ AVFilterFormats *avfilter_make_format_list(const enum PixelFormat *pix_fmts) · 85 unmodified lines
8686 return formats;
8787 }
8888
89−int avfilter_add_colorspace(AVFilterFormats *avff, enum PixelFormat pix_fmt)
89+int avfilter_add_colorspace(AVFilterFormats **avff, enum PixelFormat pix_fmt)
9090 {
91− enum PixelFormat *pix_fmts =
92− av_realloc(avff->formats, sizeof(avff->formats) * (avff->format_count+1));
91+ enum PixelFormat *pix_fmts;
9392
93+ if (!(*avff) && !(*avff = av_mallocz(sizeof(AVFilterFormats))))
94+ return AVERROR(ENOMEM);
95+
96+ pix_fmts = av_realloc((*avff)->formats,
97+ sizeof((*avff)->formats) * ((*avff)->format_count+1));
9498 if (!pix_fmts)
9599 return AVERROR(ENOMEM);
96100
97− avff->formats = pix_fmts;
98− avff->formats[avff->format_count++] = pix_fmt;
101+ (*avff)->formats = pix_fmts;
102+ (*avff)->formats[(*avff)->format_count++] = pix_fmt;
99103 return 0;
100104 }
101105
102106 AVFilterFormats *avfilter_all_colorspaces(void)
103107 {
104− AVFilterFormats *ret;
108+ AVFilterFormats *ret = NULL;
105109 enum PixelFormat pix_fmt;
106110
107− ret = av_mallocz(sizeof(AVFilterFormats));
108111 for (pix_fmt = 0; pix_fmt < PIX_FMT_NB; pix_fmt++)
109112 if (!(av_pix_fmt_descriptors[pix_fmt].flags & PIX_FMT_HWACCEL))
110− avfilter_add_colorspace(ret, pix_fmt);
113+ avfilter_add_colorspace(&ret, pix_fmt);
111114
112115 return ret;
113116 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t