/*************************************************************************
 * AM-CONTROL-CHANGE-DATA-VIEW
 *************************************************************************/
AmControlChangeDataView::AmControlChangeDataView(	BRect frame,
													AmSongRef songRef,
													AmTrackWinPropertiesI& trackWinProps,
													const AmViewPropertyI& viewProp,
													TrackViewType viewType)
		: inherited(songRef, trackWinProps, viewProp, viewType, frame, STR_CONTROL_CHANGE_DATA,
				B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW | B_FRAME_EVENTS),
		  mMeasureBg(NULL), mCc(INITIAL_CC)
{
	mCachedPrimaryTrack = mTrackWinProps.OrderedTrackAt(0);
	mTarget = new _AmControlTarget(trackWinProps, this);
	if (viewProp.Configuration() ) Configure(viewProp.Configuration() );

	ArpBackground*		bg = new AmPropGridBackground(trackWinProps);
	if (bg) AddBackground(bg);
	mMeasureBg = new AmTrackMeasureBackground(mSongRef, mCachedPrimaryTrack, mMtc);
	if (mMeasureBg) AddBackground(mMeasureBg);
	bg = new ArpFloorBackground( this, Prefs().Color(AM_DATA_FG_C) );
	if (bg) AddBackground(bg);
}
XnStatus XnSensorStreamHelper::Open()
{
	XnStatus nRetVal = XN_STATUS_OK;

	// configure the stream
	nRetVal = Configure();
	XN_IS_STATUS_OK(nRetVal);

	// Update frequency (it might change on specific stream configuration)
	XnFrequencyInformation FrequencyInformation;
	nRetVal = XnHostProtocolAlgorithmParams(m_pObjects->pDevicePrivateData, XN_HOST_PROTOCOL_ALGORITHM_FREQUENCY, &FrequencyInformation, sizeof(XnFrequencyInformation), (XnResolutions)0, 0);
	XN_IS_STATUS_OK(nRetVal);

	m_pObjects->pDevicePrivateData->fDeviceFrequency = XN_PREPARE_VAR_FLOAT_IN_BUFFER(FrequencyInformation.fDeviceFrequency);

	// and now turn it on
	nRetVal = FinalOpen();
	XN_IS_STATUS_OK(nRetVal);

	return (XN_STATUS_OK);
}
Exemple #3
0
int main()
{
	InitializeStream(&s_stream);
	Configure();
	DendriteInit();
	AxonInit();
	
	volatile float foo = 1.0f;
	float bar = 0.001f;
	foo += bar;
	
	s_y = 0;
	s_x = 0;
	
	while(1)
	{
		DendriteReadSticks();
		UpdateDendrite();
		Transmit();
	}
}
Exemple #4
0
int CDvbDeviceControl::OpenDevice(struct OPEN_DEVICE_DATA *d)
{
	if(sscanf(d->dev_id,"%d",&selected_device_enum) != 1)
		return AltxDVB_ERR;
	selected_device_type = (DEVICE_TYPE)(d->dev_type);
	Configure(hInstance);
	if(SUCCEEDED(BdaGraph.BuildGraph(selected_device_enum, (enum VENDOR_SPECIFIC *)&(conf_params.VendorSpecific))))
	{
		//char selected_device_name[128];
		//WideCharToMultiByte(CP_ACP, 0, BdaGraph.friendly_name_tuner, -1, selected_device_name, sizeof(selected_device_name), NULL, NULL);
		ConfCaps();
		if(SUCCEEDED(BdaGraph.RunGraph()))
			return AltxDVB_OK;
		else
			BdaGraph.CloseGraph();
	}
	else
		BdaGraph.CloseGraph();

	return AltxDVB_ERR; // non 0x0 quits AltDVB
}
Exemple #5
0
void main( void )
{

	typedef enum
	{	CONFIGURE,
		INITIALISE1,
		RUN
	} MAINLOOP_STATE;

	static MAINLOOP_STATE MainLoopState = CONFIGURE;

	while( 1 ) // Main Super Loop
	{
		switch ( MainLoopState )
		{
		case CONFIGURE :
			
			if ( Configure() == Command_Complete )
         	{
				MainLoopState = INITIALISE1;
			}
		break;

		case INITIALISE1 :
			if ( Initialise() == Command_Complete )
			{
				MainLoopState = RUN;
			}
		break;

		case RUN :
		
			Manage_Comms();
			Manage_Movements();
		break;
		}
	}

}
Exemple #6
0
int ShortLocater::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: Measure(); break;
        case 1: Configure((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 2: on_openShortEnable_clicked((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 3: on_External_clicked(); break;
        case 4: on_Internal_clicked(); break;
        case 5: on_pushButton_2_clicked(); break;
        case 6: on_HAADC_clicked(); break;
        case 7: on_haadcClose_clicked(); break;
        case 8: on_pushButton_clicked(); break;
        case 9: on_hold_clicked(); break;
        case 10: on_microOhms_clicked(); break;
        case 11: on_Null_clicked(); break;
        case 12: on_offset_clicked(); break;
        case 13: on_Auto_clicked(); break;
        case 14: on_buzzer_clicked(); break;
        case 15: on_exit_clicked(); break;
        case 16: on_r200mEBut_clicked(); break;
        case 17: on_r2EBut_clicked(); break;
        case 18: on_r200But_clicked(); break;
        case 19: on_ShortCalib_2_clicked(); break;
        case 20: on_ShortCalib_clicked(); break;
        case 21: on_pushButton_5_clicked(); break;
        case 22: on_pushButton_3_clicked(); break;
        case 23: on_printImage_clicked(); break;
        case 24: startStop(); break;
        case 25: Exit(); break;
        default: ;
        }
        _id -= 26;
    }
    return _id;
}
Exemple #7
0
int WINAPI WinMain (HINSTANCE hInst,
                    HINSTANCE hPrev,
                    LPSTR lpCmdLine,
                    int iCmdShow)
{
	HWND	hwndParent;
	HWND	hwndChild;
	UINT	nPreviousState;
	int	chOption;

	hInstance = hInst;

	ParseCommandLine(lpCmdLine, &chOption, &hwndParent);

	SystemParametersInfo(SPI_SETSCREENSAVERRUNNING, TRUE, &nPreviousState, 0);

	switch (chOption)
	{
		case 's':
			hwndChild = InitSaver(0);
			break;

		case 'p':
			hwndChild = InitSaver(hwndParent);
			break;

		case 'c':
		default:
			Configure();
			return 0;
	}

	MazeMain(hInst, hPrev, lpCmdLine, hwndChild);

	SystemParametersInfo(SPI_SETSCREENSAVERRUNNING, FALSE, &nPreviousState, 0);

	return 0;
}
Exemple #8
0
void CBeep::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
    //	if (nSBCode == SB_THUMBPOSITION || nSBCode == SB_THUMBTRACK) {
    //		m_ToneIndex = (int)nPos;
    //		Configure (m_ToneIndex);
    //	}


    CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
    m_ToneIndex = m_ToneSlider.GetPos();
    Configure(m_ToneIndex);

    if (nSBCode == SB_ENDSCROLL)
    {
        // user has lifted up on the mouse after dragging.
        CFlowZap *fc = (CFlowZap*)m_fc;
        double hz = fc->m_HzConversion[m_ToneSlider.GetPos()];
        PostMessage(ID_BEEP_FREQUENCY_CHANGED, 0, (LPARAM)((float)hz));
        //		fc->MakeRobotBeep (hz);
        fc->ChangeMadeInFile();

    }
}
MotionDetector::MotionDetector(ASocketServer& _server,
                               const ASettingsHandler& _settings,
                               ASettingsHandler& _stats,
                               AStdFile& _log,
                               uint_t _index) : ImageHandler(),
    stream(&_server),
    settings(_settings),
    stats(_stats),
    log(_log),
    index(_index),
    images(4),
    imgindex(0),
    verbose(0)
{
    Configure();

    stream.SetImageHandler(this);

    diffavg = (double)stats.Get(AString("avg%").Arg(index), "0.0");
    diffsd  = (double)stats.Get(AString("sd%").Arg(index),  "0.0");

    log.printf("%s[%u]: New detector\n", ADateTime().DateFormat("%Y-%M-%D %h:%m:%s.%S").str(), index);
}
Exemple #10
0
/*
 *************************************************************************
 *  MiniportReconfigure
 *************************************************************************
 *
 *
 *  Reconfigures the network interface card to new parameters available 
 *  in the NDIS library configuration functions.
 *
 *
 */
NDIS_STATUS MiniportReconfigure	(	OUT PNDIS_STATUS OpenErrorStatus,
									IN NDIS_HANDLE MiniportAdapterContext,
									IN NDIS_HANDLE WrapperConfigurationContext
								)
{
	IrDevice *thisDev = CONTEXT_TO_DEV(MiniportAdapterContext);
	NDIS_STATUS result;

	DBGOUT(("MiniportReconfigure(0x%x)", (UINT)MiniportAdapterContext));

	MiniportHalt(MiniportAdapterContext);

	if (Configure(thisDev, WrapperConfigurationContext)){
		result = NDIS_STATUS_SUCCESS;
	}
	else {
		result = NDIS_STATUS_FAILURE;
	}

	DBGOUT(("MiniportReconfigure"));
	*OpenErrorStatus = result;
	return result;
}
int CRedirDesc::SetEcho(TUint8 aEcho)
	{
	int err = KErrNone;
	//start the redirection server if not already started...
	if( ENotConnected == iStatus )
		{
		iLock.Wait();
		Configure();	
		iLock.Signal();
		}	
	//set the echo flag if the connection with the server is successfull...
	if(EConnected  == iStatus)
		{
		err = iSession.SetEcho(aEcho);
		}
	else
		{
		// If no session is there i.e. no server in production code or in the
		// config.ini file for the stdioserver the both media type is NONE then
		// just return EOF so that libc can handle it.
		err = KErrEof;
		}
	return err;
	}
Exemple #12
0
DRIVER_ERROR Job::Init(SystemServices *pSystemServices, JobAttributes *job_attrs, Encapsulator *encap_intf)
{
    DRIVER_ERROR err = NO_ERROR;

    if (encap_intf == NULL) {
        return NO_PRINTER_SELECTED;
    }

    m_pEncap = encap_intf;
    m_pSys = pSystemServices;

    //m_job_attributes = job_attrs;
    memcpy(&m_job_attributes, job_attrs, sizeof(m_job_attributes));

    err = m_pEncap->StartJob(m_pSys, &m_job_attributes);

    if (err == NO_ERROR)
        err = Configure();

//  Setup the blank raster used by sendrasters
    if (err == NO_ERROR)
        err = setBlankRaster();
    return err;
} //Job
// -----------------------------------------------------------------------------
// CRedirDesc::Write
// Implementation for Write
// -----------------------------------------------------------------------------
//
void CRedirDesc::Write(TDes8& aDesc, TRequestStatus& aStatus)
	{	
	if( ENotConnected == iStatus )
		{
		iLock.Wait();
		if( ENotConnected == iStatus )
			{	
			Configure();	
			}
		iLock.Signal();
		}
	if(EConnected  == iStatus && !iWriteNone)
		{
		iSession.Write(aStatus, aDesc, aDesc.Length());		
		}
	else
		{
		// If no session is there i.e. no server in production code or the user
		// has specified the media type in config.ini file as NONE put the write
		// data in blackhole and just complete the request as done in Read call.
		TRequestStatus* status = &aStatus;
		User::RequestComplete(status, KErrNone);
		}
	}
MpMessageDialog::MpMessageDialog (const char *title, const char *text, int icon,
				  const char *yes, const char *no, const char *cancel)
  : MpFrame(title,300,200), icon(icon), text(text)
{
  const int framwidth = 2, midwidth = 3, // button frame constants
            htextpad = 4, vtextpad = 2,  // button text pad values
            butminwidth = 80,            // minimum button width
            textminheight = 30; // minimum height of text assumed

  // get text sizes
  int buth,butw,totw,toth;
  int bw[3] = { 0,0,0 }, bh[3] = { 0,0,0 }, bx[3] = { 0,0,0 }, by;
  int text_width,text_height;

  if (yes) Mp.GetTextExtent(yes,Mp.theFont,bw[0],bh[0]);
  if (no) Mp.GetTextExtent(no,Mp.theFont,bw[1],bh[1]);
  if (cancel) Mp.GetTextExtent(cancel,Mp.theFont,bw[2],bh[2]);
  if (text) { 
    Mp.GetTextExtent(text,Mp.theBoldFont,text_width,text_height);
    text_height = MpMax(textminheight,text_height);
    trec.Set(2*margin+icon_size,margin+margin/4,text_width,text_height);
  }

  // button widths and heights
  buth = 0;
  butw = 2*margin;
  for (int i = 0; i < 3; ++i) {
    bw[i] += 2*(midwidth+2*framwidth+htextpad);
    bw[i] = MpMax(butminwidth,bw[i]);
    butw += bw[i];
    if (bh[i] > buth) buth = bh[i];
  }
  buth += 2*(midwidth+2*framwidth+vtextpad); 
  butw += margin;

  // button y position
  by = trec.GetBottom() + margin + margin/2;
  
  // total width
  totw = margin + MpMax((int)trec.GetRight(),butw);
  toth = by + margin + buth;

  // button x positions
  bx[0] = 2*margin;
  bx[1] = (totw-bw[1])/2;
  bx[2] = totw-2*margin-bw[2];

  // generate buttons
  but[0] = but[1] = but[2] = 0;
  if (yes)
    but[0] = new MpVoidClassButton <MpMessageDialog>
	          (*this,yes,&MpMessageDialog::Button_0_Clicked,this,
		   bw[0],buth,bx[0],by);
  if (no)
    but[1] = new MpVoidClassButton <MpMessageDialog>
	          (*this,no,&MpMessageDialog::Button_1_Clicked,this,
		   bw[1],buth,bx[1],by);

  if (cancel)
    but[2] = new MpVoidClassButton <MpMessageDialog>
	          (*this,cancel,&MpMessageDialog::Button_2_Clicked,this,
		   bw[2],buth,bx[2],by);

  for (int i = 0; i < 3; ++i) 
    if (but[i]) {
      but[i]->SetFrameStyle(MpCanvas::BoxButton|MpCanvas::Sunken|MpCanvas::Enhanced);
      but[i]->SetFrameMidWidth(midwidth);
    }

  // configure this window
  Configure(totw,toth);
  SetMinMaxWindowSize(totw,toth,totw,toth); // resize is forbidden
}
Exemple #15
0
static LONG_PTR WINAPI DlgProc(HANDLE hDlg,int Msg,int Param1,LONG_PTR Param2)
{
  static TCHAR Filter[MAX_PATH];
  static TCHAR spFilter[MAX_PATH];
  static FarListTitles ListTitle;

  switch(Msg)
  {
    case DN_RESIZECONSOLE:
    {
      Info.SendDlgMessage(hDlg,DM_ENABLEREDRAW,FALSE,0);
      ResizeDialog(hDlg);
      Info.SendDlgMessage(hDlg,DM_ENABLEREDRAW,TRUE,0);
    }
    return TRUE;

    case DMU_UPDATE:
    {
      int OldPos = static_cast<int>(Info.SendDlgMessage(hDlg,DM_LISTGETCURPOS,LIST_BOX,0));

      if (Param1)
        UpDateInfo();

      ListSize = 0;
      int NewPos = -1;
      if (OldPos >= 0 && OldPos < nCount)
      {
        if (!*Filter || strstri(p[OldPos].Keys[DisplayName],Filter)) //без учета регистра в OEM кодировке
          NewPos = OldPos;
      }
      for (int i = 0; i < nCount; i++)
      {
        const TCHAR* DispName = p[i].Keys[DisplayName], *Find;
        if (*Filter)
          Find = strstri(DispName,Filter);
        else
          Find = DispName;
        if (Find != nullptr) //без учета регистра в OEM кодировке
        {
          FLI[i].Flags &= ~LIF_HIDDEN;
          if (Param2 && (i == OldPos))
          {
            if (FLI[i].Flags & LIF_CHECKED)
            {
              FLI[i].Flags &= ~LIF_CHECKED;
            }
            else
            {
              FLI[i].Flags |= LIF_CHECKED;
            }
          }
          //без учета регистра - а кодировка ANSI
          if (NewPos == -1 && Find == DispName)
            NewPos = i;
          ListSize++;
        }
        else
          FLI[i].Flags |= LIF_HIDDEN;
      }
      if (Param1 == 0 && Param2)
      {
        // Снятие или установка пометки (Ins)
        if (Param2 == 1)
        {
          for (int i = (OldPos+1); i < nCount; i++)
          {
            if (!(FLI[i].Flags & LIF_HIDDEN))
            {
              OldPos = i; break;
            }
          }
          NewPos = OldPos;
        }
        // Снятие или установка пометки (RClick)
        else if (Param2 == 2)
        {
          NewPos = OldPos;
        }
      }
      else if (NewPos == -1)
      {
        NewPos = OldPos;
      }

      Info.SendDlgMessage(hDlg,DM_ENABLEREDRAW,FALSE,0);

      Info.SendDlgMessage(hDlg,DM_LISTSET,LIST_BOX,reinterpret_cast<LONG_PTR>(&FL));

      StringCchPrintf(spFilter,ARRAYSIZE(spFilter), GetMsg(MFilter),Filter,ListSize,nCount);
      ListTitle.Title = spFilter;
      ListTitle.TitleLen = lstrlen(spFilter);
      Info.SendDlgMessage(hDlg,DM_LISTSETTITLES,LIST_BOX,reinterpret_cast<LONG_PTR>(&ListTitle));

      ResizeDialog(hDlg);

      struct FarListPos FLP;
      FLP.SelectPos = NewPos;
      FLP.TopPos = -1;
      Info.SendDlgMessage(hDlg,DM_LISTSETCURPOS,LIST_BOX,reinterpret_cast<LONG_PTR>(&FLP));

      Info.SendDlgMessage(hDlg,DM_ENABLEREDRAW,TRUE,0);
    }
    break;

    case DN_INITDIALOG:
    {
      StringCchCopy(Filter,ARRAYSIZE(Filter),_T(""));
      ListTitle.Bottom = const_cast<TCHAR*>(GetMsg(MBottomLine));
      ListTitle.BottomLen = lstrlen(GetMsg(MBottomLine));

      //подстраиваемся под размеры консоли
      Info.SendDlgMessage(hDlg,DM_ENABLEREDRAW,FALSE,0);
      ResizeDialog(hDlg);
      Info.SendDlgMessage(hDlg,DM_ENABLEREDRAW,TRUE,0);
      //заполняем диалог
      Info.SendDlgMessage(hDlg,DMU_UPDATE,1,0);
    }
    break;

    case DN_MOUSECLICK:
    {
      if (Param1 == LIST_BOX)
      {
        MOUSE_EVENT_RECORD *mer = (MOUSE_EVENT_RECORD *)Param2;
        if (mer->dwButtonState == FROM_LEFT_1ST_BUTTON_PRESSED)
        {
          // find list on-screen coords (excluding frame and border)
          SMALL_RECT list_rect;
          Info.SendDlgMessage(hDlg, DM_GETDLGRECT, 0, reinterpret_cast<LONG_PTR>(&list_rect));
          list_rect.Left += 2;
          list_rect.Top += 1;
          list_rect.Right -= 2;
          list_rect.Bottom -= 1;
          if ((mer->dwEventFlags == 0) && (mer->dwMousePosition.X > list_rect.Left) && (mer->dwMousePosition.X < list_rect.Right) && (mer->dwMousePosition.Y > list_rect.Top) && (mer->dwMousePosition.Y < list_rect.Bottom))
          {
            DlgProc(hDlg, DN_KEY, LIST_BOX, KEY_ENTER);
            return TRUE;
          }
          // pass message to scrollbar if needed
          if ((mer->dwMousePosition.X == list_rect.Right) && (mer->dwMousePosition.Y > list_rect.Top) && (mer->dwMousePosition.Y < list_rect.Bottom)) return FALSE;
          return TRUE;
        }
        else if (mer->dwButtonState == RIGHTMOST_BUTTON_PRESSED)
        {
          Info.SendDlgMessage(hDlg,DMU_UPDATE,0,2);
          return TRUE;
        }
      }
    }
    break;

    case DN_KEY:
      switch (Param2)
      {
        case KEY_F8:
        {
          if (ListSize)
          {
            TCHAR DlgText[MAX_PATH + 200];
            StringCchPrintf(DlgText, ARRAYSIZE(DlgText), GetMsg(MConfirm), p[Info.SendDlgMessage(hDlg,DM_LISTGETCURPOS,LIST_BOX,NULL)].Keys[DisplayName]);
            if (EMessage((const TCHAR * const *) DlgText, 0, 2) == 0)
            {
              if (!DeleteEntry(static_cast<int>(Info.SendDlgMessage(hDlg,DM_LISTGETCURPOS,LIST_BOX,NULL))))
                DrawMessage(FMSG_WARNING, 1, "%s",GetMsg(MPlugIn),GetMsg(MDelRegErr),GetMsg(MBtnOk),NULL);
              Info.SendDlgMessage(hDlg,DMU_UPDATE,1,0);
            }
          }
        }
        return TRUE;

        case (KEY_F9|KEY_SHIFT|KEY_ALT):
        case (KEY_F9):
        {
          Configure(0);
        }
        return TRUE;

        case KEY_CTRLR:
        {
          Info.SendDlgMessage(hDlg,DMU_UPDATE,1,0);
        }
        return TRUE;

        case KEY_INS:
        {
          Info.SendDlgMessage(hDlg,DMU_UPDATE,0,1);
        }
        return TRUE;

        case KEY_ENTER:
        case KEY_SHIFTENTER:
        {
          if (ListSize)
          {
            int liChanged = 0;
            int liSelected = 0, liFirst = -1;

            for (int i = 0; i < nCount; i++)
            {
               if (FLI[i].Flags & LIF_CHECKED)
               {
                 if (liFirst == -1)
                   liFirst = i;
                 liSelected++;
               }
            }

            if (liSelected <= 1)
            {
              int liAction = (Param2 == KEY_ENTER) ? Opt.EnterAction : Opt.ShiftEnterAction;
              int pos = (liFirst == -1) ? static_cast<int>(Info.SendDlgMessage(hDlg,DM_LISTGETCURPOS,LIST_BOX,NULL)) : liFirst;
              liChanged = ExecuteEntry(pos, liAction, (Opt.RunLowPriority!=0));
            }
            else
            {
              int liAction = (Param2 == KEY_ENTER) ? Opt.EnterAction : Opt.ShiftEnterAction;
              bool LowPriority = (Opt.RunLowPriority!=0);

              // Обязательно ожидание - два инсталлятора сразу недопускаются
              if (liAction == Action_Menu)
              {
                if (EntryMenu(0, liAction, LowPriority, liSelected) < 0)
                  return TRUE;
              }
              else if (liAction == Action_Uninstall)
                liAction = Action_UninstallWait;
              else if (liAction == Action_Modify)
                liAction = Action_ModifyWait;
              else if (liAction == Action_Repair)
                liAction = Action_RepairWait;
              
              for (int pos = 0; pos < nCount; pos++)
              {
                if (!(FLI[pos].Flags & LIF_CHECKED))
                  continue;
                struct FarListPos FLP;
                FLP.SelectPos = pos;
                FLP.TopPos = -1;
                Info.SendDlgMessage(hDlg,DM_LISTSETCURPOS,LIST_BOX,reinterpret_cast<LONG_PTR>(&FLP));
                int li = ExecuteEntry(pos, liAction, LowPriority);
                if (li == -1)
                  break; // отмена
                if (li == 1)
                  liChanged = 1;
              }
            }

            if (liChanged == 1)
            {
              Info.SendDlgMessage(hDlg,DMU_UPDATE,1,0);
            }
          }
        }
        return TRUE;

        case KEY_SHIFTINS:
        case KEY_CTRLV:
        {
          TCHAR * bufP = FSF.PasteFromClipboard();
          static TCHAR bufData[MAX_PATH];
          if (bufP)
          {
            StringCchCopy(bufData,ARRAYSIZE(bufData),bufP);
            FSF.DeleteBuffer(bufP);
            unQuote(bufData);
            FSF.LStrlwr(bufData);
            for (int i = lstrlen(bufData); i >= 1; i--)
              for (int j = 0; j < nCount; j++)
                if (strnstri(p[j].Keys[DisplayName],bufData,i))
                {
                  lstrcpyn(Filter,bufData,i+1);
                  Info.SendDlgMessage(hDlg,DMU_UPDATE,0,0);
                  return TRUE;
                }
          }
        }
        return TRUE;

        case KEY_DEL:
        {
          if (lstrlen(Filter) > 0)
          {
            StringCchCopy(Filter,ARRAYSIZE(Filter),_T(""));
            Info.SendDlgMessage(hDlg,DMU_UPDATE,0,0);
          }
        }
        return TRUE;

        case KEY_F3:
        case KEY_F4:
        {
          if (ListSize)
          {
            DisplayEntry(static_cast<int>(Info.SendDlgMessage(hDlg,DM_LISTGETCURPOS,LIST_BOX,NULL)));
            Info.SendDlgMessage(hDlg,DM_REDRAW,NULL,NULL);
          }
        }
        return TRUE;

        case KEY_F2:
        {
          Opt.SortByDate = !Opt.SortByDate;
          Info.SendDlgMessage(hDlg,DMU_UPDATE,1,0);
        }
        return TRUE;

        case KEY_BS:
        {
          if (lstrlen(Filter))
          {
            Filter[lstrlen(Filter)-1] = '\0';
            Info.SendDlgMessage(hDlg,DMU_UPDATE,0,0);
          }
        }
        return TRUE;

        default:
        {
          if (Param2 >= KEY_SPACE && Param2 < KEY_FKEY_BEGIN)
          {
            struct FarListInfo ListInfo;
            Info.SendDlgMessage(hDlg,DM_LISTINFO,LIST_BOX,reinterpret_cast<LONG_PTR>(&ListInfo));
            if ((lstrlen(Filter) < sizeof(Filter)) && ListInfo.ItemsNumber)
            {
              int filterL = lstrlen(Filter);
              Filter[filterL] = FSF.LLower(static_cast<unsigned>(Param2));
              Filter[filterL+1] = '\0';
              Info.SendDlgMessage(hDlg,DMU_UPDATE,0,0);
              return TRUE;
            }
          }
        }
      }
      return FALSE;

    case DN_CTLCOLORDIALOG:
      return Info.AdvControl(Info.ModuleNumber,ACTL_GETCOLOR,(void *)COL_MENUTEXT);

    case DN_CTLCOLORDLGLIST:
      if (Param1 == LIST_BOX)
      {
        FarListColors *Colors = (FarListColors *)Param2;
        int ColorIndex[] = { COL_MENUBOX, COL_MENUBOX, COL_MENUTITLE, COL_MENUTEXT, COL_MENUHIGHLIGHT, COL_MENUBOX, COL_MENUSELECTEDTEXT, COL_MENUSELECTEDHIGHLIGHT, COL_MENUSCROLLBAR, COL_MENUDISABLEDTEXT, COL_MENUARROWS, COL_MENUARROWSSELECTED, COL_MENUARROWSDISABLED };
        int Count = ARRAYSIZE(ColorIndex);
        if (Count > Colors->ColorCount)
          Count = Colors->ColorCount;
        for (int i = 0; i < Count; i++)
          Colors->Colors[i] = static_cast<BYTE>(Info.AdvControl(Info.ModuleNumber, ACTL_GETCOLOR, reinterpret_cast<void *>(ColorIndex[i])));
        return TRUE;
      }
    break;
  }
  return Info.DefDlgProc(hDlg,Msg,Param1,Param2);
}
Exemple #16
0
/*!
 ***********************************************************************
 * \brief
 *    main function for JM decoder
 ***********************************************************************
 */
int main(int argc, char **argv)
{
	struct timeval start, end;
	gettimeofday( &start, NULL );
	
  int iRet;
  //DecodedPicList *pDecPicList;
  int iFramesDecoded=0;
  InputParameters InputParams;

  if((g_encrypt_fileh = fopen(g_encrypt_file, "w+")) == NULL)
  {
	  printf("encrypt file open fail!\n");
	  return -1;
  }

#if H264_KEY_LOG 
  if((g_key_log_fileh = fopen(g_key_log_file, "a+")) == NULL)
  {
	  printf("encrypt file open fail!\n");
	  return -1;
  }
#endif  

  //init_time();

  //get input parameters;
  Configure(&InputParams, argc, argv);

	//open decoder;
  iRet = OpenDecoder(&InputParams);	//打开trace,h264bitstream文件
  if(iRet != DEC_OPEN_NOERR)
  {
    fprintf(stderr, "Open encoder failed: 0x%x!\n", iRet);
    return -1; //failed;
  }

	p_Dec->nalu_pos_array = calloc(200,sizeof(int));
	
  do
  {
    iRet = DecodeOneFrame();	
  }while((iRet == DEC_SUCCEED) && ((p_Dec->p_Inp->iDecFrmNum==0) || (iFramesDecoded<p_Dec->p_Inp->iDecFrmNum)));
	
  iRet = FinitDecoder();
  iRet = CloseDecoder();	//包含report输出

  
  printf("%d frames are decoded.\n", iFramesDecoded);
  printf("%ld MVs found!\n", NumberOfMV);
  printf("%ld P MVs found!\n", NumberOfBMV);
  printf("%ld B MVs found!\n", NumberOfPMV);
  
#if TRACE
	printf("defined trace!\n");
#endif  

#if H264_KEY_LOG
	char s[200];
	snprintf(s,200,"max_mvd_BOffset: %4d, min_KeyData_Len: %2d, max_KeyData_Len: %4d\n",
	p_Dec->max_MVD_BOffset,p_Dec->min_KeyData_Len,p_Dec->max_KeyData_Len);		
	//fwrite(s,strlen(s),1,g_key_log_fileh);

	char s2[200];

	int i =0;
	for(;i<p_Dec->nalu_pos_array_idx;++i)
	{
		snprintf(s2,200,"%2d: %5d\n",i,p_Dec->nalu_pos_array[i]);		
		fwrite(s2,strlen(s2),1,g_key_log_fileh);		
	}
	fclose(g_key_log_fileh);	
#else	
	fclose(g_encrypt_fileh);
#endif

	gettimeofday( &end, NULL );
	long int time_us = 1000000 * ( end.tv_sec - start.tv_sec ) + end.tv_usec - start.tv_usec;
	printf("run time: %ld us\n",time_us);
  return 0;
}
Exemple #17
0
/*
 *************************************************************************
 *  MiniportInitialize
 *************************************************************************
 *
 *
 *  Initializes the network interface card.
 *
 *
 *
 */
NDIS_STATUS MiniportInitialize	(	PNDIS_STATUS OpenErrorStatus,
									PUINT SelectedMediumIndex,
									PNDIS_MEDIUM MediumArray,
									UINT MediumArraySize,
									NDIS_HANDLE NdisAdapterHandle,
									NDIS_HANDLE WrapperConfigurationContext
								)
{
	UINT mediumIndex;
	IrDevice *thisDev = NULL;	
	NDIS_STATUS retStat, result = NDIS_STATUS_SUCCESS;

	DBGOUT(("MiniportInitialize()"));

	/*
	 *  Search the passed-in array of supported media for the IrDA medium.
	 */
	for (mediumIndex = 0; mediumIndex < MediumArraySize; mediumIndex++){
		if (MediumArray[mediumIndex] == NdisMediumIrda){
			break;
		}
	}
	if (mediumIndex < MediumArraySize){
		*SelectedMediumIndex = mediumIndex;
	}
	else {
		/*
		 *  Didn't see the IrDA medium
		 */
		DBGERR(("Didn't see the IRDA medium in MiniportInitialize"));
		result = NDIS_STATUS_UNSUPPORTED_MEDIA;
		goto _initDone;
	}

	/*
	 *  Allocate a new device object to represent this connection.
	 */
	thisDev = NewDevice();
	if (!thisDev){
		return NDIS_STATUS_NOT_ACCEPTED;
	}

	/*
	 *  Allocate resources for this connection.
	 */
	if (!OpenDevice(thisDev)){
		DBGERR(("OpenDevice failed"));
		result = NDIS_STATUS_FAILURE;
		goto _initDone;
	}


	/*
	 *  Read the system registry to get parameters like COM port number, etc.
	 */
	if (!Configure(thisDev, WrapperConfigurationContext)){
		result = NDIS_STATUS_FAILURE;
		goto _initDone;
	}


	/*
	 *  This call will associate our adapter handle with the wrapper's
	 *  adapter handle.  The wrapper will then always use our handle
	 *  when calling us.  We use a pointer to the device object as the context.
	 */
   	NdisMSetAttributes	(	NdisAdapterHandle,
							(NDIS_HANDLE)thisDev,
							FALSE,
							NdisInterfaceInternal  
						);

							
	/*
	 *  Tell NDIS about the range of IO space that we'll be using.
	 */
	retStat = NdisMRegisterIoPortRange(	(PVOID)thisDev->mappedPortRange,
										NdisAdapterHandle,
										thisDev->portInfo.ioBase,
										8);
	if (retStat != NDIS_STATUS_SUCCESS){
		DBGERR(("NdisMRegisterIoPortRange failed"));
		result = NDIS_STATUS_FAILURE;
		goto _initDone;
	}


	/*
	 *  Record the NDIS wrapper's handle for this adapter, which we use
	 *  when we call up to the wrapper.
	 *  (This miniport's adapter handle is just thisDev, the pointer to the device object.).
	 */
	DBGOUT(("NDIS handle: %xh <-> IRMINI handle: %xh", (UINT)NdisAdapterHandle, (UINT)thisDev));
	thisDev->ndisAdapterHandle = NdisAdapterHandle;


	/*
	 *  Open COMM communication channel.
	 *  This will let the dongle driver update its capabilities from their default values.
	 */
	if (!DoOpen(thisDev)){
		DBGERR(("DoOpen failed"));
		result = NDIS_STATUS_FAILURE;
		goto _initDone;
	}


	/*
	 *  Register an interrupt with NDIS.
	 */
	retStat = NdisMRegisterInterrupt(	(PNDIS_MINIPORT_INTERRUPT)&thisDev->interruptObj,
										NdisAdapterHandle,
										thisDev->portInfo.irq,
										thisDev->portInfo.irq,
										TRUE,	// want ISR
										TRUE,	// MUST share interrupts
										NdisInterruptLevelSensitive
									);
	if (retStat != NDIS_STATUS_SUCCESS){
		DBGERR(("NdisMRegisterInterrupt failed"));
		result = NDIS_STATUS_FAILURE;
		goto _initDone;
	}


 _initDone:
	if (result == NDIS_STATUS_SUCCESS){

		/*
		 *  Add this device object to the beginning of our global list.
		 */
		thisDev->next = firstIrDevice;
		firstIrDevice = thisDev;

		DBGOUT(("MiniportInitialize succeeded"));
	}
	else {
		if (thisDev){
			FreeDevice(thisDev);
		}
		DBGOUT(("MiniportInitialize failed"));
	}
	return result;

}
Exemple #18
0
LogManager::LogManager() {
  Configure(peloton_logging_mode, false, DEFAULT_NUM_FRONTEND_LOGGERS,
            LOGGER_MAPPING_ROUND_ROBIN);
}
Exemple #19
0
int EchoCancellationImpl::enable_delay_logging(bool enable) {
  CriticalSectionScoped crit_scoped(apm_->crit());
  delay_logging_enabled_ = enable;
  return Configure();
}
Exemple #20
0
int EchoCancellationImpl::enable_metrics(bool enable) {
  CriticalSectionScoped crit_scoped(apm_->crit());
  metrics_enabled_ = enable;
  return Configure();
}
Exemple #21
0
int EchoCancellationImpl::enable_drift_compensation(bool enable) {
  CriticalSectionScoped crit_scoped(apm_->crit());
  drift_compensation_enabled_ = enable;
  return Configure();
}
Exemple #22
0
int ModeReqRun(Client *client)
{
  int retval = 0;

  /* This exits if we don't see a CPU we want,
     Also saves us from floating point exceptions on GPU clients 
  */
  if ((modereq.reqbits & MODEREQ_NEEDS_CPU_MASK) != 0)
  {
    if (GetNumberOfDetectedProcessors() == 0)  // -1 is OK when OS doesn't support detection
      return 0;
  }

  if (++modereq.isrunning == 1)
  {
    int restart = ((modereq.reqbits & MODEREQ_RESTART) != 0);
    modereq.reqbits &= ~MODEREQ_RESTART;

    while ((modereq.reqbits & MODEREQ_ALL)!=0)
    {
      unsigned int bits = modereq.reqbits;
      if ((bits & (MODEREQ_BENCHMARK |
                   MODEREQ_BENCHMARK_QUICK |
                   MODEREQ_BENCHMARK_ALLCORE )) != 0)
      {
        do
        {
          unsigned int contest, benchsecs = 16;
          unsigned long sel_contests = modereq.bench_projbits;
          modereq.bench_projbits = 0;

          if ((bits & (MODEREQ_BENCHMARK_QUICK))!=0)
            benchsecs = 8;
          for (contest = 0; contest < CONTEST_COUNT; contest++)
          {
            if (CheckExitRequestTriggerNoIO())
              break;
            if (sel_contests == 0 /*none set==all set*/
                || (sel_contests & (1L<<contest)) != 0)
            {
              if ((bits & (MODEREQ_BENCHMARK_ALLCORE))!=0)
                if(client->corenumtotestbench < 0)
                  selcoreBenchmark( client, contest, benchsecs, -1 );
                else
                  selcoreBenchmark( client, contest, benchsecs, client->corenumtotestbench);
              else
                TBenchmark( client, contest, benchsecs, 0, NULL, NULL );
            }
          }
          Log("Compare and share your rates in the speeds database at\n"
              "http://www.distributed.net/speed/\n"
              "(benchmark rates are for a single processor core)\n");
        } while (!CheckExitRequestTriggerNoIO() && modereq.bench_projbits);
        retval |= (bits & (MODEREQ_BENCHMARK_QUICK | MODEREQ_BENCHMARK |
                           MODEREQ_BENCHMARK_ALLCORE));
        modereq.reqbits &= ~(MODEREQ_BENCHMARK_QUICK | MODEREQ_BENCHMARK |
                             MODEREQ_BENCHMARK_ALLCORE);
      }
      if ((bits & MODEREQ_CMDLINE_HELP) != 0)
      {
        DisplayHelp(modereq.helpoption);
        modereq.helpoption = (const char *)0;
        modereq.reqbits &= ~(MODEREQ_CMDLINE_HELP);
        retval |= (MODEREQ_CMDLINE_HELP);
      }
      if ((bits & (MODEREQ_CONFIG | MODEREQ_CONFRESTART)) != 0)
      {
        /* cmdline_config is set if there is an explicit --config on the cmdline */
        /* Configure() returns <0=error,0=exit+nosave,>0=exit+save */
        Configure(client,(!(!modereq.cmdline_config)) /* nottycheck */);
        /* it used to be such that restart would only be posted on an exit+save */
        /* but now we restart for other retvals too, otherwise the GUI windows */
        /* end up with half-assed content */
        if ((bits & MODEREQ_CONFRESTART) != 0)
          restart = 1;
        modereq.cmdline_config = 0;
        modereq.reqbits &= ~(MODEREQ_CONFIG | MODEREQ_CONFRESTART);
        retval |= (bits & (MODEREQ_CONFIG | MODEREQ_CONFRESTART));
      }
      if ((bits & (MODEREQ_FETCH | MODEREQ_FLUSH)) != 0)
      {
        if (client)
        {
          int domode = 0;
          int interactive = ((bits & MODEREQ_FQUIET) == 0);
          domode  = ((bits & MODEREQ_FETCH) ? BUFFERUPDATE_FETCH : 0);
          domode |= ((bits & MODEREQ_FLUSH) ? BUFFERUPDATE_FLUSH : 0);
          TRACE_BUFFUPD((0, "BufferUpdate: reason = ModeReqRun\n"));
          domode = BufferUpdate( client, domode, interactive );
          if (domode & BUFFERUPDATE_FETCH)
            retval |= MODEREQ_FETCH;
          if (domode & BUFFERUPDATE_FLUSH)
            retval |= MODEREQ_FLUSH;
          if (domode!=0 && (bits & MODEREQ_FQUIET) != 0)
            retval |= MODEREQ_FQUIET;
        }
        modereq.reqbits &= ~(MODEREQ_FETCH | MODEREQ_FLUSH | MODEREQ_FQUIET);
      }
      if ((bits & MODEREQ_IDENT) != 0)
      {
        CliIdentifyModules();
        modereq.reqbits &= ~(MODEREQ_IDENT);
        retval |= (MODEREQ_IDENT);
      }
      if ((bits & MODEREQ_UNLOCK) != 0)
      {
        if (modereq.filetounlock)
        {
          UnlockBuffer(modereq.filetounlock);
          modereq.filetounlock = (const char *)0;
        }
        modereq.reqbits &= ~(MODEREQ_UNLOCK);
        retval |= (MODEREQ_UNLOCK);
      }
      if ((bits & MODEREQ_IMPORT) != 0)
      {
        if (modereq.filetoimport && client)
        {
          BufferImportFileRecords(client, modereq.filetoimport, 1 /* interactive */);
          modereq.filetoimport = (const char *)0;
          retval |= (MODEREQ_IMPORT);
        }
        modereq.reqbits &= ~(MODEREQ_IMPORT);
      }
      if ((bits & MODEREQ_CPUINFO) != 0)
      {
        DisplayProcessorInformation();
        modereq.reqbits &= ~(MODEREQ_CPUINFO);
        retval |= (MODEREQ_CPUINFO);
      }
      if ((bits & (MODEREQ_TEST | MODEREQ_TEST_ALLCORE)) != 0)
      {

        int testfailed = 0;
        do
        {
          unsigned int contest;
          unsigned long sel_contests = modereq.test_projbits;
          modereq.test_projbits = 0;

          for (contest = 0; !testfailed && contest < CONTEST_COUNT; contest++)
          {
            if (CheckExitRequestTriggerNoIO())
            {
              testfailed = 1;
              break;
            }
            if (sel_contests == 0 /*none set==all set*/
                || (sel_contests & (1L<<contest)) != 0)
            {
              if ((bits & (MODEREQ_TEST_ALLCORE)) != 0)
              {
                if (client->corenumtotestbench < 0)
                {
                  if (selcoreSelfTest( client, contest, -1 ) < 0)
                    testfailed = 1;
                }
                else
                {
                  if (selcoreSelfTest( client, contest, client->corenumtotestbench ) < 0)
                    testfailed = 1;
                }
              }
              else if ( SelfTest( client, contest ) < 0 )
                testfailed = 1;
            }
          }
        } while (!testfailed && modereq.test_projbits);
        retval |= (MODEREQ_TEST|MODEREQ_TEST_ALLCORE);
        modereq.reqbits &= ~(MODEREQ_TEST|MODEREQ_TEST_ALLCORE);
      }
      if ((bits & (MODEREQ_STRESS | MODEREQ_STRESS_ALLCORE)) != 0)
      {

        int testfailed = 0;
        do
        {
          unsigned int contest;
          unsigned long sel_contests = modereq.stress_projbits;
          modereq.stress_projbits = 0;

          for (contest = 0; !testfailed && contest < CONTEST_COUNT; contest++)
          {
            if (CheckExitRequestTriggerNoIO())
            {
              testfailed = 1;
              break;
            }
            if (sel_contests == 0 /*none set==all set*/
                || (sel_contests & (1L<<contest)) != 0)
            {
              if ((bits & (MODEREQ_STRESS_ALLCORE)) != 0)
              {
                if (client->corenumtotestbench < 0)
                {
                  if (selcoreStressTest( client, contest, -1 ) < 0)
                    testfailed = 1;
                }
                else
                {
                  if (selcoreStressTest( client, contest, client->corenumtotestbench ) < 0)
                    testfailed = 1;
                }
              }
              else if ( StressTest( client, contest ) < 0 )
                testfailed = 1;
            }
          }
        } while (!testfailed && modereq.stress_projbits);
        retval |= (MODEREQ_STRESS|MODEREQ_STRESS_ALLCORE);
        modereq.reqbits &= ~(MODEREQ_STRESS|MODEREQ_STRESS_ALLCORE);
      }
      if ((bits & MODEREQ_VERSION) != 0)
      {
        /* the requested information already has been printed */
        modereq.reqbits &= ~(MODEREQ_VERSION);
        retval |= (MODEREQ_VERSION);
      }
      if (CheckExitRequestTriggerNoIO())
      {
        restart = 0;
        break;
      }
    } //end while

    if (restart)
      RaiseRestartRequestTrigger();
  } //if (++isrunning == 1)

  modereq.isrunning--;
  return retval;
}
	MatlabStructure::MatlabStructure(const MatlabProto& proto, mxArray* arr) {
		Configure(proto, arr);
	}
/**
\brief	Constructor.

\author	dcofer
\date	5/3/2011

\param	iM	  	Number of bits to the left of the decimal point. 
\param	iN	  	Number of bits to the right of the decimal point. 
\param	dblVal	The initial floating-point value of the variable. 
\param	iMultM	Number of bits to the left of the decimal point during multiplication. 
\param	iMultN	Number of bits to the right of the decimal point during multiplication. 
**/
CStdFixed::CStdFixed(int iM, int iN, double dblVal, int iMultM, int iMultN)
{ 
	Configure(iM, iN, iMultM, iMultN);
	Fixed( (long) Convert(dblVal));
}
static BOOL PrepareToConfig()
{
    BOOL bMustExit = FALSE;

    // Use a local copy of the config info to decide what should be configured
    // or unconfigured.  We do this so that if the user cancels for some reason,
    // the real config state will still be what the user expects (what was
    // previously read from the system plus the user's changes).
    CONFIG_STATE configFS = g_CfgData.configFS;     // File server
    CONFIG_STATE configDB = g_CfgData.configDB;     // Database server
    CONFIG_STATE configBak = g_CfgData.configBak;   // Backup server
    CONFIG_STATE configSCS = g_CfgData.configSCS;   // System Control server
    CONFIG_STATE configSCC = g_CfgData.configSCC;   // System Control client

    BOOL bWorkToDo = FALSE;

    bWorkToDo |= PrepareToConfig(configFS, bFsRunning, bFsOn, IDC_FS_SERVICE);
    bWorkToDo |= PrepareToConfig(configDB, bDbRunning, bDbOn, IDC_DB_SERVICE);
    bWorkToDo |= PrepareToConfig(configBak, bBakRunning, bBakOn, IDC_BK_SERVICE);
    bWorkToDo |= PrepareToConfig(configSCS, bScsRunning, bScsOn, IDC_SCS);
    bWorkToDo |= PrepareToConfig(configSCC, bSccRunning, bSccOn, IDC_SCC);

    // If there is nothing to do, then just return TRUE.
    if (!bWorkToDo)
        return TRUE;

    // If we are unconfiguring the last DB server:
    //		1) Warn user and ask for confirmation
    //		2) Unconfigure all other servers that are running on this machine
    //		3) Tell them (after unconfiguring) that they must run the Wizard if they
    //		   wish to reconfigure the machine, then exit the program.
    if (configDB == CS_UNCONFIGURE) {
	if (g_CfgData.bLastDBServer) {
	    int nChoice = MsgBox(hDlg, IDS_LAST_DB_SERVER, GetAppTitleID(), MB_YESNO | MB_ICONEXCLAMATION);
	    if (nChoice == IDNO)
		return FALSE;

	    // Make sure these all get unconfigured as well.  If they are not configured, then
	    // nothing bad will happen because the config calls are idempotent.
	    configFS = CS_UNCONFIGURE;
	    configBak = CS_UNCONFIGURE;
	    configSCS = CS_UNCONFIGURE;
	    configSCC = CS_UNCONFIGURE;
	}
    }

    // Get additional needed information from the user
    GET_ADMIN_INFO_OPTIONS eOptions;
    BOOL bDB = (ShouldConfig(configDB) || ShouldUnconfig(configDB));

    // Use this as our default
    eOptions = GAIO_LOGIN_ONLY;

    // If we already have a sys control machine, then we don't need to ask for it
    if (ShouldConfig(configSCC)) {
	if (szScMachine[0] == 0) {
	    ShowWarning(hDlg, IDS_MUST_ENTER_SCS_NAME);
	    return FALSE;
	}
	lstrcpy(g_CfgData.szSysControlMachine, szScMachine);
    } else if (bDB && !g_CfgData.bLastDBServer) {
        // We need to know the name of the SCM machine.  Are we the SCM machine?
        if (bScsRunning)
            lstrcpy(g_CfgData.szSysControlMachine, g_CfgData.szHostname);
        else	
	    eOptions = GAIO_GET_SCS;
    }	

    // If doing a login only and the admin info is reusable
    if ((eOptions != GAIO_LOGIN_ONLY) || !g_CfgData.bReuseAdminInfo) {
    	if (!GetAdminInfo(hDlg, eOptions))
	    return FALSE;

        // Use the admin info to get new handles
        if (!GetHandles(hDlg))
            return FALSE;
    }	

    // Now that we are ready to configure, copy our local config info
    // into the structure that the config engine uses.
    g_CfgData.configFS = configFS;
    g_CfgData.configDB = configDB;
    g_CfgData.configBak = configBak;
    g_CfgData.configSCS = configSCS;
    g_CfgData.configSCC = configSCC;

    // Configure the server
    BOOL bConfigSucceeded = Configure(hDlg, bMustExit);
    if (bConfigSucceeded) {
        if (bMustExit) {
	    PostQuitMessage(0);
	    return TRUE;
	}
        g_CfgData.bReuseAdminInfo = TRUE;
    } else
        g_CfgData.szAdminPW[0] = 0;

    // Get current config status
    BOOL bCanceled = FALSE;
    DWORD dwStatus = GetCurrentConfig(hDlg, bCanceled);
    if (dwStatus || bCanceled) {
	if (!bCanceled)
	    ErrorDialog(dwStatus, IDS_CONFIG_CHECK_FAILED);
    }	

    // Show the initial services config
    ShowInitialConfig();
    ShowServiceStates();

    return TRUE;
}
int main(int argc, char **argv)
{
	struct timeval start, end1, end2;
	long int time_us1,time_us2;
	gettimeofday( &start, NULL );
	
  int iRet;
  InputParameters InputParams;
  init_time();

  //get input parameters;
  Configure(&InputParams, argc, argv);
  //open decoder;
  iRet = OpenDecoder(&InputParams);
  if(iRet != DEC_OPEN_NOERR)
  {
    fprintf(stderr, "Open encoder failed: 0x%x!\n", iRet);
    return -1; //failed;
  }

	init_GenKeyPar();
	
  //decoding;
  do
  {
    iRet = DecodeOneFrame();
    if(iRet==DEC_EOS || iRet==DEC_SUCCEED)
    {

    }
    else
    {
      //error handling;
      fprintf(stderr, "Error in decoding process: 0x%x\n", iRet);
    }
  }while((iRet == DEC_SUCCEED) /*&& ((p_Dec->p_Inp->iDecFrmNum==0) || (iFramesDecoded<p_Dec->p_Inp->iDecFrmNum))*/);

	gettimeofday( &end1, NULL );
	time_us1 = 1000000 * ( end1.tv_sec - start.tv_sec ) + end1.tv_usec - start.tv_usec;
	printf("\nrun time0: %ld us\n",time_us1);

	//encrypt the H.264 file
	printf("key unit count: %d\n",g_KeyUnitIdx);

	int ret;
	void* status;
	pthread_attr_t attr;

	/*********use multi thread********/
	if(p_Dec->p_Inp->multi_thread == 1)
	{
		pthread_attr_t attr;
						
		ret = pthread_attr_destroy(&p_Dec->thread_attr);
		if (ret != 0)
		{
			printf("pthread_attr_destroy error: %s\n",strerror(ret));
		}
	}

	ThreadUnitPar* par = NULL;
	par = (ThreadUnitPar*)malloc(sizeof(ThreadUnitPar));
	if(!par)
	{
		printf("malloc failed!\n");
		exit(1);
	}
	memset(par,0,sizeof(ThreadUnitPar));
	
	if(p_Dec->p_Inp->multi_thread)  
	{
		//deal with the rest KU buffer data
		if(g_KeyUnitBufferLen <= MAX_THREAD_DO_KEY_UNIT_CNT)
		{
			par->buffer_start = g_KeyUnitIdx - g_KeyUnitBufferLen;
			par->buffer_len = g_KeyUnitBufferLen;
			par->cur_absolute_offset = g_ThreadParCurPos;
			Encrypt(par);
		}

		int i;
		for(i = 0; i < p_Dec->pid_id; ++i)
		{
			pthread_join(p_Dec->pid[i], &status);
		}
	}
	else
	{		
		par->buffer_start = 0;
		par->buffer_len = g_KeyUnitIdx;
		par->cur_absolute_offset = g_pKeyUnitBuffer[0].byte_offset;
		Encrypt(par);
		//encryt_thread(par);
	}

	gettimeofday( &end2, NULL );
	time_us2 = 1000000 * ( end2.tv_sec - end1.tv_sec ) + end2.tv_usec - end1.tv_usec;
	printf("run time1: %ld us\n",time_us2);

	//print_KeyUnit();

	deinit_GenKeyPar();
  iRet = FinitDecoder();
  iRet = CloseDecoder();	

	fflush(NULL);
	printf("run time(all): %ld us\n", time_us1+time_us2);
  return 0;
}
Exemple #27
0
static gmx_bool xhwCallBack(struct t_x11 *x11, XEvent *event, Window wd, void *data)
{
    t_xhighway     *xhw;
    t_windata      *win;
    float           sx;
    int             i;
    static     int  nyy = 0;
    static     int *yy;

    xhw = (t_xhighway *)data;
    win = &(xhw->win);

    if (nyy == 0)
    {
        nyy = 2*xhw->ir.nlane+1;
        snew(yy, nyy);
    }
    for (i = 0; (i < nyy); i++)
    {
        yy[i] = ((float) i*win->height)/(nyy-1);
    }

    switch (event->type)
    {
        case Expose:
        {
            if (wd == win->self)
            {
                sx = (float)win->width  / xhw->ir.metres;

                XClearWindow(x11->disp, win->self);
                XSetForeground(x11->disp, x11->gc, WHITE);

                for (i = 2; (i < nyy-1); i += 2)
                {
                    XDrawLine(x11->disp, win->self, x11->gc, 0, yy[i], win->width-1, yy[i]);
                }

                for (i = 0; (i < xhw->ncars); i++)
                {
                    t_car *car = &(xhw->cars[i]);
                    int    w1  = car->x*sx;
                    int    h1  = yy[1+2*(xhw->ir.nlane-1-car->lane)];

                    draw_car(x11->disp, win->self, x11->gc, car, w1, h1);
                }
                if (xhw->bDriving)
                {
                    simulate(x11, xhw, xhw->ncars, xhw->cars, &xhw->ir);
                }
            }
            break;
        }
        case ConfigureNotify:
            if (wd == xhw->main.self)
            {
                xhw->main.width  = event->xconfigure.width;
                xhw->main.height = event->xconfigure.height;
                Configure(xhw);
                for (i = 0; (i < NBUT); i++)
                {
                    XMoveResizeWindow(x11->disp, xhw->but[i].self,
                                      xhw->but[i].x, xhw->but[i].y,
                                      xhw->but[i].width, xhw->but[i].height);
                }
                XMoveResizeWindow(x11->disp, win->self,
                                  win->x, win->y, win->width, win->height);
            }
            else if (wd == win->self)
            {
                win->width  = event->xconfigure.width;
                win->height = event->xconfigure.height;
            }
            break;
        case ButtonPress:
            return TRUE;
        default:
            break;
    }
    return FALSE;
}
/**
\brief	Constructor.

\author	dcofer
\date	5/3/2011

\param	iM	  	Number of bits to the left of the decimal point. 
\param	iN	  	Number of bits to the right of the decimal point. 
\param	lVal  	The initial fixed-point value of the variable.
\param	iMultM	Number of bits to the left of the decimal point during multiplication. 
\param	iMultN	Number of bits to the right of the decimal point during multiplication. 
**/
CStdFixed::CStdFixed(int iM, int iN, long lVal, int iMultM, int iMultN)
{
	Configure(iM, iN, iMultM, iMultN);
	Fixed( (long) lVal);
}
Exemple #29
0
int main(int argc, char **argv)
{
	int Flag = TRUE;

	//long ftell_position;//, expected_slice_type;
	//int ret;
	NALU_t *nalu;
	
	h264_decoder* dec_params;
	char *ptr;
	
	ptr =  (  char*)malloc(10 * sizeof(char)); 

    if ((dec_params =  (  h264_decoder*)h264_malloc(1 * sizeof(h264_decoder)))==NULL) 
 //	if ((dec_params =  (  h264_decoder*)h264_malloc(1 * 100))==NULL) 
	{
		Flag=FALSE;
	}

  	if ((dec_params->input =  (InputParameters *)h264_malloc(1 * sizeof(InputParameters)))==NULL) 
	{
		printf("main: input");
		exit(0);
	}
	if ((dec_params->img   =  (ImageParameters *)h264_malloc(1 * sizeof(ImageParameters)))==NULL) 
	{
		printf("main: img");
		exit(0);
	}

	////////// ADDED INITIALIZATIONS //////
	dec_params->active_sps       = NULL;
	dec_params->active_pps       = NULL;
 	dec_params->Co_located       = NULL;
	dec_params->dec_picture     = NULL;
	dec_params->global_init_done = 0;
	dec_params->dpb.init_done	 = 0;
	dec_params->img->DeblockCall = 0;
//	dec_params->img->structure   = 0;
	dec_params->MapUnitToSliceGroupMap = NULL;
	dec_params->MbToSliceGroupMap      = NULL;
	dec_params->img->errorConcealmentFlag = 0;			// ERROR CONCEALMENT FLAG SET TO ZERO , NO ERROR CONCEALMENT
	dec_params->img->no_output_of_prior_pics_flag = -1;

	///////////////////////////////////////
	Initializations(dec_params);
	
	Configure ( argc, argv,dec_params );
	
		
	init_old_slice(dec_params);
	
	switch (dec_params->input->FileFormat)
	{
	case 0:
		OpenBitstreamFile (dec_params->input->infile,dec_params);
		break;
	case 1:
		OpenRTPFile (dec_params->input->infile,dec_params);
		break;
	default:
		printf ("Unsupported file format %d, exit\n", dec_params->input->FileFormat);
	}
	
	// Allocate Slice data struct
	malloc_slice(dec_params->input,dec_params->img,dec_params);
	
	init(dec_params->img,dec_params);
	
	dec_params->dec_picture = NULL;
	
	dec_params->dpb.init_done = 0;
	//dec_params->g_nFrame = 0;
	
//	init_out_buffer(dec_params);
	
  //dec_params->img->idr_psnr_number=dec_params->input->ref_offset;
  //dec_params->img->psnr_number=0;
	
	dec_params->img->number=0;
	dec_params->img->type = I_SLICE;
	dec_params->img->dec_ref_pic_marking_buffer = NULL;
	
	// B pictures
	dec_params->Bframe_ctr=0;

	// time for total decoding session
	dec_params->tot_time = 0;

	dec_params->nalu = AllocNALU(MAX_CODED_FRAME_SIZE,dec_params);
	nalu = dec_params->nalu;

	dec_params->dp   = AllocPartition(1, dec_params,1024);
	dec_params->sps  = AllocSPS();
	dec_params->pps  = AllocPPS();


	{
		while ( decode_one_frame( dec_params ) != EOS );
	}	
	//report( dec_params->input, dec_params->img, dec_params->snr,dec_params,);
	report( dec_params->input, dec_params->img,dec_params);
	free_slice( dec_params->input,dec_params->img);

	FreeNALU(dec_params->nalu);
	FreePartition (dec_params->dp, 1);
	FreeSPS (dec_params->sps);
    if (dec_params->PicParSet[dec_params->pps->pic_parameter_set_id].Valid == TRUE && dec_params->PicParSet[dec_params->pps->pic_parameter_set_id].slice_group_id != NULL)
	{
		h264_free (dec_params->PicParSet[dec_params->pps->pic_parameter_set_id].slice_group_id);
		dec_params->PicParSet[dec_params->pps->pic_parameter_set_id].slice_group_id = NULL;
	}
	
	// IF FMO PRESENT
	if (dec_params->active_pps->num_slice_groups_minus1) 
	{
	FmoFinit(dec_params);
	}	

	FreePPS (dec_params->pps);
	
	
	free_global_buffers_baseline(dec_params);
	
	flush_dpb(dec_params);
	
#ifdef PAIR_FIELDS_IN_OUTPUT
	flush_pending_output(dec_params->p_out);
#endif
	
	CloseBitstreamFile(dec_params);
	
	//close(dec_params->p_out);
	fclose (dec_params->f_out);
	//  fclose(p_out2);

#if TRACE
	fclose(p_trace);
#endif
	
	//ercClose(dec_params->erc_errorVar,dec_params);
	ercClose(dec_params);
	
	free_dpb(dec_params);
//	uninit_out_buffer(dec_params);
	
	free_colocated(dec_params);
	if(dec_params->dec_picture != NULL)
	{
		free (dec_params->dec_picture);
		dec_params->dec_picture = NULL;
	}
	if(dec_params->input != NULL)
	{
		h264_free (dec_params->input);
		dec_params->input = NULL;
	}
	if(dec_params->img != NULL)
	{
		h264_free (dec_params->img);
		dec_params->img = NULL;
	}
	if(dec_params != NULL)
	{
		h264_free (dec_params);
		dec_params = NULL;
	}
	return 0;
}
ObjectRenderer::ObjectRenderer(){

    mObject = NULL;
    Configure(NULL);
}