示例#1
0
//************************************************************************
PDIB CDib::GetDib(BOOL fDecodeRLE)
//************************************************************************
{
	if ((GetCompression() == BI_RLE8) && fDecodeRLE)
	{	
		DWORD dwSize = (long)GetWidthBytes() * (long)abs(GetHeight());
		LPTR lp = AllocX(dwSize, GMEM_ZEROINIT );
		if (!lp)
			return(NULL);
		PDIB pDib = new CDib(this, lp, FALSE);
		if (!pDib)
		{
			FreeUp(lp);
			return(NULL);
		}
		DecodeRLE(lp);
		pDib->SetCompression(BI_RGB);
		pDib->SetSizeImage(dwSize);
		return(pDib);
	}
	else
	{
		AddRef();
		return(this);
	}
}
示例#2
0
void Loader::Rapidfire() {
	lockH.Set(0);
	lockL.Set(0);
	compTest.Set(0);
	
	SmartDashboard::PutNumber("Compression", GetCompression());
}
示例#3
0
void Loader::CompressTest() {
	lockH.Set(1);
	lockL.Set(1);
	compTest.Set(1);
	
	SaveCompression();
	SmartDashboard::PutNumber("Compression", GetCompression());
}
示例#4
0
// OutputToStream()
//  Outputs an ImageData instance as ASCII text to the stream provided.
void ImageData::OutputToStream( ostream &out ) {
  out << " Filename:             \"" << GetFilename() << "\"" << endl;
  out << "  File Format:         " << GetFileFormat() << "; \"" << ImageFileFormatStrings[ GetFileFormat() ] << "\"" << endl;
  out << "  File Size:           " << GetFileSize() << " bytes " << endl;
  out << endl;
  out << " File Data:" << endl;
  out << "  Bits Per Pixel:      " << GetBitsPerPixel() << endl;
  out << "  Compression:         " << GetCompression() << "; \"" << ImageCompressionModeStrings[ GetCompression() ] << "\"" << endl;
  out << "  DPI X/Y:             " << GetDPIX() << "/" <<  GetDPIY() << endl;
  out << "  Pixel Aspect Ration: " << GetPixelAspectNum() << "/" <<  GetPixelAspectDenom() << endl;
  out << "  Gamma Correction:    " << GetGammaNum() << "/" <<  GetGammaDenom() << endl;
  out << "  Thumbnail:           ";
  if( GetThumbnail() == NULL )
    out << "No" << endl;
  else
    out << "Yes" << endl;

  out << endl;
  out << " Creator Data:" << endl;
  out << "  Author:              \"" << GetAuthor() << "\"" << endl;
  out << "  Creator Program:     \"" << GetCreator() << "\"" << endl;
  out << "  Creator Version:     "   << GetCreatorVersion() << "." << GetCreatorRevision() << GetCreatorSubRev() << endl;
  out << "  Comment:             \"" << GetComment() << "\"" << endl;
  out << "  Job Name:            \"" << GetJobName() << "\"" << endl;
  out << "  Job Time:            "   << GetJobTime()[0] << ":" << GetJobTime()[1] << ":" << GetJobTime()[2] << endl;
  out << "  Date Stamp:          "   << GetDateStamp()[0] << "/" << GetDateStamp()[1] << "/" << GetDateStamp()[2] << "  "
                                     << GetDateStamp()[3] << ":" << GetDateStamp()[4] << ":" << GetDateStamp()[5] << endl;
  out << endl;

  out << " Image Data:" << endl;
  out << "  Width:               " << GetImage()->GetWidth() << endl;
  out << "  Height:              " << GetImage()->GetHeight() << endl;
  out << "  Type:                " << GetImage()->GetType() << "; \"" << ImageTypeStrings[ GetImage()->GetType() ] << "\"" << endl;
  out << "  Num Registers:       ";
  if( GetImage()->GetType() == IMAGE_INDEXED )
    out << GetImage()->GetNumRegisters() << endl;
  else
    out << "N/A" << endl;

}
XnStatus XnStreamDeviceStreamHolder::ChooseCodec()
{
	XnStatus nRetVal = XN_STATUS_OK;

	// create new codec (we also need to register on all the properties)
	XnCodec* pCodec;
	XnPropertiesList CodecProps;

	switch (GetCompression())
	{
	case XN_COMPRESSION_NONE:
		{
			XN_VALIDATE_NEW_AND_INIT(pCodec, XnUncompressedCodec);
		}
		break;
	case XN_COMPRESSION_16Z:
		{
			XN_VALIDATE_NEW_AND_INIT(pCodec, Xn16zCodec);
		}
		break;
	case XN_COMPRESSION_16Z_EMB_TABLE:
		{
			// first we need to find max depth
			XnIntProperty* pDeviceMaxDepthProp;
			nRetVal = GetStream()->GetProperty(XN_STREAM_PROPERTY_DEVICE_MAX_DEPTH, &pDeviceMaxDepthProp);
			XN_IS_STATUS_OK(nRetVal);

			XnUInt64 nMaxDepth;
			nRetVal = pDeviceMaxDepthProp->GetValue(&nMaxDepth);
			XN_IS_STATUS_OK(nRetVal);

			nRetVal = CodecProps.AddLast(pDeviceMaxDepthProp);
			XN_IS_STATUS_OK(nRetVal);

			XN_VALIDATE_NEW_AND_INIT(pCodec, Xn16zEmbTablesCodec, (XnDepthPixel)nMaxDepth);
		}
		break;
	case XN_COMPRESSION_COLOR_8Z:
		{
			XN_VALIDATE_NEW_AND_INIT(pCodec, Xn8zCodec);
		}
		break;
	case XN_COMPRESSION_JPEG:
		{
			// check what is the output format
			XnIntProperty* pOutputFormatProp;
			nRetVal = GetStream()->GetProperty(XN_STREAM_PROPERTY_OUTPUT_FORMAT, &pOutputFormatProp);
			XN_IS_STATUS_OK(nRetVal);

			XnUInt64 nOutputFormat;
			nRetVal = pOutputFormatProp->GetValue(&nOutputFormat);
			XN_IS_STATUS_OK(nRetVal);

			XnBool bRGB = FALSE;

			switch (nOutputFormat)
			{
			case XN_OUTPUT_FORMAT_GRAYSCALE8:
				bRGB = FALSE;
				break;
			case XN_OUTPUT_FORMAT_RGB24:
				bRGB = TRUE;
				break;
			default:
				XN_LOG_WARNING_RETURN(XN_STATUS_ERROR, XN_MASK_DDK, "Codec factory currently supports JPEG codec only for streams of type Gray8 or RGB24!");
			}

			nRetVal = CodecProps.AddLast(pOutputFormatProp);
			XN_IS_STATUS_OK(nRetVal);

			// X res
			XnIntProperty* pXResProp;
			nRetVal = GetStream()->GetProperty(XN_STREAM_PROPERTY_X_RES, &pXResProp);
			XN_IS_STATUS_OK(nRetVal);

			XnUInt64 nXRes;
			nRetVal = pXResProp->GetValue(&nXRes);
			XN_IS_STATUS_OK(nRetVal);

			nRetVal = CodecProps.AddLast(pXResProp);
			XN_IS_STATUS_OK(nRetVal);

			// Y res
			XnIntProperty* pYResProp;
			nRetVal = GetStream()->GetProperty(XN_STREAM_PROPERTY_Y_RES, &pYResProp);
			XN_IS_STATUS_OK(nRetVal);

			XnUInt64 nYRes;
			nRetVal = pYResProp->GetValue(&nYRes);
			XN_IS_STATUS_OK(nRetVal);

			// Cropping
			XnGeneralProperty* pCroppingProp;
			nRetVal = GetStream()->GetProperty(XN_STREAM_PROPERTY_CROPPING, &pCroppingProp);
			XN_IS_STATUS_OK(nRetVal);

			XnCropping cropping;
			nRetVal = pCroppingProp->GetValue(XN_PACK_GENERAL_BUFFER(cropping));
			XN_IS_STATUS_OK(nRetVal);

			nRetVal = CodecProps.AddLast(pCroppingProp);
			XN_IS_STATUS_OK(nRetVal);

			// calc x,y
			if (cropping.bEnabled)
			{
				nXRes = cropping.nXSize;
				nYRes = cropping.nYSize;
			}

			XN_VALIDATE_NEW_AND_INIT(pCodec, XnJpegCodec, bRGB, (XnUInt32)nXRes, (XnUInt32)nYRes);
		}
		break;
	default:
		XN_LOG_WARNING_RETURN(XN_STATUS_ERROR, XN_MASK_DDK, "Codec factory does not support compression type %d", GetCompression());
	}

	// register to new props
	for (XnPropertiesList::Iterator it = CodecProps.Begin(); it != CodecProps.End(); ++it)
	{
		XnProperty* pProp = *it;

		XnPropertiesHash::Iterator hashIt = m_CodecProperties.End();
		nRetVal = m_CodecProperties.Find(pProp, hashIt);
		if (nRetVal == XN_STATUS_NO_MATCH)
		{
			XnCallbackHandle hCallbackDummy;
			nRetVal = pProp->OnChangeEvent().Register(CodecPropertyChangedCallback, this, hCallbackDummy);
			if (nRetVal != XN_STATUS_OK)
			{
				XN_DELETE(pCodec);
				return (nRetVal);
			}

			nRetVal = m_CodecProperties.Set(pProp, NULL);
			if (nRetVal != XN_STATUS_OK)
			{
				XN_DELETE(pCodec);
				return (nRetVal);
			}
		}
		else if (nRetVal != XN_STATUS_OK)
		{
			XN_DELETE(pCodec);
			return (nRetVal);
		}
	}

	// replace it
	XN_DELETE(m_pCodec);
	m_pCodec = pCodec;

	return (XN_STATUS_OK);
}
示例#6
0
int svlVideoCodecTCPStream::Create(const std::string &filename, const unsigned int width, const unsigned int height, const double CMN_UNUSED(framerate))
{
	if (Opened || ParseFilename(filename) != SVL_OK ||
        width < 1 || width > MAX_DIMENSION || height < 1 || height > MAX_DIMENSION) return SVL_FAIL;

    if (!Codec) {
        // Get default codec parameters
        Codec = GetCompression();
    }

    std::string extension(Codec->extension);
         if (extension == ".ncvi") Compressor = CVI;
    else if (extension == ".njpg") Compressor = JPEG;
    else return SVL_FAIL;

    unsigned int size;

    while (1) {

        Opened = true;
	    Writing = true;

        // Allocate YUV buffer if not done yet
        size = width * height * 2;
        if (!yuvBuffer) {
            yuvBuffer = new unsigned char[size];
            yuvBufferSize = size;
        }
        else if (yuvBuffer && yuvBufferSize < size) {
            delete [] yuvBuffer;
            yuvBuffer = new unsigned char[size];
            yuvBufferSize = size;
        }

        // Allocate compression buffer if not done yet
        size = width * height * 3;
        size += size / 100 + 4096;
        if (!comprBuffer) {
            comprBuffer = new unsigned char[size];
            comprBufferSize = size;
        }
        else if (comprBuffer && comprBufferSize < size) {
            if (comprBufferSize) delete [] comprBuffer;
            comprBuffer = new unsigned char[size];
            comprBufferSize = size;
        }

        // Allocate streaming buffers if not done yet
        for (unsigned int i = 0; i < MAX_CLIENTS; i ++) {
            if (!SendBuffer[i]) {
                SendBuffer[i] = new svlBufferMemory(size);
            }
            else if (SendBuffer[i] && SendBuffer[i]->GetMaxSize() < size) {
                delete SendBuffer[i];
                SendBuffer[i] = new svlBufferMemory(size);
            }
        }

        // Start data saving thread
        ServerInitialized = false;
        KillServerThread = false;
        ServerThread = new osaThread;
        ServerInitEvent = new osaThreadSignal;
        ServerThread->Create<svlVideoCodecTCPStream, unsigned short>(this, &svlVideoCodecTCPStream::ServerProc, SocketPort);
        ServerInitEvent->Wait();
        if (ServerInitialized == false) break;

        BegPos = EndPos = Pos = 0;
        Width = width;
        Height = height;

        return SVL_OK;
    }

	Close();
	return SVL_FAIL;
}