diff options
author | Guillaume Martres <smarter3@gmail.com> | 2014-04-05 22:32:06 +0200 |
---|---|---|
committer | Guillaume Martres <smarter3@gmail.com> | 2014-04-07 18:22:08 +0200 |
commit | 0ec5919d4202c6e99b31cf707c7125536498f1f4 (patch) | |
tree | fd27980b94056a59b6d1966289c43010e9c14d40 /vp9 | |
parent | ded9e191445c599f4fcc5d75ccf26a8b4c33532e (diff) | |
download | libvpx-0ec5919d4202c6e99b31cf707c7125536498f1f4.tar libvpx-0ec5919d4202c6e99b31cf707c7125536498f1f4.tar.gz libvpx-0ec5919d4202c6e99b31cf707c7125536498f1f4.tar.bz2 libvpx-0ec5919d4202c6e99b31cf707c7125536498f1f4.zip |
Replace imprecise 32 bits calculations by 64 bits calculations
Change-Id: If1b0a2d6603ce24f5dd99855e8dfe459e7a2835a
Diffstat (limited to 'vp9')
-rw-r--r-- | vp9/encoder/vp9_firstpass.c | 4 | ||||
-rw-r--r-- | vp9/encoder/vp9_ratectrl.c | 13 |
2 files changed, 4 insertions, 13 deletions
diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c index f4ec7cb65..fe1f2c5fa 100644 --- a/vp9/encoder/vp9_firstpass.c +++ b/vp9/encoder/vp9_firstpass.c @@ -917,9 +917,7 @@ int vp9_twopass_worst_quality(VP9_COMP *cpi, FIRSTPASS_STATS *fpstats, return rc->worst_quality; // Highest value allowed target_norm_bits_per_mb = - section_target_bandwitdh < (1 << 20) - ? (section_target_bandwitdh << BPER_MB_NORMBITS) / num_mbs - : (section_target_bandwitdh / num_mbs) << BPER_MB_NORMBITS; + ((uint64_t)section_target_bandwitdh << BPER_MB_NORMBITS) / num_mbs; // Try and pick a max Q that will be high enough to encode the // content at the given rate. diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c index 86de99ede..26e89addf 100644 --- a/vp9/encoder/vp9_ratectrl.c +++ b/vp9/encoder/vp9_ratectrl.c @@ -152,11 +152,7 @@ static int estimate_bits_at_q(int frame_kind, int q, int mbs, double correction_factor) { const int bpm = (int)(vp9_rc_bits_per_mb(frame_kind, q, correction_factor)); - // Attempt to retain reasonable accuracy without overflow. The cutoff is - // chosen such that the maximum product of Bpm and MBs fits 31 bits. The - // largest Bpm takes 20 bits. - return (mbs > (1 << 11)) ? (bpm >> BPER_MB_NORMBITS) * mbs - : (bpm * mbs) >> BPER_MB_NORMBITS; + return ((uint64_t)bpm * mbs) >> BPER_MB_NORMBITS; } int vp9_rc_clamp_pframe_target_size(const VP9_COMP *const cpi, int target) { @@ -368,11 +364,8 @@ int vp9_rc_regulate_q(const VP9_COMP *cpi, int target_bits_per_frame, // Calculate required scaling factor based on target frame size and size of // frame produced using previous Q. - if (target_bits_per_frame >= (INT_MAX >> BPER_MB_NORMBITS)) - // Case where we would overflow int - target_bits_per_mb = (target_bits_per_frame / cm->MBs) << BPER_MB_NORMBITS; - else - target_bits_per_mb = (target_bits_per_frame << BPER_MB_NORMBITS) / cm->MBs; + target_bits_per_mb = + ((uint64_t)target_bits_per_frame << BPER_MB_NORMBITS) / cm->MBs; i = active_best_quality; |