H223LowerLayer::H223LowerLayer(int32 aPortTag, TPVLoopbackMode aLoopbackMode) : PvmfPortBaseImpl(aPortTag, this), OsclTimerObject(OsclActiveObject::EPriorityHigh, "H223AO"), iTimerIntervalNum(0), iMinTimerResolution(TIMER_RES), iObserver(NULL), iMemFragmentAlloc(NULL), iDispatchPacketAlloc(NULL), iMediaDataImplMemAlloc(NULL), iMediaMsgPoolAlloc(NULL), iSendPduSz(0), iPduSize(H223_DEFAULT_PDU_SIZE), iStuffingSize(0), iTimer("H223LL"), iLoopbackMode(aLoopbackMode), iTimerCnt(0), iBytesSent(0), iMediaDataAlloc(&iMemAlloc), iLogger(NULL), iDemuxBuffer(NULL), iDemuxBufferPos(NULL), iIdleSyncCheckBuffer(NULL) { iLogger = PVLogger::GetLoggerObject("3g324m.h223.lowerlayer"); AddToScheduler(); InitParams(); ResetStats(); }
void PingStatistics::Update( IP_STATUS S ) { _list_rw_lock.w_lock(); _pings.push_front( PingStatus( S ) ); if( _pings.size() > _pingsNum ) { _pings.pop_back(); } if( S == IP_SUCCESS ) { if( _onlineStrike < MAX_STRIKE_NUMBER ) _onlineStrike++; _offlineStrike = 0; } else { if( _offlineStrike < MAX_STRIKE_NUMBER ) _offlineStrike++; _onlineStrike = 0; } ResetStats(); for( auto it = _pings.begin(); it != _pings.end(); it++ ) { if( it->Status != IP_SUCCESS ) _bad++; } _percs = ( (float) _bad / _pings.size() ) * 100; _list_rw_lock.w_unlock(); }
// Called when the game starts or when spawned void AMyBallClass::BeginPlay() { Super::BeginPlay(); ResetStats(); //SetPowerUp(PowerUp::PowerUpType::strength); }
CNO::CNO( unsigned int seed, D3DXVECTOR3 &position) : m_seed( seed), m_position( position) { // init members for( int i= 0; i < NUM_LVLS; i++) { m_LevelHeads[ i].SetNonTerminal( 'H'); m_LevelHeads[ i].SetLevel( i); m_levelBodyDataBeginsAt[ i] = 777; m_levelBodyIndexDataBeginsAt[ i] = 777; m_levelPSDataBeginsAt[ i] = 777; } // set all levels buffers and chains to NULL m_PSVertBuf = NULL; m_bodyVertBuf = NULL; m_indexBuffer = NULL; // set # of active levels to 0 m_curActiveLevels = 0; m_lastDistance = 0; ZeroMemory( m_centerDistances, sizeof( float) * NUM_LVLS); m_LoDSteps[ 0] = 1; // anlu one branch on 0th level so 1 LoD operat #ifdef MYSTATS ResetStats( ); #endif }
JRenderServerGL::JRenderServerGL() { m_Viewport = Frame( 0.0f, 0.0f, 800.0f, 600.0f ); m_CurFrame = 0; m_bInited = false; m_ViewTM = Mat4::identity; m_ProjTM = Mat4::identity; m_WorldTM = Mat4::identity; m_TextureTM = Mat4::identity; m_bCursorVisible = true; m_bHasStencil = false; m_CurFVF = 0; m_QuadIB = -1; m_Ambience = 0xFF333333; m_CurShader = -1; m_BaseIndex = 0; m_RTID = -1; m_DSID = -1; m_bDeviceLost = false; m_FPS = 0; m_bWireFrame = false; g_pRenderServer = this; ResetStats(); }
ezCVarsWidget::ezCVarsWidget(QWidget* parent) : QDockWidget (parent) { s_pWidget = this; setupUi (this); ResetStats(); }
ezGlobalEventsWidget::ezGlobalEventsWidget(QWidget* parent) : QDockWidget (parent) { s_pWidget = this; setupUi (this); ResetStats(); }
void CNetConnection::Init(NETSOCKET Socket) { Reset(); ResetStats(); m_Socket = Socket; mem_zero(m_ErrorString, sizeof(m_ErrorString)); }
void CNetConnection::Init(NETSOCKET Socket, bool BlockCloseMsg) { Reset(); ResetStats(); m_Socket = Socket; m_BlockCloseMsg = BlockCloseMsg; mem_zero(m_ErrorString, sizeof(m_ErrorString)); }
void CirclingComputer::Reset() { turn_rate_delta_time.Reset(); turning_delta_time.Reset(); percent_delta_time.Reset(); ResetStats(); }
void fhImmediateMode::Init() { for(int i=0; i<drawVertsCapacity*2; ++i) { lineIndices[i] = i; } ResetStats(); }
//***************************************************************************** void CSwordsman::Clear() { this->wX = this->wY = this->wPrevX = this->wPrevY = this->wO = this->wPrevO = this->wSwordX = this->wSwordY = 0; this->wAppearance = this->wIdentity = M_BEETHRO; this->bSwordOff = false; this->wWaterTraversal = WTrv_AsPlayerRole; ResetStats(); }
/////////////////////////////////// // nuiPainter implementation: nuiPainter::nuiPainter(const nuiRect& rRect, nglContext* pContext) { ResetStats(); mWidth = ToNearest(rRect.GetWidth()); mHeight = ToNearest(rRect.GetHeight()); mMatrixStack.push(nuiMatrix()); mProjectionMatrixStack.push(nuiMatrix()); mProjectionViewportStack.push(nuiRect()); mDummyMode = false; mpSurface = NULL; mAngle=0; mEnableDrawArray = true; }
void AMyBallClass::SetPowerUp(PowerUp::PowerUpType thisPowerUp) { currentPowerup = thisPowerUp; ResetStats(); switch (currentPowerup) { case PowerUp::PowerUpType::strength: Strength = 2; break; case PowerUp::PowerUpType::precision: Pricision = 0; break; case PowerUp::PowerUpType::homing: homing = true; homingDuration = 0; } }
void AMyBallClass::homingBallfunc() { AAdder_DodgeBallCharacter* currentTarget; FVector currentLocation = FVector(this->GetActorLocation().X, this->GetActorLocation().Y, this->GetActorLocation().Z); FVector direction(0, 0, 0); float distance = 5000; for (TActorIterator <AAdder_DodgeBallCharacter> itr(GetWorld()); itr; ++itr) { if ((itr->GetActorLocation() - this->GetActorLocation()).Size() < distance) { if (teamNumber != itr->teamNumber) { currentTarget = *itr; direction = (currentTarget->GetActorLocation() - this->GetActorLocation()).GetSafeNormal(); } } } this->SetActorLocation(currentLocation + (direction * 20), false, NULL, ETeleportType::TeleportPhysics); if (homingDuration > 1000) ResetStats(); }
BtreeBucket *BtreeCache::ConstructCache(unsigned num_bkts, BtreeSize_t dbkey_size, BtreeNodeOrder_t order) // Constructs and initialize and array of buckets. NOTE: This // implementation uses contiguous memory for the cache buckets. // Returns a pointer to the bucket array or a null value if an // error occurs. { if(!IsEmpty()) DestroyCache(); // Set minimum number of buckets. The gxBtree tree insert function // requires a minimum of 2 cache buckets (left and right pointers) // and both delete functions require a minimum of 3 cache buckets // (left, right, and parent pointers). if((num_bkts == 0) || (num_bkts < (unsigned)MIN_BTREECACHE_SEGMENTS)) { num_bkts = MIN_BTREECACHE_SEGMENTS; } num_buckets = num_bkts; buckets = new BtreeBucket[num_bkts]; // Construct an array of buckets if(buckets) InitCache(dbkey_size, order); ResetStats(); return buckets; }
ezTimeWidget::ezTimeWidget(QWidget* parent) : QDockWidget (parent) { s_pWidget = this; setupUi (this); ComboTimeframe->blockSignals(true); ComboTimeframe->addItem("Timeframe: 1 minute"); ComboTimeframe->addItem("Timeframe: 2 minutes"); ComboTimeframe->addItem("Timeframe: 3 minutes"); ComboTimeframe->addItem("Timeframe: 4 minutes"); ComboTimeframe->addItem("Timeframe: 5 minutes"); ComboTimeframe->addItem("Timeframe: 6 minutes"); ComboTimeframe->addItem("Timeframe: 7 minutes"); ComboTimeframe->addItem("Timeframe: 8 minutes"); ComboTimeframe->addItem("Timeframe: 9 minutes"); ComboTimeframe->addItem("Timeframe: 10 minutes"); ComboTimeframe->setCurrentIndex(0); ComboTimeframe->blockSignals(false); m_pPathMax = m_Scene.addPath (QPainterPath (), QPen (QBrush (QColor(64, 64, 64)), 0 )); for (ezUInt32 i = 0; i < s_uiMaxColors; ++i) m_pPath[i] = m_Scene.addPath (QPainterPath (), QPen (QBrush (s_Colors[i]), 0 )); QTransform t = TimeView->transform (); t.scale (1, -1); TimeView->setTransform (t); TimeView->setScene(&m_Scene); TimeView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); TimeView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); TimeView->setViewportUpdateMode(QGraphicsView::FullViewportUpdate); //TimeView->setMaximumHeight(100); ResetStats(); }
BBridge::BBridge(ZTime *ztime_, ZSettings *zsettings_, planet_type palette_, bool is_vertical_, unsigned short extra_links_) : ZBuilding(ztime_, zsettings_, palette_) { object_name = "bridge"; //render_img = NULL; //render_damaged_img = NULL; //render_destroyed_img = NULL; palette = palette_; is_vertical = is_vertical_; extra_links = extra_links_; do_rerender = true; do_revive_rerender = false; next_revive_rerender_time = 0; //max_health = BRIDGE_BUILDING_HEALTH; //health = max_health; last_process_health = max_health; ResetStats(); InitTypeId(object_type, object_id); }
Boolean CIrDevice::Init(TIrGlue *irda, AppleIrDASerial *driver) { XTRACE(kLogInit, 0, this); fIrDA = nil; fDriver = nil; fGetBuffer = nil; bzero(&fIrStatus, sizeof(fIrStatus)); fLAPAddr = 0; fSpeed = 0; fBofs = 0; fXmitting = false; // true if in middle of xmit if (!super::init()) return false; fIrDA = irda; fDriver = driver; ResetStats(); return true; }
//----------------------------------------------------------------- // Reset: Reset CPU state //----------------------------------------------------------------- void OR32::Reset(TRegister start_addr /*= VECTOR_RESET*/) { int i; r_pc = start_addr; r_pc_next = start_addr; r_pc_last = start_addr; r_sr = 0; r_epc = 0; r_esr = 0; for (i=0;i<REGISTERS;i++) r_gpr[i] = 0; r_reg_ra = 0; r_reg_rb = 0; r_reg_result = 0; r_rd_wb = 0; r_ra = 0; r_rb = 0; mem_addr = 0; mem_offset = 0; mem_wr = 0; mem_rd = 0; mem_ifetch = 0; Fault = 0; Break = 0; BreakValue = 0; Trace = 0; Cycle = 2; ResetStats(); PeripheralReset(); }
/** * Handles the statistics sub-command. * * @returns Suitable exit code. * @param pArgs The handler arguments. * @param pDebugger Pointer to the debugger interface. */ static RTEXITCODE handleDebugVM_Statistics(HandlerArg *pArgs, IMachineDebugger *pDebugger) { /* * Parse arguments. */ bool fWithDescriptions = false; const char *pszPattern = NULL; /* all */ bool fReset = false; RTGETOPTSTATE GetState; RTGETOPTUNION ValueUnion; static const RTGETOPTDEF s_aOptions[] = { { "--descriptions", 'd', RTGETOPT_REQ_NOTHING }, { "--pattern", 'p', RTGETOPT_REQ_STRING }, { "--reset", 'r', RTGETOPT_REQ_NOTHING }, }; int rc = RTGetOptInit(&GetState, pArgs->argc, pArgs->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 2, 0 /*fFlags*/); AssertRCReturn(rc, RTEXITCODE_FAILURE); while ((rc = RTGetOpt(&GetState, &ValueUnion)) != 0) { switch (rc) { case 'd': fWithDescriptions = true; break; case 'p': if (pszPattern) return errorSyntax("Multiple --pattern options are not permitted"); pszPattern = ValueUnion.psz; break; case 'r': fReset = true; break; default: return errorGetOpt(rc, &ValueUnion); } } if (fReset && fWithDescriptions) return errorSyntax("The --reset and --descriptions options does not mix"); /* * Execute the order. */ com::Bstr bstrPattern(pszPattern); if (fReset) CHECK_ERROR2I_RET(pDebugger, ResetStats(bstrPattern.raw()), RTEXITCODE_FAILURE); else { com::Bstr bstrStats; CHECK_ERROR2I_RET(pDebugger, GetStats(bstrPattern.raw(), fWithDescriptions, bstrStats.asOutParam()), RTEXITCODE_FAILURE); /* if (fFormatted) { big mess } else */ RTPrintf("%ls\n", bstrStats.raw()); } return RTEXITCODE_SUCCESS; }
void jpeg_reset_stats() { ResetStats(); }
void ANetworkController::ReceivedResetStats() { for (TActorIterator<AVehiclestats> ObjIt(GetWorld()); ObjIt; ++ObjIt) { auto Stats = *ObjIt; Stats->ResetStats(); } }
void CTransfersView::AddItem(CDCCTransfer *pDCCTransfer) { if (!pDCCTransfer) return; char SizeStr[11]; BuildSizeString(SizeStr,sizeof(SizeStr)-1,(double)pDCCTransfer->m_Size); /* if (pDCCTransfer->m_Size > 1024 * 1024) _snprintf(SizeStr,10,"%.2fMB",(double)pDCCTransfer->m_Size / (double)(1024 * 1024)); else _snprintf(SizeStr,10,"%.2fKB",(double)pDCCTransfer->m_Size / 1024); */ tm *t = localtime(&pDCCTransfer->m_Time); /* char *DirectionStr; if (pDCCTransfer->m_Type == DCC_RECEIVE) DirectionStr = "Receive"; else DirectionStr = "Send"; */ int itemnum = m_TransfersListCtrl.InsertItem(0,""/*DirectionStr*/,pDCCTransfer->m_Type == DCC_SEND ? TILN_SEND : TILN_RECEIVE); if (itemnum != -1) { m_TransfersListCtrl.AddItem(itemnum,1,pDCCTransfer->m_FileName); m_TransfersListCtrl.AddItem(itemnum,2,pDCCTransfer->m_OtherNick); m_TransfersListCtrl.AddItem(itemnum,3,pDCCTransfer->m_StatusStr); m_TransfersListCtrl.AddItem(itemnum,4,""); m_TransfersListCtrl.AddItem(itemnum,5,""); m_TransfersListCtrl.AddItem(itemnum,6,pDCCTransfer->m_Size > 0 ? SizeStr : "Unknown"); m_TransfersListCtrl.AddItem(itemnum,7,stripcrlf(asctime(t))); m_TransfersListCtrl.AddItem(itemnum,8,pDCCTransfer->m_IPAddressString); if (pDCCTransfer->m_pServer && (g_ServerList.Find(pDCCTransfer->m_pServer) >= 0)) { char *serverstr = HydraIRC_BuildString(128,"%s (%s)", pDCCTransfer->m_pServer->m_pDetails->m_Name, GetNetworkName(pDCCTransfer->m_pServer->m_pDetails->m_NetworkID)); if (serverstr) { m_TransfersListCtrl.AddItem(itemnum,9,serverstr); free(serverstr); } } else m_TransfersListCtrl.AddItem(itemnum,9,"N/A"); m_TransfersListCtrl.SetItemData(itemnum,(DWORD_PTR)pDCCTransfer); } TransferStats_t *pTS = (TransferStats_t *)malloc(sizeof (TransferStats_t)); if (pTS) { ZeroMemory(pTS,sizeof (TransferStats_t)); pTS->pDCCTransfer = pDCCTransfer; CNode *pNode = new CNode(pTS); m_TransferStats.AddTail(pNode); ResetStats(pDCCTransfer); } }
void PingStatistics::Reset( void ) { _list_rw_lock.w_lock(); ResetStats(); _pings.resize( 0 ); _list_rw_lock.w_unlock(); }
bool Zone::CheckAlarms( const Image *delta_image ) { ResetStats(); if ( overload_count ) { Info( "In overload mode, %d frames of %d remaining", overload_count, overload_frames ); Debug( 4, "In overload mode, %d frames of %d remaining", overload_count, overload_frames ); overload_count--; return( false ); } delete image; // Get the difference image Image *diff_image = image = new Image( *delta_image ); int diff_width = diff_image->Width(); uint8_t* diff_buff = (uint8_t*)diff_image->Buffer(); uint8_t* pdiff; const uint8_t* ppoly; unsigned int pixel_diff_count = 0; int alarm_lo_x = 0; int alarm_hi_x = 0; int alarm_lo_y = 0; int alarm_hi_y = 0; int alarm_mid_x = -1; int alarm_mid_y = -1; unsigned int lo_y = polygon.LoY(); unsigned int lo_x = polygon.LoX(); unsigned int hi_x = polygon.HiX(); unsigned int hi_y = polygon.HiY(); Debug( 4, "Checking alarms for zone %d/%s in lines %d -> %d", id, label, lo_y, hi_y ); Debug( 5, "Checking for alarmed pixels" ); /* if(config.cpu_extensions && sseversion >= 20) { sse2_alarmedpixels(diff_image, pg_image, &alarm_pixels, &pixel_diff_count); } else { std_alarmedpixels(diff_image, pg_image, &alarm_pixels, &pixel_diff_count); } */ std_alarmedpixels(diff_image, pg_image, &alarm_pixels, &pixel_diff_count); if ( config.record_diag_images ) { static char diag_path[PATH_MAX] = ""; if ( !diag_path[0] ) { snprintf( diag_path, sizeof(diag_path), "%s/%s/diag-%d-%d.jpg", config.dir_events, monitor->Name(), id, 1 ); } diff_image->WriteJpeg( diag_path ); } if ( pixel_diff_count && alarm_pixels ) pixel_diff = pixel_diff_count/alarm_pixels; Debug( 5, "Got %d alarmed pixels, need %d -> %d, avg pixel diff %d", alarm_pixels, min_alarm_pixels, max_alarm_pixels, pixel_diff ); if( alarm_pixels ) { if( min_alarm_pixels && (alarm_pixels < (unsigned int)min_alarm_pixels) ) { /* Not enough pixels alarmed */ return (false); } else if( max_alarm_pixels && (alarm_pixels > (unsigned int)max_alarm_pixels) ) { /* Too many pixels alarmed */ overload_count = overload_frames; return (false); } } else { /* No alarmed pixels */ return (false); } score = (100*alarm_pixels)/polygon.Area(); if(score < 1) score = 1; /* Fix for score of 0 when frame meets thresholds but alarmed area is not big enough */ Debug( 5, "Current score is %d", score ); if ( check_method >= FILTERED_PIXELS ) { int bx = filter_box.X(); int by = filter_box.Y(); int bx1 = bx-1; int by1 = by-1; Debug( 5, "Checking for filtered pixels" ); if ( bx > 1 || by > 1 ) { // Now remove any pixels smaller than our filter size unsigned char *cpdiff; int ldx, hdx, ldy, hdy; bool block; for ( unsigned int y = lo_y; y <= hi_y; y++ ) { int lo_x = ranges[y].lo_x; int hi_x = ranges[y].hi_x; pdiff = (uint8_t*)diff_image->Buffer( lo_x, y ); for ( int x = lo_x; x <= hi_x; x++, pdiff++ ) { if ( *pdiff == WHITE ) { // Check participation in an X block ldx = (x>=(lo_x+bx1))?-bx1:lo_x-x; hdx = (x<=(hi_x-bx1))?0:((hi_x-x)-bx1); ldy = (y>=(lo_y+by1))?-by1:lo_y-y; hdy = (y<=(hi_y-by1))?0:((hi_y-y)-by1); block = false; for ( int dy = ldy; !block && dy <= hdy; dy++ ) { for ( int dx = ldx; !block && dx <= hdx; dx++ ) { block = true; for ( int dy2 = 0; block && dy2 < by; dy2++ ) { for ( int dx2 = 0; block && dx2 < bx; dx2++ ) { cpdiff = diff_buff + (((y+dy+dy2)*diff_width) + (x+dx+dx2)); if ( !*cpdiff ) { block = false; } } } } } if ( !block ) { *pdiff = BLACK; continue; } alarm_filter_pixels++; } } } } else { alarm_filter_pixels = alarm_pixels; } if ( config.record_diag_images ) { static char diag_path[PATH_MAX] = ""; if ( !diag_path[0] ) { snprintf( diag_path, sizeof(diag_path), "%s/%d/diag-%d-%d.jpg", config.dir_events, monitor->Id(), id, 2 ); } diff_image->WriteJpeg( diag_path ); } Debug( 5, "Got %d filtered pixels, need %d -> %d", alarm_filter_pixels, min_filter_pixels, max_filter_pixels ); if( alarm_filter_pixels ) { if( min_filter_pixels && (alarm_filter_pixels < min_filter_pixels) ) { /* Not enough pixels alarmed */ return (false); } else if( max_filter_pixels && (alarm_filter_pixels > max_filter_pixels) ) { /* Too many pixels alarmed */ overload_count = overload_frames; return (false); } } else { /* No filtered pixels */ return (false); } score = (100*alarm_filter_pixels)/(polygon.Area()); if(score < 1) score = 1; /* Fix for score of 0 when frame meets thresholds but alarmed area is not big enough */ Debug( 5, "Current score is %d", score ); if ( check_method >= BLOBS ) { Debug( 5, "Checking for blob pixels" ); typedef struct { unsigned char tag; int count; int lo_x; int hi_x; int lo_y; int hi_y; } BlobStats; BlobStats blob_stats[256]; memset( blob_stats, 0, sizeof(BlobStats)*256 ); uint8_t *spdiff; uint8_t last_x, last_y; BlobStats *bsx, *bsy; BlobStats *bsm, *bss; for ( unsigned int y = lo_y; y <= hi_y; y++ ) { int lo_x = ranges[y].lo_x; int hi_x = ranges[y].hi_x; pdiff = (uint8_t*)diff_image->Buffer( lo_x, y ); for ( int x = lo_x; x <= hi_x; x++, pdiff++ ) { if ( *pdiff == WHITE ) { Debug( 9, "Got white pixel at %d,%d (%p)", x, y, pdiff ); //last_x = (x>lo_x)?*(pdiff-1):0; //last_y = (y>lo_y&&x>=last_lo_x&&x<=last_hi_x)?*(pdiff-diff_width):0; last_x = 0; if(x > 0) { if((x-1) >= lo_x) { last_x = *(pdiff-1); } } last_y = 0; if(y > 0) { if((y-1) >= lo_y && ranges[(y-1)].lo_x <= x && ranges[(y-1)].hi_x >= x) { last_y = *(pdiff-diff_width); } } if ( last_x ) { Debug( 9, "Left neighbour is %d", last_x ); bsx = &blob_stats[last_x]; if ( last_y ) { Debug( 9, "Top neighbour is %d", last_y ); bsy = &blob_stats[last_y]; if ( last_x == last_y ) { Debug( 9, "Matching neighbours, setting to %d", last_x ); // Add to the blob from the x side (either side really) *pdiff = last_x; alarm_blob_pixels++; bsx->count++; if ( x > bsx->hi_x ) bsx->hi_x = x; if ( (int)y > bsx->hi_y ) bsx->hi_y = y; } else { // Aggregate blobs bsm = bsx->count>=bsy->count?bsx:bsy; bss = bsm==bsx?bsy:bsx; Debug( 9, "Different neighbours, setting pixels of %d to %d", bss->tag, bsm->tag ); Debug( 9, "Master blob t:%d, c:%d, lx:%d, hx:%d, ly:%d, hy:%d", bsm->tag, bsm->count, bsm->lo_x, bsm->hi_x, bsm->lo_y, bsm->hi_y ); Debug( 9, "Slave blob t:%d, c:%d, lx:%d, hx:%d, ly:%d, hy:%d", bss->tag, bss->count, bss->lo_x, bss->hi_x, bss->lo_y, bss->hi_y ); // Now change all those pixels to the other setting int changed = 0; for ( int sy = bss->lo_y; sy <= bss->hi_y; sy++) { int lo_sx = bss->lo_x>=ranges[sy].lo_x?bss->lo_x:ranges[sy].lo_x; int hi_sx = bss->hi_x<=ranges[sy].hi_x?bss->hi_x:ranges[sy].hi_x; Debug( 9, "Changing %d, %d->%d", sy, lo_sx, hi_sx ); Debug( 9, "Range %d, %d->%d", sy, ranges[sy].lo_x, ranges[sy].hi_x ); spdiff = diff_buff + ((diff_width * sy) + lo_sx); for ( int sx = lo_sx; sx <= hi_sx; sx++, spdiff++ ) { Debug( 9, "Pixel at %d,%d (%p) is %d", sx, sy, spdiff, *spdiff ); if ( *spdiff == bss->tag ) { Debug( 9, "Setting pixel" ); *spdiff = bsm->tag; changed++; } } } *pdiff = bsm->tag; alarm_blob_pixels++; if ( !changed ) { Info( "Master blob t:%d, c:%d, lx:%d, hx:%d, ly:%d, hy:%d", bsm->tag, bsm->count, bsm->lo_x, bsm->hi_x, bsm->lo_y, bsm->hi_y ); Info( "Slave blob t:%d, c:%d, lx:%d, hx:%d, ly:%d, hy:%d", bss->tag, bss->count, bss->lo_x, bss->hi_x, bss->lo_y, bss->hi_y ); Error( "No pixels changed, exiting" ); exit( -1 ); } // Merge the slave blob into the master bsm->count += bss->count+1; if ( x > bsm->hi_x ) bsm->hi_x = x; if ( (int)y > bsm->hi_y ) bsm->hi_y = y; if ( bss->lo_x < bsm->lo_x ) bsm->lo_x = bss->lo_x; if ( bss->lo_y < bsm->lo_y ) bsm->lo_y = bss->lo_y; if ( bss->hi_x > bsm->hi_x ) bsm->hi_x = bss->hi_x; if ( bss->hi_y > bsm->hi_y ) bsm->hi_y = bss->hi_y; alarm_blobs--; Debug( 6, "Merging blob %d with %d at %d,%d, %d current blobs", bss->tag, bsm->tag, x, y, alarm_blobs ); // Clear out the old blob bss->tag = 0; bss->count = 0; bss->lo_x = 0; bss->lo_y = 0; bss->hi_x = 0; bss->hi_y = 0; } } else { Debug( 9, "Setting to left neighbour %d", last_x ); // Add to the blob from the x side *pdiff = last_x; alarm_blob_pixels++; bsx->count++; if ( x > bsx->hi_x ) bsx->hi_x = x; if ( (int)y > bsx->hi_y ) bsx->hi_y = y; } } else { if ( last_y ) { Debug( 9, "Top neighbour is %d", last_y ); Debug( 9, "Setting to top neighbour %d", last_y ); // Add to the blob from the y side BlobStats *bsy = &blob_stats[last_y]; *pdiff = last_y; alarm_blob_pixels++; bsy->count++; if ( x > bsy->hi_x ) bsy->hi_x = x; if ( (int)y > bsy->hi_y ) bsy->hi_y = y; } else { // Create a new blob int i; for ( i = (WHITE-1); i > 0; i-- ) { BlobStats *bs = &blob_stats[i]; // See if we can recycle one first, only if it's at least two rows up if ( bs->count && bs->hi_y < (int)(y-1) ) { if ( (min_blob_pixels && bs->count < min_blob_pixels) || (max_blob_pixels && bs->count > max_blob_pixels) ) { if ( config.create_analysis_images || config.record_diag_images ) { for ( int sy = bs->lo_y; sy <= bs->hi_y; sy++ ) { spdiff = diff_buff + ((diff_width * sy) + bs->lo_x); for ( int sx = bs->lo_x; sx <= bs->hi_x; sx++, spdiff++ ) { if ( *spdiff == bs->tag ) { *spdiff = BLACK; } } } } alarm_blobs--; alarm_blob_pixels -= bs->count; Debug( 6, "Eliminated blob %d, %d pixels (%d,%d - %d,%d), %d current blobs", i, bs->count, bs->lo_x, bs->lo_y, bs->hi_x, bs->hi_y, alarm_blobs ); bs->tag = 0; bs->count = 0; bs->lo_x = 0; bs->lo_y = 0; bs->hi_x = 0; bs->hi_y = 0; } } if ( !bs->count ) { Debug( 9, "Creating new blob %d", i ); *pdiff = i; alarm_blob_pixels++; bs->tag = i; bs->count++; bs->lo_x = bs->hi_x = x; bs->lo_y = bs->hi_y = y; alarm_blobs++; Debug( 6, "Created blob %d at %d,%d, %d current blobs", bs->tag, x, y, alarm_blobs ); break; } } if ( i == 0 ) { Warning( "Max blob count reached. Unable to allocate new blobs so terminating. Zone settings may be too sensitive." ); x = hi_x+1; y = hi_y+1; } } } } } } if ( config.record_diag_images ) { static char diag_path[PATH_MAX] = ""; if ( !diag_path[0] ) { snprintf( diag_path, sizeof(diag_path), "%s/%d/diag-%d-%d.jpg", config.dir_events, monitor->Id(), id, 3 ); } diff_image->WriteJpeg( diag_path ); } if ( !alarm_blobs ) { return( false ); } Debug( 5, "Got %d raw blob pixels, %d raw blobs, need %d -> %d, %d -> %d", alarm_blob_pixels, alarm_blobs, min_blob_pixels, max_blob_pixels, min_blobs, max_blobs ); // Now eliminate blobs under the threshold for ( int i = 1; i < WHITE; i++ ) { BlobStats *bs = &blob_stats[i]; if ( bs->count ) { if ( (min_blob_pixels && bs->count < min_blob_pixels) || (max_blob_pixels && bs->count > max_blob_pixels) ) { if ( config.create_analysis_images || config.record_diag_images ) { for ( int sy = bs->lo_y; sy <= bs->hi_y; sy++ ) { spdiff = diff_buff + ((diff_width * sy) + bs->lo_x); for ( int sx = bs->lo_x; sx <= bs->hi_x; sx++, spdiff++ ) { if ( *spdiff == bs->tag ) { *spdiff = BLACK; } } } } alarm_blobs--; alarm_blob_pixels -= bs->count; Debug( 6, "Eliminated blob %d, %d pixels (%d,%d - %d,%d), %d current blobs", i, bs->count, bs->lo_x, bs->lo_y, bs->hi_x, bs->hi_y, alarm_blobs ); bs->tag = 0; bs->count = 0; bs->lo_x = 0; bs->lo_y = 0; bs->hi_x = 0; bs->hi_y = 0; } else { Debug( 6, "Preserved blob %d, %d pixels (%d,%d - %d,%d), %d current blobs", i, bs->count, bs->lo_x, bs->lo_y, bs->hi_x, bs->hi_y, alarm_blobs ); if ( !min_blob_size || bs->count < min_blob_size ) min_blob_size = bs->count; if ( !max_blob_size || bs->count > max_blob_size ) max_blob_size = bs->count; } } } if ( config.record_diag_images ) { static char diag_path[PATH_MAX] = ""; if ( !diag_path[0] ) { snprintf( diag_path, sizeof(diag_path), "%s/%d/diag-%d-%d.jpg", config.dir_events, monitor->Id(), id, 4 ); } diff_image->WriteJpeg( diag_path ); } Debug( 5, "Got %d blob pixels, %d blobs, need %d -> %d, %d -> %d", alarm_blob_pixels, alarm_blobs, min_blob_pixels, max_blob_pixels, min_blobs, max_blobs ); if( alarm_blobs ) { if( min_blobs && (alarm_blobs < min_blobs) ) { /* Not enough pixels alarmed */ return (false); } else if(max_blobs && (alarm_blobs > max_blobs) ) { /* Too many pixels alarmed */ overload_count = overload_frames; return (false); } } else { /* No blobs */ return (false); } score = (100*alarm_blob_pixels)/(polygon.Area()); if(score < 1) score = 1; /* Fix for score of 0 when frame meets thresholds but alarmed area is not big enough */ Debug( 5, "Current score is %d", score ); alarm_lo_x = polygon.HiX()+1; alarm_hi_x = polygon.LoX()-1; alarm_lo_y = polygon.HiY()+1; alarm_hi_y = polygon.LoY()-1; for ( int i = 1; i < WHITE; i++ ) { BlobStats *bs = &blob_stats[i]; if ( bs->count ) { if ( bs->count == max_blob_size ) { if ( config.weighted_alarm_centres ) { unsigned long x_total = 0; unsigned long y_total = 0; for ( int sy = bs->lo_y; sy <= bs->hi_y; sy++ ) { spdiff = diff_buff + ((diff_width * sy) + bs->lo_x); for ( int sx = bs->lo_x; sx <= bs->hi_x; sx++, spdiff++ ) { if ( *spdiff == bs->tag ) { x_total += sx; y_total += sy; } } } alarm_mid_x = int(round(x_total/bs->count)); alarm_mid_y = int(round(y_total/bs->count)); } else { alarm_mid_x = int((bs->hi_x+bs->lo_x+1)/2); alarm_mid_y = int((bs->hi_y+bs->lo_y+1)/2); } } if ( alarm_lo_x > bs->lo_x ) alarm_lo_x = bs->lo_x; if ( alarm_lo_y > bs->lo_y ) alarm_lo_y = bs->lo_y; if ( alarm_hi_x < bs->hi_x ) alarm_hi_x = bs->hi_x; if ( alarm_hi_y < bs->hi_y ) alarm_hi_y = bs->hi_y; } } } else { alarm_mid_x = int((alarm_hi_x+alarm_lo_x+1)/2); alarm_mid_y = int((alarm_hi_y+alarm_lo_y+1)/2); } } if ( type == INCLUSIVE ) { // score >>= 1; score /= 2; } else if ( type == EXCLUSIVE ) { // score <<= 1; score *= 2; } Debug( 5, "Adjusted score is %d", score ); // Now outline the changed region if ( score ) { alarm_box = Box( Coord( alarm_lo_x, alarm_lo_y ), Coord( alarm_hi_x, alarm_hi_y ) ); //if ( monitor->followMotion() ) if ( true ) { alarm_centre = Coord( alarm_mid_x, alarm_mid_y ); } else { alarm_centre = alarm_box.Centre(); } if ( (type < PRECLUSIVE) && check_method >= BLOBS && config.create_analysis_images ) { // First mask out anything we don't want for ( unsigned int y = lo_y; y <= hi_y; y++ ) { pdiff = diff_buff + ((diff_width * y) + lo_x); int lo_x2 = ranges[y].lo_x; int hi_x2 = ranges[y].hi_x; int lo_gap = lo_x2-lo_x; if ( lo_gap > 0 ) { if ( lo_gap == 1 ) { *pdiff++ = BLACK; } else { memset( pdiff, BLACK, lo_gap ); pdiff += lo_gap; } } ppoly = pg_image->Buffer( lo_x2, y ); for ( int x = lo_x2; x <= hi_x2; x++, pdiff++, ppoly++ ) { if ( !*ppoly ) { *pdiff = BLACK; } } int hi_gap = hi_x-hi_x2; if ( hi_gap > 0 ) { if ( hi_gap == 1 ) { *pdiff = BLACK; } else { memset( pdiff, BLACK, hi_gap ); } } } if( monitor->Colours() == ZM_COLOUR_GRAY8 ) { image = diff_image->HighlightEdges( alarm_rgb, ZM_COLOUR_RGB24, ZM_SUBPIX_ORDER_RGB, &polygon.Extent() ); } else { image = diff_image->HighlightEdges( alarm_rgb, monitor->Colours(), monitor->SubpixelOrder(), &polygon.Extent() ); } // Only need to delete this when 'image' becomes detached and points somewhere else delete diff_image; } else { delete image; image = 0; } Debug( 1, "%s: Pixel Diff: %d, Alarm Pixels: %d, Filter Pixels: %d, Blob Pixels: %d, Blobs: %d, Score: %d", Label(), pixel_diff, alarm_pixels, alarm_filter_pixels, alarm_blob_pixels, alarm_blobs, score ); } return( true ); }
void CGameStats::StartGame(bool server) { if(!server && gEnv->bServer)//we simply ignore client events on server return; if(IGameRulesSystem* pGR = gEnv->pGame->GetIGameFramework()->GetIGameRulesSystem()) { IGameRules *pR = pGR->GetCurrentGameRules(); if(pR) { IEntityScriptProxy *pScriptProxy=static_cast<IEntityScriptProxy *>(pR->GetEntity()->GetProxy(ENTITY_PROXY_SCRIPT)); if (pScriptProxy) { string gameState = pScriptProxy->GetState(); if(gameState=="InGame") { m_playing=true; m_gameMode = pR->GetEntity()->GetClass()->GetName(); } } } } if(!m_statsTrack || !m_serverReport) Init(); if(m_serverReport) { ReportGame(); m_serverReport->Update(); } if(m_playing) { if (ILevelInfo* pLevelInfo = gEnv->pGame->GetIGameFramework()->GetILevelSystem()->GetCurrentLevel()) { m_mapName = pLevelInfo->GetName();//we only need pure level name here const char* p = strrchr(m_mapName.c_str(),'/'); if(p != 0 && strlen(p) > 1) { m_mapName = p + 1; char* pStr = const_cast<char*>(m_mapName.data()); pStr[0] = toupper(m_mapName[0]); for(int i = 1; i < m_mapName.size(); ++i) pStr[i] = tolower(m_mapName[i]); } } } if(m_statsTrack && m_playing && gEnv->bServer) m_statsTrack->StartGame(); if(gEnv->bServer && m_playing) { m_roundStart = gEnv->pTimer->GetFrameStartTime(); m_lastPosUpdate = 0.0f; ResetStats(); m_roundStats->Start(m_mapName, m_roundStart); } }
WallClass::WallClass(void){ ThisType = TInfo::WallType; ResetStats(); //deals with graphics related fuctions Vertical = false; }