summaryrefslogtreecommitdiff
path: root/vp9
diff options
context:
space:
mode:
Diffstat (limited to 'vp9')
-rw-r--r--vp9/encoder/vp9_firstpass.c71
-rw-r--r--vp9/encoder/vp9_onyx_if.c4
-rw-r--r--vp9/encoder/vp9_temporal_filter.c71
-rw-r--r--vp9/encoder/vp9_temporal_filter.h2
4 files changed, 73 insertions, 75 deletions
diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c
index cda3b5d6d..e4e7b9a4e 100644
--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -1447,77 +1447,6 @@ static int calc_arf_boost(
return arf_boost;
}
-void configure_arnr_filter(VP9_COMP *cpi, const unsigned int this_frame,
- int group_boost) {
- int half_gf_int;
- int frames_after_arf;
- int frames_bwd = cpi->oxcf.arnr_max_frames - 1;
- int frames_fwd = cpi->oxcf.arnr_max_frames - 1;
- int q;
-
- // Define the arnr filter width for this group of frames:
- // We only filter frames that lie within a distance of half
- // the GF interval from the ARF frame. We also have to trap
- // cases where the filter extends beyond the end of clip.
- // Note: this_frame->frame has been updated in the loop
- // so it now points at the ARF frame.
- half_gf_int = cpi->baseline_gf_interval >> 1;
- frames_after_arf = (int)(cpi->twopass.total_stats->count - this_frame - 1);
-
- switch (cpi->oxcf.arnr_type) {
- case 1: // Backward filter
- frames_fwd = 0;
- if (frames_bwd > half_gf_int)
- frames_bwd = half_gf_int;
- break;
-
- case 2: // Forward filter
- if (frames_fwd > half_gf_int)
- frames_fwd = half_gf_int;
- if (frames_fwd > frames_after_arf)
- frames_fwd = frames_after_arf;
- frames_bwd = 0;
- break;
-
- case 3: // Centered filter
- default:
- frames_fwd >>= 1;
- if (frames_fwd > frames_after_arf)
- frames_fwd = frames_after_arf;
- if (frames_fwd > half_gf_int)
- frames_fwd = half_gf_int;
-
- frames_bwd = frames_fwd;
-
- // For even length filter there is one more frame backward
- // than forward: e.g. len=6 ==> bbbAff, len=7 ==> bbbAfff.
- if (frames_bwd < half_gf_int)
- frames_bwd += (cpi->oxcf.arnr_max_frames + 1) & 0x1;
- break;
- }
-
- cpi->active_arnr_frames = frames_bwd + 1 + frames_fwd;
-
- // Adjust the strength based on active max q
- q = ((int)vp9_convert_qindex_to_q(cpi->active_worst_quality) >> 1);
- if (q > 8) {
- cpi->active_arnr_strength = cpi->oxcf.arnr_strength;
- } else {
- cpi->active_arnr_strength = cpi->oxcf.arnr_strength - (8 - q);
- if (cpi->active_arnr_strength < 0)
- cpi->active_arnr_strength = 0;
- }
-
- // Adjust number of frames in filter and strength based on gf boost level.
- if (cpi->active_arnr_frames > (group_boost / 150)) {
- cpi->active_arnr_frames = (group_boost / 150);
- cpi->active_arnr_frames += !(cpi->active_arnr_frames & 1);
- }
- if (cpi->active_arnr_strength > (group_boost / 300)) {
- cpi->active_arnr_strength = (group_boost / 300);
- }
-}
-
#if CONFIG_MULTIPLE_ARF
// Work out the frame coding order for a GF or an ARF group.
// The current implementation codes frames in their natural order for a
diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c
index afc5fb51b..dc02f146e 100644
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -82,10 +82,6 @@ extern double vp9_calc_ssimg(YV12_BUFFER_CONFIG *source,
#endif
-// TODO(agrange) Move this function.
-extern void configure_arnr_filter(VP9_COMP *cpi, const unsigned int this_frame,
- int group_boost);
-
// #define OUTPUT_YUV_REC
#ifdef OUTPUT_YUV_SRC
diff --git a/vp9/encoder/vp9_temporal_filter.c b/vp9/encoder/vp9_temporal_filter.c
index 22a12f4a8..cf84fa1e5 100644
--- a/vp9/encoder/vp9_temporal_filter.c
+++ b/vp9/encoder/vp9_temporal_filter.c
@@ -482,3 +482,74 @@ void vp9_temporal_filter_prepare(VP9_COMP *cpi, int distance) {
frames_to_blur_backward,
strength);
}
+
+void configure_arnr_filter(VP9_COMP *cpi, const unsigned int this_frame,
+ const int group_boost) {
+ int half_gf_int;
+ int frames_after_arf;
+ int frames_bwd = cpi->oxcf.arnr_max_frames - 1;
+ int frames_fwd = cpi->oxcf.arnr_max_frames - 1;
+ int q;
+
+ // Define the arnr filter width for this group of frames:
+ // We only filter frames that lie within a distance of half
+ // the GF interval from the ARF frame. We also have to trap
+ // cases where the filter extends beyond the end of clip.
+ // Note: this_frame->frame has been updated in the loop
+ // so it now points at the ARF frame.
+ half_gf_int = cpi->baseline_gf_interval >> 1;
+ frames_after_arf = (int)(cpi->twopass.total_stats->count - this_frame - 1);
+
+ switch (cpi->oxcf.arnr_type) {
+ case 1: // Backward filter
+ frames_fwd = 0;
+ if (frames_bwd > half_gf_int)
+ frames_bwd = half_gf_int;
+ break;
+
+ case 2: // Forward filter
+ if (frames_fwd > half_gf_int)
+ frames_fwd = half_gf_int;
+ if (frames_fwd > frames_after_arf)
+ frames_fwd = frames_after_arf;
+ frames_bwd = 0;
+ break;
+
+ case 3: // Centered filter
+ default:
+ frames_fwd >>= 1;
+ if (frames_fwd > frames_after_arf)
+ frames_fwd = frames_after_arf;
+ if (frames_fwd > half_gf_int)
+ frames_fwd = half_gf_int;
+
+ frames_bwd = frames_fwd;
+
+ // For even length filter there is one more frame backward
+ // than forward: e.g. len=6 ==> bbbAff, len=7 ==> bbbAfff.
+ if (frames_bwd < half_gf_int)
+ frames_bwd += (cpi->oxcf.arnr_max_frames + 1) & 0x1;
+ break;
+ }
+
+ cpi->active_arnr_frames = frames_bwd + 1 + frames_fwd;
+
+ // Adjust the strength based on active max q
+ q = ((int)vp9_convert_qindex_to_q(cpi->active_worst_quality) >> 1);
+ if (q > 8) {
+ cpi->active_arnr_strength = cpi->oxcf.arnr_strength;
+ } else {
+ cpi->active_arnr_strength = cpi->oxcf.arnr_strength - (8 - q);
+ if (cpi->active_arnr_strength < 0)
+ cpi->active_arnr_strength = 0;
+ }
+
+ // Adjust number of frames in filter and strength based on gf boost level.
+ if (cpi->active_arnr_frames > (group_boost / 150)) {
+ cpi->active_arnr_frames = (group_boost / 150);
+ cpi->active_arnr_frames += !(cpi->active_arnr_frames & 1);
+ }
+ if (cpi->active_arnr_strength > (group_boost / 300)) {
+ cpi->active_arnr_strength = (group_boost / 300);
+ }
+}
diff --git a/vp9/encoder/vp9_temporal_filter.h b/vp9/encoder/vp9_temporal_filter.h
index f3ca8c616..c5f3b467e 100644
--- a/vp9/encoder/vp9_temporal_filter.h
+++ b/vp9/encoder/vp9_temporal_filter.h
@@ -12,5 +12,7 @@
#define VP9_ENCODER_VP9_TEMPORAL_FILTER_H_
void vp9_temporal_filter_prepare(VP9_COMP *cpi, int distance);
+void configure_arnr_filter(VP9_COMP *cpi, const unsigned int this_frame,
+ const int group_boost);
#endif // VP9_ENCODER_VP9_TEMPORAL_FILTER_H_