On the left side I have a buffer with decoded pixels that I can get in two formats:
RGB interleaved/packed where bytes in buffer are R0G0B0R1G1B1....
or
YUV444 interleaved/packed where bytes in buffer are Y0U0V0Y1U1V1...
(JCS_RGB or JCS_YCbCr in jpeglib.h)
(Please note that I use libjpeg-turbo because I need to decompress a cropped region of the image. (jpeg_crop_scanline()))
On the right side I have x264 codec via ffmpeg that support only planar pixel formats:
yuv420p, yuvj420p, yuv422p, yuvj422p, yuv444p, yuvj444p, nv12, nv16, nv21, yuv420p10le, yuv422p10le, yuv444p10le, nv20le
yuv444p where bytes in buffer are Y0Y1Y2...U0U1...V0V1...
according to ffmpeg -h encoder=libx264
I have some ideas already:
- Decompress Jpeg to RBG888 in buffer 1 then libswscale to yuv420p in buffer 2 and encoding. (copy)
- Decompress Jpeg to YUV444 interleaved in buffer 1 then SSSE3 magic in buffer 1 to yuv444p and encoding. (no copy)
- or else.
What would be the most effective fastest way ?
I which to avoid buffer copy.
Movie have the same width & height than Jpegs.



If you are fine with using the RGB version of the libx264 encoder, you can use the rgb24 and bgr24 pixel formats without conversion.