📄 dmo_videodecoder.c
字号:
props.cBuffers = 1; props.cbBuffer = this->m_sDestType.lSampleSize; props.cbAlign = 1; props.cbPrefix = 0; this->m_pDMO_Filter->m_pAll->vt->SetProperties(this->m_pDMO_Filter->m_pAll, &props, &props1); this->m_pDMO_Filter->m_pAll->vt->Commit(this->m_pDMO_Filter->m_pAll);#endif this->iv.m_State = START;}void DMO_VideoDecoder_StopInternal(DMO_VideoDecoder *this){ // this->m_pDMO_Filter->Stop(this->m_pDMO_Filter); //??? why was this here ??? m_pOurOutput->SetFramePointer(0);}int DMO_VideoDecoder_DecodeInternal(DMO_VideoDecoder *this, const void* src, int size, int is_keyframe, char* imdata){// IMediaSample* sample = 0; int result; unsigned long status; // to be ignored by M$ specs DMO_OUTPUT_DATA_BUFFER db; CMediaBuffer* bufferin;//+ uint8_t* imdata = dest ? dest->Data() : 0; Debug printf("DMO_VideoDecoder_DecodeInternal(%p,%p,%d,%d,%p)\n",this,src,size,is_keyframe,imdata);// this->m_pDMO_Filter->m_pAll->vt->GetBuffer(this->m_pDMO_Filter->m_pAll, &sample, 0, 0, 0);// if (!sample)// {// Debug printf("ERROR: null sample\n");// return -1;// }#ifdef WIN32_LOADER Setup_FS_Segment();#endif bufferin = CMediaBufferCreate(size, (void*)src, size, 0); result = this->m_pDMO_Filter->m_pMedia->vt->ProcessInput(this->m_pDMO_Filter->m_pMedia, 0, (IMediaBuffer*)bufferin, DMO_INPUT_DATA_BUFFERF_SYNCPOINT, 0, 0); ((IMediaBuffer*)bufferin)->vt->Release((IUnknown*)bufferin); if (result != S_OK) { /* something for process */ if (result != S_FALSE) printf("ProcessInputError r:0x%x=%d (keyframe: %d)\n", result, result, is_keyframe); else printf("ProcessInputError FALSE ?? (keyframe: %d)\n", is_keyframe); return size; } db.rtTimestamp = 0; db.rtTimelength = 0; db.dwStatus = 0; db.pBuffer = (IMediaBuffer*) CMediaBufferCreate(this->m_sDestType.lSampleSize, imdata, 0, 0); result = this->m_pDMO_Filter->m_pMedia->vt->ProcessOutput(this->m_pDMO_Filter->m_pMedia, (imdata) ? 0 : DMO_PROCESS_OUTPUT_DISCARD_WHEN_NO_BUFFER, 1, &db, &status); //m_pDMO_Filter->m_pMedia->vt->Lock(m_pDMO_Filter->m_pMedia, 0); if ((unsigned)result == DMO_E_NOTACCEPTING) printf("ProcessOutputError: Not accepting\n"); else if (result) printf("ProcessOutputError: r:0x%x=%d %ld stat:%ld\n", result, result, status, db.dwStatus); ((IMediaBuffer*)db.pBuffer)->vt->Release((IUnknown*)db.pBuffer); //int r = m_pDMO_Filter->m_pMedia->vt->Flush(m_pDMO_Filter->m_pMedia); //printf("FLUSH %d\n", r); return 0;}/* * bits == 0 - leave unchanged *///int SetDestFmt(DMO_VideoDecoder * this, int bits = 24, fourcc_t csp = 0);int DMO_VideoDecoder_SetDestFmt(DMO_VideoDecoder *this, int bits, unsigned int csp){ HRESULT result; int should_test=1; Debug printf("DMO_VideoDecoder_SetDestFmt (%p, %d, %d)\n",this,bits,(int)csp); /* if (!CImage::Supported(csp, bits)) return -1;*/ // BitmapInfo temp = m_obh; if (!csp) // RGB { int ok = true; switch (bits) { case 15: this->m_sDestType.subtype = MEDIASUBTYPE_RGB555; break; case 16: this->m_sDestType.subtype = MEDIASUBTYPE_RGB565; break; case 24: this->m_sDestType.subtype = MEDIASUBTYPE_RGB24; break; case 32: this->m_sDestType.subtype = MEDIASUBTYPE_RGB32; break; default: ok = false; break; } if (ok) { this->iv.m_obh.biBitCount=bits; if( bits == 15 || bits == 16 ) { this->iv.m_obh.biSize=sizeof(BITMAPINFOHEADER)+12; this->iv.m_obh.biCompression=3;//BI_BITFIELDS this->iv.m_obh.biSizeImage=abs((int)(2*this->iv.m_obh.biWidth*this->iv.m_obh.biHeight)); } if( bits == 16 ) { this->iv.m_obh.colors[0]=0xF800; this->iv.m_obh.colors[1]=0x07E0; this->iv.m_obh.colors[2]=0x001F; } else if ( bits == 15 ) { this->iv.m_obh.colors[0]=0x7C00; this->iv.m_obh.colors[1]=0x03E0; this->iv.m_obh.colors[2]=0x001F; } else { this->iv.m_obh.biSize = sizeof(BITMAPINFOHEADER); this->iv.m_obh.biCompression = 0; //BI_RGB //this->iv.m_obh.biHeight = labs(this->iv.m_obh.biHeight); this->iv.m_obh.biSizeImage = labs(this->iv.m_obh.biWidth * this->iv.m_obh.biHeight) * ((this->iv.m_obh.biBitCount + 7) / 8); } } //.biSizeImage=abs(temp.biWidth*temp.biHeight*((temp.biBitCount+7)/8)); } else { // YUV int ok = true; switch (csp) { case fccYUY2: this->m_sDestType.subtype = MEDIASUBTYPE_YUY2; break; case fccYV12: this->m_sDestType.subtype = MEDIASUBTYPE_YV12; break; case fccIYUV: this->m_sDestType.subtype = MEDIASUBTYPE_IYUV; break; case fccI420: this->m_sDestType.subtype = MEDIASUBTYPE_I420; break; case fccUYVY: this->m_sDestType.subtype = MEDIASUBTYPE_UYVY; break; case fccYVYU: this->m_sDestType.subtype = MEDIASUBTYPE_YVYU; break; case fccYVU9: this->m_sDestType.subtype = MEDIASUBTYPE_YVU9; default: ok = false; break; } if (ok) { if (csp != 0 && csp != 3 && this->iv.m_obh.biHeight > 0) this->iv.m_obh.biHeight *= -1; // YUV formats uses should have height < 0 this->iv.m_obh.biSize = sizeof(BITMAPINFOHEADER); this->iv.m_obh.biCompression=csp; this->iv.m_obh.biBitCount=bits; this->iv.m_obh.biSizeImage = labs(this->iv.m_obh.biWidth * this->iv.m_obh.biHeight) * ((this->iv.m_obh.biBitCount + 7) / 8); } } this->m_sDestType.lSampleSize = this->iv.m_obh.biSizeImage; memcpy(&(this->m_sVhdr2->bmiHeader), &this->iv.m_obh, sizeof(this->iv.m_obh)); this->m_sVhdr2->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); if (this->m_sVhdr2->bmiHeader.biCompression == 3) this->m_sDestType.cbFormat = sizeof(VIDEOINFOHEADER) + 12; else this->m_sDestType.cbFormat = sizeof(VIDEOINFOHEADER); switch(csp) { case fccYUY2: if(!(this->m_Caps & CAP_YUY2)) should_test=false; break; case fccYV12: if(!(this->m_Caps & CAP_YV12)) should_test=false; break; case fccIYUV: if(!(this->m_Caps & CAP_IYUV)) should_test=false; break; case fccI420: if(!(this->m_Caps & CAP_I420)) should_test=false; break; case fccUYVY: if(!(this->m_Caps & CAP_UYVY)) should_test=false; break; case fccYVYU: if(!(this->m_Caps & CAP_YVYU)) should_test=false; break; case fccYVU9: if(!(this->m_Caps & CAP_YVU9)) should_test=false; break; }#ifdef WIN32_LOADER Setup_FS_Segment();#endif// if(should_test)// result = this->m_pDMO_Filter->m_pOutputPin->vt->QueryAccept(this->m_pDMO_Filter->m_pOutputPin, &this->m_sDestType);// else// result = -1; // test accept if(!this->m_pDMO_Filter) return 0; result = this->m_pDMO_Filter->m_pMedia->vt->SetOutputType(this->m_pDMO_Filter->m_pMedia, 0, &this->m_sDestType, DMO_SET_TYPEF_TEST_ONLY); if (result != 0) { if (csp) printf("Warning: unsupported color space\n"); else printf("Warning: unsupported bit depth\n"); this->m_sDestType.lSampleSize = this->iv.m_decoder.biSizeImage; memcpy(&(this->m_sVhdr2->bmiHeader), &this->iv.m_decoder, sizeof(this->iv.m_decoder)); this->m_sVhdr2->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); if (this->m_sVhdr2->bmiHeader.biCompression == 3) this->m_sDestType.cbFormat = sizeof(VIDEOINFOHEADER) + 12; else this->m_sDestType.cbFormat = sizeof(VIDEOINFOHEADER); return -1; } memcpy( &this->iv.m_decoder, &this->iv.m_obh, sizeof(this->iv.m_obh));// m_obh=temp;// if(csp)// m_obh.biBitCount=BitmapInfo::BitCount(csp); this->iv.m_bh->biBitCount = bits; //DMO_VideoDecoder_Restart(this); this->m_pDMO_Filter->m_pMedia->vt->SetOutputType(this->m_pDMO_Filter->m_pMedia, 0, &this->m_sDestType, 0); return 0;}int DMO_VideoDecoder_SetDirection(DMO_VideoDecoder *this, int d){ this->iv.m_obh.biHeight = (d) ? this->iv.m_bh->biHeight : -this->iv.m_bh->biHeight; this->m_sVhdr2->bmiHeader.biHeight = this->iv.m_obh.biHeight; return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -