dubhater / vapoursynth-mvtools

Motion compensation and stuff
184 stars 28 forks source link

[Cosmetic] dctmode in PlaneOfBlocks.c #31

Closed ghost closed 6 years ago

ghost commented 6 years ago

In lines 136 to 144, it is:

} else if (pob->dctmode == 5) { // dct SAD (SATD)
    sad = pob->SATD(pob->pSrc[0], pob->nSrcPitch[0], pRef0, pob->nRefPitch[0]);
} else if (pob->dctmode == 6) { //  globally (lumaChange) weighted spatial and DCT (better estimate)
    sad = pob->SAD(pob->pSrc[0], pob->nSrcPitch[0], pRef0, pob->nRefPitch[0]);
    if (pob->dctweight16 > 0) {
        int64_t dctsad = pob->SATD(pob->pSrc[0], pob->nSrcPitch[0], pRef0, pob->nRefPitch[0]);
        sad = (sad * (16 - pob->dctweight16) + dctsad * pob->dctweight16) / 16;

Should "dctmode == 5" and "dctmode == 6" be separated like the other DCT modes?

dubhater commented 6 years ago

I don't know what you mean.

ghost commented 6 years ago

https://github.com/dubhater/vapoursynth-mvtools/blob/master/src/PlaneOfBlocks.c

Between DCT 7 & 8

} else if (pob->dctmode == 7) { // per block adaptive switched from spatial to equal mixed SAD (faster?)
    pob->refLuma = pob->LUMA(pRef0, pob->nRefPitch[0]);
    sad = pob->SAD(pob->pSrc[0], pob->nSrcPitch[0], pRef0, pob->nRefPitch[0]);
    if (abs(pob->srcLuma - pob->refLuma) > (pob->srcLuma + pob->refLuma) >> 5) {
        int64_t dctsad = pob->SATD(pob->pSrc[0], pob->nSrcPitch[0], pRef0, pob->nRefPitch[0]);
        sad = sad / 2 + dctsad / 2;
    }
} else if (pob->dctmode == 8) { //  per block adaptive switched from spatial to mixed SAD with more weight of DCT (faster?)
    pob->refLuma = pob->LUMA(pRef0, pob->nRefPitch[0]);
    sad = pob->SAD(pob->pSrc[0], pob->nSrcPitch[0], pRef0, pob->nRefPitch[0]);
    if (abs(pob->srcLuma - pob->refLuma) > (pob->srcLuma + pob->refLuma) >> 5) {
        int64_t dctsad = pob->SATD(pob->pSrc[0], pob->nSrcPitch[0], pRef0, pob->nRefPitch[0]);
        sad = sad / 4 + dctsad / 2 + dctsad / 4;

Between 5 & 6

} else if (pob->dctmode == 5) { // dct SAD (SATD)
    sad = pob->SATD(pob->pSrc[0], pob->nSrcPitch[0], pRef0, pob->nRefPitch[0]);
} else if (pob->dctmode == 6) { //  globally (lumaChange) weighted spatial and DCT (better estimate)
    sad = pob->SAD(pob->pSrc[0], pob->nSrcPitch[0], pRef0, pob->nRefPitch[0]);
    if (pob->dctweight16 > 0) {
        int64_t dctsad = pob->SATD(pob->pSrc[0], pob->nSrcPitch[0], pRef0, pob->nRefPitch[0]);
        sad = (sad * (16 - pob->dctweight16) + dctsad * pob->dctweight16) / 16;

Shouldn't there be a bracket that separates between mode 5 & 6?

dubhater commented 6 years ago

Ah, I see. No, that bracket is not cosmetic. It doesn't separate modes 7 and 8, it ends the code block started by the bracket at the end of the "if" statement three lines above.

if (abs...) { // block starts here
    ...
    ...
} // block ends here