diff options
author | Mina Nagy Zaki <mnzaki@gmail.com> | 2011-06-07 21:17:23 +0300 |
---|---|---|
committer | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2011-06-19 22:58:31 +0200 |
commit | 527ca3985c736ffe077a82fdf3616f0fd571b923 (patch) | |
tree | d9f5c72ce586ad89fbd368e9feceded98f10975f /libavfilter/formats.c | |
parent | 8f349b64813b348634042d96b9d104ada94dc538 (diff) | |
download | ffmpeg-527ca3985c736ffe077a82fdf3616f0fd571b923.tar.gz |
lavfi: use int64_t lists in AVFilteFormats
The list type was changed to int64_t to be able to hold
channel layouts.
avfilter_make_format_list() still takes a int32_t array and converts
it to int64_t. A new function, avfilter_make_format64_list, that
takes int64_t arrays has been added.
Diffstat (limited to 'libavfilter/formats.c')
-rw-r--r-- | libavfilter/formats.c | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/libavfilter/formats.c b/libavfilter/formats.c index 4a23c2f1b3..4e101c570c 100644 --- a/libavfilter/formats.c +++ b/libavfilter/formats.c @@ -72,28 +72,44 @@ AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b) return ret; } +#define MAKE_FORMAT_LIST() \ + AVFilterFormats *formats; \ + int count = 0; \ + if (fmts) \ + for (count = 0; fmts[count] != -1; count++) \ + ; \ + formats = av_mallocz(sizeof(AVFilterFormats)); \ + if (!formats) return NULL; \ + formats->format_count = count; \ + if (count) { \ + formats->formats = av_malloc(sizeof(*formats->formats)*count); \ + if (!formats->formats) { \ + av_free(formats); \ + return NULL; \ + } \ + } + AVFilterFormats *avfilter_make_format_list(const int *fmts) { - AVFilterFormats *formats; - int count = 0; + MAKE_FORMAT_LIST(); + while (count--) + formats->formats[count] = fmts[count]; - if (fmts) - for (count = 0; fmts[count] != -1; count++) - ; + return formats; +} - formats = av_mallocz(sizeof(AVFilterFormats)); - formats->format_count = count; - if (count) { - formats->formats = av_malloc(sizeof(*formats->formats) * count); +AVFilterFormats *avfilter_make_format64_list(const int64_t *fmts) +{ + MAKE_FORMAT_LIST(); + if (count) memcpy(formats->formats, fmts, sizeof(*formats->formats) * count); - } return formats; } -int avfilter_add_format(AVFilterFormats **avff, int fmt) +int avfilter_add_format(AVFilterFormats **avff, int64_t fmt) { - int *fmts; + int64_t *fmts; if (!(*avff) && !(*avff = av_mallocz(sizeof(AVFilterFormats)))) return AVERROR(ENOMEM); |