* be found in the AUTHORS file in the root of the source tree.
*/
+#include <assert.h>
+
#include "./vpx_config.h"
#include "vpx_scale/yv12config.h"
#include "vpx_mem/vpx_mem.h"
/****************************************************************************
*
****************************************************************************/
-
#define yv12_align_addr(addr, align) \
- (void*)(((size_t)(addr) + ((align) - 1)) & (size_t)-(align))
+ (void*)(((size_t)(addr) + ((align) - 1)) & (size_t)-(align))
int
vp8_yv12_de_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf) {
if (ybf) {
- // If libvpx is using external frame buffers then buffer_alloc_sz must
+ // If libvpx is using frame buffer callbacks then buffer_alloc_sz must
// not be set.
if (ybf->buffer_alloc_sz > 0) {
vpx_free(ybf->buffer_alloc);
const int frame_size = yplane_size + 2 * uvplane_size;
if (!ybf->buffer_alloc) {
- ybf->buffer_alloc = vpx_memalign(32, frame_size);
+ ybf->buffer_alloc = (uint8_t *)vpx_memalign(32, frame_size);
ybf->buffer_alloc_sz = frame_size;
}
int vp9_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf,
int width, int height,
int ss_x, int ss_y, int border,
- vpx_codec_frame_buffer_t *ext_fb,
- vpx_realloc_frame_buffer_cb_fn_t cb,
- void *user_priv) {
+ vpx_codec_frame_buffer_t *fb,
+ vpx_get_frame_buffer_cb_fn_t cb,
+ void *cb_priv) {
if (ybf) {
const int aligned_width = (width + 7) & ~7;
const int aligned_height = (height + 7) & ~7;
#else
const int frame_size = yplane_size + 2 * uvplane_size;
#endif
-
- if (ext_fb != NULL) {
+ if (cb != NULL) {
const int align_addr_extra_size = 31;
const size_t external_frame_size = frame_size + align_addr_extra_size;
- if (external_frame_size > ext_fb->size) {
- // Allocation to hold larger frame, or first allocation.
- if (cb(user_priv, external_frame_size, ext_fb) < 0) {
- return -1;
- }
-
- if (ext_fb->data == NULL || ext_fb->size < external_frame_size) {
- return -1;
- }
-
- ybf->buffer_alloc = yv12_align_addr(ext_fb->data, 32);
- }
- } else {
- if (frame_size > ybf->buffer_alloc_sz) {
- // Allocation to hold larger frame, or first allocation.
- if (ybf->buffer_alloc)
- vpx_free(ybf->buffer_alloc);
- ybf->buffer_alloc = vpx_memalign(32, frame_size);
- ybf->buffer_alloc_sz = frame_size;
- }
-
- if (ybf->buffer_alloc_sz < frame_size)
+
+ assert(fb != NULL);
+
+ // Allocation to hold larger frame, or first allocation.
+ if (cb(cb_priv, external_frame_size, fb) < 0)
return -1;
- }
- if (!ybf->buffer_alloc)
- return -1;
+ 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 > ybf->buffer_alloc_sz) {
+ // Allocation to hold larger frame, or first allocation.
+ if (ybf->buffer_alloc)
+ vpx_free(ybf->buffer_alloc);
+ ybf->buffer_alloc = (uint8_t *)vpx_memalign(32, frame_size);
+ if (!ybf->buffer_alloc)
+ return -1;
+
+ ybf->buffer_alloc_sz = frame_size;
+
+ // 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(ybf->buffer_alloc, 0, ybf->buffer_alloc_sz);
+ }
/* Only support allocating buffers that have a border that's a multiple
* of 32. The border restriction is required to get 16-byte alignment of