tffdshowvideoinputpin.cpp.svn-base
来自「ffshow源码」· SVN-BASE 代码 · 共 577 行 · 第 1/2 页
SVN-BASE
577 行
avgTimePerFrame=0; codecId=CODEC_ID_NONE;rawDecode=false; autosubflnm[0]=oldSubSearchDir[0]='\0';oldSubHeuristic=false;}STDMETHODIMP TffdshowVideoInputPin::GetAllocator(IMemAllocator** ppAllocator){ if (!raw_codec(codecId)) return TinputPin::GetAllocator(ppAllocator); else { CheckPointer(ppAllocator, E_POINTER); if (m_pAllocator==NULL) { m_pAllocator=&allocator; m_pAllocator->AddRef(); } m_pAllocator->AddRef(); *ppAllocator=m_pAllocator; return NOERROR; } }STDMETHODIMP TffdshowVideoInputPin::NotifyAllocator(IMemAllocator *pAllocator,BOOL bReadOnly){ HRESULT hr=TinputPin::NotifyAllocator(pAllocator,bReadOnly); if (FAILED(hr)) return hr; usingOwnAllocator=(pAllocator==(IMemAllocator*)&allocator); return S_OK;}STDMETHODIMP TffdshowVideoInputPin::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate){ fv->lockReceive(); HRESULT hr=TinputPin::NewSegment(tStart,tStop,dRate); fv->unlockReceive(); return hr;}STDMETHODIMP TffdshowVideoInputPin::Receive(IMediaSample* pSample){ AM_MEDIA_TYPE *pmt=NULL; if (SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt) { CMediaType mt(*pmt); SetMediaType(&mt); allocator.mtChanged=false; DeleteMediaType(pmt); } return TinputPin::Receive(pSample);}HRESULT TffdshowVideoInputPin::decompress(IMediaSample *pSample,long *srcLen){ BYTE *bitstream; if (pSample->GetPointer(&bitstream)!=S_OK) { *srcLen=-1; return S_FALSE; } *srcLen=pSample->GetActualDataLength(); if (bitstream && strippacket) StripPacket(bitstream,*srcLen); return video->decompress(bitstream,*srcLen,pSample);}HRESULT TffdshowVideoInputPin::getAVIfps(unsigned int *fps1000){ if (!fps1000 || avgTimePerFrame==0) return S_FALSE; *fps1000=(unsigned int)(REF_SECOND_MULT*1000/avgTimePerFrame); return S_OK;}HRESULT TffdshowVideoInputPin::getAverageTimePerFrame(int64_t *avg){ if (IsConnected() && m_mt.cbFormat) *avg=getAvgTimePerFrame(m_mt); else *avg=avgTimePerFrame; return S_OK;}HRESULT TffdshowVideoInputPin::getAVIdimensions(unsigned int *x,unsigned int *y){ if (!x || !y) return E_POINTER; *x=pictIn.rectFull.dx;*y=pictIn.rectFull.dy; return (pictIn.rectFull.dx==0 || pictIn.rectFull.dy==0)?S_FALSE:S_OK;}HRESULT TffdshowVideoInputPin::getInputSAR(unsigned int *a1,unsigned int *a2){ if (!a1 || !a2) return E_POINTER; *a1=pictIn.rectFull.sar.num;*a2=pictIn.rectFull.sar.den; return *a1 && *a2?S_OK:S_FALSE;}HRESULT TffdshowVideoInputPin::getInputDAR(unsigned int *a1,unsigned int *a2){ if (!a1 || !a2) return E_POINTER; *a1=pictIn.rectFull.dar().num;*a2=pictIn.rectFull.dar().den; return *a1 && *a2?S_OK:S_FALSE;}HRESULT TffdshowVideoInputPin::getMovieSource(const TvideoCodecDec* *moviePtr){ if (!moviePtr) return S_FALSE; *moviePtr=video; return S_OK;}FOURCC TffdshowVideoInputPin::getMovieFOURCC(void){ return codecId!=CODEC_ID_NONE?biIn.bmiHeader.biCompression:0;}HRESULT TffdshowVideoInputPin::getFrameTime(unsigned int framenum,unsigned int *sec){ if (!sec) return E_POINTER; if (avgTimePerFrame==0) return E_FAIL; *sec=(unsigned int)(avgTimePerFrame*framenum/REF_SECOND_MULT); return S_OK;}HRESULT TffdshowVideoInputPin::getFrameTimeMS(unsigned int framenum,unsigned int *msec){ if (!msec) return E_POINTER; if (avgTimePerFrame==0) return E_FAIL; *msec=(unsigned int)(avgTimePerFrame*framenum/10000); return S_OK;}HRESULT TffdshowVideoInputPin::calcMeanQuant(float *quant){ if (!quant) return E_POINTER; if (!video) return S_FALSE; *quant=video->calcMeanQuant(); return S_OK;}HRESULT TffdshowVideoInputPin::quantsAvailable(void){ if (!video) return E_FAIL; return video->quants?S_OK:S_FALSE;}HRESULT TffdshowVideoInputPin::getQuantMatrices(uint8_t intra8[64],uint8_t inter8[64],uint8_t intra4luma[16],uint8_t intra4chroma[16],uint8_t inter4luma[16],uint8_t inter4chroma[16]){ if (!intra8 || !inter8) return E_POINTER; if (!video) return E_FAIL; if ((!video->inter_matrix && !video->intra_matrix) || (video->intra_matrix[0]==0 && video->inter_matrix[0]==0)) return E_UNEXPECTED; if (video->inter_matrix) for (int i=0;i<64;i++) inter8[i]=(uint8_t)video->inter_matrix[i]; else memset(inter8,0,64); if (video->intra_matrix) for (int i=0;i<64;i++) intra8[i]=(uint8_t)video->intra_matrix[i]; else memset(intra8,0,64); if (inter4luma) if (video->inter_matrix_luma) for (int i=0;i<16;i++) inter4luma[i]=(uint8_t)video->inter_matrix_luma[i]; else memset(inter4luma,0,16); if (inter4chroma) if (video->inter_matrix_chroma) for (int i=0;i<16;i++) inter4chroma[i]=(uint8_t)video->inter_matrix_chroma[i]; else memset(inter4chroma,0,16); if (intra4luma) if (video->intra_matrix_luma) for (int i=0;i<16;i++) intra4luma[i]=(uint8_t)video->intra_matrix_luma[i]; else memset(intra4luma,0,16); if (intra4chroma) if (video->intra_matrix_chroma) for (int i=0;i<16;i++) intra4chroma[i]=(uint8_t)video->intra_matrix_chroma[i]; else memset(intra4chroma,0,16); return S_OK; }HRESULT TffdshowVideoInputPin::getInCodecString(char_t *buf,size_t buflen){ if (!buf) return E_POINTER; if (video) { char_t name[60]; tsnprintf(buf,buflen,_l("%s (%s)"),fourcc2str(biIn.bmiHeader.biCompression,name,60),video->getName()); buf[buflen-1]='\0'; } else buf[0]='\0'; return S_OK;}bool TffdshowVideoInputPin::waitForKeyframes(void){ return !rawDecode && !(video && mpeg12_codec(codecId) && biIn.bmiHeader.biCompression!=FOURCC_MPEG);}void TffdshowVideoInputPin::setSampleSkipped(void){ if (video) video->onDiscontinuity();}const char_t* TffdshowVideoInputPin::findAutoSubflnm(IcheckSubtitle *checkSubtitle,const char_t *searchDir,bool heuristic){ if (IsConnected()==FALSE) return _l(""); const char_t *AVIname=getFileSourceName(); if (AVIname[0]=='\0') return _l(""); if (autosubflnm[0]=='\0' || oldSubHeuristic!=heuristic || stricmp(oldSubSearchDir,searchDir)!=0) { oldSubHeuristic=heuristic;strcpy(oldSubSearchDir,searchDir); TsubtitlesFile::findSubtitlesFile(AVIname,searchDir,autosubflnm,MAX_PATH,heuristic,checkSubtitle); } return autosubflnm;}//================================ TffdshowVideoEncInputPin ================================STDMETHODIMP TffdshowVideoEncInputPin::NonDelegatingQueryInterface(REFIID riid, void** ppv){ if (riid==IID_IMixerPinConfig) { isOverlay=true; return GetInterface<IMixerPinConfig>(this,ppv); } else return TffdshowVideoInputPin::NonDelegatingQueryInterface(riid, ppv);}STDMETHODIMP TffdshowVideoEncInputPin::SetRelativePosition(THIS_ IN DWORD dwLeft, IN DWORD dwTop, IN DWORD dwRight, IN DWORD dwBottom){ DPRINTF(_l(" SetRelativePosition")); return S_OK;} STDMETHODIMP TffdshowVideoEncInputPin::GetRelativePosition(THIS_ OUT DWORD *pdwLeft,OUT DWORD *pdwTop,OUT DWORD *pdwRight,OUT DWORD *pdwBottom){ DPRINTF(_l(" GetRelativePosition")); return S_OK;} STDMETHODIMP TffdshowVideoEncInputPin::SetZOrder(THIS_ IN DWORD dwZOrder){ DPRINTF(_l(" SetZOrder")); return S_OK;} STDMETHODIMP TffdshowVideoEncInputPin::GetZOrder(THIS_ OUT DWORD *pdwZOrder){ DPRINTF(_l(" GetZOrder")); return S_OK;} STDMETHODIMP TffdshowVideoEncInputPin::SetColorKey(THIS_ IN COLORKEY *pColorKey){ DPRINTF(_l(" SetColorKey")); return S_OK;} STDMETHODIMP TffdshowVideoEncInputPin::GetColorKey(THIS_ OUT COLORKEY *pColorKey,OUT DWORD *pColor){ DPRINTF(_l(" GetColorKey")); return S_OK;} STDMETHODIMP TffdshowVideoEncInputPin::SetBlendingParameter(THIS_ IN DWORD dwBlendingParameter){ DPRINTF(_l(" SetBlendingParameter")); return S_OK;} STDMETHODIMP TffdshowVideoEncInputPin::GetBlendingParameter(THIS_ OUT DWORD *pdwBlendingParameter){ DPRINTF(_l(" GetBlendingParameter")); return S_OK;} STDMETHODIMP TffdshowVideoEncInputPin::SetAspectRatioMode(THIS_ IN AM_ASPECT_RATIO_MODE amAspectRatioMode){ DPRINTF(_l(" SetAspectRatioMode")); return S_OK;} STDMETHODIMP TffdshowVideoEncInputPin::GetAspectRatioMode(THIS_ OUT AM_ASPECT_RATIO_MODE* pamAspectRatioMode){ DPRINTF(_l(" GetAspectRatioMode")); return S_OK;} STDMETHODIMP TffdshowVideoEncInputPin::SetStreamTransparent(THIS_ IN BOOL bStreamTransparent){ DPRINTF(_l(" SetStreamTransparent")); return S_OK;} STDMETHODIMP TffdshowVideoEncInputPin::GetStreamTransparent(THIS_ OUT BOOL *pbStreamTransparent){ DPRINTF(_l(" GetStreamTransparent")); return S_OK;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?