当前位置: 首页>>代码示例>>C++>>正文


C++ XRef类代码示例

本文整理汇总了C++中XRef的典型用法代码示例。如果您正苦于以下问题:C++ XRef类的具体用法?C++ XRef怎么用?C++ XRef使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了XRef类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: printf

void H264UserDataTest::TestZeroRawSEI()
{
    printf("H264UserDataTest::TestZeroRawSEI()\n");
    fflush(stdout);

    XIRef<XMemory> data = new XMemory;

    for(uint8_t i = 1; i < 77; ++i)
        data->Append<uint8_t>(0);

    XRef<SEIPayload> payload = new SEIPayload(data);
    CPPUNIT_ASSERT(payload->GetData().Get() == data.Get());
    CPPUNIT_ASSERT(payload->GetUUID() == XUuid("7e0858c4-38fe-48ea-852d-dace39badb30"));

    H264UserData before(payload);
    const std::vector<XRef<SEIPayload> >& beforePayloads = before.GetPayloads();
    CPPUNIT_ASSERT(beforePayloads.size() == 1);
    CPPUNIT_ASSERT(beforePayloads.front() == payload);
    XIRef<XMemory> sei = before.GenSEI();

    H264UserData after(sei->begin(), sei->GetDataSize());
    const std::vector<XRef<SEIPayload> >& afterPayloads = before.GetPayloads();
    CPPUNIT_ASSERT(afterPayloads.size() == 1);
    CPPUNIT_ASSERT(afterPayloads.front().Get() == payload.Get());
}
开发者ID:KennyDark,项目名称:opencvr,代码行数:25,代码来源:H264UserDataTest.cpp

示例2: TestMaxSamples

void XStatisticsTest::TestMaxSamples()
{
    XRef<XStatistics<Average,double> > avg = new XStatistics<Average,double>(MAX_SAMPLES);
    UT_ASSERT( avg.IsValid() == true );
    for (size_t ii=0; ii<g_testLen; ++ii)
        avg->AddSample(g_test[ii]);
    double result = 0.0;
    UT_ASSERT_NO_THROW( avg->GetResult(result) );

    // "Hand-calculate" the average
    double answer = 0.0;
    for (size_t ii=g_testLen-MAX_SAMPLES; ii<g_testLen; ++ii)
        answer += g_test[ii];
    answer /= MAX_SAMPLES;

    UT_ASSERT( answer == result );

    int count = -1;
    UT_ASSERT_NO_THROW( count = avg->GetNumSamples() );
    UT_ASSERT( count == MAX_SAMPLES );
    UT_ASSERT_NO_THROW( count = avg->GetMaxSamples() );
    UT_ASSERT( count == MAX_SAMPLES );

    UT_ASSERT_NO_THROW( avg->SetMaxSamples( MAX_SAMPLES + 1 ) );
    UT_ASSERT( count = avg->GetMaxSamples() );
    UT_ASSERT( count == MAX_SAMPLES + 1 );
    for (size_t ii=0; ii<g_testLen; ++ii)
        avg->AddSample(g_test[ii]);
    UT_ASSERT_NO_THROW( count = avg->GetNumSamples() );
    UT_ASSERT( count == MAX_SAMPLES + 1 );
}
开发者ID:KennyDark,项目名称:opencvr,代码行数:31,代码来源:XStatisticsTest.cpp

示例3: removeSymbol

  void removeSymbol( const Symbol & sym, XRef & it)
  {
    iterator item = it.begin();
    iterator last = it.end();

    while (item != last)
    {
      iterator thisOne = item++;

      if ((*thisOne).second == sym)
      {
	it.erase( thisOne );
      }
    }
  }
开发者ID:madGambol,项目名称:OMDT,代码行数:15,代码来源:circAnalysis.cpp

示例4: set_media_box

void set_media_box(PDFDoc * doc, int page, PDFRectangle * rect)
{
	XRef *xref = doc->getXRef();
	//int num = xref->getNumObjects();
	Catalog *catalog = doc->getCatalog();
	Ref *ref = catalog->getPageRef(page);

	XRefEntry *entry = xref->getEntry(ref->num);
	Object obj;
	xref->fetch(ref->num, ref->gen, &obj);
	Object *newArray =
	    mk_box_array(rect->x1, rect->y1, rect->x2, rect->y2);
	obj.dictSet((char *) "MediaBox", newArray);
	entry->obj = obj;
	entry->updated = gTrue;
}
开发者ID:hamano,项目名称:pdfclip,代码行数:16,代码来源:pdfclip.cpp

示例5: TestAverage

void XStatisticsTest::TestAverage()
{
    XRef<XStatistics<Average,double> > avg = new XStatistics<Average,double>;
    UT_ASSERT( avg.IsValid() == true );
    for (size_t ii=0; ii<g_testLen; ++ii)
        avg->AddSample(g_test[ii]);
    double result = 0.0;
    UT_ASSERT_NO_THROW( avg->GetResult(result) );

    // "Hand-calculate" the average
    double answer = 0.0;
    for (size_t ii=0; ii<g_testLen; ++ii)
        answer += g_test[ii];
    answer /= g_testLen;

    UT_ASSERT( answer == result );
}
开发者ID:KennyDark,项目名称:opencvr,代码行数:17,代码来源:XStatisticsTest.cpp

示例6: while

void CmnOAPIServer::run()
{
	m_port = 9080;
        XSocket socket;

        socket.Bind(m_port);
        socket.Listen();

	while(1)
	{
		XRef<XSocket> clientSocket = socket.Accept();

		CmnOAPIServerSession *session = new CmnOAPIServerSession(m_pFactory, 
			clientSocket);
		session->start();
#if 0

		ServerSideRequest request;
		try
		{
			request.ReadRequest(clientSocket);

			const URI uri = request.GetURI();

			XString body = "<!DOCTYPE html>\
			<html>\
			<head ><title>OpenCVR</title></head>\
			<body>\
			<h1>Wellcome OpenCVR //TODO</h1><br>\
			</body>\
			</html>";

			ServerSideResponse ssResponse;
			ssResponse.SetBody(body);
			ssResponse.SetContentType("text/html; charset=UTF-8");
			ssResponse.WriteResponse(clientSocket);
		}
		catch(XSDK::XException)
		{
		}
		
		clientSocket->Shutdown(SOCKET_SHUT_FLAGS);
		clientSocket->Close();
#endif
	}
}
开发者ID:KennyDark,项目名称:opencvr,代码行数:46,代码来源:cmnoapiserverimpl.hpp

示例7: TestMedian

void XStatisticsTest::TestMedian()
{
    XRef<XStatistics<Median,double> > med = new XStatistics<Median,double>;
    UT_ASSERT( med.IsValid() == true );
    for (size_t ii=0; ii<g_testLen; ++ii)
        med->AddSample(g_test[ii]);
    double result = 0.0;
    UT_ASSERT_NO_THROW( med->GetResult(result) );

    // "Hand-calculate" the median
    vector<double> sorted(g_testLen);
    for (size_t ii=0; ii<g_testLen; ++ii)
        sorted[ii] = g_test[ii];
    sort(sorted.begin(), sorted.end());
    double answer = sorted[g_testLen/2];

    UT_ASSERT( answer == result );
}
开发者ID:KennyDark,项目名称:opencvr,代码行数:18,代码来源:XStatisticsTest.cpp

示例8: main

int main(int argc, char *argv[])
{
	XRef<XSocket> pSocket = new XSocket;
	
	try
    {
		XSDK::XString host = "127.0.0.1";
		pSocket->Connect(host, 9080);
		
		oapi::DeviceList list;
		OAPIClient pClient(pSocket);
		
		pClient.DeviceListRequest(list);
    }
	catch( XSDK::XException& ex )
	{
		
	}
	
	x_sleep(10000);
}
开发者ID:licshire,项目名称:opencvr,代码行数:21,代码来源:oapicmain.cpp

示例9: XDuration

void XStatisticsTest::TestSampleTimeout()
{
    // Add samples, wait half the expiration time, add more samples,
    // wait a little over half the expiration time, make sure half
    // the sample have been pruned.
    XRef<XStatistics<Average,double> > avg = new XStatistics<Average,double>(g_testLen*10, XDuration(XSDK::SECONDS, MAX_DURATION_SEC));
    UT_ASSERT( avg.IsValid() == true );
    for (size_t ii=0; ii<g_testLen; ++ii)
        avg->AddSample(g_test[ii]);

    x_sleep(MAX_DURATION_SEC / 2);

    for (size_t ii=0; ii<g_testLen; ++ii)
        avg->AddSample(g_test[ii]);

    x_sleep( (MAX_DURATION_SEC / 2) + (MAX_DURATION_SEC / 4) );

    double result = 0.0;
    UT_ASSERT_NO_THROW( avg->GetResult(result) );

    int count = -1;
    UT_ASSERT_NO_THROW( count = avg->GetNumSamples() );
    UT_ASSERT( count == (int)g_testLen );

    // "Hand-calculate" the average
    double answer = 0.0;
    for (size_t ii=0; ii<g_testLen; ++ii)
        answer += g_test[ii];
    answer /= g_testLen;

    UT_ASSERT( answer == result );
}
开发者ID:KennyDark,项目名称:opencvr,代码行数:32,代码来源:XStatisticsTest.cpp

示例10: _FinishInit

void TranscodeExport::_FinishInit( XRef<H264Encoder>& encoder,
                                   XRef<AVMuxer>& muxer,
                                   H264Decoder& decoder,
                                   const XString& tempFileName,
                                   bool outputToFile,
                                   int traversalNum,
                                   int traversalDen )
{
    // Now that we have decoded the first frame, we can finish initializing everything...

    // First, we should finish initializing our Decoder by setting an output resolution.
    uint16_t width = 0;
    uint16_t height = 0;

    AspectCorrectDimensions( decoder.GetInputWidth(), decoder.GetInputHeight(),
                             _requestedWidth, _requestedHeight,
                             width, height );

    decoder.SetOutputWidth( width );
    decoder.SetOutputHeight( height );

    // Configure and create our encoder...
    int timeBaseNum = 0;
    int timeBaseDen = 0;
    AVKit::DToQ( (1 / _frameRate), timeBaseNum, timeBaseDen );

    CodecOptions options = GetCRFH264EncoderOptions( 26, width, height, 15, timeBaseNum, timeBaseDen );

    encoder = new H264Encoder( options, false );

    // Create our muxer...
    muxer = new AVMuxer( encoder->GetOptions(),
                         tempFileName,
                         (outputToFile) ? AVMuxer::OUTPUT_LOCATION_FILE : AVMuxer::OUTPUT_LOCATION_BUFFER );

    // Finally, provide the muxer with our encoders extra data so we create valid conainers.
    muxer->SetExtraData( encoder->GetExtraData() );
}
开发者ID:MultiSight,项目名称:exporty,代码行数:38,代码来源:TranscodeExport.cpp

示例11: _CleanSocket

void ClientSideResponse::_CleanSocket(XRef<XStreamIO> socket, char** writer)
{
    if ( socket.IsEmpty() )
        X_STHROW(WebbyException, ("StreamIO is null"));

    if(!socket->Valid())
        X_STHROW(WebbyException, ("Invalid Socket"));

    char tempBuffer[1];

    // Clear junk off the socket
    while(true)
    {
        if(!_ReceiveData(socket, tempBuffer, 1))
            X_STHROW(WebbyException, ("Failed to read data from socket->"));

        if(!XString::IsSpace(tempBuffer[0]))
        {
            **writer = tempBuffer[0];
            ++*writer;
            break;
        }
    }
}
开发者ID:MultiSight,项目名称:webby,代码行数:24,代码来源:ClientSideResponse.cpp

示例12: AVMuxer

void AVMuxerTest::TestRecontainerize()
{
    struct CodecOptions options;

    options.gop_size = 15;
    options.bit_rate = 1424400; // size of gop * 8 == bit_rate
    options.width = 1280;
    options.height = 720;
    options.time_base_num = 1;
    options.time_base_den = 30;

    XRef<AVMuxer> c = new AVMuxer( options,
                                   "bar.mp4",
                                   AVMuxer::OUTPUT_LOCATION_FILE );

    for( int i = 0; i < NUM_FRAMES_IN_GOP; i++ )
    {
        int index = i % NUM_FRAMES_IN_GOP;
        XIRef<Packet> pkt = new Packet( gop[index].frame, gop[index].frameSize, false );
        c->WriteVideoPacket( pkt, ((i % 15) == 0) ? true : false );
    }

    c->FinalizeFile();
}
开发者ID:MultiSight,项目名称:avkit,代码行数:24,代码来源:AVMuxerTest.cpp

示例13: _main

int _main(int argc, char* argv[], stringstream * preLog)
{
  int fromPage = 1;
  int toPage = 0;
  char * usageString = "\npdfToText: Wrong arguments. Usage: pdfToText(.exe) [input pdf file] [otput txt file] [optional args]\n\
                       Optional arguments are: -pfrom [page number], -pto [page number], -logenabled\n";

  if(argc < 3 || argc > 8) //program inputFile oputputFile [optional]
	{
		cerr << "\npdfToText: Wrong number of arguments.\n";
		cout << usageString;
		return 1;
	}
		
	char * inputFilePath = argv[1];
  //Open the PDF source file:
  *preLog << "\nOpening source file " << inputFilePath;
  cerr << "Input file: " << inputFilePath << endl;
	ifstream filei (inputFilePath, ios::binary);
	if (!filei.is_open() || !filei.good())
	{
		cerr << "\npdfToText: Could not open input file";
    cout << "\nCould not open input file.";
		return 2; //files couldnt be opened
	}
	filei.clear();

	char * outputFilePath = argv[2];
	//Discard existing output:
	*preLog << "\nOpening output file " << outputFilePath;
  FILE * fileo = fopen( outputFilePath, "wb");
	if (fileo == null)
	{
		cerr << "\npdfToText: Could not open output file";
    cout << "\nCould not open output file";
		return 2; //files couldnt be opened
	}

  //Process optional arguments
  for(int argindex = 3; argindex < argc; argindex++)
  {
    if(stricmp(argv[argindex], "-pfrom") == 0)
    {
      if(argindex+1 < argc)
      {
        argindex++;
        long int pfrom = strtol(argv[argindex], null, 10);
        if(pfrom > 0 && pfrom < INT_MAX)
        {
          fromPage = (int) pfrom;
          continue;
        }
      }
    }
    if(stricmp(argv[argindex], "-pto") == 0)
    {
      if(argindex+1 < argc)
      {
        argindex++;
        long int pto = strtol(argv[argindex], null, 10);
        if(pto > 0 && pto < INT_MAX)
        {
          toPage = (int) pto;
          continue;
        }
      }
    }
    if(stricmp(argv[argindex], "-logenabled") == 0)
    {
      logEnabled = true;
      continue;
    }
    cerr << "\npdfToText: Wrong arguments.\n";
    cout << usageString;
    return 1;
  }

  if(logEnabled)
  {
    clog<<preLog->str();
  }

	conv_desc = iconv_open ("WCHAR_T", "UTF-16BE");
	if (conv_desc == (iconv_t)-1)
	{
		/* Initialization failure. */
		cerr << "\npdfToText: Iconv init failed.\n";
		return 5;
	}
	//-----------------------------------------------
	//---- Read reference table and find objects ----
  if(logEnabled)
		clog<< "\n\n-=| Finding refference table and its objects |=-\n";

	objectMap = new map < pair<int,int>, IndirectObject*>;
	map <pair<int,int>, IndirectObject*>::iterator objectMapIterator;

	XRef * refTable = new XRef(filei);
  XRef * firstRefTable = refTable;
  if(logEnabled)
//.........这里部分代码省略.........
开发者ID:bujocek,项目名称:pdf-to-text,代码行数:101,代码来源:pdfToText.cpp

示例14: _GetTMPName

void TranscodeExport::Create( XIRef<XMemory> output )
{
    XString tempFileName = _GetTMPName( _fileName );

    // If their is only 1 export in progress (us), but the temp file exists then it means we were interrupted
    // (either a power issue, or a segfault) and we should delete the temporary.
    if( _exportsInProgress == 1 )
    {
        if( XPath::Exists(tempFileName) )
            unlink(tempFileName.c_str());
    }

    if( XPath::Exists(tempFileName) )
        X_THROW(("Export in progress exception: %s", tempFileName.c_str()));

    bool outputToFile = (output.IsEmpty()) ? true : false;
    H264Decoder decoder( GetFastH264DecoderOptions() );
    XRef<YUV420PToARGB24> yuvToARGB = new YUV420PToARGB24;
    XRef<ARGB24ToYUV420P> argbToYUV = new ARGB24ToYUV420P;
    XRef<H264Transcoder> transcoder;
    XRef<H264Encoder> encoder;
    XRef<AVMuxer> muxer;
    XRef<ExportOverlay> ov;
    bool wroteToContainer = false;

    auto lastProgressTime = steady_clock::now();

    // We are going to count how many decoding or encoding exceptions we get... If it
    // ever exceeds some large threshold, we bail on this export.
    int64_t codingExceptions = 0;

    XString recorderURI;
    while( _recorderURLS.GetNextURL( recorderURI ) )
    {
        auto now = steady_clock::now();
        if( wroteToContainer && duration_cast<seconds>(now-lastProgressTime).count() > 2 )
        {
            _progress( _recorderURLS.PercentComplete() );
            lastProgressTime = now;
        }
        
        try
        {
            XIRef<XMemory> responseBuffer = FRAME_STORE_CLIENT::FetchMedia( _config->GetRecorderIP(),
                                                                            _config->GetRecorderPort(),
                                                                            recorderURI );

            ResultParser resultParser;

            resultParser.Parse( responseBuffer );

            FRAME_STORE_CLIENT::ResultStatistics stats = resultParser.GetStatistics();

            // If we are not provided with a bit rate or a frame rate, we use the sources values.
            if( _bitRate == 0 )
                _bitRate = stats.averageBitRate;
            
            if( _maxRate == 0 )
                _maxRate = 2 * stats.averageBitRate;

            if( _bufSize == 0 )
                _bufSize = 2 * stats.averageBitRate;

            if( _frameRate == 0.0 )
                _frameRate = stats.frameRate;

            // Fix for ffmpeg's inability to make files with fps < 6.0. Don't believe me? Try these 2 commands and play
            // output in vlc:
            //
            //   # generate a test movie of the game of life in life.mp4
            //   ffmpeg -f lavfi -i life -frames:v 1000 life.mp4
            //   # transcode and drop framerate of life.mp4 to 1 fps. output.mp4 won't play in vlc and will have a weird
            //   # pause at the beginning for other players.
            //   ffmpeg -i life.mp4 -vf fps=fps=1/1 -vcodec h264 output.mp4
            //
            if( _frameRate < 6.0 )
                _frameRate = 6.0;

            int outputTimeBaseNum = 0;
            int outputTimeBaseDen = 0;
            int inputTimeBaseNum = 0;
            int inputTimeBaseDen = 0;

            AVKit::DToQ( (1/stats.frameRate), inputTimeBaseNum, inputTimeBaseDen );
            AVKit::DToQ( (1/_frameRate), outputTimeBaseNum, outputTimeBaseDen );

            if( transcoder.IsEmpty() )
            {
                transcoder = new H264Transcoder( inputTimeBaseNum, inputTimeBaseDen,
                                                 outputTimeBaseNum, outputTimeBaseDen,
                                                 _speed,
                                                 // if our input is key only, enable decode skipping...
                                                 _recorderURLS.KeyFrameOnly() );
            }

            double secondsPer = AVKit::QToD(inputTimeBaseNum, inputTimeBaseDen) / (AVKit::QToD(inputTimeBaseNum, inputTimeBaseDen) / (AVKit::QToD(outputTimeBaseNum, outputTimeBaseDen) * _speed));
            int traversalNum = 0;
            int traversalDen = 0;

            AVKit::DToQ( secondsPer, traversalNum, traversalDen );
//.........这里部分代码省略.........
开发者ID:MultiSight,项目名称:exporty,代码行数:101,代码来源:TranscodeExport.cpp

示例15: _ReceiveData

bool ClientSideResponse::_ReceiveData(XRef<XStreamIO> socket, void* data, size_t dataLen)
{
    const ssize_t bytesSent = socket->Recv(data, dataLen);

    return socket->Valid() && bytesSent == (ssize_t)dataLen;
}
开发者ID:MultiSight,项目名称:webby,代码行数:6,代码来源:ClientSideResponse.cpp


注:本文中的XRef类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。