Exemple #1
0
void genQuicklookRow(sqlite3_stmt* stmt, Row& r) {
  for (int i = 0; i < sqlite3_column_count(stmt); i++) {
    auto column_name = std::string(sqlite3_column_name(stmt, i));
    auto column_type = sqlite3_column_type(stmt, i);
    if (column_type == SQLITE_TEXT) {
      auto value = sqlite3_column_text(stmt, i);
      if (value != nullptr) {
        r[column_name] = std::string((const char*)value);
      }
    } else if (column_type == SQLITE_INTEGER) {
      // Handle INTEGER columns explicitly to handle the date-value offset.
      auto value = sqlite3_column_int(stmt, i);
      if (column_name == "last_hit_date") {
        value += kReferenceDateOffset;
      }
      r[column_name] = INTEGER(value);
    } else if (column_type == SQLITE_BLOB) {
      // Handle BLOB values explicitly to avoid the default char* termination
      // for binary-plist data.
      auto getField = [](const pt::ptree& tree, const std::string& field) {
        if (field == "mtime" && tree.count(field) > 0) {
          // Apply a special case for embedded date-value fields.
          return INTEGER(tree.get<size_t>(field) + kReferenceDateOffset);
        }
        return (tree.count(field) > 0) ? tree.get<std::string>(field) : "";
      };

      if (column_name == "version") {
        pt::ptree tree;
        auto version = std::string((const char*)sqlite3_column_blob(stmt, i),
                                   sqlite3_column_bytes(stmt, i));
        if (parsePlistContent(version, tree)) {
          r["mtime"] = getField(tree, "date");
          r["size"] = getField(tree, "size");
          r["label"] = getField(tree, "gen");
        }
      }
    }
  }

  // Transform the folder/file_name into an aggregate path.
  r["path"] = std::move(r["folder"]) + "/" + std::move(r["file_name"]);
  r.erase("folder");
  r.erase("file_name");

  // Transform the encoded fs_id.
  auto details = osquery::split(r["fs_id"], "=.");
  if (details.size() == 4) {
    r["volume_id"] = details[2];
    r["inode"] = details[3];
  }
}
void Constant::engine(int y, int x, int r, ChannelMask channels, Row& row)
{
  for (int i = 4; i--; )
    if (intersect(channels, channel[i])) {
      float C = color[i];
      if (C) {
        float* TO = row.writable(channel[i]) + x;
        float* END = TO + (r - x);
        while (TO < END)
          *TO++ = C;
      }
      else {
        row.erase(channel[i]);
      }
    }

}
void AppendClip::engine(int y, int x, int r, ChannelMask channels, Row& out)
{
  if (!weight0) {
    out.erase(channels);
    return;
  }
  input(input0)->get(y, x, r, channels, out);
  if (weight1) {
    Row in(x, r);
    input(input1)->get(y, x, r, channels, in);
    foreach (z, channels) {
      const float* A = out[z] + x;
      const float* B = in[z] + x;
      float* C = out.writable(z) + x;
      float* E = C + (r - x);
      while (C < E)
        *C++ = *A++ *weight0 + *B++ *weight1;
    }
  }
  else if (weight0 < 1) {
Exemple #4
0
    void engine(int y, int x, int r, ChannelMask channels, Row& row) {
        if (!haveImage_)
            iop->internalError("engine called, but haveImage_ is false");

        if (aborted()) {
            row.erase(channels);
            return;
        }

        const bool doAlpha = channels.contains(Chan_Alpha);

        if (flip_)
            y = height() - y - 1;

        if (lastMipLevel_) {  // Mip level other than 0
            const int mipW = oiioInput_->spec().width;
            const int mipMult = width() / mipW;

            y = y * oiioInput_->spec().height / height();
            const int bufX = x ? x / mipMult : 0;
            const int bufR = r / mipMult;
            const int bufW = bufR - bufX;

            std::vector<float> chanBuf(bufW);
            float* chanStart = &chanBuf[0];
            const int bufStart = y * mipW * chanCount_ + bufX * chanCount_;
            const float* alpha = doAlpha ? &imageBuf_[bufStart + chanMap_[Chan_Alpha]] : NULL;
            foreach (z, channels) {
                from_float(z, &chanBuf[0], &imageBuf_[bufStart + chanMap_[z]],
                           alpha, bufW, chanCount_);

                float* OUT = row.writable(z);
                for (int stride = 0, c = 0; stride < bufW; stride++, c = 0)
                    for (; c < mipMult; c++)
                        *OUT++ = *(chanStart + stride);
            }
        }
Exemple #5
0
void LensDistort::engine( int y, int x, int r, ChannelMask channels, Row & outrow )
{
	// Provide an early-out for any black rows.
	bool blackOutside = info().black_outside();
	if( blackOutside && ( y == info().t()-1 || y == info().y() ) )
	{
		outrow.erase( channels );
		return;
	}

	const Info &info = input0().info();
	const double h( format().height() );
	const double w( format().width() );
	const double v( double(y)/h );
	double x_min = std::numeric_limits<double>::max();
	double x_max = std::numeric_limits<double>::min();
	double y_min = std::numeric_limits<double>::max();
	double y_max = std::numeric_limits<double>::min();
	
	// Work out which of the array of lens models we should use depending on the current thread.
	int lensIdx = 0;
	const Thread::ThreadInfo * f = Thread::thisThread();
	if( f ) lensIdx=f->index;
	
	// Clamp the index to the array range.
	lensIdx = lensIdx > m_nThreads ? 0 : lensIdx;
	
	// Create an array of distorted values that we will populate.
	Imath::V2d distort[r-x];
	
	// Thread safe read of distortion data.
	{
		Guard l( m_locks[lensIdx] );
		
		// Distort each pixel on the row, store the result in an array and track the bounding box.
		for( int i = x; i < r; i++ )
		{
			double u = (i+0.0)/w;
	
			Imath::V2d &dp( distort[i-x] );
			Imath::V2d p(u, v);
			if( m_mode )
			{
				dp = m_model[lensIdx]->distort( p );
			}
			else
			{
				dp = m_model[lensIdx]->undistort( p );
			}
			
			dp.x *= w;
			dp.y *= h;
			
			// Clamp our distorted values to the bounding box.
			dp.x = std::max( double(info.x()), dp.x );
			dp.y = std::max( double(info.y()), dp.y );
			dp.x = std::min( double(info.r()-1), dp.x );
			dp.y = std::min( double(info.t()-1), dp.y );
			x_min = std::min( x_min, dp.x );
			y_min = std::min( y_min, dp.y );
			x_max = std::max( x_max, dp.x );
			y_max = std::max( y_max, dp.y );
		}
	}
	
	// Now we know which pixels we'll need, request them!
	y_max++;
	x_max++;
	
	DD::Image::Pixel out(channels);
	
	// Lock the tile into the cache
	DD::Image::Tile t( input0(), IECore::fastFloatFloor( x_min ), IECore::fastFloatFloor( y_min ), IECore::fastFloatCeil( x_max ), IECore::fastFloatCeil( y_max ), channels );

	// Write the black outside pixels.
	if( blackOutside )
	{
		foreach ( z, channels )
		{
			outrow.writable(z)[x] = 0.f;
			outrow.writable(z)[r-1] = 0.f;
		}
	}