OSDN Git Service

lavfi: use int64_t lists in AVFilteFormats
authorMina Nagy Zaki <mnzaki@gmail.com>
Tue, 7 Jun 2011 18:17:23 +0000 (21:17 +0300)
committerStefano Sabatini <stefano.sabatini-lala@poste.it>
Sun, 19 Jun 2011 20:58:31 +0000 (22:58 +0200)
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.

doc/APIchanges
libavfilter/avfilter.h
libavfilter/formats.c

index 4db7ffe..dc352e7 100644 (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.
 
index 5ac7039..1a3a69d 100644 (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.
index 4a23c2f..4e101c5 100644 (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;
+    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);