$ show wysaid/android-gpuimage-plus
This repository is an Android library for GPU-accelerated real-time image and video processing, named 'android-gpuimage-plus' (CGE engine). It provides a comprehensive set of OpenGL ES shader-based filters (brightness, contrast, hue, saturation, vignette, sketch, liquify, color mapping, LUT, etc.) and a filter chain pipeline for applying multiple effects. The library supports camera preview with live filters, video playback with effects, and video recording to MP4 using an optional FFmpeg backend. It includes a demo application (cgeDemo) showcasing all features, including image editing, camera capture, video player, and face tracking (stub). The architecture is a Java/Kotlin API layer with JNI wrappers to a native C++ core that manages OpenGL ES contexts, shader programs, and frame buffer objects. External dependencies include OpenGL ES 2.0/3.0, optional FFmpeg (version 3.4.8), and Android Camera1/CameraX APIs. The library is published as an AAR artifact with variants for different page sizes (4KB and 16KB) and optional video module.
The LLM identified 4 files worth highlighting for reuse:
A self-contained OpenGL rendering view built on Android's TextureView. It abstracts EGL context creation, surface lifecycle, and render loop (continuous or dirty mode). The implementation is reusable by any Android app needing a custom GLSurfaceView-like component without inheriting from GLSurfaceView. It demonstrates non-obvious skill in managing EGL configuration, context sharing, and thread safety, and can be extracted with minimal modification.
An interface that abstracts the Android camera API (Camera1 and CameraX) behind a single contract. It defines methods for open, close, setPreviewTexture, setZoomRatio, and focusAtPoint, with default implementations and static helper methods. This pattern allows swapping camera backends without changing higher-level code. The implementations (Camera1Provider and CameraXProvider) are provided separately, making the interface a clean, reusable abstraction for camera access in Android apps.
A header-only C++ math library for 2D/3D transformations, providing Mat2, Mat3, Mat4 classes with perspective, orthographic, lookAt, rotation, and projection functions. It uses templates and inline functions, has no external dependencies, and can be dropped into any project requiring basic 3D math. The implementation is clean and demonstrates good C++ practices for a reusable math utility.
The CGEVideoEncoderMP4 class implements video encoding using FFmpeg with a custom AVIO context that wraps an Android file descriptor obtained from ContentResolver. This pattern is essential for Android scoped storage (API 29+), where traditional file paths are not accessible. The code demonstrates how to use avio_alloc_context with a buffer and write callback, and how to integrate with Android's MediaStore IS_PENDING flag. This pattern is reusable for any FFmpeg-based encoder on Android that needs to write to a content URI.