forked from FFmpeg/FFmpeg
Merge commit 'de69aedf9935631b7f78e8b8da6e460422a9bc5f'
* commit 'de69aedf9935631b7f78e8b8da6e460422a9bc5f': mathematics: K&R formatting cosmetics Conflicts: libavutil/mathematics.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
commit
bc4b424dfa
1 changed files with 54 additions and 43 deletions
|
@ -52,12 +52,16 @@ const uint8_t av_reverse[256]={
|
|||
};
|
||||
#endif
|
||||
|
||||
int64_t av_gcd(int64_t a, int64_t b){
|
||||
if(b) return av_gcd(b, a%b);
|
||||
else return a;
|
||||
int64_t av_gcd(int64_t a, int64_t b)
|
||||
{
|
||||
if (b)
|
||||
return av_gcd(b, a % b);
|
||||
else
|
||||
return a;
|
||||
}
|
||||
|
||||
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd){
|
||||
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd)
|
||||
{
|
||||
int64_t r = 0;
|
||||
av_assert2(c > 0);
|
||||
av_assert2(b >=0);
|
||||
|
@ -72,10 +76,13 @@ int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd){
|
|||
rnd -= AV_ROUND_PASS_MINMAX;
|
||||
}
|
||||
|
||||
if(a<0 && a != INT64_MIN) return -av_rescale_rnd(-a, b, c, rnd ^ ((rnd>>1)&1));
|
||||
if (a < 0 && a != INT64_MIN)
|
||||
return -av_rescale_rnd(-a, b, c, rnd ^ ((rnd >> 1) & 1));
|
||||
|
||||
if(rnd==AV_ROUND_NEAR_INF) r= c/2;
|
||||
else if(rnd&1) r= c-1;
|
||||
if (rnd == AV_ROUND_NEAR_INF)
|
||||
r = c / 2;
|
||||
else if (rnd & 1)
|
||||
r = c - 1;
|
||||
|
||||
if (b <= INT_MAX && c <= INT_MAX) {
|
||||
if (a <= INT_MAX)
|
||||
|
@ -98,10 +105,9 @@ int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd){
|
|||
a1 += a0 < r;
|
||||
|
||||
for (i = 63; i >= 0; i--) {
|
||||
// int o= a1 & 0x8000000000000000ULL;
|
||||
a1 += a1 + ((a0 >> i) & 1);
|
||||
t1 += t1;
|
||||
if(/*o || */c <= a1){
|
||||
if (c <= a1) {
|
||||
a1 -= c;
|
||||
t1++;
|
||||
}
|
||||
|
@ -118,7 +124,8 @@ int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd){
|
|||
#endif
|
||||
}
|
||||
|
||||
int64_t av_rescale(int64_t a, int64_t b, int64_t c){
|
||||
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
|
||||
{
|
||||
return av_rescale_rnd(a, b, c, AV_ROUND_NEAR_INF);
|
||||
}
|
||||
|
||||
|
@ -135,17 +142,21 @@ int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
|
|||
return av_rescale_q_rnd(a, bq, cq, AV_ROUND_NEAR_INF);
|
||||
}
|
||||
|
||||
int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b){
|
||||
int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b)
|
||||
{
|
||||
int64_t a = tb_a.num * (int64_t)tb_b.den;
|
||||
int64_t b = tb_b.num * (int64_t)tb_a.den;
|
||||
if ((FFABS(ts_a)|a|FFABS(ts_b)|b) <= INT_MAX)
|
||||
return (ts_a*a > ts_b*b) - (ts_a*a < ts_b*b);
|
||||
if (av_rescale_rnd(ts_a, a, b, AV_ROUND_DOWN) < ts_b) return -1;
|
||||
if (av_rescale_rnd(ts_b, b, a, AV_ROUND_DOWN) < ts_a) return 1;
|
||||
if (av_rescale_rnd(ts_a, a, b, AV_ROUND_DOWN) < ts_b)
|
||||
return -1;
|
||||
if (av_rescale_rnd(ts_b, b, a, AV_ROUND_DOWN) < ts_a)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int64_t av_compare_mod(uint64_t a, uint64_t b, uint64_t mod){
|
||||
int64_t av_compare_mod(uint64_t a, uint64_t b, uint64_t mod)
|
||||
{
|
||||
int64_t c = (a - b) & (mod - 1);
|
||||
if (c > (mod >> 1))
|
||||
c -= mod;
|
||||
|
|
Loading…
Add table
Reference in a new issue