[FFmpeg-cvslog] r25878 - in trunk: doc/APIchanges libavcore/avcore.h libavcore/imgutils.c libavcore/imgutils.h libavfilter/avfilter.h libavfilter/defaults.c

stefano subversion
Sat Dec 4 13:56:17 CET 2010


Author: stefano
Date: Sat Dec  4 13:56:16 2010
New Revision: 25878

Log:
Implement av_image_alloc() and use it in
avfilter_default_get_video_buffer().

Modified:
   trunk/doc/APIchanges
   trunk/libavcore/avcore.h
   trunk/libavcore/imgutils.c
   trunk/libavcore/imgutils.h
   trunk/libavfilter/avfilter.h
   trunk/libavfilter/defaults.c

Modified: trunk/doc/APIchanges
==============================================================================
--- trunk/doc/APIchanges	Sat Dec  4 06:50:28 2010	(r25877)
+++ trunk/doc/APIchanges	Sat Dec  4 13:56:16 2010	(r25878)
@@ -12,6 +12,9 @@ libavutil:   2009-03-08
 
 
 API changes, most recent first:
+2010-12-04 - r25878 - lavcore 1.15.0 - av_image_alloc()
+  Add av_image_alloc() to libavcore/imgutils.h.
+
 2010-12-02 - r25862 - lavfi 1.67.0 - avfilter_graph_create_filter()
   Add function avfilter_graph_create_filter() in avfiltergraph.h.
 

Modified: trunk/libavcore/avcore.h
==============================================================================
--- trunk/libavcore/avcore.h	Sat Dec  4 06:50:28 2010	(r25877)
+++ trunk/libavcore/avcore.h	Sat Dec  4 13:56:16 2010	(r25878)
@@ -27,7 +27,7 @@
 #include "libavutil/avutil.h"
 
 #define LIBAVCORE_VERSION_MAJOR  0
-#define LIBAVCORE_VERSION_MINOR 14
+#define LIBAVCORE_VERSION_MINOR 15
 #define LIBAVCORE_VERSION_MICRO  0
 
 #define LIBAVCORE_VERSION_INT   AV_VERSION_INT(LIBAVCORE_VERSION_MAJOR, \

Modified: trunk/libavcore/imgutils.c
==============================================================================
--- trunk/libavcore/imgutils.c	Sat Dec  4 06:50:28 2010	(r25877)
+++ trunk/libavcore/imgutils.c	Sat Dec  4 13:56:16 2010	(r25878)
@@ -172,6 +172,35 @@ int ff_set_systematic_pal2(uint32_t pal[
     return 0;
 }
 
+int av_image_alloc(uint8_t *pointers[4], int linesizes[4],
+                   int w, int h, enum PixelFormat pix_fmt, int align)
+{
+    int i, ret;
+    uint8_t *buf;
+
+    if ((ret = av_image_check_size(w, h, 0, NULL)) < 0)
+        return ret;
+    if ((ret = av_image_fill_linesizes(linesizes, pix_fmt, w)) < 0)
+        return ret;
+
+    for (i = 0; i < 4; i++)
+        linesizes[i] = FFALIGN(linesizes[i], align);
+
+    if ((ret = av_image_fill_pointers(pointers, pix_fmt, h, NULL, linesizes)) < 0)
+        return ret;
+    buf = av_malloc(ret + align);
+    if (!buf)
+        return AVERROR(ENOMEM);
+    if ((ret = av_image_fill_pointers(pointers, pix_fmt, h, buf, linesizes)) < 0) {
+        av_free(buf);
+        return ret;
+    }
+    if (av_pix_fmt_descriptors[pix_fmt].flags & PIX_FMT_PAL)
+        ff_set_systematic_pal2((uint32_t*)pointers[1], pix_fmt);
+
+    return ret;
+}
+
 typedef struct ImgUtils {
     const AVClass *class;
     int   log_offset;

Modified: trunk/libavcore/imgutils.h
==============================================================================
--- trunk/libavcore/imgutils.h	Sat Dec  4 06:50:28 2010	(r25877)
+++ trunk/libavcore/imgutils.h	Sat Dec  4 13:56:16 2010	(r25878)
@@ -78,6 +78,19 @@ int av_image_fill_pointers(uint8_t *data
                            uint8_t *ptr, const int linesizes[4]);
 
 /**
+ * Allocate an image with size w and h and pixel format pix_fmt, and
+ * fill pointers and linesizes accordingly.
+ * The allocated image buffer has to be freed by using
+ * av_freep(&pointers[0]).
+ *
+ * @param align the value to use for buffer size alignment
+ * @return the size in bytes required for the image buffer, a negative
+ * error code in case of failure
+ */
+int av_image_alloc(uint8_t *pointers[4], int linesizes[4],
+                   int w, int h, enum PixelFormat pix_fmt, int align);
+
+/**
  * Copy image plane from src to dst.
  * That is, copy "height" number of lines of "bytewidth" bytes each.
  * The first byte of each successive line is separated by *_linesize

Modified: trunk/libavfilter/avfilter.h
==============================================================================
--- trunk/libavfilter/avfilter.h	Sat Dec  4 06:50:28 2010	(r25877)
+++ trunk/libavfilter/avfilter.h	Sat Dec  4 13:56:16 2010	(r25878)
@@ -26,7 +26,7 @@
 
 #define LIBAVFILTER_VERSION_MAJOR  1
 #define LIBAVFILTER_VERSION_MINOR 67
-#define LIBAVFILTER_VERSION_MICRO  0
+#define LIBAVFILTER_VERSION_MICRO  1
 
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
                                                LIBAVFILTER_VERSION_MINOR, \

Modified: trunk/libavfilter/defaults.c
==============================================================================
--- trunk/libavfilter/defaults.c	Sat Dec  4 06:50:28 2010	(r25877)
+++ trunk/libavfilter/defaults.c	Sat Dec  4 13:56:16 2010	(r25878)
@@ -37,26 +37,18 @@ void ff_avfilter_default_free_buffer(AVF
  * alloc & free cycle currently implemented. */
 AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
 {
-    char *buf = NULL;
-    int linesize[4], i, tempsize;
+    int linesize[4];
     uint8_t *data[4];
     AVFilterBufferRef *picref = NULL;
 
-    av_image_fill_linesizes(linesize, link->format, w);
-    for (i = 0; i < 4; i++)
-        linesize[i] = FFALIGN(linesize[i], 16);
-    tempsize = av_image_fill_pointers(data, link->format, h, NULL, linesize);
-    buf = av_malloc(tempsize + 16); // +2 is needed for swscaler, +16 to be
-                                    // SIMD-friendly
-    if (!buf)
+    // +2 is needed for swscaler, +16 to be SIMD-friendly
+    if (av_image_alloc(data, linesize, w, h, link->format, 16) < 0)
         return NULL;
 
-    av_image_fill_pointers(data, link->format, h, buf, linesize);
-
     picref = avfilter_get_video_buffer_ref_from_arrays(data, linesize,
                                                        perms, w, h, link->format);
     if (!picref) {
-        av_free(buf);
+        av_free(data[0]);
         return NULL;
     }
 



More information about the ffmpeg-cvslog mailing list