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.
This commit is contained in:
Mina Nagy Zaki 2011-06-07 21:17:23 +03:00 committed by Stefano Sabatini
parent 8f349b6481
commit 527ca3985c
3 changed files with 43 additions and 18 deletions

View File

@ -13,6 +13,14 @@ libavutil: 2011-04-18
API changes, most recent first:
2011-06-19 - xxxxxxx - lavfi 2.22.0 - AVFilterFormats
Change type of AVFilterFormats.formats from int * to int64_t *,
and update formats handling API accordingly.
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.
2011-06-19 - xxxxxxx - lavfi 2.21.0 - vsink_buffer.h
Add video sink buffer and vsink_buffer.h public header.

View File

@ -26,7 +26,7 @@
#include "libavutil/samplefmt.h"
#define LIBAVFILTER_VERSION_MAJOR 2
#define LIBAVFILTER_VERSION_MINOR 21
#define LIBAVFILTER_VERSION_MINOR 22
#define LIBAVFILTER_VERSION_MICRO 0
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
@ -223,7 +223,7 @@ void avfilter_unref_buffer(AVFilterBufferRef *ref);
*/
typedef struct AVFilterFormats {
unsigned format_count; ///< number of formats
int *formats; ///< list of media formats
int64_t *formats; ///< list of media formats
unsigned refcount; ///< number of references to this list
struct AVFilterFormats ***refs; ///< references to this list
@ -238,6 +238,7 @@ typedef struct AVFilterFormats {
* @return the format list, with no existing references
*/
AVFilterFormats *avfilter_make_format_list(const int *fmts);
AVFilterFormats *avfilter_make_format64_list(const int64_t *fmts);
/**
* Add fmt to the list of media formats contained in *avff.
@ -247,7 +248,7 @@ AVFilterFormats *avfilter_make_format_list(const int *fmts);
* @return a non negative value in case of success, or a negative
* value corresponding to an AVERROR code in case of error
*/
int avfilter_add_format(AVFilterFormats **avff, int fmt);
int avfilter_add_format(AVFilterFormats **avff, int64_t fmt);
/**
* Return a list of all formats supported by FFmpeg for the given media type.

View File

@ -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;
if (fmts)
for (count = 0; fmts[count] != -1; count++)
;
formats = av_mallocz(sizeof(AVFilterFormats));
formats->format_count = count;
if (count) {
formats->formats = av_malloc(sizeof(*formats->formats) * count);
memcpy(formats->formats, fmts, sizeof(*formats->formats) * count);
}
MAKE_FORMAT_LIST();
while (count--)
formats->formats[count] = fmts[count];
return formats;
}
int avfilter_add_format(AVFilterFormats **avff, int fmt)
AVFilterFormats *avfilter_make_format64_list(const int64_t *fmts)
{
int *fmts;
MAKE_FORMAT_LIST();
if (count)
memcpy(formats->formats, fmts, sizeof(*formats->formats) * count);
return formats;
}
int avfilter_add_format(AVFilterFormats **avff, int64_t fmt)
{
int64_t *fmts;
if (!(*avff) && !(*avff = av_mallocz(sizeof(AVFilterFormats))))
return AVERROR(ENOMEM);