Commit 4e23998f authored by Marco's avatar Marco

vp9: SVC: Add option to set downsampling filter type.

Add option in SVC to set the filter type and phase for
the frame level downsampling filters.

For 3 spatial layers: set downsampling filter type to bilinear
and set phase to 8, for lowest spatial layer.

Change-Id: Id81f4b1ba93db19c1cd37b6a46d1281a2c61bc43
parent ecd1eb21
......@@ -225,7 +225,7 @@ if (vpx_config("CONFIG_VP9_HIGHBITDEPTH") eq "yes") {
#
# frame based scale
#
add_proto qw/void vp9_scale_and_extend_frame/, "const struct yv12_buffer_config *src, struct yv12_buffer_config *dst, int phase_scaler";
add_proto qw/void vp9_scale_and_extend_frame/, "const struct yv12_buffer_config *src, struct yv12_buffer_config *dst, uint8_t filter_type, int phase_scaler";
specialize qw/vp9_scale_and_extend_frame ssse3/;
}
......
This diff is collapsed.
......@@ -836,17 +836,14 @@ void vp9_update_reference_frames(VP9_COMP *cpi);
void vp9_set_high_precision_mv(VP9_COMP *cpi, int allow_high_precision_mv);
YV12_BUFFER_CONFIG *vp9_svc_twostage_scale(VP9_COMMON *cm,
YV12_BUFFER_CONFIG *unscaled,
YV12_BUFFER_CONFIG *scaled,
YV12_BUFFER_CONFIG *scaled_temp,
int phase_scaler, int phase_scaler2);
YV12_BUFFER_CONFIG *vp9_scale_if_required(VP9_COMMON *cm,
YV12_BUFFER_CONFIG *unscaled,
YV12_BUFFER_CONFIG *scaled,
int use_normative_scaler,
int phase_scaler);
YV12_BUFFER_CONFIG *vp9_svc_twostage_scale(
VP9_COMMON *cm, YV12_BUFFER_CONFIG *unscaled, YV12_BUFFER_CONFIG *scaled,
YV12_BUFFER_CONFIG *scaled_temp, INTERP_FILTER filter_type,
int phase_scaler, INTERP_FILTER filter_type2, int phase_scaler2);
YV12_BUFFER_CONFIG *vp9_scale_if_required(
VP9_COMMON *cm, YV12_BUFFER_CONFIG *unscaled, YV12_BUFFER_CONFIG *scaled,
int use_normative_scaler, INTERP_FILTER filter_type, int phase_scaler);
void vp9_apply_encoding_flags(VP9_COMP *cpi, vpx_enc_frame_flags_t flags);
......
......@@ -1400,7 +1400,7 @@ void vp9_first_pass(VP9_COMP *cpi, const struct lookahead_entry *source) {
(cpi->ref_frame_flags & VP9_GOLD_FLAG) ? GOLDEN_FRAME : NONE);
cpi->Source = vp9_scale_if_required(cm, cpi->un_scaled_source,
&cpi->scaled_source, 0, 0);
&cpi->scaled_source, 0, EIGHTTAP, 0);
}
vp9_setup_block_planes(&x->e_mbd, cm->subsampling_x, cm->subsampling_y);
......
......@@ -16,7 +16,8 @@
#include "vpx_scale/yv12config.h"
void vp9_scale_and_extend_frame_c(const YV12_BUFFER_CONFIG *src,
YV12_BUFFER_CONFIG *dst, int phase_scaler) {
YV12_BUFFER_CONFIG *dst,
INTERP_FILTER filter_type, int phase_scaler) {
const int src_w = src->y_crop_width;
const int src_h = src->y_crop_height;
const int dst_w = dst->y_crop_width;
......@@ -26,7 +27,7 @@ void vp9_scale_and_extend_frame_c(const YV12_BUFFER_CONFIG *src,
const int src_strides[3] = { src->y_stride, src->uv_stride, src->uv_stride };
uint8_t *const dsts[3] = { dst->y_buffer, dst->u_buffer, dst->v_buffer };
const int dst_strides[3] = { dst->y_stride, dst->uv_stride, dst->uv_stride };
const InterpKernel *const kernel = vp9_filter_kernels[EIGHTTAP];
const InterpKernel *const kernel = vp9_filter_kernels[filter_type];
int x, y, i;
for (i = 0; i < MAX_MB_PLANE; ++i) {
......
......@@ -38,11 +38,12 @@ void vp9_init_layer_context(VP9_COMP *const cpi) {
svc->current_superframe = 0;
for (i = 0; i < REF_FRAMES; ++i) svc->ref_frame_index[i] = -1;
for (sl = 0; sl < oxcf->ss_number_layers; ++sl) {
cpi->svc.ext_frame_flags[sl] = 0;
cpi->svc.ext_lst_fb_idx[sl] = 0;
cpi->svc.ext_gld_fb_idx[sl] = 1;
cpi->svc.ext_alt_fb_idx[sl] = 2;
cpi->svc.filtertype_downsample_source[sl] = 0;
svc->ext_frame_flags[sl] = 0;
svc->ext_lst_fb_idx[sl] = 0;
svc->ext_gld_fb_idx[sl] = 1;
svc->ext_alt_fb_idx[sl] = 2;
svc->downsample_filter_type[sl] = EIGHTTAP;
svc->downsample_filter_phase[sl] = 0; // Set to 8 for averaging filter.
}
if (cpi->oxcf.error_resilient_mode == 0 && cpi->oxcf.pass == 2) {
......@@ -651,10 +652,12 @@ int vp9_one_pass_cbr_svc_start_layer(VP9_COMP *const cpi) {
lc->scaling_factor_num, lc->scaling_factor_den, &width,
&height);
// For low resolutions: set the filtertype for downsampling source to 1,
// to get averaging filter.
if (width <= 320 && height <= 240)
cpi->svc.filtertype_downsample_source[cpi->svc.spatial_layer_id] = 1;
// For low resolutions: set phase of the filter = 8 (for symmetric averaging
// filter), use bilinear for now.
if (width <= 320 && height <= 240) {
cpi->svc.downsample_filter_type[cpi->svc.spatial_layer_id] = BILINEAR;
cpi->svc.downsample_filter_phase[cpi->svc.spatial_layer_id] = 8;
}
// The usage of use_base_mv assumes down-scale of 2x2. For now, turn off use
// of base motion vectors if spatial scale factors for any layers are not 2,
......
......@@ -89,11 +89,12 @@ typedef struct {
int current_superframe;
int use_base_mv;
// Used to control the downscaling filter for source scaling, for 1 pass CBR.
// 0 will do sub-sampling (no weighted average), 1 will center the target
// pixel and use the averaging filter, for the default eightap_regular:
// {-1, 6, -19, 78, 78, -19, 6, -1 }.
// TODO(marpan): Add option for bilinear.
int filtertype_downsample_source[VPX_SS_MAX_LAYERS];
// downsample_filter_phase: = 0 will do sub-sampling (no weighted average),
// = 8 will center the target pixel and get a symmetric averaging filter.
// downsample_filter_type: 4 filters may be used: eighttap_regular,
// eighttap_smooth, eighttap_sharp, and bilinear.
INTERP_FILTER downsample_filter_type[VPX_SS_MAX_LAYERS];
int downsample_filter_phase[VPX_SS_MAX_LAYERS];
} SVC;
struct VP9_COMP;
......
......@@ -755,7 +755,8 @@ void vp9_temporal_filter(VP9_COMP *cpi, int distance) {
"Failed to reallocate alt_ref_buffer");
}
frames[frame] = vp9_scale_if_required(
cm, frames[frame], &cpi->svc.scaled_frames[frame_used], 0, 0);
cm, frames[frame], &cpi->svc.scaled_frames[frame_used], 0,
EIGHTTAP, 0);
++frame_used;
}
}
......
......@@ -17,7 +17,7 @@
extern void vp9_scale_and_extend_frame_c(const YV12_BUFFER_CONFIG *src,
YV12_BUFFER_CONFIG *dst,
int phase_scaler);
uint8_t filter_type, int phase_scaler);
static void downsample_2_to_1_ssse3(const uint8_t *src, ptrdiff_t src_stride,
uint8_t *dst, ptrdiff_t dst_stride, int w,
......@@ -170,7 +170,7 @@ static void upsample_1_to_2_ssse3(const uint8_t *src, ptrdiff_t src_stride,
void vp9_scale_and_extend_frame_ssse3(const YV12_BUFFER_CONFIG *src,
YV12_BUFFER_CONFIG *dst,
int phase_scaler) {
uint8_t filter_type, int phase_scaler) {
const int src_w = src->y_crop_width;
const int src_h = src->y_crop_height;
const int dst_w = dst->y_crop_width;
......@@ -198,9 +198,9 @@ void vp9_scale_and_extend_frame_ssse3(const YV12_BUFFER_CONFIG *src,
dst->uv_stride, dst_uv_w, dst_uv_h);
vpx_extend_frame_borders(dst);
} else {
vp9_scale_and_extend_frame_c(src, dst, phase_scaler);
vp9_scale_and_extend_frame_c(src, dst, filter_type, phase_scaler);
}
} else {
vp9_scale_and_extend_frame_c(src, dst, phase_scaler);
vp9_scale_and_extend_frame_c(src, dst, filter_type, phase_scaler);
}
}
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