if(a<0) 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));
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd){    AVInteger ai;    int64_t r=0;    assert(c > 0);    assert(b >=0);    assert(rnd >=0 && rnd<=5 && rnd!=4);        if(a<0) 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(b<=INT_MAX && c<=INT_MAX){        if(a<=INT_MAX)            return (a * b + r)/c;        else            return a/c*b + (a%c*b + r)/c;    }        ai= av_mul_i(av_int2i(a), av_int2i(b));    ai= av_add_i(ai, av_int2i(r));        return av_i2int(av_div_i(ai, av_int2i(c)));}