Add code missing from manual merge
authorFrank Livingston <frank-livingston@ti.com>
Wed, 16 Nov 2016 21:43:22 +0000 (15:43 -0600)
committerFrank Livingston <frank-livingston@ti.com>
Wed, 16 Nov 2016 21:43:22 +0000 (15:43 -0600)
pasdk/test_arm/framework/audioStreamDecodeProc.c
pasdk/test_dsp/framework/aspDecOpCircBuf_master.c
pasdk/test_dsp/framework/audioStreamOutProc.c

index 51a5d0e215ecee8932ba36ee3407ea14ce7edd71..197af1dba413bc58b2d49605e887bda5d6afc699 100644 (file)
@@ -565,10 +565,13 @@ Void taskAsdpFxn(
 
                     bufEnd = (Int) pIpBufConfig->base.pVoid + pIpBufConfig->sizeofBuffer;
                     currentBufSize = (bufEnd - (Int)pIpBufConfig->pntr.pSmInt);
-                    if(currentBufSize >= size){
-                       chunkSize = size;
-                    }else{
-                       chunkSize = currentBufSize;
+                    if (currentBufSize >= size)
+                    {
+                        chunkSize = size;
+                    }
+                    else
+                    {
+                        chunkSize = currentBufSize;
                     }
                     wrapSize = size - chunkSize;
                     // invalidate input data
index d1fcaa6f6585ff243a33ddd2f6669285e1dc49c8..783768d0eb925242f4478d85333b706e9312cb8a 100644 (file)
@@ -265,8 +265,8 @@ Int cbInitSourceSel(
         pCb->afWrtIdx = ASP_DECOP_CB_INIT_WRTIDX_PCM;
         pCb->afRdIdx = ASP_DECOP_CB_INIT_RDIDX_PCM;
         pCb->pcmRdIdx = 0;
-               pCb->maxAFChanNum = ASP_DECOP_CB_MAX_NUM_PCM_CH;
-               pCb->maxAFSampCount = DEF_DEC_OP_FRAME_LEN;
+        pCb->maxAFChanNum = ASP_DECOP_CB_MAX_NUM_PCM_CH;
+        pCb->maxAFSampCount = DEF_DEC_OP_FRAME_LEN;
         
         // initialize audio frames
         for (n=0; n<pCb->maxNumAfCb; n++)
@@ -297,8 +297,8 @@ Int cbInitSourceSel(
         pCb->afWrtIdx = ASP_DECOP_CB_INIT_WRTIDX_DDP;
         pCb->afRdIdx = ASP_DECOP_CB_INIT_RDIDX_DDP;
         pCb->pcmRdIdx = decOpFrameLen - ASP_DECOP_CB_INIT_LAG_DDP*strFrameLen; // 4*256 behind
-               pCb->maxAFChanNum = ASP_DECOP_CB_MAX_NUM_PCM_CH_DDP;
-               pCb->maxAFSampCount = ASP_DECOP_CB_MAX_PCM_FRAME_LEN_48kDDP;
+        pCb->maxAFChanNum = ASP_DECOP_CB_MAX_NUM_PCM_CH_DDP;
+        pCb->maxAFSampCount = ASP_DECOP_CB_MAX_PCM_FRAME_LEN_48kDDP;
         
         // initialize audio frames
         for (n=0; n<pCb->maxNumAfCb; n++)
@@ -329,8 +329,8 @@ Int cbInitSourceSel(
         pCb->afWrtIdx = ASP_DECOP_CB_INIT_WRTIDX_THD;
         pCb->afRdIdx = ASP_DECOP_CB_INIT_RDIDX_THD;
         pCb->pcmRdIdx = 0;
-               pCb->maxAFChanNum = ASP_DECOP_CB_MAX_NUM_PCM_CH_MAT;
-               pCb->maxAFSampCount = ASP_DECOP_CB_MAX_PCM_FRAME_LEN_48kMAT;
+        pCb->maxAFChanNum = ASP_DECOP_CB_MAX_NUM_PCM_CH_MAT;
+        pCb->maxAFSampCount = ASP_DECOP_CB_MAX_PCM_FRAME_LEN_48kMAT;
         
         // initialize audio frames
         for (n=0; n<pCb->maxNumAfCb; n++)
@@ -557,7 +557,7 @@ Int cbReadAf(
         // Skip UNDerflow check, mute output.
         //
         //cbReadAfMute(pAfRd, pCb->strFrameLen);
-               cbReadMuteWithLastAfInfo(pCb, pAfRd);
+        cbReadMuteWithLastAfInfo(pCb, pAfRd);
         
         // Leave the gate
         GateMP_leave(gateHandle, key);
@@ -578,7 +578,7 @@ Int cbReadAf(
             //
             pCb->errUndCnt++;
             //cbReadAfMute(pAfRd, pCb->strFrameLen);
-                   cbReadMuteWithLastAfInfo(pCb, pAfRd);
+            cbReadMuteWithLastAfInfo(pCb, pAfRd);
             //SW_BREAKPOINT; // FL: debug
             
             // Write back circular buffer configuration.
@@ -654,11 +654,11 @@ Int cbReadAf(
         }
         
         for (i = 0; i < PAF_MAX_NUM_PRIVATE_MD; i++)
-               {
-                       pAfRd->pafPrivateMetadata[i].offset = 0;
-                       pAfRd->pafPrivateMetadata[i].size   = 0;
-               }
-               
+        {
+            pAfRd->pafPrivateMetadata[i].offset = 0;
+            pAfRd->pafPrivateMetadata[i].size   = 0;
+        }
+        
         // read metadata //QIN
         for (i = 0; i < pAfCb->numPrivateMetadata; i++) // FL: only read numPrivateMetadata
         {
@@ -680,7 +680,7 @@ Int cbReadAf(
                 pAfRd->pafPrivateMetadata[numMetadata].offset = pAfCb->pafPrivateMetadata[i].offset - pCb->pcmRdIdx;
                 pAfRd->pafPrivateMetadata[numMetadata].size   = pAfCb->pafPrivateMetadata[i].size;
                 memcpy(pAfRd->pafPrivateMetadata[numMetadata].pMdBuf, pAfCb->pafPrivateMetadata[i].pMdBuf, pAfCb->pafPrivateMetadata[i].size);
-                               numMetadata++; //number of metadata associated with current 256 segment of audio samples
+                numMetadata++; //number of metadata associated with current 256 segment of audio samples
             }
             else //reset un-used buf
             {
@@ -689,7 +689,7 @@ Int cbReadAf(
             }
 
         }
-               pAfRd->numPrivateMetadata = numMetadata; //number of metadata associated with current 256 segment of audio samples
+        pAfRd->numPrivateMetadata = numMetadata; //number of metadata associated with current 256 segment of audio samples
         
         pCb->pcmRdIdx += pCb->strFrameLen; // update PCM read index
         if (pCb->pcmRdIdx >= pAfCb->sampleCount) 
@@ -707,6 +707,7 @@ Int cbReadAf(
             // update number of audio frames in circular buffer
             pCb->numAfCb--;
         }
+        memcpy (&pCb->lastAf, pAfRd, sizeof(PAF_AudioFrame));
     }
     
     if (pCb->emptyFlag == 1)
@@ -760,7 +761,7 @@ static Void cbReadAfMute(
     {
         if ((streamMask >> i) & 0x1)
         {
-                       memset(pAfRd->data.sample[i], 0, strFrameLen*sizeof(PAF_AudioData));
+            memset(pAfRd->data.sample[i], 0, strFrameLen*sizeof(PAF_AudioData));
         }
         pAfRd->data.samsiz[i] = 0;
     }
@@ -815,14 +816,14 @@ static Void cbReadMuteWithLastAfInfo (
     // compute stream mask
     streamMask = pAfRd->fxns->channelMask(pAfRd, pAfRd->channelConfigurationStream);
     // Clear PCM data
-       for (i = 0; i < ASP_DECOP_CB_MAX_NUM_PCM_CH; i++)
-       {
-               if ((streamMask >> i) & 0x1)
-               {
-                       memset(pAfRd->data.sample[i], 0, pAfRd->sampleCount*sizeof(PAF_AudioData));
-               }
-               pAfRd->data.samsiz[i] = 0;
-       }
+    for (i = 0; i < ASP_DECOP_CB_MAX_NUM_PCM_CH; i++)
+    {
+        if ((streamMask >> i) & 0x1)
+        {
+            memset(pAfRd->data.sample[i], 0, pAfRd->sampleCount*sizeof(PAF_AudioData));
+        }
+        pAfRd->data.samsiz[i] = 0;
+    }
     pAfRd->bsMetadata_type     = PAF_bsMetadata_none;           /* non zero if metadata is attached. */
     pAfRd->pafBsMetadataUpdate = 0;                             /* indicates whether bit-stream metadata update */
     pAfRd->numPrivateMetadata  = 0;                             /* number of valid private metadata (0 or 1 if metadata filtering enabled) */
index c9194211868041352ead8ca1ae21aaac51f88da0..770c8b822b0d8959efc7cc70cd93a47484573bc0 100644 (file)
@@ -1014,10 +1014,10 @@ PAF_ASOT_initFrame0(
     
     if (aLen_int*aSize!=0) // check size != 0, otherwise malloc throws fatal error
     {
-        if (!(aBuf_int = (PAF_AudioData *)Memory_calloc((IHeap_Handle)HEAP_FRMBUF, aLen_int*aSize, aAlign, &eb)))
+        if (!(aBuf_int = (PAF_AudioData *)Memory_calloc((IHeap_Handle)HEAP_FRMBUF, (aLen_int+(maxFrameLength-FRAMELENGTH))*aSize, aAlign, &eb))) //Qin: Add start offset
         {
             TRACE_TERSE1("PAF_ASOT_initFrame0: AS%d: Memory_calloc failed", as+z);
-            TRACE_TERSE2("  maxFrameLength: %d.  aLen_int*aSize: %d", maxFrameLength, aLen_int*aSize);
+            TRACE_TERSE2("  maxFrameLength: %d.  aLen_int*aSize: %d", maxFrameLength, (aLen_int+(maxFrameLength-FRAMELENGTH))*aSize);
             SW_BREAKPOINT;
             return __LINE__;
         }
@@ -1025,17 +1025,17 @@ PAF_ASOT_initFrame0(
         
     if (aLen_ext*aSize!=0)
     {
-        if (!(aBuf_ext = (PAF_AudioData *)Memory_calloc((IHeap_Handle)HEAP_EXTERNAL, aLen_ext*aSize, aAlign, &eb)))
+        if (!(aBuf_ext = (PAF_AudioData *)Memory_calloc((IHeap_Handle)HEAP_EXTERNAL, (aLen_ext+(maxFrameLength-FRAMELENGTH))*aSize, aAlign, &eb)))//Qin: Add start offset
         {
             TRACE_TERSE1("PAF_ASOT_initFrame0: AS%d: Memory_calloc failed", as+z);
-            TRACE_TERSE2("  maxFrameLength: %d.  aLen_ext*aSize: %d", maxFrameLength, aLen_ext*aSize);
+            TRACE_TERSE2("  maxFrameLength: %d.  aLen_ext*aSize: %d", maxFrameLength, (aLen_ext+(maxFrameLength-FRAMELENGTH))*aSize);
             SW_BREAKPOINT;
             return __LINE__;
         }
     }
     
-    TRACE_TERSE3("  maxFrameLength: %d.  aLen_int*aSize: %d.  aBuf_int: 0x%x", maxFrameLength, aLen_int*aSize, (IArg)aBuf_int);
-    TRACE_TERSE3("  maxFrameLength: %d.  aLen_ext*aSize: %d.  aBuf_ext: 0x%x", maxFrameLength, aLen_ext*aSize, (IArg)aBuf_ext);
+    TRACE_TERSE3("  maxFrameLength: %d.  aLen_int*aSize: %d.  aBuf_int: 0x%x", maxFrameLength, (aLen_int+(maxFrameLength-FRAMELENGTH))*aSize, (IArg)aBuf_int);
+    TRACE_TERSE3("  maxFrameLength: %d.  aLen_ext*aSize: %d.  aBuf_ext: 0x%x", maxFrameLength, (aLen_ext+(maxFrameLength-FRAMELENGTH))*aSize, (IArg)aBuf_ext);
 
     TRACE_TERSE1("PAF_ASOT_initFrame0: AS%d: Memory_calloc for metadata buffers", as+z);
     if (!(metadataBuf = (XDAS_UInt8 *)Memory_calloc((IHeap_Handle)HEAP_MDBUF, pP->pMetadataBufStatus->bufSize*pP->pMetadataBufStatus->NumBuf, pP->pMetadataBufStatus->alignment, &eb)))