title: Stride calculation for Image format YUY2
body: <p>I am studying Android's YuvImage.java code, <a href="http://androidxref.com/4.2.2_r1/xref/frameworks/base/graphics/java/android/graphics/YuvImage.java#199" rel="nofollow">http://androidxref.com/4.2.2_r1/xref/frameworks/base/graphics/java/android/graphics/YuvImage.java#199</a>:</p>
  
  <p>Why stride for YUY2 is width*2 but stride for NV21 is width?</p>
  
  <p>Here is the code:</p>
  
  <pre><code>199    private int[] calculateStrides(int width, int format) {
  200        int[] strides = null;
  201        if (format == ImageFormat.NV21) {
  202            strides = new int[] {width, width};
  203            return strides;
  204        }
  205
  206        if (format == ImageFormat.YUY2) {
  207            strides = new int[] {width * 2};
  208            return strides;
  209        }
  210
  211        return strides;
  212    }
  </code></pre>