Пример #1
0
void TComb::getFinalMasks(int lc, IScriptEnvironment *env)
{
	for (int i = 10; i <= 14; i += 2)
	{
		TCombFrame *tf = tdc->frames[tdc->getCachePos(i)];
		if (!tf->isValid[8])
		{
			if (tdc->frames[tdc->getCachePos(i - 2)]->sc ||
				tdc->frames[tdc->getCachePos(i - 0)]->sc)
			{
				for (int j = 0; j<3; ++j)
					memset(tf->msk2->GetPtr(j), 0, tf->msk2->GetPitch(j)*tf->msk2->GetHeight(j));
			}
			else
			{
				if (lc & 0x1)
				{
					andMasks(tdc->frames[tdc->getCachePos(i - 2)]->omsk,
						tdc->frames[tdc->getCachePos(i)]->omsk,
						tmpPF, 0x1, env);
					for (int j = 0; j <= 4; j += 2)
						orAndMasks(tdc->frames[tdc->getCachePos(i + j)]->omsk,
						tdc->frames[tdc->getCachePos(i + j + 2)]->omsk,
						tmpPF, 0x1, env);
					andNeighborsInPlace(tmpPF, 0x1, env);
					orAndMasks(tdc->frames[tdc->getCachePos(i - 2)]->msk1,
						tf->msk1, tmpPF, 0x1, env);
				}
				if (lc & 0x110)
				{
					or3Masks(tf->omsk,
						tdc->frames[tdc->getCachePos(i + 2)]->omsk,
						tdc->frames[tdc->getCachePos(i + 4)]->omsk,
						tmpPF, (lc & 0x110), env);
				}
				buildFinalMask(tdc->frames[tdc->getCachePos(i - 4)]->orig,
					tf->orig, tmpPF, tf->msk2, lc, env);
			}
			tf->isValid[8] = true;
		}
	}
}
Пример #2
0
PVideoFrame __stdcall CombMask::GetFrame(int n, ise_t* env)
{
    static const int planes[] = { PLANAR_Y, PLANAR_U, PLANAR_V };

    PVideoFrame src = child->GetFrame(n, env);

    PVideoFrame prev = mthresh == 0 ? PVideoFrame() 
                     : child->GetFrame(std::max(n - 1, 0), env);

    PVideoFrame dst = env->NewVideoFrame(vi, align);

    Buffer* b = buff;
    uint8_t *buffp, *tmpp;
    if (needBuff) {
        if (isPlus) {
            b = new Buffer(buffPitch, vi.height, mthresh > 0 ? 2 : 1, align,
                           isPlus, env);
        }
        buffp = b->buffp;
        tmpp = buffp + vi.height * buffPitch;
    }

    for (int p = 0; p < numPlanes; ++p) {
        const int plane = planes[p];

        const uint8_t* srcp = src->GetReadPtr(plane);
        uint8_t* dstp = dst->GetWritePtr(plane);
        const int spitch = src->GetPitch(plane);
        const int dpitch = dst->GetPitch(plane);
        const int width = src->GetRowSize(plane);
        const int height = src->GetHeight(plane);

        if (!needBuff) {
            writeCombMask(dstp, srcp, dpitch, spitch, cthresh, width, height);
            continue;
        }

        writeCombMask(buffp, srcp, buffPitch, spitch, cthresh, width, height);

        if (mthresh == 0) {
            expandMask(dstp, buffp, dpitch, buffPitch, width, height);
            continue;
        }

        writeMotionMask(tmpp, dstp, srcp, prev->GetReadPtr(plane), buffPitch,
                        dpitch, spitch, prev->GetPitch(plane), mthresh, width,
                        height);

        if (!expand) {
            andMasks(dstp, buffp, dpitch, buffPitch, width, height);
            continue;
        }

        andMasks(buffp, dstp, buffPitch, dpitch, width, height);

        expandMask(dstp, buffp, dpitch, buffPitch, width, height);
    }

    if (isPlus && needBuff) {
        delete b;
    }

    return dst;
}