diff options
author | John Koleszar <jkoleszar@google.com> | 2011-05-13 11:18:42 -0700 |
---|---|---|
committer | Code Review <code-review@webmproject.org> | 2011-05-13 11:18:42 -0700 |
commit | eafdc5e10acd025e3587ee56bfa90894eb52d5ba (patch) | |
tree | 1cd2ea1ab1e5d40e2d5294c54b8a2a6fe652567e /vp8/encoder | |
parent | 5608c1402019314810f49ede9e5da2ec8f8d276f (diff) | |
parent | 5ed116e22044e501b87a9466da36d7f943f63563 (diff) | |
download | libvpx-eafdc5e10acd025e3587ee56bfa90894eb52d5ba.tar libvpx-eafdc5e10acd025e3587ee56bfa90894eb52d5ba.tar.gz libvpx-eafdc5e10acd025e3587ee56bfa90894eb52d5ba.tar.bz2 libvpx-eafdc5e10acd025e3587ee56bfa90894eb52d5ba.zip |
Merge "Improve framerate adaptation"
Diffstat (limited to 'vp8/encoder')
-rw-r--r-- | vp8/encoder/onyx_if.c | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c index 35f14ac55..2a7723581 100644 --- a/vp8/encoder/onyx_if.c +++ b/vp8/encoder/onyx_if.c @@ -4714,23 +4714,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; |