Esempio n. 1
0
static void put_postprocessed_frame_to_cache(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf,
                                               int flag, int postprocess_flag)
{
	MovieClipCache *cache = clip->cache;
	MovieTrackingCamera *camera = &clip->tracking.camera;

	cache->postprocessed.framenr = user->framenr;
	cache->postprocessed.flag = postprocess_flag;

	if (flag & MCLIP_USE_PROXY) {
		cache->postprocessed.proxy = rendersize_to_proxy(user, flag);
		cache->postprocessed.render_flag = user->render_flag;
	}
	else {
		cache->postprocessed.proxy = IMB_PROXY_NONE;
		cache->postprocessed.render_flag = 0;
	}

	if (need_undistortion_postprocess(user)) {
		copy_v2_v2(cache->postprocessed.principal, camera->principal);
		copy_v3_v3(&cache->postprocessed.k1, &camera->k1);
		cache->postprocessed.undistortion_used = TRUE;
	}
	else {
		cache->postprocessed.undistortion_used = FALSE;
	}

	IMB_refImBuf(ibuf);

	if (cache->postprocessed.ibuf)
		IMB_freeImBuf(cache->postprocessed.ibuf);

	cache->postprocessed.ibuf = ibuf;
}
Esempio n. 2
0
static int need_postprocessed_frame(MovieClipUser *user, int postprocess_flag)
{
	int result = postprocess_flag;

	result |= need_undistortion_postprocess(user);

	return result;
}
Esempio n. 3
0
static ImBuf *put_postprocessed_frame_to_cache(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf,
        int flag, int postprocess_flag)
{
    MovieClipCache *cache = clip->cache;
    MovieTrackingCamera *camera = &clip->tracking.camera;
    ImBuf *postproc_ibuf = NULL;

    if (cache->postprocessed.ibuf)
        IMB_freeImBuf(cache->postprocessed.ibuf);

    cache->postprocessed.framenr = user->framenr;
    cache->postprocessed.flag = postprocess_flag;

    if (flag & MCLIP_USE_PROXY) {
        cache->postprocessed.proxy = rendersize_to_proxy(user, flag);
        cache->postprocessed.render_flag = user->render_flag;
    }
    else {
        cache->postprocessed.proxy = IMB_PROXY_NONE;
        cache->postprocessed.render_flag = 0;
    }

    if (need_undistortion_postprocess(user, flag)) {
        copy_v2_v2(cache->postprocessed.principal, camera->principal);
        copy_v3_v3(&cache->postprocessed.k1, &camera->k1);
        cache->postprocessed.undistoriton_used = TRUE;
        postproc_ibuf = get_undistorted_ibuf(clip, NULL, ibuf);
    }
    else {
        cache->postprocessed.undistoriton_used = FALSE;
    }

    if (postprocess_flag) {
        int disable_red   = postprocess_flag & MOVIECLIP_DISABLE_RED,
            disable_green = postprocess_flag & MOVIECLIP_DISABLE_GREEN,
            disable_blue  = postprocess_flag & MOVIECLIP_DISABLE_BLUE,
            grayscale     = postprocess_flag & MOVIECLIP_PREVIEW_GRAYSCALE;

        if (!postproc_ibuf)
            postproc_ibuf = IMB_dupImBuf(ibuf);

        if (disable_red || disable_green || disable_blue || grayscale)
            BKE_tracking_disable_imbuf_channels(postproc_ibuf, disable_red, disable_green, disable_blue, 1);
    }

    IMB_refImBuf(postproc_ibuf);

    cache->postprocessed.ibuf = postproc_ibuf;

    if (cache->stabilized.ibuf) {
        /* force stable buffer be re-calculated */
        IMB_freeImBuf(cache->stabilized.ibuf);
        cache->stabilized.ibuf = NULL;
    }

    return postproc_ibuf;
}
Esempio n. 4
0
static ImBuf *get_postprocessed_cached_frame(MovieClip *clip, MovieClipUser *user, int flag, int postprocess_flag)
{
	MovieClipCache *cache = clip->cache;
	int framenr = user->framenr;
	short proxy = IMB_PROXY_NONE;
	int render_flag = 0;

	if (flag & MCLIP_USE_PROXY) {
		proxy = rendersize_to_proxy(user, flag);
		render_flag = user->render_flag;
	}

	/* no cache or no cached postprocessed image */
	if (!clip->cache || !clip->cache->postprocessed.ibuf)
		return NULL;

	/* postprocessing happened for other frame */
	if (cache->postprocessed.framenr != framenr)
		return NULL;

	/* cached ibuf used different proxy settings */
	if (cache->postprocessed.render_flag != render_flag || cache->postprocessed.proxy != proxy)
		return NULL;

	if (cache->postprocessed.flag != postprocess_flag)
		return NULL;

	if (need_undistortion_postprocess(user)) {
		if (!check_undistortion_cache_flags(clip))
			return NULL;
	}
	else if (cache->postprocessed.undistortion_used)
		return NULL;

	IMB_refImBuf(cache->postprocessed.ibuf);

	return cache->postprocessed.ibuf;
}
Esempio n. 5
0
static ImBuf *postprocess_frame(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, int postprocess_flag)
{
	ImBuf *postproc_ibuf = NULL;

	if (need_undistortion_postprocess(user)) {
		postproc_ibuf = get_undistorted_ibuf(clip, NULL, ibuf);
	}
	else {
		postproc_ibuf = IMB_dupImBuf(ibuf);
	}

	if (postprocess_flag) {
		bool disable_red   = (postprocess_flag & MOVIECLIP_DISABLE_RED) != 0,
			 disable_green = (postprocess_flag & MOVIECLIP_DISABLE_GREEN) != 0,
			 disable_blue  = (postprocess_flag & MOVIECLIP_DISABLE_BLUE) != 0,
			 grayscale     = (postprocess_flag & MOVIECLIP_PREVIEW_GRAYSCALE) != 0;

		if (disable_red || disable_green || disable_blue || grayscale)
			BKE_tracking_disable_channels(postproc_ibuf, disable_red, disable_green, disable_blue, 1);
	}

	return postproc_ibuf;
}