Skip to content

Add ffmpeg with 16kb page size support, add prebuilt 16kb aligned libraries in the README #543

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 2, 2025

Conversation

wysaid
Copy link
Owner

@wysaid wysaid commented Jun 24, 2025

Add ffmpeg with 16kb page size support, fix cmake with 16kb ffmpeg, add tasks for 16kb page size changing, ref: #542

Summary by CodeRabbit

  • New Features

    • Added support for 16KB page size builds, offering new build variants for improved compatibility and performance.
    • Expanded library variants to include options for both 4KB and 16KB page sizes, and both full-featured and image-only builds.
  • Documentation

    • Updated README with detailed instructions and descriptions for new build variants and configuration options.
  • Build & Release

    • Incremented version to 3.1.0.
    • Improved build scripts and configuration for flexible page size support and artifact publishing.
    • Added new FFmpeg configuration files for various architectures and page size options.
    • Introduced new build tasks to enable or disable 16KB page size support via the development environment.
    • Modernized build system with enhanced modularity, conditional linking, and target-based commands for improved maintainability.

Copy link

coderabbitai bot commented Jun 24, 2025

Walkthrough

This update introduces support for 16KB memory page sizes in the Android-GPUImage-Plus project. It modifies build scripts, Gradle configurations, and documentation to distinguish between 4KB and 16KB page size variants. The JNI build system and FFmpeg integration are updated to support conditional selection of libraries and flags. New FFmpeg configuration headers are added for each architecture.

Changes

File(s) / Path(s) Change Summary
.vscode/tasks.json Added two build tasks for enabling/disabling 16KB page size via shell scripts.
README.md Updated Gradle dependency instructions, added 16KB variant info, clarified architectures, and improved formatting.
build.gradle, library/build.gradle Incremented version to 3.1.0; updated artifact versioning logic to append -16k and -min suffixes; improved Maven publishing config.
library/src/main/jni/Application.mk Added conditional enabling of flexible page sizes based on CGE_ENABLE_16KB_PAGE_SIZE.
library/src/main/jni/Android.mk Added conditional linker flags and FFmpeg path selection for 16KB support.
library/src/main/jni/CMakeLists.txt Refactored to modern CMake; modularized targets; added 16KB page size support; improved video module and FFmpeg integration.
library/src/main/jni/buildJNI Added --16kb option to set environment variable; improved argument parsing with error reporting.
library/src/main/jni/ffmpeg-16kb/include/ Added new FFmpeg config headers for 16KB builds for all architectures (arm64-v8a, armeabi-v7a, x86, x86_64).
library/src/main/jni/ffmpeg-16kb/version.h Added version header defining FFMPEG_VERSION, X264_VERSION, and ENABLE_16KB_PAGE_SIZE.
library/src/main/jni/ffmpeg/include/ Added new FFmpeg config headers for standard (4KB) builds for all architectures (arm64-v8a, armeabi-v7a, x86, x86_64).

Sequence Diagram(s)

sequenceDiagram
    participant Dev as Developer
    participant VSCode as VSCode Tasks
    participant BuildScript as tasks.sh/buildJNI
    participant Env as Build Environment
    participant JNI as JNI Build System
    participant FFmpeg as FFmpeg Libraries

    Dev->>VSCode: Select "Enable 16KB Page Size" task
    VSCode->>BuildScript: Run tasks.sh --enable-16kb-page-size
    BuildScript->>Env: Set CGE_ENABLE_16KB_PAGE_SIZE=1
    Env->>JNI: Start build with 16KB page size flag
    JNI->>FFmpeg: Link against ffmpeg-16kb libs and includes
    JNI->>JNI: Add linker flag -Wl,-z,max-page-size=16384
    JNI-->>Dev: Build output with 16KB page size
Loading

Poem

In fields of code where pixels play,
A rabbit hops with joy today!
Sixteen thousand bytes per page,
New builds unlocked upon the stage.
With headers, flags, and scripts anew,
The project grows—thanks to the crew!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8da32a7 and 31dfbe8.

⛔ Files ignored due to path filters (24)
  • library/src/main/jni/ffmpeg-16kb/libs/arm64-v8a/libffmpeg.so is excluded by !**/*.so
  • library/src/main/jni/ffmpeg-16kb/libs/armeabi-v7a/libffmpeg.so is excluded by !**/*.so
  • library/src/main/jni/ffmpeg-16kb/libs/x86/libffmpeg.so is excluded by !**/*.so
  • library/src/main/jni/ffmpeg-16kb/libs/x86_64/libffmpeg.so is excluded by !**/*.so
  • library/src/main/jni/ffmpeg/arm64-v8a/libffmpeg.so is excluded by !**/*.so
  • library/src/main/jni/ffmpeg/armeabi-v7a/libffmpeg.so is excluded by !**/*.so
  • library/src/main/jni/ffmpeg/libs/arm64-v8a/libffmpeg.so is excluded by !**/*.so
  • library/src/main/jni/ffmpeg/libs/armeabi-v7a/libffmpeg.so is excluded by !**/*.so
  • library/src/main/jni/ffmpeg/libs/x86/libffmpeg.so is excluded by !**/*.so
  • library/src/main/jni/ffmpeg/libs/x86_64/libffmpeg.so is excluded by !**/*.so
  • library/src/main/jni/ffmpeg/x86/libffmpeg.so is excluded by !**/*.so
  • library/src/main/jni/ffmpeg/x86_64/libffmpeg.so is excluded by !**/*.so
  • library/src/main/libs/arm64-v8a/libCGE.so is excluded by !**/*.so
  • library/src/main/libs/arm64-v8a/libCGEExt.so is excluded by !**/*.so
  • library/src/main/libs/arm64-v8a/libffmpeg.so is excluded by !**/*.so
  • library/src/main/libs/armeabi-v7a/libCGE.so is excluded by !**/*.so
  • library/src/main/libs/armeabi-v7a/libCGEExt.so is excluded by !**/*.so
  • library/src/main/libs/armeabi-v7a/libffmpeg.so is excluded by !**/*.so
  • library/src/main/libs/x86/libCGE.so is excluded by !**/*.so
  • library/src/main/libs/x86/libCGEExt.so is excluded by !**/*.so
  • library/src/main/libs/x86/libffmpeg.so is excluded by !**/*.so
  • library/src/main/libs/x86_64/libCGE.so is excluded by !**/*.so
  • library/src/main/libs/x86_64/libCGEExt.so is excluded by !**/*.so
  • library/src/main/libs/x86_64/libffmpeg.so is excluded by !**/*.so
📒 Files selected for processing (17)
  • .vscode/tasks.json (1 hunks)
  • README.md (2 hunks)
  • build.gradle (1 hunks)
  • library/build.gradle (2 hunks)
  • library/src/main/jni/Android.mk (2 hunks)
  • library/src/main/jni/Application.mk (1 hunks)
  • library/src/main/jni/CMakeLists.txt (2 hunks)
  • library/src/main/jni/buildJNI (1 hunks)
  • library/src/main/jni/ffmpeg-16kb/include/config.arm64-v8a.h (1 hunks)
  • library/src/main/jni/ffmpeg-16kb/include/config.armeabi-v7a.h (1 hunks)
  • library/src/main/jni/ffmpeg-16kb/include/config.x86.h (1 hunks)
  • library/src/main/jni/ffmpeg-16kb/include/config.x86_64.h (1 hunks)
  • library/src/main/jni/ffmpeg-16kb/version.h (1 hunks)
  • library/src/main/jni/ffmpeg/include/config.arm64-v8a.h (1 hunks)
  • library/src/main/jni/ffmpeg/include/config.armeabi-v7a.h (1 hunks)
  • library/src/main/jni/ffmpeg/include/config.x86.h (1 hunks)
  • library/src/main/jni/ffmpeg/include/config.x86_64.h (1 hunks)
✅ Files skipped from review due to trivial changes (4)
  • library/src/main/jni/ffmpeg/include/config.x86_64.h
  • library/src/main/jni/ffmpeg-16kb/include/config.x86_64.h
  • .vscode/tasks.json
  • library/src/main/jni/ffmpeg-16kb/include/config.armeabi-v7a.h
🚧 Files skipped from review as they are similar to previous changes (12)
  • build.gradle
  • library/src/main/jni/buildJNI
  • library/src/main/jni/Application.mk
  • library/src/main/jni/ffmpeg/include/config.arm64-v8a.h
  • library/build.gradle
  • README.md
  • library/src/main/jni/Android.mk
  • library/src/main/jni/ffmpeg/include/config.x86.h
  • library/src/main/jni/ffmpeg/include/config.armeabi-v7a.h
  • library/src/main/jni/ffmpeg-16kb/include/config.x86.h
  • library/src/main/jni/ffmpeg-16kb/version.h
  • library/src/main/jni/CMakeLists.txt
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (6)
library/src/main/jni/ffmpeg-16kb/include/config.arm64-v8a.h (6)

1-3: Auto-generated FFmpeg configuration header looks appropriate for 16KB page size support.

This auto-generated configuration header properly defines the FFmpeg build for ARM64-v8a architecture as part of the 16KB page size support feature.


17-45: Architecture and CPU feature configuration is correctly set for ARM64-v8a.

The configuration properly enables:

  • ARM64 architecture (ARCH_AARCH64 1)
  • ARMv8 instruction set (HAVE_ARMV8 1)
  • NEON SIMD extensions (HAVE_NEON 1)
  • VFP floating point (HAVE_VFP 1)

This is appropriate for modern Android ARM64 devices.


535-540: Build configuration enables static linking and GPL licensing.

The configuration enables:

  • Static linking (CONFIG_STATIC 1) - appropriate for Android NDK builds
  • GPL v3 licensing (CONFIG_GPL 1, CONFIG_VERSION3 1) - allows use of libx264
  • Small build optimizations (CONFIG_SMALL 1) - good for mobile deployment

This aligns well with the Android library requirements.


1187-1316: Minimal codec and format selection may limit functionality.

The configuration enables a very limited set of multimedia components:

  • Demuxers: Only AAC, MOV, MP3, MPEGTS, IMAGE2
  • Decoders: Only AAC, H.264, MP3, MJPEG, PNG
  • Encoders: Only AAC, libx264, MJPEG, PNG
  • Muxers: Only MP4, MOV, MP3, MPEGTS, IMAGE2

While this creates a smaller library footprint, ensure this limited feature set supports all current and planned multimedia processing needs in the GPU image processing pipeline.

Also applies to: 1469-1643


2309-2356: Protocol support is minimal but sufficient for basic file operations.

Only three protocols are enabled:

  • file - for local file access
  • pipe - for data streaming
  • concat - for file concatenation

This minimal set should be sufficient for typical Android media processing tasks, but verify that network protocols or other data sources aren't needed.


4-4: Confirm limited FFmpeg configuration covers code usage

We’ve verified that the native code uses FFmpeg solely for decoding via avcodec_find_decoder(), avcodec_open2(), avcodec_decode_video2() / avcodec_decode_audio4(), as well as sws_getContext()/sws_scale() and swr_alloc() for resampling. The current build flags enable only:

• Decoders: H.264, AAC, MP3, PNG, MJPEG
• Demuxers: mov (MP4), mp3, aac, mpegts, image2
• Protocols: file, pipe, concat
• No network support

Please verify that all input formats and codecs used by the app are covered by this minimal feature set.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 12

🧹 Nitpick comments (14)
library/src/main/jni/ffmpeg/include/config.x86_64.h (2)

5-6: Confirm GPL-v3 obligations

#define FFMPEG_LICENSE "GPL version 3 or later" plus CONFIG_GPL 1 and CONFIG_LIBX264 1 places the resulting AAR / .so under GPLv3. Distributing on Google Play or embedding in closed-source apps requires the whole app to comply.

Please verify this is acceptable for your downstream consumers.


396-415: Example programs left enabled – unnecessary binary bloat

Macros such as CONFIG_ENCODE_AUDIO_EXAMPLE 1, CONFIG_MUXING_EXAMPLE 1, ... are still 1 even though all CLI tools are disabled. They pull in extra objects and enlarge .so size.

Add --disable-programs --disable-doc --disable-examples to your configure flags and regenerate, or patch them to 0.

library/src/main/jni/ffmpeg-16kb/include/config.x86.h (2)

1-3: Generated artefact committed to VCS – reconsider

config.x86.h is a huge, fully-generated header. Committing it bloats the repo and creates painful merge conflicts every time FFmpeg is re-configured. Prefer adding the generation step to the build pipeline (or vendoring a minimal patch) and git-ignoring the file.


511-520: CUDA/NVENC enabled in an Android/x86 build – unnecessary weight

CONFIG_CUDA 1, CONFIG_NVENC 1, CONFIG_CUVID 1, etc. significantly inflate binary size and pull extra dependencies that are unusable on Android devices lacking Nvidia GPUs. Disabling these flags (--disable-cuda --disable-nvenc --disable-cuvid) trims ~3-5 MB per ABI.

library/src/main/jni/ffmpeg-16kb/include/config.armeabi-v7a.h (3)

4-4: Hard-coded absolute paths reduce build reproducibility

FFMPEG_CONFIGURATION embeds absolute paths from the author’s local machine.
This leaks environment details and makes external or CI builds non-deterministic.
Consider re-running configure in a container / repo-relative path (or post-processing the header with sed) so only portable, reproducible paths are stored.


9-9: Tool-chain fingerprint constantly churns the header

CC_IDENT includes the full clang revision hash.
Every NDK upgrade will change this line and bloat future diffs.
You can safely strip or overwrite it after configure to keep the file stable.


41-47: NEON optimisations disabled – verify necessity

--disable-neonHAVE_NEON 0, yet the target is armv7-a.
Unless the 16 KB page-size build genuinely breaks NEON, this will
forfeit a large performance gain on most devices.
Double-check if the restriction is still required.

library/src/main/jni/ffmpeg-16kb/include/config.x86_64.h (2)

534-539: Double-check license flags

Both CONFIG_GPL and CONFIG_VERSION3 are 1, meaning the resulting binaries
are GPLv3. Ensure that:

  1. Your project’s license and distribution model are compatible with GPLv3.
  2. Any downstream apps (especially on Play Store) are aware of this obligation.

If GPL compliance is undesired, rebuild with --disable-gpl / remove
GPL-only components such as libx264.


2354-2356: No trailing newline

Minor, but the header ends without a final newline; some compilers warn on this.

library/src/main/jni/ffmpeg/include/config.x86.h (2)

9-9: CC_IDENT also leaks local revision metadata & paths

CC_IDENT captures the full clang tool-chain description including an internal git hash.
Consider passing --disable-ident (or overriding CC_IDENT with a sanitized string) during configure so that binaries don’t expose build host information.


1-2356: Generated file should be flagged as such and excluded from manual edits

Add a top-of-file notice or .gitattributes entry marking all config.*.h as generated to:

  • Skip them in clang-format / static-analysis runs.
  • Avoid accidental edits during code reviews.

Example:

library/src/main/jni/ffmpeg/include/config.*.h linguist-generated
library/src/main/jni/ffmpeg/include/config.armeabi-v7a.h (1)

1-2356: Consider excluding this 2 .3 k-line auto-generated header from VCS.

config.armeabi-v7a.h is produced by FFmpeg’s configure script and changes whenever build flags or toolchain versions change.
Checking it in:

  1. Bloats the repository and causes noisy diffs.
  2. Forces manual updates whenever FFmpeg is rebuilt.
  3. Couples native build logic to source control, undermining reproducible builds.

Typical pattern: keep only the build scripts and let the CI/Gradle task regenerate the header into $(buildDir)/generated/ffmpeg/include. If shipping pre-built binaries is required, store headers in an artifacts archive rather than the main tree.

If keeping the file is unavoidable, document the regeneration procedure and add a linter rule preventing accidental edits.

library/src/main/jni/ffmpeg-16kb/include/config.arm64-v8a.h (1)

1-4: Huge auto-generated header committed to VCS

The 2 300-line config header is machine-generated and changes on every rebuild.
Keeping it in git bloats the repo and causes noisy diffs.

Consider adding it to .gitignore and generating it during the CMake configure step.

library/src/main/jni/CMakeLists.txt (1)

109-116: Imported ffmpeg target may miss SONAME & interface settings

When importing a pre-built .so, set properties to avoid link-time surprises:

set_target_properties(ffmpeg PROPERTIES
  IMPORTED_LOCATION "${FFMPEG_DIR}/libs/${ANDROID_ABI}/libffmpeg.so"
  IMPORTED_NO_SONAME TRUE
  INTERFACE_COMPILE_DEFINITIONS CGE_USE_FFMPEG=1)

At a minimum, add IMPORTED_NO_SONAME TRUE to suppress duplicate soname warnings.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 625e2e6 and 09592e6.

⛔ Files ignored due to path filters (24)
  • library/src/main/jni/ffmpeg-16kb/libs/arm64-v8a/libffmpeg.so is excluded by !**/*.so
  • library/src/main/jni/ffmpeg-16kb/libs/armeabi-v7a/libffmpeg.so is excluded by !**/*.so
  • library/src/main/jni/ffmpeg-16kb/libs/x86/libffmpeg.so is excluded by !**/*.so
  • library/src/main/jni/ffmpeg-16kb/libs/x86_64/libffmpeg.so is excluded by !**/*.so
  • library/src/main/jni/ffmpeg/arm64-v8a/libffmpeg.so is excluded by !**/*.so
  • library/src/main/jni/ffmpeg/armeabi-v7a/libffmpeg.so is excluded by !**/*.so
  • library/src/main/jni/ffmpeg/libs/arm64-v8a/libffmpeg.so is excluded by !**/*.so
  • library/src/main/jni/ffmpeg/libs/armeabi-v7a/libffmpeg.so is excluded by !**/*.so
  • library/src/main/jni/ffmpeg/libs/x86/libffmpeg.so is excluded by !**/*.so
  • library/src/main/jni/ffmpeg/libs/x86_64/libffmpeg.so is excluded by !**/*.so
  • library/src/main/jni/ffmpeg/x86/libffmpeg.so is excluded by !**/*.so
  • library/src/main/jni/ffmpeg/x86_64/libffmpeg.so is excluded by !**/*.so
  • library/src/main/libs/arm64-v8a/libCGE.so is excluded by !**/*.so
  • library/src/main/libs/arm64-v8a/libCGEExt.so is excluded by !**/*.so
  • library/src/main/libs/arm64-v8a/libffmpeg.so is excluded by !**/*.so
  • library/src/main/libs/armeabi-v7a/libCGE.so is excluded by !**/*.so
  • library/src/main/libs/armeabi-v7a/libCGEExt.so is excluded by !**/*.so
  • library/src/main/libs/armeabi-v7a/libffmpeg.so is excluded by !**/*.so
  • library/src/main/libs/x86/libCGE.so is excluded by !**/*.so
  • library/src/main/libs/x86/libCGEExt.so is excluded by !**/*.so
  • library/src/main/libs/x86/libffmpeg.so is excluded by !**/*.so
  • library/src/main/libs/x86_64/libCGE.so is excluded by !**/*.so
  • library/src/main/libs/x86_64/libCGEExt.so is excluded by !**/*.so
  • library/src/main/libs/x86_64/libffmpeg.so is excluded by !**/*.so
📒 Files selected for processing (17)
  • .vscode/tasks.json (1 hunks)
  • README.md (2 hunks)
  • build.gradle (1 hunks)
  • library/build.gradle (2 hunks)
  • library/src/main/jni/Android.mk (2 hunks)
  • library/src/main/jni/Application.mk (1 hunks)
  • library/src/main/jni/CMakeLists.txt (2 hunks)
  • library/src/main/jni/buildJNI (1 hunks)
  • library/src/main/jni/ffmpeg-16kb/include/config.arm64-v8a.h (1 hunks)
  • library/src/main/jni/ffmpeg-16kb/include/config.armeabi-v7a.h (1 hunks)
  • library/src/main/jni/ffmpeg-16kb/include/config.x86.h (1 hunks)
  • library/src/main/jni/ffmpeg-16kb/include/config.x86_64.h (1 hunks)
  • library/src/main/jni/ffmpeg-16kb/version.h (1 hunks)
  • library/src/main/jni/ffmpeg/include/config.arm64-v8a.h (1 hunks)
  • library/src/main/jni/ffmpeg/include/config.armeabi-v7a.h (1 hunks)
  • library/src/main/jni/ffmpeg/include/config.x86.h (1 hunks)
  • library/src/main/jni/ffmpeg/include/config.x86_64.h (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (21)
build.gradle (1)

34-34: LGTM! Appropriate version bump for new feature.

The minor version increment from 3.0.0 to 3.1.0 correctly follows semantic versioning for the new 16KB page size feature addition.

library/src/main/jni/Application.mk (1)

16-18: LGTM! Correct conditional logic for flexible page sizes.

The conditional block properly enables APP_SUPPORT_FLEXIBLE_PAGE_SIZES when the 16KB page size feature is enabled, which is the correct approach for Android NDK builds targeting devices with different page sizes.

library/src/main/jni/buildJNI (2)

53-57: LGTM! Well-implemented command-line option.

The new --16kb option correctly:

  • Supports case-insensitive variants (--16kb and --16KB)
  • Sets the appropriate environment variable CGE_ENABLE_16KB_PAGE_SIZE=1
  • Provides clear user feedback
  • Follows the existing argument parsing pattern

58-61: Good improvement to error handling.

Adding a default case to handle unknown options with clear error messages improves the script's usability and debugging experience.

.vscode/tasks.json (1)

181-208: LGTM! Well-structured VS Code tasks for 16KB page size feature.

The new tasks are properly configured and provide convenient IDE integration for toggling the 16KB page size feature. They follow the existing task structure and naming conventions consistently.

library/src/main/jni/Android.mk (2)

112-114: LGTM! Proper linker flag for 16KB page size support.

The conditional addition of -Wl,-z,max-page-size=16384 is correct for enabling 16KB page size support. This aligns with the Android documentation for flexible page sizes.


168-174: Verify consistency with CMake build system.

The conditional FFmpeg path switching is well-implemented. However, ensure that the CMake build system (CMakeLists.txt) uses the same conditional logic and paths for consistency.

#!/bin/bash
# Verify CMake build system uses consistent FFmpeg paths and conditions
grep -A 10 -B 5 "16KB\|16kb\|ffmpeg-16kb" library/src/main/jni/CMakeLists.txt
README.md (3)

18-18: Good documentation improvement.

Adding the GitHub repository URL in the comment improves clarity for developers.


24-44: Comprehensive dependency documentation.

The new dependency variants clearly document the different page size and feature combinations. The naming convention (adding -16k and -min suffixes) is intuitive and well-organized.


95-96: Clear instructions for 16KB page size enablement.

The environment variable approach is consistent with the build system implementation and provides a simple way for developers to enable 16KB page size support.

library/build.gradle (2)

132-140: Well-implemented version naming logic.

The conditional version naming correctly implements the scheme documented in the README. The logic properly handles both 16KB page size (-16k) and minimal build (-min) suffixes, allowing for combined suffixes like 3.1.0-16k-min.


150-154: Improved Maven publishing configuration.

The updated publishing configuration properly handles different Android components and explicitly includes the AAR artifact, which should improve the reliability of artifact publishing.

library/src/main/jni/ffmpeg/include/config.arm64-v8a.h (2)

44-45: Appropriate ARM64 CPU features enabled.

The configuration correctly enables ARM64-v8a specific features:

  • HAVE_ARMV8 1 and HAVE_ARMV8_EXTERNAL 1
  • HAVE_NEON 1 and HAVE_NEON_EXTERNAL 1
  • HAVE_ARMV8_INLINE 1 and HAVE_NEON_INLINE 1

These settings are appropriate for ARM64-v8a architecture and will enable optimized code paths.

Also applies to: 88-89, 132-133


1-11: ```shell
#!/bin/bash

Check license consistency across all architecture config headers

echo "License strings in config headers:"
find library/src/main/jni -type f -name "config.*.h" -print0 | xargs -0 rg --no-heading "#define FFMPEG_LICENSE"

echo

Check CONFIG_THIS_YEAR consistency across all architecture config headers

echo "CONFIG_THIS_YEAR in config headers:"
find library/src/main/jni -type f -name "config.*.h" -print0 | xargs -0 rg --no-heading "#define CONFIG_THIS_YEAR"


</details>
<details>
<summary>library/src/main/jni/ffmpeg/include/config.x86_64.h (1)</summary>

`511-520`: **CUDA / NVENC flags enabled on Android – check link-time failures**

`CONFIG_CUDA 1`, `CONFIG_NVENC 1`, `CONFIG_CUVID 1`, etc. are set, but CUDA/NVENC tool-chains are not available in the Android NDK for x86_64.  
Expect unresolved symbols at link time or bigger binaries with dead code.

Re-run `configure` with `--disable-cuda --disable-nvenc --disable-cuvid` (or similar) unless you explicitly ship custom CUDA stubs.

</details>
<details>
<summary>library/src/main/jni/ffmpeg-16kb/include/config.armeabi-v7a.h (2)</summary>

`533-535`: **Static + small build flags are appropriate**

`--enable-small` + static linking fit mobile footprints; no action needed.

---

`196-198`: ```shell
#!/bin/bash
# List all FFmpeg config headers and check HAVE_X86ASM values
echo "Config headers and HAVE_X86ASM definitions:"
for file in library/src/main/jni/ffmpeg-16kb/include/config.*.h; do
  echo "=== $file ==="
  grep -n "HAVE_X86ASM" "$file" || echo "  (no HAVE_X86ASM)"
done
library/src/main/jni/ffmpeg-16kb/include/config.x86_64.h (1)

511-520: Validate CUDA / CUVID / NVENC flags for Android-x86_64

CONFIG_CUDA, CONFIG_CUVID, CONFIG_NVENC are enabled (1) yet Android-x86_64
NDK tool-chains rarely ship the required CUDA SDK, and the resulting objects
will pull unresolved symbols (cudaMalloc, nvEncodePicture, …).

Confirm that:

  1. The pre-built 16 KB libraries you ship actually contain/need these stubs.
  2. Java side loads libcuda.so/libnvenc.so from the device (unlikely).

If they are not strictly required, disable them in configure to save ~4 MB
of binary size and avoid runtime link errors on devices without CUDA support.

library/src/main/jni/ffmpeg/include/config.x86.h (1)

4-4: Machine-specific absolute paths hurt reproducibility and leak local env details

FFMPEG_CONFIGURATION embeds /Volumes/HikData/... and other absolute paths from the author’s workstation.
These paths:

  1. Break deterministic builds – anyone rebuilding in another location will get a different binary hash.
  2. Expose your internal directory layout in public artefacts / crash logs.
  3. Complicate CI caching because paths become embedded in objects.

Regenerate the header with --prefix, --extra-cflags, --extra-ldflags, … that use environment variables or relative paths, or post-process the string to scrub absolute segments before committing.

#!/bin/bash
# Detect any hard-coded absolute paths in all ffmpeg config headers
fd -e h config | xargs grep -nE '/(Users|Volumes|home|C:)' || true
library/src/main/jni/ffmpeg-16kb/include/config.arm64-v8a.h (2)

4-9: ```shell
#!/bin/bash

Verify that absolute build-machine paths are present in the generated header

grep -n "/Volumes/HikData" library/src/main/jni/ffmpeg-16kb/include/config.arm64-v8a.h


---

`195-199`: ```shell
#!/bin/bash
# Inspect the top of the config file for architecture and ISA defines
sed -n '1,60p' library/src/main/jni/ffmpeg-16kb/include/config.arm64-v8a.h

# Locate the HAVE_X86ASM definition
grep -n "#define HAVE_X86ASM" library/src/main/jni/ffmpeg-16kb/include/config.arm64-v8a.h

# Find any ARCH_* macros in this config
grep -n "#define ARCH" library/src/main/jni/ffmpeg-16kb/include/config.arm64-v8a.h

# Search for how HAVE_X86ASM is used elsewhere in the FFmpeg tree
grep -R "HAVE_X86ASM" -n library/src/main/jni/ffmpeg-16kb

@wysaid wysaid force-pushed the flexible_page_sizes branch from 8da32a7 to 31dfbe8 Compare July 1, 2025 16:21
@wysaid wysaid merged commit de41b19 into master Jul 2, 2025
2 checks passed
@wysaid wysaid deleted the flexible_page_sizes branch July 2, 2025 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant