Commit 17e7b081 authored by Debargha Mukherjee's avatar Debargha Mukherjee

Miscellaneous fixes for resize/frame-superres

1. Fixes logic for disabling global motion w/ resize. Turns off
conditional write/read of global parameters since it does not
work currenlty. To be fixed later.
2. Fixes call for av1_scale_if_required in encoder_frame_with_resize
function
3. Remove asserts for the scaled convolve functions

Change-Id: I6a0f18b5ab5cc819bc27ef9fc2f28b0e391643a0
parent ec329eec
...@@ -63,7 +63,7 @@ void av1_convolve_horiz_scale(const uint8_t *src, int src_stride, uint8_t *dst, ...@@ -63,7 +63,7 @@ void av1_convolve_horiz_scale(const uint8_t *src, int src_stride, uint8_t *dst,
ConvolveParams *conv_params) { ConvolveParams *conv_params) {
int x, y; int x, y;
int filter_size = filter_params.taps; int filter_size = filter_params.taps;
assert(conv_params->round == CONVOLVE_OPT_ROUND); // assert(conv_params->round == CONVOLVE_OPT_ROUND);
src -= filter_size / 2 - 1; src -= filter_size / 2 - 1;
for (y = 0; y < h; ++y) { for (y = 0; y < h; ++y) {
int x_qn = subpel_x_qn; int x_qn = subpel_x_qn;
...@@ -128,7 +128,7 @@ void av1_convolve_vert_scale(const uint8_t *src, int src_stride, uint8_t *dst, ...@@ -128,7 +128,7 @@ void av1_convolve_vert_scale(const uint8_t *src, int src_stride, uint8_t *dst,
ConvolveParams *conv_params) { ConvolveParams *conv_params) {
int x, y; int x, y;
int filter_size = filter_params.taps; int filter_size = filter_params.taps;
assert(conv_params->round == CONVOLVE_OPT_ROUND); // assert(conv_params->round == CONVOLVE_OPT_ROUND);
src -= src_stride * (filter_size / 2 - 1); src -= src_stride * (filter_size / 2 - 1);
for (x = 0; x < w; ++x) { for (x = 0; x < w; ++x) {
int y_qn = subpel_y_qn; int y_qn = subpel_y_qn;
...@@ -226,7 +226,7 @@ void av1_convolve_horiz_facade_scale(const uint8_t *src, int src_stride, ...@@ -226,7 +226,7 @@ void av1_convolve_horiz_facade_scale(const uint8_t *src, int src_stride,
const InterpFilterParams filter_params, const InterpFilterParams filter_params,
const int subpel_x_qn, int x_step_qn, const int subpel_x_qn, int x_step_qn,
ConvolveParams *conv_params) { ConvolveParams *conv_params) {
assert(conv_params->round == CONVOLVE_OPT_ROUND); // assert(conv_params->round == CONVOLVE_OPT_ROUND);
if (filter_params.taps == SUBPEL_TAPS) { if (filter_params.taps == SUBPEL_TAPS) {
const int16_t *filter_x = av1_get_interp_filter_subpel_kernel( const int16_t *filter_x = av1_get_interp_filter_subpel_kernel(
filter_params, subpel_x_qn >> SCALE_EXTRA_BITS); filter_params, subpel_x_qn >> SCALE_EXTRA_BITS);
...@@ -292,7 +292,7 @@ void av1_convolve_vert_facade_scale(const uint8_t *src, int src_stride, ...@@ -292,7 +292,7 @@ void av1_convolve_vert_facade_scale(const uint8_t *src, int src_stride,
const InterpFilterParams filter_params, const InterpFilterParams filter_params,
const int subpel_y_qn, int y_step_qn, const int subpel_y_qn, int y_step_qn,
ConvolveParams *conv_params) { ConvolveParams *conv_params) {
assert(conv_params->round == CONVOLVE_OPT_ROUND); // assert(conv_params->round == CONVOLVE_OPT_ROUND);
if (filter_params.taps == SUBPEL_TAPS) { if (filter_params.taps == SUBPEL_TAPS) {
const int16_t *filter_y = av1_get_interp_filter_subpel_kernel( const int16_t *filter_y = av1_get_interp_filter_subpel_kernel(
filter_params, subpel_y_qn >> SCALE_EXTRA_BITS); filter_params, subpel_y_qn >> SCALE_EXTRA_BITS);
...@@ -812,7 +812,7 @@ static void convolve_scale_helper(const uint8_t *src, int src_stride, ...@@ -812,7 +812,7 @@ static void convolve_scale_helper(const uint8_t *src, int src_stride,
InterpFilterParams filter_params = InterpFilterParams filter_params =
av1_get_interp_filter_params(interp_filter); av1_get_interp_filter_params(interp_filter);
#endif #endif
assert(conv_params->round == CONVOLVE_OPT_ROUND); // assert(conv_params->round == CONVOLVE_OPT_ROUND);
assert(w <= MAX_BLOCK_WIDTH); assert(w <= MAX_BLOCK_WIDTH);
assert(h <= MAX_BLOCK_HEIGHT); assert(h <= MAX_BLOCK_HEIGHT);
......
...@@ -4957,9 +4957,15 @@ static void read_global_motion_params(WarpedMotionParams *params, ...@@ -4957,9 +4957,15 @@ static void read_global_motion_params(WarpedMotionParams *params,
static void read_global_motion(AV1_COMMON *cm, aom_reader *r) { static void read_global_motion(AV1_COMMON *cm, aom_reader *r) {
int frame; int frame;
YV12_BUFFER_CONFIG *ref_buf;
for (frame = LAST_FRAME; frame <= ALTREF_FRAME; ++frame) { for (frame = LAST_FRAME; frame <= ALTREF_FRAME; ++frame) {
ref_buf = get_ref_frame(cm, frame); read_global_motion_params(&cm->global_motion[frame],
&cm->prev_frame->global_motion[frame], r,
cm->allow_high_precision_mv);
// TODO(sarahparker, debargha): The logic in the commented out code below
// does not work currently and causes mismatches when resize is on. Fix it
// before turning the optimization back on.
/*
YV12_BUFFER_CONFIG *ref_buf = get_ref_frame(cm, frame);
if (cm->width == ref_buf->y_crop_width && if (cm->width == ref_buf->y_crop_width &&
cm->height == ref_buf->y_crop_height) { cm->height == ref_buf->y_crop_height) {
read_global_motion_params(&cm->global_motion[frame], read_global_motion_params(&cm->global_motion[frame],
...@@ -4968,6 +4974,7 @@ static void read_global_motion(AV1_COMMON *cm, aom_reader *r) { ...@@ -4968,6 +4974,7 @@ static void read_global_motion(AV1_COMMON *cm, aom_reader *r) {
} else { } else {
set_default_warp_params(&cm->global_motion[frame]); set_default_warp_params(&cm->global_motion[frame]);
} }
*/
/* /*
printf("Dec Ref %d [%d/%d]: %d %d %d %d\n", printf("Dec Ref %d [%d/%d]: %d %d %d %d\n",
frame, cm->current_video_frame, cm->show_frame, frame, cm->current_video_frame, cm->show_frame,
......
...@@ -4577,9 +4577,15 @@ static void write_global_motion_params(WarpedMotionParams *params, ...@@ -4577,9 +4577,15 @@ static void write_global_motion_params(WarpedMotionParams *params,
static void write_global_motion(AV1_COMP *cpi, aom_writer *w) { static void write_global_motion(AV1_COMP *cpi, aom_writer *w) {
AV1_COMMON *const cm = &cpi->common; AV1_COMMON *const cm = &cpi->common;
int frame; int frame;
YV12_BUFFER_CONFIG *ref_buf;
for (frame = LAST_FRAME; frame <= ALTREF_FRAME; ++frame) { for (frame = LAST_FRAME; frame <= ALTREF_FRAME; ++frame) {
ref_buf = get_ref_frame_buffer(cpi, frame); write_global_motion_params(&cm->global_motion[frame],
&cm->prev_frame->global_motion[frame], w,
cm->allow_high_precision_mv);
// TODO(sarahparker, debargha): The logic in the commented out code below
// does not work currently and causes mismatches when resize is on.
// Fix it before turning the optimization back on.
/*
YV12_BUFFER_CONFIG *ref_buf = get_ref_frame_buffer(cpi, frame);
if (cpi->source->y_crop_width == ref_buf->y_crop_width && if (cpi->source->y_crop_width == ref_buf->y_crop_width &&
cpi->source->y_crop_height == ref_buf->y_crop_height) { cpi->source->y_crop_height == ref_buf->y_crop_height) {
write_global_motion_params(&cm->global_motion[frame], write_global_motion_params(&cm->global_motion[frame],
...@@ -4589,6 +4595,7 @@ static void write_global_motion(AV1_COMP *cpi, aom_writer *w) { ...@@ -4589,6 +4595,7 @@ static void write_global_motion(AV1_COMP *cpi, aom_writer *w) {
assert(cm->global_motion[frame].wmtype == IDENTITY && assert(cm->global_motion[frame].wmtype == IDENTITY &&
"Invalid warp type for frames of different resolutions"); "Invalid warp type for frames of different resolutions");
} }
*/
/* /*
printf("Frame %d/%d: Enc Ref %d (used %d): %d %d %d %d\n", printf("Frame %d/%d: Enc Ref %d (used %d): %d %d %d %d\n",
cm->current_video_frame, cm->show_frame, frame, cm->current_video_frame, cm->show_frame, frame,
......
...@@ -5096,6 +5096,7 @@ static void encode_frame_internal(AV1_COMP *cpi) { ...@@ -5096,6 +5096,7 @@ static void encode_frame_internal(AV1_COMP *cpi) {
for (frame = LAST_FRAME; frame <= ALTREF_FRAME; ++frame) { for (frame = LAST_FRAME; frame <= ALTREF_FRAME; ++frame) {
ref_buf[frame] = get_ref_frame_buffer(cpi, frame); ref_buf[frame] = get_ref_frame_buffer(cpi, frame);
int pframe; int pframe;
set_default_warp_params(&cm->global_motion[frame]);
// check for duplicate buffer // check for duplicate buffer
for (pframe = LAST_FRAME; pframe < frame; ++pframe) { for (pframe = LAST_FRAME; pframe < frame; ++pframe) {
if (ref_buf[frame] == ref_buf[pframe]) break; if (ref_buf[frame] == ref_buf[pframe]) break;
......
...@@ -4271,11 +4271,6 @@ static void encode_with_recode_loop(AV1_COMP *cpi, size_t *size, ...@@ -4271,11 +4271,6 @@ static void encode_with_recode_loop(AV1_COMP *cpi, size_t *size,
set_size_independent_vars(cpi); set_size_independent_vars(cpi);
cpi->source =
av1_scale_if_required(cm, cpi->unscaled_source, &cpi->scaled_source);
if (cpi->unscaled_last_source != NULL)
cpi->last_source = av1_scale_if_required(cm, cpi->unscaled_last_source,
&cpi->scaled_last_source);
#if CONFIG_HIGHBITDEPTH && CONFIG_GLOBAL_MOTION #if CONFIG_HIGHBITDEPTH && CONFIG_GLOBAL_MOTION
cpi->source->buf_8bit_valid = 0; cpi->source->buf_8bit_valid = 0;
#endif #endif
...@@ -4310,6 +4305,16 @@ static void encode_with_recode_loop(AV1_COMP *cpi, size_t *size, ...@@ -4310,6 +4305,16 @@ static void encode_with_recode_loop(AV1_COMP *cpi, size_t *size,
&frame_over_shoot_limit); &frame_over_shoot_limit);
} }
cpi->source =
av1_scale_if_required(cm, cpi->unscaled_source, &cpi->scaled_source);
#if CONFIG_GLOBAL_MOTION
// if frame was scaled calculate global_motion_search again if already done
if (cpi->source != cpi->unscaled_source) cpi->global_motion_search_done = 0;
#endif // CONFIG_GLOBAL_MOTION
if (cpi->unscaled_last_source != NULL)
cpi->last_source = av1_scale_if_required(cm, cpi->unscaled_last_source,
&cpi->scaled_last_source);
if (frame_is_intra_only(cm) == 0) { if (frame_is_intra_only(cm) == 0) {
if (loop_count > 0) { if (loop_count > 0) {
release_scaled_references(cpi); release_scaled_references(cpi);
......
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