Commit 43778572 authored by Yaowu Xu's avatar Yaowu Xu

Move buffer allocation to aom_scale

This commit moves the allocation of the 8bit frame buffer used in
global motion estimation to where other frame buffers are allocated.

Change-Id: Id3c0a0cb33dab7225629ce6f2d7904767f647d4c
parent 71ef7c27
......@@ -11,9 +11,9 @@
#include <assert.h>
#include "aom_scale/yv12config.h"
#include "aom_mem/aom_mem.h"
#include "aom_ports/mem.h"
#include "aom_scale/yv12config.h"
/****************************************************************************
* Exports
......@@ -35,7 +35,7 @@ int aom_free_frame_buffer(YV12_BUFFER_CONFIG *ybf) {
}
#if CONFIG_HIGHBITDEPTH && CONFIG_GLOBAL_MOTION
if (ybf->y_buffer_8bit) free(ybf->y_buffer_8bit);
if (ybf->y_buffer_8bit) aom_free(ybf->y_buffer_8bit);
#endif
/* buffer_alloc isn't accessed by most functions. Rather y_buffer,
......@@ -168,9 +168,12 @@ int aom_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height,
aom_byte_align);
#if CONFIG_HIGHBITDEPTH && CONFIG_GLOBAL_MOTION
if (ybf->y_buffer_8bit) {
free(ybf->y_buffer_8bit);
ybf->y_buffer_8bit = NULL;
if (use_highbitdepth) {
if (ybf->y_buffer_8bit) aom_free(ybf->y_buffer_8bit);
ybf->y_buffer_8bit = (uint8_t *)aom_memalign(32, (size_t)yplane_size);
if (!ybf->y_buffer_8bit) return -1;
} else {
assert(!ybf->y_buffer_8bit);
}
#endif
......
......@@ -244,16 +244,13 @@ static unsigned char *downconvert_frame(YV12_BUFFER_CONFIG *frm,
int bit_depth) {
int i, j;
uint16_t *orig_buf = CONVERT_TO_SHORTPTR(frm->y_buffer);
if (!frm->y_buffer_8bit)
frm->y_buffer_8bit =
malloc(frm->y_height * frm->y_stride * sizeof(*frm->y_buffer_8bit));
uint8_t *buf_8bit = frm->y_buffer_8bit;
assert(!buf_8bit);
for (i = 0; i < frm->y_height; ++i)
for (j = 0; j < frm->y_width; ++j)
frm->y_buffer_8bit[i * frm->y_stride + j] =
buf_8bit[i * frm->y_stride + j] =
orig_buf[i * frm->y_stride + j] >> (bit_depth - 8);
return frm->y_buffer_8bit;
return buf_8bit;
}
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment