void RequestLinear::insertCacheFrame(int pframe, IScriptEnvironment *env)
{
	RFrame *cf;
	PVideoFrame nframe;
	int first = pframe-clim+1;
	start_pos = (start_pos+1)%clim;
	if (debug)
	{
		sprintf(buf, "RequestLinear:  cache inserting frame %d\n", pframe);
		OutputDebugString(buf);
	}
	for (int i=0; i<clim; ++i)
	{
		cf = frames[getCachePos(i)];
		if (first+i == pframe && (cf->num != pframe || cf->valid != 1))
		{
			cf->data = requestFrame(mapn(first+i), env);
			cf->num = first+i;
			cf->valid = 1;
		}
		else if (cf->num != first+i)
		{
			cf->data = nframe; // force release
			cf->num = first+i;
			cf->valid = 0;
		}
	}
}
Example #2
0
PVideoFrame __stdcall TComb::GetFrame(int n, IScriptEnvironment *env)
{
	tdc->resetCacheStart(n - 10, n + 10);
	int lc = mode == 2 ? 0x111 : (mode == 1 ? 0x110 : 0x1);
	for (int i = -10; i <= 10; ++i)
	{
		if (tdc->frames[tdc->getCachePos(10 + i)]->fnum != n + i)
			insertFrame(child->GetFrame(mapn(n + i), env), 10 + i, n + i, lc, env);
	}
	if (mode == 0 || mode == 2)
		buildDiffMasks(0x1, env);
	getAverages(lc, env);
	buildOscillationMasks(lc, env);
	getFinalMasks(lc, env);
	buildFinalFrame(
		tdc->frames[tdc->getCachePos(6)]->orig,
		tdc->frames[tdc->getCachePos(8)]->orig,
		tdc->frames[tdc->getCachePos(10)]->orig,
		tdc->frames[tdc->getCachePos(12)]->orig,
		tdc->frames[tdc->getCachePos(14)]->orig,
		tdc->frames[tdc->getCachePos(10)]->msk2,
		tdc->frames[tdc->getCachePos(12)]->msk2,
		tdc->frames[tdc->getCachePos(14)]->msk2,
		dstPF, lc, env);
	PVideoFrame dst = env->NewVideoFrame(vi);
	dstPF->copyTo(dst, vi);
	return dst;
}
PVideoFrame __stdcall RequestLinear::GetFrame(int n, IScriptEnvironment *env)
{
	n = mapn(n);
	if (debug)
	{
		sprintf(buf, "RequestLinear:  frame %d -- last_request = %d\n", n, last_request);
		OutputDebugString(buf);
	}
	if (clim <= 0)
	{
		if (n > last_request && n-last_request <= rlim)
		{
			for (int i=last_request+1; i<n; ++i)
				requestFrame(i, env);
		}
		else if (n <= last_request && n <= rlim)
		{
			for (int i=0; i<n; ++i)
				requestFrame(i, env);
		}
		else if (rall)
		{
			int start = n > last_request ? last_request+1 : 0;
			for (int i=start; i<n; ++i)
				requestFrame(i, env);
		}
		else if (elim > 0)
		{
			for (int i=max(0,n-elim); i<n; ++i)
				requestFrame(i, env);
		}
		last_request = n;
		return requestFrame(n, env);
	}
	if (n > last_request)
	{
		if (n-last_request <= rlim || rall)
		{
			for (int i=last_request+1; i<=n; ++i)
				insertCacheFrame(i, env);
		}
		else 
		{
			clearCache(n, env);
			for (int i=max(0,n-elim); i<=n; ++i)
				insertCacheFrame(i, env);
		}
		last_request = n;
		return findCachedFrame(n, env);
	}
	if (last_request-n < clim)
		return findCachedFrame(n, env);
	if (n <= rlim || rall)
	{
		for (int i=0; i<=n; ++i)
			insertCacheFrame(i, env);
	}
	else 
	{
		clearCache(n, env);
		for (int i=max(0,n-elim); i<=n; ++i)
			insertCacheFrame(i, env);
	}
	last_request = n;
	return findCachedFrame(n, env);
}