Commit 58b9c9fb authored by Deb Mukherjee's avatar Deb Mukherjee Committed by Gerrit Code Review

Merge "Adds a non-normative resize library to vp9 encoder"

parents 528bf858 3cd37dfe
......@@ -208,7 +208,7 @@ class ResizeInternalTest : public ResizeTest {
virtual void PSNRPktHook(const vpx_codec_cx_pkt_t *pkt) {
if (!frame0_psnr_)
frame0_psnr_ = pkt->data.psnr.psnr[0];
EXPECT_NEAR(pkt->data.psnr.psnr[0], frame0_psnr_, 1.5);
EXPECT_NEAR(pkt->data.psnr.psnr[0], frame0_psnr_, 2.0);
}
virtual void FramePktHook(const vpx_codec_cx_pkt_t *pkt) {
......
......@@ -36,6 +36,7 @@
#include "vp9/encoder/vp9_segmentation.h"
#include "vp9/encoder/vp9_temporal_filter.h"
#include "vp9/encoder/vp9_vaq.h"
#include "vp9/encoder/vp9_resize.h"
#include "vpx_ports/vpx_timer.h"
......@@ -2295,6 +2296,42 @@ 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;
int 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 (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]);
}
}
vp8_yv12_extend_frame_borders(dst_fb);
}
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;
......@@ -2316,7 +2353,7 @@ static void scale_and_extend_frame(YV12_BUFFER_CONFIG *src_fb,
for (y = 0; y < out_h; y += 16) {
for (x = 0; x < out_w; x += 16) {
for (i = 0; i < MAX_MB_PLANE; ++i) {
const int factor = i == 0 ? 1 : 2;
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 src_stride = src_strides[i];
......@@ -2924,7 +2961,8 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
/* Scale the source buffer, if required. */
if (cm->mi_cols * 8 != cpi->un_scaled_source->y_width ||
cm->mi_rows * 8 != cpi->un_scaled_source->y_height) {
scale_and_extend_frame(cpi->un_scaled_source, &cpi->scaled_source);
scale_and_extend_frame_nonnormative(cpi->un_scaled_source,
&cpi->scaled_source);
cpi->Source = &cpi->scaled_source;
} else {
cpi->Source = cpi->un_scaled_source;
......
This diff is collapsed.
/*
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef VP9_ENCODER_VP9_RESIZE_H_
#define VP9_ENCODER_VP9_RESIZE_H_
#include <stdio.h>
void vp9_resize_plane(const uint8_t *const input,
int height,
int width,
int in_stride,
uint8_t *output,
int height2,
int width2,
int out_stride);
void vp9_resize_frame420(const uint8_t *const y,
int y_stride,
const uint8_t *const u,
const uint8_t *const v,
int uv_stride,
int height,
int width,
uint8_t *oy,
int oy_stride,
uint8_t *ou,
uint8_t *ov,
int ouv_stride,
int oheight,
int owidth);
void vp9_resize_frame422(const uint8_t *const y,
int y_stride,
const uint8_t *const u,
const uint8_t *const v,
int uv_stride,
int height,
int width,
uint8_t *oy,
int oy_stride,
uint8_t *ou,
uint8_t *ov,
int ouv_stride,
int oheight,
int owidth);
void vp9_resize_frame444(const uint8_t *const y,
int y_stride,
const uint8_t *const u,
const uint8_t *const v,
int uv_stride,
int height,
int width,
uint8_t *oy,
int oy_stride,
uint8_t *ou,
uint8_t *ov,
int ouv_stride,
int oheight,
int owidth);
#endif // VP9_ENCODER_VP9_RESIZE_H_
......@@ -61,6 +61,8 @@ VP9_CX_SRCS-yes += encoder/vp9_segmentation.c
VP9_CX_SRCS-yes += encoder/vp9_segmentation.h
VP9_CX_SRCS-yes += encoder/vp9_subexp.c
VP9_CX_SRCS-yes += encoder/vp9_subexp.h
VP9_CX_SRCS-yes += encoder/vp9_resize.c
VP9_CX_SRCS-yes += encoder/vp9_resize.h
VP9_CX_SRCS-$(CONFIG_INTERNAL_STATS) += encoder/vp9_ssim.c
VP9_CX_SRCS-yes += encoder/vp9_tokenize.c
VP9_CX_SRCS-yes += encoder/vp9_treewriter.c
......
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