shithub: libvpx

Download patch

ref: d7a32e5ae0dab0699517b2efc75561da798f3e4b
parent: a9e38537cd54ef98e65ed3da8c80cd86dfaed036
parent: c1a769d0fcadabbe3ab3442d991f9dfcd22dfee2
author: Dmitry Kovalev <[email protected]>
date: Tue Aug 19 15:01:47 EDT 2014

Merge "Using functions from vpx_mem.h inside vpx_image.c."

--- a/vpx/src/vpx_image.c
+++ b/vpx/src/vpx_image.c
@@ -8,39 +8,13 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-
 #include <stdlib.h>
 #include <string.h>
+
 #include "vpx/vpx_image.h"
 #include "vpx/vpx_integer.h"
+#include "vpx_mem/vpx_mem.h"
 
-#define ADDRESS_STORAGE_SIZE      sizeof(size_t)
-/*returns an addr aligned to the byte boundary specified by align*/
-#define align_addr(addr,align) (void*)(((size_t)(addr) + ((align) - 1)) & (size_t)-(align))
-
-/* Memalign code is copied from vpx_mem.c */
-static void *img_buf_memalign(size_t align, size_t size) {
-  void *addr,
-       * x = NULL;
-
-  addr = malloc(size + align - 1 + ADDRESS_STORAGE_SIZE);
-
-  if (addr) {
-    x = align_addr((unsigned char *)addr + ADDRESS_STORAGE_SIZE, (int)align);
-    /* save the actual malloc address */
-    ((size_t *)x)[-1] = (size_t)addr;
-  }
-
-  return x;
-}
-
-static void img_buf_free(void *memblk) {
-  if (memblk) {
-    void *addr = (void *)(((size_t *)memblk)[-1]);
-    free(addr);
-  }
-}
-
 static vpx_image_t *img_alloc_helper(vpx_image_t   *img,
                                      vpx_img_fmt_t  fmt,
                                      unsigned int   d_w,
@@ -172,7 +146,7 @@
     if (alloc_size != (size_t)alloc_size)
       goto fail;
 
-    img->img_data = img_buf_memalign(buf_align, (size_t)alloc_size);
+    img->img_data = (uint8_t *)vpx_memalign(buf_align, (size_t)alloc_size);
     img->img_data_owner = 1;
   }
 
@@ -296,7 +270,7 @@
 void vpx_img_free(vpx_image_t *img) {
   if (img) {
     if (img->img_data && img->img_data_owner)
-      img_buf_free(img->img_data);
+      vpx_free(img->img_data);
 
     if (img->self_allocd)
       free(img);