[prev in list] [next in list] [prev in thread] [next in thread] 

List:       helix-datatype-cvs
Subject:    [Datatype-cvs] mp4/payload mp4apyld.cpp, 1.14.14.1.22.3,
From:       zlin () helixcommunity ! org
Date:       2011-10-27 7:45:28
[Download RAW message or body]

Update of /cvsroot/datatype/mp4/payload
In directory cvs01.internal.helixcommunity.org:/tmp/cvs-serv12112

Modified Files:
      Tag: hxclient_3_6_1_atlas
	mp4apyld.cpp 
Log Message:
Modified by:zlin@real.com
Date: 10/27/2011
Project: RealPlayer for Android Smartphones
Synopsis:Some avi video files can not be playback

Overview:When playing some avi video files,it may fail due to some reasons.
1.> 1.100_H264_mp3_176x144_148Kbps_30fps_BP.avi
It was caused by failing to initialize decoder with opaque data.When initializing
the decoder,opaque data is always important,but not essential,because maybe the
decoder has the capability of initializing itself with following input data.Finally,
update the logic to conceal the error when parsing opaque data.It will give decoder
a chance to initializing itself.It is reasonable and adoptable.

2.>1.112_toystory_h264_aac+.avi
It was caused by initializing the aac audio render failure with the opaque data.For
avi files,if the chunk named "strd" miss,we will try to read the first frame as \
opaque data.This behavior is reasonable,however,failure may occur due the the first \
frame is not appropriate to regard as opaque data.
In order to conquer this issue,firstly,adding the functionality for validate the \
opaque data. If it is invalid,try to initialize the decoder with default audio \
specific config.Secondly, try to separate the aac mime type by checking the adts sync \
word.

3.> Update the method for extracting the resolution of H.264 and MPEG4.
The is some shortcomings of the resolution extraction of H.264 if the profile is high \
profile. Meanwhile,for MPEG4 files,adding the functionality to extract the \
resolution.

Files Added:
None

Files Modified:
/datatype/omx/video/decoder/pub/android/2.3/COmxVideoDec_smdkc110.h
/datatype/omx/video/decoder/android/2.3/COmxVideoDec_smdkc110.cpp
datatype/mp4/payload/pub/mp4apyld.h
datatype/mp4/payload/mp4apyld.cpp
datatype/avi/fileformat/avistrm.cpp

Image Size and Heap Use impact (Client -Only): None

Platforms and Profiles Affected:
Platform: android-2.3-arm-smdk_c110
Profile: helix-client-android-LePhoneTD-C110

Distribution Libraries Affected:None

Distribution library impact and planned action:None

Platforms and Profiles Build Verified:
Platform: android-2.3-arm-smdk_c110
Profile: helix-client-android-LePhoneTD-C110

Platforms and Profiles Functionality verified:
Platform: android-2.3-arm-smdk_c110
Profile: helix-client-android-LePhoneTD-C110

Branch: 361atlas 


Index: mp4apyld.cpp
===================================================================
RCS file: /cvsroot/datatype/mp4/payload/mp4apyld.cpp,v
retrieving revision 1.14.14.1.22.3
retrieving revision 1.14.14.1.22.4
diff -u -d -r1.14.14.1.22.3 -r1.14.14.1.22.4
--- mp4apyld.cpp	29 Sep 2011 00:46:12 -0000	1.14.14.1.22.3
+++ mp4apyld.cpp	27 Oct 2011 07:45:25 -0000	1.14.14.1.22.4
@@ -67,6 +67,18 @@
 #include "mp4desc.h"
 #include "mp4apyld.h"
 #include "mp4pyldutil.h"
+#include "bitstream.h"
+
+const INT32 HelixMpeg4AudioSampleFrequency[16] =
+{
+    96000, 88200, 64000, 48000, 44100, 32000,
+    24000, 22050, 16000, 12000, 11025, 8000, 7350
+};
+
+const INT8 HelixMpeg4AudioChannels[8] =
+{
+    0, 1, 2, 3, 4, 5, 6, 8
+};
 
 MP4APayloadFormat::MP4APayloadFormat()
     : m_lRefCount	    (0)
@@ -292,10 +304,10 @@
 	{
 	    m_PayloadID = PYID_X_HX_AAC_GENERIC;
 	}
-        else if (strcasecmp(pMimeTypeData, "audio/X-HX-AAC-ADTS") == 0)
-        {
-            m_PayloadID = PYID_X_HX_AAC_ADTS;
-        }
+    else if (strcasecmp(pMimeTypeData, "audio/X-HX-AAC-ADTS") == 0)
+    {
+        m_PayloadID = PYID_X_HX_AAC_ADTS;
+    }
 	else if (strcasecmp(pMimeTypeData, "audio/X-HX-3GPP-QCELP") == 0)
 	{
 	    m_PayloadID = PYID_X_HX_3GPP_QCELP;
@@ -361,7 +373,7 @@
 
     retVal = m_pStreamHeader->GetPropertyBuffer("OpaqueData",
 						pBuffer);
-    if (SUCCEEDED(retVal))
+    if ( SUCCEEDED(retVal) && IsAACSpecificConfigValid( pBuffer ) )
     {
         m_pAudioConfig = NULL;
         m_ulAudioConfigSize = pBuffer->GetSize();
@@ -389,74 +401,7 @@
     }
     else
     {
-        //if there is no Opaque data, we made one LC config data for try 
-        UINT16 audioConfig = 0;
-        BYTE objectType = 0x02; //Low Complexity
-        BYTE frequencyIndex = 0;		
-        BYTE channleInfo = 0;
-        ULONG32 samplesPerSecond = 0;
-        ULONG32 uChannels = 0;
-
-        m_unAudioConfigType = eAACConfigAudioSpecificCfg;
-        audioConfig |= objectType;
-        audioConfig <<= 11;
-        retVal = m_pStreamHeader->GetPropertyULONG32("SamplesPerSecond",samplesPerSecond);
                
-        if (SUCCEEDED(retVal))
-        {
-            switch(samplesPerSecond)
-            {
-                case 88200:
-                    frequencyIndex = 1;
-                    break;
-                case 64000:
-                    frequencyIndex = 2;
-                    break;					
-                case 48000:
-                    frequencyIndex = 3;
-                    break;					
-                case 44100:
-                    frequencyIndex = 4;
-                    break;					
-                case 32000:
-                    frequencyIndex = 5;
-                    break;					
-                case 24000:
-                    frequencyIndex = 6;
-                    break;					
-                case 22050:
-                    frequencyIndex = 7;
-                    break;					
-                case 16000:
-                    frequencyIndex = 8;
-                    break;					
-                case 12000:
-                    frequencyIndex = 9;
-                    break;
-                case 11025:
-                    frequencyIndex = 10;
-                    break;					
-                case 8000:
-                    frequencyIndex = 11;
-                    break;					
-                case 7350:
-                    frequencyIndex = 12;
-                    break;					
-            }		
-            audioConfig >>= 7;
-            audioConfig |= frequencyIndex;
-            audioConfig <<= 7;			
-        }	
-        retVal = m_pStreamHeader->GetPropertyULONG32("Channels",uChannels);
-        if (uChannels == 0 || !SUCCEEDED(retVal))
-            uChannels = 2;
-		
-        audioConfig >>= 3;
-        audioConfig |= uChannels;
-        audioConfig <<= 3;	
-        m_pAudioConfig = new UINT8[2];
-        m_pAudioConfig[0] = (audioConfig>>8);
-        m_pAudioConfig[1] = (audioConfig & 0xFF);
-        retVal = HXR_OK;
+        retVal = ConstructDefaultAACSpecificConfig();
     }
     HX_RELEASE(pBuffer);
     return retVal;
@@ -1358,3 +1303,140 @@
 
     return ulTime;
 }
+
+HX_RESULT MP4APayloadFormat::UnpackAACSpecificConfig(IHXBuffer* pOpaqueData, \
AACSpecificConfig* pConfig ) +{
+    HX_RESULT retVal = HXR_INVALID_PARAMETER;
+    if ( pOpaqueData && pConfig )
+    {
+        UCHAR* pOpaqueDataBuf = pOpaqueData->GetBuffer();
+        ULONG32 ulSize = pOpaqueData->GetSize();
+        if ( pOpaqueDataBuf && ulSize > 0 )
+        {
+            Bitstream* reader = new Bitstream;
+            if ( reader )
+            {
+                reader->SetBuffer( pOpaqueDataBuf, ulSize );
+
+                pConfig->lAudioObjectType = reader->GetBits( 5 );
+                if ( AACAudioOjbectESCAPE == pConfig->lAudioObjectType  )
+                {
+                    pConfig->lAudioObjectType = 32 + reader->GetBits( 6 );
+                }
+
+                pConfig->lSamplingFrequencyIndex = reader->GetBits( 4 );
+                if ( 0x0f == pConfig->lSamplingFrequencyIndex )
+                {
+                    pConfig->lSamplingFrequency = reader->GetBits( 24 );
+                }
+                else
+                {
+                    pConfig->lSamplingFrequency = \
HelixMpeg4AudioSampleFrequency[pConfig->lSamplingFrequencyIndex]; +                }
+                pConfig->lChannelConfiguration = reader->GetBits( 4 );
+
+                if ( pConfig->lChannelConfiguration < sizeof( \
HelixMpeg4AudioChannels ) / sizeof( HelixMpeg4AudioChannels[0] ) ) +                {
+                    pConfig->lChannels = \
HelixMpeg4AudioChannels[pConfig->lChannelConfiguration]; +                }
+                pConfig->lsbrPresentFlag = -1;
+                pConfig->lpsPresentFlag = -1;
+
+                retVal = HXR_OK;
+            }
+            else
+            {
+                retVal = HXR_OUTOFMEMORY;
+            }
+            HX_DELETE( reader );
+        }
+    }
+    return retVal;
+}
+
+HXBOOL MP4APayloadFormat::IsAACSpecificConfigValid(IHXBuffer* pOpaqueData)
+{
+    HXBOOL bIsValid = FALSE;
+    if ( pOpaqueData )
+    {
+        HX_RESULT retVal = HXR_FAIL;
+        AACSpecificConfig config;
+        memset( &config, 0, sizeof( config ) );
+        retVal = UnpackAACSpecificConfig( pOpaqueData, &config );
+        if ( SUCCEEDED( retVal ) )
+        {
+            ULONG32 ulSamplesPerSecond;
+            retVal = m_pStreamHeader->GetPropertyULONG32( "SamplesPerSecond", \
ulSamplesPerSecond ); +            if ( SUCCEEDED( retVal ) && ( \
config.lSamplingFrequency == ulSamplesPerSecond ) ) +            {
+                ULONG32 ulChannelNum;
+                retVal = m_pStreamHeader->GetPropertyULONG32( "Channels", \
ulChannelNum ); +                if ( FAILED( retVal ) ||  ulChannelNum == 0 )
+                {
+                    ulChannelNum = 2;
+                }
+
+                if ( config.lChannels == ulChannelNum )
+                {
+                    bIsValid = TRUE;
+                }
+            }
+        }
+    }
+    return bIsValid;
+}
+
+HX_RESULT MP4APayloadFormat::ConstructDefaultAACSpecificConfig()
+{
+    HX_RESULT retVal = HXR_FAIL;
+
+    //if there is no Opaque data, we made one LC config data for try
+    UINT16 audioConfig = 0;
+    BYTE objectType = 0x02; //Low Complexity
+    BYTE frequencyIndex = 0;
+    BYTE channleInfo = 0;
+    ULONG32 samplesPerSecond = 0;
+    ULONG32 uChannels = 0;
+
+    m_unAudioConfigType = eAACConfigAudioSpecificCfg;
+    m_PayloadID = PYID_X_HX_AAC_GENERIC;
+    audioConfig |= objectType;
+    audioConfig <<= 11;
+    retVal = m_pStreamHeader->GetPropertyULONG32( "SamplesPerSecond", \
samplesPerSecond ); +    if ( SUCCEEDED( retVal ) )
+    {
+        INT32 lArraySize = sizeof( HelixMpeg4AudioSampleFrequency ) / sizeof( \
HelixMpeg4AudioSampleFrequency[0] ); +        for ( INT32 lIndex = 0; lIndex < \
lArraySize; ++lIndex ) +        {
+            if ( HelixMpeg4AudioSampleFrequency[lIndex] == samplesPerSecond )
+            {
+                frequencyIndex = lIndex;
+                break;
+            }
+        }
+        audioConfig >>= 7;
+        audioConfig |= frequencyIndex;
+        audioConfig <<= 7;
+
+        retVal = m_pStreamHeader->GetPropertyULONG32( "Channels", uChannels );
+        if ( 0 == uChannels || FAILED( retVal ) )
+        {
+            uChannels = 2;
+        }
+        audioConfig >>= 3;
+        audioConfig |= uChannels;
+        audioConfig <<= 3;
+        m_pAudioConfig = new UINT8[2];
+        if ( m_pAudioConfig )
+        {
+            m_pAudioConfig[0] = ( audioConfig>>8 );
+            m_pAudioConfig[1] = ( audioConfig & 0xFF );
+            m_ulAudioConfigSize = 2;
+        }
+        else
+        {
+            retVal = HXR_OUTOFMEMORY;
+        }
+    }
+    return retVal;
+}


_______________________________________________
Datatype-cvs mailing list
Datatype-cvs@helixcommunity.org
http://lists.helixcommunity.org/mailman/listinfo/datatype-cvs


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic