diff --git a/source/Lib/CommonLib/Slice.h b/source/Lib/CommonLib/Slice.h
index b13bc03fc031dac0a0547bd2a513533f311c1a40..8934b3501db03cdd3aa7f1a643b93bad3d7a6656 100644
--- a/source/Lib/CommonLib/Slice.h
+++ b/source/Lib/CommonLib/Slice.h
@@ -2495,6 +2495,9 @@ private:
   int                         m_numAlfAps;                                              //!< number of alf aps active for the picture
   std::vector<int>            m_alfApsId;                                               //!< list of alf aps for the picture
   int                         m_alfChromaApsId;                                         //!< chroma alf aps ID
+#if JVET_Q0358_ALF_NALU_TID_CONSTRAINT
+  int                         m_alfChromaIdc;                                            //!< alf chroma idc
+#endif
 #if JVET_Q0795_CCALF
   bool m_ccalfEnabledFlag[MAX_NUM_COMPONENT];
   int  m_ccalfCbApsId;
@@ -2688,6 +2691,10 @@ public:
   int                         getNumAlfAps() const                                      { return m_numAlfAps;                                                                          }
   void                        setAlfApsIdChroma(int i)                                  { m_alfChromaApsId = i;                                                                        }
   int                         getAlfApsIdChroma() const                                 { return m_alfChromaApsId;                                                                     }
+#if JVET_Q0358_ALF_NALU_TID_CONSTRAINT
+  void                        setAlfChromaIdc(int i)                                    { m_alfChromaIdc = i;                                                                          }
+  int                         getAlfChromaIdc() const                                   { return m_alfChromaIdc;                                                                       }
+#endif
 #if JVET_Q0795_CCALF
   void setCcAlfEnabledFlag(ComponentID compId, bool b) { m_ccalfEnabledFlag[compId] = b; }
   bool getCcAlfEnabledFlag(ComponentID compId) const { return m_ccalfEnabledFlag[compId]; }
diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h
index 8ccd10bec935758f293c8448c0c805aa2b54bbb8..08004aa6ac1e24c36e2697c7cdab7dc944eba95e 100644
--- a/source/Lib/CommonLib/TypeDef.h
+++ b/source/Lib/CommonLib/TypeDef.h
@@ -76,6 +76,8 @@
 
 #define JVET_P0117_PTL_SCALABILITY                        1 // JVET-P0117: sps_ptl_dpb_hrd_params_present_flag related syntax change, others in JVET-Q0786
 
+#define JVET_Q0358_ALF_NALU_TID_CONSTRAINT                1 // JVET-Q0358: TemporalId constraint between ALF_APS NALU and the pic associated with PH
+
 #define JVET_Q0118_CLEANUPS                               1 // JVET-Q0118: AHG8/AHG9: Scalability HLS cleanups
 
 #define JVET_Q0416_WRAPAROUND_OFFSET                      1  //JVET-Q0416: subtract CtbSizeY / MinCbSizeY + 2 from wraparound offset before signaling
diff --git a/source/Lib/DecoderLib/VLCReader.cpp b/source/Lib/DecoderLib/VLCReader.cpp
index f38dbdc3511b94466d6c8da2b3461a3c25b33be0..7fd2d37d2a49eaa7322655bc3d8b4f72d54a65bb 100644
--- a/source/Lib/DecoderLib/VLCReader.cpp
+++ b/source/Lib/DecoderLib/VLCReader.cpp
@@ -2767,6 +2767,9 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag
         {
           alfChromaIdc = 0;
         }
+#if JVET_Q0358_ALF_NALU_TID_CONSTRAINT
+        picHeader->setAlfChromaIdc(alfChromaIdc);
+#endif
         if (alfChromaIdc)
         {
           READ_CODE(3, uiCode, "pic_alf_aps_id_chroma");
@@ -3874,6 +3877,33 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag
 #endif
 }
 
+#if JVET_Q0358_ALF_NALU_TID_CONSTRAINT
+void  HLSyntaxReader::checkAlfNaluTidAndPicTid(Slice* pcSlice, PicHeader* picHeader, ParameterSetManager *parameterSetManager)
+{
+  SPS* sps = parameterSetManager->getSPS(picHeader->getSPSId());
+  PPS* pps = parameterSetManager->getPPS(picHeader->getPPSId());
+  int curPicTid = pcSlice->getTLayer();
+  APS* aps;
+  const std::vector<int>&   apsId = picHeader->getAlfAPSs();
+
+  if (sps->getALFEnabledFlag() && pps->getAlfInfoInPhFlag() && picHeader->getAlfEnabledFlag(COMPONENT_Y))
+  {
+    //luma
+    for (int i = 0; i < picHeader->getNumAlfAps(); i++)
+    {
+      aps = parameterSetManager->getAPS(apsId[i], ALF_APS);
+      CHECK(aps->getTemporalId() > curPicTid, "The TemporalId of the APS NAL unit having aps_params_type equal to ALF_APS and adaptation_parameter_set_id equal to ph_alf_aps_id_luma[ i ] shall be less than or equal to the TemporalId of the picture associated with the PH.");
+    }
+    //chroma
+    if (picHeader->getAlfChromaIdc())
+    {
+      int chromaAlfApsId = picHeader->getAlfApsIdChroma();
+      aps = parameterSetManager->getAPS(chromaAlfApsId, ALF_APS);
+      CHECK(aps->getTemporalId() > curPicTid, "The TemporalId of the APS NAL unit having aps_params_type equal to ALF_APS and adaptation_parameter_set_id equal to ph_alf_aps_id_chroma shall be less than or equal to the TemporalId of the picture associated with the PH.");
+    }
+  }
+}
+#endif
 void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, ParameterSetManager *parameterSetManager, const int prevTid0POC)
 {
   uint32_t  uiCode;
@@ -3895,6 +3925,9 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par
 #endif
   CHECK(picHeader==0, "Invalid Picture Header");
   CHECK(picHeader->isValid()==false, "Invalid Picture Header");
+#if JVET_Q0358_ALF_NALU_TID_CONSTRAINT
+  checkAlfNaluTidAndPicTid(pcSlice, picHeader, parameterSetManager);
+#endif
   pps = parameterSetManager->getPPS( picHeader->getPPSId() );
   //!KS: need to add error handling code here, if PPS is not available
   CHECK(pps==0, "Invalid PPS");
diff --git a/source/Lib/DecoderLib/VLCReader.h b/source/Lib/DecoderLib/VLCReader.h
index e160db1999fe6889f5c3e05a9e1030b5d1f42541..c0e93343f7250cac74200352cf4774397bffd29f 100644
--- a/source/Lib/DecoderLib/VLCReader.h
+++ b/source/Lib/DecoderLib/VLCReader.h
@@ -180,6 +180,9 @@ public:
   void  parsePictureHeader  ( PicHeader* picHeader, ParameterSetManager *parameterSetManager, bool readRbspTrailingBits );
 #else
   void  parsePictureHeader  ( PicHeader* picHeader, ParameterSetManager *parameterSetManager );
+#endif
+#if JVET_Q0358_ALF_NALU_TID_CONSTRAINT
+  void  checkAlfNaluTidAndPicTid(Slice* pcSlice, PicHeader* picHeader, ParameterSetManager *parameterSetManager);
 #endif
   void  parseSliceHeader    ( Slice* pcSlice, PicHeader* picHeader, ParameterSetManager *parameterSetManager, const int prevTid0POC );
 #if JVET_Q0819_PH_CHANGES