Ejemplo n.º 1
0
static int start_avi(Scene *scene, RenderData *rd, int rectx, int recty, ReportList *reports)
{
	int x, y;
	char name[256];
	AviFormat format;
	int quality;
	double framerate;
	
	(void)scene; /* unused */
	
	filepath_avi(name, rd);

	sframe = (rd->sfra);
	x = rectx;
	y = recty;

	quality= rd->quality;
	framerate= (double) rd->frs_sec / (double) rd->frs_sec_base;
	
	avi = MEM_mallocN (sizeof(AviMovie), "avimovie");

	/* RPW 11-21-2002 
	if (rd->imtype != AVI_FORMAT_MJPEG) format = AVI_FORMAT_AVI_RGB;
	*/
	if (rd->imtype != R_AVIJPEG ) format = AVI_FORMAT_AVI_RGB;
	else format = AVI_FORMAT_MJPEG;

	if (AVI_open_compress (name, avi, 1, format) != AVI_ERROR_NONE) {
		BKE_report(reports, RPT_ERROR, "Cannot open or start AVI movie file.");
		MEM_freeN (avi);
		avi = NULL;
		return 0;
	}
			
	AVI_set_compress_option (avi, AVI_OPTION_TYPE_MAIN, 0, AVI_OPTION_WIDTH, &x);
	AVI_set_compress_option (avi, AVI_OPTION_TYPE_MAIN, 0, AVI_OPTION_HEIGHT, &y);
	AVI_set_compress_option (avi, AVI_OPTION_TYPE_MAIN, 0, AVI_OPTION_QUALITY, &quality);		
	AVI_set_compress_option (avi, AVI_OPTION_TYPE_MAIN, 0, AVI_OPTION_FRAMERATE, &framerate);

	avi->interlace= 0;
	avi->odd_fields= 0;
/* 	avi->interlace= rd->mode & R_FIELDS; */
/* 	avi->odd_fields= (rd->mode & R_ODDFIELD)?1:0; */
	
	printf("Created avi: %s\n", name);
	return 1;
}
Ejemplo n.º 2
0
static int start_avi(void *context_v, Scene *UNUSED(scene), RenderData *rd, int rectx, int recty,
                     ReportList *reports, bool preview, const char *suffix)
{
	int x, y;
	char name[256];
	AviFormat format;
	int quality;
	double framerate;
	AviMovie *avi = context_v;

	filepath_avi(name, rd, preview, suffix);

	x = rectx;
	y = recty;

	quality = rd->im_format.quality;
	framerate = (double) rd->frs_sec / (double) rd->frs_sec_base;

	if (rd->im_format.imtype != R_IMF_IMTYPE_AVIJPEG) format = AVI_FORMAT_AVI_RGB;
	else format = AVI_FORMAT_MJPEG;

	if (AVI_open_compress(name, avi, 1, format) != AVI_ERROR_NONE) {
		BKE_report(reports, RPT_ERROR, "Cannot open or start AVI movie file");
		return 0;
	}
			
	AVI_set_compress_option(avi, AVI_OPTION_TYPE_MAIN, 0, AVI_OPTION_WIDTH, &x);
	AVI_set_compress_option(avi, AVI_OPTION_TYPE_MAIN, 0, AVI_OPTION_HEIGHT, &y);
	AVI_set_compress_option(avi, AVI_OPTION_TYPE_MAIN, 0, AVI_OPTION_QUALITY, &quality);
	AVI_set_compress_option(avi, AVI_OPTION_TYPE_MAIN, 0, AVI_OPTION_FRAMERATE, &framerate);

	avi->interlace = 0;
	avi->odd_fields = 0;
/*  avi->interlace = rd->mode & R_FIELDS; */
/*  avi->odd_fields = (rd->mode & R_ODDFIELD) ? 1 : 0; */
	
	printf("Created avi: %s\n", name);
	return 1;
}
Ejemplo n.º 3
0
static AviMovie *alloc_proxy_output_avi(
        struct anim *anim, char *filename, int width, int height,
        int quality)
{
	int x, y;
	AviFormat format;
	double framerate;
	AviMovie *avi;
	short frs_sec = 25;      /* it doesn't really matter for proxies,
	                          * but sane defaults help anyways...*/
	float frs_sec_base = 1.0;

	IMB_anim_get_fps(anim, &frs_sec, &frs_sec_base);
	
	x = width;
	y = height;

	framerate = (double) frs_sec / (double) frs_sec_base;
	
	avi = MEM_mallocN(sizeof(AviMovie), "avimovie");

	format = AVI_FORMAT_MJPEG;

	if (AVI_open_compress(filename, avi, 1, format) != AVI_ERROR_NONE) {
		MEM_freeN(avi);
		return NULL;
	}
			
	AVI_set_compress_option(avi, AVI_OPTION_TYPE_MAIN, 0, AVI_OPTION_WIDTH, &x);
	AVI_set_compress_option(avi, AVI_OPTION_TYPE_MAIN, 0, AVI_OPTION_HEIGHT, &y);
	AVI_set_compress_option(avi, AVI_OPTION_TYPE_MAIN, 0, AVI_OPTION_QUALITY, &quality);
	AVI_set_compress_option(avi, AVI_OPTION_TYPE_MAIN, 0, AVI_OPTION_FRAMERATE, &framerate);

	avi->interlace = 0;
	avi->odd_fields = 0;

	return avi;
}
Ejemplo n.º 4
0
Archivo: main.c Proyecto: Enlik/mlt
int main(int argc, char *argv[]) {

    int opt_shutter_angle = 0;
    int opt_mjpeg_quality = 100;

    int nf, i, nc, nr;
    int tfs, fps;

    vc *pos_i, *pos_h, *pos_y;

    es_ctx *es;
    rs_ctx *rs;

    opterr = 0;

    while ((i = getopt(argc, argv, "r:q:")) != -1) {

        switch (i) {

            case 'r':
                opt_shutter_angle = atoi(optarg);
                break;

            case 'q':
                opt_mjpeg_quality = atoi(optarg);
                break;

            default:
                print_help(argv);
        }
    }

    if (argc < optind + 2)
        print_help(argv);

    if (AVI_open_movie(argv[optind], &mv_in) != AVI_ERROR_NONE) {

        printf("error: can't read from %s\n", argv[optind]);
        return EXIT_FAILURE;
    }

    if (mv_in.header->Streams < 1 || mv_in.streams[0].sh.Type != AVIST_VIDEO) {

        printf("error: video stream not found on %s\n", argv[optind]);
        return EXIT_FAILURE;
    }

    if (AVI_open_compress(argv[optind + 1], &mv_out, 1, AVI_FORMAT_MJPEG) != AVI_ERROR_NONE) {

        printf("error: can't write to %s\n", argv[optind + 1]);
        return EXIT_FAILURE;
    }

    printf("status: setup\n");

    prepare_lanc_kernels();

	nc = mv_in.header->Width;
	nr = mv_in.header->Height;

    tfs = mv_in.header->TotalFrames;
    fps = 1000000 / mv_in.header->MicroSecPerFrame;

    pos_i = (vc *)malloc(tfs * sizeof(vc));
    pos_h = (vc *)malloc(tfs * sizeof(vc));

    pos_y = (vc *)malloc(nr * sizeof(vc));
    
    AVI_set_compress_option(&mv_out, AVI_OPTION_TYPE_MAIN, 0, AVI_OPTION_WIDTH, &nc);
    AVI_set_compress_option(&mv_out, AVI_OPTION_TYPE_MAIN, 0, AVI_OPTION_HEIGHT, &nr);
    AVI_set_compress_option(&mv_out, AVI_OPTION_TYPE_MAIN, 0, AVI_OPTION_FRAMERATE, &fps);
    AVI_set_compress_option(&mv_out, AVI_OPTION_TYPE_MAIN, 0, AVI_OPTION_QUALITY, &opt_mjpeg_quality);

    es = es_init(nc, nr);
    rs = rs_init(nc, nr);

    printf("status: estimating\n");

    for (nf = 0; nf < tfs; nf ++) {

        unsigned char *fr = (unsigned char *)AVI_read_frame(&mv_in, AVI_FORMAT_RGB24, nf, 0);

        pos_i[nf] = vc_add(
            nf > 0 ? pos_i[nf - 1] : vc_set(0.0, 0.0),
            es_estimate(es, fr)
            );
        
        free(fr);

        if ((nf + 1) % 10 == 0) {

            printf(".");
            fflush(stdout);
        }
    }

    printf("\nstatus: filtering\n");

    hipass(pos_i, pos_h, tfs, fps / 2);

    printf("status: resampling\n");

    for (nf = 0; nf < tfs; nf ++) {

        unsigned char *fr = (unsigned char *)AVI_read_frame(&mv_in, AVI_FORMAT_RGB24, nf, 0);

        for (i = 0; i < nr; i ++) {

            pos_y[i] = interp(
                pos_h, tfs,
                nf + (i - nr / 2.0) * opt_shutter_angle / (nr * 360.0)
                );
        }

        rs_resample(rs, fr, pos_y);

        AVI_write_frame(&mv_out, nf, AVI_FORMAT_RGB24, fr, nc * nr * 3 * sizeof(unsigned char));

        if ((nf + 1) % 10 == 0) {

            printf(".");
            fflush(stdout);
        }
    }
        
    printf("\nstatus: closing\n");

    es_free(es);
    rs_free(rs);

    free_lanc_kernels();

    AVI_close(&mv_in);
    AVI_close_compress(&mv_out);

    return EXIT_SUCCESS;
}