📄 video.c
字号:
case EMhwlibTVStandard_1080p29: case EMhwlibTVStandard_1080p25: case EMhwlibTVStandard_1080p24: case EMhwlibTVStandard_1080p23: case EMhwlibTVStandard_1080i50_1250: case EMhwlibTVStandard_1080p50_1250: case EMhwlibTVStandard_720p60: case EMhwlibTVStandard_720p59: case EMhwlibTVStandard_720p50: case EMhwlibTVStandard_720p30: case EMhwlibTVStandard_720p29: case EMhwlibTVStandard_720p25: case EMhwlibTVStandard_720p24: case EMhwlibTVStandard_720p23: case EMhwlibTVStandard_VESA_1360x768x60: case EMhwlibTVStandard_VESA_1280x720x60: case EMhwlibTVStandard_VESA_1280x720x75: case EMhwlibTVStandard_VESA_1920x1080x60i: *asp_x = 16; *asp_y = 9; break; case EMhwlibTVStandard_VESA_1280x768x60RB: case EMhwlibTVStandard_VESA_1280x768x60: case EMhwlibTVStandard_VESA_1280x768x75: case EMhwlibTVStandard_VESA_1280x768x85: *asp_x = 5; *asp_y = 3; break; case EMhwlibTVStandard_VESA_1280x1024x60: case EMhwlibTVStandard_VESA_1280x1024x75: case EMhwlibTVStandard_VESA_1280x1024x85: case EMhwlibTVStandard_CVT_1280x1024x50: case EMhwlibTVStandard_CVT_1280x1024x60: case EMhwlibTVStandard_CVT_1280x1024x75: case EMhwlibTVStandard_CVT_1280x1024x85: *asp_x = 5; *asp_y = 4; break; case EMhwlibTVStandard_VESA_1920x1200x60RB: case EMhwlibTVStandard_VESA_1920x1200x60: case EMhwlibTVStandard_VESA_1920x1200x75: case EMhwlibTVStandard_VESA_1920x1200x85: case EMhwlibTVStandard_VESA_1440x900x60RB: case EMhwlibTVStandard_VESA_1440x900x60: case EMhwlibTVStandard_VESA_1440x900x75: case EMhwlibTVStandard_VESA_1680x1050x60RB: case EMhwlibTVStandard_VESA_1680x1050x60: *asp_x = 8; *asp_y = 5; break; case EMhwlibTVStandard_VESA_720x400x70: *asp_x = 9; *asp_y = 5; break; // SD/ED modes, ambiguous case EMhwlibTVStandard_HDMI_480p59: case EMhwlibTVStandard_HDMI_480p60: case EMhwlibTVStandard_HDMI_480i59: case EMhwlibTVStandard_HDMI_480i60: case EMhwlibTVStandard_HDMI_1440x480i59: case EMhwlibTVStandard_HDMI_1440x480i60: case EMhwlibTVStandard_HDMI_240p59: case EMhwlibTVStandard_HDMI_240p60: case EMhwlibTVStandard_HDMI_1440x240p59: case EMhwlibTVStandard_HDMI_1440x240p60: case EMhwlibTVStandard_HDMI_2880x480i59: case EMhwlibTVStandard_HDMI_2880x480i60: case EMhwlibTVStandard_HDMI_2880x240p59: case EMhwlibTVStandard_HDMI_2880x240p60: case EMhwlibTVStandard_HDMI_1440x480p59: case EMhwlibTVStandard_HDMI_1440x480p60: case EMhwlibTVStandard_HDMI_576p50: case EMhwlibTVStandard_HDMI_576i50: case EMhwlibTVStandard_HDMI_1440x576i50: case EMhwlibTVStandard_HDMI_288p50: case EMhwlibTVStandard_HDMI_1440x288p50: case EMhwlibTVStandard_HDMI_2880x576i50: case EMhwlibTVStandard_HDMI_2880x288p50: case EMhwlibTVStandard_HDMI_1440x576p50: case EMhwlibTVStandard_HDMI_2880x480p59: case EMhwlibTVStandard_HDMI_2880x480p60: case EMhwlibTVStandard_HDMI_2880x576p50: case EMhwlibTVStandard_HDMI_576p100: case EMhwlibTVStandard_HDMI_576i100: case EMhwlibTVStandard_HDMI_1440x576i100: case EMhwlibTVStandard_HDMI_480p119: case EMhwlibTVStandard_HDMI_480p120: case EMhwlibTVStandard_HDMI_480i119: case EMhwlibTVStandard_HDMI_480i120: case EMhwlibTVStandard_HDMI_1440x480i119: case EMhwlibTVStandard_HDMI_1440x480i120: case EMhwlibTVStandard_HDMI_576p200: case EMhwlibTVStandard_HDMI_576i200: case EMhwlibTVStandard_HDMI_1440x576i200: case EMhwlibTVStandard_HDMI_480p239: case EMhwlibTVStandard_HDMI_480p240: case EMhwlibTVStandard_HDMI_480i239: case EMhwlibTVStandard_HDMI_480i240: case EMhwlibTVStandard_HDMI_1440x480i239: case EMhwlibTVStandard_HDMI_1440x480i240: case EMhwlibTVStandard_ITU_Bt656_525: case EMhwlibTVStandard_ITU_Bt656_240p: case EMhwlibTVStandard_NTSC_M_Japan: case EMhwlibTVStandard_NTSC_M: case EMhwlibTVStandard_PAL_60: case EMhwlibTVStandard_PAL_M: case EMhwlibTVStandard_480p59: case EMhwlibTVStandard_NTSC_M_Japan_714: case EMhwlibTVStandard_NTSC_M_714: case EMhwlibTVStandard_PAL_60_714: case EMhwlibTVStandard_PAL_M_714: case EMhwlibTVStandard_480p59_714: case EMhwlibTVStandard_ITU_Bt656_625: case EMhwlibTVStandard_ITU_Bt656_288p: case EMhwlibTVStandard_PAL_BG: case EMhwlibTVStandard_PAL_N: case EMhwlibTVStandard_576p50: case EMhwlibTVStandard_PAL_BG_702: case EMhwlibTVStandard_PAL_N_702: case EMhwlibTVStandard_576p50_702: if (wide) { *asp_x = 16; *asp_y = 9; break; } // all others, 4:3 default: *asp_x = 4; *asp_y = 3; break; } return RM_OK;}// 0..4095: absolute// 4096..8192: 0%..100% relativestatic RMstatus cap_video_set_scaler_source_zoom( struct RUA *pRUA, RMuint32 ScalerModuleID, RMuint32 x, RMuint32 y, RMuint32 w, RMuint32 h){ struct EMhwlibDisplayWindow source_window; #ifdef _DEBUG RMDBGLOG((LOCALDBG, "current zoom window on scaler 0x%08lX: ", ScalerModuleID)); if (x >= ZOOM_0) { RMuint32 xx = (((x - ZOOM_0) * 10000) + ((ZOOM_1 - ZOOM_0) / 2)) / (ZOOM_1 - ZOOM_0); RMDBGPRINT((LOCALDBG, "x=%ld.%02ld%% ", xx / 100, xx % 100)); } else RMDBGPRINT((LOCALDBG, "x=%ld ", x)); if (y >= ZOOM_0) { RMuint32 yy = (((y - ZOOM_0) * 10000) + ((ZOOM_1 - ZOOM_0) / 2)) / (ZOOM_1 - ZOOM_0); RMDBGPRINT((LOCALDBG, "y=%ld.%02ld%% ", yy / 100, yy % 100)); } else RMDBGPRINT((LOCALDBG, "y=%ld ", y)); if (w >= ZOOM_0) { RMuint32 ww = (((w - ZOOM_0) * 10000) + ((ZOOM_1 - ZOOM_0) / 2)) / (ZOOM_1 - ZOOM_0); RMDBGPRINT((LOCALDBG, "w=%ld.%02ld%% ", ww / 100, ww % 100)); } else RMDBGPRINT((LOCALDBG, "w=%ld ", w)); if (h >= ZOOM_0) { RMuint32 hh = (((h - ZOOM_0) * 10000) + ((ZOOM_1 - ZOOM_0) / 2)) / (ZOOM_1 - ZOOM_0); RMDBGPRINT((LOCALDBG, "h=%ld.%02ld%% ", hh / 100, hh % 100)); } else RMDBGPRINT((LOCALDBG, "h=%ld ", h)); RMDBGPRINT((LOCALDBG, "\n"));#endif source_window.X = (x >= ZOOM_0) ? (x - ZOOM_0) : x; source_window.Y = (y >= ZOOM_0) ? (y - ZOOM_0) : y; source_window.Width = (w >= ZOOM_0) ? (w - ZOOM_0) : w; source_window.Height = (h >= ZOOM_0) ? (h - ZOOM_0) : h; source_window.XPositionMode = EMhwlibDisplayWindowPositionMode_FrontEdgeToBorder; source_window.YPositionMode = EMhwlibDisplayWindowPositionMode_FrontEdgeToBorder; source_window.XMode = (x >= ZOOM_0) ? EMhwlibDisplayWindowValueMode_Relative : EMhwlibDisplayWindowValueMode_Fixed; source_window.YMode = (y >= ZOOM_0) ? EMhwlibDisplayWindowValueMode_Relative : EMhwlibDisplayWindowValueMode_Fixed; source_window.WidthMode = (w >= ZOOM_0) ? EMhwlibDisplayWindowValueMode_Relative : EMhwlibDisplayWindowValueMode_Fixed; source_window.HeightMode = (h >= ZOOM_0) ? EMhwlibDisplayWindowValueMode_Relative : EMhwlibDisplayWindowValueMode_Fixed; DCCSPERR(pRUA, ScalerModuleID, RMGenericPropertyID_ScalerInputWindow, &source_window, sizeof(source_window), "Error setting ScalerInputWindow"); DCCSPERR(pRUA, ScalerModuleID, RMGenericPropertyID_Validate, NULL, 0, "Failed to validate input"); return RM_OK;}/* local helper function to translate capture parameter to DCCCaptureProfile */static RMstatus cap_video_build_profile( struct cap_video_instance *pVideo, struct DCCCaptureProfile *cp){ RMstatus err; RMuint32 x_size, y_size; RMbool interlaced; RMDBGLOG((FUNCNAME, "%s\n",__func__)); if (pVideo->Setup.SurfaceColorSpace == EMhwlibColorSpace_None) pVideo->Setup.SurfaceColorSpace = pVideo->Setup.InputColorSpace; err = cap_video_get_frame_size(pVideo, pVideo->Setup.TVStandard, &x_size, &y_size, &interlaced); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Could not find video format #%u: %s\n", pVideo->Setup.TVStandard, RMstatusToString(err))); return err; } pVideo->Setup.over_pos_x = pVideo->Setup.shift_x - (pVideo->Setup.ov_lft << ((pVideo->Setup.bussize == 8) ? 1 : 0)); pVideo->Setup.over_pos_y = pVideo->Setup.shift_y - pVideo->Setup.ov_top; pVideo->Setup.over_width = (pVideo->Setup.ov_lft + pVideo->Setup.ov_rgt) << ((pVideo->Setup.bussize == 8) ? 1 : 0); pVideo->Setup.over_height = pVideo->Setup.ov_top + pVideo->Setup.ov_bot; cp->SamplingMode = pVideo->Setup.SamplingMode; cp->ColorMode = pVideo->Setup.ColorMode; cp->Width = x_size + pVideo->Setup.over_width; cp->Height = y_size + pVideo->Setup.over_height; cp->OrigWidth = x_size; cp->OrigHeight = y_size; cp->Interlaced = interlaced; cp->ColorSpace = pVideo->Setup.SurfaceColorSpace; cp->DeInt = pVideo->Setup.DeInt; cp->UseV2Pads = pVideo->Setup.UseV2Pads; if (pVideo->Setup.bussize == 8) { cp->ColorFormat = EMhwlibColorFormat_16BPP_565; } else if (pVideo->Setup.bussize == 16) { switch(pVideo->Setup.InputColorFormat) { case EMhwlibInputColorFormat_24BPP: case EMhwlibInputColorFormat_16BPP_565: cp->ColorFormat = EMhwlibColorFormat_16BPP_565; break; case EMhwlibInputColorFormat_24BPP_8565: case EMhwlibInputColorFormat_24BPP_5676: case EMhwlibInputColorFormat_32BPP: case EMhwlibInputColorFormat_16BPP_4444: case EMhwlibInputColorFormat_31BPP_7888: cp->ColorFormat = EMhwlibColorFormat_16BPP_4444; break; case EMhwlibInputColorFormat_16BPP_1555: cp->ColorFormat = EMhwlibColorFormat_16BPP_1555; break; } } else if (pVideo->Setup.bussize == 32) { switch(pVideo->Setup.InputColorFormat) { case EMhwlibInputColorFormat_24BPP: case EMhwlibInputColorFormat_16BPP_565: cp->ColorFormat = EMhwlibColorFormat_24BPP; break; case EMhwlibInputColorFormat_24BPP_8565: case EMhwlibInputColorFormat_24BPP_5676: case EMhwlibInputColorFormat_32BPP: case EMhwlibInputColorFormat_16BPP_1555: case EMhwlibInputColorFormat_16BPP_4444: case EMhwlibInputColorFormat_31BPP_7888: cp->ColorFormat = EMhwlibColorFormat_32BPP; break; } } // convert picture aspect ratio to pixel aspect ratio or vice versa // TODO use picture aspect ratio directly, when implemented in irq handler. if (pVideo->Setup.PixelAspectRatio.X && pVideo->Setup.PixelAspectRatio.Y) { cp->PixelAspectRatio = pVideo->Setup.PixelAspectRatio; cp->PictureAspectRatio.X = cp->PixelAspectRatio.X * cp->OrigWidth; cp->PictureAspectRatio.Y = cp->PixelAspectRatio.Y * cp->OrigHeight; cap_video_reduce_aspect_ratio(&(cp->PictureAspectRatio.X), &(cp->PictureAspectRatio.Y), 255); } else { cp->PictureAspectRatio = pVideo->Setup.PictureAspectRatio; cp->PixelAspectRatio.X = cp->PictureAspectRatio.X * cp->OrigHeight; cp->PixelAspectRatio.Y = cp->PictureAspectRatio.Y * cp->OrigWidth; cap_video_reduce_aspect_ratio(&(cp->PixelAspectRatio.X), &(cp->PixelAspectRatio.Y), 255); } return err;}/* Apply video capture options and start the capture */RMstatus cap_video_start_capture( struct cap_video_instance *pVideo){ RMstatus err; struct DCCCaptureProfile cp; RMDBGLOG((FUNCNAME, "%s\n",__func__)); // create capture profile from options err = cap_video_build_profile(pVideo, &cp); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Could not build capture profile: %s\n", RMstatusToString(err))); return err; } // open (and potentially create) video source if (EMHWLIB_MODULE_CATEGORY(pVideo->Setup.InputModuleID) == DispVideoInput) { err = DCCOpenVideoInputSource(pVideo->pDCC, &cp, pVideo->STCTimerNumber, pVideo->Setup.dram, &(pVideo->pVideoSource)); } else if (EMHWLIB_MODULE_CATEGORY(pVideo->Setup.InputModuleID) == DispGraphicInput) { err = DCCOpenGraphicInputSource(pVideo->pDCC, &cp, pVideo->STCTimerNumber, pVideo->Setup.dram, &(pVideo->pVideoSource)); } else if (EMHWLIB_MODULE_CATEGORY(pVideo->Setup.InputModuleID) == DispColorBars) { pVideo->Setup.disablescaler = TRUE; return RM_OK; } else { err = RM_ERROR; } if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Could not open video source: %s\n", RMstatusToString(err))); return err; } // set up input if (EMHWLIB_MODULE_CATEGORY(pVideo->Setup.InputModuleID) == DispGraphicInput) { err = DCCSetupGraphicInput(pVideo->pDCC, pVideo->Setup.TVStandard, pVideo->Setup.DigitalTimingSignal, pVideo->Setup.UseVideoValid, pVideo->Setup.bussize, pVideo->Setup.over_pos_x, pVideo->Setup.over_pos_y, pVideo->Setup.over_width, pVideo->Setup.over_height, pVideo->Setup.DualEdge, pVideo->Setup.DualEdgeWidth, pVideo->Setup.DualEdgeInvert,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -