[FFmpeg-devel] dv_guess_dct_mode

Roman V. Shaposhnik rvs
Tue Feb 3 23:17:24 CET 2009


Guys,

the function dv_guess_dct_mode is used by DV codec to figure
out whether the material is interlaced or not. Long time ago
it was thought that we might eventually make such functionality
part of dsputils. My brief look through the current state of dsputils,
however, suggests that we don't have anything like that there yet.

And now that I have to put a very similar code there for DVCPRO HD
this begs the questions -- what would be the way to generalize it?

Currently it only deals with a 8x8 blocks, but for DVCPRO HD it would
have to deal with an entire frame, so... should I leave the special
8x8 version alone and introduce add a generalized one to the DV codec,
should it all somehow be moved to dsputils.

Comments are welcome.

Thanks,
Roman.

P.S. And, for your convenience, here's the text of dv_guess_dct_mode:

//FIXME replace this by dsputil
#define SC(x, y) ((s[x] - s[y]) ^ ((s[x] - s[y]) >> 7))
static av_always_inline int dv_guess_dct_mode(DCTELEM *blk) {
    DCTELEM *s;
    int score88  = 0;
    int score248 = 0;
    int i;

    /* Compute 8-8 score (small values give a better chance for 8-8 DCT) */
    s = blk;
    for (i = 0; i < 7; i++) {
        score88 += SC(0,  8) + SC(1, 9) + SC(2, 10) + SC(3, 11) +
                   SC(4, 12) + SC(5,13) + SC(6, 14) + SC(7, 15);
        s += 8;
    }
    /* Compute 2-4-8 score (small values give a better chance for 2-4-8 DCT) */
    s = blk;
    for (i = 0; i < 6; i++) {
        score248 += SC(0, 16) + SC(1,17) + SC(2, 18) + SC(3, 19) +
                    SC(4, 20) + SC(5,21) + SC(6, 22) + SC(7, 23);
        s += 8;
    }

    return (score88 - score248 > -10);
}






More information about the ffmpeg-devel mailing list