Ejemplo n.º 1
0
OGRErr OGRPCIDSKLayer::ICreateFeature( OGRFeature *poFeature )

{
    try {

        PCIDSK::ShapeId id = poVecSeg->CreateShape( 
            (PCIDSK::ShapeId) poFeature->GetFID() );

        poFeature->SetFID( (long) id );

        return SetFeature( poFeature );
    }
/* -------------------------------------------------------------------- */
/*      Trap exceptions and report as CPL errors.                       */
/* -------------------------------------------------------------------- */
    catch( PCIDSK::PCIDSKException ex )
    {
        CPLError( CE_Failure, CPLE_AppDefined, 
                  "%s", ex.what() );
        return OGRERR_FAILURE;
    }
    catch(...)
    {
        CPLError( CE_Failure, CPLE_AppDefined, 
                  "Non-PCIDSK exception trapped." );
        return OGRERR_FAILURE;
    }
    
}
Ejemplo n.º 2
0
CacheStorageChild::CacheStorageChild(CacheStorage* aListener, Feature* aFeature)
  : mListener(aListener)
  , mNumChildActors(0)
  , mDelayedDestroy(false)
{
  MOZ_COUNT_CTOR(cache::CacheStorageChild);
  MOZ_ASSERT(mListener);

  SetFeature(aFeature);
}
Ejemplo n.º 3
0
CachePushStreamChild::CachePushStreamChild(Feature* aFeature,
                                           nsISupports* aParent,
                                           nsIAsyncInputStream* aStream)
  : mParent(aParent)
  , mStream(aStream)
  , mClosed(false)
{
  MOZ_ASSERT(mParent);
  MOZ_ASSERT(mStream);
  MOZ_ASSERT_IF(!NS_IsMainThread(), aFeature);
  SetFeature(aFeature);
}
Ejemplo n.º 4
0
void applyFilterbank( Filterbank *pFilterbank, Features * pFeats )
{

  assert(pFilterbank!=NULL);
  assert(pFeats!=NULL);

  int gabfeatsidx = 0;

  pFilterbank->m_pFeatures = CreateFeatures(pFeats->ncols, pFeats->nrows, pFeats->nfeats*NSCALES*NORIENTATIONS);
  assert(pFilterbank->m_pFeatures!=NULL);

  register int idx, s, k;

  for(idx=0; idx < pFeats->nfeats; idx++)
  {

    DImage* pImgfeats       = GetFeature(pFeats, idx);

    Spectrum *pSpectrumImg  = NULL;
    pSpectrumImg            = DFFT2D(pImgfeats);
    assert(pSpectrumImg!=NULL);

    for( s = 0; s < NSCALES; s++ )
    {
      for( k = 0; k < NORIENTATIONS; k++ )
      {
          Spectrum * pSpectrumConv = MultSpectrum(pSpectrumImg, pFilterbank->m_pSpectralFilterBank[s*NORIENTATIONS+k]);

          DImage   *  pInvImg       = DInvFFT2D(pSpectrumConv);
          DImage   *  pShiftedInvImg = DShift(pInvImg);

          SetFeature(pFilterbank->m_pFeatures, gabfeatsidx, pShiftedInvImg);
          gabfeatsidx++;

          DestroySpectrum(&(pSpectrumConv));
          DestroyDImage(&(pInvImg));
          DestroyDImage(&(pShiftedInvImg));
      }
    }
    DestroyDImage(&(pImgfeats));
    DestroySpectrum(&(pSpectrumImg));
  }
}
Ejemplo n.º 5
0
OGRErr OGRMemLayer::ICreateFeature( OGRFeature *poFeature )

{
    if (!bUpdatable)
        return OGRERR_FAILURE;

    if( poFeature->GetFID() != OGRNullFID &&
        poFeature->GetFID() != iNextCreateFID )
        bHasHoles = TRUE;

    if( poFeature->GetFID() != OGRNullFID 
        && poFeature->GetFID() >= 0
        && poFeature->GetFID() < nMaxFeatureCount )
    {
        if( papoFeatures[poFeature->GetFID()] != NULL )
            poFeature->SetFID( OGRNullFID );
    }

    if( poFeature->GetFID() > 10000000 )
        poFeature->SetFID( OGRNullFID );

    return SetFeature( poFeature );
}
Ejemplo n.º 6
0
SurfFeature::SurfFeature(const Rect &_feature)
{
	SetFeature(_feature);
}
Ejemplo n.º 7
0
/**********************************************************************
 *                   IMapInfoFile::CreateFeature()
 *
 * Standard OGR CreateFeature implementation.  This methode is used
 * to create a new feature in current dataset 
 **********************************************************************/
OGRErr     IMapInfoFile::CreateFeature(OGRFeature *poFeature)
{
    TABFeature *poTABFeature;
    OGRGeometry   *poGeom;
    OGRwkbGeometryType eGType;
    OGRErr  eErr;

    /*-----------------------------------------------------------------
     * MITAB won't accept new features unless they are in a type derived
     * from TABFeature... so we have to do our best to map to the right
     * feature type based on the geometry type.
     *----------------------------------------------------------------*/
    poGeom = poFeature->GetGeometryRef();
    if( poGeom != NULL )
        eGType = poGeom->getGeometryType();
    else
        eGType = wkbNone;

    switch (eGType)
    {
      /*-------------------------------------------------------------
       * POINT
       *------------------------------------------------------------*/
      case wkbPoint:
        poTABFeature = new TABPoint(poFeature->GetDefnRef());
        break;
      /*-------------------------------------------------------------
       * REGION
       *------------------------------------------------------------*/
      case wkbPolygon:
      case wkbMultiPolygon:
        poTABFeature = new TABRegion(poFeature->GetDefnRef());
        break;
      /*-------------------------------------------------------------
       * LINE/PLINE/MULTIPLINE
       *------------------------------------------------------------*/
      case wkbLineString:
      case wkbMultiLineString:
        poTABFeature = new TABPolyline(poFeature->GetDefnRef());
        break;
      /*-------------------------------------------------------------
       * Collection types that are not directly supported... convert
       * to multiple features in output file through recursive calls.
       *------------------------------------------------------------*/
      case wkbGeometryCollection:
      case wkbMultiPoint:
      {
          OGRErr eStatus = OGRERR_NONE;
          int i;
          OGRGeometryCollection *poColl = (OGRGeometryCollection*)poGeom;
          OGRFeature *poTmpFeature = poFeature->Clone();

          for (i=0; eStatus==OGRERR_NONE && i<poColl->getNumGeometries(); i++)
          {
              poTmpFeature->SetGeometry(poColl->getGeometryRef(i));
              eStatus = CreateFeature(poTmpFeature);
          }
          delete poTmpFeature;
          return eStatus;
        }
        break;
      /*-------------------------------------------------------------
       * Unsupported type.... convert to MapInfo geometry NONE
       *------------------------------------------------------------*/
      case wkbUnknown:
      default:
         poTABFeature = new TABFeature(poFeature->GetDefnRef()); 
        break;
    }

    if( poGeom != NULL )
        poTABFeature->SetGeometryDirectly(poGeom->clone());
    
    for (int i=0; i< poFeature->GetDefnRef()->GetFieldCount();i++)
    {
        poTABFeature->SetField(i,poFeature->GetRawFieldRef( i ));
    }
    

    if (SetFeature(poTABFeature) > -1)
        eErr = OGRERR_NONE;
    else
        eErr = OGRERR_FAILURE;

    delete poTABFeature;
    
    return eErr;
}
Ejemplo n.º 8
0
VOID
EvtIoDeviceControl(
    _In_  WDFQUEUE          Queue,
    _In_  WDFREQUEST        Request,
    _In_  size_t            OutputBufferLength,
    _In_  size_t            InputBufferLength,
    _In_  ULONG             IoControlCode
    )
/*++
Routine Description:

    This event callback function is called when the driver receives an

    (KMDF) IOCTL_HID_Xxx code when handlng IRP_MJ_INTERNAL_DEVICE_CONTROL
    (UMDF) IOCTL_HID_Xxx, IOCTL_UMDF_HID_Xxx when handling IRP_MJ_DEVICE_CONTROL

Arguments:

    Queue - A handle to the queue object that is associated with the I/O request

    Request - A handle to a framework request object.

    OutputBufferLength - The length, in bytes, of the request's output buffer,
            if an output buffer is available.

    InputBufferLength - The length, in bytes, of the request's input buffer, if
            an input buffer is available.

    IoControlCode - The driver or system defined IOCTL associated with the request

Return Value:

    NTSTATUS

--*/
{
    NTSTATUS                status;
    BOOLEAN                 completeRequest = TRUE;
    WDFDEVICE               device = WdfIoQueueGetDevice(Queue);
    PDEVICE_CONTEXT         deviceContext = NULL;
    PQUEUE_CONTEXT          queueContext = GetQueueContext(Queue);
    UNREFERENCED_PARAMETER  (OutputBufferLength);
    UNREFERENCED_PARAMETER  (InputBufferLength);

    deviceContext = GetDeviceContext(device);

    switch (IoControlCode)
    {
    case IOCTL_HID_GET_DEVICE_DESCRIPTOR:   // METHOD_NEITHER
        //
        // Retrieves the device's HID descriptor.
        //
        _Analysis_assume_(deviceContext->HidDescriptor.bLength != 0);
        status = RequestCopyFromBuffer(Request,
                            &deviceContext->HidDescriptor,
                            deviceContext->HidDescriptor.bLength);
        break;

    case IOCTL_HID_GET_DEVICE_ATTRIBUTES:   // METHOD_NEITHER
        //
        //Retrieves a device's attributes in a HID_DEVICE_ATTRIBUTES structure.
        //
        status = RequestCopyFromBuffer(Request,
                            &queueContext->DeviceContext->HidDeviceAttributes,
                            sizeof(HID_DEVICE_ATTRIBUTES));
        break;

    case IOCTL_HID_GET_REPORT_DESCRIPTOR:   // METHOD_NEITHER
        //
        //Obtains the report descriptor for the HID device.
        //
        status = RequestCopyFromBuffer(Request,
                            deviceContext->ReportDescriptor,
                            deviceContext->HidDescriptor.DescriptorList[0].wReportLength);
        break;

    case IOCTL_HID_READ_REPORT:             // METHOD_NEITHER
        //
        // Returns a report from the device into a class driver-supplied
        // buffer.
        //
        status = ReadReport(queueContext, Request, &completeRequest);
        break;

    case IOCTL_HID_WRITE_REPORT:            // METHOD_NEITHER
        //
        // Transmits a class driver-supplied report to the device.
        //
        status = WriteReport(queueContext, Request);
        break;

#ifdef _KERNEL_MODE

    case IOCTL_HID_GET_FEATURE:             // METHOD_OUT_DIRECT

        status = GetFeature(queueContext, Request);
        break;

    case IOCTL_HID_SET_FEATURE:             // METHOD_IN_DIRECT

        status = SetFeature(queueContext, Request);
        break;

    case IOCTL_HID_GET_INPUT_REPORT:        // METHOD_OUT_DIRECT

        status = GetInputReport(queueContext, Request);
        break;

    case IOCTL_HID_SET_OUTPUT_REPORT:       // METHOD_IN_DIRECT

        status = SetOutputReport(queueContext, Request);
        break;

#else // UMDF specific

    //
    // HID minidriver IOCTL uses HID_XFER_PACKET which contains an embedded pointer.
    //
    //   typedef struct _HID_XFER_PACKET {
    //     PUCHAR reportBuffer;
    //     ULONG  reportBufferLen;
    //     UCHAR  reportId;
    //   } HID_XFER_PACKET, *PHID_XFER_PACKET;
    //
    // UMDF cannot handle embedded pointers when marshalling buffers between processes.
    // Therefore a special driver mshidumdf.sys is introduced to convert such IRPs to
    // new IRPs (with new IOCTL name like IOCTL_UMDF_HID_Xxxx) where:
    //
    //   reportBuffer - passed as one buffer inside the IRP
    //   reportId     - passed as a second buffer inside the IRP
    //
    // The new IRP is then passed to UMDF host and driver for further processing.
    //

    case IOCTL_UMDF_HID_GET_FEATURE:        // METHOD_NEITHER

        status = GetFeature(queueContext, Request);
        break;

    case IOCTL_UMDF_HID_SET_FEATURE:        // METHOD_NEITHER

        status = SetFeature(queueContext, Request);
        break;

    case IOCTL_UMDF_HID_GET_INPUT_REPORT:  // METHOD_NEITHER

        status = GetInputReport(queueContext, Request);
        break;

    case IOCTL_UMDF_HID_SET_OUTPUT_REPORT: // METHOD_NEITHER

        status = SetOutputReport(queueContext, Request);
        break;

#endif // _KERNEL_MODE

    case IOCTL_HID_GET_STRING:                      // METHOD_NEITHER

        status = GetString(Request);
        break;

    case IOCTL_HID_GET_INDEXED_STRING:              // METHOD_OUT_DIRECT

        status = GetIndexedString(Request);
        break;

    case IOCTL_HID_SEND_IDLE_NOTIFICATION_REQUEST:  // METHOD_NEITHER
        //
        // This has the USBSS Idle notification callback. If the lower driver
        // can handle it (e.g. USB stack can handle it) then pass it down
        // otherwise complete it here as not inplemented. For a virtual
        // device, idling is not needed.
        //
        // Not implemented. fall through...
        //
    case IOCTL_HID_ACTIVATE_DEVICE:                 // METHOD_NEITHER
    case IOCTL_HID_DEACTIVATE_DEVICE:               // METHOD_NEITHER
    case IOCTL_GET_PHYSICAL_DESCRIPTOR:             // METHOD_OUT_DIRECT
        //
        // We don't do anything for these IOCTLs but some minidrivers might.
        //
        // Not implemented. fall through...
        //
    default:
        status = STATUS_NOT_IMPLEMENTED;
        break;
    }

    //
    // Complete the request. Information value has already been set by request
    // handlers.
    //
    if (completeRequest) {
        WdfRequestComplete(Request, status);
    }
}
/***************************************************************************//**
 * @brief       Processes Standard Request (Chapter 9 Command)
 * @return      Status of request (type @ref USB_Status_TypeDef)
 * @note        This function takes no parameters, but it uses the setup command
 *              stored in @ref myUsbDevice.setup.
 ******************************************************************************/
USB_Status_TypeDef USBDCH9_SetupCmd(void)
{
  USB_Status_TypeDef status = USB_STATUS_OK;

  switch (myUsbDevice.setup.bRequest)
  {
    case GET_STATUS:
      status = GetStatus();
      break;

    case CLEAR_FEATURE:
      status = ClearFeature();
      break;

    case SET_FEATURE:
      status = SetFeature();
      break;

    case SET_ADDRESS:
      status = SetAddress();
      break;

    case GET_DESCRIPTOR:
      status = GetDescriptor();
      break;

    case GET_CONFIGURATION:
      status = GetConfiguration();
      break;

    case SET_CONFIGURATION:
      status = SetConfiguration();
      break;

    case GET_INTERFACE:
      status = GetInterface();
      break;

    case SET_INTERFACE:
      status = SetInterface();
      break;

//    case GET_MS_DESCRIPTOR:
//    	status = HandleMsRequest();
//    	break;

    default:
      status = USB_STATUS_REQ_ERR;
      break;
  }

  // Reset index to 0 in case one of the above commands modified it
  USB_SetIndex(0);

  // If the command resulted in an error, send a procedural stall
  if (status == USB_STATUS_REQ_ERR)
  {
    SendEp0Stall();
  }

  return status;
}
Ejemplo n.º 10
0
void ApplySPFilterBank(DImage* img, Filterbank* bank, int startingnfeat)
{

    if(bank == NULL)
    {
        Error("Filterbank NULL", "ApplySPFilterBank");
    }
    if(bank->m_pSpectralFilterBank == NULL)
    {
        Error("Filterbank->m_pSpectralFilterBank NULL", "ApplySPFilterBank");
    }
    if(img->ncols != bank->m_pSpectralFilterBank[0]->ncols &&
            img->nrows != bank->m_pSpectralFilterBank[0]->nrows)
    {
        Error("DImage and bank are of different sizes","ApplySPFilterBank");
    }
    if(bank->m_pFeatures == NULL)
    {
        Error("m_pFeatures NULL","ApplySPFilterBank");
    }

    int s, k;
    int scales = bank->scales;
    int orientations = bank->orientations;
    int featindex = startingnfeat;
    Spectrum*  smoothedDImg;
    DImage* scaled = img;

    float Sx = 0.5, Sy = 0.5;

    for(s = 0; s < scales; s++)
    {
        /// Applying low-pass filter
        smoothedDImg = SmoothDImage(scaled);

        for(k = 0; k < orientations; k++)
        {
            /// Applying band-pass filter
            Spectrum* filteredSpec = ApplyFilter(smoothedDImg, bank->m_pSpectralFilterBank[s*orientations+k]);
            DImage* filtered = DInvFFT2D(filteredSpec);
//            char name[30];
//            sprintf(name,"filtersp_%d_%d.pgm",s,k);
//            WriteImage(ViewMagnitude(FFTShift(bank->m_pSpectralFilterBank[s*orientations+k])),name);

            DImage* filteredscl = filtered;

            /** If scale is greater than 0, resample the image
             *  to its original size
             **/
            if(s > 0)
            {
                /// Returning image to original size
                filteredscl = DScale(filtered,1/(Sx+Sx),1/(Sy+Sy));
            }

            /// Sets the rescaled image to the proper bank feature index
            SetFeature(bank->m_pFeatures,featindex++,filteredscl);

            /// Cleaning up
            if(filtered != filteredscl)
            {
                DestroyDImage(&filtered);
            }
            DestroyDImage(&filteredscl);
            DestroySpectrum(&filteredSpec);
        }

        DestroySpectrum(&smoothedDImg);

        if(scaled != img) DestroyDImage(&scaled);

        /// Downscaling image
        scaled = DScale(img,Sx,Sy);
        Sx = Sx/2;
        Sy = Sy/2;
    }

    if(scaled != img) DestroyDImage(&scaled);

}
Ejemplo n.º 11
0
// This function is designed to be called once. A second call will not
// reset all variables.
bool Config::SetFromProperties() {
  char property_str[PROP_VALUE_MAX];
  memset(property_str, 0, sizeof(property_str));
  if (!__system_property_get("libc.debug.malloc.options", property_str)) {
    return false;
  }

  // Initialize a few default values.
  fill_alloc_value = PropertyParser::DEFAULT_FILL_ALLOC_VALUE;
  fill_free_value = PropertyParser::DEFAULT_FILL_FREE_VALUE;
  front_guard_value = PropertyParser::DEFAULT_FRONT_GUARD_VALUE;
  rear_guard_value = PropertyParser::DEFAULT_REAR_GUARD_VALUE;
  backtrace_signal = SIGRTMIN + 10;

  // Parse the options are of the format:
  //   option_name or option_name=XX

  // Supported features:
  const Feature features[] = {
    Feature("guard", 32, 0, nullptr, nullptr, true),
    // Enable front guard. Value is the size of the guard.
    Feature("front_guard", 32, FRONT_GUARD, &this->front_guard_bytes, nullptr, true),
    // Enable end guard. Value is the size of the guard.
    Feature("rear_guard", 32, REAR_GUARD, &this->rear_guard_bytes, nullptr, true),

    // Enable logging the backtrace on allocation. Value is the total
    // number of frames to log.
    Feature("backtrace", 16, BACKTRACE | TRACK_ALLOCS, &this->backtrace_frames,
            &this->backtrace_enabled, false),
    // Enable gathering backtrace values on a signal.
    Feature("backtrace_enable_on_signal", 16, BACKTRACE | TRACK_ALLOCS, &this->backtrace_frames,
            &this->backtrace_enable_on_signal, false),

    Feature("fill", SIZE_MAX, 0, nullptr, nullptr, true),
    // Fill the allocation with an arbitrary pattern on allocation.
    // Value is the number of bytes of the allocation to fill
    // (default entire allocation).
    Feature("fill_on_alloc", SIZE_MAX, FILL_ON_ALLOC, &this->fill_on_alloc_bytes,
            nullptr, true),
    // Fill the allocation with an arbitrary pattern on free.
    // Value is the number of bytes of the allocation to fill
    // (default entire allocation).
    Feature("fill_on_free", SIZE_MAX, FILL_ON_FREE, &this->fill_on_free_bytes, nullptr, true),

    // Expand the size of every alloc by this number bytes. Value is
    // the total number of bytes to expand every allocation by.
    Feature ("expand_alloc", 16, EXPAND_ALLOC, &this->expand_alloc_bytes, nullptr, false),

    // Keep track of the freed allocations and verify at a later date
    // that they have not been used. Turning this on, also turns on
    // fill on free.
    Feature("free_track", 100, FREE_TRACK | FILL_ON_FREE, &this->free_track_allocations,
            nullptr, false),

    // Enable printing leaked allocations.
    Feature("leak_track", 0, LEAK_TRACK | TRACK_ALLOCS, nullptr, nullptr, false),
  };

  // Process each property name we can find.
  std::string property;
  size_t value;
  bool value_set;
  PropertyParser parser(property_str);
  bool found = false;
  bool valid = true;
  while (valid && parser.Get(&property, &value, &value_set)) {
    for (size_t i = 0; i < sizeof(features)/sizeof(Feature); i++) {
      if (property == features[i].name) {
        if (features[i].option == 0 && features[i].combo_option) {
          i++;
          for (; i < sizeof(features)/sizeof(Feature) && features[i].combo_option; i++) {
            if (!SetFeature(features[i], value, value_set)) {
              valid = false;
              break;
            }
            options |= features[i].option;
          }
          if (!valid) {
            break;
          }
        } else {
          if (!SetFeature(features[i], value, value_set)) {
            valid = false;
            break;
          }
          options |= features[i].option;
        }
        found = true;
        break;
      }
    }
    if (valid && !found) {
      error_log("%s: unknown option %s", getprogname(), property.c_str());
      valid = false;
      break;
    }
  }

  valid = valid && parser.Done();

  if (valid) {
    // It's necessary to align the front guard to sizeof(uintptr_t) to
    // make sure that the header is aligned properly.
    if (options & FRONT_GUARD) {
      front_guard_bytes = BIONIC_ALIGN(front_guard_bytes, sizeof(uintptr_t));
    }

    // This situation can occur if the free_track option is specified and
    // the fill_on_free option is not. In this case, indicate the whole
    // allocation should be filled.
    if ((options & FILL_ON_FREE) && fill_on_free_bytes == 0) {
      fill_on_free_bytes = SIZE_MAX;
    }
  } else {
    parser.LogUsage();
  }

  return valid;
}