00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #pragma once
00033
00034 #define OGGCODECS_LOGGING
00035
00036 #include "Theoradecoderdllstuff.h"
00037 #include "theoradecodeoutputpin.h"
00038 #include "theoradecodeinputpin.h"
00039
00040 #include <libilliCore/iBE_Math.h>
00041 #include <math.h>
00042
00043 #include "TheoraDecoder.h"
00044 #include <fstream>
00045 using namespace std;
00046 class TheoraDecodeFilter
00047
00048 : public CTransformFilter
00049
00050 {
00051 public:
00052 friend class TheoraDecodeInputPin;
00053 TheoraDecodeFilter(void);
00054 virtual ~TheoraDecodeFilter(void);
00055
00056
00057 static CUnknown* WINAPI CreateInstance(LPUNKNOWN pUnk, HRESULT *pHr);
00058
00059
00060 virtual HRESULT CheckInputType(const CMediaType* inMediaType);
00061 virtual HRESULT CheckTransform(const CMediaType* inInputMediaType, const CMediaType* inOutputMediaType);
00062 virtual HRESULT DecideBufferSize(IMemAllocator* inAllocator, ALLOCATOR_PROPERTIES* inPropertyRequest);
00063 virtual HRESULT GetMediaType(int inPosition, CMediaType* outOutputMediaType);
00064 virtual HRESULT Transform(IMediaSample* inInputSample, IMediaSample* outOutputSample);
00065
00066
00067 virtual HRESULT Receive(IMediaSample* inSample);
00068
00069 virtual HRESULT SetMediaType(PIN_DIRECTION inDirection, const CMediaType* inMediaType);
00070 virtual HRESULT NewSegment(REFERENCE_TIME inStart, REFERENCE_TIME inEnd, double inRate);
00071
00072 virtual CBasePin* TheoraDecodeFilter::GetPin(int inPinNo);
00073
00074 sTheoraFormatBlock* getTheoraFormatBlock();
00075 void setTheoraFormat(BYTE* inFormatBlock);
00076 protected:
00077
00078 static const unsigned long THEORA_IDENT_HEADER_SIZE = 42;
00079 virtual void ResetFrameCount();
00080
00081 void deleteBufferedPacketsAfter(unsigned long inPacketIndex);
00082 void FillMediaType(CMediaType* outMediaType, unsigned long inSampleSize);
00083 bool FillVideoInfoHeader(VIDEOINFOHEADER* inFormatBuffer);
00084 bool SetSampleParams(IMediaSample* outMediaSample, unsigned long inDataSize, REFERENCE_TIME* inStartTime, REFERENCE_TIME* inEndTime, BOOL inIsSync);
00085 unsigned long mHeight;
00086 unsigned long mWidth;
00087 unsigned long mFrameSize;
00088 unsigned long mFrameCount;
00089 unsigned long mYOffset;
00090 unsigned long mXOffset;
00091 __int64 mFrameDuration;
00092 bool mBegun;
00093 TheoraDecoder* mTheoraDecoder;
00094
00095 vector<StampedOggPacket*> mBufferedPackets;
00096
00097 HRESULT TheoraDecoded (yuv_buffer* inYUVBuffer, IMediaSample* outSample, bool inIsKeyFrame, REFERENCE_TIME inStart, REFERENCE_TIME inEnd);
00098
00099 REFERENCE_TIME mSegStart;
00100 REFERENCE_TIME mSegEnd;
00101 double mPlaybackRate;
00102
00103 __int64 mSeekTimeBase;
00104 __int64 mLastSeenStartGranPos;
00105
00106 sTheoraFormatBlock* mTheoraFormatInfo;
00107 fstream debugLog;
00108 };