VDAudioSourceWAV::VDAudioSourceWAV(VDInputFileWAV *parent) : mpParent(parent) , mBytesPerSample(parent->GetBytesPerSample()) { mSampleFirst = 0; mSampleLast = parent->GetDataLength() / mBytesPerSample; const vdstructex<VDWaveFormat>& format = parent->GetFormat(); memcpy(allocFormat(format.size()), format.data(), format.size()); streamInfo.fccType = streamtypeAUDIO; streamInfo.fccHandler = 0; streamInfo.dwFlags = 0; streamInfo.wPriority = 0; streamInfo.wLanguage = 0; streamInfo.dwInitialFrames = 0; streamInfo.dwScale = mBytesPerSample; streamInfo.dwRate = getWaveFormat()->mDataRate; streamInfo.dwStart = 0; streamInfo.dwLength = VDClampToUint32(mSampleLast); streamInfo.dwSuggestedBufferSize = 0; streamInfo.dwQuality = 0xffffffff; streamInfo.dwSampleSize = mBytesPerSample; }
VideoSourceImages::VideoSourceImages(VDInputFileImages *parent) : mpParent(parent) , mCachedHandleFrame(-1) { mSampleFirst = 0; mpTargetFormatHeader.resize(sizeof(BITMAPINFOHEADER)); allocFormat(sizeof(BITMAPINFOHEADER)); invalidateFrameBuffer(); // This has to be 1 so that read() doesn't kick away the request. mSampleLast = mpParent->GetFrameCount(); getFrame(0); // Fill out streamInfo extern const VDFraction& VDPreferencesGetImageSequenceFrameRate(); const VDFraction& fr = VDPreferencesGetImageSequenceFrameRate(); streamInfo.fccType = VDAVIStreamInfo::kTypeVideo; streamInfo.fccHandler = NULL; streamInfo.dwFlags = 0; streamInfo.dwCaps = 0; streamInfo.wPriority = 0; streamInfo.wLanguage = 0; streamInfo.dwScale = fr.getLo(); streamInfo.dwRate = fr.getHi(); streamInfo.dwStart = 0; streamInfo.dwLength = VDClampToUint32(mSampleLast); streamInfo.dwInitialFrames = 0; streamInfo.dwSuggestedBufferSize = 0; streamInfo.dwQuality = (DWORD)-1; streamInfo.dwSampleSize = 0; streamInfo.rcFrameLeft = 0; streamInfo.rcFrameTop = 0; streamInfo.rcFrameRight = (uint16)getImageFormat()->biWidth; streamInfo.rcFrameBottom = (uint16)getImageFormat()->biHeight; }
void Frameserver::Go(IVDubServerLink *ivdsl, char *name) { int server_index = -1; lpszFsname = name; // prepare the sources... if (!vSrc->setTargetFormat(g_dubOpts.video.mInputFormat)) if (!vSrc->setTargetFormat(nsVDPixmap::kPixFormat_XRGB8888)) if (!vSrc->setTargetFormat(nsVDPixmap::kPixFormat_RGB888)) if (!vSrc->setTargetFormat(nsVDPixmap::kPixFormat_XRGB1555)) if (!vSrc->setTargetFormat(nsVDPixmap::kPixFormat_Pal8)) throw MyError("The decompression codec cannot decompress to an RGB format. This is very unusual. Check that any \"Force YUY2\" options are not enabled in the codec's properties."); IVDStreamSource *pVSS = vSrc->asStream(); FrameSubset videoset(mSubset); const VDFraction frameRateTimeline(g_project->GetTimelineFrameRate()); VDPosition startFrame; VDPosition endFrame; VDConvertSelectionTimesToFrames(*opt, mSubset, frameRateTimeline, startFrame, endFrame); InitVideoStreamValuesStatic(vInfo, vSrc, aSrc, opt, &mSubset, &startFrame, &endFrame); const VDPixmap& px = vSrc->getTargetFormat(); const VDFraction& srcFAR = vSrc->getPixelAspectRatio(); filters.prepareLinearChain(&g_filterChain, px.w, px.h, px.format, vInfo.mFrameRatePreFilter, -1, srcFAR); mpVideoFrameSource = new VDFilterFrameVideoSource; mpVideoFrameSource->Init(vSrc, filters.GetInputLayout()); filters.SetVisualAccelDebugEnabled(false); filters.SetAccelEnabled(VDPreferencesGetFilterAccelEnabled()); filters.SetAsyncThreadCount(VDPreferencesGetFilterThreadCount()); filters.initLinearChain(NULL, 0, &g_filterChain, mpVideoFrameSource, px.w, px.h, px.format, px.palette, vInfo.mFrameRatePreFilter, -1, srcFAR); filters.ReadyFilters(); InitVideoStreamValuesStatic2(vInfo, opt, &filters, frameRateTimeline); InitAudioStreamValuesStatic(aInfo, aSrc, opt); vdfastvector<IVDVideoSource *> vsrcs(1, vSrc); mVideoFrameMap.Init(vsrcs, vInfo.start_src, vInfo.mFrameRateTimeline / vInfo.mFrameRate, &mSubset, vInfo.end_dst, opt->video.mbUseSmartRendering, opt->video.mode == DubVideoOptions::M_NONE, opt->video.mbPreserveEmptyFrames, &filters, false, false); if (opt->audio.fEndAudio) videoset.deleteRange(endFrame, videoset.getTotalFrames()); if (opt->audio.fStartAudio) videoset.deleteRange(0, startFrame); VDDEBUG("Video subset:\n"); videoset.dump(); if (aSrc) AudioTranslateVideoSubset(audioset, videoset, vInfo.mFrameRateTimeline, aSrc->getWaveFormat(), !opt->audio.fEndAudio && (videoset.empty() || videoset.back().end() == pVSS->getEnd()) ? aSrc->getEnd() : 0, NULL); VDDEBUG("Audio subset:\n"); audioset.dump(); if (aSrc) { audioset.offset(aSrc->msToSamples(-opt->audio.offset)); lAudioSamples = VDClampToUint32(audioset.getTotalFrames()); } else lAudioSamples = 0; lVideoSamples = VDClampToUint32(mVideoFrameMap.size()); vSrc->streamBegin(true, false); const VDPixmapLayout& outputLayout = filters.GetOutputLayout(); mFrameSize = VDPixmapCreateLinearLayout(mFrameLayout, nsVDPixmap::kPixFormat_RGB888, outputLayout.w, outputLayout.h, 4); VDPixmapLayoutFlipV(mFrameLayout); if (aSrc) aSrc->streamBegin(true, false); // usurp the window VDUIFrame *pFrame = VDUIFrame::GetFrame(hwnd); mpUIFrame = pFrame; pFrame->Attach(this); guiSetTitle(hwnd, IDS_TITLE_FRAMESERVER); // create dialog box mbExit = false; if (hwndStatus = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_SERVER), hwnd, Frameserver::StatusDlgProc, (LPARAM)this)) { // hide the main window ShowWindow(hwnd, SW_HIDE); // create the frameserver server_index = ivdsl->CreateFrameServer(name, hwnd); if (server_index>=0) { // kick us into high priority SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); // enter window loop { MSG msg; while(!mbExit) { BOOL result = GetMessage(&msg, NULL, 0, 0); if (result == (BOOL)-1) break; if (!result) { PostQuitMessage(msg.wParam); break; } TranslateMessage(&msg); DispatchMessage(&msg); } } // return to normal priority SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); ivdsl->DestroyFrameServer(server_index); } if (IsWindow(hwndStatus)) DestroyWindow(hwndStatus); // show the main window ShowWindow(hwnd, SW_SHOW); } // unsubclass pFrame->Detach(); if (vSrc) { IVDStreamSource *pVSS = vSrc->asStream(); pVSS->streamEnd(); } if (server_index<0) throw MyError("Couldn't create frameserver"); }