aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-11-06 17:21:11 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-11-06 17:21:36 +0100
commitc96a44d0ddb063cf5c3d5b4fb2e46d3ca2309ba0 (patch)
tree89187f067277e30e8b87ab20dcbcc2b790edf1f7
parent5241f900581480030e2f2ac47010f86f7ee4f9fd (diff)
parent0a6664706168dc1049967bec311970d720581625 (diff)
downloadffmpeg-c96a44d0ddb063cf5c3d5b4fb2e46d3ca2309ba0.tar.gz
Merge commit '0a6664706168dc1049967bec311970d720581625'
* commit '0a6664706168dc1049967bec311970d720581625': mpegvideo_enc: factor out denominator and explicitly cast operands Conflicts: libavcodec/mpegvideo_enc.c See: c753b56b4d56724284dd7ed972efdb843db80f12 Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/mpegvideo_enc.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 31d2dcb8c3..27153cf6a8 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -96,41 +96,40 @@ void ff_convert_matrix(MpegEncContext *s, int (*qmat)[64],
fdsp->fdct == ff_jpeg_fdct_islow_10) {
for (i = 0; i < 64; i++) {
const int j = s->idsp.idct_permutation[i];
+ int64_t den = (int64_t) qscale * quant_matrix[j];
/* 16 <= qscale * quant_matrix[i] <= 7905
* Assume x = ff_aanscales[i] * qscale * quant_matrix[i]
* 19952 <= x <= 249205026
* (1 << 36) / 19952 >= (1 << 36) / (x) >= (1 << 36) / 249205026
* 3444240 >= (1 << 36) / (x) >= 275 */
- qmat[qscale][i] = (int)((UINT64_C(1) << QMAT_SHIFT) /
- (qscale * quant_matrix[j]));
+ qmat[qscale][i] = (int)((UINT64_C(1) << QMAT_SHIFT) / den);
}
} else if (fdsp->fdct == ff_fdct_ifast) {
for (i = 0; i < 64; i++) {
const int j = s->idsp.idct_permutation[i];
+ int64_t den = ff_aanscales[i] * (int64_t) qscale * quant_matrix[j];
/* 16 <= qscale * quant_matrix[i] <= 7905
* Assume x = ff_aanscales[i] * qscale * quant_matrix[i]
* 19952 <= x <= 249205026
* (1 << 36) / 19952 >= (1 << 36) / (x) >= (1 << 36) / 249205026
* 3444240 >= (1 << 36) / (x) >= 275 */
- qmat[qscale][i] = (int)((UINT64_C(1) << (QMAT_SHIFT + 14)) /
- (ff_aanscales[i] * (int64_t)qscale * quant_matrix[j]));
+ qmat[qscale][i] = (int)((UINT64_C(1) << (QMAT_SHIFT + 14)) / den);
}
} else {
for (i = 0; i < 64; i++) {
const int j = s->idsp.idct_permutation[i];
+ int64_t den = (int64_t) qscale * quant_matrix[j];
/* We can safely suppose that 16 <= quant_matrix[i] <= 255
* Assume x = qscale * quant_matrix[i]
* So 16 <= x <= 7905
* so (1 << 19) / 16 >= (1 << 19) / (x) >= (1 << 19) / 7905
* so 32768 >= (1 << 19) / (x) >= 67 */
- qmat[qscale][i] = (int)((UINT64_C(1) << QMAT_SHIFT) /
- (qscale * quant_matrix[j]));
+ qmat[qscale][i] = (int)((UINT64_C(1) << QMAT_SHIFT) / den);
//qmat [qscale][i] = (1 << QMAT_SHIFT_MMX) /
// (qscale * quant_matrix[i]);
- qmat16[qscale][0][i] = (1 << QMAT_SHIFT_MMX) /
- (qscale * quant_matrix[j]);
+ qmat16[qscale][0][i] = (1 << QMAT_SHIFT_MMX) / den;
if (qmat16[qscale][0][i] == 0 ||
qmat16[qscale][0][i] == 128 * 256)