title: Why ANativeWindow_Buffer.stride is different for different devices
body: <p>I am writing simple video player using ffmpeg for android. Following are the steps I followed</p>
  <ol>
  <li>Read AVFrame from file</li>
  <li>Convert AVFrame to RGB565 format using <code>sws_scale</code></li>
  <li>Get buffer from using <code>av_image_copy_to_buffer</code></li>
  <li>Display this buffer to <code>SurfaceView</code> by copying buffer to <code>ANativeWindow_Buffer</code></li>
  </ol>
  <p>Most of the videos are playing fine, but there is issue with videos which have lower resolution than window. For ex, when I play a 656x480 video on my OnePlus 7T (2206x1080), video looks distorted. The same video plays fine on emulator (2160x1080).</p>
  <p>When I debugged whole pipe, I found that on OP7T, after locking <code>ANativeWindow</code>, <code>ANativeWindow_Buffer.stride</code> was set to 704 instead of 656. For all videos which plays normal, stride is same as width of buffer. The same is not  the case with Android emulator.</p>
  <p>I did some trials and tried to scale width to 600, then stride jumped to 640 and video was distorted. When I scaled width to 640, video was displayed vertically half correct.</p>
  <p>Can anyone help me understand, How stride is calculated? And What is the reason stride is wrongly calculated?</p>
  <p>I found one same problem here: <a href="https://stackoverflow.com/questions/40202746/simple-ffmpeg-player-for-android">Simple FFMpeg player for Android</a>
  OP mentions that video works fine for 640, 1280, 1920.</p>