Fixed directshow... again.

Originally committed to SVN as r1939.
This commit is contained in:
Rodrigo Braz Monteiro 2008-03-07 00:09:58 +00:00
parent d181c3a7f6
commit eb5be3115a
2 changed files with 7 additions and 80 deletions

View File

@ -93,15 +93,15 @@ void FFT::DoTransform (size_t n_samples,float *input,float *output_r,float *outp
ai[2] = sm2; ai[2] = sm2;
for (j=i,n=0;n<BlockEnd;j++,n++) { for (j=i,n=0;n<BlockEnd;j++,n++) {
ar[0] = w*ar[1] - ar[2]; k = j + BlockEnd;
ar[2] = ar[1];
ar[1] = ar[0];
ar[0] = w*ar[1] - ar[2];
ai[0] = w*ai[1] - ai[2]; ai[0] = w*ai[1] - ai[2];
ar[2] = ar[1];
ai[2] = ai[1]; ai[2] = ai[1];
ar[1] = ar[0];
ai[1] = ai[0]; ai[1] = ai[0];
k = j + BlockEnd;
tr = ar[0]*output_r[k] - ai[0]*output_i[k]; tr = ar[0]*output_r[k] - ai[0]*output_i[k];
ti = ar[0]*output_i[k] + ai[0]*output_r[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 // Divide everything by number of samples if it's an inverse transform
if (inverse) { if (inverse) {
float denom = (float)n_samples; float denom = 1.0f/(float)n_samples;
for (i=0;i<n_samples;i++) { for (i=0;i<n_samples;i++) {
output_r[i] /= denom; output_r[i] *= denom;
output_i[i] /= denom; output_i[i] *= denom;
} }
} }
} }

View File

@ -59,79 +59,6 @@
#include "video_provider_dshow.h" #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 // Constructor
// Based on Haali's code for DirectShowSource2 // Based on Haali's code for DirectShowSource2