static int create_RGB_list(JNIEnv *e, struct v4l4j_device *d,
		jobject formats, jmethodID add_method, jclass format_class,
		jmethodID format_ctor ){
	int i, j;
	struct device_info *di = d->vdev->info;
	int v4l4j_rgb24_conv_formats[] = RGB24_CONVERTIBLE_FORMATS;

	dprint(LOG_V4L4J, "[V4L4J] Creating RGB encodable format list\n");

	/* Populates the RGBformats list*/

	for(i=0; i<di->nb_palettes; i++){
		if(di->palettes[i].index==RGB24 && !di->palettes[i].raw_palettes){
			//if there is native RGB24 format, add it
			dprint(LOG_V4L4J,
					"[V4L4J] Found native RGB24 format - adding it to list\n");

			if(add_format(e,formats,add_method,format_class,
					format_ctor, RGB24, d)==-1)
				return -1;

		} else if(di->palettes[i].index==RGB24 && di->palettes[i].raw_palettes){
			//if there are libvideo-converted formats, add them
			j=-1;
			while(di->palettes[i].raw_palettes[++j]!=-1){
				dprint(LOG_V4L4J, "[V4L4J] Found libvideo-converted RGB24 "
						"format from %s format - add it\n",
						libvideo_palettes[di->palettes[i].raw_palettes[j]].name);

				if(add_format(e,formats,add_method,format_class,
						format_ctor, di->palettes[i].raw_palettes[j], d)==-1)
					return -1;
			}

		} else {
			//check if v4l4j can convert it
			for(j=0; j<ARRAY_SIZE(v4l4j_rgb24_conv_formats); j++){

				//if it is a native format AND v4l4j knows how to convert it
				if(!di->palettes[i].raw_palettes &&
						di->palettes[i].index==v4l4j_rgb24_conv_formats[j]){

					dprint(LOG_V4L4J, "[V4L4J] Found v4l4j provided RGB24 "
							"format from %s format - add it\n",
							libvideo_palettes[v4l4j_rgb24_conv_formats[j]].name);

					if(add_format(e,formats,add_method,format_class,
							format_ctor, v4l4j_rgb24_conv_formats[j], d)==-1)
						return -1;
				}
			} //end for v4l4j rgv24 convertible formats
		}
	}//end for all supported formats

	return 0;
}
Beispiel #2
0
void harddisk_image_device::device_config_complete()
{
	add_format("chd", "CHD Hard drive", "chd,hd", hd_option_spec);

	// set brief and instance name
	update_names();
}
static int create_native_list(JNIEnv *e, struct v4l4j_device *d,
		jobject formats, jmethodID add_method, jclass format_class,
		jmethodID format_ctor ){
	int i;
	struct device_info *di = d->vdev->info;

	dprint(LOG_V4L4J, "[V4L4J] Creating native format list\n");

	/* Populates the native formats list*/
	for(i=0; i<di->nb_palettes; i++){
		dprint(LOG_V4L4J, "[V4L4J] Checking format %s - index: %d - raw ? %s\n",
				libvideo_palettes[di->palettes[i].index].name,
				di->palettes[i].index,
				(!di->palettes[i].raw_palettes?"Yes-adding it":"No-skipping it")
				);

		if(!di->palettes[i].raw_palettes)
			//it is a native format, add it to the list
			if(add_format(e, formats,add_method, format_class,
					format_ctor, di->palettes[i].index,d)==-1)
				return -1;
	}

	return 0;
}
bool BatchGeom::insert_attribute( const Attribute_type att_type, const unsigned int size, const unsigned int index /*= 0*/ ){
	unsigned int i;

	for (i = 0; i < m_formats.size(); i++) {
		if (m_formats[i].att_type == att_type && m_formats[i].index == index) return false;
	}

	add_format(att_type, size, m_vertex_elements, index);

	unsigned int old_vertex_elements = m_vertex_elements - size;
	float *new_vertices = new float[m_num_vertices * m_vertex_elements];

	float *dest = new_vertices;
	float *src = m_vertices;
	for(i=0; i<m_num_vertices; ++i) {
		memcpy(dest, src, old_vertex_elements * sizeof(float) );
		memset(&dest[old_vertex_elements], 0, size * sizeof(float) );
		dest += m_vertex_elements;
		src += old_vertex_elements;
	}

	delete[] m_vertices;    
	m_vertices = new_vertices;

	return true;
}
Beispiel #5
0
void cdrom_image_device::device_config_complete()
{
	m_extension_list = "chd,cue,toc,nrg,gdi,iso,cdr";

	add_format("chdcd", "CD-ROM drive", m_extension_list, "");

	// set brief and instance name
	update_names();
}
static int create_JPEG_list(JNIEnv *e, struct v4l4j_device *d,
		jobject formats, jmethodID add_method, jclass format_class,
		jmethodID format_ctor ){
	int i, j;
	struct device_info *di = d->vdev->info;
	int jpeg_conv_formats[] = JPEG_CONVERTIBLE_FORMATS;

	dprint(LOG_V4L4J, "[V4L4J] Creating JPEG encodable format list\n");

	/* Populates the JPEGformats list*/

	for(i=0; i<di->nb_palettes; i++){
		if(di->palettes[i].index==JPEG && !di->palettes[i].raw_palettes){
			//if there is native JPEG format, add it
			dprint(LOG_V4L4J,
					"[V4L4J] Found native JPEG format - adding it to list\n");

			if(add_format(e,formats,add_method,format_class,
					format_ctor, JPEG, d)==-1)
				return -1;

		} else {
			//check if v4l4j can convert it
			for(j=0; j<ARRAY_SIZE(jpeg_conv_formats); j++){

				//if v4l4j knows how to convert it
				if(di->palettes[i].index==jpeg_conv_formats[j]){

					dprint(LOG_V4L4J, "[V4L4J] Found v4l4j-convertible JPEG "
							"format from %s format - add it\n",
							libvideo_palettes[jpeg_conv_formats[j]].name);

					if(add_format(e,formats,add_method,format_class,
							format_ctor, jpeg_conv_formats[j], d)==-1)
						return -1;
				}
			} //end for v4l4j JPEG convertible formats
		}
	}//end for all supported formats

	return 0;
}
Beispiel #7
0
/*
 * create the reader passing an optional
 * filename to help determine the most
 * likely file type.
 */
MREAD_T* mread_create(const char *filename, int options) {
  MREAD_T * mread = mm_malloc(sizeof(MREAD_T));
  memset(mread, 0, sizeof(MREAD_T));
  if (filename) mread->filename = strdup(filename);
  if (options & OPEN_MFILE) {
    if (strcmp(filename, "-") == 0) {
      mread->fp = stdin;
    } else {
      mread->fp = fopen(filename, "r");
      if (!mread->fp) die("Failed to open motif file: %s\n", filename);
    }
  }
  mread->options = options;
  mread->valid = 0;
  mread->total = 0;
  mread->pseudo_total = 0;
  mread->other_bg_src = strdup("--motif--");
  //TODO create readers of each format
  add_format(mread, "MEME XML", mxml_create, mxml_destroy, mxml_update,
      mxml_has_format_match, mxml_has_error, mxml_next_error, 
      mxml_has_motif, mxml_next_motif, mxml_get_alphabet, mxml_get_strands, 
      mxml_get_bg, mxml_motif_optional, mxml_file_optional);
  add_format(mread, "MEME HTML", mhtml_create, mhtml_destroy, mhtml_update,
      mhtml_has_format_match, mhtml_has_error, mhtml_next_error, 
      mhtml_has_motif, mhtml_next_motif, mhtml_get_alphabet, mhtml_get_strands,
      mhtml_get_bg, mhtml_motif_optional, mhtml_file_optional);
  add_format(mread, "MEME HTML+JSON", mhtml2_create, mhtml2_destroy, mhtml2_update,
      mhtml2_has_format_match, mhtml2_has_error, mhtml2_next_error, 
      mhtml2_has_motif, mhtml2_next_motif, mhtml2_get_alphabet, mhtml2_get_strands,
      mhtml2_get_bg, mhtml2_motif_optional, mhtml2_file_optional);
  add_format(mread, "MEME text", mtext_create, mtext_destroy, mtext_update,
      mtext_has_format_match, mtext_has_error, mtext_next_error, 
      mtext_has_motif, mtext_next_motif, mtext_get_alphabet, mtext_get_strands,
      mtext_get_bg, mtext_motif_optional, mtext_file_optional);
  add_format(mread, "DREME XML", dxml_create, dxml_destroy, dxml_update,
      dxml_has_format_match, dxml_has_error, dxml_next_error, 
      dxml_has_motif, dxml_next_motif, dxml_get_alphabet, dxml_get_strands,
      dxml_get_bg, dxml_motif_optional, dxml_file_optional);
  return mread;
}
static int create_YVU_list(JNIEnv *e, struct v4l4j_device *d,
		jobject formats, jmethodID add_method, jclass format_class,
		jmethodID format_ctor ){
	int i,j;
	struct device_info *di = d->vdev->info;

	dprint(LOG_V4L4J, "[V4L4J] Creating YVU encodable format list\n");

	/* Populates the YUVformats list*/

	for(i=0; i<di->nb_palettes; i++){
		if(di->palettes[i].index==YVU420 && !di->palettes[i].raw_palettes){
			//if there is native YVU420 format, add it
			dprint(LOG_V4L4J,
					"[V4L4J] Found native YVU420 format - adding it to list\n");

			if(add_format(e,formats,add_method,format_class, format_ctor,
					YVU420,d )==-1)
				return -1;

		} else if(di->palettes[i].index==YVU420 && di->palettes[i].raw_palettes){
			//if there are libvideo-converted YVU420 format, add them
			j=-1;
			while(di->palettes[i].raw_palettes[++j]!=-1){
				dprint(LOG_V4L4J, "[V4L4J] Found libvideo-converted YVU420 "
						"format from %s format - add it\n",
						libvideo_palettes[di->palettes[i].raw_palettes[j]].name);

				if(add_format(e,formats,add_method,format_class,
						format_ctor, di->palettes[i].raw_palettes[j],d)==-1)
					return -1;
			}
		}
	}

	return 0;
}
Beispiel #9
0
void legacy_floppy_image_device::device_config_complete()
{
	m_extension_list[0] = '\0';
	const struct FloppyFormat *floppy_options = m_config->formats;
	for (int i = 0; floppy_options[i].construct; i++)
	{
		// only add if creatable
		if (floppy_options[i].param_guidelines) {
			// allocate a new format and append it to the list
			add_format(floppy_options[i].name, floppy_options[i].description, floppy_options[i].extensions, floppy_options[i].param_guidelines);
		}
		image_specify_extension( m_extension_list, 256, floppy_options[i].extensions );
	}

	// set brief and instance name
	update_names();
}
Beispiel #10
0
void device_image_interface::add_format(std::string &&name, std::string &&description, std::string &&extensions, std::string &&optspec)
{
	auto format = std::make_unique<image_device_format>(std::move(name), std::move(description), std::move(extensions), std::move(optspec));
	add_format(std::move(format));
}
Beispiel #11
0
image_source_t *image_source_v4l2_open(url_parser_t *urlp)
{
    const char *path = url_parser_get_path(urlp);

    image_source_t *isrc = calloc(1, sizeof(image_source_t));
    impl_v4l2_t *impl = calloc(1, sizeof(impl_v4l2_t));

    isrc->impl_type = IMPL_TYPE;
    isrc->impl = impl;
    isrc->num_formats = num_formats;
    isrc->get_format = get_format;
    isrc->get_current_format = get_current_format;
    isrc->set_format = set_format;
    isrc->set_named_format = set_named_format;
    isrc->num_features = num_features;
    isrc->get_feature_name = get_feature_name;
    isrc->is_feature_available = is_feature_available;
    isrc->get_feature_type = get_feature_type;
    isrc->get_feature_value = get_feature_value;
    isrc->set_feature_value = set_feature_value;
    isrc->start = start;
    isrc->get_frame = get_frame;
    isrc->release_frame = release_frame;
    isrc->stop = stop;
    isrc->close = my_close;

    isrc->print_info = print_info;

    impl->path = strdup(path);

    impl->fd = open(path, O_RDWR, 0); // | O_NONBLOCK, 0);
    if (impl->fd < 0)
        goto fail;

    struct v4l2_capability cap;
    if (-1 == ioctl (impl->fd, VIDIOC_QUERYCAP, &cap)) {
        if (EINVAL == errno) {
            fprintf (stderr, "%s is not a V4L2 device\n", path);
            exit (EXIT_FAILURE);
        } else {
            perror("VIDIOC_QUERYCAP");
            goto fail;
        }
    }

    if (0) {
        struct v4l2_cropcap cropcap;
        struct v4l2_crop crop;
        memset(&crop, 0, sizeof(struct v4l2_crop));
        memset(&cropcap, 0, sizeof(struct v4l2_cropcap));

        cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        if (0 == ioctl (impl->fd, VIDIOC_CROPCAP, &cropcap)) {
            crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
            crop.c = cropcap.defrect; /* reset to default */

            if (-1 == ioctl (impl->fd, VIDIOC_S_CROP, &crop)) {
                switch (errno) {
                case EINVAL:
                    // Cropping not supported.
                    break;
                default:
                    // Errors ignored.
                    break;
                }
            }
        } else {
            // Errors ignored.
        }
    }

    struct v4l2_fmtdesc fmt;
    memset (&fmt, 0, sizeof (fmt));
    fmt.index = 0;
    fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    int oldfindex = fmt.index;

    while (ioctl(impl->fd, VIDIOC_ENUM_FMT, &fmt) == 0) {
        // With some Logitech Quickcams the only way we know there are
        // no more formats is that the index gets modified under us.
        if (fmt.index != oldfindex && oldfindex != 0)
            break;

//        if (f.pixelformat == 0x32435750) { // 'PWC2'
//            cam_pixelformat = CAM_PIXEL_FORMAT_I420;
//        }

        struct v4l2_frmsizeenum framesize;
        memset (&framesize, 0, sizeof(framesize));
        framesize.index = 0;
        framesize.pixel_format = fmt.pixelformat;

        int got_frame_size = 0;

        while (ioctl(impl->fd, VIDIOC_ENUM_FRAMESIZES, &framesize) == 0) {
            int width, height;

            got_frame_size = 1;

            if (framesize.type == V4L2_FRMSIZE_TYPE_STEPWISE || framesize.type == V4L2_FRMSIZE_TYPE_CONTINUOUS) {
                width = framesize.stepwise.max_width;
                height = framesize.stepwise.max_height;
            } else {
                width = framesize.discrete.width;
                height = framesize.discrete.height;
            }

            add_format(isrc, &fmt, width, height);

            framesize.index++;
        }

        if (!got_frame_size) {
            // just add a big format. The try_fmt will correct the resolution.
            add_format(isrc, &fmt, 4096, 4096);
        }

        fmt.index++;
        oldfindex = fmt.index;
    }

    if (impl->nformats == 0) {
        printf("image_source_v4l2: camera has no image formats.\n");
    }

    int res = set_format(isrc, 0);
    if (res < 0) {
        printf("Unable to set format 0\n");
    }

    return isrc;

fail:
    free(isrc);
    free(impl);

    return NULL;
}