{aq_variance,firstpass,ratectrl}.c: quiet -Wshorten warnings

ported from libvpx:

Added casts to remove warnings:

In regards to the safety of these casts they are of two types:-

- Normalized bits per (16x16) MB stored in a 32 bit int (This is safe as
  bits per MB even with << 9 normalization cant overflow 32 bits. Even
  raw 12 bits hdr source even would only be  29 bits :- (4+4+12+9) and
  the encoder imposes much stricter limits than this on max bit rate.

- Cast as part of variance calculations.  There is an internal cast up
  to 64 bit for the Sum X Sum calculation, but after normalization
  dividing by the number of points the result will always be <= the SSE
  value.

BUG=aomedia:445

Change-Id: I4e700236ed83d6b2b1955e92e84c3b1978b9eaa0
This commit is contained in:
James Zern 2017-04-20 15:48:47 -07:00
Родитель 0c45941443
Коммит be0bdd8cfb
3 изменённых файлов: 8 добавлений и 7 удалений

Просмотреть файл

@ -169,8 +169,8 @@ static unsigned int block_variance(const AV1_COMP *const cpi, MACROBLOCK *x,
aq_variance(x->plane[0].src.buf, x->plane[0].src.stride, av1_all_zeros, 0,
bw, bh, &sse, &avg);
#endif // CONFIG_HIGHBITDEPTH
var = sse - (((int64_t)avg * avg) / (bw * bh));
return ((uint64_t)var * 256) / (bw * bh);
var = sse - (unsigned int)(((int64_t)avg * avg) / (bw * bh));
return (unsigned int)((uint64_t)var * 256) / (bw * bh);
} else {
#if CONFIG_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
@ -185,7 +185,7 @@ static unsigned int block_variance(const AV1_COMP *const cpi, MACROBLOCK *x,
var = cpi->fn_ptr[bs].vf(x->plane[0].src.buf, x->plane[0].src.stride,
av1_all_zeros, 0, &sse);
#endif // CONFIG_HIGHBITDEPTH
return ((uint64_t)var * 256) >> num_pels_log2_lookup[bs];
return (unsigned int)((uint64_t)var * 256) >> num_pels_log2_lookup[bs];
}
}

Просмотреть файл

@ -1186,7 +1186,8 @@ static int get_twopass_worst_quality(const AV1_COMP *cpi,
const double speed_term = 1.0 + 0.04 * oxcf->speed;
double ediv_size_correction;
const int target_norm_bits_per_mb =
((uint64_t)section_target_bandwidth << BPER_MB_NORMBITS) / active_mbs;
(int)((uint64_t)section_target_bandwidth << BPER_MB_NORMBITS) /
active_mbs;
int q;
// Larger image formats are expected to be a little harder to code

Просмотреть файл

@ -494,7 +494,7 @@ int av1_rc_regulate_q(const AV1_COMP *cpi, int target_bits_per_frame,
// Calculate required scaling factor based on target frame size and size of
// frame produced using previous Q.
target_bits_per_mb =
((uint64_t)target_bits_per_frame << BPER_MB_NORMBITS) / cm->MBs;
(int)((uint64_t)target_bits_per_frame << BPER_MB_NORMBITS) / cm->MBs;
i = active_best_quality;
@ -1165,8 +1165,8 @@ void av1_rc_set_frame_target(AV1_COMP *cpi, int target) {
rate_thresh_mult[rc->frame_size_selector]);
// Target rate per SB64 (including partial SB64s.
rc->sb64_target_rate =
((int64_t)rc->this_frame_target * 64 * 64) / (cm->width * cm->height);
rc->sb64_target_rate = (int)((int64_t)rc->this_frame_target * 64 * 64) /
(cm->width * cm->height);
}
static void update_alt_ref_frame_stats(AV1_COMP *cpi) {