📄 play_spu.c
字号:
*/ *pwLuma = ((index & 0x0f) << 4) | (alpha & 0x0f); index = (index + 1) & 0x0f; if (0 == index) { /* when index rolls over back to 0, up alpha */ alpha = (alpha + 1) & 0x0f; } } RMDBGLOG((NOTICE "unmapping OSD buffer.\n")); RUAUnMap(pdcc_info->pRUA, pLuma, luma_size); RMDBGLOG((NOTICE "unlocking OSD buffer.\n")); status = RUAUnLock(pdcc_info->pRUA, luma_addr, luma_size); if (RMFAILED(status)) { RM_PRINT_ERROR(status, "cannot unlock OSD buffer.\n"); } /* Note: enabling the mixer is an important step in * getting the display. This was not present in the code * Sigma got from Matt Bair at WindRiver. */ RMDBGLOG((NOTICE "enabling mixer.\n")); while (RM_PENDING == (status = RUASetProperty(pdcc_info->pRUA, EMHWLIB_MODULE(DispMainMixer, 0), RMGenericPropertyID_Enable, &enable, sizeof enable, 0))); if (RMFAILED(status)) { RM_PRINT_ERROR(status, "cannot enable mixer.\n"); } else { status = do_set_palette_and_display(pdcc_info); } } } } RMDBGLOG((NOTICE "closing OSD video source.\n")); status = DCCCloseVideoSource(posd_source); if (RMFAILED(status)) { RM_PRINT_ERROR(status, "cannot close OSD video source.\n"); } } return status;}static RMstatus do_set_palette_and_display(struct dcc_context *pdcc_info){ RMstatus status; RMuint32 picture, LumaAddr, LumaSize, ChromaAddr, ChromaSize; //RMuint32 i; RMuint32 scaler = pdcc_info->disp_info->osd_scaler[0]; /* From the EM8622L hardware specification: * "The color index indicates an entry (out of 16) in the sub-picture * look-up table. * The 4 bit alpha value controls the blending between video and sub- * picture pixels, according to the following formula: * Out = video if alpha = 0 * Out = (15 - alpha) * video + (alpha + 1) * subpicture if alpha = 1..15" * * Hence we use a 4bpp palette. * * Furthermore, from the EM8622L hardware specification: * "The LUT block converts the 4 bit color index into a 24 bit color (Cr, Y, Cb)." * * Thus, the value in the LUT are 8 bits of garbage (ignored), followed by 24 bits * of color value, in Cr, Y, Cb order. */ global_palette_info.Palette[0] = 0x00801080; // black global_palette_info.Palette[1] = 0x0080b580; // gray global_palette_info.Palette[2] = 0x00801580; global_palette_info.Palette[3] = 0x0080b580; global_palette_info.Palette[4] = 0x00801580; global_palette_info.Palette[5] = 0x0080b580; global_palette_info.Palette[6] = 0x00801580; global_palette_info.Palette[7] = 0x0080b580; global_palette_info.Palette[8] = 0x00801580; global_palette_info.Palette[9] = 0x0080b580; global_palette_info.Palette[10] = 0x00801580; global_palette_info.Palette[11] = 0x0080b580; global_palette_info.Palette[12] = 0x00801580; global_palette_info.Palette[13] = 0x0080b580; global_palette_info.Palette[14] = 0x00801580; global_palette_info.Palette[15] = 0x0080b580; { struct EMhwlibDisplayWindow window = { .X = 0, .Y = 0, .XPositionMode = EMhwlibDisplayWindowPositionMode_FrontEdgeToBorder, .YPositionMode = EMhwlibDisplayWindowPositionMode_FrontEdgeToBorder, .XMode = EMhwlibDisplayWindowValueMode_Relative, .YMode = EMhwlibDisplayWindowValueMode_Relative, .WidthMode = EMhwlibDisplayWindowValueMode_Relative, .HeightMode = EMhwlibDisplayWindowValueMode_Relative, .Width = 4096, .Height = 4096 }; RMDBGLOG((NOTICE "setting scaler input window.\n")); while (RM_PENDING == (status = RUASetProperty(pdcc_info->pRUA, scaler, RMGenericPropertyID_ScalerInputWindow, &window, sizeof window, 0))); if (RMFAILED(status)) { RM_PRINT_ERROR(status, "cannot set scaler input window.\n"); } else { struct DCCVideoSource *posd_source = pdcc_info->pOSDSource[0]; RMDBGLOG((DEBUG "posd_source = %p.\n", posd_source)); status = DCCGetOSDPictureInfo(posd_source, 0, &(picture), &LumaAddr, &LumaSize, &ChromaAddr, &ChromaSize); if (RMFAILED(status)) { RM_PRINT_ERROR(status, "Cannot get osd buffer info\n"); } else { RMDBGLOG((NOTICE "setting surface source.\n")); status = DCCSetSurfaceSource(pdcc_info->pDCC, scaler, posd_source); if (RMFAILED(status)) { RM_PRINT_ERROR(status, "cannot set surface source.\n"); } else { global_palette_info.PaletteSize = 16*4; global_palette_info.Picture = picture; while (RM_PENDING == (status = RUASetProperty(pdcc_info->pRUA, DisplayBlock, RMDisplayBlockPropertyID_SetPaletteOnPicture, &global_palette_info, sizeof(global_palette_info), 0))); if (RMFAILED(status)) { fprintf(stderr, "cannot set palette 1.\n"); } else { RMDBGLOG((NOTICE "enabling video source.\n")); status = DCCEnableVideoSource(posd_source, TRUE); if (RMFAILED(status)) { RM_PRINT_ERROR(status, "cannot enable video source.\n"); } else { RMDBGLOG((NOTICE "validating scaler.\n")); while (RM_PENDING == (status = RUASetProperty(pdcc_info->pRUA, scaler, RMGenericPropertyID_Validate, NULL, 0, 0))); if (RMFAILED(status)) { RM_PRINT_ERROR(status, "cannot validate scaler.\n"); } else { change_LUT_on_spu_scaler(pdcc_info); status = do_loop_and_handle_keys(pdcc_info); } } } } } } } return status;}static RMstatus change_LUT_on_spu_scaler(struct dcc_context *pdcc_info){ RMstatus status = RM_PENDING; RMpalette_4BPP Clut; Clut[0] = 0x00801080; // black Clut[1] = 0x00f0525a; // red Clut[2] = 0x00229136; // green Clut[3] = 0x0092d210; // yellow Clut[4] = 0x006e29f0; // blue Clut[5] = 0x00de6bca; // purple Clut[6] = 0x0010aaa6; // turq Clut[7] = 0x0080eb80; // white Clut[8] = 0x00c19235; // orange Clut[9] = 0x00e75e92; // hot pink Clut[10] = 0x00199d6e; // l.green Clut[11] = 0x005ab123; // l.green Clut[12] = 0x003f6acb; // l.blue Clut[13] = 0x00a64add; // l.purple Clut[14] = 0x00807e80; // d.grey Clut[15] = 0x0080b580; // l.grey if(memcmp(global_palette_info.Palette, Clut, sizeof(unsigned int) * 16) != 0) { memcpy(global_palette_info.Palette, Clut, sizeof(unsigned int) * 16); while (RM_PENDING == (status = RUASetProperty(pdcc_info->pRUA, DisplayBlock, RMDisplayBlockPropertyID_SetPaletteOnPicture, &global_palette_info, sizeof(global_palette_info), 0))); if (RMFAILED(status)) { fprintf(stderr, "cannot set palette 2.\n"); } } return status;}static RMstatus do_loop_and_handle_keys(struct dcc_context *pdcc_info){ RMstatus status; RMbool done = FALSE; display_key_usage(KEYFLAGS); RMTermInit(TRUE); RMSignalInit(NULL, NULL); do { RMuint32 cmd; status = process_key(pdcc_info, &cmd, KEYFLAGS); if (RMFAILED(status)) { RM_PRINT_ERROR(status, "cannot process key.\n"); break; } switch (cmd) { case RM_QUIT: case RM_STOP: done = TRUE; break; default: usleep(50 * 1000); break; } } while (! done); RMTermExit(); return status;}static RMstatus parse_cmdline(int argc, char **argv){ RMstatus status = RM_OK; int arg_count = 1; if (argc < 1) { show_usage(argv[0]); status = RM_ERROR; } else { while (arg_count < argc) { if (argv[arg_count][0] != '-') { show_usage(argv[0]); status = RM_ERROR; break; } else { status = parse_playback_cmdline(argc, argv, &arg_count, play_opt); if (RM_ERROR == status) { show_usage(argv[0]); break; } if (RM_PENDING != status) { continue; } status = parse_display_cmdline(argc, argv, &arg_count, disp_opt); if (RM_ERROR == status) { show_usage(argv[0]); break; } if (RM_PENDING != status) { continue; } } } } return status;}static void show_usage(char *name){ show_playback_options(); show_display_options(); show_video_options(); fprintf(stderr, "------------------------------------------------------------\n"); fprintf(stderr, "Minimum cmd line: %s\n", name); fprintf(stderr, "------------------------------------------------------------\n");}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -