Skip to content
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

Fix ImageReader crash when accessing Image buffer #119

Closed

Conversation

IrishBAM
Copy link

WHAT

When setSurface with a ImageReader surface, the MediaFormat.KEY_COLOR_FORMAT has to correspond to ImageReader's format. If not set, some codec will uses default not compatible with ImageFormat.YUV_420_888 and causes crash similar to https://ittone.ma/ittone/android-jni-detected-error-in-application-non-zero-capacity-for-nullptr-pointer-1/

Commits

  • Fix ImageReader crash when accessing Image buffer by setting MediaFormat.KEY_COLOR_FORMAT to CodecCapabilities.COLOR_FormatYUV420Flexible corresponding to ImageFormat.YUV_420_888 for extraction.

…Format.KEY_COLOR_FORMAT` to `CodecCapabilities.COLOR_FormatYUV420Flexible` corresponding to `ImageFormat.YUV_420_888` for extraction.
@protyposis
Copy link
Owner

Thank you for this PR. There are two reasons why it's not merged yet:

  • I'm unsure if this fix is broadly applicable or just for a specific scenario.
  • COLOR_FormatYUV420Flexible was introduced in Android API level 21, but the library supports down to API 16.

I'm keeping it open to collect additional feedback.

@protyposis protyposis deleted the branch protyposis:develop February 20, 2024 08:39
@protyposis protyposis closed this Feb 20, 2024
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.

2 participants