Commit 4bbd9551 authored by Marco's avatar Marco
Browse files

Dynamic resize for real-time: source scaling

Use faster scaling on source.

Change-Id: I968df97239a86834c96126b86832d3d6d0875a53
parent db50037e
......@@ -19,6 +19,7 @@
#include "vpx/internal/vpx_psnr.h"
#include "vpx_ports/mem.h"
#include "vpx_ports/vpx_timer.h"
#include "vpx_scale/vpx_scale.h"
#include "vp9/common/vp9_alloccommon.h"
#include "vp9/common/vp9_filter.h"
......@@ -3140,12 +3141,27 @@ static void encode_without_recode_loop(VP9_COMP *cpi) {
set_frame_size(cpi);
cpi->Source = vp9_scale_if_required(cm, cpi->un_scaled_source,
&cpi->scaled_source);
if (cpi->unscaled_last_source != NULL)
cpi->Last_Source = vp9_scale_if_required(cm, cpi->unscaled_last_source,
&cpi->scaled_last_source);
// For 1 pass CBR under dynamic resize mode: use faster scaling for source.
// Only for 2x2 scaling for now.
if (cpi->oxcf.pass == 0 &&
cpi->oxcf.rc_mode == VPX_CBR &&
cpi->oxcf.resize_mode == RESIZE_DYNAMIC &&
cpi->resize_scale_num == 1 &&
cpi->resize_scale_den == 2) {
cpi->Source = vp9_scale_if_required_fast(cm,
cpi->un_scaled_source,
&cpi->scaled_source);
if (cpi->unscaled_last_source != NULL)
cpi->Last_Source = vp9_scale_if_required_fast(cm,
cpi->unscaled_last_source,
&cpi->scaled_last_source);
} else {
cpi->Source = vp9_scale_if_required(cm, cpi->un_scaled_source,
&cpi->scaled_source);
if (cpi->unscaled_last_source != NULL)
cpi->Last_Source = vp9_scale_if_required(cm, cpi->unscaled_last_source,
&cpi->scaled_last_source);
}
if (frame_is_intra_only(cm) == 0) {
vp9_scale_references(cpi);
......@@ -3491,6 +3507,21 @@ static void set_ext_overrides(VP9_COMP *cpi) {
}
}
YV12_BUFFER_CONFIG *vp9_scale_if_required_fast(VP9_COMMON *cm,
YV12_BUFFER_CONFIG *unscaled,
YV12_BUFFER_CONFIG *scaled) {
if (cm->mi_cols * MI_SIZE != unscaled->y_width ||
cm->mi_rows * MI_SIZE != unscaled->y_height) {
// For 2x2 scaling down.
vpx_scale_frame(unscaled, scaled, unscaled->y_buffer, 9, 2, 1,
2, 1, 0);
vp9_extend_frame_borders(scaled);
return scaled;
} else {
return unscaled;
}
}
YV12_BUFFER_CONFIG *vp9_scale_if_required(VP9_COMMON *cm,
YV12_BUFFER_CONFIG *unscaled,
YV12_BUFFER_CONFIG *scaled) {
......
......@@ -614,6 +614,10 @@ 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_scale_if_required_fast(VP9_COMMON *cm,
YV12_BUFFER_CONFIG *unscaled,
YV12_BUFFER_CONFIG *scaled);
YV12_BUFFER_CONFIG *vp9_scale_if_required(VP9_COMMON *cm,
YV12_BUFFER_CONFIG *unscaled,
YV12_BUFFER_CONFIG *scaled);
......
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