Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e8898de1 authored by mtk12103's avatar mtk12103 Committed by Cherrypicker Worker
Browse files

Add buffer usage for more consumers

The consumer of a video decoder output could be display, GPU, or
encoders. Add checks for encoders for pixel format support test.

Bug: 282895340
Test: android.mediav2.cts.CodecEncoderSurfaceTest
(cherry picked from https://android-review.googlesource.com/q/commit:a438ca0a0e56f958994c6c0c1358c8cf9610748a)
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:06e466b209cf3fdd74aa65bd1098e9f0adac9a02)
Merged-In: Iebc17309e04a84d08f137f38e561b83a58ecb642
Change-Id: Iebc17309e04a84d08f137f38e561b83a58ecb642
parent 0765e026
Loading
Loading
Loading
Loading
+35 −1
Original line number Diff line number Diff line
@@ -82,6 +82,7 @@ bool isHalPixelFormatSupported(AHardwareBuffer_Format format) {
        return false;
    }

    // Default scenario --- the consumer is display or GPU
    const AHardwareBuffer_Desc desc = {
            .width = 320,
            .height = 240,
@@ -96,7 +97,40 @@ bool isHalPixelFormatSupported(AHardwareBuffer_Format format) {
            .rfu1 = 0,
    };

    return AHardwareBuffer_isSupported(&desc);
    // The consumer is a HW encoder
    const AHardwareBuffer_Desc descHwEncoder = {
            .width = 320,
            .height = 240,
            .format = format,
            .layers = 1,
            .usage = AHARDWAREBUFFER_USAGE_CPU_READ_RARELY |
                     AHARDWAREBUFFER_USAGE_CPU_WRITE_OFTEN |
                     AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE |
                     AHARDWAREBUFFER_USAGE_COMPOSER_OVERLAY |
                     AHARDWAREBUFFER_USAGE_VIDEO_ENCODE,
            .stride = 0,
            .rfu0 = 0,
            .rfu1 = 0,
    };

    // The consumer is a SW encoder
    const AHardwareBuffer_Desc descSwEncoder = {
            .width = 320,
            .height = 240,
            .format = format,
            .layers = 1,
            .usage = AHARDWAREBUFFER_USAGE_CPU_READ_OFTEN |
                     AHARDWAREBUFFER_USAGE_CPU_WRITE_OFTEN |
                     AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE |
                     AHARDWAREBUFFER_USAGE_COMPOSER_OVERLAY,
            .stride = 0,
            .rfu0 = 0,
            .rfu1 = 0,
    };

    return AHardwareBuffer_isSupported(&desc)
            && AHardwareBuffer_isSupported(&descHwEncoder)
            && AHardwareBuffer_isSupported(&descSwEncoder);
}

}  // namespace android