summaryrefslogtreecommitdiff
path: root/vp8/encoder/onyx_if.c
diff options
context:
space:
mode:
authorJohn Koleszar <jkoleszar@google.com>2011-05-16 09:11:18 -0400
committerJohn Koleszar <jkoleszar@google.com>2011-05-16 09:11:37 -0400
commit11b9b14691609e53a65f04c076d4191c78d115c6 (patch)
tree14cf6e221bdc655006e402e9d5b352c07341f9e5 /vp8/encoder/onyx_if.c
parent71a0eaf33ccd7437c129a91d4e3ff829551bef1f (diff)
parenteafdc5e10acd025e3587ee56bfa90894eb52d5ba (diff)
downloadlibvpx-11b9b14691609e53a65f04c076d4191c78d115c6.tar
libvpx-11b9b14691609e53a65f04c076d4191c78d115c6.tar.gz
libvpx-11b9b14691609e53a65f04c076d4191c78d115c6.tar.bz2
libvpx-11b9b14691609e53a65f04c076d4191c78d115c6.zip
Merge remote branch 'origin/master' into experimental
Conflicts: vp8/encoder/rdopt.c Change-Id: I85275aab07625bd30bbef16a752b08b18f4451ab
Diffstat (limited to 'vp8/encoder/onyx_if.c')
-rw-r--r--vp8/encoder/onyx_if.c64
1 files changed, 52 insertions, 12 deletions
diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c
index fb442a70a..64396409d 100644
--- a/vp8/encoder/onyx_if.c
+++ b/vp8/encoder/onyx_if.c
@@ -365,6 +365,12 @@ static void dealloc_compressor_data(VP8_COMP *cpi)
vpx_free(cpi->gf_active_flags);
cpi->gf_active_flags = 0;
+ // Activity mask based per mb zbin adjustments
+ vpx_free(cpi->mb_activity_map);
+ cpi->mb_activity_map = 0;
+ vpx_free(cpi->mb_norm_activity_map);
+ cpi->mb_norm_activity_map = 0;
+
vpx_free(cpi->mb.pip);
cpi->mb.pip = 0;
@@ -1391,11 +1397,20 @@ void vp8_alloc_compressor_data(VP8_COMP *cpi)
// Structures used to minitor GF usage
- vpx_free(cpi->gf_active_flags);
+ vpx_free(cpi->gf_active_flags);
+ CHECK_MEM_ERROR(cpi->gf_active_flags,
+ vpx_calloc(1, cm->mb_rows * cm->mb_cols));
+ cpi->gf_active_count = cm->mb_rows * cm->mb_cols;
- CHECK_MEM_ERROR(cpi->gf_active_flags, vpx_calloc(1, cm->mb_rows * cm->mb_cols));
+ vpx_free(cpi->mb_activity_map);
+ CHECK_MEM_ERROR(cpi->mb_activity_map,
+ vpx_calloc(sizeof(unsigned int),
+ cm->mb_rows * cm->mb_cols));
- cpi->gf_active_count = cm->mb_rows * cm->mb_cols;
+ vpx_free(cpi->mb_norm_activity_map);
+ CHECK_MEM_ERROR(cpi->mb_norm_activity_map,
+ vpx_calloc(sizeof(unsigned int),
+ cm->mb_rows * cm->mb_cols));
#if !(CONFIG_REALTIME_ONLY)
vpx_free(cpi->total_stats);
@@ -4790,23 +4805,48 @@ int vp8_get_compressed_data(VP8_PTR ptr, unsigned int *frame_flags, unsigned lon
// adjust frame rates based on timestamps given
if (!cm->refresh_alt_ref_frame)
{
+ long long this_duration;
+ int step = 0;
+
if (cpi->source->ts_start == cpi->first_time_stamp_ever)
{
- double this_fps = 10000000.000 / (cpi->source->ts_end - cpi->source->ts_start);
-
- vp8_new_frame_rate(cpi, this_fps);
+ this_duration = cpi->source->ts_end - cpi->source->ts_start;
+ step = 1;
}
else
{
- long long nanosecs = cpi->source->ts_end
- - cpi->last_end_time_stamp_seen;
+ long long last_duration;
+
+ this_duration = cpi->source->ts_end - cpi->last_end_time_stamp_seen;
+ last_duration = cpi->last_end_time_stamp_seen
+ - cpi->last_time_stamp_seen;
+ // do a step update if the duration changes by 10%
+ if (last_duration)
+ step = ((this_duration - last_duration) * 10 / last_duration);
+ }
- if (nanosecs > 0)
+ if (this_duration)
+ {
+ if (step)
+ vp8_new_frame_rate(cpi, 10000000.0 / this_duration);
+ else
{
- double this_fps = 10000000.000 / nanosecs;
- vp8_new_frame_rate(cpi, (7 * cpi->oxcf.frame_rate + this_fps) / 8);
- }
+ double avg_duration, interval;
+ /* Average this frame's rate into the last second's average
+ * frame rate. If we haven't seen 1 second yet, then average
+ * over the whole interval seen.
+ */
+ interval = cpi->source->ts_end - cpi->first_time_stamp_ever;
+ if(interval > 10000000.0)
+ interval = 10000000;
+
+ avg_duration = 10000000.0 / cpi->oxcf.frame_rate;
+ avg_duration *= (interval - avg_duration + this_duration);
+ avg_duration /= interval;
+
+ vp8_new_frame_rate(cpi, 10000000.0 / avg_duration);
+ }
}
cpi->last_time_stamp_seen = cpi->source->ts_start;