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

Unsupported format HAL_PIXEL_FORMAT_YCbCr_420_888 #23

Open
goffioul opened this issue Apr 19, 2021 · 1 comment
Open

Unsupported format HAL_PIXEL_FORMAT_YCbCr_420_888 #23

goffioul opened this issue Apr 19, 2021 · 1 comment

Comments

@goffioul
Copy link

On Android R (android-11.0.0_r35) with mesa-21.1.0, gbm_gralloc and drm_hwcomposer, opening the webcam in a WebView (Chrome/89) crashes the app at this line: https://github.com/robherring/gbm_gralloc/blob/master/gralloc_gbm.cpp#L386

The format requested is HAL_PIXEL_FORMAT_YCbCr_420_888 (35), which is not supported by gralloc_gbm_get_bpp. It returns 0 and leads to SIGFPE.

@goffioul
Copy link
Author

After finding various references about mapping the flexible pixel format to NV12, I tried this patch, which seems to solve the problem on my Baytrail platform, there's no crash and the WebView is able to access/display the webcam stream:

diff --git a/gralloc_gbm.cpp b/gralloc_gbm.cpp
index 5670213..75043dd 100644
--- a/gralloc_gbm.cpp
+++ b/gralloc_gbm.cpp
@@ -98,6 +98,7 @@ static uint32_t get_gbm_format(int format)
                break;
        case HAL_PIXEL_FORMAT_YCbCr_422_SP:
        case HAL_PIXEL_FORMAT_YCrCb_420_SP:
+       case HAL_PIXEL_FORMAT_YCbCr_420_888:
        default:
                fmt = 0;
                break;
@@ -127,6 +128,7 @@ static int gralloc_gbm_get_bpp(int format)
        case HAL_PIXEL_FORMAT_YV12:
        case HAL_PIXEL_FORMAT_YCbCr_422_SP:
        case HAL_PIXEL_FORMAT_YCrCb_420_SP:
+       case HAL_PIXEL_FORMAT_YCbCr_420_888:
                bpp = 1;
                break;
        default:
@@ -507,6 +509,7 @@ int gralloc_gbm_bo_lock_ycbcr(buffer_handle_t handle,
 
        switch (hnd->format) {
        case HAL_PIXEL_FORMAT_YCrCb_420_SP:
+       case HAL_PIXEL_FORMAT_YCbCr_420_888:
                ystride = cstride = GRALLOC_ALIGN(hnd->width, 16);
                ycbcr->y = addr;
                ycbcr->cr = (unsigned char *)addr + ystride * hnd->height;

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

No branches or pull requests

1 participant