I have some code that decodes frames from an ffmpeg steam, loads them into a magickwand via ConstituteImage, calls OptimizeImageLayers, then OptimizeImageTransparency, and finally gets the bytes via GetImagesBlob. Some pseudocode:
Code: Select all
mw = NewMagickWand()
for(i=0;i < frameCount;i++) {
MagickConstituteImage(mw, cols, rows, cspmap, stype, ptr)
MagickSetImageFuzz(mw, fuzz)
MagickSetImageDelay(mw, delay)
}
mw = MagickOptimizeImageLayers(mw)
MagickOptimizeImageTransparency(mw)
MagickSetImageFormat(mw, "gif")
data = MagickGetImagesBlob(mw, &clen)
Is there any way to speed this up without compromising quality (or at least not compromising it significantly)? I believe much of the time is spent quantizing the images, but it's unclear to me if there's a better way to do this.
As an aside, does anyone know if this code generates a global color palette or one per frame?
Thanks!
Edit: I forgot to mention I'm using the latest imagemagick compiled from source (6.9.3-7) Q16 no HDRI with OpenMP enabled. The numbers are from a 10 core Xeon server I'm using for testing.