STDMETHODIMP Tffvfw::deliverProcessedSample(TffPict &pict) { if (!convert || (LONG)convert->dx!=icd->lpbiInput->biWidth || (LONG)convert->dy!=icd->lpbiInput->biHeight) { if (convert) { delete convert; } convert=new Tconvert(decVFW,icd->lpbiInput->biWidth,abs(icd->lpbiInput->biHeight)); } unsigned char *dst[4]= {(unsigned char*)icd->lpOutput,NULL,NULL}; stride_t dstStride[4]= {icd->lpbiInput->biWidth*csp_getInfo(colorspace)->Bpp,0,0}; return convert->convert(pict,colorspace^(decVFW->getFlip()?FF_CSP_FLAGS_VFLIP:0),dst,dstStride)?ICERR_OK:ICERR_BADFORMAT; }
void TencStats::init(unsigned int Idx,unsigned int Idy,uint64_t csp) { dx=Idx; dy=Idy; const TcspInfo *cspInfo=csp_getInfo(csp); for (int i=0; i<3; i++) { mult[i]=(1<<cspInfo->shiftX[i])*(1<<cspInfo->shiftY[i]); } sumQuants=0; count=0; sumFramesize=0; sumPsnrY=sumPsnrU=sumPsnrV=0; memset(quantCount,0,sizeof(quantCount)); }
HRESULT TimgFilterOutput::process(TffPict &pict,uint64_t dstcsp,unsigned char *dst[4],int dstStride[4],LONG &dstSize,const ToutputVideoSettings *cfg) { checkBorder(pict); if ( !convert || convert->dx!=pict.rectFull.dx || convert->dy!=pict.rectFull.dy || old_cspOptionsRgbInterlaceMode != cfg->cspOptionsRgbInterlaceMode || old_highQualityRGB != cfg->highQualityRGB || old_dithering != cfg->dithering || old_outputLevelsMode != cfg->cspOptionsOutputLevelsMode || old_inputLevelsMode != cfg->cspOptionsInputLevelsMode || old_IturBt != cfg->cspOptionsIturBt) { old_highQualityRGB = cfg->highQualityRGB; old_dithering = cfg->dithering; old_cspOptionsRgbInterlaceMode = cfg->cspOptionsRgbInterlaceMode; old_outputLevelsMode = cfg->cspOptionsOutputLevelsMode; old_inputLevelsMode = cfg->cspOptionsInputLevelsMode; old_IturBt = cfg->cspOptionsIturBt; if (convert) { delete convert; } vramBenchmark.init(); convert=new Tconvert(deci,pict.rectFull.dx,pict.rectFull.dy,dstSize); } stride_t cspstride[4] = {0,0,0,0}; unsigned char *cspdst[4] = {0,0,0,0}; const TcspInfo *outcspInfo=csp_getInfo(dstcsp); for (int i=0; i<4; i++) { cspstride[i]=dstStride[0]>>outcspInfo->shiftX[i]; if (i==0) { cspdst[i]=dst[i]; } else { cspdst[i]=cspdst[i-1]+cspstride[i-1]*(pict.rectFull.dy>>outcspInfo->shiftY[i-1]); } } if (convert->m_wasChange) { vramBenchmark.onChange(); } uint64_t cspret=convert->convert(pict, (dstcsp ^ (cfg->flip ? FF_CSP_FLAGS_VFLIP : 0)) | ((!pict.film && (pict.fieldtype & FIELD_TYPE::MASK_INT)) ? FF_CSP_FLAGS_INTERLACED : 0), cspdst, cspstride, vramBenchmark.get_vram_indirect()); vramBenchmark.update(); return cspret?S_OK:E_FAIL; }
void TsubtitleVobsub::drawalpha( int x0, int y0, unsigned int w, unsigned int h, const unsigned char* srcY, const unsigned char *srcaY, int strideY, const unsigned char* srcUV, const unsigned char *srcaUV, int strideUV, const TprintPrefs &prefs, unsigned char **dst, const stride_t *stride) { const TcspInfo *cspInfo = csp_getInfo(prefs.csp); if (x0<0 || y0<0 || w==0 || h==0) { return; } TrenderedVobsubWord wrd; for (int i=0; i<3; i++) { wrd.dx[i]=w>>cspInfo->shiftX[i]; wrd.dy[i]=h>>cspInfo->shiftY[i]; } wrd.dxChar=wrd.dx[0]; wrd.dyChar=wrd.dy[0]; wrd.bmp[0]=(unsigned char*)srcY; wrd.msk[0]=(unsigned char*)srcaY; wrd.bmp[1]=wrd.bmp[2]=(unsigned char*)srcUV; wrd.msk[1]=wrd.msk[2]=(unsigned char*)srcaUV; wrd.bmpmskstride[0]=strideY; wrd.bmpmskstride[1]=wrd.bmpmskstride[2]=strideUV; TrenderedSubtitleLine ln(&wrd); TrenderedSubtitleLines lines(&ln); if (!prefs.vobchangeposition) { TprintPrefs prefs2=prefs; prefs2.xpos=-x0; prefs2.ypos=-y0; lines.print(prefs2,dst,stride); } else { lines.print(prefs,dst,stride); } }
STDMETHODIMP TffProcVideo::deliverProcessedSample(TffPict &pict) { if (!outcspInfo || outcspInfo->id!=(outcsp&FF_CSPS_MASK)) { outcspInfo=csp_getInfo(outcsp); } if (pict.csp!=outcsp) { if (!convert) { convert=new Tconvert(deci,pict.rectFull.dx,pict.rectFull.dy); } if (dst[0]) { convert->convert(pict,outcsp,dst,dstStride); } else { pict.convertCSP(outcsp,dstbuf,convert); for (unsigned int i=0; i<pict.cspInfo.numPlanes; i++) { dst[i]=pict.data[i]; dstStride[i]=pict.stride[i]; } } } else if (dst[0]) for (unsigned int i=0; i<pict.cspInfo.numPlanes; i++) { TffPict::copy(dst[i],dstStride[i],pict.data[i],pict.stride[i],(pict.rectFull.dx*outcspInfo->Bpp)>>outcspInfo->shiftX[i],pict.rectFull.dy>>outcspInfo->shiftY[i]); } else for (unsigned int i=0; i<pict.cspInfo.numPlanes; i++) {
STDMETHODIMP_(LRESULT) TffdshowEnc::compress(const BITMAPINFOHEADER *inhdr, const uint8_t *src, size_t /*srclen*/, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop) { if (firstrun) { firstrun = false; showTrayIcon(); } _mm_empty(); inColorspace = getBMPcolorspace(inhdr, coSettings->incsps); if (inColorspace == FF_CSP_NULL) { return ICERR_BADFORMAT; } if (coSettings->flip) { inColorspace ^= FF_CSP_FLAGS_VFLIP; } if (globalSettings->isDyInterlaced && dy > (unsigned int)globalSettings->dyInterlaced) { inColorspace |= FF_CSP_FLAGS_INTERLACED; } params.quant = -1; params.frametype = FRAME_TYPE::UNKNOWN; params.keyframe = false; switch (cfgcomode) { case ENC_MODE::CBR: case ENC_MODE::VBR_QUAL: break; case ENC_MODE::VBR_QUANT: params.quant = getQuantQuant(); break; case ENC_MODE::UNKNOWN: break; default: DPRINTF(_l("Invalid encoding mode")); return ICERR_ERROR; } params.gray = !!coSettings->gray; //if (!src || !srclen) return ICERR_ERROR; if (pict.csp != inColorspace) { pict.csp = inColorspace; pict.cspInfo = *csp_getInfo(pict.csp); } pict.setSize(dx, dy); pict.data[0] = (unsigned char*)src; pict.stride[0] = dx * pict.cspInfo.Bpp; if (src) { csp_yuv_adj_to_plane(pict.csp, &pict.cspInfo, dy, pict.data, pict.stride); csp_yuv_order(pict.csp, pict.data, pict.stride); csp_vflip(pict.csp, &pict.cspInfo, pict.data, pict.stride, dy); } if (!coSettings->isProc || !ffproc) { bool directYV12 = false; for (Tcsps::const_iterator c = enccsps.begin(); c != enccsps.end(); c++) if (*c == pict.csp) { directYV12 = true; break; } if (!directYV12) { if (!convert) { convert = new Tconvert(this, dx, dy); } if (!ownpict.data[0]) { ownpict.alloc(dx, dy, enccsp, ownpictbuf); } if (src) { convert->convert(pict, ownpict.csp, ownpict.data, ownpict.stride); } //srclen=ownpict.cspInfo.bpp*ownpict.rectFull.dx*ownpict.rectFull.dy/8; pict = ownpict; if (!src) { pict.data[0] = NULL; } } } params.length = 0; params.priv = NULL; pict.rtStart = rtStart; pict.rtStop = rtStop; if (src && coSettings->isProc && ffproc) { HRESULT hr = ffproc->processPict(params.framenum, pict, enccsp); if (hr == S_OK) { hr = src ? enc->compress(pict, params) : enc->flushEnc(pict, params); } return hr; } else { return src ? enc->compress(pict, params) : enc->flushEnc(pict, params); } }
char_t* csp_getName(uint64_t csp, char_t *buf, size_t len) { return csp_getName2(csp_getInfo(csp), csp, buf, len); }
uint64_t getBMPcolorspace(const BITMAPINFOHEADER *hdr, const TcspInfos &forcedCsps) { uint64_t csp; switch (hdr->biCompression) { case BI_RGB: switch (hdr->biBitCount) { case 15: csp = FF_CSP_RGB15 | FF_CSP_FLAGS_VFLIP; break; case 16: csp = FF_CSP_RGB16 | FF_CSP_FLAGS_VFLIP; break; case 24: csp = FF_CSP_RGB24 | FF_CSP_FLAGS_VFLIP; break; case 32: csp = FF_CSP_RGB32 | FF_CSP_FLAGS_VFLIP; break; default: return FF_CSP_NULL; } break; case FOURCC_I420: case FOURCC_IYUV: csp = FF_CSP_420P | FF_CSP_FLAGS_YUV_ADJ | FF_CSP_FLAGS_YUV_ORDER; break; case FOURCC_YV12: csp = FF_CSP_420P | FF_CSP_FLAGS_YUV_ADJ; break; case FOURCC_YUYV: case FOURCC_YUY2: case FOURCC_V422: csp = FF_CSP_YUY2; break; case FOURCC_YVYU: csp = FF_CSP_YVYU; break; case FOURCC_UYVY: csp = FF_CSP_UYVY; break; case FOURCC_VYUY: csp = FF_CSP_VYUY; break; case FOURCC_Y800: csp = FF_CSP_Y800; break; case FOURCC_444P: case FOURCC_YV24: csp = FF_CSP_444P; break; case FOURCC_422P: csp = FF_CSP_422P; break; case FOURCC_YV16: csp = FF_CSP_422P | FF_CSP_FLAGS_YUV_ADJ; break; case FOURCC_411P: case FOURCC_Y41B: csp = FF_CSP_411P; break; case FOURCC_410P: csp = FF_CSP_410P; break; case FOURCC_420R: csp = FF_CSP_420P10; break; case FOURCC_422R: csp = FF_CSP_422P10; break; case FOURCC_444R: csp = FF_CSP_444P10; break; case FOURCC_P016: csp = FF_CSP_P016; break; case FOURCC_P010: csp = FF_CSP_P010; break; case FOURCC_P210: csp = FF_CSP_P210; break; case FOURCC_P216: csp = FF_CSP_P216; break; case FOURCC_AYUV: csp = FF_CSP_AYUV; break; case FOURCC_Y416: csp = FF_CSP_Y416; break; default: return FF_CSP_NULL; } bool ok; if (!forcedCsps.empty()) { ok = std::find(forcedCsps.begin(), forcedCsps.end(), csp_getInfo(csp)) != forcedCsps.end(); } else { ok = true; } return ok ? csp : FF_CSP_NULL; }
//------------------------------- decompress ------------------------------- bool TvideoCodecUncompressed::beginDecompress(TffPictBase &pict,FOURCC infcc,const CMediaType &mt,int sourceFlags) { switch (codecId) { case CODEC_ID_YV12: csp=FF_CSP_420P|FF_CSP_FLAGS_YUV_ADJ; break; case CODEC_ID_I420: csp=FF_CSP_420P|FF_CSP_FLAGS_YUV_ADJ|FF_CSP_FLAGS_YUV_ORDER; break; case CODEC_ID_YUY2: csp=FF_CSP_YUY2; break; case CODEC_ID_YVYU: csp=FF_CSP_YVYU; break; case CODEC_ID_UYVY: csp=FF_CSP_UYVY; break; case CODEC_ID_VYUY: csp=FF_CSP_VYUY; break; case CODEC_ID_RGB2: csp=FF_CSP_RGB24|FF_CSP_FLAGS_VFLIP; break; case CODEC_ID_RGB3: csp=FF_CSP_RGB32|FF_CSP_FLAGS_VFLIP; break; case CODEC_ID_RGB5: csp=FF_CSP_RGB15|FF_CSP_FLAGS_VFLIP; break; case CODEC_ID_RGB6: csp=FF_CSP_RGB16|FF_CSP_FLAGS_VFLIP; break; case CODEC_ID_BGR2: csp=FF_CSP_BGR24; break; case CODEC_ID_BGR3: csp=FF_CSP_BGR32; break; case CODEC_ID_BGR5: csp=FF_CSP_BGR15; break; case CODEC_ID_BGR6: csp=FF_CSP_BGR16; break; case CODEC_ID_CLJR: csp=FF_CSP_CLJR; break; case CODEC_ID_444P: csp=FF_CSP_444P; break; case CODEC_ID_422P: csp=FF_CSP_422P; break; case CODEC_ID_411P: csp=FF_CSP_411P; break; case CODEC_ID_410P: csp=FF_CSP_410P; break; case CODEC_ID_Y800: csp=FF_CSP_Y800; break; case CODEC_ID_NV12: csp=FF_CSP_NV12|FF_CSP_FLAGS_YUV_ADJ; break; case CODEC_ID_YV16: csp=FF_CSP_422P|FF_CSP_FLAGS_YUV_ADJ; break; default: return false; } cspInfo=csp_getInfo(pict.csp=csp); if (csp_isRGB(csp)) { stride[0]=ffalign(pict.rectFull.dx*cspInfo->Bpp<<3, 32)>>3; BITMAPINFOHEADER bih; ExtractBIH(mt,&bih); if (bih.biHeight < 0) { csp &= ~FF_CSP_FLAGS_VFLIP; } } else {
char_t* csp_getName(int csp,char_t *buf,unsigned int len) { return csp_getName(csp_getInfo(csp),csp,buf,len); }