📄 video.c
字号:
&dig_clk, sizeof(dig_clk)); if RMFAILED(err) {// RMDBGLOG((ENABLE, "Could not get pixel clock for TV Standard %s!\n", StandardName)); RMDBGLOG((ENABLE, "Could not get pixel clock for TV Standard %u!\n", pVideo->Setup.TVStandard)); return err; } curr_HalfLinesPerField = dig.VTotalSize; if (! dig.TopFieldHeight) curr_HalfLinesPerField *= 2; curr_ClocksPerLine = dig.HTotalSize; if (pVideo->Setup.bussize == 8) curr_ClocksPerLine *= 2; curr_ClocksPerField = curr_HalfLinesPerField * curr_ClocksPerLine / 2; if (pVideo->Setup.bussize == 8) dig_clk *= 2; curr_VFreq = (RMuint32)((RMuint64)dig_clk * 100L / curr_ClocksPerField); if (0) RMDBGLOG((LOCALDBG, "Mode: %ld Hz, %ld.%02ld Hz, %ld pix/field, %ld lines/field, %ld pix/line\n", dig_clk, curr_VFreq / 100, curr_VFreq % 100, curr_ClocksPerField, curr_HalfLinesPerField / 2, curr_ClocksPerLine)); diff_VFreq = (VFreq) ? VFreq - curr_VFreq : 0; diff_ClocksPerField = (ClocksPerField) ? ClocksPerField - curr_ClocksPerField : 0; diff_LinesPerField = (LinesPerField) ? LinesPerField - curr_HalfLinesPerField / 2 : 0; diff_ClocksPerLine = (ClocksPerLine) ? ClocksPerLine - curr_ClocksPerLine : 0; error = diff_VFreq * diff_VFreq + diff_ClocksPerField * diff_ClocksPerField + diff_LinesPerField * diff_LinesPerField + diff_ClocksPerLine * diff_ClocksPerLine; if (0) RMDBGLOG((LOCALDBG, "deviation: dist^2: %llu (min = %llu) diff: %s%d.%02d Hz, %ld pix/field, %ld lines/field, %ld pix/line\n", error, min_err, (diff_VFreq < 0) ? "-" : "", RMabs(diff_VFreq) / 100, RMabs(diff_VFreq) % 100, diff_ClocksPerField, diff_LinesPerField / 2, diff_ClocksPerLine)); if (error < min_err) { min_err = error; best_match = pVideo->Setup.TVStandard; } } if (best_match != EMhwlibTVStandard_Custom) { pVideo->Setup.TVStandard = best_match; } else { pVideo->Setup.TVStandard = prevTVStandard; } } return RM_OK;}// corresponding video modes in 50, 59.94, 60, 75 and 85 Hz static const enum EMhwlibTVStandard vfreq_matrix[][5] = { {EMhwlibTVStandard_CVT_640x480x50, EMhwlibTVStandard_Custom, EMhwlibTVStandard_CVT_640x480x60, EMhwlibTVStandard_CVT_640x480x75, EMhwlibTVStandard_CVT_640x480x85}, {EMhwlibTVStandard_CVT_800x600x50, EMhwlibTVStandard_Custom, EMhwlibTVStandard_CVT_800x600x60, EMhwlibTVStandard_CVT_800x600x75, EMhwlibTVStandard_CVT_800x600x85}, {EMhwlibTVStandard_CVT_1024x768x50, EMhwlibTVStandard_Custom, EMhwlibTVStandard_CVT_1024x768x60, EMhwlibTVStandard_CVT_1024x768x75, EMhwlibTVStandard_CVT_1024x768x85}, {EMhwlibTVStandard_CVT_1152x864x50, EMhwlibTVStandard_Custom, EMhwlibTVStandard_CVT_1152x864x60, EMhwlibTVStandard_CVT_1152x864x75, EMhwlibTVStandard_CVT_1152x864x85}, {EMhwlibTVStandard_CVT_1280x960x50, EMhwlibTVStandard_Custom, EMhwlibTVStandard_CVT_1280x960x60, EMhwlibTVStandard_CVT_1280x960x75, EMhwlibTVStandard_CVT_1280x960x85}, {EMhwlibTVStandard_CVT_1280x1024x50, EMhwlibTVStandard_Custom, EMhwlibTVStandard_CVT_1280x1024x60, EMhwlibTVStandard_CVT_1280x1024x75, EMhwlibTVStandard_CVT_1280x1024x85}, {EMhwlibTVStandard_CVT_1600x1200x50, EMhwlibTVStandard_Custom, EMhwlibTVStandard_CVT_1600x1200x60, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_Custom, EMhwlibTVStandard_HDMI_640x480p59, EMhwlibTVStandard_HDMI_640x480p60, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_HDMI_576p50, EMhwlibTVStandard_HDMI_480p59, EMhwlibTVStandard_HDMI_480p60, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_HDMI_720p50, EMhwlibTVStandard_HDMI_720p59, EMhwlibTVStandard_HDMI_720p60, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_HDMI_1080i50, EMhwlibTVStandard_HDMI_1080i59, EMhwlibTVStandard_HDMI_1080i60, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_HDMI_576i50, EMhwlibTVStandard_HDMI_480i59, EMhwlibTVStandard_HDMI_480i60, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_HDMI_288p50, EMhwlibTVStandard_HDMI_240p59, EMhwlibTVStandard_HDMI_240p60, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_HDMI_2880x576i50, EMhwlibTVStandard_HDMI_2880x480i59, EMhwlibTVStandard_HDMI_2880x480i60, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_HDMI_2880x288p50, EMhwlibTVStandard_HDMI_2880x240p59, EMhwlibTVStandard_HDMI_2880x240p60, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_HDMI_1440x576p50, EMhwlibTVStandard_HDMI_1440x480p59, EMhwlibTVStandard_HDMI_1440x480p60, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_HDMI_1080p50, EMhwlibTVStandard_HDMI_1080p59, EMhwlibTVStandard_HDMI_1080p60, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_HDMI_1080p25, EMhwlibTVStandard_HDMI_1080p29, EMhwlibTVStandard_HDMI_1080p30, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_HDMI_2880x576p50, EMhwlibTVStandard_HDMI_2880x480p59, EMhwlibTVStandard_HDMI_2880x480p60, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_HDMI_1080i50_1250, EMhwlibTVStandard_HDMI_1080i59, EMhwlibTVStandard_HDMI_1080i60, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_HDMI_1080i100, EMhwlibTVStandard_HDMI_1080i119, EMhwlibTVStandard_HDMI_1080i120, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_HDMI_720p100, EMhwlibTVStandard_HDMI_720p119, EMhwlibTVStandard_HDMI_720p120, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_HDMI_576p100, EMhwlibTVStandard_HDMI_480p119, EMhwlibTVStandard_HDMI_480p120, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_HDMI_576i100, EMhwlibTVStandard_HDMI_480i119, EMhwlibTVStandard_HDMI_480i120, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_HDMI_576p200, EMhwlibTVStandard_HDMI_480p239, EMhwlibTVStandard_HDMI_480p240, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_HDMI_576i200, EMhwlibTVStandard_HDMI_480i239, EMhwlibTVStandard_HDMI_480i240, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_1080p50, EMhwlibTVStandard_1080p59, EMhwlibTVStandard_1080p60, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_1080i50, EMhwlibTVStandard_1080i59, EMhwlibTVStandard_1080i60, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_1080p25, EMhwlibTVStandard_1080p29, EMhwlibTVStandard_1080p30, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_1080i50_1250, EMhwlibTVStandard_1080i59, EMhwlibTVStandard_1080i60, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_1080p50_1250, EMhwlibTVStandard_1080p59, EMhwlibTVStandard_1080p60, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_720p50, EMhwlibTVStandard_720p59, EMhwlibTVStandard_720p60, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_720p25, EMhwlibTVStandard_720p29, EMhwlibTVStandard_720p30, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_ITU_Bt656_625, EMhwlibTVStandard_ITU_Bt656_525, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_PAL_BG, EMhwlibTVStandard_NTSC_M, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_PAL_BG, EMhwlibTVStandard_NTSC_M_Japan, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_PAL_BG, EMhwlibTVStandard_PAL_M, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_PAL_BG, EMhwlibTVStandard_PAL_60, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_576p50, EMhwlibTVStandard_480p59, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_PAL_BG_702, EMhwlibTVStandard_NTSC_M_714, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_PAL_BG_702, EMhwlibTVStandard_NTSC_M_Japan_714, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_PAL_BG_702, EMhwlibTVStandard_PAL_M_714, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_PAL_BG_702, EMhwlibTVStandard_PAL_60_714, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_576p50_702, EMhwlibTVStandard_480p59_714, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom, EMhwlibTVStandard_VESA_640x350x85}, {EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom, EMhwlibTVStandard_VESA_640x400x85}, {EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom, EMhwlibTVStandard_VESA_720x400x85}, {EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom, EMhwlibTVStandard_VESA_640x480x60, EMhwlibTVStandard_VESA_640x480x75, EMhwlibTVStandard_VESA_640x480x85}, {EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom, EMhwlibTVStandard_VESA_800x600x60, EMhwlibTVStandard_VESA_800x600x75, EMhwlibTVStandard_VESA_800x600x85}, {EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom, EMhwlibTVStandard_VESA_1024x768x60, EMhwlibTVStandard_VESA_1024x768x75, EMhwlibTVStandard_VESA_1024x768x85}, {EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom, EMhwlibTVStandard_VESA_1280x768x60, EMhwlibTVStandard_VESA_1280x768x75, EMhwlibTVStandard_VESA_1280x768x85}, {EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom, EMhwlibTVStandard_VESA_1280x768x60RB, EMhwlibTVStandard_VESA_1280x768x75, EMhwlibTVStandard_VESA_1280x768x85}, {EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom, EMhwlibTVStandard_VESA_1280x960x60, EMhwlibTVStandard_Custom, EMhwlibTVStandard_VESA_1280x960x85}, {EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom, EMhwlibTVStandard_VESA_1280x1024x60, EMhwlibTVStandard_VESA_1280x1024x75, EMhwlibTVStandard_VESA_1280x1024x85}, {EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom, EMhwlibTVStandard_VESA_1360x768x60, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom, EMhwlibTVStandard_VESA_1400x1050x60, EMhwlibTVStandard_VESA_1400x1050x75, EMhwlibTVStandard_VESA_1400x1050x85}, {EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom, EMhwlibTVStandard_VESA_1400x1050x60RB, EMhwlibTVStandard_VESA_1400x1050x75, EMhwlibTVStandard_VESA_1400x1050x85}, {EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom, EMhwlibTVStandard_VESA_1600x1200x60, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom, EMhwlibTVStandard_VESA_1920x1200x60RB, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}, {EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom, EMhwlibTVStandard_VESA_1920x1200x60, EMhwlibTVStandard_Custom, EMhwlibTVStandard_Custom}};// Set up local options (zoom, aspect ratio etc.) based on cap_opt->TVStandardstatic RMstatus cap_video_setup_format( struct cap_video_instance *pVideo){// RMstatus err; struct EMhwlibActiveFormatDescription afd; RMDBGLOG((FUNCNAME, "%s\n",__func__)); afd.ActiveFormat = EMhwlibAF_same_as_picture; afd.ActiveFormatValid = TRUE; afd.FrameAspectRatio.X = 4; afd.FrameAspectRatio.Y = 3; switch (pVideo->Setup.TVStandard) { case EMhwlibTVStandard_Custom: RMDBGLOG((ENABLE, "No sync or video detected!\n")); break; case EMhwlibTVStandard_ITU_Bt656_525: case EMhwlibTVStandard_ITU_Bt656_240p: { // NTSC only part pVideo->Setup.PixelAspectRatio.X = 8; pVideo->Setup.PixelAspectRatio.Y = 9; // full screen minus top 4 and bottom 3 lines of each frame if (! pVideo->Setup.zoom_force) { pVideo->Setup.zoom_x = 0; pVideo->Setup.zoom_y = 4; // discard top 2 lines of each field, containing VBI data in ITU656-525 mode pVideo->Setup.zoom_w = 720; pVideo->Setup.zoom_h = 480; // discard bottom 3 lines of each frame to match standard picture size } if (pVideo->Setup.TVStandard == EMhwlibTVStandard_ITU_Bt656_240p) { pVideo->Setup.PixelAspectRatio.Y *= 2; if (! pVideo->Setup.zoom_force) { pVideo->Setup.zoom_h /= 2; } } } if (0) case EMhwlibTVStandard_ITU_Bt656_625: case EMhwlibTVStandard_ITU_Bt656_288p: { // PAL only part pVideo->Setup.PixelAspectRatio.X = 16; pVideo->Setup.PixelAspectRatio.Y = 15; // full screen capture if (! pVideo->Setup.zoom_force) { pVideo->Setup.zoom_x = 0; pVideo->Setup.zoom_y = 0; pVideo->Setup.zoom_w = 720; pVideo->Setup.zoom_h = 576; } if (pVideo->Setup.TVStandard == EMhwlibTVStandard_ITU_Bt656_288p) { pVideo->Setup.PixelAspectRatio.Y *= 2; if (! pVideo->Setup.zoom_force) { pVideo->Setup.zoom_h /= 2; } } } { // PAL/NTSC common part // disable picture aspect ratio, using pixel aspect ratio pVideo->Setup.PictureAspectRatio.X = 0; pVideo->Setup.PictureAspectRatio.Y = 0; // Set up wide and clipping mode if (0/*TODO pVideo->Setup.wide_screen*/) { // 16:9 output pVideo->Setup.PixelAspectRatio.X *= 4; pVideo->Setup.PixelAspectRatio.Y *= 3; afd.FrameAspectRatio.X *= 4; afd.FrameAspectRatio.Y *= 3; }//TODO!!! err = apply_active_format(pVideo->pRUA, NULL/*pVideo->disp_opt*/, afd, pVideo->ScalerModuleID);// This AFD needs to be reported back to the application } break; default: // other standard, no need to do anything break; } return RM_OK;}/* Apply video capture options and start the passthrough to the current output */RMstatus cap_video_start_passthrough( struct cap_video_instance *pVideo){ RMstatus err; RMDBGLOG((FUNCNAME, "%s\n",__func__)); err = cap_video_setup_format(pVideo); err = cap_video_start_capture(pVideo); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Failed to set up capture port! %s\n", RMstatusToString(err))); if (err == RM_FATALOUTOFMEMORY) { RMDBGLOG((ENABLE, "Can not set up capture picture buffer, OUT OF MEMORY!\n")); } return err; } // Modify output video mode// This output VFreq selection needs to be done in main application. Just report back current input VFreq./*TODO if (pVideo->Setup.follow_vfreq && pVideo->disp_opt) { RMbool change_output = FALSE; RMuint32 in_vfreq = 0, in_row = 0, out_vfreq = 0, out_row = 0, i; // find input v-freq for (i = 0; i < sizeof(vfreq_matrix) / sizeof(enum EMhwlibTVStandard); i++) { if (pVideo->Setup.TVStandard == vfreq_matrix[i / 5][i % 5]) { in_vfreq = (i % 5) + 1; in_row = i / 5; break; } } // find current output v-freq for (i = 0; i < sizeof(vfreq_matrix) / sizeof(enum EMhwlibTVStandard); i++) { if (pVideo->disp_opt->standard == vfreq_matrix[i / 5][i % 5]) { out_vfreq = (i % 5) + 1; out_row = i / 5; break; } } // 50Hz capture on non-50Hz output if ((in_vfreq == 1) && out_vfreq && (out_vfreq != 1)) { RMDBGLOG((ENABLE, "Input is 50Hz\n")); if (vfreq_matrix[out_row][0] != EMhwlibTVStandard_Custom) { RMDBGLOG((ENABLE, "Changing output to 50Hz\n")); pVideo->disp_opt->standard = vfreq_matrix[out_row][0]; change_output = TRUE; } } else // 59.94Hz capture on non-59.94Hz output if ((in_vfreq == 2) && out_vfreq && (out_vfreq != 2)) { RMDBGLOG((ENABLE, "Input is 59.94Hz\n")); if (vfreq_matrix[out_row][1] != EMhwlibTVStandard_Custom) { RMDBGLOG((ENABLE, "Changing output to 59.94Hz\n")); pVideo->disp_opt->standard = vfreq_matrix[out_row][1]; change_output = TRUE; } else // 60Hz as second choice if (vfreq_matrix[out_row][2] != EMhwlibTVStandard_Custom) { RMDBGLOG((ENABLE, "Changing output to 60Hz\n")); pVideo->disp_opt->standard = vfreq_matrix[out_row][2]; change_output = TRUE; } } else // 60Hz capture on non-60Hz output if ((in_vfreq == 3) && out_vfreq && (out_vfreq != 3)) { RMDBGLOG((ENABLE, "Input is 60Hz\n")); if (vfreq_matrix[out_row][2] != EMhwlibTVStandard_Custom) { RMDBGLOG((ENABLE, "Changing output to 60Hz\n")); pVideo->disp_opt->standard = vfreq_matrix[out_row][2]; change_output = TRUE; } else // 59.94Hz as second choice if (vfreq_matrix[out_row][1] != EMhwlibTVStandard_Custom) { RMDBGLOG((ENABLE, "Changing output to 59.94Hz\n")); pVideo->disp_opt->standard = vfreq_matrix[out_row][1]; change_output = TRUE; } } else { RMDBGLOG((ENABLE, "Input vfreq is unknown\n")); } if (change_output) { err = apply_display_options(pVideo->dcc_info, pVideo->disp_opt); } }*/ err = cap_video_set_scaler_source_zoom(pVideo->pRUA, pVideo->ScalerModuleID, pVideo->Setup.zoom_x, pVideo->Setup.zoom_y, pVideo->Setup.zoom_w, pVideo->Setup.zoom_h); return RM_OK;}/* stop capture and passthrough */RMstatus cap_video_stop_passthrough( struct cap_video_instance *pVideo){ return cap_video_stop_capture(pVideo);}/* flush the current picture off the screen */RMstatus cap_video_flush_scaler( struct cap_video_instance *pVideo){ RMstatus err; RMDBGLOG((ENABLE, "flushing scaler\n")); err = RUASetProperty(pVideo->pRUA, pVideo->ScalerModuleID, RMGenericPropertyID_Stop, NULL, 0, 0); if RMFAILED(err) RMDBGLOG((ENABLE, "Error flushing scaler, err=%s\n", RMstatusToString(err))); return err;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -