summaryrefslogtreecommitdiff
path: root/vp9
diff options
context:
space:
mode:
Diffstat (limited to 'vp9')
-rw-r--r--vp9/decoder/vp9_decoder.c4
-rw-r--r--vp9/decoder/vp9_decoder.h2
-rw-r--r--vp9/encoder/vp9_noise_estimate.c23
-rw-r--r--vp9/encoder/vp9_noise_estimate.h1
-rw-r--r--vp9/encoder/vp9_svc_layercontext.c3
5 files changed, 24 insertions, 9 deletions
diff --git a/vp9/decoder/vp9_decoder.c b/vp9/decoder/vp9_decoder.c
index 4e88819b1..f5da07ea0 100644
--- a/vp9/decoder/vp9_decoder.c
+++ b/vp9/decoder/vp9_decoder.c
@@ -243,7 +243,7 @@ static void swap_frame_buffers(VP9Decoder *pbi) {
decrease_ref_count(old_idx, frame_bufs, pool);
// Release the reference frame in reference map.
- if ((mask & 1) && old_idx >= 0) {
+ if (mask & 1) {
decrease_ref_count(old_idx, frame_bufs, pool);
}
cm->ref_frame_map[ref_index] = cm->next_ref_frame_map[ref_index];
@@ -350,7 +350,7 @@ int vp9_receive_compressed_data(VP9Decoder *pbi,
decrease_ref_count(old_idx, frame_bufs, pool);
// Release the reference frame in reference map.
- if ((mask & 1) && old_idx >= 0) {
+ if (mask & 1) {
decrease_ref_count(old_idx, frame_bufs, pool);
}
++ref_index;
diff --git a/vp9/decoder/vp9_decoder.h b/vp9/decoder/vp9_decoder.h
index 4a5188f8f..afa400941 100644
--- a/vp9/decoder/vp9_decoder.h
+++ b/vp9/decoder/vp9_decoder.h
@@ -128,7 +128,7 @@ void vp9_decoder_remove(struct VP9Decoder *pbi);
static INLINE void decrease_ref_count(int idx, RefCntBuffer *const frame_bufs,
BufferPool *const pool) {
- if (idx >= 0) {
+ if (idx >= 0 && frame_bufs[idx].ref_count > 0) {
--frame_bufs[idx].ref_count;
// A worker may only get a free framebuffer index when calling get_free_fb.
// But the private buffer is not set up until finish decoding header.
diff --git a/vp9/encoder/vp9_noise_estimate.c b/vp9/encoder/vp9_noise_estimate.c
index ddf081c86..b41ffd0a3 100644
--- a/vp9/encoder/vp9_noise_estimate.c
+++ b/vp9/encoder/vp9_noise_estimate.c
@@ -36,6 +36,7 @@ void vp9_noise_estimate_init(NOISE_ESTIMATE *const ne,
} else if (width * height >= 1280 * 720) {
ne->thresh = 130;
}
+ ne->num_frames_estimate = 20;
}
int enable_noise_estimation(VP9_COMP *const cpi) {
@@ -88,10 +89,9 @@ void vp9_update_noise_estimate(VP9_COMP *const cpi) {
// Estimate of noise level every frame_period frames.
int frame_period = 10;
int thresh_consec_zeromv = 8;
- unsigned int thresh_sum_diff = 128;
+ unsigned int thresh_sum_diff = 100;
unsigned int thresh_sum_spatial = (200 * 200) << 8;
unsigned int thresh_spatial_var = (32 * 32) << 8;
- int num_frames_estimate = 20;
int min_blocks_estimate = cm->mi_rows * cm->mi_cols >> 7;
// Estimate is between current source and last source.
YV12_BUFFER_CONFIG *last_source = cpi->Last_Source;
@@ -135,6 +135,17 @@ void vp9_update_noise_estimate(VP9_COMP *const cpi) {
const int uv_width_shift = y_width_shift >> 1;
const int uv_height_shift = y_height_shift >> 1;
int mi_row, mi_col;
+ int num_low_motion = 0;
+ int frame_low_motion = 1;
+ for (mi_row = 0; mi_row < cm->mi_rows; mi_row++) {
+ for (mi_col = 0; mi_col < cm->mi_cols; mi_col++) {
+ int bl_index = mi_row * cm->mi_cols + mi_col;
+ if (cr->consec_zero_mv[bl_index] > thresh_consec_zeromv)
+ num_low_motion++;
+ }
+ }
+ if (num_low_motion < ((3 * cm->mi_rows * cm->mi_cols) >> 3))
+ frame_low_motion = 0;
for (mi_row = 0; mi_row < cm->mi_rows; mi_row++) {
for (mi_col = 0; mi_col < cm->mi_cols; mi_col++) {
// 16x16 blocks, 1/4 sample of frame.
@@ -154,7 +165,8 @@ void vp9_update_noise_estimate(VP9_COMP *const cpi) {
const uint8_t vsource =
src_v[uv_height_shift * src_uvstride + uv_width_shift];
int is_skin = vp9_skin_pixel(ysource, usource, vsource);
- if (cr->consec_zero_mv[bl_index] > thresh_consec_zeromv &&
+ if (frame_low_motion &&
+ cr->consec_zero_mv[bl_index] > thresh_consec_zeromv &&
cr->consec_zero_mv[bl_index1] > thresh_consec_zeromv &&
cr->consec_zero_mv[bl_index2] > thresh_consec_zeromv &&
cr->consec_zero_mv[bl_index3] > thresh_consec_zeromv &&
@@ -202,10 +214,11 @@ void vp9_update_noise_estimate(VP9_COMP *const cpi) {
// Normalize.
avg_est = avg_est / num_samples;
// Update noise estimate.
- ne->value = (int)((3 * ne->value + avg_est) >> 2);
+ ne->value = (int)((15 * ne->value + avg_est) >> 4);
ne->count++;
- if (ne->count == num_frames_estimate) {
+ if (ne->count == ne->num_frames_estimate) {
// Reset counter and check noise level condition.
+ ne->num_frames_estimate = 30;
ne->count = 0;
if (ne->value > (ne->thresh << 1))
ne->level = kHigh;
diff --git a/vp9/encoder/vp9_noise_estimate.h b/vp9/encoder/vp9_noise_estimate.h
index b5dded9ef..0d22ef042 100644
--- a/vp9/encoder/vp9_noise_estimate.h
+++ b/vp9/encoder/vp9_noise_estimate.h
@@ -38,6 +38,7 @@ typedef struct noise_estimate {
int count;
int last_w;
int last_h;
+ int num_frames_estimate;
} NOISE_ESTIMATE;
struct VP9_COMP;
diff --git a/vp9/encoder/vp9_svc_layercontext.c b/vp9/encoder/vp9_svc_layercontext.c
index 1dfc45cf6..13da155c7 100644
--- a/vp9/encoder/vp9_svc_layercontext.c
+++ b/vp9/encoder/vp9_svc_layercontext.c
@@ -278,7 +278,8 @@ void vp9_restore_layer_context(VP9_COMP *const cpi) {
cpi->alt_ref_source = lc->alt_ref_source;
// Reset the frames_since_key and frames_to_key counters to their values
// before the layer restore. Keep these defined for the stream (not layer).
- if (cpi->svc.number_temporal_layers > 1) {
+ if (cpi->svc.number_temporal_layers > 1 ||
+ cpi->svc.number_spatial_layers > 1) {
cpi->rc.frames_since_key = old_frame_since_key;
cpi->rc.frames_to_key = old_frame_to_key;
}