Exemplo n.º 1
0
void IMB_free_anim(struct anim *anim)
{
	if (anim == NULL) {
		printf("free anim, anim == NULL\n");
		return;
	}

	free_anim_movie(anim);

#ifdef WITH_AVI
	free_anim_avi(anim);
#endif

#ifdef WITH_QUICKTIME
	free_anim_quicktime(anim);
#endif
#ifdef WITH_FFMPEG
	free_anim_ffmpeg(anim);
#endif
#ifdef WITH_REDCODE
	free_anim_redcode(anim);
#endif
	IMB_free_indices(anim);

	MEM_freeN(anim);
}
Exemplo n.º 2
0
static ImBuf *anim_getnew(struct anim *anim)
{
    struct ImBuf *ibuf = NULL;

    if (anim == NULL) return(NULL);

    free_anim_movie(anim);

#ifdef WITH_AVI
    free_anim_avi(anim);
#endif

#ifdef WITH_QUICKTIME
    free_anim_quicktime(anim);
#endif
#ifdef WITH_FFMPEG
    free_anim_ffmpeg(anim);
#endif

    if (anim->curtype != 0) return (NULL);
    anim->curtype = imb_get_anim_type(anim->name);

    switch (anim->curtype) {
    case ANIM_SEQUENCE:
        ibuf = IMB_loadiffname(anim->name, anim->ib_flags, anim->colorspace);
        if (ibuf) {
            BLI_strncpy(anim->first, anim->name, sizeof(anim->first));
            anim->duration = 1;
        }
        break;
    case ANIM_MOVIE:
        if (startmovie(anim)) return (NULL);
        ibuf = IMB_allocImBuf(anim->x, anim->y, 24, 0); /* fake */
        break;
#ifdef WITH_AVI
    case ANIM_AVI:
        if (startavi(anim)) {
            printf("couldnt start avi\n");
            return (NULL);
        }
        ibuf = IMB_allocImBuf(anim->x, anim->y, 24, 0);
        break;
#endif
#ifdef WITH_QUICKTIME
    case ANIM_QTIME:
        if (startquicktime(anim)) return (0);
        ibuf = IMB_allocImBuf(anim->x, anim->y, 24, 0);
        break;
#endif
#ifdef WITH_FFMPEG
    case ANIM_FFMPEG:
        if (startffmpeg(anim)) return (0);
        ibuf = IMB_allocImBuf(anim->x, anim->y, 24, 0);
        break;
#endif
    }
    return(ibuf);
}
Exemplo n.º 3
0
void IMB_free_anim(struct anim *anim)
{
	if (anim == NULL) {
		printf("free anim, anim == NULL\n");
		return;
	}

	free_anim_movie(anim);

#ifdef WITH_AVI
	free_anim_avi(anim);
#endif

#ifdef WITH_FFMPEG
	free_anim_ffmpeg(anim);
#endif
	IMB_free_indices(anim);

	MEM_freeN(anim);
}
Exemplo n.º 4
0
static int startavi(struct anim *anim)
{

	AviError avierror;
#if defined(_WIN32) && !defined(FREE_WINDOWS)
	HRESULT hr;
	int i, firstvideo = -1;
	int streamcount;
	BYTE abFormat[1024];
	LONG l;
	LPBITMAPINFOHEADER lpbi;
	AVISTREAMINFO avis;

	streamcount = anim->streamindex;
#endif

	anim->avi = MEM_callocN(sizeof(AviMovie), "animavi");

	if (anim->avi == NULL) {
		printf("Can't open avi: %s\n", anim->name);
		return -1;
	}

	avierror = AVI_open_movie(anim->name, anim->avi);

#if defined(_WIN32) && !defined(FREE_WINDOWS)
	if (avierror == AVI_ERROR_COMPRESSION) {
		AVIFileInit();
		hr = AVIFileOpen(&anim->pfile, anim->name, OF_READ, 0L);
		if (hr == 0) {
			anim->pfileopen = 1;
			for (i = 0; i < MAXNUMSTREAMS; i++) {
				if (AVIFileGetStream(anim->pfile, &anim->pavi[i], 0L, i) != AVIERR_OK) {
					break;
				}
				
				AVIStreamInfo(anim->pavi[i], &avis, sizeof(avis));
				if ((avis.fccType == streamtypeVIDEO) && (firstvideo == -1)) {
					if (streamcount > 0) {
						streamcount--;
						continue;
					}
					anim->pgf = AVIStreamGetFrameOpen(anim->pavi[i], NULL);
					if (anim->pgf) {
						firstvideo = i;

						/* get stream length */
						anim->avi->header->TotalFrames = AVIStreamLength(anim->pavi[i]);

						/* get information about images inside the stream */
						l = sizeof(abFormat);
						AVIStreamReadFormat(anim->pavi[i], 0, &abFormat, &l);
						lpbi = (LPBITMAPINFOHEADER)abFormat;
						anim->avi->header->Height = lpbi->biHeight;
						anim->avi->header->Width = lpbi->biWidth;
					}
					else {
						FIXCC(avis.fccHandler);
						FIXCC(avis.fccType);
						printf("Can't find AVI decoder for type : %4.4hs/%4.4hs\n",
						       (LPSTR)&avis.fccType,
						       (LPSTR)&avis.fccHandler);
					}
				}
			}

			/* register number of opened avistreams */
			anim->avistreams = i;

			/*
			 * Couldn't get any video streams out of this file
			 */
			if ((anim->avistreams == 0) || (firstvideo == -1)) {
				avierror = AVI_ERROR_FORMAT;
			}
			else {
				avierror = AVI_ERROR_NONE;
				anim->firstvideo = firstvideo;
			}
		}
		else {
			AVIFileExit();
		}
	}
#endif

	if (avierror != AVI_ERROR_NONE) {
		AVI_print_error(avierror);
		printf("Error loading avi: %s\n", anim->name);
		free_anim_avi(anim);
		return -1;
	}
	
	anim->duration = anim->avi->header->TotalFrames;
	anim->params = NULL;

	anim->x = anim->avi->header->Width;
	anim->y = anim->avi->header->Height;
	anim->interlacing = 0;
	anim->orientation = 0;
	anim->framesize = anim->x * anim->y * 4;

	anim->curposition = 0;
	anim->preseek = 0;

	/*  printf("x:%d y:%d size:%d interl:%d dur:%d\n", anim->x, anim->y, anim->framesize, anim->interlacing, anim->duration);*/

	return 0;
}