Esempio n. 1
0
void ThisClass::ProcessCPU(int y, int x, int r, ChannelMask channels, Row& row) {
  Channel rgb_chan[3];
  rgb_chan[0] = Chan_Red;
  rgb_chan[1] = Chan_Green;
  rgb_chan[2] = Chan_Blue;

  // Must call get before initializing any pointers
  row.get(input0(), y, x, r, channels);
  // Copy all other channels through unchanged
  ChannelSet copy_mask = channels - Mask_RGB - k_spill_matte_channel_;
  row.pre_copy(row, copy_mask);
  row.copy(row, copy_mask, x, r);

  Row m_row(x, r);
  if (input(iMatte) != nullptr) { m_row.get(*input(iMatte), y, x, r, Mask_Alpha); }

  float rgb[3] = {0, 0, 0};
  afx::ReadOnlyPixel in_px(3);
  afx::Pixel out_px(3);
  for (int i = 0; i < 3; i++) {
    in_px.SetPtr(row[rgb_chan[i]] + x, i);// Set const in pointers RGB
    out_px.SetPtr(row.writable(rgb_chan[i]) + x, i); // Set out pointers RGB
  }
  const float* m_ptr = nullptr;
  if (input(iMatte) != nullptr) { m_ptr = m_row[Chan_Alpha] + x; }
  for (int x0 = x; x0 < r; ++x0) { // Loop through pixels in row
    float suppression_matte = 0.0f;
    float m = 1.0f;
    if (input(iMatte) != nullptr) { m = *m_ptr; }
    for (int i = 0; i < 3; i++) { rgb[i] = in_px.GetVal(i); }

    hue_shifter_.Rotate(rgb); //Shift hue so mean hue is 1/3 on hue scale
    float suppression = k_amount_ * m * afx::SpillSupression(rgb, k_algorithm_); //Calculate suppression
    rgb[1] -= suppression;
    hue_shifter_inv_.Rotate(rgb);
    for (int i = 0; i < 3; i++) { rgb[i] = fmaxf(rgb[i], 0.0f); }
    suppression_matte = clamp(suppression / ref_suppression_, 0.0f, 1.0f);

    for (int i = 0; i < 3; i++) {
      out_px[i] = rgb[i];
    }
    foreach (z, k_spill_matte_channel_) { *(row.writable(z) + x0) = suppression_matte; }
    in_px++;
    out_px++;
    if (input(iMatte) != nullptr) { m_ptr++; }
  }
}
Esempio n. 2
0
void LpSub::constraint2row(
	ArrayBuffer<Constraint*> &cons,
	ArrayBuffer<Row*> &rows)
{
	int   conNnz;                      //!< number of nonzero elements in constraint
	Row   rowBuf(master_, sub_->nVar());  //!< dummy to generate row
	Row  *row;                         //!< pointer to the new row

	const int nCons = cons.size();

	for (int c = 0; c < nCons; c++) {
		conNnz = cons[c]->genRow(sub_->actVar(), rowBuf);
		row = new Row(master_, conNnz);
		row->copy(rowBuf);
		rows.push(row);
		rowBuf.clear();
	}
}
        void engine(int y, int xx, int r, ChannelMask channels, Row& out)
        {
            unsigned int imageSize =
                    static_cast<unsigned int> (info().format().width()
                            * info().format().height());

            // fill up the output image from the buffer
            if (m_buffer.size() == imageSize)
            {
                float *rOut = out.writable(Chan_Red) + xx;
                float *gOut = out.writable(Chan_Green) + xx;
                float *bOut = out.writable(Chan_Blue) + xx;
                float *aOut = out.writable(Chan_Alpha) + xx;

                const float *END = rOut + (r - xx);

                unsigned int xxx = static_cast<unsigned int> (xx);
                unsigned int yyy = static_cast<unsigned int> (y);

                while (rOut < END)
                {
                    *rOut = m_buffer.get(xxx, yyy).r;
                    *gOut = m_buffer.get(xxx, yyy).g;
                    *bOut = m_buffer.get(xxx, yyy).b;
                    *aOut = m_buffer.get(xxx, yyy).a;

                    ++rOut;
                    ++gOut;
                    ++bOut;
                    ++aOut;

                    ++xxx;
                }
            }
            else
            {
                Row input(xx, r);
                input0().get(y, xx, r, Mask_All, input);
                out.copy(input, Mask_All, xx, r);
            }
        }
Esempio n. 4
0
// Called on each scanline
void NukeCtlIop::pixel_engine(const Row& in, int y, int x, int r, ChannelMask channels, Row& out) {
  if (transform != NULL)
  {
    try {
      transform->execute(in, x, r, out);
    }
    catch (const BaseExc& e) {
      error("Could not execute CTL argument transform: %s", e.what());
    }
    catch (const exception& e) {
      error("Could not execute CTL argument transform: %s", e.what());
    }
    catch (...) // Something wicked this way comes
    {
      error("Could not execute CTL argument transform");
    }
  }
  else
  {
    out.copy(in, channels, x, r);
  }
}