[Decode] Modify Reference Surfce Compression Format

Modify Reference Surfce Compression Format according to per surface control
diff --git a/media_driver/agnostic/gen12/hw/vdbox/mhw_vdbox_hcp_g12_X.cpp b/media_driver/agnostic/gen12/hw/vdbox/mhw_vdbox_hcp_g12_X.cpp
index 9d0e7f9..a170b8e 100644
--- a/media_driver/agnostic/gen12/hw/vdbox/mhw_vdbox_hcp_g12_X.cpp
+++ b/media_driver/agnostic/gen12/hw/vdbox/mhw_vdbox_hcp_g12_X.cpp
@@ -1714,7 +1714,6 @@
         cmd->DW3.YOffsetForVCr = params->dwReconSurfHeight;
     }
 
-    cmd->DW4.CompressionFormat       = params->dwCompressionFormat;
     cmd->DW4.MemoryCompressionEnable = MmcEnable(params->mmcState) ? ((~params->mmcSkipMask) & 0xff) : 0;
     cmd->DW4.CompressionType         = MmcIsRc(params->mmcState) ? 0xff : 0;
 
diff --git a/media_driver/media_softlet/agnostic/Xe_M/Xe_M_base/codec/hal/dec/hevc/packet/decode_hevc_picture_packet_xe_m_base.cpp b/media_driver/media_softlet/agnostic/Xe_M/Xe_M_base/codec/hal/dec/hevc/packet/decode_hevc_picture_packet_xe_m_base.cpp
index 33f2356..ea0c21b 100644
--- a/media_driver/media_softlet/agnostic/Xe_M/Xe_M_base/codec/hal/dec/hevc/packet/decode_hevc_picture_packet_xe_m_base.cpp
+++ b/media_driver/media_softlet/agnostic/Xe_M/Xe_M_base/codec/hal/dec/hevc/packet/decode_hevc_picture_packet_xe_m_base.cpp
@@ -367,12 +367,6 @@
     DECODE_CHK_STATUS(m_mmcState->SetSurfaceMmcState(dstSurfaceParams.psSurface));
     DECODE_CHK_STATUS(m_mmcState->GetSurfaceMmcState(dstSurfaceParams.psSurface, &dstSurfaceParams.mmcState));
     DECODE_CHK_STATUS(m_mmcState->GetSurfaceMmcFormat(dstSurfaceParams.psSurface, &dstSurfaceParams.dwCompressionFormat));
-
-    if (dstSurfaceParams.mmcState == MOS_MEMCOMP_DISABLED && m_mmcState->IsMmcEnabled())
-    {
-        m_hevcBasicFeature->m_hasMixedmmcState = true;
-        DECODE_NORMALMESSAGE("Current %d frame has mixed mmc state\n", m_hevcBasicFeature->m_frameNum);
-    }
 #endif
 
     return MOS_STATUS_SUCCESS;
@@ -397,8 +391,8 @@
     // Set refSurfaceParams mmcState as MOS_MEMCOMP_MC to satisfy MmcEnable in AddHcpSurfaceCmd
     // The actual mmcstate is recorded by refSurfaceParams.mmcSkipMask
     refSurfaceParams.mmcState = MOS_MEMCOMP_MC;
-    DECODE_CHK_STATUS(m_mmcState->GetSurfaceMmcFormat(refSurfaceParams.psSurface, &refSurfaceParams.dwCompressionFormat));
     DECODE_CHK_STATUS(hevcDecodeMemComp->SetRefSurfaceMask(*m_hevcBasicFeature, pipeBufAddrParams.presReferences, refSurfaceParams.mmcSkipMask));
+    DECODE_CHK_STATUS(hevcDecodeMemComp->SetRefSurfaceCompressionFormat(*m_hevcBasicFeature, pipeBufAddrParams.presReferences, refSurfaceParams.dwCompressionFormat));
 #endif
 
     return MOS_STATUS_SUCCESS;
diff --git a/media_softlet/agnostic/common/codec/hal/dec/hevc/mmc/decode_hevc_mem_compression.cpp b/media_softlet/agnostic/common/codec/hal/dec/hevc/mmc/decode_hevc_mem_compression.cpp
index 8528d6d..4cd715c 100644
--- a/media_softlet/agnostic/common/codec/hal/dec/hevc/mmc/decode_hevc_mem_compression.cpp
+++ b/media_softlet/agnostic/common/codec/hal/dec/hevc/mmc/decode_hevc_mem_compression.cpp
@@ -71,12 +71,6 @@
     {
         if (presReferences[i] != nullptr)
         {
-            if (hevcBasicFeature.m_hasMixedmmcState)
-            {
-                DECODE_NORMALMESSAGE("Decompress reference surface due to mixed mmc state\n");
-                DECODE_CHK_STATUS(m_osInterface->pfnDecompResource(m_osInterface, presReferences[i]));
-            }
-
             DECODE_CHK_STATUS(m_osInterface->pfnGetMemoryCompressionMode(
                 m_osInterface, presReferences[i], &refMmcState));
         }
@@ -92,6 +86,37 @@
     return MOS_STATUS_SUCCESS;
 }
 
+MOS_STATUS HevcDecodeMemComp::SetRefSurfaceCompressionFormat(
+    HevcBasicFeature    &hevcBasicFeature,
+    const PMOS_RESOURCE *presReferences,
+    uint32_t            &mmcCompressionFormat)
+{
+    MOS_MEMCOMP_STATE refMmcState       = MOS_MEMCOMP_DISABLED;
+    uint32_t          compressionFormat = 0;
+    uint32_t          refcompressionFormat = 0;
+
+    for (uint16_t i = 0; i < CODECHAL_MAX_CUR_NUM_REF_FRAME_HEVC; i++)
+    {
+        if (presReferences[i] != nullptr)
+        {
+            DECODE_CHK_STATUS(m_osInterface->pfnGetMemoryCompressionMode(
+                m_osInterface, presReferences[i], &refMmcState));
+
+            if (refMmcState == MOS_MEMCOMP_MC || refMmcState == MOS_MEMCOMP_RC)
+            {
+                DECODE_CHK_STATUS(m_osInterface->pfnGetMemoryCompressionFormat(
+                    m_osInterface, presReferences[i], &compressionFormat));
+
+                refcompressionFormat = compressionFormat;
+            }
+        }
+    }
+    mmcCompressionFormat = refcompressionFormat;
+    DECODE_NORMALMESSAGE("HEVC reference surface compression format %d\n", mmcCompressionFormat);
+
+    return MOS_STATUS_SUCCESS;
+}
+
 MOS_STATUS HevcDecodeMemComp::CheckReferenceList(HevcBasicFeature &hevcBasicFeature,
         MOS_MEMCOMP_STATE &postDeblockSurfMmcState,
         MOS_MEMCOMP_STATE &preDeblockSurfMmcState,
diff --git a/media_softlet/agnostic/common/codec/hal/dec/hevc/mmc/decode_hevc_mem_compression.h b/media_softlet/agnostic/common/codec/hal/dec/hevc/mmc/decode_hevc_mem_compression.h
index 468fbe1..1f9c9d2 100644
--- a/media_softlet/agnostic/common/codec/hal/dec/hevc/mmc/decode_hevc_mem_compression.h
+++ b/media_softlet/agnostic/common/codec/hal/dec/hevc/mmc/decode_hevc_mem_compression.h
@@ -69,6 +69,11 @@
         const PMOS_RESOURCE *presReferences,
         uint8_t             &mmcSkipMask);
 
+    MOS_STATUS SetRefSurfaceCompressionFormat(
+        HevcBasicFeature    &hevcBasicFeature,
+        const PMOS_RESOURCE *presReferences,
+        uint32_t            &compressionFormat);
+
 protected:
     PMOS_INTERFACE m_osInterface = nullptr;
 
diff --git a/media_softlet/agnostic/common/codec/hal/dec/shared/features/decode_basic_feature.h b/media_softlet/agnostic/common/codec/hal/dec/shared/features/decode_basic_feature.h
index b35c79c..b4a48d2 100644
--- a/media_softlet/agnostic/common/codec/hal/dec/shared/features/decode_basic_feature.h
+++ b/media_softlet/agnostic/common/codec/hal/dec/shared/features/decode_basic_feature.h
@@ -137,7 +137,6 @@
     bool                            m_useDummyReference = false;        //!< Indicates if use dummy reference
     MOS_SURFACE                     m_dummyReference;                   //!< Dummy reference surface
     CODECHAL_DUMMY_REFERENCE_STATUS m_dummyReferenceStatus = CODECHAL_DUMMY_REFERENCE_INVALID; //!< Indicate the status of dummy reference
-    bool                            m_hasMixedmmcState  = false;        //!< Indicate if mixed mmc exist
     constexpr static uint8_t m_invalidFrameIndex = 0xff;                //!< Invalid frame index
     constexpr static uint8_t m_maxFrameIndex = CODECHAL_NUM_UNCOMPRESSED_SURFACE_HEVC; //!< Max frame index