Camera::Camera() { SetFOV(0.0f); SetAspectRatio(0.0f); SetLookAtTarget(XMFLOAT4(0.0f, 0.0f, 0.0f, 1.0f)); SetPosition(XMFLOAT4(0.0f, 0.0f, 0.0f, 1.0f)); SetUpVector(XMFLOAT4(0.0f, 1.0f, 0.0f, 1.0f)); }
DisplayResScreen::DisplayResScreen(int w, int h, int mw, int mh, const std::vector<double>& rr, const std::map<double, short>& rr2) : realRates(rr2), width(w), height(h), width_mm(mw), height_mm(mh), refreshRates(rr), custom(true) { SetAspectRatio(-1.0); }
DisplayResScreen::DisplayResScreen(int w, int h, int mw, int mh, double aspectRatio, double refreshRate) : width(w), height(h), width_mm(mw), height_mm(mh), custom(false) { SetAspectRatio(aspectRatio); if (refreshRate > 0) refreshRates.push_back(refreshRate); }
DisplayResScreen::DisplayResScreen(int w, int h, int mw, int mh, const short* rr, uint rr_length) : width(w), height(h), width_mm(mw), height_mm(mh), custom(false) { SetAspectRatio(-1.0); for (uint i = 0; i < rr_length; ++i) refreshRates.push_back((double)rr[i]); std::sort(refreshRates.begin(), refreshRates.end()); }
void Camera::SetAspectRatio(unsigned width, unsigned height) { if (viewWidth_ != width || viewHeight_ != height) { viewWidth_ = width; viewHeight_ = height; SetAspectRatio(CalculateAspectRatio()); } }
void Camera::SetSensorFit(CameraSensorFit sensorFit) { if (sensorFit != sensorFit_) { sensorFit_ = sensorFit; SetAspectRatio(CalculateAspectRatio()); isDirty_ = true; } }
void Camera::SetWindow(Window* window) { if (window_ != window) { window_ = window; if (window) { SetAspectRatio(window->GetWidth(), window->GetHeight()); slotViewChanged_ = window->SigSizeChanged()->Connect([this](int width, int height) { if (autoAspectRatio_) SetAspectRatio(width, height); }); } else { slotViewChanged_ = nullptr; SetAspectRatio(1); } } }
void Camera::ReadXMLInfo(const XMLNode *xmlInfo) { Component::ReadXMLInfo(xmlInfo); SetClearColor(xmlInfo->GetColor("ClearColor")); SetFovDegrees(xmlInfo->GetFloat("FOVDegrees")); SetZNear(xmlInfo->GetFloat("ZNear")); SetZFar(xmlInfo->GetFloat("ZFar")); ProjectionMode pm = ProjectionMode_FromString(xmlInfo->GetEnumSelectedName("ProjectionMode")); SetProjectionMode(pm); SetAspectRatio( xmlInfo->GetFloat("AspectRatio") ); SetOrthoHeight( xmlInfo->GetFloat("OrthoHeight") ); }
void Renderer::Advance(double dt) { // Update RenderParams auto lens = m_scene->GetComponentForEntity<PerspectiveLens>(m_camera); IWindow& window = m_scene->GetWindow(); ivec2 windowSize = window.GetWindowSize(); lens->SetAspectRatio((float)windowSize.x / windowSize.y); bento::RenderParams::SetBackBufferDimensions(windowSize.x, windowSize.y); auto cameraTransform = m_scene->GetComponentForEntity<Transform>(m_camera); bento::RenderParams::SetViewMatrices(cameraTransform->matrix, *lens); godBox::RenderParams::SetRenderTarget(m_renderTarget); m_renderTarget.SetSize(windowSize.x, windowSize.y); // Setup some default render states glViewport(0, 0, windowSize.x, windowSize.y); m_renderTarget.Clear(); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); glDisable(GL_BLEND); // Forward Phase m_renderTarget.BindForForwardPhase(); glEnable(GL_DEPTH_TEST); glDepthMask(GL_TRUE); glDepthFunc(GL_LESS); RenderPassesInPhase(eRenderPhase_Forward, dt); // Copy the current forward buffer over to the 'post transparent' buffer. // If we dont do this, only fragments touched by a transparent shader will appear in the final output. m_renderTarget.BindForTransparentPhase(); glDisable(GL_DEPTH_TEST); glDepthMask(GL_FALSE); m_rectTextureToScreenShader.Render(m_renderTarget.ColorTexture()); // Transparent Phase glEnable(GL_DEPTH_TEST); glDepthMask(GL_TRUE); RenderPassesInPhase(eRenderPhase_Transparent, dt); // Switch draw target to back buffer glViewport(0, 0, windowSize.x, windowSize.y); glDepthMask(GL_TRUE); glDisable(GL_DEPTH_TEST); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, GL_NONE); glEnable( GL_FRAMEBUFFER_SRGB ); m_rectTextureToScreenShader.Render(m_renderTarget.ColorPostTransparencyTexture()); glDisable(GL_FRAMEBUFFER_SRGB); // UI Phase RenderPassesInPhase(eRenderPhase_UI, dt); }
void PS3Graphics::Init() { PSGLInitDevice(NULL, m_pal60Hz); int32_t ret = PSGLInit(); if (ret == CELL_OK) { SetResolution(); } GetAllAvailableResolutions(); // TODO : Initially set to false. This will be overridden later SetAspectRatio(false); }
void CImgStatic::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { // Check if image data is loaded if (m_bImageLoaded) { RECT rc; GetClientRect(&rc); if (m_bUseScrollBars) { UINT uiHHeight = GetSystemMetrics(SM_CYHSCROLL); UINT uiVWidth = GetSystemMetrics(SM_CXVSCROLL); CRect rectH, rectV; rectH = rc; rectH.top = rectH.bottom - uiHHeight; rectH.right -= uiVWidth; rectV = rc; rectV.left = rectV.right - uiVWidth; rectV.bottom -= uiHHeight; m_HScroll.MoveWindow(rectH); m_VScroll.MoveWindow(rectV); } // Get Gdiplus graphics object Gdiplus::Graphics grp(lpDrawItemStruct->hDC); // Get image Gdiplus::Image image(m_pStream); // Adjust for aspect ratio SetAspectRatio(image, rc); if (m_iZoomFactor == 10) { // Draw it grp.DrawImage(&image, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top); } else { Gdiplus::Rect rcDest(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top); int srcx, srcy, srcwidth, srcheight; srcx = (int)(image.GetWidth() * ((float)m_iHPos / 100.0)); srcy = (int)(image.GetHeight() * ((float)m_iVPos / 100.0)); srcwidth = (int)(image.GetWidth() / ((float)m_iZoomFactor / 10.0)); srcheight = (int)(image.GetHeight() / ((float)m_iZoomFactor / 10.0)); grp.DrawImage(&image, rcDest, srcx, srcy, srcwidth, srcheight, Gdiplus::UnitPixel); } } }
void FceuGraphics::Init(uint32_t resId) { LOG_DBG("FceuGraphics::Init(%d)\n", resId); PSGLGraphics::Init(resId, m_pal60Hz); PSGLInit(); SetDimensions(240, 256 * 4); Rect r; r.x = 0; r.y = 0; r.w = 256; r.h = 240; SetRect(r); SetAspectRatio(m_ratio); }
CSettingsSA::CSettingsSA ( void ) { m_pInterface = (CSettingsSAInterface *)CLASS_CMenuManager; m_pInterface->bFrameLimiter = false; m_bVolumetricShadowsEnabled = false; m_bVolumetricShadowsSuspended = false; SetAspectRatio ( ASPECT_RATIO_4_3 ); HookInstall ( HOOKPOS_GetFxQuality, (DWORD)HOOK_GetFxQuality, 5 ); HookInstall ( HOOKPOS_StoreShadowForVehicle, (DWORD)HOOK_StoreShadowForVehicle, 9 ); m_iDesktopWidth = 0; m_iDesktopHeight = 0; MemPut < BYTE > ( 0x6FF420, 0xC3 ); // Truncate CalculateAspectRatio // Set "radar map and radar" as default radar mode SetRadarMode ( RADAR_MODE_ALL ); }
void CryVR_WiimoteManagerPlugin::Init( bool ir_pos, bool motion, int v_time, float v_angle, int v_threshold, int bts, bool aspect, int irlevel ) { bt = bts; Init(); SetIrPosition( ir_pos ); SetAspectRatio( aspect ); SetIRSensivity( irlevel ); //SetMotionSensing(motion); SetMotionSensing( false ); SetAccelThreshold( v_threshold, v_angle ); //10 : events : <10 //1 : events : >80 //5 : events : ~40 max //7 : events : <10 //3 : events : ~60 SetTimeout( timeout ); //20,20 : events : <10 , 0 si un bouton appuyé }
int32_t FceuGraphics::ChangeResolution(uint32_t resId, uint16_t pal60Hz) { LOG_DBG("SNES9xGraphics::ChangeResolution(%d, %d)\n", resId, pal60Hz); int32_t ret; PSGLGraphics::DeinitDbgFont(); Deinit(); PSGLGraphics::Init(resId, pal60Hz); PSGLInit(); SetDimensions(240, 256 * 4); Rect r; r.x = 0; r.y = 0; r.w = 256; r.h = 240; SetRect(r); SetAspectRatio(m_ratio); PSGLGraphics::InitDbgFont(); PSGLGraphics::SetResolution(); }
int GLinitialize() { glViewport(rRatioRect.left, // init viewport by ratio rect iResY-(rRatioRect.top+rRatioRect.bottom), rRatioRect.right, rRatioRect.bottom); glScissor(0, 0, iResX, iResY); // init clipping (fullscreen) glEnable(GL_SCISSOR_TEST); #ifndef OWNSCALE glMatrixMode(GL_TEXTURE); // init psx tex sow and tow if not "ownscale" glLoadIdentity(); glScalef(1.0f/255.99f,1.0f/255.99f,1.0f); // geforce precision hack #endif glMatrixMode(GL_PROJECTION); // init projection with psx resolution glLoadIdentity(); glOrtho(0,PSXDisplay.DisplayMode.x, PSXDisplay.DisplayMode.y, 0, -1, 1); if(iZBufferDepth) // zbuffer? { uiBufferBits=GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT; glEnable(GL_DEPTH_TEST); glDepthFunc(GL_ALWAYS); iDepthFunc=1; } else // no zbuffer? { uiBufferBits=GL_COLOR_BUFFER_BIT; glDisable(GL_DEPTH_TEST); } glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // first buffer clear glClear(uiBufferBits); if(bUseLines) // funny lines { glPolygonMode(GL_FRONT, GL_LINE); glPolygonMode(GL_BACK, GL_LINE); } else // or the real filled thing { glPolygonMode(GL_FRONT, GL_FILL); glPolygonMode(GL_BACK, GL_FILL); } MakeDisplayLists(); // lists for menu/opaque GetExtInfos(); // get ext infos SetExtGLFuncs(); // init all kind of stuff (tex function pointers) glEnable(GL_ALPHA_TEST); // wanna alpha test if(!bUseAntiAlias) // no anti-alias (default) { glDisable(GL_LINE_SMOOTH); glDisable(GL_POLYGON_SMOOTH); glDisable(GL_POINT_SMOOTH); } else // wanna try it? glitches galore... { glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST); glEnable(GL_LINE_SMOOTH); glEnable(GL_POLYGON_SMOOTH); glEnable(GL_POINT_SMOOTH); glHint(GL_LINE_SMOOTH_HINT,GL_NICEST); glHint(GL_POINT_SMOOTH_HINT,GL_NICEST); glHint(GL_POLYGON_SMOOTH_HINT,GL_NICEST); } ubGloAlpha=127; // init some drawing vars ubGloColAlpha=127; TWin.UScaleFactor = 1; TWin.VScaleFactor = 1; bDrawMultiPass=FALSE; bTexEnabled=FALSE; bUsingTWin=FALSE; if(bDrawDither) glEnable(GL_DITHER); // dither mode else glDisable(GL_DITHER); glDisable(GL_FOG); // turn all (currently) unused modes off glDisable(GL_LIGHTING); glDisable(GL_LOGIC_OP); glDisable(GL_STENCIL_TEST); glDisable(GL_TEXTURE_1D); glDisable(GL_TEXTURE_2D); glDisable(GL_CULL_FACE); glPixelTransferi(GL_RED_SCALE, 1); // to be sure: glPixelTransferi(GL_RED_BIAS, 0); // init more OGL vals glPixelTransferi(GL_GREEN_SCALE, 1); glPixelTransferi(GL_GREEN_BIAS, 0); glPixelTransferi(GL_BLUE_SCALE, 1); glPixelTransferi(GL_BLUE_BIAS, 0); glPixelTransferi(GL_ALPHA_SCALE, 1); glPixelTransferi(GL_ALPHA_BIAS, 0); printf(glGetString(GL_VENDOR)); // linux: tell user what is getting used printf("\n"); printf(glGetString(GL_RENDERER)); printf("\n"); glFlush(); // we are done... glFinish(); CreateScanLines(); // setup scanline stuff (if wanted) CheckTextureMemory(); // check available tex memory if(bKeepRatio) SetAspectRatio(); // set ratio if(iShowFPS) // user wants FPS display on startup? { ulKeybits|=KEY_SHOWFPS; // -> ok, turn display on szDispBuf[0]=0; BuildDispMenu(0); } bIsFirstFrame = FALSE; // we have survived the first frame :) return 0; }
void FrameMain::OnSubtitlesOpen() { UpdateTitle(); auto vc = context->videoController; /// @todo figure out how to move this to the relevant controllers without /// prompting for each file loaded/unloaded // Load stuff from the new script auto video = config::path->MakeAbsolute(context->ass->GetScriptInfo("Video File"), "?script"); auto vfr = config::path->MakeAbsolute(context->ass->GetScriptInfo("VFR File"), "?script"); auto keyframes = config::path->MakeAbsolute(context->ass->GetScriptInfo("Keyframes File"), "?script"); auto audio = config::path->MakeAbsolute(context->ass->GetScriptInfo("Audio URI"), "?script"); bool videoChanged = !blockVideoLoad && video != vc->GetVideoName(); bool timecodesChanged = vfr != vc->GetTimecodesName(); bool keyframesChanged = keyframes != vc->GetKeyFramesName(); bool audioChanged = !blockAudioLoad && audio != context->audioController->GetAudioURL(); // Check if there is anything to change int autoLoadMode = OPT_GET("App/Auto/Load Linked Files")->GetInt(); if (autoLoadMode == 0 || (!videoChanged && !timecodesChanged && !keyframesChanged && !audioChanged)) { SetDisplayMode(1, 1); return; } if (autoLoadMode == 2) { if (wxMessageBox(_("Do you want to load/unload the associated files?"), _("(Un)Load files?"), wxYES_NO | wxCENTRE, this) != wxYES) { SetDisplayMode(1, 1); if (vc->IsLoaded() && vc->GetProvider()->GetColorSpace() != context->ass->GetScriptInfo("YCbCr Matrix")) vc->Reload(); return; } } if (audioChanged) blockAudioLoad = true; // Video if (videoChanged) { vc->SetVideo(video); if (vc->IsLoaded()) { vc->JumpToFrame(context->ass->GetUIStateAsInt("Video Position")); std::string arString = context->ass->GetUIState("Video Aspect Ratio"); if (boost::starts_with(arString, "c")) { double ar = 0.; agi::util::try_parse(arString.substr(1), &ar); vc->SetAspectRatio(ar); } else { int ar = 0; if (agi::util::try_parse(arString, &ar) && ar >= 0 && ar < 4) vc->SetAspectRatio((AspectRatio)ar); } double videoZoom = 0.; if (agi::util::try_parse(context->ass->GetUIState("Video Zoom Percent"), &videoZoom)) context->videoDisplay->SetZoom(videoZoom); } } else if (vc->IsLoaded() && vc->GetProvider()->GetColorSpace() != context->ass->GetScriptInfo("YCbCr Matrix")) vc->Reload(); vc->LoadTimecodes(vfr); vc->LoadKeyframes(keyframes); // Audio if (audioChanged) { blockAudioLoad = false; try { if (audio.empty()) context->audioController->CloseAudio(); else context->audioController->OpenAudio(audio); } catch (agi::UserCancelException const&) { } catch (agi::fs::FileSystemError const& err) { wxMessageBox(to_wx(err.GetMessage()), "Error opening audio", wxOK | wxICON_ERROR | wxCENTER, this); } } SetDisplayMode(1, 1); }
void Project::LoadUnloadFiles(ProjectProperties properties) { auto load_linked = OPT_GET("App/Auto/Load Linked Files")->GetInt(); if (!load_linked) return; auto audio = context->path->MakeAbsolute(properties.audio_file, "?script"); auto video = context->path->MakeAbsolute(properties.video_file, "?script"); auto timecodes = context->path->MakeAbsolute(properties.timecodes_file, "?script"); auto keyframes = context->path->MakeAbsolute(properties.keyframes_file, "?script"); if (video == video_file && audio == audio_file && keyframes == keyframes_file && timecodes == timecodes_file) return; if (load_linked == 2) { wxString str = _("Do you want to load/unload the associated files?"); str += "\n"; auto append_file = [&](agi::fs::path const& p, wxString const& unload, wxString const& load) { if (p.empty()) str += "\n" + unload; else str += "\n" + agi::wxformat(load, p); }; if (audio != audio_file) append_file(audio, _("Unload audio"), _("Load audio file: %s")); if (video != video_file) append_file(video, _("Unload video"), _("Load video file: %s")); if (timecodes != timecodes_file) append_file(timecodes, _("Unload timecodes"), _("Load timecodes file: %s")); if (keyframes != keyframes_file) append_file(keyframes, _("Unload keyframes"), _("Load keyframes file: %s")); if (wxMessageBox(str, _("(Un)Load files?"), wxYES_NO | wxCENTRE, context->parent) != wxYES) return; } bool loaded_video = false; if (video != video_file) { if (video.empty()) CloseVideo(); else if ((loaded_video = DoLoadVideo(video))) { auto vc = context->videoController.get(); vc->JumpToFrame(properties.video_position); auto ar_mode = static_cast<AspectRatio>(properties.ar_mode); if (ar_mode == AspectRatio::Custom) vc->SetAspectRatio(properties.ar_value); else vc->SetAspectRatio(ar_mode); context->videoDisplay->SetZoom(properties.video_zoom); } } if (!timecodes.empty()) LoadTimecodes(timecodes); if (!keyframes.empty()) LoadKeyframes(keyframes); if (audio != audio_file) { if (audio.empty()) CloseAudio(); else DoLoadAudio(audio, false); } else if (loaded_video && OPT_GET("Video/Open Audio")->GetBool() && audio_file != video_file && video_provider->HasAudio()) DoLoadAudio(video, true); }
int GLinitialize() { //----------------------------------------------------// #ifdef _WINDOWS HGLRC objectRC; // init dcGlobal = GetDC(hWWindow); // FIRST: dc/rc stuff objectRC = wglCreateContext(dcGlobal); GLCONTEXT=objectRC; wglMakeCurrent(dcGlobal, objectRC); // CheckWGLExtensions(dcGlobal); if(bWindowMode) ReleaseDC(hWWindow,dcGlobal); // win mode: release dc again #endif #ifdef MAEMO_CHANGES maemoGLinit(); #endif //----------------------------------------------------// glViewport(rRatioRect.left, // init viewport by ratio rect iResY-(rRatioRect.top+rRatioRect.bottom), rRatioRect.right, rRatioRect.bottom); glScissor(0, 0, iResX, iResY); // init clipping (fullscreen) glEnable(GL_SCISSOR_TEST); #ifndef OWNSCALE glMatrixMode(GL_TEXTURE); // init psx tex sow and tow if not "ownscale" glLoadIdentity(); glScalef(1.0f/255.99f,1.0f/255.99f,1.0f); // geforce precision hack #endif glMatrixMode(GL_PROJECTION); // init projection with psx resolution glLoadIdentity(); glOrtho(0,PSXDisplay.DisplayMode.x, PSXDisplay.DisplayMode.y, 0, -1, 1); if(iZBufferDepth) // zbuffer? { uiBufferBits=GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT; glEnable(GL_DEPTH_TEST); glDepthFunc(GL_ALWAYS); iDepthFunc=1; } else // no zbuffer? { uiBufferBits=GL_COLOR_BUFFER_BIT; glDisable(GL_DEPTH_TEST); } glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // first buffer clear glClear(uiBufferBits); GetExtInfos(); // get ext infos SetExtGLFuncs(); // init all kind of stuff (tex function pointers) glEnable(GL_ALPHA_TEST); // wanna alpha test { glDisable(GL_LINE_SMOOTH); glDisable(GL_POINT_SMOOTH); } ubGloAlpha=127; // init some drawing vars ubGloColAlpha=127; TWin.UScaleFactor = 1; TWin.VScaleFactor = 1; bDrawMultiPass=FALSE; bTexEnabled=FALSE; bUsingTWin=FALSE; if(bDrawDither) glEnable(GL_DITHER); // dither mode else glDisable(GL_DITHER); glDisable(GL_FOG); // turn all (currently) unused modes off glDisable(GL_LIGHTING); glDisable(GL_STENCIL_TEST); glDisable(GL_TEXTURE_2D); glDisable(GL_CULL_FACE); glFlush(); // we are done... glFinish(); CreateScanLines(); // setup scanline stuff (if wanted) CheckTextureMemory(); // check available tex memory if(bKeepRatio) SetAspectRatio(); // set ratio bIsFirstFrame = FALSE; // we have survived the first frame :) return 0; }
void Ys3DDrawingEnvironment::UpdateAspectRatio(void) { SetAspectRatio((double)viewport[2]/(double)viewport[3]); }
void Camera::SetAspectRatio(unsigned int width, unsigned int height) { double ratio = static_cast<double>(width) / static_cast<double>(height); SetAspectRatio(ratio); }
/****************************************************************************** 解码一帧 ******************************************************************************/ SINT32 iMediaSoftDEC_Decode(iMediaSDEC_CTX_S *pCtx, DEC_STREAM_PACKET_S *pPacket) { UINT32 i; SINT32 s32Ret; STRU_IVIDDEC_STREAM stStream; STRU_IVIDDEC_OUT_ARGS stDecOutArgs; STRU_IVIDEO_PICTURE *pstPic; IMAGE *pstImg; UINT8 *pu8Luma; UINT8 *pu8Chrom; UINT32 u32AspectRatio = 0; // aspect_ratio UINT32 u32FldFirst = 0; // 场序: 0=top first, 1=bottom first UINT32 u32SrcFmt = 0; // 逐行/隔行: 0=progressive, 1=interlaced UINT32 u32VideoFmt = 1; // 制式: 1=pal, 2=ntsc UINT32 u32CodType = 0; // 帧类型: 0=I, 1=P, 2=B /*UINT32 time1, time2, time3; UINT32 hit0,hit1, req0, req1;; */ static UINT32 *p1 = 0; static UINT32 last_image_id = -1; if (1 == pPacket->StreamPack[0].IsStreamEnd) { if (last_image_id >= 0 && last_image_id < iMediaSDEC_MAX_IMAGE_NUM) { (pVfmwToSvdecFun->pfnVfmwLastFrameNotify)(pCtx->ChanID, last_image_id); last_image_id = -1; } return iMediaSDEC_NOT_DEC; } /* y00226912 双核情况下,不断报警,暂时去掉不影响解码(修正?) if (p1 == 0) { MEM_RECORD_S MemRec; (pVfmwToSvdecFun->pfnVfmwMemMapRegisterAddr)(0x16800600, 0x400, &MemRec); // 查看L2 cache命中率 // MEM_MapRegisterAddr(0x16800600, 0x400, &MemRec); // 查看L2 cache命中率 p1 = (UINT32*)MemRec.VirAddr; } */ /* 解码输入参数 */ stStream.pucBuf = pPacket->StreamPack[0].VirAddr; stStream.uiNumBytes = pPacket->StreamPack[0].LenInByte; stStream.iPTS = (UINT32)pPacket->StreamPack[0].Pts; /* 调用iMedia库解码一帧码流 */ memset(&stDecOutArgs, 0, sizeof(stDecOutArgs)); s32Ret = IMedia_Viddec_FrameDecode(pCtx->CodecInstHandle, &stStream, &stDecOutArgs); #if 0 printk("IMedia_Viddec_FrameDecode return %d\n", s32Ret); printk("decode image properties:\n"); printk("%-20s :%d\n", "iErrorCode", stDecOutArgs.iErrorCode); printk("%-20s :%d\n", "uiBytesConsumed", stDecOutArgs.uiBytesConsumed); printk("%-20s :%d\n", "uiDisplayID", stDecOutArgs.uiDisplayID); printk("%-20s :%d\n", "iPTS", stDecOutArgs.iPTS); printk("%-20s :%d\n", "bLastFrameFlag", stDecOutArgs.bLastFrameFlag); printk("%-20s :%d\n", "usWidth", stDecOutArgs.stPicture.usWidth); printk("%-20s :%d\n", "usHeight", stDecOutArgs.stPicture.usHeight); printk("%-20s :%d\n", "usWidthPitch", stDecOutArgs.stPicture.usWidthPitch); printk("%-20s :%d\n", "eContentType", stDecOutArgs.stPicture.eContentType); printk("%-20s :%p\n", "y addr", stDecOutArgs.stPicture.apucBuf[0]); printk("%-20s :%p\n", "u addr", stDecOutArgs.stPicture.apucBuf[1]); printk("%-20s :%p\n", "v addr", stDecOutArgs.stPicture.apucBuf[2]); if (stDecOutArgs.stPicture.apucBuf[0] && stDecOutArgs.stPicture.apucBuf[1] && stDecOutArgs.stPicture.apucBuf[2]) { SaveYUV(stDecOutArgs.stPicture.usWidth, stDecOutArgs.stPicture.usHeight, stDecOutArgs.stPicture.apucBuf[0], stDecOutArgs.stPicture.apucBuf[1], stDecOutArgs.stPicture.apucBuf[2], stDecOutArgs.stPicture.usWidthPitch); } OSAL_MSLEEP(500); #endif /* 如果iMedia有图像输出,则将此图像读出,转换格式后写入到显示图像空间去,等待VO读取 */ if (stDecOutArgs.stPicture.apucBuf[0] && stDecOutArgs.stPicture.apucBuf[1] && stDecOutArgs.stPicture.apucBuf[2] && 0==s32Ret) { UINT32 bReversed = 0; /* 转换色色度格式, 使UV间插存放 */ pstPic = &stDecOutArgs.stPicture; pu8Chrom = pstPic->apucBuf[0] + pstPic->usWidthPitch * (UP_ALIGN_16(pstPic->usHeight) + 16); if ( (STD_VP6 == pCtx->eVidStd) || (STD_VP6F == pCtx->eVidStd) || (STD_VP6A == pCtx->eVidStd) ) { bReversed = pCtx->pstExtraData->StdExt.Vp6Ext.bReversed; } else { bReversed = 0; } if (1 == bReversed) { pu8Luma = pu8Chrom + pstPic->usWidthPitch * (UP_ALIGN_16(pstPic->usHeight) / 2); } else { pu8Luma = pstPic->apucBuf[0]; } ConvFormat(pstPic->usWidth/2, pstPic->usHeight/2, pstPic->usWidthPitch/2, pstPic->apucBuf[0], pstPic->apucBuf[1], pstPic->apucBuf[2], pu8Luma, pu8Chrom, bReversed); #ifdef ENV_ARMLINUX_KERNEL (pVfmwToSvdecFun->pfnVfmwKlibFlushCache)(pu8Luma, (pVfmwToSvdecFun->pfnVfmwMemVir2Phy)(pu8Luma), pstPic->usWidthPitch * pstPic->usHeight); (pVfmwToSvdecFun->pfnVfmwKlibFlushCache)(pu8Chrom, (pVfmwToSvdecFun->pfnVfmwMemVir2Phy)(pu8Chrom), pstPic->usWidthPitch * pstPic->usHeight / 2); // klib_flush_cache(pu8Luma, MEM_Vir2Phy(pu8Luma), pstPic->usWidthPitch * pstPic->usHeight); // klib_flush_cache(pu8Chrom, MEM_Vir2Phy(pu8Chrom), pstPic->usWidthPitch * pstPic->usHeight / 2); #endif /* 寻找一个空闲的IMAGE槽位存放刚刚解码的帧信息 */ for (i = 0; i < iMediaSDEC_MAX_IMAGE_NUM; i++) { if (0 == pCtx->ImageUsedFlag[i]) { break; } } /* 如果槽位占满: 将所有帧释放给解码库,然后清空IMAGE集 */ if (i >= iMediaSDEC_MAX_IMAGE_NUM) { for (i = 0; i < iMediaSDEC_MAX_IMAGE_NUM; i++) { iMediaSoftDEC_RecycleImage(pCtx, i); } i = 0; } pstImg = &pCtx->stImgs[i]; pstImg->image_id = i; pstImg->PTS = pCtx->pstExtraData->pts; pCtx->pstExtraData->pts = -1; pstImg->top_luma_phy_addr = bReversed ? iMediaSDEC_VIR_2_PHY(pu8Luma) : iMediaSDEC_VIR_2_PHY(pstPic->apucBuf[0]); pstImg->top_chrom_phy_addr = iMediaSDEC_VIR_2_PHY(pu8Chrom); pstImg->btm_luma_phy_addr = pstImg->top_luma_phy_addr + pstPic->usWidthPitch; pstImg->btm_chrom_phy_addr = pstImg->top_chrom_phy_addr + pstPic->usWidthPitch; pstImg->luma_2d_phy_addr = pstImg->top_luma_phy_addr; pstImg->luma_2d_vir_addr = pstPic->apucBuf[0]; pstImg->chrom_2d_phy_addr = pstImg->top_chrom_phy_addr; pstImg->chrom_2d_vir_addr = pu8Chrom; /* 设置宽高比的两个参数 */ SetAspectRatio(pstImg, (VDEC_DAR_E) u32AspectRatio); pstImg->format = ((u32AspectRatio&7)<<14) | ((u32FldFirst&0x3)<<12) | (3<<10) | ((u32SrcFmt&3)<<8) | ((u32VideoFmt&3)<<5) | ((0&7)<<2) // yuv420 | (u32CodType&3); pstImg->image_width = pstPic->usWidth; pstImg->image_height = pstPic->usHeight; pstImg->disp_width = pstPic->usWidth; pstImg->disp_height = pstPic->usHeight; pstImg->disp_center_x = pstPic->usWidth / 2; pstImg->disp_center_y = pstPic->usHeight / 2; pstImg->image_stride = pstPic->usWidthPitch; pstImg->frame_rate = 25 << 10; pstImg->error_level = 0; pstImg->ImageDnr.video_standard = pCtx->eVidStd; /* 将此图像插入输出队列 */ pCtx->ImageUsedFlag[i] = 1; memcpy(&pCtx->stVidPics[i], pstPic, sizeof(STRU_IVIDEO_PICTURE)); // if( VF_OK != InsertImgToVoQueue(pCtx->ChanID, pCtx->eVidStd, pCtx, &pCtx->ImageQue, pstImg)) if(VF_OK != (pVfmwToSvdecFun->pfnVfmwInsertImgToVoQueue)(pCtx->ChanID, pCtx->eVidStd, pCtx, &pCtx->ImageQue, pstImg)) { IMedia_Viddec_Control(pCtx->CodecInstHandle, IMEDIA_PICTURE_RELEASE, pstPic, NULL); pCtx->ImageUsedFlag[i] = 0; } else { last_image_id = pstImg->image_id; } } if (stDecOutArgs.uiBytesConsumed == 0) { return iMediaSDEC_NOT_DEC; } return iMediaSDEC_OK; }
DisplayResScreen::DisplayResScreen(int w, int h, int mw, int mh, const std::vector<double>& rr) : width(w), height(h), width_mm(mw), height_mm(mh), refreshRates(rr), custom(false) { SetAspectRatio(-1.0); }
void Camera::SetViewSize(float width, float height) { mViewSize = XMFLOAT2(width, height); SetAspectRatio(width / height); }
void VideoContext::SetVideo(const wxString &filename) { Reset(); if (filename.empty()) { VideoOpen(); return; } bool commit_subs = false; try { provider.reset(new ThreadedFrameSource(filename, this)); videoProvider = provider->GetVideoProvider(); videoFile = filename; // Check that the script resolution matches the video resolution int sx = context->ass->GetScriptInfoAsInt("PlayResX"); int sy = context->ass->GetScriptInfoAsInt("PlayResY"); int vx = GetWidth(); int vy = GetHeight(); // If the script resolution hasn't been set at all just force it to the // video resolution if (sx == 0 && sy == 0) { context->ass->SetScriptInfo("PlayResX", wxString::Format("%d", vx)); context->ass->SetScriptInfo("PlayResY", wxString::Format("%d", vy)); commit_subs = true; } // If it has been set to something other than a multiple of the video // resolution, ask the user if they want it to be fixed else if (sx % vx != 0 || sy % vy != 0) { switch (OPT_GET("Video/Check Script Res")->GetInt()) { case 1: // Ask to change on mismatch if (wxYES != wxMessageBox( wxString::Format(_("The resolution of the loaded video and the resolution specified for the subtitles don't match.\n\nVideo resolution:\t%d x %d\nScript resolution:\t%d x %d\n\nChange subtitles resolution to match video?"), vx, vy, sx, sy), _("Resolution mismatch"), wxYES_NO | wxCENTER, context->parent)) break; // Fallthrough to case 2 case 2: // Always change script res context->ass->SetScriptInfo("PlayResX", wxString::Format("%d", vx)); context->ass->SetScriptInfo("PlayResY", wxString::Format("%d", vy)); commit_subs = true; break; default: // Never change break; } } keyFrames = videoProvider->GetKeyFrames(); // Set frame rate videoFPS = videoProvider->GetFPS(); if (ovrFPS.IsLoaded()) { int ovr = wxMessageBox(_("You already have timecodes loaded. Would you like to replace them with timecodes from the video file?"), _("Replace timecodes?"), wxYES_NO | wxICON_QUESTION); if (ovr == wxYES) { ovrFPS = agi::vfr::Framerate(); ovrTimecodeFile.clear(); } } // Set aspect ratio double dar = videoProvider->GetDAR(); if (dar > 0) SetAspectRatio(4, dar); // Set filename config::mru->Add("Video", STD_STR(filename)); StandardPaths::SetPathValue("?video", wxFileName(filename).GetPath()); // Show warning wxString warning = videoProvider->GetWarning(); if (!warning.empty()) wxMessageBox(warning, "Warning", wxICON_WARNING | wxOK); hasSubtitles = false; if (filename.Right(4).Lower() == ".mkv") { hasSubtitles = MatroskaWrapper::HasSubtitles(filename); } provider->LoadSubtitles(context->ass); VideoOpen(); KeyframesOpen(keyFrames); TimecodesOpen(FPS()); } catch (agi::UserCancelException const&) { } catch (agi::FileNotAccessibleError const& err) { config::mru->Remove("Video", STD_STR(filename)); wxMessageBox(lagi_wxString(err.GetMessage()), "Error setting video", wxOK | wxICON_ERROR | wxCENTER); } catch (VideoProviderError const& err) { wxMessageBox(lagi_wxString(err.GetMessage()), "Error setting video", wxOK | wxICON_ERROR | wxCENTER); } if (commit_subs) context->ass->Commit(_("change script resolution"), AssFile::COMMIT_SCRIPTINFO); else JumpToFrame(0); }
void VDVideoWindow::OnCommand(int cmd) { switch(cmd) { case ID_DISPLAY_ZOOM_6: SetZoom(0.0625); break; case ID_DISPLAY_ZOOM_12: SetZoom(0.125); break; case ID_DISPLAY_ZOOM_25: SetZoom(0.25); break; case ID_DISPLAY_ZOOM_33: SetZoom(1.0/3.0); break; case ID_DISPLAY_ZOOM_50: SetZoom(0.5); break; case ID_DISPLAY_ZOOM_66: SetZoom(2.0/3.0); break; case ID_DISPLAY_ZOOM_75: SetZoom(3.0/4.0); break; case ID_DISPLAY_ZOOM_100: SetZoom(1.0); break; case ID_DISPLAY_ZOOM_150: SetZoom(1.5); break; case ID_DISPLAY_ZOOM_200: SetZoom(2.0); break; case ID_DISPLAY_ZOOM_300: SetZoom(3.0); break; case ID_DISPLAY_ZOOM_400: SetZoom(4.0); break; case ID_DISPLAY_ZOOM_EXACT: mZoom = 1.0; SetAspectRatio(1.0, false); break; case ID_DISPLAY_AR_FREE: SetAspectRatio(-1, false); break; case ID_DISPLAY_AR_PIXEL_SOURCE: SetAspectRatioSourcePAR(); break; case ID_DISPLAY_AR_PIXEL_0909: SetAspectRatio( 10.0/11.0, false); break; case ID_DISPLAY_AR_PIXEL_1000: SetAspectRatio( 1.0 , false); break; case ID_DISPLAY_AR_PIXEL_1093: SetAspectRatio( 59.0/54.0, false); break; case ID_DISPLAY_AR_PIXEL_1212: SetAspectRatio( 40.0/33.0, false); break; case ID_DISPLAY_AR_PIXEL_1364: SetAspectRatio( 15.0/11.0, false); break; case ID_DISPLAY_AR_PIXEL_1457: SetAspectRatio(118.0/81.0, false); break; case ID_DISPLAY_AR_PIXEL_1639: SetAspectRatio( 59.0/36.0, false); break; case ID_DISPLAY_AR_PIXEL_1818: SetAspectRatio( 20.0/11.0, false); break; case ID_DISPLAY_AR_PIXEL_2185: SetAspectRatio( 59.0/27.0, false); break; case ID_DISPLAY_AR_FRAME_1333: SetAspectRatio(4.0/3.0, true); break; case ID_DISPLAY_AR_FRAME_1364: SetAspectRatio(15.0/11.0, true); break; case ID_DISPLAY_AR_FRAME_1777: SetAspectRatio(16.0/9.0, true); break; case ID_DISPLAY_FILTER_POINT: if (mpDisplay) mpDisplay->SetFilterMode(IVDVideoDisplay::kFilterPoint); break; case ID_DISPLAY_FILTER_BILINEAR: if (mpDisplay) mpDisplay->SetFilterMode(IVDVideoDisplay::kFilterBilinear); break; case ID_DISPLAY_FILTER_BICUBIC: if (mpDisplay) mpDisplay->SetFilterMode(IVDVideoDisplay::kFilterBicubic); break; case ID_DISPLAY_FILTER_ANY: if (mpDisplay) mpDisplay->SetFilterMode(IVDVideoDisplay::kFilterAnySuitable); break; } }
int GLinitialize(void *ext_gles_display, void *ext_gles_surface) { if(ext_gles_display != NULL && ext_gles_surface != NULL) { display = (EGLDisplay)ext_gles_display; surface = (EGLSurface)ext_gles_surface; } else { if(initEGL()!=0) return -1; created_gles_context=1; } //----------------------------------------------------// glDepthRangef(0.0f, 1.0f);glError(); glViewport(rRatioRect.left, // init viewport by ratio rect iResY-(rRatioRect.top+rRatioRect.bottom), rRatioRect.right, rRatioRect.bottom); glError(); glScissor(0, 0, iResX, iResY); glError(); // init clipping (fullscreen) glEnable(GL_SCISSOR_TEST); glError(); #ifndef OWNSCALE glMatrixMode(GL_TEXTURE); // init psx tex sow and tow if not "ownscale" glLoadIdentity(); glScalef(1.0f/255.99f,1.0f/255.99f,1.0f); // geforce precision hack #endif //glPolygonOffset( -0.2f, -0.2f );glError(); glMatrixMode(GL_PROJECTION); glError(); // init projection with psx resolution glLoadIdentity(); glError(); glOrtho(0,PSXDisplay.DisplayMode.x, PSXDisplay.DisplayMode.y, 0, -1, 1); glError(); if(iZBufferDepth) // zbuffer? { uiBufferBits=GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT; glEnable(GL_DEPTH_TEST); glError(); glDepthFunc(GL_ALWAYS); glError(); iDepthFunc=1; } else // no zbuffer? { uiBufferBits=GL_COLOR_BUFFER_BIT; glDisable(GL_DEPTH_TEST); glError(); } glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glError(); // first buffer clear glClear(uiBufferBits); glError(); GetExtInfos(); // get ext infos SetExtGLFuncs(); // init all kind of stuff (tex function pointers) glEnable(GL_ALPHA_TEST); glError(); // wanna alpha test { glDisable(GL_LINE_SMOOTH); glError(); glDisable(GL_POINT_SMOOTH); glError(); } ubGloAlpha=127; // init some drawing vars ubGloColAlpha=127; TWin.UScaleFactor = 1; TWin.VScaleFactor = 1; bDrawMultiPass=FALSE; bTexEnabled=FALSE; bUsingTWin=FALSE; if(bDrawDither) glEnable(GL_DITHER); // dither mode else glDisable(GL_DITHER); glError(); glDisable(GL_FOG); glError(); // turn all (currently) unused modes off glDisable(GL_LIGHTING); glError(); glDisable(GL_STENCIL_TEST); glError(); glDisable(GL_TEXTURE_2D); glError(); glDisable(GL_CULL_FACE); glFlush(); glError(); // we are done... glFinish(); glError(); CreateScanLines(); // setup scanline stuff (if wanted) CheckTextureMemory(); // check available tex memory if(bKeepRatio) SetAspectRatio(); // set ratio bIsFirstFrame = FALSE; // we have survived the first frame :) return 0; }