Пример #1
0
static void
new_decoded_pad (GstElement * dec, GstPad * new_pad, gboolean last,
    AppInfo * info)
{
  const gchar *sname;
  GstElement *csp, *scale, *filter;
  GstStructure *s;
  GstCaps *caps;
  GstPad *sinkpad;

  /* already found a video stream? */
  if (info->got_video)
    return;

  /* FIXME: is this racy or does decodebin2 make sure caps are always
   * negotiated at this point? */
  caps = gst_pad_get_caps (new_pad);
  g_return_if_fail (caps != NULL);

  s = gst_caps_get_structure (caps, 0);
  sname = gst_structure_get_name (s);
  if (!g_str_has_prefix (sname, "video/x-raw-"))
    goto not_video;

  csp = create_element ("ffmpegcolorspace");
  scale = create_element ("videoscale");
  filter = create_element ("capsfilter");
  info->sink = create_element ("gdkpixbufsink");
  g_object_set (info->sink, "qos", FALSE, "max-lateness", (gint64) - 1, NULL);

  gst_bin_add_many (GST_BIN (info->pipe), csp, scale, filter, info->sink, NULL);

  sinkpad = gst_element_get_static_pad (csp, "sink");
  if (GST_PAD_LINK_FAILED (gst_pad_link (new_pad, sinkpad)))
    g_error ("Can't link new decoded pad to ffmpegcolorspace's sink pad");
  gst_object_unref (sinkpad);

  if (!gst_element_link (csp, scale))
    g_error ("Can't link ffmpegcolorspace to videoscale");
  if (!gst_element_link (scale, filter))
    g_error ("Can't link videoscale to capsfilter");
  if (!gst_element_link (filter, info->sink))
    g_error ("Can't link capsfilter to gdkpixbufsink");

  gst_element_set_state (info->sink, GST_STATE_PAUSED);
  gst_element_set_state (filter, GST_STATE_PAUSED);
  gst_element_set_state (scale, GST_STATE_PAUSED);
  gst_element_set_state (csp, GST_STATE_PAUSED);

  info->got_video = TRUE;
  return;

not_video:
  {
    if (last) {
      g_error ("This file does not contain a video track, or you do not have "
          "the necessary decoder(s) installed");
    }
  }
}
static gboolean
create_pipeline (AppInfo * info, const gchar * filename)
{
  GstElement *src, *dec;
  GstBus *bus;

  info->pipe = gst_pipeline_new ("pipeline");
  src = create_element ("filesrc");
  g_object_set (src, "location", filename, NULL);

  dec = create_element ("decodebin");

  gst_bin_add_many (GST_BIN (info->pipe), src, dec, NULL);
  if (!gst_element_link (src, dec))
    g_error ("Can't link filesrc to decodebin");

  g_signal_connect (dec, "pad-added", G_CALLBACK (new_decoded_pad), info);

  g_signal_connect (dec, "no-more-pads", G_CALLBACK (no_more_pads), info);

  /* set up bus */
  bus = gst_element_get_bus (info->pipe);
  gst_bus_add_signal_watch (bus);
  g_signal_connect (bus, "message", G_CALLBACK (bus_message_cb), info);
  gst_object_unref (bus);

  return TRUE;
}
Пример #3
0
void odf_conversion_context::start_presentation()
{
	create_object();
	create_element(L"office", L"presentation", objects_.back().content, this, true);

	create_element(L"office", L"scripts", objects_.back().scripts, this);
}
Пример #4
0
style_text_properties * odf_lists_styles_context::get_text_properties()
{
	if (lists_format_array_.empty()) return NULL;
	if (lists_format_array_.back().elements.empty()) return NULL;
	
	text_list_level_style_number *style_number_ = dynamic_cast<text_list_level_style_number *>(lists_format_array_.back().elements.back().get());
	text_list_level_style_bullet *style_bullet_ = dynamic_cast<text_list_level_style_bullet *>(lists_format_array_.back().elements.back().get());
	text_list_level_style_image  *style_image_  = dynamic_cast<text_list_level_style_image  *>(lists_format_array_.back().elements.back().get());

	style_text_properties *props = NULL;
	if (style_number_)
	{
 		if (!style_number_->style_text_properties_)
			create_element(L"style", L"text-properties", style_number_->style_text_properties_, odf_context_);

		props = dynamic_cast<style_text_properties *>(style_number_->style_text_properties_.get());    
	}
	if (style_bullet_)
	{
 		if (!style_bullet_->style_text_properties_)
			create_element(L"style", L"text-properties", style_bullet_->style_text_properties_, odf_context_);

		props =  dynamic_cast<style_text_properties *>(style_bullet_->style_text_properties_.get());    
	}
	if (style_image_)
	{
 		if (!style_image_->style_list_level_properties_)
			create_element(L"style", L"list-level-properties",style_image_->style_list_level_properties_,odf_context_);

		props =  dynamic_cast<style_text_properties *>(style_image_->style_text_properties_.get());    
	}
	return props;
}
Пример #5
0
int stream2scene(FILE* stream,element_t element,element_t light){
	char ch;
	scalar *data,*color,*ptr;
	color=ALLOC_SCALAR(4);
	color[0]=0.0; color[1]=0.0; color[2]=0.0; color[3]=0.0;
	ch=fgetc(stream);
	while(ch!=EOF){
		switch(ch){
			case 'T': /* triangle */
				data=ALLOC_SCALAR(12);
				data=fill_data(stream,data,9);
				ptr=data+3; EXP3(ptr,-,data,ptr) /* B-A */
				ptr=data+6; EXP3(ptr,-,data,ptr) /* C-A */
				cross(data+3,data+6,data+9); /* compute normal */
				normalize(data+9,data+9);
				/* append to current element list */
				element->next=create_element();
				element=element->next;
				element->type=TRIANGLE;
				element->data=data;
				element->color=color;
				break;
			case 'S': /* sphere */
				data=ALLOC_SCALAR(4);
				data=fill_data(stream,data,4);
				/* append to current element list */
				element->next=create_element();
				element=element->next;
				element->type=SPHERE;
				element->data=data;
				element->color=color;
				break;
			case 'L': /* light */
				data=ALLOC_SCALAR(4);
				data=fill_data(stream,data,4);
				if(data[3]==0) { normalize(data,data);} /* if a parallel light source*/
				/* append to current light list */
				light->next=create_element();
				light=light->next;
				light->type=LIGHT;
				light->data=data;
				light->color=color;
				break;
			case 'C': /* if color, then update the current color */
				color=ALLOC_SCALAR(4);
				color=fill_data(stream,color,3);
				break;
			default:
				break;
		}
		while(((ch=fgetc(stream))!=EOF)&&!isprint(ch)); /* goto nextvalid character */
	}
	return 0;
}
Пример #6
0
Projectile *create_projectile_p(Projectile **dest, Texture *tex, complex pos, Color *clr,
							    ProjDRule draw, ProjRule rule, complex a1, complex a2, complex a3, complex a4) {
	Projectile *p, *e, **d;
	
	for(e = *dest; e && e->next; e = e->next)
		if(e->prev && tex->w*tex->h > e->tex->w*e->tex->h)
			break;
		
	if(e == NULL)
		d = dest;
	else
		d = &e;
		
	p = create_element((void **)d, sizeof(Projectile));
	
	p->birthtime = global.frames;
	p->pos = pos;
	p->pos0 = pos;
	p->angle = M_PI/2;
	p->rule = rule;
	p->draw = draw;
	p->tex = tex;
	p->type = FairyProj;
	p->clr = clr;
	p->grazed = 0;
	
	p->args[0] = a1;
	p->args[1] = a2;
	p->args[2] = a3;
	p->args[3] = a4;
	
	return p;
}
Пример #7
0
rise::element* rise::document::create_root_node()
{
    auto *el = xmlpp::Document::create_root_node("svg");
    auto *node = el->cobj();
    delete el;
    return create_element("svg", node); 
}
Пример #8
0
mxml_node * node_identify( void * doc, const mxml_char_t * str, parsing_context *ctx )
{	
	mxml_node * doc_node = (mxml_node *)doc;
	mxml_node * ident_node = NULL;

	UNUSED_ARG( ctx );

	if ( !doc_node )
		return NULL;
	
	if ( is_declaration ( str ) )
		ident_node = create_declaration( doc_node );
	else if ( is_comment( str ) )
		ident_node = create_comment( doc_node );
	else if ( is_unknown( str ) )
		ident_node = create_unknown( doc_node );
	else if ( is_element( str ) )
		ident_node = create_element( XML_T(""), doc_node );
	else if ( is_text( str ) )
		ident_node = create_text( doc_node );
	else 
		ident_node = create_unknown( doc_node );

	return ident_node;
}
Пример #9
0
Laser *create_laser(complex pos, float time, float deathtime, Color *color, LaserPosRule prule, LaserLogicRule lrule, complex a0, complex a1, complex a2, complex a3) {
	Laser *l = create_element((void **)&global.lasers, sizeof(Laser));
		
	l->birthtime = global.frames;
	l->timespan = time;
	l->deathtime = deathtime;
	l->pos = pos;
	l->color = color;
	
	l->args[0] = a0;	
	l->args[1] = a1;
	l->args[2] = a2;
	l->args[3] = a3;
	
	l->prule = prule;
	l->lrule = lrule;
	
	l->shader = NULL;
	l->collision_step = 5;
	l->width = 10;
	l->speed = 1;
	l->timeshift = 0;
	
	if(l->lrule)
		l->lrule(l, EVENT_BIRTH);
	
	l->prule(l, EVENT_BIRTH);
	
	return l;
}
Пример #10
0
void QuadMeshBuilder::fill_area(unsigned xLower, unsigned xUpper, unsigned yLower, unsigned yUpper)
{
    int procCounter = 0;
    for (unsigned x = xLower; x <= xUpper; x++)
        for (unsigned y = yLower; y <= yUpper; y++)
           create_element(x, y, procCounter++%num_procs());
}
Пример #11
0
static VALUE rb_bst_insert_value(VALUE self,VALUE key,VALUE data) {
  bst_head *headNode;
  Data_Get_Struct(self,bst_head,headNode);
  insert_element(&(headNode->head),create_element(key,data));
  headNode->size++;
  return self;
}
Пример #12
0
int main(int argc, char** argv)
{
	const size_t n = 1e3;

	distribution_t distribution(0.0, 1.0);
	twister_t twister;
	generator_t g(twister, distribution);
	twister.seed(std::time(0)); // seed with the current time

	std::cout << "Building a " << tree_t::dimension << "-dimensional tree with " << n << " elements, approximately " << sizeof(tree_t) * n << " bytes" << std::endl;

	std::list<element_t> els;
	
	for(size_t i = 0; i < n; i++)
		els.emplace_back(create_element(g));
	
	std::cout << "Dataset generated" << std::endl;
	
	tree_t t = wtree_builder<tree_t::dimension>::create(els);
	
	std::cout << "Tree built" << std::endl;
	
	for(float i = 0.0; i <= 1.0; i += 0.01)
	{
		for(size_t d = 0; d < tree_t::dimension; d++)
			b[d] = {{0.0, i}};
	
		std::cout << "Currently " << wtree_counter<tree_t::dimension>::count(t, b) << " elements between 0.0 and " << i << std::endl;
	}
	
	wtree3_viewer::run(argc, argv, t);
}
Пример #13
0
void odf_lists_styles_context::start_style(bool bMaster, int based_number)
{
	list_format_state state;

	office_element_ptr elm;	
	create_element(L"text", L"list-style", elm, odf_context_);
	state.elements.push_back(elm);
	
	if (based_number < 0) 
	{
		state.oox_based_number		= lists_format_array_.size();
		state.odf_list_style_name	= std::wstring(L"L") + boost::lexical_cast<std::wstring>(state.oox_based_number + 1);
	}
	else
	{
		state.oox_based_number		= based_number;
		state.odf_list_style_name	= std::wstring(L"WWNum") + boost::lexical_cast<std::wstring>(state.oox_based_number + 1);
	}
	state.automatic	= !bMaster; 

	text_list_style *style = dynamic_cast<text_list_style *>(elm.get());
	if (style == NULL)return;

	style->text_list_style_attr_.style_name_ = state.odf_list_style_name;
	lists_format_array_.push_back(state); //перенести в end??
}
Пример #14
0
void QuadMeshBuilder::fill_area_on_proc(unsigned xLower, unsigned xUpper, unsigned yLower,
                                        unsigned yUpper, int chosenProc)
{
    for (unsigned x = xLower; x <= xUpper; x++)
        for (unsigned y = yLower; y <= yUpper; y++)
           create_element(x, y, chosenProc);
}
Пример #15
0
int main() {
	int *store=NULL, *stor=NULL, i, j, n2, n_num, k, tmp, s;
	stk=NULL;
	findex=-1;
	printf("Enter number of vertices\n");
	scanf("%d", &n);
	n2=n*n;
	stor=(int*)malloc(sizeof(int)*n2);
	vertex=(ELE*)malloc(sizeof(ELE)*n);
	finished=(int*)malloc(sizeof(int)*n);
	input=(int**)malloc(sizeof(int)*n2);
	for(i=0;i<n2;i++) {
		scanf("%d", &stor[i]);
	}
	
	for(i=0;i<n;i++) {
		input[i]=stor+n*i;
	}
	
	for(i=0;i<n;i++) {
		for(j=0;j<n;j++) {
			if(input[i][j]>0) {
				input[j][i]=1;
			}
		}
	}
	
	printf("Enter source\n");
	scanf("%d", &s);
	for(i=0;i<n;i++) {
		vertex[i]=create_element(i);
	}
	
	for(i=0;i<n;i++) {
		n_num=-1;
		store=(int*)malloc(sizeof(int)*n);
		for(j=0;j<n;j++) {
			if(input[i][j]>0) {
				store[++n_num]=j;
			}
		}
		if(n_num>-1) {
			vertex[i]->child=(ELE*)malloc(sizeof(ELE)*n_num);
			vertex[i]->n_child=n_num;
		}
		else {
			continue;
		}
		for(k=0;k<=n_num;k++) {
			tmp=store[k];
			(vertex[i]->child)[k]=vertex[tmp];
		}
		free(store);
	}
	
	depth_first(vertex[s]);
	
	return 0;
}
Пример #16
0
//insère un élément à la position indiquée
list insert(char* e, int i, list l)
{
    assert(i>=0);
    if(i == 0) return create_element(e,l);
    assert(!is_empty(l));
    l->tail = insert(e, i - 1, l->tail);
    return l;
}
Пример #17
0
void HexMeshBuilder::fill_area(unsigned xLower, unsigned xUpper, unsigned yLower, unsigned yUpper,
                               unsigned zLower, unsigned zUpper)
{
    int currentProc = 0;
    for (unsigned x = xLower; x <= xUpper; x++)
        for (unsigned y = yLower; y <= yUpper; y++)
            for (unsigned z = zLower; z <= zUpper; z++)
                create_element(x, y, z, currentProc++%num_procs());
}
KMS_END_TEST
GST_START_TEST (test_create_agnosticbin)
{
  int i;

  for (i = 0; i < iterations; i++) {
    create_element ("agnosticbin");
  }
}
Пример #19
0
void newelem_press_cb(guiObject_t *obj, const void *data)
{
    (void)obj;
    (void)data;
    //PAGE_MainLayoutExit();
    create_element();
    current_selected = 0;
    PAGE_ChangeByID(PAGEID_MAINCFG, 0);
}
Пример #20
0
void odp_conversion_context::start_slide()
{
	slide_context_.set_styles_context(styles_context());

	create_element(L"draw", L"page", root_presentation_->pages_, this);		
	slide_context_.start_page(root_presentation_->pages_.back());	
	
	drawing_context()->set_presentation(0);
}
KMS_END_TEST
GST_START_TEST (test_create_queue)
{
  int i;

  for (i = 0; i < iterations; i++) {
    create_element ("queue");
  }
}
KMS_END_TEST
GST_START_TEST (test_create_decodebin)
{
  int i;

  for (i = 0; i < iterations; i++) {
    create_element ("decodebin");
  }
}
static gboolean
create_elements (GstSplitMuxSink * splitmux)
{
  /* Create internal elements */
  if (splitmux->mq == NULL) {
    if ((splitmux->mq =
            create_element (splitmux, "multiqueue", "multiqueue")) == NULL)
      goto fail;

    splitmux->mq_max_buffers = 5;
    /* No bytes or time limit, we limit buffers manually */
    g_object_set (splitmux->mq, "max-size-bytes", 0, "max-size-time",
        (guint64) 0, "max-size-buffers", splitmux->mq_max_buffers, NULL);
  }

  if (splitmux->muxer == NULL) {
    GstElement *provided_muxer = NULL;

    GST_OBJECT_LOCK (splitmux);
    if (splitmux->provided_muxer != NULL)
      provided_muxer = gst_object_ref (splitmux->provided_muxer);
    GST_OBJECT_UNLOCK (splitmux);

    if (provided_muxer == NULL) {
      if ((splitmux->muxer =
              create_element (splitmux, "mp4mux", "muxer")) == NULL)
        goto fail;
    } else {
      if (!gst_bin_add (GST_BIN (splitmux), splitmux->provided_muxer)) {
        g_warning ("Could not add muxer element - splitmuxsink will not work");
        gst_object_unref (provided_muxer);
        goto fail;
      }

      splitmux->muxer = provided_muxer;
      gst_object_unref (provided_muxer);
    }
  }

  return TRUE;
fail:
  return FALSE;
}
Пример #24
0
void newelem_press_cb(guiObject_t *obj, const void *data)
{
    (void)obj;
    (void)data;
    int i = create_element();
    if (i >= 0) {
        draw_elements();
        select_for_move(&gui->elem[i]);
    }
}
Пример #25
0
void odf_conversion_context::process_settings(_object & object, bool isRoot)
{
	create_element(L"office", L"settings", object.settings, this, true);
	
	object.settings_context->process_office_settings(object.settings);
	
	if (isRoot)
	{	
	}
}
Пример #26
0
void odp_conversion_context::start_comment(int oox_comm_id)
{
	office_element_ptr comm_elm;
	create_element(L"office", L"annotation", comm_elm, this);

	current_slide().comment_context()->start_comment(comm_elm, oox_comm_id);
	
	current_slide().drawing_context()->start_drawing();
	current_slide().drawing_context()->start_element(comm_elm);
}
Пример #27
0
HYD_status HYDTI_bscd_ssh_store_launch_time(char *hostname)
{
    int i, oldest, time_left;
    struct timeval now;
    struct HYDT_bscd_ssh_time *e;
    HYD_status status = HYD_SUCCESS;

    for (e = HYDT_bscd_ssh_time; e; e = e->next)
        if (!strcmp(hostname, e->hostname))
            break;

    if (e == NULL) {    /* Couldn't find an element for this host */
        status = create_element(hostname, &e);
        HYDU_ERR_POP(status, "unable to create ssh time element\n");
    }

    /* Search for an unset element to store the current time */
    for (i = 0; i < HYDT_bscd_ssh_limit; i++) {
        if (e->init_time[i].tv_sec == 0 && e->init_time[i].tv_usec == 0) {
            gettimeofday(&e->init_time[i], NULL);
            goto fn_exit;
        }
    }

    /* No free element found; wait for the oldest element to turn
     * older */
    oldest = 0;
    for (i = 0; i < HYDT_bscd_ssh_limit; i++)
        if (older(e->init_time[i], e->init_time[oldest]))
            oldest = i;

    gettimeofday(&now, NULL);
    time_left = HYDT_bscd_ssh_limit_time - now.tv_sec + e->init_time[oldest].tv_sec;

    /* A better approach will be to make progress here, but that would
     * mean that we need to deal with nested calls to the demux engine
     * and process launches. */
    if (time_left > 0) {
        if (HYDT_bscd_ssh_warnings)
            HYDU_dump(stdout, "WARNING: too many ssh connections to %s; waiting %d seconds\n",
                      hostname, time_left);
        sleep(time_left);
    }

    /* Store the current time in the oldest element */
    gettimeofday(&e->init_time[oldest], NULL);

  fn_exit:
    return status;

  fn_fail:
    goto fn_exit;
}
Пример #28
0
int insert_hash_elem(hash_table_t hash,char * key,void *obj)
{
	int keyIndex = hash.hashFunc(key,hash.size);
	if (find_hash_elem(hash,keyIndex,key))
		return -1;
	hash_element_t * t = create_element(keyIndex,key,obj);
	int i =  hash.list[keyIndex].curIndex;
	hash.list[keyIndex].elems[i++] = t;
	hash.list[keyIndex].curIndex = i;

	hash.totalNum += 1;
	return 0;
}
Пример #29
0
void litehtml::document::parse_tag_start(const wchar_t* tag_name) {
     parse_pop_empty_element();

     // We add the html(root) element before parsing
     if (!wcscmp(tag_name, L"html")) {
	  return;
     }

     element::ptr el = create_element(tag_name);
     if (el) {
	  if (!wcscmp(m_parse_stack.back()->get_tagName(), L"html")) {
	       // if last element is root we have to add head or body
	       if (!value_in_list(tag_name, L"head;body")) {
		    parse_push_element(create_element(L"body"));
	       }
	  }

	  // fix <TD> and <TH>
	  if (value_in_list(tag_name, L"td;th")) {
	       if (value_in_list(m_parse_stack.back()->get_tagName(), L"th;td")) {
		    parse_pop_element();
	       }

	       if (wcscmp(m_parse_stack.back()->get_tagName(), L"tr")) {
		    parse_push_element(create_element(L"tr"));
	       }
	  }

	  // fix <TR>: add tbody into the table
	  if (!wcscmp(tag_name, L"tr")) {
	       if (!value_in_list(m_parse_stack.back()->get_tagName(),
				  L"tbody;thead;tfoot")) {
		    parse_push_element(create_element(L"tbody"));
	       }
	  }

	  parse_push_element(el);
     }
}
Пример #30
0
bool create_element(const std::wstring & Ns,
                             const std::wstring & Name,
                             office_element_ptr_array & _Elements,
                             odf_conversion_context * Context,
                             bool isRoot)
{
    office_element_ptr elm;
    if (create_element(Ns, Name, elm, Context, isRoot))
    {
        _Elements.push_back(elm);
        return true;
    }
    return false;
}