Beispiel #1
0
int main(void)
{
    unsigned u;

    for(u=0; u<65536; u++) {
        unsigned s = u*u;
        unsigned root = ff_sqrt(s);
        unsigned root_m1 = ff_sqrt(s-1);
        if (s && root != u) {
            fprintf(stderr, "ff_sqrt failed at %u with %u\n", s, root);
            return 1;
        }
        if (u && root_m1 != u - 1) {
            fprintf(stderr, "ff_sqrt failed at %u with %u\n", s, root);
            return 1;
        }
    }
    return 0;
}
Beispiel #2
0
static av_cold void roq_dpcm_table_init(void)
{
    int i;

    /* Create a table of quick DPCM values */
    for (i=0; i<MAX_DPCM; i++) {
        int s= ff_sqrt(i);
        int mid= s*s + s;
        dpcmValues[i]= s + (i>mid);
    }
}
void TquantTablesPageBase::writeMatrix(FILE *f,const char *section,const uint8_t *matrix,unsigned int len)
{
    fprintf(f,"%s =\n",section);
    int cnt=ff_sqrt(len);
    for (int i=0; i<cnt; i++) {
        for (int j=0; j<cnt; j++) {
            fprintf(f,"%i%s",int(*matrix++),--len>0?",":"");
        }
        fprintf(f,"\n");
    }
    fprintf(f,"\n");
}
Beispiel #4
0
static unsigned char dpcm_predict(short *previous, short current)
{
    int diff;
    int negative;
    int result;
    int predicted;

    diff = current - *previous;

    negative = diff<0;
    diff = FFABS(diff);

    if (diff >= MAX_DPCM)
        result = 127;
    else {
        result = ff_sqrt(diff);
        result += diff > result*result+result;
    }

    /* See if this overflows */
 retry:
    diff = result*result;
    if (negative)
        diff = -diff;
    predicted = *previous + diff;

    /* If it overflows, back off a step */
    if (predicted > 32767 || predicted < -32768) {
        result--;
        goto retry;
    }

    /* Add the sign bit */
    result |= negative << 7;   //if (negative) result |= 128;

    *previous = predicted;

    return result;
}