📄 cne2000.c
字号:
* PARAMETERS * IN IDecoderBoard* pIDecoderBoard - pointer to the board object * IN MPEG_OVERLAY_MODE Mode - one of: * MpegModeNone - hide the Mpeg * MpegModeRectangle - show the Mpeg over any VGA * MpegModeOverlay - see the Mpeg only through the selected VGA color * MpegModeCalibrate - for calibration * RETURN VALUE * Q_OK, E_INVALID_PARAMETER, E_NOT_SUPPORTED if Analog overlay is not present * SEE ALSO * IAnalogOverlay_SetMode, CNova__UpdateColorKey/*****************************************************************************/QRESULT CNE2000__OverlaySetMode(IDecoderBoard* pIDecoderBoard, MPEG_OVERLAY_MODE Mode){ CQuasarBoard *this = (CQuasarBoard*) pIDecoderBoard; if(this->m_pINova1 == NULL) return E_NOT_SUPPORTED; QDbgLog((QLOG_TRACE, QDebugLevelTrace, TEXT("CQB: SetMode %x"), Mode)); this->ModeReq = Mode; switch (Mode) { case MpegModeRectangle: // 2 this->OldLetterBox = this->LetterBox; // patch for border adjust this->LetterBox = (this->LetterBox & ~0x10);// no letter box in border adjust but keep PanScan flag break; case MpegModeNone: // 1 case MpegModeOverlay: // 3 case MpegModeCalibrate: // 4 this->LetterBox = this->OldLetterBox; break; default: this->LetterBox = this->OldLetterBox; return E_INVALID_PARAMETER; } IAnalogOverlay_SetMode(this->m_pINova1, Mode); return Q_OK;}/****f* HwLib/IDecoderBoard_OverlaySetColorCalibration * USAGE * QRESULT IDecoderBoard_OverlaySetColorCalibration(IDecoderBoard* pIDecoderBoard, PCALIBRATION_PARAMETERS p) * QRESULT CNE2000__OverlaySetColorCalibration(IDecoderBoard* pIDecoderBoard, PCALIBRATION_PARAMETERS p) * DESCRIPTION * IDecoderBoard_OverlaySetColorCalibration - used to set the internal CALIBRATION_PARAMETERS * structure after autocalibration or when the VGA mode is changed. * It calls IAnalogOverlay_SetColorCalibration. * PARAMETERS * IN IDecoderBoard* pIDecoderBoard - pointer to the board object * IN PCALIBRATION_PARAMETERS p * RETURN VALUE * Q_OK, E_NOT_SUPPORTED if Analog overlay is not present * SEE ALSO * IDecoderBoard_OverlayColorCalibrate/*****************************************************************************/QRESULT CNE2000__OverlaySetColorCalibration(IDecoderBoard* pIDecoderBoard, PCALIBRATION_PARAMETERS p){ CQuasarBoard *this = (CQuasarBoard*) pIDecoderBoard; if( this->m_pINova1 == NULL ) return E_NOT_SUPPORTED; IAnalogOverlay_SetColorCalibration(this->m_pINova1, p); return Q_OK;}/****f* HwLib/IDecoderBoard_AdjTopBorder * USAGE * QRESULT IDecoderBoard_AdjTopBorder(IDecoderBoard* pIDecoderBoard, SHORT* pYOffset) * QRESULT CNE2000__AdjTopBorder(IDecoderBoard* pIDecoderBoard, SHORT* pYOffset) * DESCRIPTION * IDecoderBoard_AdjTopBorder - it tries 5 times to autodetect the offset corresponding * to 0 vertical coordinate of the physical screen. * Before calling IDecoderBoard_AdjTopBorder paint VGA black with one 50% blue * horizontal line at the top of the screen. * IDecoderBoard_AdjTopBorder draws MpegWindow black with two/four white horizontal * lines at the top and set color key to 25% blue. Then it moves down MpegWnd until * the analog chip detects the Mpeg white line through first VGA blue line. * PARAMETERS * IN IDecoderBoard* pIDecoderBoard - pointer to the board object * OUT SHORT* pYOffset - points to SHORT that receive the YOffset * RETURN VALUE * Q_OK, E_NOVA_AUTOCALIB_FAILED or E_NOT_SUPPORTED if AnalogOverlay is not present * SEE ALSO * IDecoderBoard_OverlayCalibrate, IAnalogOverlay_StartAutoCalibration, * IAnalogOverlay_DetectPulse, IAnalogOverlay_ClearPulse/*****************************************************************************/QRESULT CNE2000__AdjTopBorder(IDecoderBoard* pIDecoderBoard, SHORT* pYOffset){#define YOFFSET_MIN 4#define YOFFSET_MAX 60 CQuasarBoard *this = (CQuasarBoard*) pIDecoderBoard; DWORD Width = 720, Height = 480; int iNbAttempts = 0; SHORT BorderOfsX = 100, BorderOfsY; DWORD Correction = 1000; if( this->m_pINova1 == NULL ) return E_NOT_SUPPORTED; IAnalogOverlay_StartAutoCalibration(this->m_pINova1); IDecoder_VideoWriteCommand(this->m_pIDecoder, VIDEO_BLACKFRAME_UNPACKED); OSTimeDelay(DICOM_UPDATE_TIME); // Draw 2 (4 when interlaced) WHITE horizontal lines in MPEG video IDecoder_DrawBar(this->m_pIDecoder, 0, 0, Width, 2<<(this->IsInterlaced), BRIGHT, WHITE); do { iNbAttempts++; IAnalogOverlay_ClearPulse(this->m_pINova1, 1); BorderOfsY = YOFFSET_MIN; while (BorderOfsY < YOFFSET_MAX) { OSTimeDelay(DICOM_UPDATE_TIME); IDecoder_UpdateMpegDICOM(this->m_pIDecoder, 0, 0, Width, Height, BorderOfsX, BorderOfsY, Correction, this->IsInterlaced); if (IAnalogOverlay_DetectPulse(this->m_pINova1, 1)) break; // Increment the TOP border until blue pulse is detected BorderOfsY++; } } while ( ((BorderOfsY == YOFFSET_MIN)||(BorderOfsY == YOFFSET_MAX)) && (iNbAttempts < 5) ); // Restore 4 BLACK horizontal lines in MPEG video // IDecoder_DrawBar(this->m_pIDecoder, 0, 0, Width, 4, DARK, BLACK); QDbgLog((QLOG_TRACE, QDebugLevelWarning, TEXT("Pulse %s BorderOfsY=%d iNbAttempts=%d"), (BorderOfsY < YOFFSET_MAX)?"detected":"not detected", BorderOfsY, iNbAttempts )); BorderOfsY -= 1; BorderOfsY >>= this->IsInterlaced; *pYOffset = BorderOfsY; IAnalogOverlay_StopAutoCalibration(this->m_pINova1); return ((iNbAttempts < 5) && (BorderOfsY < YOFFSET_MAX)) ? Q_OK : E_NOVA_AUTOCALIB_FAILED;}/****f* HwLib/IDecoderBoard_AdjLeftBorder * USAGE * QRESULT IDecoderBoard_AdjLeftBorder(IDecoderBoard* pIDecoderBoard, SHORT* pXOffset) * QRESULT CNE2000__AdjLeftBorder(IDecoderBoard* pIDecoderBoard, SHORT* pXOffset) * DESCRIPTION * IDecoderBoard_AdjLeftBorder - it tries 5 times to autodetect the offset corresponding * to 0 horizontal coordinate of the physical screen. * Before calling IDecoderBoard_AdjLeftBorder paint VGA black with one 50% blue * vertical line at the left of the screen. * IDecoderBoard_AdjLeftBorder draws MpegWindow black with two white vertical * lines at the left and set color key to 25% blue. Then it moves to right MpegWnd until * the analog chip detects the Mpeg white line through first VGA blue line. * PARAMETERS * IN IDecoderBoard* pIDecoderBoard - pointer to the board object * OUT SHORT* pXOffset - points to SHORT that receive the XOffset * RETURN VALUE * Q_OK, E_NOVA_AUTOCALIB_FAILED or E_NOT_SUPPORTED if AnalogOverlay is not present * SEE ALSO * IDecoderBoard_OverlayCalibrate, IAnalogOverlay_StartAutoCalibration, * IAnalogOverlay_DetectPulse, IAnalogOverlay_ClearPulse/*****************************************************************************/QRESULT CNE2000__AdjLeftBorder(IDecoderBoard* pIDecoderBoard, SHORT* pXOffset){#define XOFFSET_MIN 100//#define XOFFSET_MAX 280 // Dvclk same as VGA pixel clock#define XOFFSET_MAX 480 // Dvclk at maximum value CQuasarBoard *this = (CQuasarBoard*) pIDecoderBoard; DWORD Width = 720, Height = 480; int iNbAttempts = 0; SHORT BorderOfsX, BorderOfsY = 4; // The minimum for Quasar DWORD Correction = 1000; if( this->m_pINova1 == NULL ) return E_NOT_SUPPORTED; IAnalogOverlay_StartAutoCalibration(this->m_pINova1); IDecoder_VideoWriteCommand(this->m_pIDecoder, VIDEO_BLACKFRAME_UNPACKED); OSTimeDelay(DICOM_UPDATE_TIME); // Draw 2 WHITE vertical lines in MPEG video IDecoder_DrawBar(this->m_pIDecoder, 0, 0, 2, Height, BRIGHT, WHITE); do { iNbAttempts++; IAnalogOverlay_ClearPulse(this->m_pINova1, 1); BorderOfsX = XOFFSET_MIN; while (BorderOfsX < XOFFSET_MAX) { OSTimeDelay(DICOM_UPDATE_TIME); IDecoder_UpdateMpegDICOM(this->m_pIDecoder, 0, 0, Width, Height, BorderOfsX, BorderOfsY, Correction, this->IsInterlaced); if (IAnalogOverlay_DetectPulse(this->m_pINova1, 1)) break; // Increment the left border until blue pulse is detected BorderOfsX++; } } while ( ((BorderOfsX == XOFFSET_MIN)||(BorderOfsX == XOFFSET_MAX)) && (iNbAttempts < 5) ); // Restore 2 BLACK vertical lines in MPEG video // IDecoder_DrawBar(this->m_pIDecoder, 0, 0, 2, Height, DARK, BLACK); QDbgLog((QLOG_TRACE, QDebugLevelWarning, TEXT("Pulse %s BorderOfsX=%d iNbAttempts=%d"), (BorderOfsX < XOFFSET_MAX)?"detected":"not detected", BorderOfsX, iNbAttempts )); *pXOffset = BorderOfsX; IAnalogOverlay_StopAutoCalibration(this->m_pINova1); return ((iNbAttempts < 5) && (BorderOfsX < XOFFSET_MAX)) ? Q_OK : E_NOVA_AUTOCALIB_FAILED;}/****f* HwLib/IDecoderBoard_AdjCorrection * USAGE * QRESULT IDecoderBoard_AdjCorrection(IDecoderBoard* pIDecoderBoard, SHORT* pXOffset) * QRESULT CNE2000__AdjCorrection(IDecoderBoard* pIDecoderBoard, SHORT* pXOffset) * DESCRIPTION * IDecoderBoard_AdjCorrection - it tries 5 times to autodetect the correction ratio * between the VGA pixel period and Mpeg pixel period. * Before calling IDecoderBoard_AdjCorrection paint VGA black with one 50% blue * vertical line at at x = 355 of the screen. * IDecoderBoard_AdjCorrection draws MpegWindow black with two white vertical * lines at x = 710 and set color key to 25% blue. Then it scales MpegWnd until * the analog chip detects the Mpeg white line through the VGA blue line. * PARAMETERS * IN IDecoderBoard* pIDecoderBoard - pointer to the board object * IN SHORT BorderOfsX - the XOffset previously determined by IDecoderBoard_AdjLeftBorder * OUT DWORD* pCorrection - points to DWORD that receive the Correction * RETURN VALUE * Q_OK, E_NOVA_AUTOCALIB_FAILED or E_NOT_SUPPORTED if AnalogOverlay is not present * SEE ALSO * IDecoderBoard_OverlayCalibrate, IAnalogOverlay_StartAutoCalibration, * IAnalogOverlay_DetectPulse, IAnalogOverlay_ClearPulse/*****************************************************************************/QRESULT CNE2000__AdjCorrection(IDecoderBoard* pIDecoderBoard, SHORT BorderOfsX, DWORD* pCorrection){#define DELTA_CORR_MINUS 100#define DELTA_CORR_PLUS 150 CQuasarBoard *this = (CQuasarBoard*) pIDecoderBoard; DWORD Width = 720, Height = 480; int iNbAttempts = 0; DWORD BorderOfsY = 4, Correction; LONG IncrCorr = 1; if( this->m_pINova1 == NULL ) return E_NOT_SUPPORTED; IAnalogOverlay_StartAutoCalibration(this->m_pINova1); IDecoder_VideoWriteCommand(this->m_pIDecoder, VIDEO_BLACKFRAME_UNPACKED); OSTimeDelay(DICOM_UPDATE_TIME); // Draw 2 WHITE vertical lines in MPEG video IDecoder_DrawBar(this->m_pIDecoder, 356, 0, 2, Height, BRIGHT, WHITE); if(this->DefCorrection >1200) IncrCorr = 2; do { iNbAttempts++; IAnalogOverlay_ClearPulse(this->m_pINova1, 1); Correction = this->DefCorrection - DELTA_CORR_MINUS; while (Correction < (this->DefCorrection + DELTA_CORR_PLUS) ) { OSTimeDelay(DICOM_UPDATE_TIME); IDecoder_UpdateMpegDICOM(this->m_pIDecoder, 0, 0, Width, Height, BorderOfsX, BorderOfsY, Correction, this->IsInterlaced); if (IAnalogOverlay_DetectPulse(this->m_pINova1, 1)) break; // Scale down the Mpeg until blue pulse is detected Correction += IncrCorr; } } while ( ((Correction == (this->DefCorrection - DELTA_CORR_PLUS)) || (Correction == (this->DefCorrection + DELTA_CORR_PLUS))) && (iNbAttempts < 5) ); // Restore 2 BLACK vertical lines in MPEG video // IDecoder_DrawBar(this->m_pIDecoder, 356, 0, 2, Height, DARK, BLACK); QDbgLog((QLOG_TRACE, QDebugLevelWarning, TEXT("Pulse %s Correction=%d iNbAttempts=%d"), (Correction < (this->DefCorrection + DELTA_CORR_PLUS))?"detected":"not detected", Correction, iNbAttempts )); *pCorrection = Correction; IAnalogOverlay_StopAutoCalibration(this->m_pINova1); return ((iNbAttempts < 5) && (Correction < (this->DefCorrection + DELTA_CORR_PLUS))) ? Q_OK : E_NOVA_AUTOCALIB_FAILED;}/****f* HwLib/IDecoderBoard_OverlayColorCalibrate * USAGE * QRESULT IDecoderBoard_OverlayColorCalibrate(IDecoderBoard* pIDecoderBoard, * OVERLAY_COLOUR_REGISTERS *pIn, OVERLAY_COLOUR_REGISTERS *pOut) * QRESULT CNE2000__OverlayColorCalibrate(IDecoderBoard* pIDecoderBoard, * OVERLAY_COLOUR_REGISTERS *pIn, OVERLAY_COLOUR_REGISTERS *pOut) * DESCRIPTION * IDecoderBoard_OverlayColorCalibrate determine the range for 100%,50% and 0%: * - for 100% - paint VGA black with one central white bar and call * IDecoderBoard_OverlayColorCalibrate with pIn->Mask=0x81 for lower values and * pIn->Mask=0x80 for upper values. IDecoderBoard_OverlayColorCalibrate draws * MpegWindow black. Then it modifies the range of color until the analog chip detects. * - for 50% - paint VGA black with one central grey bar and call * IDecoderBoard_OverlayColorCalibrate with pIn->Mask=0x83 for lower values and * pIn->Mask=0x82 for upper values. IDecoderBoard_OverlayColorCalibrate draws * MpegWindow black. Then it modifies the range of color until the analog chip detects. * - for 0% - paint VGA black and call IDecoderBoard_OverlayColorCalibrate with * pIn->Mask=0x85 for lower values and pIn->Mask=0x84 for upper values. * IDecoderBoard_OverlayColorCalibrate returns some defaults. * PARAMETERS * IN IDecoderBoard* pIDecoderBoard - pointer to the board object * IN OVERLAY_COLOUR_REGISTERS *pIn - * OUT OVERLAY_COLOUR_REGISTERS *pOut - * RETURN VALUE * Q_OK, E_NOVA_AUTOCALIB_FAILED or E_NOT_SUPPORTED if AnalogOverlay is not present * SEE ALSO * IDecoderBoard_OverlayCalibrate, IAnalogOverlay_UpperLower/*****************************************************************************/QRESULT CNE2000__OverlayColorCalibrate(IDecoderBoard* pIDecoderBoard, OVERLAY_COLOUR_REGISTERS *pIn, OVERLAY_COLOUR_REGISTERS *pOut){ CQuasarBoard *this = (CQuasarBoard*) pIDecoderBoard; DWORD Width = 720, Height = 480;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -