RsYuvpublic class RsYuv extends Object implements TextureView.SurfaceTextureListener
Fields Summary |
---|
private int | mHeight | private int | mWidth | private android.renderscript.RenderScript | mRS | private android.renderscript.Allocation | mAllocationOut | private android.renderscript.Allocation | mAllocationIn | private ScriptC_yuv | mScript | private ScriptIntrinsicYuvToRGB | mYuv | private boolean | mHaveSurface | private android.view.Surface | mSurface | private ScriptGroup | mGroup | private long[] | mTiming | private int | mTimingSlot |
Constructors Summary |
---|
RsYuv(android.renderscript.RenderScript rs)
mRS = rs;
mScript = new ScriptC_yuv(mRS);
mYuv = ScriptIntrinsicYuvToRGB.create(rs, Element.RGBA_8888(mRS));
|
Methods Summary |
---|
void | execute(byte[] yuv)
mAllocationIn.copyFrom(yuv);
if (mHaveSurface) {
mGroup.setOutput(mScript.getKernelID_root(), mAllocationOut);
mGroup.execute();
//mYuv.forEach(mAllocationOut);
//mScript.forEach_root(mAllocationOut, mAllocationOut);
mAllocationOut.ioSend();
}
| public int | getHeight()
return mHeight;
| public int | getWidth()
return mWidth;
| public void | onSurfaceTextureAvailable(android.graphics.SurfaceTexture surface, int width, int height)
android.util.Log.v("cpa", "onSurfaceTextureAvailable " + surface);
mSurface = new Surface(surface);
setupSurface();
| public boolean | onSurfaceTextureDestroyed(android.graphics.SurfaceTexture surface)
android.util.Log.v("cpa", "onSurfaceTextureDestroyed " + surface);
mSurface = null;
setupSurface();
return true;
| public void | onSurfaceTextureSizeChanged(android.graphics.SurfaceTexture surface, int width, int height)
android.util.Log.v("cpa", "onSurfaceTextureSizeChanged " + surface);
mSurface = new Surface(surface);
setupSurface();
| public void | onSurfaceTextureUpdated(android.graphics.SurfaceTexture surface)
| void | reset(int width, int height)
if (mAllocationOut != null) {
mAllocationOut.destroy();
}
android.util.Log.v("cpa", "reset " + width + ", " + height);
mHeight = height;
mWidth = width;
mScript.invoke_setSize(mWidth, mHeight);
Type.Builder tb = new Type.Builder(mRS, Element.RGBA_8888(mRS));
tb.setX(mWidth);
tb.setY(mHeight);
Type t = tb.create();
mAllocationOut = Allocation.createTyped(mRS, t, Allocation.USAGE_SCRIPT |
Allocation.USAGE_IO_OUTPUT);
tb = new Type.Builder(mRS, Element.createPixel(mRS, Element.DataType.UNSIGNED_8, Element.DataKind.PIXEL_YUV));
tb.setX(mWidth);
tb.setY(mHeight);
tb.setYuvFormat(android.graphics.ImageFormat.NV21);
mAllocationIn = Allocation.createTyped(mRS, tb.create(), Allocation.USAGE_SCRIPT);
mYuv.setInput(mAllocationIn);
setupSurface();
ScriptGroup.Builder b = new ScriptGroup.Builder(mRS);
b.addKernel(mScript.getKernelID_root());
b.addKernel(mYuv.getKernelID());
b.addConnection(t, mYuv.getKernelID(), mScript.getKernelID_root());
mGroup = b.create();
| void | setupSurface()
if (mAllocationOut != null) {
mAllocationOut.setSurface(mSurface);
}
if (mSurface != null) {
mHaveSurface = true;
} else {
mHaveSurface = false;
}
|
|