title: Converting MSB padding to LSB padding
body: <p>I am using FFmpeg and Vulkan for a video related project. The problem is that FFmpeg uses MSB padding for the 9, 10 and 12bit formats, whilst Vulkan accepts LSB padded pixel formats.</p>
  <p>I am using the following code to convert from one another, but the performance is terrible (1 second per frame), which cannot be accepted for video playback.</p>
  <pre><code>if(paddingBits &gt; 0) {
      //As padding bits are set to 0, using CPU words for the shifting should not affect the result
      assert(dstBuffers[plane].size() % sizeof(size_t) == 0);
      for(size_t i = 0; i &lt; dstBuffers[plane].size(); i += sizeof(size_t)) {
          reinterpret_cast&lt;size_t&amp;&gt;(dstBuffers[plane][i]) &lt;&lt;= paddingBits;
      }
  }
  </code></pre>
  <p>Note that this code will be executed 1-4 times per frame (once per <code>plane</code>) and <code>dstBuffers[plane].size()</code> will be in the order of a couple of MegaBytes. <code>dstBuffers[plane]</code>'s data has an alignment greater than <code>size_t</code>'s, so I am not performing unaligned read/writes. Using a smaller type such as uint16_t makes it perform worse.</p>
  <p>My question is if there is any standard function (or inside the FFmpeg library) which implements the same behavior in a fancy way so that the performance is not a concern. If not, is there a more efficient way to implement it?</p>
  <p>Edit:<code>dstBuffers[plane]</code> stores <code>std::byte</code>-s and although is not of type <code>std::vector</code>, (it is a custom class) it is contiguous.</p>