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
25#include "libavutil/avutil.h"25#include "libavutil/avutil.h"
26 26
27#define LIBAVFILTER_VERSION_MAJOR 127#define LIBAVFILTER_VERSION_MAJOR 1
28#define LIBAVFILTER_VERSION_MINOR 1328#define LIBAVFILTER_VERSION_MINOR 14
29#define LIBAVFILTER_VERSION_MICRO 029#define LIBAVFILTER_VERSION_MICRO 0
30 30
31#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \31#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
@@ -192,12 +192,14 @@ struct AVFilterFormats · 160 unmodified lines
192AVFilterFormats *avfilter_make_format_list(const enum PixelFormat *pix_fmts);192AVFilterFormats *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 * @return a non negative value in case of success, or a negative199 * @return a non negative value in case of success, or a negative
198 * value corresponding to an AVERROR code in case of error200 * value corresponding to an AVERROR code in case of error
199 */201 */
200int avfilter_add_colorspace(AVFilterFormats *avff, enum PixelFormat pix_fmt);202int avfilter_add_colorspace(AVFilterFormats **avff, enum PixelFormat pix_fmt);
201 203
202/**204/**
203 * Returns a list of all colorspaces supported by FFmpeg.205 * 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
86 return formats;86 return formats;
87}87}
88 88
89int avfilter_add_colorspace(AVFilterFormats *avff, enum PixelFormat pix_fmt)89int avfilter_add_colorspace(AVFilterFormats **avff, enum PixelFormat pix_fmt)
90{90{
91 enum PixelFormat *pix_fmts =91 enum PixelFormat *pix_fmts;
92 av_realloc(avff->formats, sizeof(avff->formats) * (avff->format_count+1));
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 if (!pix_fmts)98 if (!pix_fmts)
95 return AVERROR(ENOMEM);99 return AVERROR(ENOMEM);
96 100
97 avff->formats = pix_fmts;101 (*avff)->formats = pix_fmts;
98 avff->formats[avff->format_count++] = pix_fmt;102 (*avff)->formats[(*avff)->format_count++] = pix_fmt;
99 return 0;103 return 0;
100}104}
101 105
102AVFilterFormats *avfilter_all_colorspaces(void)106AVFilterFormats *avfilter_all_colorspaces(void)
103{107{
104 AVFilterFormats *ret;108 AVFilterFormats *ret = NULL;
105 enum PixelFormat pix_fmt;109 enum PixelFormat pix_fmt;
106 110
107 ret = av_mallocz(sizeof(AVFilterFormats));
108 for (pix_fmt = 0; pix_fmt < PIX_FMT_NB; pix_fmt++)111 for (pix_fmt = 0; pix_fmt < PIX_FMT_NB; pix_fmt++)
109 if (!(av_pix_fmt_descriptors[pix_fmt].flags & PIX_FMT_HWACCEL))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 return ret;115 return ret;
113}116}

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