___ _ _ _ _
/ _ \ (_|_) | | (_)
/ /_\ \___ ___ _ _ _ __ ___ _ __ __| | ___ _ __ ___ _ __ __ _ _ _ __ ___
| _ / __|/ __| | | | '__/ _ \ '_ \ / _` |/ _ \ '__| / _ \ '_ \ / _` | | '_ \ / _ \
| | | \__ \ (__| | | | | | __/ | | | (_| | __/ | | __/ | | | (_| | | | | | __/
\_| |_/___/\___|_|_| |_| \___|_| |_|\__,_|\___|_| \___|_| |_|\__, |_|_| |_|\___|
__/ |
|___/
This program extracts frames from a video file and processes them to display a quantized mosaic visualization in real time.
example.mp4
Frame Extraction:
- Uses
ffmpegvia an external thread to extract.jpgimages intovideo_data/.
Frame Processing Loop:
- Waits until a minimum number of frames are available.
- Loads one frame at a time and:
- Converts it to grayscale.
- Downscales it into 8×8 pixel blocks.
- Maps luminance to one of 10 tile images (0–9).
- Renders the mosaic in a SDL2 window.
Visualization:
- Each tile represents a quantized brightness level.
- Rendering continues until all frames are processed or the user exits.
To compile the program, make sure you have SDL2 SDL2_image stb and ffmpeg installed:
make cpu./image_processing input.mp4To improve performance the gpu is used. The gpu.c only quantize and samples frames on the gpu and copy back data to the cpu to display the frame. This solution improves slightly the rendering speed (2-5%). The gpu+.c is loading quantizing sampling and rendering frames on the gpu. It improves a lot rendering (350-450%).
make gpu
make gpu+video_data/– Temporary storage for extracted frames.char/– Folder containing 10 grayscale tile images (0.pngto9.png).video/– RGB videos to use as input.include/– Include for CPU and GPU version.gpu+include/– Include for GPU+ version.font/– Font for CPU and GPU FPS display.example/– Ascii rendering example.

