[automerger skipped] Fix Segv on unknown address error flagged by fuzzer test. am: d44311374e -s ours am: a371fa8751 -s ours am: 5e34d3792a -s ours am: 7a8d8fe3ad -s ours am: d6dae88a95 -s ours am: 8158125455 -s ours am: 2b7ed94e76 -s ours am: c2968abe3d -s ours am: a7afbea75b -s ours
am skip reason: Merged-In I255cd68b7641e96ac47ab81479b9b46b78c15580 with SHA-1 9b2183ae5d is already in history
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/av/+/23914014
Change-Id: I4e3ffb60a380371bd9f750a00bab7e5ae052d651
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/media/codec2/sfplugin/utils/Codec2CommonUtils.cpp b/media/codec2/sfplugin/utils/Codec2CommonUtils.cpp
index 332d3ac..f428fce 100644
--- a/media/codec2/sfplugin/utils/Codec2CommonUtils.cpp
+++ b/media/codec2/sfplugin/utils/Codec2CommonUtils.cpp
@@ -82,7 +82,8 @@
return false;
}
- const AHardwareBuffer_Desc desc = {
+ // Default scenario --- the consumer is display or GPU
+ const AHardwareBuffer_Desc consumableForDisplayOrGpu = {
.width = 320,
.height = 240,
.format = format,
@@ -96,7 +97,40 @@
.rfu1 = 0,
};
- return AHardwareBuffer_isSupported(&desc);
+ // The consumer is a HW encoder
+ const AHardwareBuffer_Desc consumableForHwEncoder = {
+ .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 consumableForSwEncoder = {
+ .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(&consumableForDisplayOrGpu)
+ && AHardwareBuffer_isSupported(&consumableForHwEncoder)
+ && AHardwareBuffer_isSupported(&consumableForSwEncoder);
}
} // namespace android