Make the function use more convenient. Originally committed as revision 21035 to svn://svn.ffmpeg.org/ffmpeg/trunk
Unified · Split
| @@ -25,7 +25,7 @@ · 24 unmodified lines | ||
| 25 | 25 | #include "libavutil/avutil.h" |
| 26 | 26 | |
| 27 | 27 | #define LIBAVFILTER_VERSION_MAJOR 1 |
| 28 | −#define LIBAVFILTER_VERSION_MINOR 13 | |
| 28 | +#define LIBAVFILTER_VERSION_MINOR 14 | |
| 29 | 29 | #define LIBAVFILTER_VERSION_MICRO 0 |
| 30 | 30 | |
| 31 | 31 | #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ |
| @@ -192,12 +192,14 @@ struct AVFilterFormats · 160 unmodified lines | ||
| 192 | 192 | AVFilterFormats *avfilter_make_format_list(const enum PixelFormat *pix_fmts); |
| 193 | 193 | |
| 194 | 194 | /** |
| 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. | |
| 196 | 198 | * |
| 197 | 199 | * @return a non negative value in case of success, or a negative |
| 198 | 200 | * value corresponding to an AVERROR code in case of error |
| 199 | 201 | */ |
| 200 | −int avfilter_add_colorspace(AVFilterFormats *avff, enum PixelFormat pix_fmt); | |
| 202 | +int avfilter_add_colorspace(AVFilterFormats **avff, enum PixelFormat pix_fmt); | |
| 201 | 203 | |
| 202 | 204 | /** |
| 203 | 205 | * Returns a list of all colorspaces supported by FFmpeg. |
| @@ -86,28 +86,31 @@ AVFilterFormats *avfilter_make_format_list(const enum PixelFormat *pix_fmts) · 85 unmodified lines | ||
| 86 | 86 | return formats; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | −int avfilter_add_colorspace(AVFilterFormats *avff, enum PixelFormat pix_fmt) | |
| 89 | +int avfilter_add_colorspace(AVFilterFormats **avff, enum PixelFormat pix_fmt) | |
| 90 | 90 | { |
| 91 | − enum PixelFormat *pix_fmts = | |
| 92 | − av_realloc(avff->formats, sizeof(avff->formats) * (avff->format_count+1)); | |
| 91 | + enum PixelFormat *pix_fmts; | |
| 93 | 92 | |
| 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)); | |
| 94 | 98 | if (!pix_fmts) |
| 95 | 99 | return AVERROR(ENOMEM); |
| 96 | 100 | |
| 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; | |
| 99 | 103 | return 0; |
| 100 | 104 | } |
| 101 | 105 | |
| 102 | 106 | AVFilterFormats *avfilter_all_colorspaces(void) |
| 103 | 107 | { |
| 104 | − AVFilterFormats *ret; | |
| 108 | + AVFilterFormats *ret = NULL; | |
| 105 | 109 | enum PixelFormat pix_fmt; |
| 106 | 110 | |
| 107 | − ret = av_mallocz(sizeof(AVFilterFormats)); | |
| 108 | 111 | for (pix_fmt = 0; pix_fmt < PIX_FMT_NB; pix_fmt++) |
| 109 | 112 | 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); | |
| 111 | 114 | |
| 112 | 115 | return ret; |
| 113 | 116 | } |