summaryrefslogtreecommitdiffstats
path: root/encoder
diff options
context:
space:
mode:
authorHarish Mahendrakar <harish.mahendrakar@ittiam.com>2015-08-03 12:13:51 +0530
committerRonghua Wu <ronghuawu@google.com>2015-08-03 09:45:14 -0700
commitbb1543bd8596700ab12a5968e73a9794e26fd4de (patch)
tree6de3b790839c0f3f955b2fa49e3e8a5c5b0c0db1 /encoder
parentf73e92aff13e29f74d6280f280dd3ab4106cef92 (diff)
downloadandroid_external_libavc-bb1543bd8596700ab12a5968e73a9794e26fd4de.tar.gz
android_external_libavc-bb1543bd8596700ab12a5968e73a9794e26fd4de.tar.bz2
android_external_libavc-bb1543bd8596700ab12a5968e73a9794e26fd4de.zip
Encoder: Fixed an issue in handling FPS greater than 60
FPS > 60 was resulting in an integer overflow, so using float now. Bug: 22504214 Change-Id: I4626ba6a43167c00c42dd6440df37bd1eb1f151a
Diffstat (limited to 'encoder')
-rw-r--r--encoder/ih264e_time_stamp.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/encoder/ih264e_time_stamp.c b/encoder/ih264e_time_stamp.c
index cd829b5..85b75a3 100644
--- a/encoder/ih264e_time_stamp.c
+++ b/encoder/ih264e_time_stamp.c
@@ -84,6 +84,7 @@
#include "ih264e_structs.h"
#include "ih264e_rc_mem_interface.h"
#include "ih264e_time_stamp.h"
+#include "irc_common.h"
#include "irc_rate_control_api.h"
@@ -278,8 +279,15 @@ void ih264e_init_frame_time(frame_time_t *ps_frame_time,
* frame times increase */
WORD32 i4_gcd = gcd(u4_src_frm_rate, u4_tgt_frm_rate);
- ps_frame_time->common_time_base = (u4_src_frm_rate * u4_tgt_frm_rate)
- / i4_gcd;
+ /* Avoiding overflow by doing calculations in float */
+ number_t s_src_frm_rate, s_tgt_frm_rate, s_gcd, s_common_time_base, s_numerator;
+
+ SET_VAR_Q(s_src_frm_rate, u4_src_frm_rate, 0);
+ SET_VAR_Q(s_tgt_frm_rate, u4_tgt_frm_rate, 0);
+ SET_VAR_Q(s_gcd, i4_gcd, 0);
+ mult32_var_q(s_src_frm_rate, s_tgt_frm_rate, &s_numerator);
+ div32_var_q(s_numerator, s_gcd, &s_common_time_base);
+ number_t_to_word32(s_common_time_base, &(ps_frame_time->common_time_base));
/* The source and target increment per vop is initialized */
ps_frame_time->u4_src_frm_time_incr = ps_frame_time->common_time_base