[Datatype-cvs] h263/renderer h263dec.cpp, 1.15.2.2.2.5, 1.15.2.2.2.6 h263vidfmt.cpp, 1.16.2.1.2.6, 1.16.2.1.2.7

[Datatype-cvs] h263/renderer h263dec.cpp, 1.15.2.2.2.5, 1.15.2.2.2.6 h263vidfmt.cpp, 1.16.2.1.2.6, 1.16.2.1.2.7

gahluwalia at helixcommunity.org gahluwalia at helixcommunity.org
Mon Sep 20 02:06:07 PST 2010


Update of /cvsroot/datatype/h263/renderer
In directory cvs01.internal.helixcommunity.org:/tmp/cvs-serv23162

Modified Files:
      Tag: hxclient_3_6_1_atlas
	h263dec.cpp h263vidfmt.cpp 
Log Message:
Fallback mechanism from H/W to S/W decoder

Index: h263vidfmt.cpp
===================================================================
RCS file: /cvsroot/datatype/h263/renderer/h263vidfmt.cpp,v
retrieving revision 1.16.2.1.2.6
retrieving revision 1.16.2.1.2.7
diff -u -d -r1.16.2.1.2.6 -r1.16.2.1.2.7
--- h263vidfmt.cpp	4 Sep 2010 04:49:33 -0000	1.16.2.1.2.6
+++ h263vidfmt.cpp	20 Sep 2010 10:06:04 -0000	1.16.2.1.2.7
@@ -113,11 +113,17 @@
     , m_pMaxDims(NULL)
     , m_pAssmDims(NULL)
     , m_ulDecoderBufSize(0)
+    , m_bIsDecodeSuccessful(FALSE) 
 {
     HX_ASSERT(m_pCommonClassFactory);
     HX_ASSERT(pH263VideoRenderer);
 
     m_pH263VideoRenderer->AddRef();
+#ifdef THREADS_SUPPORTED
+    HXMutex::MakeMutex(m_pInputLock);
+#else
+    HXMutex::MakeStubMutex(m_pInputLock);
+#endif
     _Reset();
 }
 
@@ -137,7 +143,8 @@
 	m_pRssm->Release();
 	m_pRssm = NULL;
     }
-
+    ClearInputList();
+    HX_DELETE(m_pInputLock);
     HX_DELETE(m_pDecoder);
     HX_DELETE(m_pMaxDims);
 
@@ -258,13 +265,38 @@
     return retVal;
 }
 
+void 
+CH263VideoFormat::ClearInputList()
+{
+    m_pInputLock->Lock();
+    int iCount =   m_InputList.GetCount();
+    while(iCount > 0)
+    {
+        IHXPacket* pPacket =  (IHXPacket*)m_InputList.RemoveHead();
+        HX_RELEASE(pPacket);
+        iCount--;
+    }
+    m_pInputLock->Unlock();
+}
+
+CMediaPacket* CH263VideoFormat::CreateAssembledPacket(IHXPacket* pCodecData)
+{
+    if(!m_bIsDecodeSuccessful && pCodecData)
+    {
+        pCodecData->AddRef();
+        m_pInputLock->Lock();
+        m_InputList.AddTail(pCodecData);
+        m_pInputLock->Unlock();
+    }
+    return _CreateAssembledPacket(pCodecData);
+}
 
 /****************************************************************************
  *  Method:
  *    CQTVideoFormat::CreateAssembledPacket
  *
  */
-CMediaPacket* CH263VideoFormat::CreateAssembledPacket(IHXPacket* pCodecData)
+CMediaPacket* CH263VideoFormat::_CreateAssembledPacket(IHXPacket* pCodecData)
 {
     CMediaPacket* pFramePacket = NULL;
     IHXPacket* pPacket = NULL;
@@ -446,7 +478,6 @@
 #endif /* #if defined(HELIX_FEATURE_STATS) */
 	}
     }
-
     return pFramePacket;
 }
 
@@ -483,6 +514,39 @@
     }
 }
 
+HX_RESULT 
+CH263VideoFormat::SendQueuedPacket()
+{
+    CMediaPacket* pFramePacket = NULL;
+    CHXSimpleList m;
+    m_pInputLock->Lock();
+    LISTPOSITION pos = m_InputList.GetHeadPosition(); 
+    IHXPacket* pPacket = m_InputList.GetAt(pos);
+    while(pPacket && pos)
+    {
+        HX_ADDREF(pPacket);
+        m.AddTail(pPacket);
+        pPacket =  (IHXPacket*)m_InputList.GetNext(pos);
+    }
+    m_pInputLock->Unlock();
+    
+    while(m.GetCount())
+    { 
+        IHXPacket* pCodecData = m.RemoveHead();
+        pFramePacket = _CreateAssembledPacket(pCodecData);        
+        if(pFramePacket)
+        {
+            pFramePacket = CreateDecodedPacket(pFramePacket);
+            if(pFramePacket && !ReturnDecodedPacket(pFramePacket))
+            {
+                m_pFramePool->Put(pFramePacket);
+                m_pH263VideoRenderer->ReportDroppedFrame();
+            }
+        }
+        HX_RELEASE(pCodecData);
+    }
+    return HXR_OK;
+}
 
 /****************************************************************************
  *  Method:
@@ -515,7 +579,6 @@
             {
                 bUseHWDecoder = FALSE;
             }
-
 	    if (m_pDecoder->InitDecoder(&m_DecoderDims, bUseHWDecoder) != HXR_OK)
 	    {
 		m_DecoderDims.cx = 0;
@@ -593,7 +656,6 @@
     if (pData)
     {
 	m_pH263VideoRenderer->BltIfNeeded();
-
 	if ((m_LastError = m_pDecoder->DecodeFrame(pFrameToDecode,
 				    pData,
                                     decodedTS, bUseTS,
@@ -612,9 +674,28 @@
 		pData = NULL;
 	    }
 
+        if(m_LastError == HXR_UNSUPPORTED_VIDEO &&  !m_bIsDecodeSuccessful)
+        {
+            // TRY NEXT DECODER
+            Reset();
+            m_DecoderDims.cx      = 0;
+            m_DecoderDims.cy      = 0;
+            m_LastFrameDims.cx    = 0;
+            m_LastFrameDims.cy    = 0;
+            m_DesiredFrameSize.cx = 0;
+            m_DesiredFrameSize.cy = 0;
+            m_ulDecoderBufSize    = 0;
+            if(SendQueuedPacket() == HXR_OK)
+            {
+                m_LastError = HXR_OK;
+            }
+        }        
+        else
+        {
 #if defined(HELIX_FEATURE_STATS)
 	    m_pH263VideoRenderer->ReportDroppedFrame();
 #endif /* #if defined(HELIX_FEATURE_STATS) */
+        }
 	}
     }
     m_pH263VideoRenderer->BltIfNeeded();
@@ -672,6 +753,11 @@
     // function to clean up output buffer
     if(pDecodedFrame && pDecodedFrame->m_pData)
     {
+        if(!m_bIsDecodeSuccessful)
+        {
+             m_bIsDecodeSuccessful = TRUE;
+             ClearInputList();
+        }
         UINT32* pColorFormat = (UINT32*) pDecodedFrame->m_pData;
         if (*pColorFormat == 0x7fa30c00) 
         { // a valid frame from OMXV decoder is acquired

Index: h263dec.cpp
===================================================================
RCS file: /cvsroot/datatype/h263/renderer/h263dec.cpp,v
retrieving revision 1.15.2.2.2.5
retrieving revision 1.15.2.2.2.6
diff -u -d -r1.15.2.2.2.5 -r1.15.2.2.2.6
--- h263dec.cpp	4 Sep 2010 04:49:33 -0000	1.15.2.2.2.5
+++ h263dec.cpp	20 Sep 2010 10:06:04 -0000	1.15.2.2.2.6
@@ -72,7 +72,6 @@
 #undef HX_THIS_FILE		
 static const char HX_THIS_FILE[] = __FILE__;
 #endif
-
 /****************************************************************************
  *  Method:
  *    CH263Decoder::CH263Decoder
@@ -90,6 +89,7 @@
     , m_pCodecAccess(NULL)
     , m_pDecoderState(NULL)
     , m_bMoreFrames(FALSE)
+    , m_iStartingDecoder(0)
 {
     HX_ADDREF(m_pContext);
 }
@@ -134,8 +134,10 @@
     // Build the module name if none is supplied
     char pLibName[16]; /* Flawfinder: ignore */
     HX_RESULT ret = HXR_OK;
+    //Close Old Decoder if any
+    CloseDecoder();
 	// Try to load a codec until OS_BuildLibName does not find one
-    for (INT32 i=0;; i++)
+    for (INT32 i=m_iStartingDecoder;; i++)
     {
         if (!m_pCodecAccess)
         {
@@ -148,11 +150,9 @@
                 // If no HW decoder is to used and the returned LibName is "omxv", try next decoder
                 continue;
             }
-
             // DLLAccess should be used to provide cross-platform support
             m_pCodecAccess = new DLLAccessBridge(pLibName, DLLTYPE_CODEC, m_pContext);
         }
-
         if (LoadCodecFunctions())
         {
             // We found a codec and could get its symbols
@@ -177,7 +177,8 @@
             ret = m_fpH263Init(&m_InitParams, &m_pDecoderState);
             HX_RELEASE(m_InitParams.pContext); 
             if(SUCCEEDED(ret))
-            {           
+            {   
+                m_iStartingDecoder = i + 1;           
                 break;
             }
             else
@@ -218,7 +219,6 @@
     {
 	H263DecoderOutParams OutputParams;
 	H263DecoderInParams InputParams;
-	
 	InputParams.dataLength = pFrameToDecode->m_ulDataSize;
 	InputParams.bInterpolateImage = FALSE;
 	InputParams.numDataSegments = 0;
@@ -240,7 +240,6 @@
         {
             return ret;
         }
-
         ret = m_fpH263Transform(pFrameToDecode->m_pData, 
 		pDecodedBuf, &InputParams, 
 		&OutputParams, m_pDecoderState);




More information about the Datatype-cvs mailing list
 

Site Map   |   Terms of Use   |   Privacy Policy   |   Contact Us

Copyright © 1995-2007 RealNetworks, Inc. All rights reserved. RealNetworks and Helix are trademarks of RealNetworks.
All other trademarks or registered trademarks are the property of their respective holders.