From eb5be3115afe575cd68dbc71c3d193a3d7a81d83 Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro <zeratul@cellosoft.com> Date: Fri, 7 Mar 2008 00:09:58 +0000 Subject: [PATCH] Fixed directshow... again. Originally committed to SVN as r1939. --- aegisub/fft.cpp | 14 +++--- aegisub/video_provider_dshow.cpp | 73 -------------------------------- 2 files changed, 7 insertions(+), 80 deletions(-) diff --git a/aegisub/fft.cpp b/aegisub/fft.cpp index 8e5ed215a..3d6582685 100644 --- a/aegisub/fft.cpp +++ b/aegisub/fft.cpp @@ -93,15 +93,15 @@ void FFT::DoTransform (size_t n_samples,float *input,float *output_r,float *outp ai[2] = sm2; for (j=i,n=0;n<BlockEnd;j++,n++) { - ar[0] = w*ar[1] - ar[2]; - ar[2] = ar[1]; - ar[1] = ar[0]; + k = j + BlockEnd; + ar[0] = w*ar[1] - ar[2]; ai[0] = w*ai[1] - ai[2]; + ar[2] = ar[1]; ai[2] = ai[1]; + ar[1] = ar[0]; ai[1] = ai[0]; - k = j + BlockEnd; tr = ar[0]*output_r[k] - ai[0]*output_i[k]; ti = ar[0]*output_i[k] + ai[0]*output_r[k]; @@ -119,10 +119,10 @@ void FFT::DoTransform (size_t n_samples,float *input,float *output_r,float *outp // Divide everything by number of samples if it's an inverse transform if (inverse) { - float denom = (float)n_samples; + float denom = 1.0f/(float)n_samples; for (i=0;i<n_samples;i++) { - output_r[i] /= denom; - output_i[i] /= denom; + output_r[i] *= denom; + output_i[i] *= denom; } } } diff --git a/aegisub/video_provider_dshow.cpp b/aegisub/video_provider_dshow.cpp index c9f658525..d0f2b2006 100644 --- a/aegisub/video_provider_dshow.cpp +++ b/aegisub/video_provider_dshow.cpp @@ -59,79 +59,6 @@ #include "video_provider_dshow.h" -/////////////////////////////////// -// DirectShow Video Provider class -class DirectShowVideoProvider: public VideoProvider { - struct DF { - public: - REFERENCE_TIME timestamp; // DS timestamp that we used for this frame - AegiVideoFrame frame; - - DF() : timestamp(-1) { } - DF(AegiVideoFrame f) : timestamp(-1), frame(f) { } - DF(const DF& f) { operator=(f); } - DF& operator=(const DF& f) { timestamp = f.timestamp; frame = f.frame; return *this; } - }; - -private: - wxArrayInt frameTime; - - unsigned int last_fnum; - unsigned int width; - unsigned int height; - unsigned int num_frames; - double fps; - int64_t defd; - - HRESULT OpenVideo(wxString _filename); - void CloseVideo(); - - static void ReadFrame(__int64 timestamp, unsigned format, unsigned bpp, const unsigned char *frame, unsigned width, unsigned height, int stride, unsigned arx, unsigned ary, void *arg); - int NextFrame(DF &df,int &fn); - - void RegROT(); - void UnregROT(); - - REFERENCE_TIME duration; - DF rdf; - CComPtr<IVideoSink> m_pR; - CComPtr<IMediaControl> m_pGC; - CComPtr<IMediaSeeking> m_pGS; - HANDLE m_hFrameReady; - bool m_registered; - DWORD m_rot_cookie; - -public: - DirectShowVideoProvider(wxString _filename, double _fps=0.0); - ~DirectShowVideoProvider(); - - void RefreshSubtitles(); - - const AegiVideoFrame DoGetFrame(int n); - void GetFloatFrame(float* Buffer, int n); - - int GetPosition() { return last_fnum; }; - int GetFrameCount() { return num_frames; }; - double GetFPS() { return fps; }; - int GetWidth() { return width; }; - int GetHeight() { return height; }; - wxString GetDecoderName() { return _("DirectShow"); } - - void OverrideFrameTimeList(wxArrayInt list); -}; - - - -/////////// -// Factory -class DirectShowVideoProviderFactory : public VideoProviderFactory { -public: - VideoProvider *CreateProvider(wxString video,double fps=0.0) { return new DirectShowVideoProvider(video,fps); } - DirectShowVideoProviderFactory() : VideoProviderFactory(_T("dshow")) {} -} registerDShow; - - - /////////////// // Constructor // Based on Haali's code for DirectShowSource2 -- GitLab