Logo Search packages:      
Sourcecode: pwlib version File versions  Download package

BOOL PVideoDevice::SetFrameSizeConverter ( unsigned  width,
unsigned  height,
BOOL  bScaleNotCrop 
) [virtual, inherited]

Set the frame size to be used, trying converters if available.

If the device does not support the size, a set of alternate resolutions are attempted. A converter is setup if possible.

Parameters:
widthNew width of frame
heightNew height of frame
bScaleNotCropScale or crop/pad preference

Reimplemented in PVideoInput1394DcDevice, PVideoInputDevice_1394AVC, and PVideoInputDevice_1394DC.

Definition at line 716 of file videoio.cxx.

References PColourConverter::Create().

Referenced by VidTest::Main(), and PVideoInputDevice_V4L::SetColourFormat().

{
  if (SetFrameSize(width, height)) {
    if (nativeVerticalFlip && converter == NULL) {
      converter = PColourConverter::Create(colourFormat, colourFormat, frameWidth, frameHeight);
      if (PAssertNULL(converter) == NULL)
        return FALSE;
    }
    if (converter != NULL) {
      converter->SetFrameSize(frameWidth, frameHeight);
      converter->SetVFlipState(nativeVerticalFlip);
    }
    return TRUE;
  }

  if (converter == NULL) {
    converter = PColourConverter::Create(colourFormat, colourFormat, width, height);
    if (converter == NULL) {
      PTRACE(1, "PVidDev\tSetFrameSizeConverter Colour converter creation failed");
      return FALSE;
    }
  }
  
  PTRACE(3,"PVidDev\tColour converter used for " << width << 'x' << height);

  unsigned minWidth, minHeight, maxWidth, maxHeight;
  BOOL limits = GetFrameSizeLimits(minWidth, minHeight, maxWidth, maxHeight);

  for (PINDEX i = 0; i < PARRAYSIZE(framesizeTab); i++) {
    if (framesizeTab[i].asked_width == width &&
        framesizeTab[i].asked_height == height &&
        (!limits ||
         (framesizeTab[i].device_width >= minWidth &&
          framesizeTab[i].device_width <= maxWidth &&
          framesizeTab[i].device_height >= minHeight &&
          framesizeTab[i].device_height <= maxHeight)) &&
          SetFrameSize(framesizeTab[i].device_width,
          framesizeTab[i].device_height)) {
      if (CanCaptureVideo() ?
          converter->SetDstFrameSize(width, height, bScaleNotCrop)
          :
          converter->SetSrcFrameSize(width, height) &&
          converter->SetDstFrameSize(framesizeTab[i].device_width,
          framesizeTab[i].device_height,
          bScaleNotCrop)) {
        PTRACE(4,"PVideoDevice\tSetFrameSizeConverter succeeded for converting from "
            << framesizeTab[i].device_width << 'x' << framesizeTab[i].device_height
         << " to " << width << 'x' << height);

        converter->SetVFlipState(converter->GetVFlipState() ^ nativeVerticalFlip);
        return TRUE;
      }
    }
  }

  if (CanCaptureVideo()) {
    // Failed to find a resolution the device can do so far, so try
    // using the maximum width and height it claims it can do.
    if (limits &&
      SetFrameSize(maxWidth, maxHeight)) {
      if (converter->SetDstFrameSize(width, height, bScaleNotCrop)) {
        PTRACE(4,"PVideoDevice\tSetFrameSizeConverter succeeded for converting from "
          << maxWidth << 'x' << maxHeight
          << " to " << width << 'x' << height);

        converter->SetVFlipState(converter->GetVFlipState() ^ nativeVerticalFlip);
        return TRUE;
      }
    }
  }

  PTRACE(2,"PVideoDevice\tSetFrameSizeConverter failed for " << width << 'x' << height);

  return FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index