Commit 8493f916 authored by Todd Nguyen's avatar Todd Nguyen

Add temporal filtering/interpolation to bgsprite

- Modified temporal filter to take extra buffer parameter
- Added bilinear interpolation, can be turned on by setting
BGSPRITE_INTERPOLATION define to 1.
- Added mean filter to bgsprite for blending modes
- Bilinear interpolation is turned OFF by default
- Mean filtering turned ON by default (was previously median filtering)
- Allow for multiple references for alt_ref in encodeframe

Change-Id: Icfe9054049339d353b4befff11e96c12ca73ed4e
parent 6d6e170d
This diff is collapsed.
......@@ -5422,8 +5422,13 @@ void av1_encode_frame(AV1_COMP *cpi) {
cm->reference_mode = SINGLE_REFERENCE;
else
cm->reference_mode = REFERENCE_MODE_SELECT;
#else
#if CONFIG_BGSPRITE
(void)is_alt_ref;
if (!cpi->allow_comp_inter_inter)
#else
if (is_alt_ref || !cpi->allow_comp_inter_inter)
#endif // CONFIG_BGSPRITE
cm->reference_mode = SINGLE_REFERENCE;
else if (mode_thrs[COMPOUND_REFERENCE] > mode_thrs[SINGLE_REFERENCE] &&
mode_thrs[COMPOUND_REFERENCE] > mode_thrs[REFERENCE_MODE_SELECT] &&
......
......@@ -5529,7 +5529,11 @@ int av1_get_compressed_data(AV1_COMP *cpi, unsigned int *frame_flags,
// Do temporal filter if bgsprite not generated.
if (bgsprite_ret != 0)
#endif // CONFIG_BGSPRITE
av1_temporal_filter(cpi, arf_src_index);
av1_temporal_filter(cpi,
#if CONFIG_BGSPRITE
NULL,
#endif // CONFIG_BGSPRITE
arf_src_index);
aom_extend_frame_borders(&cpi->alt_ref_buffer);
force_src_buffer = &cpi->alt_ref_buffer;
}
......
......@@ -602,7 +602,11 @@ static void adjust_arnr_filter(AV1_COMP *cpi, int distance, int group_boost,
*arnr_strength = strength;
}
void av1_temporal_filter(AV1_COMP *cpi, int distance) {
void av1_temporal_filter(AV1_COMP *cpi,
#if CONFIG_BGSPRITE
YV12_BUFFER_CONFIG *bg,
#endif // CONFIG_BGSPRITE
int distance) {
RATE_CONTROL *const rc = &cpi->rc;
int frame;
int frames_to_blur;
......@@ -644,9 +648,18 @@ void av1_temporal_filter(AV1_COMP *cpi, int distance) {
// Setup frame pointers, NULL indicates frame not included in filter.
for (frame = 0; frame < frames_to_blur; ++frame) {
const int which_buffer = start_frame - frame;
struct lookahead_entry *buf =
av1_lookahead_peek(cpi->lookahead, which_buffer);
frames[frames_to_blur - 1 - frame] = &buf->img;
#if CONFIG_BGSPRITE
if (frame == frames_to_blur_backward && bg != NULL) {
// Insert bg into frames at ARF index.
frames[frames_to_blur - 1 - frame] = bg;
} else {
#endif // CONFIG_BGSPRITE
struct lookahead_entry *buf =
av1_lookahead_peek(cpi->lookahead, which_buffer);
frames[frames_to_blur - 1 - frame] = &buf->img;
#if CONFIG_BGSPRITE
}
#endif // CONFIG_BGSPRITE
}
if (frames_to_blur > 0) {
......
......@@ -16,7 +16,11 @@
extern "C" {
#endif
void av1_temporal_filter(AV1_COMP *cpi, int distance);
void av1_temporal_filter(AV1_COMP *cpi,
#if CONFIG_BGSPRITE
YV12_BUFFER_CONFIG *bg,
#endif // CONFIG_BGSPRITE
int distance);
#ifdef __cplusplus
} // extern "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