]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/performance-audio-sr.git/commitdiff
PASDK-277: Updated CB lag implementation.
authorChitresh Gupta <chitresh.g@pathpartnertech.com>
Sat, 27 May 2017 13:47:29 +0000 (19:17 +0530)
committerChitresh Gupta <chitresh.g@pathpartnertech.com>
Sat, 27 May 2017 13:47:29 +0000 (19:17 +0530)
This implementation also helps to
synchronize CB read and write operation.

pasdk/common/aspDecOpCircBuf_common.h
pasdk/test_arm/framework/aspDecOpCircBuf_slave.c
pasdk/test_arm/framework/audioStreamDecodeProc.c
pasdk/test_dsp/framework/aspDecOpCircBuf_master.c

index f2c4a4c96ff34bbf296a9db952d075807790835c..e824a0af33c838db8e27b9019ee8bf27f4ce0bbc 100644 (file)
@@ -43,9 +43,9 @@ All rights reserved.
 #define ASP_DECOP_CB_SOK                    ( 0 )       // ok
 #define ASP_DECOP_CB_CTL_INIT_INV_GATE      ( ASP_DECOP_CB_SOK-1 )  // error: invalid gate handle
 #define ASP_DECOP_CB_ERR_START              ( ASP_DECOP_CB_CTL_INIT_INV_GATE )
-#define ASP_DECOP_CB_MAX_NUM_AF             ( 10 )       // decoder output circular buffer maximum number audio frames
+#define ASP_DECOP_CB_MAX_NUM_AF             ( 15 )       // decoder output circular buffer maximum number audio frames
 #define ASP_DECOP_CB_MAX_NUM_PCM_CH         ( 16 )      // decoder output circular buffer maximum number audio PCM channels
-#define ASP_DECOP_CB_MAX_NUM_PCM_FRAMES     ( 10 ) // decoder output circular buffer maximum number PCM frames //Qin - Increased to prevent cb overflow for ddp.
+#define ASP_DECOP_CB_MAX_NUM_PCM_FRAMES     ( 15 ) // decoder output circular buffer maximum number PCM frames //Qin - Increased to prevent cb overflow for ddp.
 #define ASP_DECOP_CB_MAX_PCM_FRAME_LEN      ( 6*256 )   // decoder output circular buffer maximum PCM frame length
 
 #define ASP_DECOP_CB_MAX_NUM_PCM_CH_DDP        ( 16 )     // decoder output circular buffer maximum number audio PCM channels for DDP
@@ -59,17 +59,17 @@ All rights reserved.
 
 #define ASP_DECOP_CB_MAX_NUM_AF_PCM         ( 4 )
 #define ASP_DECOP_CB_INIT_LAG_PCM           ( 2 ) // 1...3
-#define ASP_DECOP_CB_INIT_WRTIDX_PCM        ( ASP_DECOP_CB_INIT_LAG_PCM )
+#define ASP_DECOP_CB_INIT_WRTIDX_PCM        ( 0 )
 #define ASP_DECOP_CB_INIT_RDIDX_PCM         ( 0 )
 
 #define ASP_DECOP_CB_MAX_NUM_AF_DDP         ( 2 )
-#define ASP_DECOP_CB_INIT_LAG_DDP           ( 4 ) // 0...5
-#define ASP_DECOP_CB_INIT_WRTIDX_DDP        ( 1 )
+#define ASP_DECOP_CB_INIT_LAG_DDP           ( 1 ) // 0...5
+#define ASP_DECOP_CB_INIT_WRTIDX_DDP        ( 0 )
 #define ASP_DECOP_CB_INIT_RDIDX_DDP         ( 0 )
 
-#define ASP_DECOP_CB_MAX_NUM_AF_THD         ( 10 )
-#define ASP_DECOP_CB_INIT_LAG_THD           ( 3 ) // ( 6 )  
-#define ASP_DECOP_CB_INIT_WRTIDX_THD        ( 1 ) // ( ASP_DECOP_CB_INIT_LAG_THD )
+#define ASP_DECOP_CB_MAX_NUM_AF_THD         ( 15 )
+#define ASP_DECOP_CB_INIT_LAG_THD           ( 5 )  // 5*20ms = 80 ms, For the worst case of 100 ms
+#define ASP_DECOP_CB_INIT_WRTIDX_THD        ( 0 ) //ASP_DECOP_CB_INIT_LAG_THD )
 #define ASP_DECOP_CB_INIT_RDIDX_THD         ( 0 )
 #define ASP_DECODE_CB_GATE_NAME             ( "AspDecOpCbGate" )
 #define ASP_DECODE_CB_GATE_REGION_ID        ( 0 )
@@ -84,6 +84,8 @@ typedef struct PAF_AST_DecOpCircBuf
     Int8 sourceSel;         // selected source
     Int8 afRdIdx;           // audio frame CB read index
     Int8 afWrtIdx;          // audio frame CB write index
+    Int8 afLagIdx;          // audio frame CB Lag idx,
+    Int8 afInitialLag;      // Initial delay/lag between CB write and read
     Int16 pcmRdIdx;         // pcm buffer read index
     Int8 numAfCb;           // current number frames in CB
     Int8 maxNumAfCb;        // maximum number of audio frames in CB
index a5de2f00e80e75e6b16b24c0e9a23ffce3143dcf..50b2d861d04d4aecaf53d169985e421bea9728f3 100644 (file)
@@ -114,6 +114,7 @@ Int cbWriteStart(
     // update flags
     pCb->writerActiveFlag = 1;
     pCb->emptyFlag = 0;
+    pCb->afLagIdx = 0;
     
     // (***) FL: revisit
     // Write back circular buffer configuration
@@ -370,6 +371,12 @@ Int cbWriteAf(
         Cache_wait();
         // update number of audio frames in circular buffer
         pCb->numAfCb++;
+        // Update CB Lag index 
+        if (pCb->afLagIdx < pCb->afInitialLag)
+        {
+            pCb->afLagIdx += 1;
+        }
+
 
         // (***) FL: revisit
         // Write back circular buffer configuration
index 4ed99b029145bc35535c6da2b4f23003116b37e9..cfe72fdedf1921645e40666ba814b6ce99317ed1 100644 (file)
@@ -122,6 +122,14 @@ UInt32 gSlaveDecDecodeCnt       =0;
 UInt32 gSlaveDecDeactivateCnt   =0;
 
 
+//#define CAPTURE_DECODER_OUTSAMPLES_PP
+#ifdef CAPTURE_DECODER_OUTSAMPLES_PP
+
+#define CAP_FRAME_SAMPLES            2000
+Uint32 sampCountCapFrame = 0;
+int tempCap_decSampleOut[CAP_FRAME_SAMPLES] = {0.0};
+#endif
+
 /*
  *  ======== taskAsdpFxn ========
  *  Audio Stream Decode Processing task function
@@ -719,6 +727,15 @@ Void taskAsdpFxn(
                         //    Log_info0("capAfWrite() error");
                         //}                        
 
+                        #ifdef CAPTURE_DECODER_OUTSAMPLES_PP
+
+                        if (sampCountCapFrame < CAP_FRAME_SAMPLES)
+                        {
+                            tempCap_decSampleOut[sampCountCapFrame] = pAfWrt->sampleCount;
+                            sampCountCapFrame++;
+                        }
+                        #endif
+
                         GPIOSetOutput(GPIO_PORT_0, GPIO_PIN_107);
                         cbErrno = cbWriteAf(pCbCtl, z, pAfWrt);
                         if ((cbErrno < 0) && (cbErrno != ASP_DECOP_CB_WRITE_OVERFLOW))
index 47bd334850dae532cc4635188544f473cbadec6b..bc546a9b957f1291a5ad36a79e37cc3794a0d386 100644 (file)
@@ -258,12 +258,17 @@ Int cbInitSourceSel(
     
     // set output frame length
     pCb->strFrameLen = strFrameLen;
+
+    pCb->afInitialLag = 0;  // default No lag
+    pCb->afLagIdx = 0;
+
     
     // initialize circular buffer maximum number of audio frames
     if (sourceSelect == PAF_SOURCE_PCM)
     {
         pCb->maxNumAfCb = ASP_DECOP_CB_MAX_NUM_AF_PCM;
         // 2*256 in behind
+        pCb->afInitialLag = ASP_DECOP_CB_INIT_LAG_PCM;
         pCb->afWrtIdx = ASP_DECOP_CB_INIT_WRTIDX_PCM;
         pCb->afRdIdx = ASP_DECOP_CB_INIT_RDIDX_PCM;
         pCb->pcmRdIdx = 0;
@@ -298,7 +303,8 @@ Int cbInitSourceSel(
         // 4*256 in behind
         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->afInitialLag = ASP_DECOP_CB_INIT_LAG_DDP;
+        pCb->pcmRdIdx = 0; //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;
         
@@ -327,7 +333,7 @@ Int cbInitSourceSel(
     else if (sourceSelect == PAF_SOURCE_THD)
     {
         pCb->maxNumAfCb = ASP_DECOP_CB_MAX_NUM_AF_THD;
-        // 0 in behind
+        pCb->afInitialLag = ASP_DECOP_CB_INIT_LAG_THD;
         pCb->afWrtIdx = ASP_DECOP_CB_INIT_WRTIDX_THD;
         pCb->afRdIdx = ASP_DECOP_CB_INIT_RDIDX_THD;
         pCb->pcmRdIdx = 0;
@@ -552,7 +558,7 @@ Int cbReadAf(
         return ASP_DECOP_CB_READ_INVSTATE;
     }
 
-    if ((pCb->writerActiveFlag == 0) && (pCb->emptyFlag == 0))
+    if (((pCb->writerActiveFlag == 0) && (pCb->emptyFlag == 0)) || (pCb->afLagIdx < pCb->afInitialLag))
     {
         //
         // No active writer, not draining circular buffer.