PageRenderTime 47ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/src/VirtualDub/h/DubProcess.h

https://github.com/chattama/modplus
C Header | 151 lines | 115 code | 30 blank | 6 comment | 1 complexity | 886afbdbeaad50ecd33035adeecdc5a9 MD5 | raw file
  1. #ifndef f_VD2_DUBPROCESS_H
  2. #define f_VD2_DUBPROCESS_H
  3. #include <vd2/system/thread.h>
  4. #include <vd2/system/time.h>
  5. #include <vd2/system/profile.h>
  6. #include <vd2/Kasumi/pixmaputils.h>
  7. #include <deque>
  8. class IVDMediaOutput;
  9. class IVDMediaOutputStream;
  10. class IVDDubberOutputSystem;
  11. class VDAudioPipeline;
  12. class DubOptions;
  13. class IVDVideoSource;
  14. class IVDVideoDisplay;
  15. class AudioStream;
  16. class VideoTelecineRemover;
  17. class VDStreamInterleaver;
  18. class IVDVideoCompressor;
  19. class IVDAsyncBlitter;
  20. class IDubStatusHandler;
  21. class VDDubProcessThread : public VDThread, protected IVDTimerCallback {
  22. public:
  23. VDDubProcessThread();
  24. ~VDDubProcessThread();
  25. void SetAbortSignal(volatile bool *pAbort);
  26. void SetStatusHandler(IDubStatusHandler *pStatusHandler);
  27. void SetInputDisplay(IVDVideoDisplay *pVideoDisplay);
  28. void SetOutputDisplay(IVDVideoDisplay *pVideoDisplay);
  29. void SetVideoFilterOutput(FilterStateInfo *pfsi, void *pBuffer, const VDPixmap& px);
  30. void SetVideoSources(IVDVideoSource *const *pVideoSources, uint32 count);
  31. void SetAudioSourcePresent(bool present);
  32. void SetAudioCorrector(AudioStreamL3Corrector *pCorrector);
  33. void SetVideoIVTC(VideoTelecineRemover *pIVTC);
  34. void SetVideoCompressor(IVDVideoCompressor *pCompressor);
  35. void Init(const DubOptions& opts, DubVideoStreamInfo *pvsi, IVDDubberOutputSystem *pOutputSystem, AVIPipe *pVideoPipe, VDAudioPipeline *pAudioPipe, VDStreamInterleaver *pStreamInterleaver);
  36. void Shutdown();
  37. void Abort();
  38. void UpdateFrames();
  39. bool GetError(MyError& e) {
  40. if (mbError) {
  41. e.TransferFrom(mError);
  42. return true;
  43. }
  44. return false;
  45. }
  46. uint32 GetActivityCounter() {
  47. return mActivityCounter;
  48. }
  49. const char *GetCurrentAction() {
  50. return mpCurrentAction;
  51. }
  52. VDSignal *GetBlitterSignal();
  53. void SetThrottle(float f);
  54. protected:
  55. enum VideoWriteResult {
  56. kVideoWriteOK, // Frame was processed and written
  57. kVideoWritePushedPendingEmptyFrame, // A pending null frame was processed instead of the current frame.
  58. kVideoWriteBufferedEmptyFrame,
  59. kVideoWriteDelayed,
  60. kVideoWriteBuffered,
  61. kVideoWriteDiscarded,
  62. };
  63. void NextSegment();
  64. VideoWriteResult WriteVideoFrame(void *buffer, int exdata, int droptype, LONG lastSize, VDPosition sampleFrame, VDPosition targetFrame, VDPosition origDisplayFrame, VDPosition displayFrame, VDPosition timelineFrame, int srcIndex);
  65. void WritePendingEmptyVideoFrame();
  66. void WriteAudio(void *buffer, long lActualBytes, long lActualSamples);
  67. void ThreadRun();
  68. void TimerCallback();
  69. void UpdateAudioStreamRate();
  70. static bool AsyncReinitDisplayCallback(int pass, void *pThisAsVoid, void *, bool aborting);
  71. const DubOptions *opt;
  72. VDStreamInterleaver *mpInterleaver;
  73. VDLoopThrottle mLoopThrottle;
  74. // OUTPUT
  75. IVDMediaOutput *mpAVIOut;
  76. IVDMediaOutputStream *mpAudioOut; // alias: AVIout->audioOut
  77. IVDMediaOutputStream *mpVideoOut; // alias: AVIout->videoOut
  78. IVDDubberOutputSystem *mpOutputSystem;
  79. // AUDIO SECTION
  80. VDAudioPipeline *mpAudioPipe;
  81. AudioStreamL3Corrector *mpAudioCorrector;
  82. bool mbAudioPresent;
  83. // VIDEO SECTION
  84. AVIPipe *mpVideoPipe;
  85. IVDVideoDisplay *mpInputDisplay;
  86. IVDVideoDisplay *mpOutputDisplay;
  87. VideoTelecineRemover *mpInvTelecine;
  88. DubVideoStreamInfo *mpVInfo;
  89. IVDAsyncBlitter *mpBlitter;
  90. FilterStateInfo mfsi;
  91. IDubStatusHandler *mpStatusHandler;
  92. IVDVideoCompressor *mpVideoCompressor;
  93. vdblock<char> mVideoCompressionBuffer;
  94. void *mpVideoFilterOutputBuffer;
  95. VDPixmap mVideoFilterOutputPixmap;
  96. typedef vdfastvector<IVDVideoSource *> VideoSources;
  97. VideoSources mVideoSources;
  98. std::deque<uint32> mVideoNullFrameDelayQueue; ///< This is a queue used to track null frames between non-null frames. It runs parallel to a video codec's internal B-frame delay queue.
  99. uint32 mPendingNullVideoFrames;
  100. // PREVIEW
  101. bool mbAudioFrozen;
  102. bool mbAudioFrozenValid;
  103. bool mbSyncToAudioEvenClock;
  104. long lDropFrames;
  105. // DECOMPRESSION PREVIEW
  106. vdautoptr<IVDVideoDecompressor> mpVideoDecompressor;
  107. bool mbVideoDecompressorEnabled;
  108. bool mbVideoDecompressorPending;
  109. bool mbVideoDecompressorErrored;
  110. VDPixmapBuffer mVideoDecompBuffer;
  111. // ERROR HANDLING
  112. MyError mError;
  113. bool mbError;
  114. volatile bool *mpAbort;
  115. const char *volatile mpCurrentAction;
  116. VDAtomicInt mActivityCounter;
  117. VDAtomicInt mRefreshFlag;
  118. VDRTProfileChannel mProcessingProfileChannel;
  119. VDCallbackTimer mFrameTimer;
  120. };
  121. #endif