title: android - YUV NV12 to RGB conversion with RenderScript
body: <p>Android has buildin convert function for YUV to RGB, below code works fine for NV21 YUV input but if use NV12 input, it will crash.</p>
  
  <pre><code>public Bitmap YUV_toRGB(byte[] yuvByteArray,int W,int H) {
      RenderScript rs = RenderScript.create(this);
      ScriptIntrinsicYuvToRGB yuvToRgbIntrinsic = ScriptIntrinsicYuvToRGB.create(rs, Element.U8_4(rs));
  
      Type.Builder yuvType = new Type.Builder(rs, Element.U8(rs)).setX(yuvByteArray.length);
      Allocation in = Allocation.createTyped(rs, yuvType.create(), Allocation.USAGE_SCRIPT);
  
      Type.Builder rgbaType = new Type.Builder(rs, Element.RGBA_8888(rs)).setX(W).setY(H);
      Allocation out = Allocation.createTyped(rs, rgbaType.create(), Allocation.USAGE_SCRIPT);
  
      in.copyFrom(yuvByteArray);
  
      yuvToRgbIntrinsic.setInput(in);
      yuvToRgbIntrinsic.forEach(out);
      Bitmap bmp = Bitmap.createBitmap(W, H, Bitmap.Config.ARGB_8888);
      out.copyTo(bmp);
  
      yuvToRgbIntrinsic.destroy();
      rs.destroy();
      return bmp;
  }
  </code></pre>
  
  <p>How can I change the code to convert NV12 to RGB? No document say what's the input format supported and how to config it.</p>