Commit 0006073f authored by Yaowu Xu's avatar Yaowu Xu

Update 8-bit frame buffers for Global Motion estimation

This commit makes sure that 8bit frame buffers used in global motion
estimation are updated, so to help global motion to improve compression
for hbd internal encoding. 

On lowres 12 encoding, the improvements are: 
Overall PSNR: .896%
SSIM:  1.159%
PSNR HVS: .952%

Change-Id: I5d75c231407bc1e4ed564c3a216bdd1ec3919f14
parent cb9c1c52
......@@ -244,14 +244,16 @@ 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);
uint8_t *buf = malloc(frm->y_height * frm->y_stride * sizeof(*buf));
if (!frm->y_buffer_8bit)
frm->y_buffer_8bit =
malloc(frm->y_height * frm->y_stride * sizeof(*frm->y_buffer_8bit));
for (i = 0; i < frm->y_height; ++i)
for (j = 0; j < frm->y_width; ++j)
buf[i * frm->y_stride + j] =
frm->y_buffer_8bit[i * frm->y_stride + j] =
orig_buf[i * frm->y_stride + j] >> (bit_depth - 8);
return buf;
return frm->y_buffer_8bit;
}
#endif
......@@ -274,16 +276,10 @@ int compute_global_motion_feature_based(
if (frm->flags & YV12_FLAG_HIGHBITDEPTH) {
// The frame buffer is 16-bit, so we need to convert to 8 bits for the
// following code. We cache the result until the frame is released.
if (frm->y_buffer_8bit)
frm_buffer = frm->y_buffer_8bit;
else
frm_buffer = frm->y_buffer_8bit = downconvert_frame(frm, bit_depth);
frm_buffer = downconvert_frame(frm, bit_depth);
}
if (ref->flags & YV12_FLAG_HIGHBITDEPTH) {
if (ref->y_buffer_8bit)
ref_buffer = ref->y_buffer_8bit;
else
ref_buffer = ref->y_buffer_8bit = downconvert_frame(ref, bit_depth);
ref_buffer = downconvert_frame(ref, bit_depth);
}
#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