]> granicus.if.org Git - libvpx/commitdiff
Remove memset of every external frame buffer.
authorFrank Galligan <fgalligan@google.com>
Thu, 11 Sep 2014 15:39:38 +0000 (08:39 -0700)
committerFrank Galligan <fgalligan@google.com>
Mon, 15 Sep 2014 22:37:36 +0000 (15:37 -0700)
Libvpx was memseting every external frame buffer before decode. This
was to work around a valgrind issue in our C loop filter. Most of
the time this was not needed and we have noticed some significant
performance loss on some platforms. Now we require the application to
zero out the buffers if it is using external frame buffers.

Change-Id: I7330d00a315e65137ed30edd5f813e8929b76242

test/external_frame_buffer_test.cc
vp9/common/vp9_frame_buffers.c
vpx/vpx_frame_buffer.h
vpx_scale/generic/yv12config.c
vpxdec.c

index 44eba33175ecde9979bcdeb9f1de0a6b45f883a0..70b3009289188e4717032af80c3219a14259b99c 100644 (file)
@@ -71,6 +71,7 @@ class ExternalFrameBufferList {
     if (ext_fb_list_[idx].size < min_size) {
       delete [] ext_fb_list_[idx].data;
       ext_fb_list_[idx].data = new uint8_t[min_size];
+      memset(ext_fb_list_[idx].data, 0, min_size);
       ext_fb_list_[idx].size = min_size;
     }
 
index 733b3a927233aaecc139a4879efe8dca3171bc79..34795b74ec2199172fa0dd06086643c1c2014f73 100644 (file)
@@ -61,6 +61,10 @@ int vp9_get_frame_buffer(void *cb_priv, size_t min_size,
     if (!int_fb_list->int_fb[i].data)
       return -1;
 
+    // This memset is needed for fixing valgrind error from C loop filter
+    // due to access uninitialized memory in frame border. It could be
+    // removed if border is totally removed.
+    vpx_memset(int_fb_list->int_fb[i].data, 0, min_size);
     int_fb_list->int_fb[i].size = min_size;
   }
 
index e69df4bc8221abc0529d79ab9f71e2edda7ea34e..41038b10df6726fae01341cb14e5c44f44e7697a 100644 (file)
@@ -43,15 +43,15 @@ typedef struct vpx_codec_frame_buffer {
  *
  * This callback is invoked by the decoder to retrieve data for the frame
  * buffer in order for the decode call to complete. The callback must
- * allocate at least min_size in bytes and assign it to fb->data. Then the
- * callback must set fb->size to the allocated size. The application does not
- * need to align the allocated data. The callback is triggered when the
- * decoder needs a frame buffer to decode a compressed image into. This
- * function may be called more than once for every call to vpx_codec_decode.
- * The application may set fb->priv to some data which will be passed
- * back in the ximage and the release function call. |fb| is guaranteed to
- * not be NULL. On success the callback must return 0. Any failure the
- * callback must return a value less than 0.
+ * allocate at least min_size in bytes and assign it to fb->data. The callback
+ * must zero out all the data allocated. Then the callback must set fb->size
+ * to the allocated size. The application does not need to align the allocated
+ * data. The callback is triggered when the decoder needs a frame buffer to
+ * decode a compressed image into. This function may be called more than once
+ * for every call to vpx_codec_decode. The application may set fb->priv to
+ * some data which will be passed back in the ximage and the release function
+ * call. |fb| is guaranteed to not be NULL. On success the callback must
+ * return 0. Any failure the callback must return a value less than 0.
  *
  * \param[in] priv         Callback's private data
  * \param[in] new_size     Size in bytes needed by the buffer
index 70d7ac0c8862a83f1d61354d5136f706f892f232..475d231e1c74d238e99875d7cac434f6eed99991 100644 (file)
@@ -199,11 +199,6 @@ int vp9_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf,
       if (fb->data == NULL || fb->size < external_frame_size)
         return -1;
 
-      // This memset is needed for fixing valgrind error from C loop filter
-      // due to access uninitialized memory in frame border. It could be
-      // removed if border is totally removed.
-      vpx_memset(fb->data, 0, fb->size);
-
       ybf->buffer_alloc = (uint8_t *)yv12_align_addr(fb->data, 32);
     } else if (frame_size > (size_t)ybf->buffer_alloc_sz) {
       // Allocation to hold larger frame, or first allocation.
index 091522f067d1c94abd773a20287990c8ca8125fa..cf23c295e02fe99c19bfdb8b2110166ed54cce8e 100644 (file)
--- a/vpxdec.c
+++ b/vpxdec.c
@@ -384,7 +384,7 @@ int get_vp9_frame_buffer(void *cb_priv, size_t min_size,
 
   if (ext_fb_list->ext_fb[i].size < min_size) {
     free(ext_fb_list->ext_fb[i].data);
-    ext_fb_list->ext_fb[i].data = (uint8_t *)malloc(min_size);
+    ext_fb_list->ext_fb[i].data = (uint8_t *)calloc(min_size, sizeof(uint8_t));
     if (!ext_fb_list->ext_fb[i].data)
       return -1;