Writing Black&White 1bit/pixel image file in C, _-FAST-_?
Posted: 2016-02-17T12:11:06-07:00
I need to covert ~36 million bits in C to a "standard" png/jpg/gif/mng/??? file format FAST.
Would appreciate recommendation on suitable C library.
One goal is to create a movie with 1025 frames: Pure image and then 1024 with a single bin masked
DETAILS:
=======
libgd is used to create 1 bit/pixel lossless black&white (actually BLACK&TRANSPARENT) masks.
o Profiling shows 43% of program time is spent writing 3 in-memory, gdi images to disk
o >open binary file (PingFilePtr) for output
o gdImagePng(gdi, pfp); fflush(pfp); fclose(pfp); destroy gdi
o 3 gdi->PNG files, ~20kb each
9% of program time to read 217 MB, 36MPix raw rgb to SSD so disk is not the bottleneck
Output file size has near zero importance, data are already <2% of RAW image size and highly compressible.
Will be making many thousands to create movies, probably with FFMPEG
Feeding a raw, bit stream to FFMPEG library function linked in to the C program would be the Holy Grail for the video!
Video will show some full-color image with various masks obscuring parts of the image on successive frames
REQUIREMENTS: <br>
==============
Would appreciate recommendation on suitable C library.
One goal is to create a movie with 1025 frames: Pure image and then 1024 with a single bin masked
DETAILS:
=======
libgd is used to create 1 bit/pixel lossless black&white (actually BLACK&TRANSPARENT) masks.
o Profiling shows 43% of program time is spent writing 3 in-memory, gdi images to disk
o >open binary file (PingFilePtr) for output
o gdImagePng(gdi, pfp); fflush(pfp); fclose(pfp); destroy gdi
o 3 gdi->PNG files, ~20kb each
9% of program time to read 217 MB, 36MPix raw rgb to SSD so disk is not the bottleneck
Output file size has near zero importance, data are already <2% of RAW image size and highly compressible.
Will be making many thousands to create movies, probably with FFMPEG
Feeding a raw, bit stream to FFMPEG library function linked in to the C program would be the Holy Grail for the video!
Video will show some full-color image with various masks obscuring parts of the image on successive frames
REQUIREMENTS: <br>
==============
- C language, Linux/64, currently GCC (may try Intel), (without Byzantine dependencies :)
Speed is Paramount, file size is of little/no concern
MUST support transparency for mask creation; black -> masked, rest (most) is Clear
SIMD/SSE/SMP aware, processor is Skylake 6700K
Format should be widely readable (FFMPEG, photoshop, Perl Data Language, Firefox/chrome)
Should have very low loss, but not necessarily lossless
Short of downloading/building/performance testing umpteen different packages, recommendations or horror stories would be of great interest.
- JPEG-8/9? libjpeg-turbo? TurboJPEG? JPEG 2000?
GIF? MNG? PNG?
BNG (Better Net Graphics by Fabrice Bellard look great vs JPEG but only supports 8-14 bits/channel)
WebP - optimized for size, ~4x processing time. Not suitable
ImageMagick? GraphicsMagick? OpenCV? OpenGL? GIMP?