Exemplo n.º 1
0
void BKE_movieclip_reload(MovieClip *clip)
{
	/* clear cache */
	free_buffers(clip);

	clip->tracking.stabilization.ok = false;

	/* update clip source */
	detect_clip_source(clip);

	clip->lastsize[0] = clip->lastsize[1] = 0;
	movieclip_load_get_szie(clip);

	movieclip_calc_length(clip);

	/* same as for image update -- don't use notifiers because they are not 100% sure to succeeded
	 * (node trees which are not currently visible wouldn't be refreshed)
	 */
	{
		Scene *scene;
		for (scene = G.main->scene.first; scene; scene = scene->id.next) {
			if (scene->nodetree) {
				nodeUpdateID(scene->nodetree, &clip->id);
			}
		}
	}
}
Exemplo n.º 2
0
/* checks if image was already loaded, then returns same image
 * otherwise creates new.
 * does not load ibuf itself
 * pass on optional frame for #name images */
MovieClip *BKE_movieclip_file_add(const char *name)
{
    MovieClip *clip;
    MovieClipUser user = {0};
    int file, len, width, height;
    const char *libname;
    char str[FILE_MAX], strtest[FILE_MAX];

    BLI_strncpy(str, name, sizeof(str));
    BLI_path_abs(str, G.main->name);

    /* exists? */
    file = BLI_open(str, O_BINARY | O_RDONLY, 0);
    if (file == -1)
        return NULL;
    close(file);

    /* ** first search an identical clip ** */
    for (clip = G.main->movieclip.first; clip; clip = clip->id.next) {
        BLI_strncpy(strtest, clip->name, sizeof(clip->name));
        BLI_path_abs(strtest, G.main->name);

        if (strcmp(strtest, str) == 0) {
            BLI_strncpy(clip->name, name, sizeof(clip->name));  /* for stringcode */
            clip->id.us++;  /* officially should not, it doesn't link here! */

            return clip;
        }
    }

    /* ** add new movieclip ** */

    /* create a short library name */
    len = strlen(name);

    while (len > 0 && name[len - 1] != '/' && name[len - 1] != '\\')
        len--;
    libname = name + len;

    clip = movieclip_alloc(libname);
    BLI_strncpy(clip->name, name, sizeof(clip->name));

    if (BLI_testextensie_array(name, imb_ext_movie))
        clip->source = MCLIP_SRC_MOVIE;
    else
        clip->source = MCLIP_SRC_SEQUENCE;

    user.framenr = 1;
    BKE_movieclip_get_size(clip, &user, &width, &height);
    if (width && height) {
        clip->tracking.camera.principal[0] = ((float)width) / 2.0f;
        clip->tracking.camera.principal[1] = ((float)height) / 2.0f;

        clip->tracking.camera.focal = 24.0f * width / clip->tracking.camera.sensor_width;
    }

    movieclip_calc_length(clip);

    return clip;
}
Exemplo n.º 3
0
int BKE_movieclip_get_duration(MovieClip *clip)
{
	if (!clip->len) {
		movieclip_calc_length(clip);
	}

	return clip->len;
}
Exemplo n.º 4
0
/* checks if image was already loaded, then returns same image
 * otherwise creates new.
 * does not load ibuf itself
 * pass on optional frame for #name images */
MovieClip *BKE_movieclip_file_add(Main *bmain, const char *name)
{
	MovieClip *clip;
	int file, len;
	const char *libname;
	char str[FILE_MAX], strtest[FILE_MAX];

	BLI_strncpy(str, name, sizeof(str));
	BLI_path_abs(str, bmain->name);

	/* exists? */
	file = BLI_open(str, O_BINARY | O_RDONLY, 0);
	if (file == -1)
		return NULL;
	close(file);

	/* ** first search an identical clip ** */
	for (clip = bmain->movieclip.first; clip; clip = clip->id.next) {
		BLI_strncpy(strtest, clip->name, sizeof(clip->name));
		BLI_path_abs(strtest, G.main->name);

		if (strcmp(strtest, str) == 0) {
			BLI_strncpy(clip->name, name, sizeof(clip->name));  /* for stringcode */
			clip->id.us++;  /* officially should not, it doesn't link here! */

			return clip;
		}
	}

	/* ** add new movieclip ** */

	/* create a short library name */
	len = strlen(name);

	while (len > 0 && name[len - 1] != '/' && name[len - 1] != '\\')
		len--;
	libname = name + len;

	clip = movieclip_alloc(bmain, libname);
	BLI_strncpy(clip->name, name, sizeof(clip->name));

	detect_clip_source(clip);

	movieclip_load_get_szie(clip);
	if (clip->lastsize[0]) {
		int width = clip->lastsize[0];

		clip->tracking.camera.focal = 24.0f * width / clip->tracking.camera.sensor_width;
	}

	movieclip_calc_length(clip);

	return clip;
}
Exemplo n.º 5
0
void BKE_movieclip_reload(MovieClip *clip)
{
    /* clear cache */
    free_buffers(clip);

    clip->tracking.stabilization.ok = FALSE;

    /* update clip source */
    if (BLI_testextensie_array(clip->name, imb_ext_movie))
        clip->source = MCLIP_SRC_MOVIE;
    else
        clip->source = MCLIP_SRC_SEQUENCE;

    movieclip_calc_length(clip);
}