]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/formats.c
lavfi: handle NULL lists in avfilter_make_format_list
[ffmpeg] / libavfilter / formats.c
index 5e65c2968dd3ae667295a5c111e5b15a7193da7e..ec7fca3817dfd6bfe8a7a8a2d9c3f0421051147e 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Filter layer - format negotiation
- * copyright (c) 2007 Bobby Bingham
+ * Copyright (c) 2007 Bobby Bingham
  *
  * This file is part of FFmpeg.
  *
@@ -73,15 +73,18 @@ AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b)
 AVFilterFormats *avfilter_make_format_list(const int *fmts)
 {
     AVFilterFormats *formats;
-    int count;
+    int count = 0;
 
-    for (count = 0; fmts[count] != -1; count++)
-        ;
+    if (fmts)
+        for (count = 0; fmts[count] != -1; count++)
+            ;
 
     formats               = av_mallocz(sizeof(AVFilterFormats));
-    formats->formats      = av_malloc(sizeof(*formats->formats) * count);
     formats->format_count = count;
-    memcpy(formats->formats, fmts, sizeof(*formats->formats) * count);
+    if (count) {
+        formats->formats  = av_malloc(sizeof(*formats->formats) * count);
+        memcpy(formats->formats, fmts, sizeof(*formats->formats) * count);
+    }
 
     return formats;
 }
@@ -108,7 +111,7 @@ AVFilterFormats *avfilter_all_formats(enum AVMediaType type)
     AVFilterFormats *ret = NULL;
     int fmt;
     int num_formats = type == AVMEDIA_TYPE_VIDEO ? PIX_FMT_NB    :
-                      type == AVMEDIA_TYPE_AUDIO ? SAMPLE_FMT_NB : 0;
+                      type == AVMEDIA_TYPE_AUDIO ? AV_SAMPLE_FMT_NB : 0;
 
     for (fmt = 0; fmt < num_formats; fmt++)
         if ((type != AVMEDIA_TYPE_VIDEO) ||