示例#1
0
static void movieclip_calc_length(MovieClip *clip)
{
	if (clip->source == MCLIP_SRC_MOVIE) {
		movieclip_open_anim_file(clip);

		if (clip->anim) {
			clip->len = IMB_anim_get_duration(clip->anim, clip->proxy.tc);
		}
	}
	else if (clip->source == MCLIP_SRC_SEQUENCE) {
		unsigned short numlen;
		char name[FILE_MAX], head[FILE_MAX], tail[FILE_MAX];

		BLI_stringdec(clip->name, head, tail, &numlen);

		if (numlen == 0) {
			/* there's no number group in file name, assume it's single framed sequence */
			clip->len = 1;
		}
		else {
			clip->len = 0;
			for (;;) {
				get_sequence_fname(clip, clip->len + clip->start_frame, name);

				if (BLI_exists(name))
					clip->len++;
				else
					break;
			}
		}
	}
}
示例#2
0
static int user_frame_to_cache_frame(MovieClip *clip, int framenr)
{
	int index;

	index = framenr - clip->start_frame + clip->frame_offset;

	if (clip->source == MCLIP_SRC_SEQUENCE) {
		if (clip->cache->sequence_offset == -1) {
			unsigned short numlen;
			char head[FILE_MAX], tail[FILE_MAX];

			BLI_stringdec(clip->name, head, tail, &numlen);

			/* see comment in get_sequence_fname */
			clip->cache->sequence_offset = sequence_guess_offset(clip->name, strlen(head), numlen);
		}

		index += clip->cache->sequence_offset;
	}

	if (index < 0)
		return framenr - index;

	return framenr;
}
示例#3
0
static void get_sequence_fname(MovieClip *clip, int framenr, char *name)
{
    unsigned short numlen;
    char head[FILE_MAX], tail[FILE_MAX];
    int offset;

    BLI_strncpy(name, clip->name, sizeof(clip->name));
    BLI_stringdec(name, head, tail, &numlen);

    /* movieclips always points to first image from sequence,
     * autoguess offset for now. could be something smarter in the future */
    offset = sequence_guess_offset(clip->name, strlen(head), numlen);

    if (numlen)
        BLI_stringenc(name, head, tail, numlen, offset + framenr - 1);
    else
        BLI_strncpy(name, clip->name, sizeof(clip->name));

    BLI_path_abs(name, ID_BLEND_PATH(G.main, &clip->id));
}
示例#4
0
void BLI_newname(char *name, int add)
{
	char head[UNIQUE_NAME_MAX], tail[UNIQUE_NAME_MAX];
	int pic;
	unsigned short digits;
	
	pic = BLI_stringdec(name, head, tail, &digits);
	
	/* are we going from 100 -> 99 or from 10 -> 9 */
	if (add < 0 && digits < 4 && digits > 0) {
		int i, exp;
		exp = 1;
		for (i = digits; i > 1; i--) exp *= 10;
		if (pic >= exp && (pic + add) < exp) digits--;
	}
	
	pic += add;
	
	if (digits == 4 && pic < 0) pic = 0;
	BLI_stringenc(name, head, tail, digits, pic);
}