diff options
Diffstat (limited to 'tinyMEDIA')
-rwxr-xr-x | tinyMEDIA/include/tinymedia/tmedia_common.h | 1 | ||||
-rwxr-xr-x | tinyMEDIA/src/tmedia_common.c | 12 |
2 files changed, 13 insertions, 0 deletions
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 |