/** \fn getFrame \brief Get a processed frame */ bool unstackFieldFilter::getNextFrame(uint32_t *fn,ADMImage *image) { // since we do nothing, just get the output of previous filter if(false==previousFilter->getNextFrame(fn,current)) { ADM_warning("unstackField : Cannot get frame\n"); return false; } // do in place flip image->copyInfo(current); for(int i=PLANAR_Y;i<PLANAR_LAST;i++) { ADM_PLANE plane=(ADM_PLANE)i; uint32_t srcPitch=current->GetPitch(plane); uint32_t dstPitch=image->GetPitch(plane); uint8_t *src=current->GetReadPtr(plane); uint8_t *dst=image->GetWritePtr(plane); uint32_t w=info.width; uint32_t h=info.height; if(plane) { w>>=1; h>>=1; } // Even BitBlit(dst, dstPitch*2,src,srcPitch,w,h/2); BitBlit(dst+dstPitch, dstPitch*2,src+(srcPitch*h)/2,srcPitch,w,h/2); } return true; }
/** \fn copyField */ static bool copyField(ADMImage *target, ADMImage *source, bool top) { for(int i=0;i<3;i++) { ADM_PLANE plane=(ADM_PLANE )i; uint8_t *dest=target->GetWritePtr(plane); uint8_t *src=source->GetReadPtr(plane); uint32_t sPitch=source->GetPitch(plane); uint32_t dPitch=target->GetPitch(plane); if(false==top) { dest=dest+dPitch; src=src+sPitch; } uint32_t h=target->GetHeight(plane); uint32_t w=target->GetWidth(plane); // copy one line out of two h>>=1; dPitch*=2; sPitch*=2; BitBlit(dest,dPitch,src,sPitch,w,h); } return true; }
/** \fn rotatePlane */ void rotatePlane(uint32_t angle,uint8_t *src, uint32_t srcPitch, uint8_t *dst, uint32_t dstPitch, uint32_t width, uint32_t height) { int32_t dstIncPix, dstIncLine; switch(angle) { case 0: BitBlit(dst,dstPitch,src,srcPitch,width,height);return;break; case 180: dstIncPix=-1; dstIncLine=-dstPitch; dst=dst+((height-1)*dstPitch)+width-1;break; case 90: dstIncPix=dstPitch; dstIncLine=-1; dst=dst+height-1;break; case 270: dstIncPix=-dstPitch;dstIncLine=1; dst=dst+((width-1)*dstPitch);break; default: break; } uint8_t *lineIn,*lineOut; for(int y=0;y<height;y++) { lineIn=src+srcPitch*y; lineOut=dst+dstIncLine*y; for(int x=0;x<width;x++) { *lineOut=*lineIn; lineIn++; lineOut+=dstIncPix; } } }
void Image::ReadPixels(const Offset3D& offset, const Extent3D& extent, const DstImageDescriptor& imageDesc, std::size_t threadCount) const { if (imageDesc.data && IsRegionInside(offset, extent)) { /* Validate required size */ ValidateImageDataSize(extent, imageDesc); /* Get source image parameters */ const auto bpp = GetBytesPerPixel(); const auto srcRowStride = bpp * GetExtent().width; const auto srcDepthStride = srcRowStride * GetExtent().height; auto src = data_.get() + GetDataPtrOffset(offset); if (GetFormat() == imageDesc.format && GetDataType() == imageDesc.dataType) { /* Get destination image parameters */ const auto dstRowStride = bpp * extent.width; const auto dstDepthStride = dstRowStride * extent.height; auto dst = reinterpret_cast<char*>(imageDesc.data); /* Blit region into destination image */ BitBlit( extent, bpp, dst, dstRowStride, dstDepthStride, src, srcRowStride, srcDepthStride ); } else { /* Copy region into temporary sub-image */ Image subImage { extent, GetFormat(), GetDataType() }; BitBlit( extent, bpp, reinterpret_cast<char*>(subImage.GetData()), subImage.GetRowStride(), subImage.GetDepthStride(), src, srcRowStride, srcDepthStride ); /* Convert sub-image */ subImage.Convert(imageDesc.format, imageDesc.dataType, threadCount); /* Copy sub-image into output data */ ::memcpy(imageDesc.data, subImage.GetData(), imageDesc.dataSize); } } }
static bool d3dBlit(ADMImage *pic,ADM_PLANE plane,uint8_t *target,int targetPitch,int w, int h) { uint8_t *y=pic->GetReadPtr(plane); int pitch=pic->GetPitch(plane); BitBlit(target,targetPitch, y,pitch, w,h); return true; }
void Image::Blit(Offset3D dstRegionOffset, const Image& srcImage, Offset3D srcRegionOffset, Extent3D srcRegionExtent) { if (GetFormat() == srcImage.GetFormat() && GetDataType() == srcImage.GetDataType()) { /* First clamp source region to source image dimension */ srcImage.ClampRegion(srcRegionOffset, srcRegionExtent); /* Then shift negative destination region */ if ( ShiftNegative1DRegion(dstRegionOffset.x, GetExtent().width, srcRegionOffset.x, srcRegionExtent.width ) && ShiftNegative1DRegion(dstRegionOffset.y, GetExtent().height, srcRegionOffset.y, srcRegionExtent.height) && ShiftNegative1DRegion(dstRegionOffset.z, GetExtent().depth, srcRegionOffset.z, srcRegionExtent.depth ) ) { /* Check if a temporary copy of the source image must be allocated */ Image srcImageTemp; const Image* srcImageRef = &srcImage; if (srcImageRef == this && Overlap3DRegion(dstRegionOffset, srcRegionOffset, srcRegionExtent)) { /* Copy source image */ srcImageTemp = *this; srcImageRef = &srcImageTemp; } /* Get destination image parameters */ const auto bpp = GetBytesPerPixel(); const auto dstRowStride = bpp * GetExtent().width; const auto dstDepthStride = dstRowStride * GetExtent().height; auto dst = data_.get() + GetDataPtrOffset(dstRegionOffset); /* Get source image parameters */ const auto srcRowStride = bpp * srcImageRef->GetExtent().width; const auto srcDepthStride = srcRowStride * srcImageRef->GetExtent().height; auto src = srcImageRef->data_.get() + srcImageRef->GetDataPtrOffset(srcRegionOffset); /* Blit source image into region */ BitBlit( srcRegionExtent, bpp, dst, dstRowStride, dstDepthStride, src, srcRowStride, srcDepthStride ); } } }