// This tells the PixelIop what channels to get to calculate a given
 // set of output channels. In order to calculate any color channel, it
 // needs all the color channels, because red (for instance) depends on
 // the green and blue.
 void in_channels(int input_number, ChannelSet& channels) const
 {
     // Must turn on the other color channels if any color channels are requested:
     ChannelSet done;
     foreach (z, channels) {
         if (colourIndex(z) < 3) { // it is red, green, or blue
             if (!(done & z)) { // save some time if we already turned this on
                 done.addBrothers(z, 3); // add all three to the "done" set
             }
         }
     }
     channels += done; // add the colors to the channels we need
 }
Exemplo n.º 2
0
void HttpClientHandler::MessageReceived(ChannelHandlerContext& ctx,
		MessageEvent<HTTPMessage>& e)
{
	g_recved_res++;
	g_ratio_recved_res++;
	m_request_sent = false;
	if (!g_options.keepAlive)
	{
		ctx.GetChannel()->Close();
		g_all_channels.erase(this);
	} else
	{
		g_ready_channels.insert(this);
	}
	try_send_request();
}
Exemplo n.º 3
0
void writeProgagationSection(std::ostream& out,
                             Config& config,
                             ChannelSet& channels)
{
    out << "# Propagation" << std::endl;
    for (size_t i=0; i<channels.size(); i++)
    {
        std::stringstream channel;
        channel << "[" << i << "]";
        out << config.getParameter(
            std::string("PROPAGATION-CHANNEL-FREQUENCY") + channel.str())
            << std::endl;
        out << config.getParameter(
            std::string("PROPAGATION-LIMIT") + channel.str())
            << std::endl;
        out << config.getParameter(
            std::string("PROPAGATION-PATHLOSS-MODEL") + channel.str())
            << std::endl;
        out << config.getParameter(
            std::string("PROPAGATION-SHADOWING-MODEL") + channel.str())
            << std::endl;
        out << config.getParameter(
            std::string("PROPAGATION-SHADOWING-MEAN") + channel.str())
            << std::endl;
        out << config.getParameter(
            std::string("PROPAGATION-FADING-MODEL") + channel.str())
            << std::endl;
        out << std::endl;
    }
}
Exemplo n.º 4
0
void HttpClientHandler::ChannelConnected(ChannelHandlerContext& ctx,
		ChannelStateEvent& e)
{
	m_connected = true;
	m_client = ctx.GetChannel();
	g_ready_channels.insert(this);
	try_send_request();
}
void
StatisticsFilter::LoadChannelSets( const Context& ioContext ) const
{
  typedef ChannelSetSource::ChannelSet ChannelSet;
  typedef map<string, ChannelSet> ChannelSetContainer;
  ChannelSetContainer sets;
  const SignalProperties& Input = ioContext.signal->Properties();

  const ParamRef& ChannelSets = Parameter( "ChannelSets" );
  for( int i = 0; i < ChannelSets->NumRows(); ++i )
  {
    string name = ChannelSets->RowLabels()[i],
           definition;
    for( int j = 0; j < ChannelSets->NumColumns(); ++j )
      definition += string( ChannelSets( i, j ) ) + " ";
    istringstream iss( definition );
    string entry;
    ChannelSet channelSet;
    while( iss >> ws >> entry )
    {
      if( sets.find( entry ) != sets.end() )
      { // A channel list with that name exists, copy it.
        for( size_t i = 0; i < sets[entry].size(); ++i )
          channelSet.push_back( sets[entry][i] );
      }
      else
      {
        IndexList s( entry, Input.ChannelLabels(), Input.ChannelUnit() );
        string errors = s.Errors();
        if( errors.empty() && s.Empty() )
          errors = "entry \"" + entry + "\" does not match any channel";
        if( errors.empty() )
          for( int i = 0; i < s.Size(); ++i )
            channelSet.push_back( static_cast<int>( s[i] ) );
        else
          bcierr << "Channel set \"" << name << "\": " << errors;
      }
    }
    if( channelSet.empty() )
      bcierr << "Empty channel set \"" << name << "\"" << endl;
    else
      sets[name] = channelSet;
  }
  for( ChannelSetContainer::const_iterator i = sets.begin(); i != sets.end(); ++i )
    ioContext.sources->Add( new ChannelSetSource( i->first, i->second ) );
}
Exemplo n.º 6
0
static void http_pipeline_init(ChannelPipeline* pipeline, void* data)
{
	pipeline->AddLast("encoder", new HTTPMessageEncoder());
	pipeline->AddLast("decoder", new HTTPMessageDecoder(false));
	HttpClientHandler* handler = new HttpClientHandler;
	handler->m_client = (Channel*) data;
	pipeline->AddLast("handler", handler);
	g_all_channels.insert(handler);
}
Exemplo n.º 7
0
void HttpClientHandler::ChannelClosed(ChannelHandlerContext& ctx,
		ChannelStateEvent& e)
{
	g_ready_channels.erase(this);
	g_all_channels.erase(this);
	if (!m_connected)
	{
		WARN_LOG(
				"Connect %s:%u failed!", g_options.host.c_str(), g_options.port);
	}
	try_send_request();
	if (m_request_sent)
	{
		g_unanwsered_requests++;
		if (g_unanwsered_requests % 10000 == 0)
		{
			INFO_LOG("Recv %d xres.", g_unanwsered_requests);
		}
	}
}
Exemplo n.º 8
0
static int try_send_request()
{
	if (g_limit > 0 && g_sent_count >= g_limit)
	{
		stop_serv();
		return 0;
	}
	uint64 now = get_current_monotonic_millis();

	if (g_tp10ms > 0 && g_count_in_10msperiod >= g_tp10ms)
	{

		if (g_period_task_id == -1)
		{
			if (g_count_in_1speriod >= g_options.tps)
			{
				uint64 delay_1s = 0;
				if (now >= g_1s_transc_start_time + 1000)
				{
					delay_1s = 0;
				} else
				{
					delay_1s = (g_1s_transc_start_time + 1000) - now;
				}
				g_period_task_id = g_serv->GetTimer().ScheduleHeapTask(
						make_fun_runnable(start_1s_period_task, true), delay_1s,
						-1);
			} else
			{
				uint64 delay_10ms = 0;
				if (now >= g_10ms_transc_start_time + 10)
				{
					delay_10ms = 0;
				} else
				{
					delay_10ms = (g_10ms_transc_start_time + 10) - now;
				}
				g_period_task_id = g_serv->GetTimer().ScheduleHeapTask(
						make_fun_runnable(start_10ms_period_task, true),
						delay_10ms, -1);
			}
		}

		return 0;
	}
	if (!g_ready_channels.empty())
	{
		ChannelSet::iterator it = g_ready_channels.begin();
		HttpClientHandler* client = *it;
		client->m_request_sent = true;
		Buffer& data = get_request_data();
		client->m_client->Write(data);
		data.SetReadIndex(0);
		g_ready_channels.erase(it);
		g_count_in_10msperiod++;
		g_sent_count++;
		g_ratio_sent_req++;
		g_count_in_1speriod++;
		return 1;
	} else
	{
		if (g_all_channels.size() < g_options.concurrentConns)
		{
			http_client_connect(g_options.host.c_str(), g_options.port);
		}
	}
	return 0;
}
Exemplo n.º 9
0
    void execute() {
        const int chanCount = num_channels();
        ChannelSet channels = channel_mask(chanCount);
        const bool doAlpha = channels.contains(Chan_Alpha);

        iop->progressMessage("Preparing image");
        input0().request(0, 0, width(), height(), channels, 1);

        if (aborted())
            return;

        ImageSpec srcSpec(width(), height(), chanCount, TypeDesc::FLOAT);
        ImageBuf srcBuffer(srcSpec);
        Row row(0, width());
        // Buffer for a channel-interleaved row after output LUT processing
        std::vector<float> lutBuffer(width() * chanCount);

        for (int y = 0; y < height(); y++) {
            iop->progressFraction(double(y) / height() * 0.85);
            get(height() - y - 1, 0, width(), channels, row);
            if (aborted())
                return;

            const float* alpha = doAlpha ? row[Chan_Alpha] : NULL;

            for (int i = 0; i < chanCount; i++)
                to_float(i, &lutBuffer[i], row[channel(i)], alpha, width(),
                         chanCount);
            for (int x = 0; x < width(); x++)
                srcBuffer.setpixel(x, y, &lutBuffer[x * chanCount]);
        }

        ImageSpec destSpec(width(), height(), chanCount, oiioBitDepths[bitDepth_]);

        setChannelNames(destSpec, channels);

        destSpec.attribute("maketx:filtername", gFilterNames[filter_]);

        switch (preset_) {
            case 0:
                destSpec.attribute("maketx:oiio_options", 1);
                break;
            case 1:
                destSpec.attribute("maketx:prman_options", 1);
                break;
            default:
                destSpec.tile_width = tileW_;
                destSpec.tile_height = tileH_;
                destSpec.attribute("planarconfig",
                                   planarMode_ ? "separate" : "contig");
                break;
        }

        if (fixNan_) {
            if (nanFixType_)
                destSpec.attribute("maketx:fixnan", "box3");
            else
                destSpec.attribute("maketx:fixnan", "black");
        }
        else
            destSpec.attribute("maketx:fixnan", "none");

        destSpec.attribute("maketx:checknan", checkNan_);
        destSpec.attribute("maketx:verbose", verbose_);
        destSpec.attribute("maketx:stats", stats_);

        OIIO::attribute("threads", (int)Thread::numCPUs);

        if (aborted())
            return;

        iop->progressMessage("Writing %s", filename());
        if (!ImageBufAlgo::make_texture(oiiotxMode[txMode_], srcBuffer,
                                        filename(), destSpec, &std::cout))
            iop->critical("ImageBufAlgo::make_texture failed to write file %s",
                          filename());
    }
Exemplo n.º 10
0
Arquivo: Aton.cpp Projeto: jonntd/Aton
        void _validate(bool for_real)
        {
            // do we need to open a port?
            if ( m_server.isConnected()==false && !m_inError && m_legit )
                changePort(m_port);
            
            if (m_stat.progress > 0)
                status(m_stat.progress,
                       m_stat.ram,
                       m_stat.p_ram,
                       m_stat.time);
            
            // handle any connection error
            if ( m_inError )
                error(m_connectionError.c_str());

            // setup format etc
            info_.format(*m_fmtp.fullSizeFormat());
            info_.full_size_format(*m_fmtp.format());
            
            // add aovs as nuke channels
            std::string rgba = "RGBA";
            std::string z = "Z";
            std::string n = "N";
            std::string p = "P";
            
            for(std::vector<std::string>::iterator it = m_aovs.begin(); it != m_aovs.end(); ++it)
            {
                if (it->compare(rgba)==0)
                {
                    if (!m_channels.contains(Chan_Red))
                    {
                        m_channels.insert(Chan_Red);
                        m_channels.insert(Chan_Green);
                        m_channels.insert(Chan_Blue);
                        m_channels.insert(Chan_Alpha);
                    }
                }
                else if (it->compare(z)==0)
                {
                    if (!m_channels.contains(Chan_Z))
                        m_channels.insert( Chan_Z );
                }
                else if (it->compare(n)==0 || it->compare(p)==0)
                {
                    if (!m_channels.contains(channel((boost::format("%s.X")%it->c_str()).str().c_str())))
                    {
                        m_channels.insert( channel((boost::format("%s.X")%it->c_str()).str().c_str()) );
                        m_channels.insert( channel((boost::format("%s.Y")%it->c_str()).str().c_str()) );
                        m_channels.insert( channel((boost::format("%s.Z")%it->c_str()).str().c_str()) );
                    }
                }
                else
                {
                    if (!m_channels.contains( channel((boost::format("%s.red")%it->c_str()).str().c_str())))
                    {
                        m_channels.insert( channel((boost::format("%s.red")%it->c_str()).str().c_str()) );
                        m_channels.insert( channel((boost::format("%s.blue")%it->c_str()).str().c_str()) );
                        m_channels.insert( channel((boost::format("%s.green")%it->c_str()).str().c_str()) );
                    }
                }
            }
            
            info_.channels( m_channels );
            info_.set(info().format());
        }