void PostProcessor::DrawDepthBuffer(DepthStencilBuffer& depthBuffer, ID3D11RenderTargetView* rt) { Assert_(depthBuffer.SRView != nullptr); if(depthBuffer.MultiSamples > 1) PostProcess(depthBuffer.SRView, rt, drawDepthMSAA, L"Draw Depth"); else PostProcess(depthBuffer.SRView, rt, drawDepth, L"Draw Depth"); }
void D3DPostProcessor::PostProcessEFB(const TargetRectangle& src_rect, const TargetSize& src_size) { // Apply normal post-process process, but to the EFB buffers. // Uses the current viewport as the "visible" region to post-process. // In D3D, the viewport rectangle must fit within the render target. TargetRectangle target_rect; TargetSize target_size(src_size.width, src_size.height); target_rect.left = src_rect.left >= 0 ? src_rect.left : 0; target_rect.top = src_rect.top >= 0 ? src_rect.top : 0; target_rect.right = src_rect.right <= src_size.width ? src_rect.right : src_size.width; target_rect.bottom = src_rect.bottom <= src_size.height ? src_rect.bottom : src_size.height; // Source and target textures, if MSAA is enabled, this needs to be resolved D3DTexture2D* color_texture = FramebufferManager::GetResolvedEFBColorTexture(); D3DTexture2D* depth_texture = nullptr; if (m_requires_depth_buffer) { depth_texture = FramebufferManager::GetResolvedEFBDepthTexture(); } // Invoke post process process PostProcess(nullptr, nullptr, nullptr, target_rect, target_size, reinterpret_cast<uintptr_t>(color_texture), target_rect, target_size, reinterpret_cast<uintptr_t>(depth_texture)); // Copy back to EFB buffer when multisampling is enabled if (g_ActiveConfig.iMultisamples > 1) CopyTexture(target_rect, reinterpret_cast<uintptr_t>(FramebufferManager::GetEFBColorTexture()), target_rect, reinterpret_cast<uintptr_t>(color_texture), target_size, -1, false, true); g_renderer->RestoreAPIState(); }
bool PrePostProcessor::Process() { if(!PreProcess()) return false; if(!DoProcess()) return false; if(!PostProcess()) return false; return ProcessNextMethod(); }
void PostProcessor::CalcAvgLuminance(ID3D11ShaderResourceView* input) { TempRenderTarget* initialLuminance = GetTempRenderTarget(LumMapSize, LumMapSize, DXGI_FORMAT_R32_FLOAT, 1, 0, 0, TRUE); // Luminance mapping PostProcess(input, initialLuminance->RTView, luminanceMap, L"Luminance Map Generation"); // Generate the mip chain context->GenerateMips(initialLuminance->SRView); // Adaptation inputs.push_back(adaptedLuminance[!currLumTarget].SRView); inputs.push_back(initialLuminance->SRView); outputs.push_back(adaptedLuminance[currLumTarget].RTView); PostProcess(adaptLuminance, L"Luminance Adaptation"); initialLuminance->InUse = FALSE; }
bool cSmartCardNagra::Decode(const cEcmInfo *ecm, const unsigned char *data, unsigned char *cw) { if(!isTiger) { unsigned char pkt[256+16]; memset(pkt,0,sizeof(pkt)); memcpy(pkt,data+3+2,data[4]); for(int i=1; i>=0; i--) { if(((!isN3 && DoBlkCmd(data[3],data[4]+2,0x87,0x02,pkt)) || ( isN3 && DoBlkCmd(data[3]+1,data[4]+5+2,0x88,0x04,pkt))) && Status()) break; PRINTF(L_SC_ERROR,"ECM cmd failed%s",(i>0)?", retrying":""); if(i==0) return false; } cCondWait::SleepMs(10); for(int retry=0; !GetCardStatus() && retry<5; retry++) cCondWait::SleepMs(5); cCondWait::SleepMs(10); if(HAS_CW() && DoBlkCmd(0x1C,0x02,0x9C,0x36) && Status()) { DecryptCW(cw,buff+33,buff+7); PostProcess(); if(swapCW) { unsigned char tt[8]; memcpy(&tt[0],&cw[0],8); memcpy(&cw[0],&cw[8],8); memcpy(&cw[8],&tt[0],8); } return true; } } else { // ecm_data: 80 30 89 D3 87 54 11 10 DA A6 0F 4B 92 05 34 00 ... //serial_data: A0 CA 00 00 8C D3 8A 00 00 00 00 00 10 DA A6 0F . unsigned char ecm_trim[150]; memset(ecm_trim,0,150); memcpy(&ecm_trim[5],data+3+2+2,data[4]+2); if(DoBlkCmd(data[3],data[4]+5,0x53,0x16,ecm_trim) && Status()) { DecryptCW(cw,buff+17,buff+9); PostProcess(); return true; } } return false; }
void PostProcessor::ToneMap(ID3D11ShaderResourceView* input, ID3D11ShaderResourceView* bloom, ID3D11RenderTargetView* output) { // Composite the bloom with the original image, and apply tone-mapping inputs.push_back(input); inputs.push_back(adaptedLuminance[currLumTarget].SRView); inputs.push_back(bloom); outputs.push_back(output); PostProcess(composite, L"Tone Map And Composite"); }
bool cSmartCardNagra::Update(int pid, int caid, const unsigned char *data) { if(MatchEMM(data)) { if(DoBlkCmd(data[8],data[9]+2,0x84,0x02,data+8+2) && Status()) { cCondWait::SleepMs(300); PostProcess(); } return true; } return false; }
TempRenderTarget* PostProcessor::Bloom(ID3D11ShaderResourceView* input) { PIXEvent pixEvent(L"Bloom"); TempRenderTarget* downscale1 = GetTempRenderTarget(inputWidth / 2, inputHeight / 2, DXGI_FORMAT_R16G16B16A16_FLOAT); inputs.push_back(input); outputs.push_back(downscale1->RTView); PostProcess(bloom, L"Bloom Initial Pass"); // Blur it for(uint64 i = 0; i < 2; ++i) { TempRenderTarget* blurTemp = GetTempRenderTarget(inputWidth / 2, inputHeight / 2, DXGI_FORMAT_R16G16B16A16_FLOAT); PostProcess(downscale1->SRView, blurTemp->RTView, blurH, L"Horizontal Bloom Blur"); PostProcess(blurTemp->SRView, downscale1->RTView, blurV, L"Vertical Bloom Blur"); blurTemp->InUse = false; } return downscale1; }
// result forming form one predicate, based on hjliu's original function void DepSRL::ProcessOnePredicate( const vector<string>& vecWords, const vector<string>& vecPos, int intPredicates, const vector< pair<int, int> >& vecPairPS, const vector< pair<string, double> >& vecPairMaxArgs, const vector< pair<string, double> >& vecPairNextArgs, vector< pair< string, pair< int, int > > > &vecResultForOnePredicate ) { vector< pair<int, int> > vecPairPSBuf; vector< pair<string, double> > vecPairMaxArgBuf; vector< pair<string, double> > vecPairNextArgBuf; //step1. remove the null label vector< pair<string, double> > vecPairNNLMax; vector< pair<string, double> > vecPairNNLNext; vector< pair<int, int> > vecPairNNLPS; RemoveNullLabel(vecPairMaxArgs, vecPairNextArgs, vecPairPS, vecPairNNLMax, vecPairNNLNext, vecPairNNLPS); // step 2. insert the args vector<int> vecItem; for (int index = 0; index < vecPairNNLPS.size(); index++) { InsertOneArg( vecPairNNLPS.at(index), vecPairNNLMax.at(index), vecPairNNLNext.at(index), vecPairPSBuf, vecPairMaxArgBuf, vecPairNextArgBuf ) ; } // step 3. insert predicate node if ( IsInsertPredicate(intPredicates, vecPairMaxArgBuf, vecPairPSBuf) ) { pair<int, int> prPdPS; pair<string, double> prPdArg; prPdPS.first = intPredicates; prPdPS.second = intPredicates; prPdArg.first = S_PD_ARG; prPdArg.second = 1; vecPairPSBuf.push_back(prPdPS); vecPairMaxArgBuf.push_back(prPdArg); vecPairNextArgBuf.push_back(prPdArg); } // step 4. post process PostProcess(vecPos, vecPairPS, vecPairMaxArgs, vecPairNextArgs, vecPairPSBuf, vecPairMaxArgBuf, vecPairNextArgBuf); // put into output vector for (int index = 0; index < vecPairPSBuf.size(); index++) { vecResultForOnePredicate.push_back(make_pair(vecPairMaxArgBuf[index].first, vecPairPSBuf[index])); } }
main() { void GetAtomlist(); void GetAtomlist_mod(); void GetCOdict(); void AnalyzeTrajectory(); void PostProcess(); GetAtomlist_mod(Snapshots); GetCOdict(Cutoff); AnalyzeTrajectory(Snapshots,Output3); PostProcess(Output1,Output2,Output3); }
void LogicMain::Run() { while (m_isRun) { m_pNetwork->Run(); while (m_pNetwork->PacketQueueEmpty() == false) { auto pkt = m_pNetwork->GetPacket(); m_pktProcArr->ProcessPacket(pkt); } PostProcess(); } }
bool CGenericProcessingMachine::Run(void) { if (!PreProcess()) return false; // bool result = true; CString source_directory; CString target_directory; if (PSC().VarDefined(GPM_VAR_NAME_INDIR)) { source_directory = CheckLastChar(PSC().VarNamed(GPM_VAR_NAME_INDIR).GetString(),'/'); PSC().VarNamed(GPM_VAR_NAME_INDIR).SetString(source_directory); } if (PSC().VarDefined(GPM_VAR_NAME_OUTDIR)) { target_directory = CheckLastChar(PSC().VarNamed(GPM_VAR_NAME_OUTDIR).GetString(),'/'); PSC().VarNamed(GPM_VAR_NAME_OUTDIR).SetString(target_directory); } bool do_rename_outfile = ((!PSC().VarDefined(GPM_VAR_NAME_LIST))&&(PSC().VarDefined(GPM_VAR_NAME_OUT))); bool do_create_outlist = ((PSC().VarDefined(GPM_VAR_NAME_LIST))&&(PSC().VarDefined(GPM_VAR_NAME_OUT))); //if ((ILST().GetCount()>1)||(!PSC().VarDefined(GPM_VAR_NAME_OUT))) for (int i = 0; i < ILST().GetCount(); i++) { m_FileIndex = i; if (ILST().GetString(i).GetLength()==0) continue; CString source_file_name = source_directory + ILST().GetString(i); CString target_name = TargetName(i,ILST().GetString(i)); if (do_rename_outfile) { target_name = PSC().VarNamed(GPM_VAR_NAME_OUT).GetString(); } CString target_file_name = target_directory + target_name; result = result && ProcessFile(source_file_name,target_file_name); if (!target_file_name.IsEmpty()) { OLST().Insert(target_name); } } if (do_create_outlist) { OLST().SaveToFile(PSC().VarNamed(GPM_VAR_NAME_OUT).GetString()); } // result = result && PostProcess(); return result; }
void PostProcessor::ToneMap(ID3D11ShaderResourceView* input, ID3D11ShaderResourceView* bloom, ID3D11RenderTargetView* output) { // Use an intermediate render target so that we can render do sRGB conversion ourselves in the shader TempRenderTarget* tmOutput = GetTempRenderTarget(inputWidth, inputHeight, DXGI_FORMAT_R8G8B8A8_UNORM); inputs.push_back(input); inputs.push_back(bloom); outputs.push_back(tmOutput->RTView); PostProcess(toneMap, L"Tone Mapping"); ID3D11ResourcePtr outputResource; output->GetResource(&outputResource); context->CopyResource(outputResource, tmOutput->Texture); tmOutput->InUse = false; }
QTSS_Error QTSSAccessLogModuleDispatch(QTSS_Role inRole, QTSS_RoleParamPtr inParamBlock) { switch (inRole) { case QTSS_Register_Role: return Register(&inParamBlock->regParams); case QTSS_StateChange_Role: return StateChange(&inParamBlock->stateChangeParams); case QTSS_Initialize_Role: return Initialize(&inParamBlock->initParams); case QTSS_RereadPrefs_Role: return RereadPrefs(); case QTSS_RTSPPostProcessor_Role: return PostProcess(&inParamBlock->rtspPostProcessorParams); case QTSS_ClientSessionClosing_Role: return ClientSessionClosing(&inParamBlock->clientSessionClosingParams); case QTSS_Shutdown_Role: return Shutdown(); } return QTSS_NoErr; }
void PostProcessor::Bloom(ID3D11ShaderResourceView* input, TempRenderTarget*& bloomTarget) { // Downscale TempRenderTarget* bloomSrc = GetTempRenderTarget(inputWidth, inputHeight, DXGI_FORMAT_R11G11B10_FLOAT); inputs.push_back(input); inputs.push_back(adaptedLuminance[currLumTarget].SRView); outputs.push_back(bloomSrc->RTView); PostProcess(bloomThreshold, L"Bloom Threshold"); TempRenderTarget* downscale1 = GetTempRenderTarget(inputWidth / 2, inputHeight / 2, DXGI_FORMAT_R11G11B10_FLOAT); PostProcess(bloomSrc->SRView, downscale1->RTView, scale, L"Bloom Downscale"); bloomSrc->InUse = false; TempRenderTarget* downscale2 = GetTempRenderTarget(inputWidth / 4, inputHeight / 4, DXGI_FORMAT_R11G11B10_FLOAT); PostProcess(downscale1->SRView, downscale2->RTView, scale, L"Bloom Downscale"); TempRenderTarget* downscale3 = GetTempRenderTarget(inputWidth / 8, inputHeight / 8, DXGI_FORMAT_R11G11B10_FLOAT); PostProcess(downscale2->SRView, downscale3->RTView, scale, L"Bloom Downscale"); // Blur it for (uint64 i = 0; i < 4; ++i) { TempRenderTarget* blurTemp = GetTempRenderTarget(inputWidth / 8, inputHeight / 8, DXGI_FORMAT_R11G11B10_FLOAT); PostProcess(downscale3->SRView, blurTemp->RTView, bloomBlurH, L"Horizontal Bloom Blur"); PostProcess(blurTemp->SRView, downscale3->RTView, bloomBlurV, L"Vertical Bloom Blur"); blurTemp->InUse = false; } PostProcess(downscale3->SRView, downscale2->RTView, scale, L"Bloom Upscale"); downscale3->InUse = false; PostProcess(downscale2->SRView, downscale1->RTView, scale, L"Bloom Upscale"); downscale2->InUse = false; bloomTarget = downscale1; }
void D3DPostProcessor::PostProcessEFBToTexture(uintptr_t dst_texture) { // Apply normal post-process process, but to the EFB buffers. // Uses the current viewport as the "visible" region to post-process. TargetRectangle target_rect = { 0, 0, g_renderer->GetTargetWidth(), g_renderer->GetTargetHeight() }; TargetSize target_size(g_renderer->GetTargetWidth(), g_renderer->GetTargetHeight()); // Source and target textures, if MSAA is enabled, this needs to be resolved D3DTexture2D* color_texture = FramebufferManager::GetResolvedEFBColorTexture(); D3DTexture2D* depth_texture = nullptr; if (m_requires_depth_buffer) { depth_texture = FramebufferManager::GetResolvedEFBDepthTexture(); } D3DTexture2D* real_dst_texture = reinterpret_cast<D3DTexture2D*>(dst_texture); // Invoke post process process PostProcess(nullptr, nullptr, nullptr, target_rect, target_size, reinterpret_cast<uintptr_t>(color_texture), target_rect, target_size, reinterpret_cast<uintptr_t>(depth_texture), dst_texture); g_renderer->RestoreAPIState(); }
int theora_decode_packetin(theora_state *th,ogg_packet *op){ long ret; PB_INSTANCE *pbi=(PB_INSTANCE *)(th->internal_decode); pbi->DecoderErrorCode = 0; #ifndef LIBOGG2 oggpackB_readinit(pbi->opb,op->packet,op->bytes); #else oggpackB_readinit(pbi->opb,op->packet); #endif /* verify that this is a video frame */ theora_read(pbi->opb,1,&ret); if (ret==0) { ret=LoadAndDecode(pbi); if(ret)return ret; if(pbi->PostProcessingLevel) PostProcess(pbi); if(op->granulepos>-1) th->granulepos=op->granulepos; else{ if(th->granulepos==-1){ th->granulepos=0; }else{ if(pbi->FrameType==BASE_FRAME){ long frames= th->granulepos & ((1<<pbi->keyframe_granule_shift)-1); th->granulepos>>=pbi->keyframe_granule_shift; th->granulepos+=frames+1; th->granulepos<<=pbi->keyframe_granule_shift; }else th->granulepos++; }
void ClusterCulling::DrawFrame(double deltaTime) { if (m_sceneLoaded.load(std::memory_order_relaxed)) { if (!m_sceneIsSetup) { // Clean-up the thread m_sceneLoaderThread.join(); DirectX::XMVECTOR AABB_minXM = DirectX::XMVectorSet(0.0f, 0.0f, 0.0f, 0.0f); DirectX::XMVECTOR AABB_maxXM = DirectX::XMVectorSet(0.0f, 0.0f, 0.0f, 0.0f); // Get the AABB of the scene so we can calculate the scale factors for the camera movement for (auto iter = m_models.begin(); iter != m_models.end(); ++iter) { AABB_minXM = DirectX::XMVectorMin(AABB_minXM, DirectX::XMVectorScale(iter->first->GetAABBMin_XM(), m_sceneScaleFactor)); AABB_maxXM = DirectX::XMVectorMax(AABB_maxXM, DirectX::XMVectorScale(iter->first->GetAABBMax_XM(), m_sceneScaleFactor)); } for (auto iter = m_instancedModels.begin(); iter != m_instancedModels.end(); ++iter) { for (auto transformIter = iter->second->begin(); transformIter != iter->second->end(); ++transformIter) { AABB_minXM = DirectX::XMVectorMin(AABB_minXM, DirectX::XMVectorScale(DirectX::XMVector3Transform(iter->first->GetAABBMin_XM(), *transformIter), m_sceneScaleFactor)); AABB_maxXM = DirectX::XMVectorMax(AABB_maxXM, DirectX::XMVectorScale(DirectX::XMVector3Transform(iter->first->GetAABBMax_XM(), *transformIter), m_sceneScaleFactor)); } } DirectX::XMFLOAT3 AABB_min; DirectX::XMFLOAT3 AABB_max; DirectX::XMStoreFloat3(&AABB_min, AABB_minXM); DirectX::XMStoreFloat3(&AABB_max, AABB_maxXM); float min = std::min(std::min(AABB_min.x, AABB_min.y), AABB_min.z); float max = std::max(std::max(AABB_max.x, AABB_max.y), AABB_max.z); float range = max - min; m_cameraPanFactor = range * 0.0002857f; m_cameraScrollFactor = range * 0.0002857f; m_sceneIsSetup = true; } RenderMainPass(); PostProcess(); } else { // Set the backbuffer as the main render target m_immediateContext->OMSetRenderTargets(1, &m_backbufferRTV, nullptr); // Clear the render target view m_immediateContext->ClearRenderTargetView(m_backbufferRTV, DirectX::Colors::LightGray); m_spriteRenderer.Begin(m_immediateContext, Graphics::SpriteRenderer::Point); DirectX::XMFLOAT4X4 transform {2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 2.0f, 0.0f, m_clientWidth / 2.0f - 90.0f, m_clientHeight / 2.0f - 30.0f, 0.0f, 1.0f}; m_spriteRenderer.RenderText(m_timesNewRoman12Font, L"Scene is loading....", transform, 0U, DirectX::XMFLOAT4(1.0f, 1.0f, 0.0f, 1.0f)); m_spriteRenderer.End(); Sleep(50); } RenderHUD(); if (m_showConsole) { m_immediateContext->OMSetRenderTargets(1, &m_backbufferRTV, nullptr); m_console.Render(m_immediateContext, deltaTime); } uint syncInterval = m_vsync ? 1 : 0; m_swapChain->Present(syncInterval, 0); }
void GUI::PostProcess(const unsigned int& processed) { for (auto eleHandle = mElementHandles.begin(); eleHandle != mElementHandles.end(); ++eleHandle) { auto ele = mElementManager.GetAsBase(*eleHandle); ele->PostProcess(processed, this); } }
BOOL CShockWaveEffect::Process(FLOAT time) { FLOAT fDeltaTime, fProcessedTime; BOOL bRet, bRender; if(!PreProcess(time, bRet, bRender, fDeltaTime, fProcessedTime)) { if(!bRender) SetNotRenderAtThisFrame(); return bRet; } //color 정보 FLOAT fadeVal = this->GetFadeValue(fProcessedTime); if(fadeVal == 1.0f && m_bColorWhite) { //nothing } else { m_vectorGFXColor.clear(); m_vectorGFXColor.reserve(m_iSplitCount*2); UBYTE ubColElement = UBYTE(255.0f * fadeVal); GFXColor col; if( m_eBlendType == PBT_BLEND || m_eBlendType == PBT_ADDALPHA ) { col = 0xFFFFFF00 | ubColElement; //fade by alpha } else if( m_eBlendType == PBT_ADD ) { col = (ubColElement << 24) | (ubColElement << 16) | (ubColElement << 8) | 0x000000FF; //fade by color } else col = 0xFFFFFFFF; //fade 의미 없음. for(INDEX i=0; i<m_iSplitCount; ++i) { m_vectorGFXColor.push_back(col); m_vectorGFXColor.push_back(col); } } //wave 정보 m_ssHeight.Prepare(); FLOAT3D height(0, m_ssHeight.Value(fProcessedTime), 0); FLOAT radiusInner = 0, radiusOuter = 0; m_ssRadius.Prepare(); m_ssWidth.Prepare(); if(m_bInnerBasis) { radiusInner = m_ssRadius.Value(fProcessedTime); radiusOuter = radiusInner + m_ssWidth.Value(fProcessedTime); } else { radiusOuter = m_ssRadius.Value(fProcessedTime); radiusInner = radiusOuter - m_ssWidth.Value(fProcessedTime); } //tag의 정보 if(m_ePosition == EOTT_ALWAYS) m_vTagPos = m_ptrAttachTag->CurrentTagInfo().m_vPos; if(m_eRotation == EOTT_ALWAYS) m_qTagRot = m_ptrAttachTag->CurrentTagInfo().m_qRot; //gfx vertex fill, every frame GFXVertex vtx; FLOAT3D pos; const FLOAT angleUnit = 2 * PI / m_iSplitCount; FLOAT angle = 0; INDEX index = 0; m_vectorGFXVertex.clear(); m_vectorGFXColor.reserve(m_iSplitCount*2); for(INDEX i=0; i<m_iSplitCount; ++i) { index = 2*i+0; pos = m_vectorMoveVector[index] * radiusOuter + height; RotateVector(pos, m_qTagRot); pos += m_vTagPos; vtx.x = pos(1); vtx.y = pos(2); vtx.z = pos(3); m_vectorGFXVertex.push_back(vtx); ++index; pos = m_vectorMoveVector[index] * radiusInner; RotateVector(pos, m_qTagRot); pos += m_vTagPos; vtx.x = pos(1); vtx.y = pos(2); vtx.z = pos(3); m_vectorGFXVertex.push_back(vtx); angle += angleUnit; } PostProcess(); return TRUE; }
void PostProcessHelper::PostProcess(CompiledShaderPtr pixelShader, const char* name, const TempRenderTarget* input, const TempRenderTarget* output) { uint32 inputs[1] = { input->RT.SRV() }; const RenderTexture* outputs[1] = { &output->RT }; PostProcess(pixelShader, name, inputs, 1, outputs, 1); }
int main(int argc, char *argv[]){ int p_order = 2; int n_threads = 0; TPZGeoMesh * gmesh = ReadGeometry(); #ifdef PZDEBUG PrintGeometry(gmesh); #endif TPZCompMesh *cmesh = CMeshFooting2D(gmesh, p_order); TPZAnalysis *analysis = Analysis(cmesh,n_threads); #ifdef USING_BOOST boost::posix_time::ptime post_proc_t1 = boost::posix_time::microsec_clock::local_time(); #endif /// Creation of a post-process analysis TPZPostProcAnalysis * post_processor = new TPZPostProcAnalysis; post_processor->SetCompMesh(cmesh); int n_regions = 1; TPZManVector<int,10> post_mat_id(n_regions); post_mat_id[0] = ERock; TPZStack<std::string> scalar_names,vector_names, tensor_names; vector_names.Push("Displacement"); tensor_names.Push("Strain"); tensor_names.Push("StrainPlastic"); tensor_names.Push("Stress"); TPZStack<std::string> var_names; for (auto i : scalar_names) { var_names.Push(i); } for (auto i : vector_names) { var_names.Push(i); } for (auto i : tensor_names) { var_names.Push(i); } post_processor->SetPostProcessVariables(post_mat_id, var_names); TPZFStructMatrix structmatrix(post_processor->Mesh()); structmatrix.SetNumThreads(n_threads); post_processor->SetStructuralMatrix(structmatrix); #ifdef USING_BOOST boost::posix_time::ptime post_proc_t2 = boost::posix_time::microsec_clock::local_time(); #endif #ifdef USING_BOOST REAL case_solving_time = boost::numeric_cast<double>((post_proc_t2-post_proc_t1).total_milliseconds()); std::cout << "Created post-processing in :" << setw(10) << case_solving_time/1000.0 << setw(5) << " seconds." << std::endl; std::cout << std::endl; #endif #ifdef USING_BOOST boost::posix_time::ptime case_t1 = boost::posix_time::microsec_clock::local_time(); #endif std::string plotfile = "footing_elast.vtk"; // For a single step REAL dt = 0.1; int n_steps = 10; for (int it = 1; it <= n_steps; it++) { REAL t = it*dt; LoadingRamp(t,cmesh); FindRoot(analysis); AcceptSolution(cmesh, analysis); #ifdef USING_BOOST boost::posix_time::ptime post_l2_projection_proc_t1 = boost::posix_time::microsec_clock::local_time(); #endif post_processor->TransferSolution(); #ifdef USING_BOOST boost::posix_time::ptime post_l2_projection_proc_t2 = boost::posix_time::microsec_clock::local_time(); REAL l2_projection_time = boost::numeric_cast<double>((post_l2_projection_proc_t2-post_l2_projection_proc_t1).total_milliseconds()); std::cout << "L2 projection post-processing in :" << setw(10) << l2_projection_time/1000.0 << setw(5) << " seconds." << std::endl; std::cout << std::endl; #endif #ifdef USING_BOOST boost::posix_time::ptime post_vtk_proc_t1 = boost::posix_time::microsec_clock::local_time(); #endif PostProcess(post_processor,scalar_names,vector_names,tensor_names,plotfile); #ifdef USING_BOOST boost::posix_time::ptime post_vtk_proc_t2 = boost::posix_time::microsec_clock::local_time(); REAL vtk_drawing_time = boost::numeric_cast<double>((post_vtk_proc_t2-post_vtk_proc_t1).total_milliseconds()); std::cout << "Drawing vtk file in :" << setw(10) << vtk_drawing_time/1000.0 << setw(5) << " seconds." << std::endl; std::cout << std::endl; #endif } #ifdef USING_BOOST boost::posix_time::ptime case_t2 = boost::posix_time::microsec_clock::local_time(); REAL case_time = boost::numeric_cast<double>((case_t2-case_t1).total_milliseconds()); std::cout << "Execution complete in :" << setw(10) << case_time/1000.0 << setw(5) << " seconds." << std::endl; std::cout << std::endl; #endif std::cout << "Execution complete." << std::endl; return 0; }
int main(int argc, const char* argv[]) { mutl::ArgumentParser parser; if( false == parser.Initialize(argc, argv, descs, sizeof(descs)/sizeof(Desc)) || parser.IsEnabled("h") || parser.GetArgumentCount() < 2 ) { usage(param); return 0; } param.upperValue = 32767.0; param.optimize = false; param.optimizeSeparately = false; param.outputLog = false; param.inputLength = -1; param.inputFilepath = parser.GetArgument(0); param.referenceFilepath = parser.GetArgument(1); size_t& tapps = param.tapps; tapps = 256; if (parser.IsEnabled("m")) { tapps = atoi( parser.GetOption("m").c_str() ); } if ( tapps < 1 ) { ERROR_LOG("tapps (an argument of \"-m\" swtich) must be larger than 0: %d\n", static_cast<int>(tapps) ); return 0; } if (parser.IsEnabled("c")) { param.upperValue = atof( parser.GetOption("c").c_str() ); if (param.upperValue <= 0.0) { ERROR_LOG("The specified value with -c (%f) must be positive.\n", param.upperValue); return 0; } } if (parser.IsEnabled("l")) { param.inputLength = atoi( parser.GetOption("l").c_str() ); if (param.inputLength < 1) { ERROR_LOG("The specified value with -l (%d) must be positive.\n", static_cast<int>(param.inputLength) ); return 0; } } if (parser.IsEnabled("opt")) { param.optimize = true; } if (parser.IsEnabled("sep")) { param.optimizeSeparately = true; } if (parser.IsEnabled("log")) { param.outputLog = true; } std::string outputPrefix; if (parser.IsEnabled("o")) { outputPrefix = parser.GetOption("o"); } else { mutl::NodePath _inputPath(param.inputFilepath); mutl::NodePath _referencePath(param.referenceFilepath); char tappsString[11]; sprintf(tappsString, "%d", static_cast<int>(tapps)); outputPrefix = std::string("./Af_") + std::string(tappsString) + std::string("tapps_") + _inputPath.GetBasename() + std::string("_") + _referencePath.GetBasename(); } std::string outdir("./"); if ( parser.IsEnabled("d") ) { outdir = parser.GetOption("d"); outdir += std::string("/"); } param.outputBase = outdir + outputPrefix; // Display messages real-time setvbuf(stdout, NULL, _IONBF, 0); LOG("Input: %s\n", param.inputFilepath.c_str()); LOG("Reference: %s\n", param.referenceFilepath.c_str()); LOG("Tapps: %d\n", static_cast<int>(tapps) ); LOG("Clamped Value: %g\n", param.upperValue); LOG("\n"); status_t status; status = Setup(¶m); if ( NO_ERROR != status ) { ERROR_LOG("Failed in Startup(): %d\n", status); return 0; } LOG("[Input]\n"); LOG(" File : %s\n", param.inputFilepath.c_str()); LOG(" SamplingRate: %d\n", static_cast<int>(param.samplingRate) ); LOG(" Length : %d\n", static_cast<int>(param.inputSignal.GetColumnLength()) ); LOG("\n"); LOG("[Reference]\n"); LOG(" File : %s\n", param.referenceFilepath.c_str()); LOG(" Length: %d\n", static_cast<int>(param.referenceSignal.GetLength())); LOG("\n"); status = PreProcess(¶m); if ( NO_ERROR != status ) { ERROR_LOG("Failed in PreProcess(): %d\n", status); return 0; } status = Process(¶m); if ( NO_ERROR != status ) { ERROR_LOG("Failed in Estimater(): %d\n", status); return 0; } status = PostProcess(¶m); if ( NO_ERROR != status ) { ERROR_LOG("Failed in PostProcess(): %d\n", status); return 0; } status = Cleanup(¶m); if ( NO_ERROR != status ) { ERROR_LOG("Failed in Cleanup(): %d\n", status); return 0; } return 0; }
bool emGifFileModel::TryContinueLoading() throw(emString) { char * p; Render * r; Render * * pr; char tmp[256]; int b,i; errno=0; if (InLoadingRenderData) { r=RenderArray[RenderCount-1]; b=Read8(); if (b) { if (r->DataFill+b>r->DataSize) { r->DataSize+=65536; p=new char[r->DataSize]; if (r->Data) { memcpy(p,r->Data,r->DataFill); delete [] r->Data; } r->Data=p; } if (fread(r->Data+r->DataFill,1,b,File)!=(size_t)b) goto Err; r->DataFill+=b; } else { if (r->DataFill<=0) goto Err; if (r->DataFill<r->DataSize) { p=new char[r->DataFill]; memcpy(p,r->Data,r->DataFill); delete [] r->Data; r->Data=p; r->DataSize=r->DataFill; } InLoadingRenderData=false; } if (ferror(File) || feof(File)) goto Err; return false; } b=Read8(); if (ferror(File)) { goto Err; } else if (feof(File) || b==0x3B) { fclose(File); File=NULL; if (!PostProcess()) goto Err; return true; } else if (b==0x2c) { r=new Render; r->Disposal=NextDisposal; r->Delay=NextDelay; r->Transparent=NextTransparent; r->UserInput=NextUserInput; r->Interlaced=false; r->X=Read16(); r->Y=Read16(); r->Width=Read16(); r->Height=Read16(); r->ColorCount=0; r->DataSize=0; r->DataFill=0; r->Colors=NULL; r->Data=NULL; if (RenderCount>=RenderArraySize) { RenderArraySize+=64; pr=new Render*[RenderArraySize]; if (RenderArray) { for (i=0; i<RenderCount; i++) pr[i]=RenderArray[i]; delete [] RenderArray; } RenderArray=pr; } RenderArray[RenderCount++]=r; b=Read8(); if (ferror(File) || feof(File)) goto Err; if ((b&0x40)!=0) r->Interlaced=true; if ((b&0x80)!=0) { r->ColorCount=2<<(b&7); r->Colors=new emColor[r->ColorCount]; for (i=0; i<r->ColorCount; i++) { r->Colors[i].SetRed((emByte)Read8()); r->Colors[i].SetGreen((emByte)Read8()); r->Colors[i].SetBlue((emByte)Read8()); r->Colors[i].SetAlpha(255); } if (ferror(File) || feof(File)) goto Err; } else { if (ColorCount<=0) goto Err; } r->MinCodeSize=Read8(); if (r->MinCodeSize<1 || r->MinCodeSize>8) goto Err; NextDisposal=0; NextUserInput=false; NextDelay=0; NextTransparent=-1; InLoadingRenderData=true; } else if (b==0x21) { b=Read8(); if (b==0xfe) { if (Comment.GetLen()>=65536) goto Err; for (i=0;;) { b=Read8(); if (ferror(File) || feof(File)) goto Err; if (!b) break; i+=b; if (i>=65536) goto Err; if (fread(tmp,1,b,File)!=(size_t)b) goto Err; tmp[b]=0; Comment+=tmp; } } else if (b==0xf9) { if (Read8()!=4) goto Err; b=Read8(); NextDelay=Read16(); NextTransparent=Read8(); Read8(); if (ferror(File) || feof(File)) goto Err; NextDisposal=(b>>2)&7; if (NextDisposal==4) NextDisposal=3; if (NextDisposal>3) goto Err; NextUserInput=(b&0x02) ? true : false; if ((b&0x01)==0) NextTransparent=-1; } else if (b==0x01) {
void PostProcessorBase::PostProcess(ID3D11ShaderResourceView* input, ID3D11RenderTargetView* output, ID3D11PixelShader* pixelShader, const wchar* name) { inputs.push_back(input); outputs.push_back(output); PostProcess(pixelShader, name); }
void TEvalResult::PostProcess(int threadCount) { NPar::TLocalExecutor executor; executor.RunAdditionalThreads(threadCount - 1); PostProcess(&executor); }
void sseConcurrentContextGuard::Render(sseGrafxInterface *pRenderer) { PreProcess(pRenderer, m_pTextureLoader); DrawObject(pRenderer, m_pTextureLoader); PostProcess(pRenderer, m_pTextureLoader); }
HRESULT CLAVAudio::DecodeDTS(const BYTE * pDataBuffer, int buffsize, int &consumed, HRESULT *hrDeliver) { HRESULT hr = S_FALSE; int nPCMLength = 0; BOOL bFlush = (pDataBuffer == nullptr); BufferDetails out; consumed = 0; while (buffsize > 0) { nPCMLength = 0; if (bFlush) buffsize = 0; ASSERT(m_pParser); BYTE *pOut = nullptr; int pOut_size = 0; int used_bytes = av_parser_parse2(m_pParser, m_pAVCtx, &pOut, &pOut_size, pDataBuffer, buffsize, AV_NOPTS_VALUE, AV_NOPTS_VALUE, 0); if (used_bytes < 0) { return E_FAIL; } else if(used_bytes == 0 && pOut_size == 0) { DbgLog((LOG_TRACE, 50, L"::Decode() - could not process buffer, starving?")); break; } // Timestamp cache to compensate for one frame delay the parser might introduce, in case the frames were already perfectly sliced apart // If we used more (or equal) bytes then was output again, we encountered a new frame, update timestamps if (used_bytes >= pOut_size && m_bUpdateTimeCache) { m_rtStartInputCache = m_rtStartInput; m_rtStopInputCache = m_rtStopInput; m_rtStartInput = m_rtStopInput = AV_NOPTS_VALUE; m_bUpdateTimeCache = FALSE; } if (!bFlush && used_bytes > 0) { buffsize -= used_bytes; pDataBuffer += used_bytes; consumed += used_bytes; } if (pOut && pOut_size > 0) { // Parse DTS headers m_bsParser.Parse(AV_CODEC_ID_DTS, pOut, pOut_size, nullptr); unsigned decode_channels = dts_determine_decode_channels(m_bsParser.m_DTSHeader); // Init Decoder with new Parameters, if required if (m_DTSDecodeChannels != decode_channels) { DbgLog((LOG_TRACE, 20, L"::Decode(): Switching to %d channel decoding", decode_channels)); m_DTSDecodeChannels = decode_channels; FlushDTSDecoder(); } int bitdepth = 0, channels = 0, CoreSampleRate = 0, HDSampleRate = 0, profile = 0; int unk4 = 0, unk5 = 0; nPCMLength = SafeDTSDecode(pOut, pOut_size, m_pDTSDecoderContext->dtsPCMBuffer, 0, 8, &bitdepth, &channels, &CoreSampleRate, &unk4, &HDSampleRate, &unk5, &profile); if (nPCMLength > 0 && bitdepth != m_DTSBitDepth) { int decodeBits = bitdepth > 16 ? 24 : 16; // If the bit-depth changed, instruct the DTS Decoder to decode to the new bit depth, and decode the previous sample again. if (decodeBits != m_DTSBitDepth && out.bBuffer->GetCount() == 0) { DbgLog((LOG_TRACE, 20, L"::Decode(): The DTS decoder indicated that it outputs %d bits, changing config to %d bits to compensate", bitdepth, decodeBits)); m_DTSBitDepth = decodeBits; FlushDTSDecoder(); nPCMLength = SafeDTSDecode(pOut, pOut_size, m_pDTSDecoderContext->dtsPCMBuffer, 0, 2, &bitdepth, &channels, &CoreSampleRate, &unk4, &HDSampleRate, &unk5, &profile); } } if (nPCMLength <= 0) { DbgLog((LOG_TRACE, 50, L"::Decode() - DTS decoding failed")); FlushDTSDecoder(TRUE); m_bQueueResync = TRUE; continue; } out.wChannels = channels; out.dwSamplesPerSec = HDSampleRate; out.sfFormat = m_DTSBitDepth == 24 ? SampleFormat_24 : SampleFormat_16; out.dwChannelMask = get_channel_mask(channels); // TODO out.wBitsPerSample = bitdepth; int profile_index = 0; while(profile >>= 1) profile_index++; if (profile_index > 7) m_pAVCtx->profile = FF_PROFILE_UNKNOWN; else if (profile == 0 && !m_bsParser.m_DTSHeader.HasCore) m_pAVCtx->profile = FF_PROFILE_DTS_EXPRESS; else m_pAVCtx->profile = DTSProfiles[profile_index]; // TODO: get rid of these m_pAVCtx->sample_rate = HDSampleRate; m_pAVCtx->bits_per_raw_sample = bitdepth; // Send current input time to the delivery function out.rtStart = m_rtStartInputCache; m_rtStartInputCache = AV_NOPTS_VALUE; m_bUpdateTimeCache = TRUE; } // Send to Output if (nPCMLength > 0) { hr = S_OK; out.bBuffer->Append(m_pDTSDecoderContext->dtsPCMBuffer, nPCMLength); out.nSamples = out.bBuffer->GetCount() / get_byte_per_sample(out.sfFormat) / out.wChannels; if (m_pAVCtx->profile != (1 << 7)) { DTSRemapOutputChannels(&out, m_bsParser.m_DTSHeader); } m_pAVCtx->channels = out.wChannels; m_DecodeFormat = out.sfFormat; m_DecodeLayout = out.dwChannelMask; if (SUCCEEDED(PostProcess(&out))) { *hrDeliver = QueueOutput(out); if (FAILED(*hrDeliver)) { return S_FALSE; } } } }
// Solution method void NewtonSolver::Solve(arma::vec& solution, arma::vec& residualHistory, ExitFlagType& exitFlag, arma::mat* pJacobianExternal) { // Parse parameter list Initialise(); // Eventually print the header if (mPrintOutput) { PrintHeader("Newton Method", mMaxIterations, mTolerance); } // Check if dimensions are compatible int problem_size = mpInitialGuess->n_rows; assert( problem_size == solution.n_rows ); // Iterator int iteration = 0; // Assign initial guess solution = *mpInitialGuess; // Initial residual arma::vec residual(problem_size); mpProblem->ComputeF(solution,residual); // Residual norm double residual_norm = arma::norm(residual,2); // Residual history residualHistory.set_size(1+mpParameterList->maxIterations); residualHistory(iteration) = residual_norm; // Eventually print iteration if (mPrintOutput) { PrintIteration(iteration, residual_norm, true); } // Check convergence bool converged = mpConvergenceCriterion->TestConvergence(residual_norm); arma::mat jacobian(problem_size,problem_size); // Newton's method main loop while ( (iteration < mMaxIterations) && (!converged) ) { // Compute Jacobian (eventually use finite differences) if (mpProblemJacobian) { mpProblemJacobian->ComputeDFDU(solution,jacobian); } else { ComputeDFDU(solution,residual,jacobian); } // Linear solve to find direction arma::vec direction = arma::solve( jacobian, -residual); // Update solution solution += mpParameterList->damping*direction; // Update iterator iteration++; // Update residual mpProblem->ComputeF(solution,residual); // Update residual norm residual_norm = arma::norm(residual,2); // Check convergence converged = mpConvergenceCriterion->TestConvergence(residual_norm); // Update residual history residualHistory(iteration) = residual_norm; // Print infos if (mPrintOutput) { PrintIteration(iteration, residual_norm); } } // Post process PostProcess(); // Trim residual history residualHistory.head(iteration); // Assign exit flag if (converged) { exitFlag = AbstractNonlinearSolver::ExitFlagType::converged; } else { exitFlag = AbstractNonlinearSolver::ExitFlagType::notConverged; } // Eventually print final message if (mPrintOutput) { PrintFooter(iteration, exitFlag); } // Output to external jacobian if requested if (pJacobianExternal) { assert( (*pJacobianExternal).n_rows==problem_size); assert( (*pJacobianExternal).n_cols==problem_size); assert( jacobian.n_rows==problem_size); (*pJacobianExternal) = jacobian; } }
void MainFrame::OnMachiningAreaclear(wxCommandEvent& WXUNUSED(event) ) { double cr = 3.; double fr = 0.; double sd = 15.; double si = cr / 2.; if (RunCoreRoughDlg(cr, fr, sd, si)) { GSTsurface *gstsurf = SelectedSurface(); GSTtoolpath *gstbound = SelectedBoundary(); ASSERT((gstsurf != NULL) && (gstbound != NULL)); if (!(gstsurf || gstbound)) return; MachineParams params; // linking parameters params.leadoffdz = 0.1; params.leadofflen = 1.1; params.leadoffrad = 2.0; params.retractzheight = gstsurf->zrg.hi + 5.0; params.leadoffsamplestep = 0.6; // cutting parameters params.toolcornerrad = cr; params.toolflatrad = fr; params.samplestep = 0.4; params.stepdown = sd; params.clearcuspheight = sd / 3.0; // weave parameters params.triangleweaveres = 0.51; params.flatradweaveres = 0.71; // stearing parameters // fixed values controlling the step-forward of the tool and // changes of direction. params.dchangright = 0.17; params.dchangrightoncontour = 0.37; params.dchangleft = -0.41; params.dchangefreespace = -0.6; params.sidecutdisplch = 0.0; params.fcut = 1000; params.fretract = 5000; params.thintol = 0.0001; GSTtoolpath* gsttpath = new GSTtoolpath; gst->gstees.push_back(gsttpath); // define the empty surface SurfX sx(gstsurf->xrg.Inflate(2), gstsurf->yrg.Inflate(2), gstsurf->zrg); gstsurf->PushTrianglesIntoSurface(sx); sx.BuildComponents(); // compress thing ASSERT(gstbound->ftpaths.size() == 1); MakeCorerough(gsttpath->ftpaths, sx, gstbound->ftpaths[0], params); // write result to a file FILE* fpost = fopen("freesteel.tp", "w"); ASSERT(fpost); PostProcess(fpost, gsttpath->ftpaths, params); fclose(fpost); gsttpath->toolshape = ToolShape(params.toolflatrad, params.toolcornerrad, params.toolcornerrad, params.toolcornerrad / 10.0); gsttpath->bound.Append(gstbound->ftpaths[0].pths); gsttpath->UpdateFromPax(); gsttpath->AddToRenderer(&gst->ren1); UpdateActors(); UpdateAnimate(); } }