void assign_values(int month, int day, int *number_direct_coefficients)
{
	int hour1;
	double st; /* solar time */
	double sd;
	double alt2_rise, alt2_set;
	sd = sdec(jdate(month, day));
	alt2_rise = f_salt(sd, radians(2.0));
	alt2_set = 24 - f_salt(sd, radians(2.0));
	for (hour1 = 0; hour1< 24; hour1++){
		st = hour1;
		if (((hour1 - 0.5)<alt2_rise) && ((hour1 + 0.5) > alt2_rise)){ st = alt2_rise; }
		if (((hour1 - 0.5)<alt2_set) && ((hour1 + 0.5) > alt2_set)){ st = alt2_set; }

		if (degrees(salt(sd, st)) > 1.999){
			direct_pts[*number_direct_coefficients][0] = (float)st;
			direct_pts[*number_direct_coefficients][1] = (float)degrees(salt(sd, st));
			if (direct_pts[*number_direct_coefficients][1] <2.001){ direct_pts[*number_direct_coefficients][1] = 2; }
			direct_pts[*number_direct_coefficients][2] = (float)degrees(sazi(sd, st));
			direct_calendar[month][hour1][0] = direct_pts[*number_direct_coefficients][0];
			direct_calendar[month][hour1][1] = direct_pts[*number_direct_coefficients][1];
			direct_calendar[month][hour1][2] = direct_pts[*number_direct_coefficients][2];
			*number_direct_coefficients = *number_direct_coefficients + 1;
		}
		else{
			direct_calendar[month][hour1][0] = (float)st;
			direct_calendar[month][hour1][1] = (float)degrees(salt(sd, st));
			direct_calendar[month][hour1][2] = (float)degrees(sazi(sd, st));
		}
	}
}
Пример #2
0
void testsymbit()
{
	std::string const fn = "mem://tmp";

	uint64_t const n = 16*1024+37;
	libmaus2::autoarray::AutoArray<libmaus2::huffman::SymBit> ASC(n);

	for ( uint64_t i = 0; i < n; ++i )
	{
		ASC[i].sbit = libmaus2::random::Random::rand64() % 2;
	}
	for ( uint64_t i = 0; i < n; )
	{
		uint64_t const z = libmaus2::random::Random::rand64() % 64;
		uint64_t const zz = std::min(n-i,z);

		// ASC[i].cnt = zz;

		i += zz;
	}
	for ( uint64_t i = 0; i < n; )
	{
		uint64_t const z = libmaus2::random::Random::rand64() % 64;
		uint64_t const zz = std::min(n-i,z);
		uint64_t const sym = libmaus2::random::Random::rand64() % 31;

		for ( uint64_t j = 0; j < zz; ++j )
			ASC[i++].sym = sym;
	}

	libmaus2::huffman::SymBitEncoderStd::unique_ptr_type senc(new libmaus2::huffman::SymBitEncoderStd(fn,512));
	for ( uint64_t i = 0; i < n; ++i )
		senc->encode(ASC[i]);
	senc.reset();

	assert ( libmaus2::huffman::SymBitDecoder::getLength(fn) == n );

	for ( uint64_t j = 0; j < n; ++j )
	{
		libmaus2::huffman::SymBitDecoder sdec(std::vector<std::string>(1,fn),j,1 /* numthreads */);
		libmaus2::huffman::SymBit SC;
		uint64_t i = 0;
		for ( ; sdec.decode(SC); ++i )
		{
			// std::cerr << SC.sym << "," << SC.cnt << "," << SC.sbit << std::endl;
			assert ( SC == ASC[i+j] );
		}
		assert ( i+j == n );
	}
}
Пример #3
0
void EntradaFitxer::crea(int k, GstElement *pipeline, QString nom_fitxer)
{
    //Elements de font d'entrada de fitxer
    QString sbin("bin_font%1"),  ssource("source_%1"), sdec("decoder%1"), svolumen_m("volumen_mix%1"), squeue("audio_queue%1");
    QString saconv("audio_conv_%1"), sabin("bin_audio_%1"), sconv("video_conv_%1"), ssink("video_sink_%1");

    //Creem entrada de fitxer i el decodebin, els afegim al pipeline i els linkem.
    bin_font = gst_bin_new ((char*)sbin.arg(k).toStdString().c_str());

    source = gst_element_factory_make ("filesrc",   (char*)ssource.arg(k).toStdString().c_str());
    dec = gst_element_factory_make ("decodebin2",   (char*)sdec.arg(k).toStdString().c_str());

    //Comprovem que s'han pogut crear tots els elements d'entrada
    if(!bin_font || !source || !dec){
      g_printerr ("Un dels elements de l'entrada de fitxer no s'ha pogut crear. Sortint.\n");
    }

    g_signal_connect (dec, "new-decoded-pad", G_CALLBACK (cb_newpad_audio), this);
    g_signal_connect (dec, "new-decoded-pad", G_CALLBACK (cb_newpad_video), this);
    gst_bin_add_many (GST_BIN (bin_font), source, dec, NULL);
    gst_element_link (source, dec);

    //Creem l'entrada d'àudio
    a.bin = gst_bin_new ((char*)sabin.arg(k).toStdString().c_str());
    conv_audio =    gst_element_factory_make("audioconvert",    (char*)saconv.arg(k).toStdString().c_str());
    audiopad =      gst_element_get_static_pad (conv_audio, "sink");
    a.queue_mix=    gst_element_factory_make("queue2",          (char*)squeue.arg(k).toStdString().c_str());
    a.volume_mix =  gst_element_factory_make("volume",          (char*)svolumen_m.arg(k).toStdString().c_str());

    //Comprovem que s'han pogut crear tots els elements d'entrada
    if(!a.bin || !conv_audio || !audiopad || !a.queue_mix || !a.volume_mix){
      g_printerr ("Un dels elements de l'entrada de fitxer d'àudio no s'ha pogut crear. Sortint.\n");
    }

    gst_bin_add_many (GST_BIN (a.bin), conv_audio, a.queue_mix, a.volume_mix, NULL);
    gst_element_link_many (conv_audio, a.queue_mix, a.volume_mix, NULL);
    gst_element_add_pad (a.bin, gst_ghost_pad_new ("sink", audiopad));
    gst_object_unref (audiopad);
    gst_bin_add (GST_BIN (bin_font), a.bin);

    //Creem l'entrada de vídeo
    v.creacomuns(k,"video_fitxer");
    v.creatransformadors(k);
    conv_video =    gst_element_factory_make ("ffmpegcolorspace",   (char*)sconv.arg(k).toStdString().c_str());
    videopad =      gst_element_get_static_pad (conv_video,         "sink");
    v.sink =        gst_element_factory_make ("xvimagesink",        (char*)ssink.arg(k).toStdString().c_str());

    //Comprovem que s'han pogut crear tots els elements d'entrada
    if( !videopad || !conv_video || !v.sink){
      g_printerr ("Un dels elements de l'entrada de fitxer de vídeo no s'ha pogut crear. Sortint.\n");
    }

    gst_bin_add_many (GST_BIN (v.bin), conv_video, v.tee, v.queue, v.scale, v.sink, v.queue_mix, v.color_conv, v.scale_mix, NULL);
    gst_element_link_many (conv_video, v.tee, v.queue, v.scale, v.sink, NULL);
    gst_element_add_pad (v.bin, gst_ghost_pad_new ("sink", videopad));
    gst_object_unref (videopad);
    gst_bin_add (GST_BIN (bin_font), v.bin);

    //Seleccionem el fitxer d'entrada
    const char *c_nom_fitxer = nom_fitxer.toStdString().c_str();
    g_object_set (G_OBJECT (source), "location", c_nom_fitxer, NULL);
    gst_element_set_state(v.sink, GST_STATE_READY);

    //Afegim el bin_video_pgm al pipeline
    gst_bin_add (GST_BIN (pipeline),bin_font);
}