static void flip_page (void) {
	int i, j, k;
	//FILE *fp;
	//char filename[100];
	/* do we have a free buffer? */
	for (j = 0; j < zr_count; j++) {
		zr_info_t *zr = &zr_info[j];
		/* using MJPEG_NBUFFERS here, using the real number of
		 * buffers may give sync issues (real number of buffers
		 * is always sufficient) */
		if (zr->queue-zr->synco < MJPEG_NBUFFERS) {
			zr->frame = zr->queue;
		} else {
			if (ioctl(zr->vdes, MJPIOC_SYNC, &zr->zs) < 0)
				mp_msg(MSGT_VO, MSGL_ERR, "zr: error waiting for buffers to become free\n");
			zr->frame = zr->zs.frame;
			zr->synco++;
		}
		k=0;
		for (i = 0; i < zr->fields; i++)
			k+=jpeg_enc_frame(zr->j, zr->y_data + i*zr->y_stride,
					zr->u_data + i*zr->u_stride,
					zr->v_data + i*zr->v_stride,
					zr->buf + zr->frame*zr->zrq.size+k);
		if (k > zr->zrq.size) mp_msg(MSGT_VO, MSGL_WARN, "zr: jpeg image too large for maximum buffer size. Lower the jpeg encoding\nquality or the resolution of the movie.\n");
	}
	/* Warning: Only the first jpeg image contains huffman- and
	 * quantisation tables, so don't expect files other than
	 * test0001.jpg to be readable */
	/*sprintf(filename, "test%04d.jpg", framenum);
	fp = fopen(filename, "w");
	if (!fp) exit(1);
	fwrite(buf+frame*zrq.size, 1, k, fp);
	fclose(fp);*/
	/*fp = fopen("test1.jpg", "r");
	fread(buf+frame*zrq.size, 1, 2126, fp);
	fclose(fp);*/

	for (j = 0; j < zr_count; j++) {
		zr_info_t *zr = &zr_info[j];
		if (ioctl(zr->vdes, MJPIOC_QBUF_PLAY, &zr->frame) < 0)
			mp_msg(MSGT_VO, MSGL_ERR, "zr: error queueing buffer for playback\n");
		zr->queue++;
	}

	framenum++;
	return;
}
Beispiel #2
0
/***
 * \param vf pointer to vf_instance
 * \param mpi pointer to mp_image_t structure
 * \param pts
 */
static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
	struct vf_priv_s *priv = vf->priv;
	int size = 0;
	int i;
	mp_image_t* dmpi;
	for (i = 0; i < priv->fields; i++)
		size += jpeg_enc_frame(priv->j,
				mpi->planes[0] + i*priv->y_stride,
				mpi->planes[1] + i*priv->c_stride,
				mpi->planes[2] + i*priv->c_stride,
				priv->buf + size);

	dmpi = vf_get_image(vf->next, IMGFMT_ZRMJPEGNI,
			MP_IMGTYPE_EXPORT, 0, mpi->w, mpi->h);
	dmpi->planes[0] = (uint8_t*)priv->buf;
	dmpi->planes[1] = (uint8_t*)size;
	return vf_next_put_image(vf,dmpi, pts);
}