Fix Memory Issue#20509
Conversation
Fix the YUV index and YUVPlaner condition
|
@komakai I figure you were the primary contributor on this feature. It will be helpful if you please let me know in case I am missing something here. |
| AImage_getPlaneData(image.get(), 1, &vPixel, &vLen); | ||
| AImage_getPlaneData(image.get(), 2, &uPixel, &uLen); | ||
| AImage_getPlaneData(image.get(), 1, &uPixel, &vLen); | ||
| AImage_getPlaneData(image.get(), 2, &vPixel, &uLen); |
There was a problem hiding this comment.
Don't you also want to swap vLen with uLen ?
There was a problem hiding this comment.
yeah, I missed that. They were of same length, so I did not catch it.
There was a problem hiding this comment.
@komakai I made the changes. Can please suggest how to take this PR further? I am not sure why the default build has failed. I can probably initiate a retest is that is something holding us back.
There was a problem hiding this comment.
@saikatnanda I'm also not sure why the build is failing - will try and take a look when I get a minute. In the meantime could you rollup your changes into a single commit? Also it might be worth rebasing onto the latest master - sometimes that solves weird build failures.
There was a problem hiding this comment.
Thanks. I will then rebase and will create a fresh PR to look better.
| fourCC = FOURCC_NV21; | ||
| } | ||
| } else if ( (uvPixelStride == 1) && (vPixel = uPixel + uLen) && (yLen == frameWidth * frameHeight) && (uLen == yLen / 4) && (vLen == uLen) ) { | ||
| } else if ( (uvPixelStride == 1) && (vPixel == uPixel + uLen) && (yLen == frameWidth * frameHeight) && (uLen == yLen / 4) && (vLen == uLen) ) { |
There was a problem hiding this comment.
Good catch! Thanks for finding that.
Fix uLen and vLen
|
bump!! |
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.
The code was crashing on
buffer.insert()line#330 on Android 11 Emulator with Camera2 NDK. This is tested with a C++ Test Application.It looks like the U & V indexes are revered and the YUVPlaner check condition is having an assignment operator than
==.This fix satisfies the YUV buffer memory layout expectation as in https://en.wikipedia.org/wiki/YUV#/media/File:Yuv420.svg