Skip to content

Commit

Permalink
add 420 p hardware buffer support to igl
Browse files Browse the repository at this point in the history
Reviewed By: pixelperfect3, corporateshark

Differential Revision: D68332754

fbshipit-source-id: 1edba8413d5a80f25956aa36ba6016a92387f575
  • Loading branch information
Heidi Gaertner authored and facebook-github-bot committed Jan 22, 2025
1 parent b16f7e0 commit d08847b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/igl/android/NativeHWBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ uint32_t getNativeHWFormat(TextureFormat iglFormat) {
case TextureFormat::YUV_NV12:
return AHARDWAREBUFFER_FORMAT_YCbCr_420_SP_VENUS;

#if __ANDROID_MIN_SDK_VERSION__ >= 30
case TextureFormat::YUV_420p:
return AHARDWAREBUFFER_FORMAT_Y8Cb8Cr8_420;
#endif

default:
return 0;
}
Expand Down Expand Up @@ -107,6 +112,11 @@ TextureFormat getIglFormat(uint32_t nativeFormat) {
case COLOR_QCOM_FORMATYUV420PackedSemiPlanar32m:
return TextureFormat::YUV_NV12;

#if __ANDROID_MIN_SDK_VERSION__ >= 30
case AHARDWAREBUFFER_FORMAT_Y8Cb8Cr8_420:
return TextureFormat::YUV_420p;
#endif

default:
return TextureFormat::Invalid;
}
Expand Down Expand Up @@ -191,6 +201,13 @@ Result INativeHWTextureBuffer::attachHWBuffer(AHardwareBuffer* buffer) {
const bool isValid = desc.format != TextureFormat::Invalid && desc.usage != 0;
if (!isValid) {
AHardwareBuffer_release(buffer);
IGL_LOG_ERROR(
"Can not create texture for hardware buffer format is %x usage is %x width is %d height "
"is %d",
hwbDesc.format,
hwbDesc.usage,
hwbDesc.width,
hwbDesc.height);
return Result(Result::Code::Unsupported, "Can not create texture for hardware buffer");
}

Expand Down
7 changes: 7 additions & 0 deletions src/igl/tests/android/NativeHWBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ TEST_F(NativeHWBufferTest, Basic_getNativeHWFormat) {
EXPECT_EQ(getNativeHWFormat(igl::TextureFormat::YUV_NV12),
AHARDWAREBUFFER_FORMAT_YCbCr_420_SP_VENUS);
EXPECT_EQ(getNativeHWFormat(igl::TextureFormat::Invalid), 0);
#if __ANDROID_MIN_SDK_VERSION__ >= 30
EXPECT_EQ(getNativeHWFormat(igl::TextureFormat::YUV_420p), AHARDWAREBUFFER_FORMAT_Y8Cb8Cr8_420);
#endif
}

TEST_F(NativeHWBufferTest, Basic_getIglFormat) {
Expand All @@ -80,6 +83,10 @@ TEST_F(NativeHWBufferTest, Basic_getIglFormat) {
EXPECT_EQ(igl::android::getIglFormat(AHARDWAREBUFFER_FORMAT_S8_UINT), TextureFormat::S_UInt8);
EXPECT_EQ(igl::android::getIglFormat(AHARDWAREBUFFER_FORMAT_YCbCr_420_SP_VENUS),
TextureFormat::YUV_NV12);
#if __ANDROID_MIN_SDK_VERSION__ >= 30
EXPECT_EQ(igl::android::getIglFormat(AHARDWAREBUFFER_FORMAT_Y8Cb8Cr8_420),
TextureFormat::YUV_420p);
#endif
}

TEST_F(NativeHWBufferTest, getNativeHWBufferUsage) {
Expand Down

0 comments on commit d08847b

Please sign in to comment.