static float computeDiff2(ADMImage *src1,ADMImage *src2,ADMImage *cand) { float df=0; int delta; uint32_t ww,hh; uint8_t *s1,*s2,*d1; int a1,a2,t1; s1=YPLANE(src1); s2=YPLANE(src2); d1=YPLANE(cand); ww=src1->_width; hh=src1->_height; for(int y=0;y<hh;y++) for(int x=0;x<ww;x++) { a1=*s1; a2=*s2; t1=*d1; if(a1==a2) ; else if(a1>a2) { if(t1 <=a1 && t1>=a2) df+=1; else df-=1; }else if(t1 <=a2 && t1>=a1) df+=1; else df-=1; s1++; s2++; d1++; } return df; }
uint8_t ADMVideoChromaShift::getFrameNumberNoAlloc(uint32_t frame, uint32_t *len, ADMImage *data, uint32_t *flags) { if(frame>= _info.nb_frames) return 0; ADM_assert(_param); // read uncompressed frame if(!_in->getFrameNumberNoAlloc(frame, len,_uncompressed,flags)) return 0; // copy luma as it is left untouched uint32_t w=_info.width; uint32_t h=_info.height; // uint8_t *in,*out; uint32_t page; page=(w*h); memcpy(YPLANE(data),YPLANE(_uncompressed),page); if(!_param->u) { memcpy(UPLANE(data),UPLANE(_uncompressed),page>>2); }
uint8_t AVDMVideoWhirl::getFrameNumberNoAlloc(uint32_t frame, uint32_t *len, ADMImage *data, uint32_t *flags) { uint32_t page=_info.width*_info.height; ADMImage *cur,*prev; double frac; if(frame>= _info.nb_frames) return 0; if(frame>STEP_SIZE) frac=1; else frac=(double)frame/(double)STEP_SIZE; if(frame>(_info.nb_frames-1)) return 0; *len=(page*3)>>1; if(!_in->getFrameNumberNoAlloc(frame,len,_uncompressed,flags)) return 0; data->copyInfo(_uncompressed); Process(YPLANE(_uncompressed),YPLANE(data),_info.width,_info.height,frac); Process(UPLANE(_uncompressed),UPLANE(data),_info.width>>1,_info.height>>1,frac); Process(VPLANE(_uncompressed),VPLANE(data),_info.width>>1,_info.height>>1,frac); return 1; }
static void merge(ADMImage *src1,ADMImage *src2,ADMImage *tgt) { uint32_t ww,hh; uint8_t *s1,*s2,*out; int o; s1=YPLANE(src1); s2=YPLANE(src2); out=YPLANE(tgt); ww=src1->_width; hh=src1->_height; for(int y=0;y<hh;y++) for(int x=0;x<ww;x++) { o=*s1+*s2; o>>=1; *out=o; s1++; s2++; out++; } }
uint8_t ADMVideoMPdelogo::getFrameNumberNoAlloc(uint32_t frame, uint32_t *len, ADMImage *data, uint32_t *flags) { if(frame>=_info.nb_frames) { printf("MPdelogo : Filter : out of bound!\n"); return 0; } ADM_assert(_param); ADMImage *curImage; char txt[256]; curImage=vidCache->getImage(frame); if(!curImage) { printf("MPdelogo : error getting frame\n"); return 0; } delogo(YPLANE(data), YPLANE(curImage), _info.width, _info.width, _info.width, _info.height, _param->xoff, _param->yoff, _param->lw, _param->lh, _param->band, _param->show,0); delogo(UPLANE(data), UPLANE(curImage), _info.width>>1, _info.width>>1, _info.width>>1, _info.height>>1,_param->xoff>>1, _param->yoff>>1, _param->lw>>1, _param->lh>>1, _param->band>>1, _param->show,0); delogo(VPLANE(data), VPLANE(curImage), _info.width>>1, _info.width>>1, _info.width>>1, _info.height>>1,_param->xoff>>1, _param->yoff>>1, _param->lw>>1, _param->lh>>1, _param->band>>1, _param->show,0); vidCache->unlockAll(); return 1; }
uint8_t ADMVideoDropOut::getFrameNumberNoAlloc(uint32_t frame, uint32_t *len, ADMImage *data, uint32_t *flags) { UNUSED_ARG(flags); uint32_t uvlen; uint32_t dlen,dflags; ADMImage *_next; ADMImage *_previous; ADMImage *_current; // printf("\n DropOut : %lu\n",frame); uvlen= _info.width*_info.height; *len=uvlen+(uvlen>>1); if(frame> _info.nb_frames-1) return 0; if(!frame || (frame==_info.nb_frames-1)) { _current=vidCache->getImage(frame); if(!_current) return 0; memcpy(YPLANE(data),YPLANE(_current),uvlen); memcpy(UPLANE(data),UPLANE(_current),uvlen>>2); memcpy(VPLANE(data),VPLANE(_current),uvlen>>2); vidCache->unlockAll(); return 1; }
uint8_t flyHue::process(void ) { uint8_t *src,*dst; uint32_t stride; float hue,sat; hue=param.hue*M_PI/180.; sat=(100+param.saturation)/100.; memcpy(YPLANE(_yuvBufferOut),YPLANE(_yuvBuffer),_w*_h); // copy luma // Do it! HueProcess_C(VPLANE(_yuvBufferOut), UPLANE(_yuvBufferOut), VPLANE(_yuvBuffer), UPLANE(_yuvBuffer), _w>>1,_w>>1, _w>>1,_h>>1, hue, sat); // Copy half source to display dst=_yuvBufferOut->data+_w*_h; src=_yuvBuffer->data+_w*_h; stride=_w>>1; for(uint32_t y=0;y<_h;y++) // We do both u & v! { memcpy(dst,src,stride>>1); dst+=stride; src+=stride; } return 1; }
// // Remove y and v just keep U and expand it // uint8_t ADMVideoDenoise::getFrameNumberNoAlloc(uint32_t frame, uint32_t *len, ADMImage *data, uint32_t *flags) { //uint32_t x,w; uint32_t page; ADM_assert(_param); if(frame>= _info.nb_frames) return 0; if(!_in->getFrameNumberNoAlloc(frame, len,_uncompressed,flags)) return 0; page=_info.width*_info.height; *len=(page*3)>>1; if((_lastFrame+1)!=frame) // async jump { // just copy it memcpy(YPLANE(data),YPLANE(_uncompressed),page); memcpy(UPLANE(data),UPLANE(_uncompressed),page>>2); memcpy(VPLANE(data),VPLANE(_uncompressed),page>>2); memcpy(YPLANE(_locked),YPLANE(_uncompressed),page); memcpy(UPLANE(_locked),UPLANE(_uncompressed),page>>2); memcpy(VPLANE(_locked),VPLANE(_uncompressed),page>>2); _lastFrame=frame; return 1; }
uint8_t ADMVideoEq2::getFrameNumberNoAlloc(uint32_t frame, uint32_t *len, ADMImage *data, uint32_t *flags) { ADMImage *mysrc=NULL; if(frame>=_info.nb_frames) return 0; mysrc=vidCache->getImage(frame); if(!mysrc) return 0; uint32_t w,h; w=_info.width; h=_info.height; #ifdef ADM_CPU_X86 if(CpuCaps::hasMMX()) { affine_1d_MMX(&(settings.param[0]),YPLANE(data),YPLANE(mysrc),w,h); w>>=1; h>>=1; affine_1d_MMX(&(settings.param[2]),UPLANE(data),UPLANE(mysrc),w,h); affine_1d_MMX(&(settings.param[1]),VPLANE(data),VPLANE(mysrc),w,h); } else #endif {
uint8_t ADMVideoMosaic::getFrameNumberNoAlloc(uint32_t frame, uint32_t *len, ADMImage *data, uint32_t *flags) { if(frame>=_info.nb_frames) { printf("Filter : out of bound!\n"); return 0; } ADM_assert(_param); ADMImage *curImage; char txt[256]; for(int y=0;y<_param->vz;y++) for(int x=0;x<_param->hz;x++) { curImage=vidCache->getImage(frame+y*_param->hz+x); if(!curImage) continue; if(_param->show) { sprintf(txt," %02d",frame+x+y*_param->hz); drawString(curImage,2,0,txt); } uint8_t *src[3]; uint8_t *dst[3]; int ssrc[3]; int ddst[3]; uint32_t page; page=_in->getInfo()->width*_in->getInfo()->height; src[0]=YPLANE(curImage); src[1]=UPLANE(curImage); src[2]=VPLANE(curImage); ssrc[0]=_in->getInfo()->width; ssrc[1]=ssrc[2]=_in->getInfo()->width>>1; page=_info.width*tinyH; dst[0]=YPLANE(data)+page*y+tinyW*x; dst[1]=UPLANE(data)+((page*y)/4)+((tinyW*x)/2); dst[2]=VPLANE(data)+((page*y)/4)+((tinyW*x)/2); ddst[0]=_info.width; ddst[1]=ddst[2]=_info.width>>1; sws_scale(_context,src,ssrc,0,_in->getInfo()->height,dst,ddst); } vidCache->unlockAll(); return 1; }
void update(void ) { uint8_t *src,*dst; uint32_t stride; int32_t T,D,B,B2; ASHARP_PARAM *_param=&myHue; uint32_t ww,hh; download(); ww=incoming->getInfo()->width; hh=incoming->getInfo()->height; // parameters floating point to fixed point convertion T = (int)(_param->t*(4<<7)); D = (int)(_param->d*(4<<7)); B = (int)(256-_param->b*64); B2= (int)(256-_param->b*48); // clipping (recommended for SIMD code) if (T<-(4<<7)) T = -(4<<7); // yes, negatives values are accepted if (D<0) D = 0; if (B<0) B = 0; if (B2<0) B2 = 0; if (T>(32*(4<<7))) T = (32*(4<<7)); if (D>(16*(4<<7))) D = (16*(4<<7)); if (B>256) B = 256; if (B2>256) B2 = 256; memcpy(YPLANE(imgdisplay),YPLANE(imgsrc),ww*hh); asharp_run_c( imgdisplay->GetWritePtr(PLANAR_Y), imgdisplay->GetPitch(PLANAR_Y), hh, ww, T, D, B, B2, myHue.bf); // Copy half source to display dst=imgdisplay->data; src=imgsrc->data; stride=ww; for(uint32_t y=0;y<hh;y++) // We do both u & v! { memcpy(dst,src,stride>>1); dst+=stride; src+=stride; } // COL_yv12rgb( w, h,imgdisplay->data,(uint8_t *)rgbbuffer ); }
//************************************************************* uint8_t ADMVideoLavPPDeint::getFrameNumberNoAlloc(uint32_t frame, uint32_t *len, ADMImage *data, uint32_t *flags) { if(frame>= _info.nb_frames) return 0; // read uncompressed frame if(!_in->getFrameNumberNoAlloc(frame, len,_uncompressed,flags)) return 0; // const uint8_t *iBuff[3]; uint8_t *oBuff[3]; int strideTab[3],strideTab2[3]; oBuff[0]=YPLANE(data); oBuff[1]=UPLANE(data); oBuff[2]=VPLANE(data); iBuff[0]=YPLANE(_uncompressed); iBuff[1]=UPLANE(_uncompressed); iBuff[2]=VPLANE(_uncompressed); strideTab[0]=strideTab2[0]=_info.width; strideTab[1]=strideTab2[1]=_info.width>>1; strideTab[2]=strideTab2[2]=_info.width>>1; int type; if(_uncompressed->flags&AVI_KEY_FRAME) type=1; else if(_uncompressed->flags & AVI_B_FRAME) type=3; else type=2; pp_postprocess( iBuff, strideTab, oBuff, strideTab2, _info.width, _info.height, NULL, 0, ppmode, ppcontext, type); // I ? data->copyInfo(_uncompressed); return 1; }
uint8_t ADMVideoFlipV::getFrameNumberNoAlloc(uint32_t frame, uint32_t *len, ADMImage *data, uint32_t *flags) { if(frame>= _info.nb_frames) return 0; // read uncompressed frame if(!_in->getFrameNumberNoAlloc(frame, len,_uncompressed,flags)) return 0; uint8_t *in,*out; uint32_t stride=_info.width; uint32_t h=_info.height; uint32_t page,qpage; page=stride*h; qpage=page>>2; in=YPLANE(_uncompressed); out=YPLANE(data)+(h-1)*stride; // flip y for(uint32_t y=h;y>0;y--) { memcpy(out,in,stride); in+=stride; out-=stride; } // Flip U & V stride>>=1; in=UPLANE(_uncompressed); out=UPLANE(data)+qpage-stride; // flip u for(uint32_t y=h>>1;y>0;y--) { memcpy(out,in,stride); in+=stride; out-=stride; } in=VPLANE(_uncompressed); out=VPLANE(data)+qpage-stride; // flip u for(uint32_t y=h>>1;y>0;y--) { memcpy(out,in,stride); in+=stride; out-=stride; } data->copyInfo(_uncompressed); return 1; }
uint32_t ADMImage::lumaDiff(ADMImage *src1,ADMImage *src2,uint32_t noise) { #if 1 && defined( ARCH_X86 ) || defined (ARCH_X86_64) uint32_t r1,r2; if(CpuCaps::hasMMX()) { return computeDiffMMX(YPLANE(src1),YPLANE(src2),noise,src1->_width*src1->_height); } #endif return computeDiff(YPLANE(src1),YPLANE(src2),noise,src1->_width*src1->_height); }
uint32_t ADMImage::lumaDiff(ADMImage *src1,ADMImage *src2,uint32_t noise) { #ifdef ADM_CPU_X86 uint32_t r1,r2; if(CpuCaps::hasMMX()) { return computeDiffMMX(YPLANE(src1),YPLANE(src2),noise,src1->_width*src1->_height); } #endif return computeDiff(YPLANE(src1),YPLANE(src2),noise,src1->_width*src1->_height); }
static uint8_t unblend(ADMImage *tgt,ADMImage *src,ADMImage *srcP) { int delta; uint32_t ww,hh; uint8_t *s1,*s2,*d1; int a1,a2,t1; tinyUnblend(YPLANE(tgt),YPLANE(src),YPLANE(srcP),tgt->_width,tgt->_height); tinyUnblend(UPLANE(tgt),UPLANE(src),UPLANE(srcP),tgt->_width>>1,tgt->_height>>1); tinyUnblend(VPLANE(tgt),VPLANE(src),VPLANE(srcP),tgt->_width>>1,tgt->_height>>1); return 1; }
static uint8_t restore(ADMImage *tgt,ADMImage *srcP,ADMImage *src,ADMImage *srcN,ADMImage *srcNN) { int delta; uint32_t ww,hh; uint8_t *s1,*s2,*d1; int a1,a2,t1; tinyRestore(YPLANE(tgt),YPLANE(srcP),YPLANE(src),YPLANE(srcN),YPLANE(srcNN),tgt->_width,tgt->_height); tinyRestore(UPLANE(tgt),UPLANE(srcP),UPLANE(src),UPLANE(srcN),UPLANE(srcNN),tgt->_width>>1,tgt->_height>>1); tinyRestore(VPLANE(tgt),VPLANE(srcP),VPLANE(src),VPLANE(srcN),VPLANE(srcNN),tgt->_width>>1,tgt->_height>>1); return 1; }
// 1 // Get in range in 121 + coeff matrix // 1 // // If the value is too far away we ignore it // else we blend //__________________________________________________________________ uint8_t ADMVideoSubtitle::getFrameNumberNoAlloc(uint32_t frame, uint32_t *len, ADMImage *data, uint32_t *flags) { double f; uint32_t time,srch; uint32_t absFrame=frame+_info.orgFrame; // printf("\n Stabilize : %lu\n",frame); _uncompressed=data; if(frame>=_info.nb_frames) { printf("Filter : out of bound!\n"); return 0; } if(!_in->getFrameNumberNoAlloc(frame, len,data,flags)) return 0; // if no subtitle return... if(!_subs) return 1; // compute time stamp f=absFrame*1000000./_info.fps1000; time=(uint32_t) floor(f); // Do we have it already ? if(time<=_subs[_oldline].endTime && time >=_subs[_oldline].startTime) { aprintf("Sub: cached %lu %lu %lu\n",time,_subs[_oldline].startTime,_subs[_oldline].endTime); blend(YPLANE(data),_conf->_baseLine); // re-use it return 1; } srch=search(time); // we got the right one if(srch!=SUB_OUT) // we got something... { _oldline=srch; aprintf("Sub: Using line %d\n",srch); //printf("\n %s \n",_subs[_oldline].string); displayString(&(_subs[_oldline])); blend(YPLANE(data),_conf->_baseLine); } return 1; }
/** Interleave frame*2 and frame*2+1 */ uint8_t AVDMVideoUnStackField::getFrameNumberNoAlloc(uint32_t frame, uint32_t *len, ADMImage *data, uint32_t *flags) { uint32_t ref,ref2; ADMImage *ptr1,*ptr2; if(frame>=_info.nb_frames) return 0; if(!_in->getFrameNumberNoAlloc(frame, len, _uncompressed, flags)) return 0; vidFielUnStack(_info.width ,_info.height,YPLANE(_uncompressed),YPLANE(data)); data->copyInfo(_uncompressed); return 1; }
/* Returns the number of difference (interlacing) found */ uint32_t ADMVideoTelecide::getMatch( ADMImage *image ) { uint32_t m=0,x,y; uint8_t *p,*n,*c; p=YPLANE(image) ; c=p+ _info.width; n=c+ _info.width; for(y=_info.height>>2; y >2 ; y--) { for(x=_info.width;x>0;x--) { if( (*c-*p)*(*c-*n) >MATCH_THRESH) m++; p++;c++;n++; } p+=3*_info.width; c+=3*_info.width; n+=3*_info.width; } return m; }
uint8_t ADMVideoFields::doBlend(ADMImage *src,ADMImage *dst) { uint32_t w,h,x; //,y; uint8_t *n,*p,*c,*e2; uint8_t *f; uint8_t *yplane; w=_info.width; h=_info.height; f=YPLANE(dst); yplane=YPLANE(src); p=yplane; c=yplane; n=c+w; e2=_motionmask2+w; // First line // always blend for(x=w;x>0;x--) { *f++=(*c+*n)>>1; n++; c++; } #if (defined( ARCH_X86) || defined(ARCH_X86_64)) && defined(ASM_BLEND) if(CpuCaps::hasMMX()) blend_MMX(p,c,n,e2,f); else #endif blend_C(p,c,n,e2,f); // Last line for(x=w;x>0;x--) { *f++=(*c+*p)>>1; p++; c++; } return 1; }
ADMVideoDenoise::ADMVideoDenoise( AVDMGenericVideoStream *in,CONFcouple *couples) { if(distMatrixDone==false) { buildDistMatrix(); distMatrixDone=true; } _in=in; memcpy(&_info,_in->getInfo(),sizeof(_info)); uint32_t page; _info.encoding=1; page= _in->getInfo()->width*_in->getInfo()->height; // _uncompressed=new uint8_t [page]; _uncompressed=new ADMImage(_in->getInfo()->width,_in->getInfo()->height); ADM_assert(_uncompressed); // _locked=new uint8_t [page]; _locked=new ADMImage(_in->getInfo()->width,_in->getInfo()->height); ADM_assert(_locked); // _lockcount=new uint8_t [page]; _lockcount=new ADMImage(_in->getInfo()->width,_in->getInfo()->height); memset(YPLANE(_lockcount),0,page); memset(UPLANE(_lockcount),0,page>>2); memset(VPLANE(_lockcount),0,page>>2); _param=NULL; if(couples) { _param=NEW(NOISE_PARAM); GET(lumaLock); GET(lumaThreshold); GET(chromaLock); GET(chromaThreshold); GET(sceneChange); } else { #define XXX 1 _param=NEW(NOISE_PARAM); _param->lumaLock= 4*XXX; _param->lumaThreshold= 10*XXX; _param->chromaLock= 8*XXX; _param->chromaThreshold= 16*XXX; _param->sceneChange= 30*XXX; } _lastFrame=0xfffffff0; }
uint8_t AVDMVideoKeepOdd::getFrameNumberNoAlloc(uint32_t frame, uint32_t *len, ADMImage *data, uint32_t *flags) { //static Image in,out; if(frame>= _info.nb_frames) return 0; if(!_in->getFrameNumberNoAlloc(frame, len,_uncompressed,flags)) return 0; uint32_t w=_info.width; uint32_t h=_info.height; vidFieldKeepOdd( w, h, YPLANE(_uncompressed),YPLANE(data)); data->copyInfo(_uncompressed); return 1; }
uint8_t flyEq2::process(void) { Eq2Settings mySettings; #if 0 printf("Contrast :%f\n",param.contrast); printf("brightness :%f\n",param.brightness); printf("saturation :%f\n",param.saturation); printf("gamma_weight :%f\n",param.gamma_weight); printf("gamma :%f\n",param.gamma); printf("rgamma :%f\n",param.rgamma); printf("bgamma :%f\n",param.bgamma); printf("ggamma :%f\n",param.ggamma); printf("******************\n"); #endif update_lut(&mySettings,¶m); typedef void lutMeType(oneSetting *par, unsigned char *dst, unsigned char *src, unsigned int w, unsigned int h); lutMeType *lutMe=apply_lut; #ifdef ADM_CPU_X86 if(CpuCaps::hasMMX()) { lutMe=affine_1d_MMX; } #endif lutMe(&(mySettings.param[0]),YPLANE(_yuvBufferOut),YPLANE(_yuvBuffer),_w,_h); lutMe(&(mySettings.param[2]),UPLANE(_yuvBufferOut),UPLANE(_yuvBuffer),_w>>1,_h>>1); lutMe(&(mySettings.param[1]),VPLANE(_yuvBufferOut),VPLANE(_yuvBuffer),_w>>1,_h>>1); #if 1 _yuvBuffer->copyLeftSideTo(_yuvBufferOut); #endif return 1; }
uint8_t AVDMVideoHzStackField::getFrameNumberNoAlloc(uint32_t frame, uint32_t *len, ADMImage *data, uint32_t *flags) { uint32_t ref,ref2; ADMImage *ptr1,*ptr2; if(frame>=_info.nb_frames) return 0; if(!_in->getFrameNumberNoAlloc(frame, len, _uncompressed, flags)) return 0; uint32_t pg=_info.width*_info.height; // Duplicate _uncompressed memcpy(YPLANE(data),YPLANE(_uncompressed),pg); memcpy(UPLANE(data),UPLANE(_uncompressed),pg>>2); memcpy(VPLANE(data),VPLANE(_uncompressed),pg>>2); return 1; }
uint8_t AVDMVideoSwapField::getFrameNumberNoAlloc(uint32_t frame, uint32_t *len, ADMImage *data, uint32_t *flags) { //static Image in,out; if(frame>=_info.nb_frames) return 0; // read uncompressed frame if(!_in->getFrameNumberNoAlloc(frame, len,_uncompressed,flags)) return 0; uint32_t w=_info.width; uint32_t h=_info.height; uint32_t page=w*h; uint32_t stride; // copy u & v memcpy(UPLANE(data),UPLANE(_uncompressed),page>>2); memcpy(VPLANE(data),VPLANE(_uncompressed),page>>2); uint8_t *odd,*even,*target,*target2; even=YPLANE(_uncompressed); odd=even+w; target=YPLANE(data); target2=YPLANE(data)+w; stride=2*w; h>>=1; for(;h--;h>0) { memcpy(target,odd,w); memcpy(target2,even,w); target+=stride; target2+=stride; odd+=stride; even+=stride; } data->copyInfo(_uncompressed); return 1; }
/* Interleave _uncompressed with in2 even line from in2 odd=0 odd line odd=1 */ uint8_t ADMVideoTelecide::interleave( ADMImage *imgsrc, ADMImage *imgdst,uint8_t odd) { uint32_t w=_info.width; uint8_t *src1,*dst; src1=YPLANE(imgsrc); dst=YPLANE(imgdst); if(odd) { src1+=w; dst+=w; } for(uint32_t y=(_info.height>>1);y>0;y--) { memcpy(dst,src1,w); src1+=w<<1; dst+=w<<1; } return 1; }
static void hint(ADMImage *img) { unsigned int hint; hint= PROGRESSIVE; hint |= IN_PATTERN; PutHintingData(YPLANE(img), hint); }
uint8_t AVDMVideoStreamMPResize::getFrameNumberNoAlloc(uint32_t frame, uint32_t *len, ADMImage *data, uint32_t *flags) { if(frame>=_info.nb_frames) { printf("Filter : out of bound!\n"); return 0; } ADM_assert(_param); if(!_in->getFrameNumberNoAlloc(frame, len,_uncompressed,flags)) return 0; uint8_t *src[3]; uint8_t *dst[3]; int ssrc[3]; int ddst[3]; uint32_t page; page=_in->getInfo()->width*_in->getInfo()->height; src[0]=YPLANE(_uncompressed); src[1]=UPLANE(_uncompressed); src[2]=VPLANE(_uncompressed); ssrc[0]=_in->getInfo()->width; ssrc[1]=ssrc[2]=_in->getInfo()->width>>1; page=_info.width*_info.height; dst[0]=YPLANE(data); dst[1]=UPLANE(data); dst[2]=VPLANE(data); ddst[0]=_info.width; ddst[1]=ddst[2]=_info.width>>1; sws_scale(_context,src,ssrc,0,_in->getInfo()->height,dst,ddst); data->copyInfo(_uncompressed); return 1; }
/** * \fn copyLeftSideTo * \brief Copy half the image (left part) to dest * @param dest : Image to copy to */ uint8_t ADMImage::copyLeftSideTo(ADMImage *dest) { uint8_t *src,*dst; uint32_t stride; ADM_assert(_width==dest->_width); ADM_assert(_height==dest->_height); dst=YPLANE(dest); src=YPLANE(this); stride=_width; for(uint32_t y=0;y<_height;y++) // We do both u & v! { memcpy(dst,src,stride>>1); dst+=stride; src+=stride; } // U dst=UPLANE(dest); src=UPLANE(this); stride=_width>>1; uint32_t h2=_height>>1; for(uint32_t y=0;y<h2;y++) // We do both u & v! { memcpy(dst,src,stride>>1); dst+=stride; src+=stride; } // V dst=VPLANE(dest); src=VPLANE(this); for(uint32_t y=0;y<h2;y++) // We do both u & v! { memcpy(dst,src,stride>>1); dst+=stride; src+=stride; } return 1; }