Use MediaCodec suggested conversion components

This commit is contained in:
2025-11-20 08:46:50 +09:00
parent 1571123a5e
commit 97f4be574f

View File

@@ -407,26 +407,16 @@ bool MediaCodecSurfaceManager::CreateVulkanImage(void* vk_device, void* vk_insta
LogInfo(" YcbcrModel: " + std::to_string(ycbcrConversionCreateInfo.ycbcrModel));
LogInfo(" YcbcrRange: " + std::to_string(ycbcrConversionCreateInfo.ycbcrRange));
// Log component mapping from MediaCodec
LogInfo(" MediaCodec suggested components:");
// Use MediaCodec suggested component mapping for all devices
// Previous Qualcomm-specific swizzle workaround removed - trust MediaCodec
ycbcrConversionCreateInfo.components = ahb_format_props.samplerYcbcrConversionComponents;
LogInfo(" Using MediaCodec suggested components:");
LogInfo(" r: " + std::to_string(ahb_format_props.samplerYcbcrConversionComponents.r));
LogInfo(" g: " + std::to_string(ahb_format_props.samplerYcbcrConversionComponents.g));
LogInfo(" b: " + std::to_string(ahb_format_props.samplerYcbcrConversionComponents.b));
LogInfo(" a: " + std::to_string(ahb_format_props.samplerYcbcrConversionComponents.a));
// Qualcomm Adreno GPU requires component swizzle because it outputs NV21 (CrCb)
// but VkFormat expects NV12 (CbCr)
if (is_qualcomm_gpu) {
ycbcrConversionCreateInfo.components.r = VK_COMPONENT_SWIZZLE_B; // R (Cr) from B position
ycbcrConversionCreateInfo.components.g = VK_COMPONENT_SWIZZLE_G; // G (Y) unchanged
ycbcrConversionCreateInfo.components.b = VK_COMPONENT_SWIZZLE_R; // B (Cb) from R position
ycbcrConversionCreateInfo.components.a = VK_COMPONENT_SWIZZLE_A; // A unchanged
LogInfo(" Using SWAPPED components (R<-B, B<-R) for Adreno NV21");
} else {
ycbcrConversionCreateInfo.components = ahb_format_props.samplerYcbcrConversionComponents;
LogInfo(" Using MediaCodec suggested components");
}
// Use MediaCodec suggested chroma offset (DON'T override!)
ycbcrConversionCreateInfo.xChromaOffset = static_cast<VkChromaLocation>(ahb_format_props.suggestedXChromaOffset);
ycbcrConversionCreateInfo.yChromaOffset = static_cast<VkChromaLocation>(ahb_format_props.suggestedYChromaOffset);