modules/video_processing/content_analysis.cc
int32_t VPMContentAnalysis::ComputeSpatialMetrics_C() {
  const int sizei = height_;
  const int sizej = width_;

  // Pixel mean square average: used to normalize the spatial metrics.
  uint32_t pixelMSA = 0;

  uint32_t spatialErrSum = 0;
  uint32_t spatialErrVSum = 0;
  uint32_t spatialErrHSum = 0;

  // make sure work section is a multiple of 16
  const int width_end = ((sizej - 2 * border_) & -16) + border_;

  for (int i = border_; i < sizei - border_; i += skip_num_) {
    for (int j = border_; j < width_end; j++) {
      int ssn1 = i * sizej + j;
      int ssn2 = (i + 1) * sizej + j;  // bottom
      int ssn3 = (i - 1) * sizej + j;  // top
      int ssn4 = i * sizej + j + 1;    // right
      int ssn5 = i * sizej + j - 1;    // left

      uint16_t refPixel1 = orig_frame_[ssn1] << 1;
      uint16_t refPixel2 = orig_frame_[ssn1] << 2;

      uint8_t bottPixel = orig_frame_[ssn2];
      uint8_t topPixel = orig_frame_[ssn3];
      uint8_t rightPixel = orig_frame_[ssn4];
      uint8_t leftPixel = orig_frame_[ssn5];

      spatialErrSum += static_cast<uint32_t>(abs(static_cast<int16_t>(
          refPixel2 - static_cast<uint16_t>(bottPixel + topPixel + leftPixel +
                                            rightPixel))));
      spatialErrVSum += static_cast<uint32_t>(abs(static_cast<int16_t>(
          refPixel1 - static_cast<uint16_t>(bottPixel + topPixel))));
      spatialErrHSum += static_cast<uint32_t>(abs(static_cast<int16_t>(
          refPixel1 - static_cast<uint16_t>(leftPixel + rightPixel))));
      pixelMSA += orig_frame_[ssn1];
    }
  }

  // Normalize over all pixels.
  const float spatialErr = static_cast<float>(spatialErrSum >> 2);
  const float spatialErrH = static_cast<float>(spatialErrHSum >> 1);
  const float spatialErrV = static_cast<float>(spatialErrVSum >> 1);
  const float norm = static_cast<float>(pixelMSA);

  // 2X2:
  spatial_pred_err_ = spatialErr / norm;
  // 1X2:
  spatial_pred_err_h_ = spatialErrH / norm;
  // 2X1:
  spatial_pred_err_v_ = spatialErrV / norm;
  return VPM_OK;
}
// Compute spatial metrics:
// To reduce complexity, we compute the metric for a reduced set of points.
// The spatial metrics are rough estimates of the prediction error cost for
//  each QM spatial mode: 2x2,1x2,2x1
// The metrics are a simple estimate of the up-sampling prediction error,
// estimated assuming sub-sampling for decimation (no filtering),
// and up-sampling back up with simple bilinear interpolation.
Compute spatial metrics:
To reduce complexity, we compute the metric for a reduced set of points.
The spatial metrics are rough estimates of the prediction error cost for
each QM spatial mode: 2x2,1x2,2x1
The metrics are a simple estimate of the up-sampling prediction error,
estimated assuming sub-sampling for decimation (no filtering),
and up-sampling back up with simple bilinear interpolation.
Compute spatial metrics : To reduce complexity we compute the metric for a reduced set of points . The spatial metrics are rough estimates of the prediction error cost for each QM spatial mode : 2x2 1x2 2x1 The metrics are a simple estimate of the up - sampling prediction error estimated assuming sub - sampling for decimation ( no filtering ) and up - sampling back up with simple bilinear interpolation .
int32_t VPMContentAnalysis::ComputeSpatialMetrics_C() {
  const int sizei = height_;
  const int sizej = width_;
  uint32_t pixelMSA = 0;
  uint32_t spatialErrSum = 0;
  uint32_t spatialErrVSum = 0;
  uint32_t spatialErrHSum = 0;
  const int width_end = ((sizej - 2 * border_) & -16) + border_;
  for (int i = border_; i < sizei - border_; i += skip_num_) {
    for (int j = border_; j < width_end; j++) {
      int ssn1 = i * sizej + j;
      int ssn2 = (i + 1) * sizej + j;  
      int ssn3 = (i - 1) * sizej + j;  
      int ssn4 = i * sizej + j + 1;    
      int ssn5 = i * sizej + j - 1;    
      uint16_t refPixel1 = orig_frame_[ssn1] << 1;
      uint16_t refPixel2 = orig_frame_[ssn1] << 2;
      uint8_t bottPixel = orig_frame_[ssn2];
      uint8_t topPixel = orig_frame_[ssn3];
      uint8_t rightPixel = orig_frame_[ssn4];
      uint8_t leftPixel = orig_frame_[ssn5];
      spatialErrSum += static_cast<uint32_t>(abs(static_cast<int16_t>(
          refPixel2 - static_cast<uint16_t>(bottPixel + topPixel + leftPixel +
                                            rightPixel))));
      spatialErrVSum += static_cast<uint32_t>(abs(static_cast<int16_t>(
          refPixel1 - static_cast<uint16_t>(bottPixel + topPixel))));
      spatialErrHSum += static_cast<uint32_t>(abs(static_cast<int16_t>(
          refPixel1 - static_cast<uint16_t>(leftPixel + rightPixel))));
      pixelMSA += orig_frame_[ssn1];
    }
  }
  const float spatialErr = static_cast<float>(spatialErrSum >> 2);
  const float spatialErrH = static_cast<float>(spatialErrHSum >> 1);
  const float spatialErrV = static_cast<float>(spatialErrVSum >> 1);
  const float norm = static_cast<float>(pixelMSA);
  spatial_pred_err_ = spatialErr / norm;
  spatial_pred_err_h_ = spatialErrH / norm;
  spatial_pred_err_v_ = spatialErrV / norm;
  return VPM_OK;
}
int32_t VPMContentAnalysis :: ComputeSpatialMetrics_C ( ) { const int sizei = height_ ; const int sizej = width_ ; uint32_t pixelMSA = 0 ; uint32_t spatialErrSum = 0 ; uint32_t spatialErrVSum = 0 ; uint32_t spatialErrHSum = 0 ; const int width_end = ( ( sizej - 2 * border_ ) & -16 ) + border_ ; for ( int i = border_ ; i < sizei - border_ ; i += skip_num_ ) { for ( int j = border_ ; j < width_end ; j ++ ) { int ssn1 = i * sizej + j ; int ssn2 = ( i + 1 ) * sizej + j ; int ssn3 = ( i - 1 ) * sizej + j ; int ssn4 = i * sizej + j + 1 ; int ssn5 = i * sizej + j - 1 ; uint16_t refPixel1 = orig_frame_ [ ssn1 ] << 1 ; uint16_t refPixel2 = orig_frame_ [ ssn1 ] << 2 ; uint8_t bottPixel = orig_frame_ [ ssn2 ] ; uint8_t topPixel = orig_frame_ [ ssn3 ] ; uint8_t rightPixel = orig_frame_ [ ssn4 ] ; uint8_t leftPixel = orig_frame_ [ ssn5 ] ; spatialErrSum += static_cast < uint32_t > ( abs ( static_cast < int16_t > ( refPixel2 - static_cast < uint16_t > ( bottPixel + topPixel + leftPixel + rightPixel ) ) ) ) ; spatialErrVSum += static_cast < uint32_t > ( abs ( static_cast < int16_t > ( refPixel1 - static_cast < uint16_t > ( bottPixel + topPixel ) ) ) ) ; spatialErrHSum += static_cast < uint32_t > ( abs ( static_cast < int16_t > ( refPixel1 - static_cast < uint16_t > ( leftPixel + rightPixel ) ) ) ) ; pixelMSA += orig_frame_ [ ssn1 ] ; } } const float spatialErr = static_cast < float > ( spatialErrSum >> 2 ) ; const float spatialErrH = static_cast < float > ( spatialErrHSum >> 1 ) ; const float spatialErrV = static_cast < float > ( spatialErrVSum >> 1 ) ; const float norm = static_cast < float > ( pixelMSA ) ; spatial_pred_err_ = spatialErr / norm ; spatial_pred_err_h_ = spatialErrH / norm ; spatial_pred_err_v_ = spatialErrV / norm ; return VPM_OK ; }
Compute spatial metrics:
To reduce complexity, we compute the metric for a reduced set of points.
Compute spatial metrics : To reduce complexity we compute the metric for a reduced set of points .
// Pixel mean square average: used to normalize the spatial metrics. // make sure work section is a multiple of 16 // bottom // top // right // left // Normalize over all pixels. // 2X2: // 1X2: // 2X1: