Skip to content

Commit

Permalink
gralloc: Allow devices to opt-in for YCrCb camera video encode
Browse files Browse the repository at this point in the history
DeviceAsWebcam is using USAGE_VIDEO_ENCODE [1] for buffers and
this results in combined usage: (VIDEO_ENCODER | CAMERA_OUTPUT).

On some Qcom devices (verified on pyxis (sdm710)) and maybe others
DeviceAsWebcam has red & blue colors swapped with HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS.

When using HAL_PIXEL_FORMAT_YCrCb_420_SP_VENUS the output from
DeviceAsWebcam has correct colors.

[1] https://android.googlesource.com/platform/packages/services/DeviceAsWebcam/+/d079a82ba4f773210c01d488d2dfa1d4d25be8e2

Change-Id: I4376102e2b0eeaefed536eff29c315a71e469b57
  • Loading branch information
ivecera authored and 33bca committed Jul 17, 2024
1 parent 40f8202 commit d40d593
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ soong_config_module_type {
"var3",
"llvmcov",
"panel_dimension_extra_precision",
"use_ycrcb_camera_encode",
],
properties: [
"cflags",
Expand Down Expand Up @@ -112,6 +113,9 @@ qtidisplay_cc_defaults {
panel_dimension_extra_precision: {
cflags: ["-DTARGET_PANEL_DIMENSION_HAS_EXTRA_PRECISION"],
},
use_ycrcb_camera_encode: {
cflags: ["-DTARGET_USE_YCRCB_CAMERA_ENCODE"],
},
},
}

Expand Down
5 changes: 5 additions & 0 deletions config/display-product.mk
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ SOONG_CONFIG_qtidisplay_var2 := false
SOONG_CONFIG_qtidisplay_var3 := false
SOONG_CONFIG_qtidisplay_llvmcov := false
SOONG_CONFIG_qtidisplay_panel_dimension_extra_precision := false
SOONG_CONFIG_qtidisplay_use_ycrcb_camera_encode := false

ifeq ($(call is-vendor-board-platform,QCOM),true)
SOONG_CONFIG_qtidisplay_displayconfig_enabled := true
Expand All @@ -177,6 +178,10 @@ ifeq ($(TARGET_PANEL_DIMENSION_HAS_EXTRA_PRECISION), true)
SOONG_CONFIG_qtidisplay_panel_dimension_extra_precision := true
endif

ifeq ($(TARGET_USE_YCRCB_CAMERA_ENCODE), true)
SOONG_CONFIG_qtidisplay_use_ycrcb_camera_encode := true
endif

# Techpack values

ifeq ($(TARGET_IS_HEADLESS), true)
Expand Down
10 changes: 9 additions & 1 deletion gralloc/gr_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1545,7 +1545,15 @@ int GetImplDefinedFormat(uint64_t usage, int format) {
} else if (usage & GRALLOC_USAGE_PRIVATE_HEIF) {
gr_format = HAL_PIXEL_FORMAT_NV12_HEIF;
} else if (format == static_cast<int>(PixelFormat::YCBCR_420_888)) {
gr_format = HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS;
#ifdef TARGET_USE_YCRCB_CAMERA_ENCODE
if (usage & BufferUsage::CAMERA_OUTPUT) {
gr_format = HAL_PIXEL_FORMAT_YCrCb_420_SP_VENUS;
} else {
gr_format = HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS;
}
#else
gr_format = HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS;
#endif
} else {
gr_format = HAL_PIXEL_FORMAT_NV12_ENCODEABLE; // NV12
}
Expand Down

0 comments on commit d40d593

Please sign in to comment.