📄 play_capture_tw.c
字号:
&mode, sizeof(mode), &dig, sizeof(dig)); if RMFAILED(err) { fprintf(stderr, "Could not get format!\n"); return err; } dig_1001 = ( (dig.PixelClock == 25174825) || (dig.PixelClock == 74175824) || (dig.PixelClock == 148351648) || (( (dig.ActiveHeight == 240) || (dig.ActiveHeight == 480) ) && ( (dig.PixelClock == 27000000) || (dig.PixelClock == 54000000) || (dig.PixelClock == 108000000) )) ); // skip X*1000/1001 frame rate modes, capture does not discriminate between those and X*1 modes if (dig_1001) { i++; continue; } dig_Intrl = (dig.TopFieldHeight != 0); if (dig_Intrl) dig.VTotalSize = (dig.VTotalSize + 1) / 2; /*if (mode == EMhwlibTVStandard_HDMI_1080i60) { fprintf(stderr, "1080i60 video format: \nh_res = %lu\nv_res = %lu\nde_pix = %lu\nde_lin = %lu\nvid_vtavl = %lu\nvid_vfp = %lu\nvid_hfp = %lu\nvid_hswidth = %lu\nvid_xpcnt = %lu\nintrl = %u\nvspol = %u\nhspol = %u\n", dig.HTotalSize, dig.VTotalSize, dig.ActiveWidth, dig.ActiveHeight, dig.YOffsetTop, dig.VTotalSize - dig.ActiveHeight - dig.YOffsetTop, dig.HTotalSize - dig.ActiveWidth - dig.XOffset, dig.HSyncWidth, (RMuint32)(28322000LL * 128LL / dig.PixelClock), dig_Intrl, ! dig.VSyncActiveLow, ! dig.HSyncActiveLow);}*/ match = 0; match += comp_weight(h_res, dig.HTotalSize, 20); match += comp_weight(v_res, dig.VTotalSize, 20); match += comp_weight(de_pix, dig.ActiveWidth, 20); match += comp_weight(de_lin, dig.ActiveHeight, 20); //match += comp_weight(vid_vtavl, dig.YOffsetTop, 12); //match += comp_weight(vid_vfp, dig.VTotalSize - dig.ActiveHeight - dig.YOffsetTop, 12); //match += comp_weight(vid_hfp, dig.HTotalSize - dig.ActiveWidth - dig.XOffset, 12); //match += comp_weight(vid_hswidth, dig.HSyncWidth, 12); match += comp_weight(vid_xpcnt, RM64mult32div32(28322000, 128, dig.PixelClock), 20); if (intrl == dig_Intrl) match += 32; if (vspol == ! dig.VSyncActiveLow) match += 20; if (hspol == ! dig.HSyncActiveLow) match += 20; if (match > best_match) { best_match = match; options->TVStandard = mode; //GetTVStandardName(mode, &StandardName); //fprintf(stderr, "%s scores %lu\n", StandardName, match); } i++; } if (options->TVStandard != old) { GetTVStandardName(options->TVStandard, &StandardName); fprintf(stderr, "Detected new mode from timing: %s\n", StandardName); *update = TRUE; } err = read_i2c_data(dcc_info->pRUA, delay, dev + 4, 0x2A, &data[0], 3); if (RMFAILED(err)) return err; err = read_i2c_data(dcc_info->pRUA, delay, dev + 4, 0x30, &data[3], 2); if (RMFAILED(err)) return err; fprintf(stderr, "SiI9031 audio channel status [39:0]: %02X %02X %02X %02X %02X\n", data[4], data[3], data[2], data[1], data[0]); return RM_OK;}// Set up local and capture options (zoom, aspect ratio etc.) based on capture_opt->TVStandardstatic RMstatus setup_format_options( struct dcc_context *dcc_info, struct capture_cmdline *capture_opt, struct display_cmdline *disp_opt, struct local_cmdline *local_opt, RMuint32 input){ struct EMhwlibActiveFormatDescription afd; afd.ActiveFormat = local_opt->active_format; afd.ActiveFormatValid = TRUE; afd.FrameAspectRatio.X = 4; afd.FrameAspectRatio.Y = 3; switch (capture_opt->TVStandard) { case EMhwlibTVStandard_Custom: fprintf(stderr, "No sync or video detected!\n"); break; case EMhwlibTVStandard_ITU_Bt656_525: case EMhwlibTVStandard_ITU_Bt656_240p: { // NTSC only part capture_opt->PixelAspectRatio.X = 8; capture_opt->PixelAspectRatio.Y = 9; if (local_opt->parse_anc) { capture_opt->vbianc_w = 12; capture_opt->vbianc_h = 3; capture_opt->vbianc_ytop = 16; capture_opt->vbianc_ybot = 17; capture_opt->vbianc_enable = TRUE; //capture_opt->vbi_dma = FALSE; fprintf(stderr, "*** NTSC ClosedCaption, setting up capture window w=%lu, h=%lu, ytop=%lu, ybot=%lu ***\n", capture_opt->vbianc_w, capture_opt->vbianc_h, capture_opt->vbianc_ytop, capture_opt->vbianc_ybot); } else { capture_opt->vbianc_enable = FALSE; } // full screen minus top 4 and bottom 3 lines of each frame if (! local_opt->zoom_force) { local_opt->zoom_x = 0; local_opt->zoom_y = 4; // discard top 2 lines of each field, containing VBI data in ITU656-525 mode local_opt->zoom_w = 720; local_opt->zoom_h = 480; // discard bottom 3 lines of each frame to match standard picture size } if (capture_opt->TVStandard == EMhwlibTVStandard_ITU_Bt656_240p) { capture_opt->PixelAspectRatio.Y *= 2; if (! local_opt->zoom_force) { local_opt->zoom_h /= 2; } } } if (0) case EMhwlibTVStandard_ITU_Bt656_625: case EMhwlibTVStandard_ITU_Bt656_288p: { // PAL only part capture_opt->PixelAspectRatio.X = 16; capture_opt->PixelAspectRatio.Y = 15; if (local_opt->parse_anc) { ////////////////////////////////////////////////////////////////////////// capture_opt->vbianc_w = 52;// for SAA if(local_opt->i2c_board==cap_sigma895e1) capture_opt->vbianc_w = 56; //for TW9919 capture_opt->vbianc_h = 18; capture_opt->vbianc_ytop = 5; capture_opt->vbianc_ybot = 5; capture_opt->vbianc_enable = TRUE; //capture_opt->vbi_dma = TRUE; fprintf(stderr, "*** PAL TeleText, setting up capture window w=%lu, h=%lu, ytop=%lu, ybot=%lu ***\n", capture_opt->vbianc_w, capture_opt->vbianc_h, capture_opt->vbianc_ytop, capture_opt->vbianc_ybot); } else { capture_opt->vbianc_enable = FALSE; } // full screen capture if (! local_opt->zoom_force) { local_opt->zoom_x = 0; local_opt->zoom_y = 0; local_opt->zoom_w = 720; local_opt->zoom_h = 576; } if (capture_opt->TVStandard == EMhwlibTVStandard_ITU_Bt656_288p) { capture_opt->PixelAspectRatio.Y *= 2; if (! local_opt->zoom_force) { local_opt->zoom_h /= 2; } } } { // PAL/NTSC common part // disable picture aspect ratio, using pixel aspect ratio capture_opt->PictureAspectRatio.X = 0; capture_opt->PictureAspectRatio.Y = 0; // Set up wide and clipping mode if (local_opt->wide_screen) { // 16:9 output capture_opt->PixelAspectRatio.X *= 4; capture_opt->PixelAspectRatio.Y *= 3; afd.FrameAspectRatio.X *= 4; afd.FrameAspectRatio.Y *= 3; } if (! local_opt->zoom_force) { RMstatus err; struct EMhwlibAspectRatio scaler_ar; RMbool output_variable_ar, variable_output; struct EMhwlibActiveFormatDescription output_afd; RMuint32 w = local_opt->zoom_w, h = local_opt->zoom_h, adj; err = get_scaler_output_aspect_ratio( dcc_info->pRUA, dcc_info->disp_info->osd_scaler[input], (dcc_info->route == DCCRoute_Secondary) ? DispVCRMixer : DispMainMixer, &scaler_ar, &variable_output); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Can not get scaler output aspect ratio! %s\n", RMstatusToString(err))); // fallback, this assumes full screen scaler window. return err; } else { RMDBGLOG((LOCALDBG, "Scaler output aspect ratio: %lu:%lu\n", scaler_ar.X, scaler_ar.Y)); } output_afd.FrameAspectRatio.X = disp_opt->ar_x; output_afd.FrameAspectRatio.Y = disp_opt->ar_y; output_afd.ActiveFormat = disp_opt->active_format; output_afd.ActiveFormatValid = disp_opt->active_format_valid; if (variable_output) { get_output_variable_aspect_ratio(disp_opt->standard, &output_variable_ar); } else { output_variable_ar = FALSE; } apply_active_format_abs( afd, scaler_ar, output_variable_ar, &output_afd, &(local_opt->zoom_x), &(local_opt->zoom_y), &(local_opt->zoom_w), &(local_opt->zoom_h), NULL); // Apply overscan crop, if any if (local_opt->overscan_crop) { adj = w * local_opt->overscan_crop / 200; local_opt->zoom_x += adj; local_opt->zoom_w -= (adj * 2); adj = h * local_opt->overscan_crop / 200; local_opt->zoom_y += adj; local_opt->zoom_h -= (adj * 2); } if (variable_output && ( (output_afd.FrameAspectRatio.X != disp_opt->ar_x) || (output_afd.FrameAspectRatio.Y != disp_opt->ar_y) || (output_afd.ActiveFormatValid && (output_afd.ActiveFormat != disp_opt->active_format)) || (output_afd.ActiveFormatValid != disp_opt->active_format_valid) )) { apply_active_format_output(dcc_info->pRUA, (dcc_info->route == DCCRoute_Secondary) ? DispVCRMixer : DispMainMixer, disp_opt->dh_info->pDH, output_afd); disp_opt->ar_x = output_afd.FrameAspectRatio.X; disp_opt->ar_y = output_afd.FrameAspectRatio.Y; disp_opt->active_format_valid = output_afd.ActiveFormatValid; disp_opt->active_format = output_afd.ActiveFormat; } } } break; default: // other standard, no need to do anything break; } return RM_OK;}static RMstatus get_format_SAA7119( struct dcc_context *dcc_info, struct capture_cmdline *capture_opt, struct local_cmdline *local_opt, RMuint8 dev, RMuint8 delay, RMbool *update){ RMstatus err; RMuint32 reg1e, reg1f; RMbool u = FALSE; enum EMhwlibTVStandard TVStandard; u = FALSE; err = read_i2c(dcc_info->pRUA, delay, dev, 0x1E, ®1e); if (RMFAILED(err)) { fprintf(stderr, "Failed to read status at 0x1E\n"); return err; } err = read_i2c(dcc_info->pRUA, delay, dev, 0x1F, ®1f); if (RMFAILED(err)) { fprintf(stderr, "Failed to read status at 0x1F\n"); return err; } //fprintf(stderr, "SAA7119 Status 1E/1F: %02lX %02lX\n", reg1e, reg1f); // TODO detect HDTV modes if ((reg1f & (1 << 6)) || !(reg1f & (1 << 0))) { // ready to capture?// if (capture_opt->TVStandard != EMhwlibTVStandard_Custom) {// fprintf(stderr, "SAA7119 Status 1E/1F: %02lX %02lX\n", reg1e, reg1f);// fprintf(stderr, "No sync or video detected!\n");// u = TRUE;// }// capture_opt->TVStandard = EMhwlibTVStandard_Custom; } else //if (reg1f & (1 << 7)) { // interlaced if (reg1f & (1 << 5)) { // NTSC 525/59.94 TVStandard = (reg1f & (1 << 7)) ? EMhwlibTVStandard_ITU_Bt656_525 : EMhwlibTVStandard_ITU_Bt656_240p; if (capture_opt->TVStandard != TVStandard) { fprintf(stderr, "SAA7119 Status 1E/1F: %02lX %02lX\n", reg1e, reg1f); fprintf(stderr, "SAA7119: Detected 60Hz %s%s, setting up CC\n", ((reg1e & 3) == 1) ? "NTSC" : ((reg1e & 3) == 2) ? "PAL" : ((reg1e & 3) == 3) ? "SECAM" : "b/w", (reg1f & (1 << 7)) ? "" : " PROGRESSIVE"); if ((reg1e & 3) == 0) return RM_OK; // wait until color capture_opt->TVStandard = TVStandard; u = TRUE; } // read WSS525, set local_opt->wide_screen, local_opt->active_format and u { // TODO: use WSS Fifo to read back changed data from VSync IRQ handler RMuint8 wss_data[7]; RMuint32 wss; RMbool uw = FALSE; RMbool active_format_valid; enum EMhwlibActiveFormat active_format = local_opt->active_format; RMbool wide_screen = local_opt->wide_screen; err = read_i2c_data(dcc_info->pRUA, delay, dev, 0x6B, wss_data, 7); if (RMFAILED(err)) { //fprintf(stderr, "Failed to read WSS data at 0x6B\n"); return err; } //fprintf(stderr, "SAA7119 WSS: %02X %02X %02X %02X %02X %02X %02X\n", // wss_data[0], wss_data[1], wss_data[2], wss_data[3], wss_data[4], wss_data[5], wss_data[6]); if (((wss_data[0] & 0xC0) == 0) && ((wss_data[3] & 0x80) == 0)) { wss = ((wss_data[3] & 0x0F) << 16) | (wss_data[2] << 8) | wss_data[1]; if (local_opt->wss_odd != wss) { fprintf(stderr, "SAA7119 WSS odd: 0x%05lX\n", wss); local_opt->wss_odd = wss; uw = TRUE; } } if (((wss_data[0] & 0x30) == 0) && ((wss_data[6] & 0x80) == 0)) { wss = ((wss_data[6] & 0x0F) << 16) | (wss_data[5] << 8) | wss_data[4]; if (local_opt->wss_even != wss) { fprintf(stderr, "SAA7119 WSS evn: 0x%05lX\n", wss); local_opt->wss_even = wss; /*uw = TRUE;*/ } } if (uw /*&& (local_opt->wss_odd == local_opt->wss_even)*/) { active_format_valid = TRUE; active_format = EMhwlibAF_same_as_picture; wide_screen = FALSE; switch (local_opt->wss_odd & 0x03) { case 0: // NTSC WSS "4:3 frame" fprintf(stderr, "SAA7119 WSS.525: 4:3 Frame, Full Picture\n"); break; case 1: // NTSC WSS "16:9 frame" fprintf(stderr, "SAA7119 WSS.525: 16:9 Frame, Full Picture\n"); wide_screen = TRUE; break; case 2: // NTSC WSS "16:9 in 4:3 frame" fprintf(stderr, "SAA7119 WSS.525: 4:3 Frame, Letterbox 16:9 Picture\n"); active_format = EMhwlibAF_16x9_centered; break; default: active_format_valid = FALSE; break; } if (active_format_valid && (! local_opt->force_active_format) && (local_opt->active_format != active_format)) { fprintf(stderr, "SAA7119 new active format from WSS: %s\n", (active_format == EMhwlibAF_same_as_picture) ? "Full" : "Letterbox"); local_opt->active_format = active_format; u = TRUE; } if (active_format_valid && (! local_opt->force_wide_screen) && (local_opt->wide_screen != wide_screen)) { fprintf(stderr, "SAA7119 new aspect ratio from WSS: %s\n", wide_screen ? "Wide" : "Normal"); local_opt->wide_screen = wide_screen; u = TRUE; } } } } else { // PAL 625/50 TVStandard = (reg1f & (1 << 7)) ? EMhwlibTVStandard_ITU_Bt656_625 : EMhwlibTVStandard_ITU_Bt656_288p; if (capture_opt->TVStandard != TVStandard) { fprintf(stderr, "SAA7119 Status 1E/1F: %02lX %02lX\n", reg1e, reg1f); fprintf(stderr, "SAA7119: Detected 50Hz %s%s, setting up TT\n", ((reg1e & 3) == 1) ? "NTSC" : ((reg1e & 3) == 2) ? "PAL" : ((reg1e & 3) == 3) ? "SECAM" : "b/w", (reg1f & (1 << 7)) ? "" : " PROGRESSIVE"); if ((reg1e & 3) == 0) return RM_OK; // wait until color capture_opt->TVStandard = TVStandard; u = TRUE; } // read WSS, set local_opt->wide_screen, local_opt->active_format and u { // TODO: use WSS Fifo to read back changed data from VSync IRQ handler RMuint8 wss_data[7]; RMuint32 ws
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -