From df8878af00e9758ef51c4ed945a74da88f7a1c19 Mon Sep 17 00:00:00 2001 From: Mamadou DIOP Date: Thu, 10 Mar 2016 01:31:45 +0100 Subject: Add support for resolution change based on network congestion (enabled on 'tch' build only) --- tinyMEDIA/include/tinymedia/tmedia_common.h | 1 + tinyMEDIA/src/tmedia_common.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) (limited to 'tinyMEDIA') diff --git a/tinyMEDIA/include/tinymedia/tmedia_common.h b/tinyMEDIA/include/tinymedia/tmedia_common.h index e786146..5fc041e 100755 --- a/tinyMEDIA/include/tinymedia/tmedia_common.h +++ b/tinyMEDIA/include/tinymedia/tmedia_common.h @@ -263,6 +263,7 @@ TINYMEDIA_API int tmedia_get_video_quality(tmedia_bandwidth_level_t bl); TINYMEDIA_API int32_t tmedia_get_video_bandwidth_kbps(unsigned width, unsigned height, unsigned fps, unsigned motion_rank); TINYMEDIA_API int32_t tmedia_get_video_bandwidth_kbps_2(unsigned width, unsigned height, unsigned fps); TINYMEDIA_API int32_t tmedia_get_video_bandwidth_kbps_3(); +TINYMEDIA_API int32_t tmedia_get_video_motion_rank(unsigned width, unsigned height, unsigned fps, int32_t bw_kbps); #define tmedia_get_video_qscale tmedia_get_video_quality TMEDIA_END_DECLS diff --git a/tinyMEDIA/src/tmedia_common.c b/tinyMEDIA/src/tmedia_common.c index 86832e1..1f20845 100755 --- a/tinyMEDIA/src/tmedia_common.c +++ b/tinyMEDIA/src/tmedia_common.c @@ -451,4 +451,16 @@ int32_t tmedia_get_video_bandwidth_kbps_3() unsigned height = 2160; tmedia_video_get_size(tmedia_defaults_get_pref_video_size(), &width, &height); return tmedia_get_video_bandwidth_kbps(width, height, tmedia_defaults_get_video_fps(), tmedia_defaults_get_video_motion_rank()); +} + +int32_t tmedia_get_video_motion_rank(unsigned width, unsigned height, unsigned fps, int32_t bw_kbps) +{ + if (!width || !height || !fps || bw_kbps <= 0) { + TSK_DEBUG_ERROR("Invalid parameter"); + return 0; + } + else { + float mr = (bw_kbps * 1024.f) / (width * height * fps * 0.07f); + return (int32_t)(TSK_MAX(1.f, (mr + 0.5f))); + } } \ No newline at end of file -- cgit v1.1