scale_and_extend_frame{,_nonnormative}() cleanup.

Change-Id: Ie99fd7af436ab2f6b3ef0c3f1a652fb26116d861
This commit is contained in:
Dmitry Kovalev 2014-04-25 12:44:26 -07:00
Родитель c3c5cf443c
Коммит 3875df8fdb
1 изменённых файлов: 49 добавлений и 59 удалений

Просмотреть файл

@ -1444,77 +1444,67 @@ void vp9_write_yuv_rec_frame(VP9_COMMON *cm) {
}
#endif
static void scale_and_extend_frame_nonnormative(YV12_BUFFER_CONFIG *src_fb,
YV12_BUFFER_CONFIG *dst_fb) {
const int in_w = src_fb->y_crop_width;
const int in_h = src_fb->y_crop_height;
const int out_w = dst_fb->y_crop_width;
const int out_h = dst_fb->y_crop_height;
const int in_w_uv = src_fb->uv_crop_width;
const int in_h_uv = src_fb->uv_crop_height;
const int out_w_uv = dst_fb->uv_crop_width;
const int out_h_uv = dst_fb->uv_crop_height;
static void scale_and_extend_frame_nonnormative(const YV12_BUFFER_CONFIG *src,
YV12_BUFFER_CONFIG *dst) {
// TODO(dkovalev): replace YV12_BUFFER_CONFIG with vpx_image_t
int i;
const uint8_t *const srcs[4] = {src->y_buffer, src->u_buffer, src->v_buffer,
src->alpha_buffer};
const int src_strides[4] = {src->y_stride, src->uv_stride, src->uv_stride,
src->alpha_stride};
const int src_widths[4] = {src->y_crop_width, src->uv_crop_width,
src->uv_crop_width, src->y_crop_width};
const int src_heights[4] = {src->y_crop_height, src->uv_crop_height,
src->uv_crop_height, src->y_crop_height};
uint8_t *const dsts[4] = {dst->y_buffer, dst->u_buffer, dst->v_buffer,
dst->alpha_buffer};
const int dst_strides[4] = {dst->y_stride, dst->uv_stride, dst->uv_stride,
dst->alpha_stride};
const int dst_widths[4] = {dst->y_crop_width, dst->uv_crop_width,
dst->uv_crop_width, dst->y_crop_width};
const int dst_heights[4] = {dst->y_crop_height, dst->uv_crop_height,
dst->uv_crop_height, dst->y_crop_height};
uint8_t *srcs[4] = {src_fb->y_buffer, src_fb->u_buffer, src_fb->v_buffer,
src_fb->alpha_buffer};
int src_strides[4] = {src_fb->y_stride, src_fb->uv_stride, src_fb->uv_stride,
src_fb->alpha_stride};
for (i = 0; i < MAX_MB_PLANE; ++i)
vp9_resize_plane(srcs[i], src_heights[i], src_widths[i], src_strides[i],
dsts[i], dst_heights[i], dst_widths[i], dst_strides[i]);
uint8_t *dsts[4] = {dst_fb->y_buffer, dst_fb->u_buffer, dst_fb->v_buffer,
dst_fb->alpha_buffer};
int dst_strides[4] = {dst_fb->y_stride, dst_fb->uv_stride, dst_fb->uv_stride,
dst_fb->alpha_stride};
for (i = 0; i < MAX_MB_PLANE; ++i) {
if (i == 0 || i == 3) {
// Y and alpha planes
vp9_resize_plane(srcs[i], in_h, in_w, src_strides[i],
dsts[i], out_h, out_w, dst_strides[i]);
} else {
// Chroma planes
vp9_resize_plane(srcs[i], in_h_uv, in_w_uv, src_strides[i],
dsts[i], out_h_uv, out_w_uv, dst_strides[i]);
}
}
// TODO(hkuang): Call C version explicitly
// as neon version only expand border size 32.
vp8_yv12_extend_frame_borders_c(dst_fb);
vp8_yv12_extend_frame_borders_c(dst);
}
static void scale_and_extend_frame(YV12_BUFFER_CONFIG *src_fb,
YV12_BUFFER_CONFIG *dst_fb) {
const int in_w = src_fb->y_crop_width;
const int in_h = src_fb->y_crop_height;
const int out_w = dst_fb->y_crop_width;
const int out_h = dst_fb->y_crop_height;
static void scale_and_extend_frame(const YV12_BUFFER_CONFIG *src,
YV12_BUFFER_CONFIG *dst) {
const int src_w = src->y_crop_width;
const int src_h = src->y_crop_height;
const int dst_w = dst->y_crop_width;
const int dst_h = dst->y_crop_height;
const uint8_t *const srcs[4] = {src->y_buffer, src->u_buffer, src->v_buffer,
src->alpha_buffer};
const int src_strides[4] = {src->y_stride, src->uv_stride, src->uv_stride,
src->alpha_stride};
uint8_t *const dsts[4] = {dst->y_buffer, dst->u_buffer, dst->v_buffer,
dst->alpha_buffer};
const int dst_strides[4] = {dst->y_stride, dst->uv_stride, dst->uv_stride,
dst->alpha_stride};
int x, y, i;
uint8_t *srcs[4] = {src_fb->y_buffer, src_fb->u_buffer, src_fb->v_buffer,
src_fb->alpha_buffer};
int src_strides[4] = {src_fb->y_stride, src_fb->uv_stride, src_fb->uv_stride,
src_fb->alpha_stride};
uint8_t *dsts[4] = {dst_fb->y_buffer, dst_fb->u_buffer, dst_fb->v_buffer,
dst_fb->alpha_buffer};
int dst_strides[4] = {dst_fb->y_stride, dst_fb->uv_stride, dst_fb->uv_stride,
dst_fb->alpha_stride};
for (y = 0; y < out_h; y += 16) {
for (x = 0; x < out_w; x += 16) {
for (y = 0; y < dst_h; y += 16) {
for (x = 0; x < dst_w; x += 16) {
for (i = 0; i < MAX_MB_PLANE; ++i) {
const int factor = (i == 0 || i == 3 ? 1 : 2);
const int x_q4 = x * (16 / factor) * in_w / out_w;
const int y_q4 = y * (16 / factor) * in_h / out_h;
const int x_q4 = x * (16 / factor) * src_w / dst_w;
const int y_q4 = y * (16 / factor) * src_h / dst_h;
const int src_stride = src_strides[i];
const int dst_stride = dst_strides[i];
uint8_t *src = srcs[i] + y / factor * in_h / out_h * src_stride +
x / factor * in_w / out_w;
uint8_t *dst = dsts[i] + y / factor * dst_stride + x / factor;
const uint8_t *src_ptr = srcs[i] + (y / factor) * src_h / dst_h *
src_stride + (x / factor) * src_w / dst_w;
uint8_t *dst_ptr = dsts[i] + (y / factor) * dst_stride + (x / factor);
vp9_convolve8(src, src_stride, dst, dst_stride,
vp9_sub_pel_filters_8[x_q4 & 0xf], 16 * in_w / out_w,
vp9_sub_pel_filters_8[y_q4 & 0xf], 16 * in_h / out_h,
vp9_convolve8(src_ptr, src_stride, dst_ptr, dst_stride,
vp9_sub_pel_filters_8[x_q4 & 0xf], 16 * src_w / dst_w,
vp9_sub_pel_filters_8[y_q4 & 0xf], 16 * src_h / dst_h,
16 / factor, 16 / factor);
}
}
@ -1522,7 +1512,7 @@ static void scale_and_extend_frame(YV12_BUFFER_CONFIG *src_fb,
// TODO(hkuang): Call C version explicitly
// as neon version only expand border size 32.
vp8_yv12_extend_frame_borders_c(dst_fb);
vp8_yv12_extend_frame_borders_c(dst);
}
static int find_fp_qindex() {
@ -1701,7 +1691,7 @@ void vp9_scale_references(VP9_COMP *cpi) {
for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) {
const int idx = cm->ref_frame_map[get_ref_frame_idx(cpi, ref_frame)];
YV12_BUFFER_CONFIG *const ref = &cm->frame_bufs[idx].buf;
const YV12_BUFFER_CONFIG *const ref = &cm->frame_bufs[idx].buf;
if (ref->y_crop_width != cm->width ||
ref->y_crop_height != cm->height) {