static void __WINAPI LPMessageCB(lprec *lp, void *USERHANDLE, int msg)
{
  if(msg==MSG_LPFEASIBLE)
    DoReport(lp, "Feasible solution ");
  else if(msg==MSG_LPOPTIMAL)
    DoReport(lp, "Real solution ");
  else if(msg==MSG_MILPFEASIBLE)
    DoReport(lp, "First MILP    ");
  else if(msg==MSG_MILPBETTER)
    DoReport(lp, "Improved MILP ");
}
Esempio n. 2
0
/*
--------------------------------------------------------------------------------
API routine : Get encoding mode
--------------------------------------------------------------------------------
*/
ST_ErrorCode_t  STDENC_GetEncodingMode(
                const STDENC_Handle_t    Handle,
                STDENC_EncodingMode_t *  const EncodingMode_p
                )
{
    ST_ErrorCode_t ErrorCode;
    DENC_t *Unit_p;

    if (STDENC_CheckHandle(Handle) != ST_NO_ERROR)
    {
        return(ST_ERROR_INVALID_HANDLE);
    }
    if (EncodingMode_p == NULL)
    {
        return(ST_ERROR_BAD_PARAMETER);
    }
    Unit_p = (DENC_t *)Handle;

    /* Protect access */
    STOS_SemaphoreWait(Unit_p->Device_p->ModeCtrlAccess_p);

    *EncodingMode_p = Unit_p->Device_p->EncodingMode;
    ErrorCode = ST_NO_ERROR;

    /* Free access */
    STOS_SemaphoreSignal(Unit_p->Device_p->ModeCtrlAccess_p);

    DoReport("STDENC_GetEncodingMode ", ErrorCode);
    return(ErrorCode);
} /* end of STDENC_GetEncodingMode */
Esempio n. 3
0
UINT CMReportMainView::Main()
{
	wstring tmp = theApp.m_strStaionID;
	m_isExit = false;
	while(!m_isExit)
	{
		if(!m_dataToBeReported.is_not_empty())
		{
			if (m_isExit)
			{
				break;
			}
			Sleep(5);
			continue;
		}
		DoReport();
		Sleep(20);
	}
	return 0;
}
Esempio n. 4
0
/*
--------------------------------------------------------------------------------
API routine : Set colorbar pattern
--------------------------------------------------------------------------------
*/
ST_ErrorCode_t  STDENC_SetColorBarPattern(
                const STDENC_Handle_t       Handle,
                const BOOL                  ColorBarPattern
                )
 {
    ST_ErrorCode_t ErrorCode = ST_NO_ERROR;
    DENC_t *Unit_p;
    char string[30];

    sprintf(string, "STDENC_SetColorBarPattern ");

    if (STDENC_CheckHandle(Handle) != ST_NO_ERROR)
    {
        return(ST_ERROR_INVALID_HANDLE);
    }

    Unit_p = (DENC_t *)Handle;

    /* Protect access */
    STOS_SemaphoreWait(Unit_p->Device_p->ModeCtrlAccess_p);

    if (ColorBarPattern)
    {
        strcat(string, " On");
        ErrorCode = stdenc_HALSetColorBarPattern(Unit_p->Device_p);
    }
    else
    {
        strcat(string, " Off");
        ErrorCode = stdenc_HALRestoreConfiguration0(Unit_p->Device_p);
    }
    /* Free access */
    STOS_SemaphoreSignal(Unit_p->Device_p->ModeCtrlAccess_p);

    DoReport(string, ErrorCode);
    return(ErrorCode);
 } /* end of STDENC_SetColorBarPattern */
Esempio n. 5
0
flag CReport::DoExcelReports()
  {
  ASSERT(gs_pPrj);
  CSVColArray c;
  char Buff[8192];
  const int ReportKeyLen = strlen(ReportKey);
  int i,j,Pos1;
  char* p;
  DWORD dwSize = 0;
  void* pData = NULL;
  char* pDat;
  i = 0;
  flag found = 0;
  flag DoMore = 1;
  flag FoundOne = 0;
  flag DoReportErr = 1;
  int jStart = 0;
  CDdeReportInfo& d = gs_pPrj->ReportInfo; 
  while (DoMore && i<d.iVSearchLen)
    {
    sprintf(Buff, "R%dC1:R%dC%d", i+1, i+1, d.iHSearchLen+1);
    pConv->Request(Buff, &pData, &dwSize); //request for a row
    if (dwSize) 
      {//got row...
      pDat = (char*)pData;
      int nToks = ParseTokens(pDat, c, '\t');
      XStrRTrim(c[nToks-1], "\r\t\n ");
      found = False;
      j = jStart;
      while (!found && j<nToks)
        {
        if (_strnicmp(c[j], ReportKey, ReportKeyLen)==0)
          {
          if (ParseFn(c[j]))
            found = (bAll || sReportName==sName);
          else
            {
            DoReportErr = 0;
            ReportError(13L, "Illegal syntax for %s....) R%dC%d", ReportKey, i+1, j+1);
            found = False;
            }
          }
        j++;
        }
      delete pData;
      
      jStart = 0;
      if (found)
        {//found, now get tags...
        iStartRow = i+1;
        iStartCol = j;
        //get the primary tags...
        if (bVert)
          sprintf(Buff, "R%dC%d:R%dC%d", iStartRow+1, iStartCol, iStartRow+lALen, iStartCol);
        else
          sprintf(Buff, "R%dC%d:R%dC%d", iStartRow, iStartCol+1, iStartRow, iStartCol+lALen);
        char c = (bVert ? '\r' : '\t');
        pConv->Request(Buff, &pData, &dwSize);
        if (dwSize) 
          {
          pDat = (char*)pData;
          Pos1 = 0;
          int index = 0;
          p = strchr(pDat, c);
          while (p)
            {
            p[0] = 0;
            SetATag(index, &pDat[Pos1]);
            Pos1 = p - pDat + 1;
            if (bVert)
              Pos1++;
            index++;
            p = strchr(&pDat[Pos1], c);
            }
          if (index<lALen)
            SetATag(index, &pDat[Pos1]);
          delete pData;
          }
        else
          {
          pConv->Release(); // and it should get deleted
          ReportError(14L, "Unable to get primary tags %s from excel", Buff);
          return False;
          }
        //get the secondary tags...
        if (bVert)
          sprintf(Buff, "R%dC%d:R%dC%d", iStartRow, iStartCol+1, iStartRow, iStartCol+lBLen);
        else
          sprintf(Buff, "R%dC%d:R%dC%d", iStartRow+1, iStartCol, iStartRow+lBLen, iStartCol);
        c = (bVert ? '\t' : '\r');
        pConv->Request(Buff, &pData, &dwSize);
        if (dwSize) 
          {
          pDat = (char*)pData;
          Pos1 = 0;
          int index = 0;
          p = strchr(pDat, c);
          while (p)
            {
            p[0] = 0;
            SetBTag(index, &pDat[Pos1]);
            Pos1 = p - pDat + 1;
            if (!bVert)
              Pos1++;
            index++;
            p = strchr(&pDat[Pos1], c);
            }
          if (index<lBLen)
            SetBTag(index, &pDat[Pos1]);
          delete pData;
          }
        else
          {
          pConv->Release(); // and it should get deleted
          ReportError(15L, "Unable to get secondary tags %s from excel", Buff);
          return False;
          }

        //have the primary and secondry tags, do the report...
        DoReport();
        FoundOne = 1;
        DoMore = bAll;
        i--;
        jStart = j;
        }
      }
    else
      {
      pConv->Release(); // and it should get deleted
      ReportError(11L, "Unable to get request %s from excel", Buff);
      return False;
      }
    i++;
    }
  if (!FoundOne)
    {
    pConv->Release(); // and it should get deleted
    if (DoReportErr)
      ReportError(12L, "Unable to find %s....)", ReportKey);
    return False;
    }
  return True;
  }
Esempio n. 6
0
/*
--------------------------------------------------------------------------------
API routine : Get mode option
ATTENTION : ModeOption_p->Option is an INPUT although in a "Get" function
--------------------------------------------------------------------------------
*/
ST_ErrorCode_t STDENC_GetModeOption (
                    const STDENC_Handle_t  Handle,
                    STDENC_ModeOption_t *  const ModeOption_p
                    )
{
    ST_ErrorCode_t ErrorCode = ST_NO_ERROR;
    STDENC_EncodingMode_t *CurrentMode_p;
    DENC_t *Unit_p;

    if (STDENC_CheckHandle(Handle) != ST_NO_ERROR)
    {
        return(ST_ERROR_INVALID_HANDLE);
    }
    if (ModeOption_p == NULL)
    {
        return(ST_ERROR_BAD_PARAMETER);
    }

    Unit_p = (DENC_t *)Handle;

    /* Protect access */
    STOS_SemaphoreWait(Unit_p->Device_p->ModeCtrlAccess_p);

    CurrentMode_p = &(Unit_p->Device_p->EncodingMode);
    switch(ModeOption_p->Option)
    {
        case STDENC_OPTION_BLACK_LEVEL_PEDESTAL :
            ModeOption_p->Value.BlackLevelPedestal = Unit_p->Device_p->BlackLevelPedestal;
            break;
        case STDENC_OPTION_BLACK_LEVEL_PEDESTAL_AUX :
            if (Unit_p->Device_p->DencVersion < 12 || !(Unit_p->Device_p->IsAuxEncoderOn))
            {
                ErrorCode = ST_ERROR_FEATURE_NOT_SUPPORTED;
            }
            else
            {
                ModeOption_p->Value.BlackLevelPedestalAux = Unit_p->Device_p->BlackLevelPedestalAux;
            }
            break;
        case STDENC_OPTION_CHROMA_DELAY :
            ModeOption_p->Value.ChromaDelay = Unit_p->Device_p->ChromaDelay;
            break;
        case STDENC_OPTION_CHROMA_DELAY_AUX :
            if (Unit_p->Device_p->DencVersion < 12 || !(Unit_p->Device_p->IsAuxEncoderOn))
            {
                ErrorCode = ST_ERROR_FEATURE_NOT_SUPPORTED;
            }
            else
            {
                ModeOption_p->Value.ChromaDelayAux = Unit_p->Device_p->ChromaDelayAux;
            }
            break;
        case STDENC_OPTION_LUMA_TRAP_FILTER :
            ModeOption_p->Value.LumaTrapFilter = Unit_p->Device_p->LumaTrapFilter;
            break;
        case STDENC_OPTION_LUMA_TRAP_FILTER_AUX :
            if (Unit_p->Device_p->DencVersion < 12 || !(Unit_p->Device_p->IsAuxEncoderOn))
            {
                ErrorCode = ST_ERROR_FEATURE_NOT_SUPPORTED;
            }
            else
            {
                ModeOption_p->Value.LumaTrapFilterAux = Unit_p->Device_p->LumaTrapFilterAux;
            }
            break;
        case STDENC_OPTION_FIELD_RATE_60HZ :
            if (   (MODE_IS_PAL(CurrentMode_p->Mode))
                || (MODE_IS_SECAM(CurrentMode_p->Mode)))
            {
                ErrorCode = ST_ERROR_FEATURE_NOT_SUPPORTED;
            }
            else
            {
                ModeOption_p->Value.FieldRate60Hz = CurrentMode_p->Option.Ntsc.FieldRate60Hz;
            }
            break;
        case STDENC_OPTION_NON_INTERLACED :
            if (CurrentMode_p->Mode == STDENC_MODE_SECAM)
            {
                ErrorCode = ST_ERROR_FEATURE_NOT_SUPPORTED;
            }
            else
            {
                if (MODE_IS_PAL(CurrentMode_p->Mode))
                {
                    ModeOption_p->Value.Interlaced = CurrentMode_p->Option.Pal.Interlaced;
                }
                else if (MODE_IS_NTSC(CurrentMode_p->Mode))
                {
                    ModeOption_p->Value.Interlaced = CurrentMode_p->Option.Ntsc.Interlaced;
                }
            }
            break;
        case STDENC_OPTION_SQUARE_PIXEL :
            if ((CurrentMode_p->Mode == STDENC_MODE_SECAM) && (Unit_p->Device_p->DencVersion < 10))
            {
                ErrorCode = ST_ERROR_FEATURE_NOT_SUPPORTED;
            }
            else
            {
                if (MODE_IS_PAL(CurrentMode_p->Mode))
                {
                    ModeOption_p->Value.SquarePixel = CurrentMode_p->Option.Pal.SquarePixel;
                }
                else if (MODE_IS_NTSC(CurrentMode_p->Mode))
                {
                    ModeOption_p->Value.SquarePixel = CurrentMode_p->Option.Ntsc.SquarePixel;
                }
                else if (CurrentMode_p->Mode == STDENC_MODE_SECAM)
                {
                    ModeOption_p->Value.SquarePixel = Unit_p->Device_p->SECAMSquarePixel;
                }
            }
            break;
        case STDENC_OPTION_YCBCR444_INPUT :
            ModeOption_p->Value.YCbCr444Input = Unit_p->Device_p->YCbCr444Input;
            break;
        default :
            ErrorCode = ST_ERROR_BAD_PARAMETER;
            break;
    } /* end of switch(ModeOption_p->Option) */

    /* Free access */
    STOS_SemaphoreSignal(Unit_p->Device_p->ModeCtrlAccess_p);

    DoReport("STDENC_GetModeOption ", ErrorCode);
    return(ErrorCode);
} /* end of STDENC_GetModeOption */
Esempio n. 7
0
/*
--------------------------------------------------------------------------------
API routine : Set mode option
--------------------------------------------------------------------------------
*/
ST_ErrorCode_t STDENC_SetModeOption (
                    const STDENC_Handle_t          Handle,
                    const STDENC_ModeOption_t *    const ModeOption_p
                    )
{
    BOOL IsThereChange = FALSE; /* update only if new Option is different from current */
    DENC_t *Unit_p;
    STDENC_EncodingMode_t *CurrentMode_p;
    ST_ErrorCode_t ErrorCode = ST_NO_ERROR;

    if (STDENC_CheckHandle(Handle) != ST_NO_ERROR)
    {
        return(ST_ERROR_INVALID_HANDLE);
    }
    if (ModeOption_p == NULL)
    {
        return(ST_ERROR_BAD_PARAMETER);
    }

    Unit_p = (DENC_t *)Handle;

    /* Protect access */
    STOS_SemaphoreWait(Unit_p->Device_p->ModeCtrlAccess_p);

    CurrentMode_p = &(Unit_p->Device_p->EncodingMode);
    /* check Option is valid, then that it is supported by current encoding mode and DENC cell version */
    /* then update only if new Option is different from current */
    switch(ModeOption_p->Option)
    {
        case STDENC_OPTION_BLACK_LEVEL_PEDESTAL :
            if (ModeOption_p->Value.BlackLevelPedestal != Unit_p->Device_p->BlackLevelPedestal)
            {
                Unit_p->Device_p->BlackLevelPedestal = ModeOption_p->Value.BlackLevelPedestal;
                IsThereChange = TRUE;
            }
            break;
        case STDENC_OPTION_BLACK_LEVEL_PEDESTAL_AUX :
            if (Unit_p->Device_p->DencVersion < 12 || !(Unit_p->Device_p->IsAuxEncoderOn))
            {
                ErrorCode = ST_ERROR_FEATURE_NOT_SUPPORTED;
            }
            else if (ModeOption_p->Value.BlackLevelPedestalAux != Unit_p->Device_p->BlackLevelPedestalAux)
            {
                Unit_p->Device_p->BlackLevelPedestalAux = ModeOption_p->Value.BlackLevelPedestalAux;
                IsThereChange = TRUE;
            }
            break;
        case STDENC_OPTION_CHROMA_DELAY :
            if (!IsChromaDelayValid(Unit_p->Device_p->DencVersion, ModeOption_p->Value.ChromaDelay))
            {
                ErrorCode = ST_ERROR_BAD_PARAMETER;
            }
            else if (ModeOption_p->Value.ChromaDelay != Unit_p->Device_p->ChromaDelay)
            {
                Unit_p->Device_p->ChromaDelay = ModeOption_p->Value.ChromaDelay;
                IsThereChange = TRUE;
            }
            break;
        case STDENC_OPTION_CHROMA_DELAY_AUX :
            if (Unit_p->Device_p->DencVersion < 12 || !(Unit_p->Device_p->IsAuxEncoderOn))
            {
                ErrorCode = ST_ERROR_FEATURE_NOT_SUPPORTED;
            }
            else if (!IsChromaDelayValid(Unit_p->Device_p->DencVersion, ModeOption_p->Value.ChromaDelayAux))
            {
                ErrorCode = ST_ERROR_BAD_PARAMETER;
            }
            else if (ModeOption_p->Value.ChromaDelayAux != Unit_p->Device_p->ChromaDelayAux)
            {
                Unit_p->Device_p->ChromaDelayAux = ModeOption_p->Value.ChromaDelayAux;
                IsThereChange = TRUE;
            }
            break;
        case STDENC_OPTION_LUMA_TRAP_FILTER :
            /* For SECAM trap filter must always be set */
            if ((CurrentMode_p->Mode == STDENC_MODE_SECAM) && !ModeOption_p->Value.LumaTrapFilter)
            {
                ErrorCode = ST_ERROR_FEATURE_NOT_SUPPORTED;
            }
            else if (ModeOption_p->Value.LumaTrapFilter != Unit_p->Device_p->LumaTrapFilter)
            {
                Unit_p->Device_p->LumaTrapFilter = ModeOption_p->Value.LumaTrapFilter;
                IsThereChange = TRUE;
            }
            break;
        case STDENC_OPTION_LUMA_TRAP_FILTER_AUX :
            if (Unit_p->Device_p->DencVersion < 12 || !(Unit_p->Device_p->IsAuxEncoderOn))
            {
                ErrorCode = ST_ERROR_FEATURE_NOT_SUPPORTED;
            }
            else if (CurrentMode_p->Mode == STDENC_MODE_SECAM) /* should be SECAM_AUX */
            {
                ErrorCode = ST_ERROR_BAD_PARAMETER;
            }
            /* For SECAM trap filter must always be set */
            else if ((CurrentMode_p->Mode == STDENC_MODE_SECAM_AUX) && !ModeOption_p->Value.LumaTrapFilterAux)
            {
                ErrorCode = ST_ERROR_BAD_PARAMETER;
            }
            else if (ModeOption_p->Value.LumaTrapFilterAux != Unit_p->Device_p->LumaTrapFilterAux)
            {
                Unit_p->Device_p->LumaTrapFilterAux = ModeOption_p->Value.LumaTrapFilterAux;
                IsThereChange = TRUE;
            }
            break;
        case STDENC_OPTION_FIELD_RATE_60HZ :
            if (   (   (MODE_IS_PAL(CurrentMode_p->Mode))
                    || (MODE_IS_SECAM(CurrentMode_p->Mode)))
                && (ModeOption_p->Value.FieldRate60Hz))
            {
                ErrorCode = ST_ERROR_FEATURE_NOT_SUPPORTED;
            }
            else if (ModeOption_p->Value.FieldRate60Hz != CurrentMode_p->Option.Ntsc.FieldRate60Hz)
            {
                CurrentMode_p->Option.Ntsc.FieldRate60Hz = ModeOption_p->Value.FieldRate60Hz;
                IsThereChange = TRUE;
            }
            break;
        case STDENC_OPTION_NON_INTERLACED :
            if ( (MODE_IS_SECAM(CurrentMode_p->Mode)) && (!ModeOption_p->Value.Interlaced))
            {
                ErrorCode = ST_ERROR_FEATURE_NOT_SUPPORTED;
            }
            else
            {
                if (   (MODE_IS_PAL(CurrentMode_p->Mode))
                    && (ModeOption_p->Value.Interlaced != CurrentMode_p->Option.Pal.Interlaced))
                {
                    CurrentMode_p->Option.Pal.Interlaced = ModeOption_p->Value.Interlaced;
                    IsThereChange = TRUE;
                }
                else if (   (MODE_IS_NTSC(CurrentMode_p->Mode))
                            && (ModeOption_p->Value.Interlaced != CurrentMode_p->Option.Ntsc.Interlaced))
                {
                    CurrentMode_p->Option.Ntsc.Interlaced = ModeOption_p->Value.Interlaced;
                    IsThereChange = TRUE;
                }
            }
            break;
        case STDENC_OPTION_SQUARE_PIXEL :
            if (   ((CurrentMode_p->Mode == STDENC_MODE_SECAM) && (Unit_p->Device_p->DencVersion < 10))
                && (ModeOption_p->Value.SquarePixel))
            /* STDENC_MODE_SECAM_AUX is only supported for DencVersion >= 12 so ok */
            {
                ErrorCode = ST_ERROR_FEATURE_NOT_SUPPORTED;
            }
            else
            {
                if (   (MODE_IS_PAL(CurrentMode_p->Mode))
                    && (ModeOption_p->Value.SquarePixel != CurrentMode_p->Option.Pal.SquarePixel))
                {
                    CurrentMode_p->Option.Pal.SquarePixel = ModeOption_p->Value.SquarePixel;
                    IsThereChange = TRUE;
                }
                else if (   (MODE_IS_NTSC(CurrentMode_p->Mode))
                            && (ModeOption_p->Value.SquarePixel != CurrentMode_p->Option.Ntsc.SquarePixel))
                {
                    CurrentMode_p->Option.Ntsc.SquarePixel = ModeOption_p->Value.SquarePixel;
                    IsThereChange = TRUE;
                }
                else if (   (CurrentMode_p->Mode == STDENC_MODE_SECAM)
                            && (ModeOption_p->Value.SquarePixel != Unit_p->Device_p->SECAMSquarePixel))
                {
                    Unit_p->Device_p->SECAMSquarePixel = ModeOption_p->Value.SquarePixel;
                    IsThereChange = TRUE;
                }
            }
            break;
        case STDENC_OPTION_YCBCR444_INPUT :
            if (   (    (Unit_p->Device_p->DencVersion < 6)
                     || (Unit_p->Device_p->DeviceType == STDENC_DEVICE_TYPE_7015) )
                    && (ModeOption_p->Value.YCbCr444Input))
            {
                /* 4:4:4 is not supported */
                ErrorCode = ST_ERROR_FEATURE_NOT_SUPPORTED;
            }
            else if (  (   (Unit_p->Device_p->DencVersion >= 12)
                        || (Unit_p->Device_p->DeviceType == STDENC_DEVICE_TYPE_GX1)
                        || (Unit_p->Device_p->DeviceType == STDENC_DEVICE_TYPE_7020))
                     && !(ModeOption_p->Value.YCbCr444Input))
            {
                /* 4:2:2 is not supported */
                ErrorCode = ST_ERROR_FEATURE_NOT_SUPPORTED;
            }
            else if (ModeOption_p->Value.YCbCr444Input != Unit_p->Device_p->YCbCr444Input)
            {
                Unit_p->Device_p->YCbCr444Input = ModeOption_p->Value.YCbCr444Input;
                IsThereChange = TRUE;
            }
            break;
        default :
            ErrorCode = ST_ERROR_BAD_PARAMETER;
            break;
    } /* end of switch(ModeOption_p->Option) */

    if ( (ErrorCode == ST_NO_ERROR) && (IsThereChange))
    {
        ErrorCode = stdenc_HALSetEncodingMode(Unit_p->Device_p);
    }
    /* Free access */
    STOS_SemaphoreSignal(Unit_p->Device_p->ModeCtrlAccess_p);

    DoReport("STDENC_SetModeOption ", ErrorCode);
    return(ErrorCode);
} /* end of STDENC_SetModeOption */
Esempio n. 8
0
/*
--------------------------------------------------------------------------------
API routine : Set encoding mode
--------------------------------------------------------------------------------
*/
ST_ErrorCode_t  STDENC_SetEncodingMode(
                const STDENC_Handle_t         Handle,
                const STDENC_EncodingMode_t * const EncodingMode_p
                )
{
    ST_ErrorCode_t ErrorCode = ST_NO_ERROR;
    DENC_t *Unit_p;

    if (STDENC_CheckHandle(Handle) != ST_NO_ERROR)
    {
        return(ST_ERROR_INVALID_HANDLE);
    }
    if (EncodingMode_p == NULL)
    {
        return(ST_ERROR_BAD_PARAMETER);
    }

    Unit_p = (DENC_t *)Handle;

    /* Protect access */
    STOS_SemaphoreWait(Unit_p->Device_p->ModeCtrlAccess_p);

    /* check mode is valid */
    switch(EncodingMode_p->Mode)
    {
        case STDENC_MODE_NTSCM : /* no break */
        case STDENC_MODE_NTSCM_J : /* no break */
        case STDENC_MODE_NTSCM_443 :
            if (   (EncodingMode_p->Option.Ntsc.SquarePixel)    /* Square Pixel feature is only */
                && (Unit_p->Device_p->DencVersion < 6)          /* available for v>=6 */
                )
            {
                ErrorCode = STDENC_ERROR_INVALID_ENCODING_MODE;
            }
            else
            {
                if (EncodingMode_p->Mode == STDENC_MODE_NTSCM_J)
                {
                    Unit_p->Device_p->BlackLevelPedestal = FALSE; /* BlackLevelPedestalAux is set below */
                }
                else /* STDENC_MODE_NTSCM or STDENC_MODE_NTSCM_443*/
                {
                    Unit_p->Device_p->BlackLevelPedestal = TRUE;
                }
                if (Unit_p->Device_p->DencVersion < 10)
                {
                    Unit_p->Device_p->ChromaDelay = 0;
                }
                else /* Id >= 10 */
                {
                    if ( (Unit_p->Device_p->DeviceType == STDENC_DEVICE_TYPE_7015) || (Unit_p->Device_p->DeviceType == STDENC_DEVICE_TYPE_7020))
                    {
                        /* SwRWA of DDTS GNBvd07130, topic 4.3 of STi7015 Cut 1.1 validation report */
                        Unit_p->Device_p->ChromaDelay = -3;
                    }
                    else
                    {
                        Unit_p->Device_p->ChromaDelay = -1; /* in 4:2:2 format on CVBS, 4:4:4 format on CVBS is not supported */
                        if (Unit_p->Device_p->IsAuxEncoderOn)
                        {
                            Unit_p->Device_p->ChromaDelayAux = -1;
                            Unit_p->Device_p->BlackLevelPedestalAux = Unit_p->Device_p->BlackLevelPedestal;
                        }
                    }
                }
            }
            break;
        case STDENC_MODE_PALBDGHI : /* no break */
        case STDENC_MODE_PALM :     /* no break */
        case STDENC_MODE_PALN :     /* no break */
        case STDENC_MODE_PALN_C :
            if (   (EncodingMode_p->Option.Pal.SquarePixel)     /* Square Pixel feature is only */
                && (Unit_p->Device_p->DencVersion < 6)          /* available for v>=6 */
                )
            {
                ErrorCode = STDENC_ERROR_INVALID_ENCODING_MODE;
            }
            else
            {
                if ( (EncodingMode_p->Mode == STDENC_MODE_PALBDGHI) || (EncodingMode_p->Mode == STDENC_MODE_PALN_C))
                {
                    Unit_p->Device_p->BlackLevelPedestal = FALSE; /* BlackLevelPedestalAux is set below */
                }
                else /* STDENC_MODE_PALN or STDENC_MODE_PALM*/
                {
                    Unit_p->Device_p->BlackLevelPedestal = TRUE;
                }
                if (Unit_p->Device_p->DencVersion < 10)
                {
                    Unit_p->Device_p->ChromaDelay = 0;
                }
                else /* Id >= 10 */
                {
                    if ( (Unit_p->Device_p->DeviceType == STDENC_DEVICE_TYPE_7015) || (Unit_p->Device_p->DeviceType == STDENC_DEVICE_TYPE_7020))
                    {
                        /* SwRWA of DDTS GNBvd07130, topic 4.3 of STi7015 Cut 1.1 validation report */
                        Unit_p->Device_p->ChromaDelay = -3;
                    }
                    else
                    {
                        Unit_p->Device_p->ChromaDelay = 3;/*yxl 2007-09-06 modify to 3*/ /* in 4:2:2 format on CVBS, 4:4:4 format on CVBS is not supported */
                        if (Unit_p->Device_p->IsAuxEncoderOn)
                        {
                            Unit_p->Device_p->ChromaDelayAux = 3;/*yxl 2007-09-06 modify to 3*/
                            Unit_p->Device_p->BlackLevelPedestalAux = Unit_p->Device_p->BlackLevelPedestal;
                        }
                    }
                }
            }
            break;
        case STDENC_MODE_SECAM :
            if (   (Unit_p->Device_p->DencVersion < 6)   /* SECAM is not supported by v3 and v5 */
                || (   (Unit_p->Device_p->SECAMSquarePixel)     /* Square Pixel feature is only */
                    && (Unit_p->Device_p->DencVersion < 10)))   /* available for v>=10 */
            {
                ErrorCode = STDENC_ERROR_INVALID_ENCODING_MODE;
            }
            else
            {
                Unit_p->Device_p->BlackLevelPedestal = FALSE;  /* BlackLevelPedestalAux is set below switch() */
                Unit_p->Device_p->LumaTrapFilter     = TRUE;   /* mandatory */
                if ( (Unit_p->Device_p->DeviceType == STDENC_DEVICE_TYPE_7015) || (Unit_p->Device_p->DeviceType == STDENC_DEVICE_TYPE_7020))
                {
                    /* SwRWA of DDTS GNBvd07130, topic 4.3 of STi7015 Cut 1.1 validation report */
                    Unit_p->Device_p->ChromaDelay = -3;
                }
                else
                {
                    Unit_p->Device_p->ChromaDelay = 0; /* in 4:2:2 format on CVBS, 4:4:4 format on CVBS is not supported */
                    if (Unit_p->Device_p->IsAuxEncoderOn)
                    {
                        Unit_p->Device_p->ChromaDelayAux = 0;
                        Unit_p->Device_p->LumaTrapFilterAux = TRUE;   /* mandatory */
                    }
                }
            }
            break;
        case STDENC_MODE_SECAM_AUX :
            if ((Unit_p->Device_p->DencVersion < 12) || !(Unit_p->Device_p->IsAuxEncoderOn))   /* AUX is supported since V12 */
            {
                ErrorCode = STDENC_ERROR_INVALID_ENCODING_MODE;
            }
            else
            {
                Unit_p->Device_p->BlackLevelPedestalAux = FALSE;  /* BlackLevelPedestalAux is set below switch() */
                Unit_p->Device_p->ChromaDelayAux        = 0;
                Unit_p->Device_p->LumaTrapFilterAux     = TRUE;   /* mandatory */
            }
            break;
        case STDENC_MODE_NONE : /* no break */
        default :
            ErrorCode = STDENC_ERROR_INVALID_ENCODING_MODE;
            break;
    } /* end of switch(EncodingMode_p->Mode) */

    if (ErrorCode == ST_NO_ERROR)
    {
        /* update only if new EncodingMode is different from current */
        if ( memcmp(EncodingMode_p, &(Unit_p->Device_p->EncodingMode), sizeof(STDENC_EncodingMode_t)) != 0)
        {
            Unit_p->Device_p->EncodingMode = *EncodingMode_p;
            ErrorCode = stdenc_HALSetEncodingMode(Unit_p->Device_p);
        }
    } /* end of if (ErrorCode == ST_NO_ERROR) */

    /* Free access */
    STOS_SemaphoreSignal(Unit_p->Device_p->ModeCtrlAccess_p);

    DoReport("STDENC_SetEncodingMode ", ErrorCode);
    return(ErrorCode);
} /* end of STDENC_SetEncodingMode */