FFmpeg expects Blender to feed it pixels in the output pixel format. If the output pixel format is different than Blender's RGBA, a conversion is needed (via FFmpeg's sws_scale() function). There were a few issues with this conversion (and surrounding code) that are fixed in this commit:
- When conversion was necessary a temporary buffer was allocated and deallocated for every frame. This is now allocated once and re-used.
- Copying data to the buffer was done byte-for-byte. On little-endian machines it is now done line-by-line using memcpy for a little speedup.
- The decision whether pixel format conversion is necessary is now correctly done based on the pixel format Blender is actually using.
- The pixel format of the buffer sent to FFmpeg is no longer hard-coded incorrectly to a fixed pixel format, but uses the actual output pixel format. This is fixes T53058 properly, making RGB QTRLE export possible.
- I added some comments to make it clear which pixel format is referred to (either Blender's internal format or the FFmpeg output format).
Combined these improvements not only correct a bug (T53058) but also results in approximately 5% speed improvement (tested with a 117-frame shot from Spring, loaded as PNGs in the VSE, encoding to h.264 with preset 'realtime').