PASDK-218:Update cbInitSourceSel() to init CB using Dec Info1 AF output
authorFrank Livingston <frank-livingston@ti.com>
Mon, 3 Jul 2017 19:12:17 +0000 (14:12 -0500)
committerFrank Livingston <frank-livingston@ti.com>
Mon, 3 Jul 2017 19:12:17 +0000 (14:12 -0500)
pasdk/common/aspDecOpCircBuf_common.h
pasdk/test_arm/framework/aspDecOpCircBuf_slave.c
pasdk/test_arm/framework/aspDecOpCircBuf_slave.h
pasdk/test_arm/framework/audioStreamDecodeProc.c

index 8d31fe3fb61a2d3cac71460b067cfe02c413dba4..ec14feeae51f7ad14924a2c763e81cf7b9ceebf1 100644 (file)
@@ -87,7 +87,7 @@ All rights reserved.
 #define ASP_DECOP_CB_INIT_WRTIDX_DDP            ( 0 )
 #define ASP_DECOP_CB_INIT_RDIDX_DDP             ( 0 )
 #define ASP_DECOP_CB_INIT_LAG_DDP               ( 1 )
-#define ASP_DECOP_CB_TARGET_ND_SAMPS_48kDDP     ( ASP_DECOP_CB_INIT_LAG_DDP * 1536 ) // DDP target Nominal Delay in number of samples, fs=48 kHz
+#define ASP_DECOP_CB_TARGET_ND_SAMPS_DDP        ( ASP_DECOP_CB_INIT_LAG_DDP * 1536 ) // DDP target Nominal Delay in number of samples
 
 #define ASP_DECOP_CB_MAX_NUM_AF_THD             ( 30 ) //( 15 )
 #if (ASP_DECOP_CB_MAX_NUM_AF_THD > ASP_DECOP_CB_MAX_NUM_AF)
@@ -97,6 +97,8 @@ All rights reserved.
 #define ASP_DECOP_CB_INIT_RDIDX_THD             ( 0 )
 //#define ASP_DECOP_CB_INIT_LAG_THD               ( 5 ) // 5*20ms = 100 ms, For the worst case of 100 ms
 #define ASP_DECOP_CB_TARGET_ND_SAMPS_48kTHD     ( 3504 )//( 2224 ) // THD target Nominal Delay in number of samples, fs=48 kHz
+#define ASP_DECOP_CB_TARGET_ND_SAMPS_96kTHD     ( ASP_DECOP_CB_TARGET_ND_SAMPS_48kTHD ) // THD target Nominal Delay in number of samples, fs=96 kHz
+#define ASP_DECOP_CB_TARGET_ND_SAMPS_192kTHD    ( ASP_DECOP_CB_TARGET_ND_SAMPS_48kTHD ) // THD target Nominal Delay in number of samples, fs=192 kHz
 
 #define ASP_DECODE_CB_GATE_NAME                 ( "AspDecOpCbGate" ) // name of GateMP used for circular buffer shared memory protection
 #define ASP_DECODE_CB_GATE_REGION_ID            ( 0 )                // IPC shared region ID used for CB gate allocation   
index b258f747b6d0c6c6e5a2f13466da37bd288c71f5..13189f94c415211fdd0cc7861d4a595f98f442f1 100644 (file)
@@ -88,7 +88,8 @@ Int cbInitSourceSel(
     Int8 sourceSelect,                  // source select (PCM, DDP, etc.)
     Int16 decOpFrameLen,                // decoder output frame length (PCM samples)
     Int16 strFrameLen,                  // stream frame length (PCM samples)
-    Int8 resetRwFlags                   // whether to reset reader, writer, and drain flags
+    Int8 resetRwFlags,                  // whether to reset reader, writer, and drain flags
+    PAF_AudioFrame *pDecInfo1Af         // pointer to Dec Info1 audio frame
 )
 {
     IArg key;
@@ -116,13 +117,13 @@ Int cbInitSourceSel(
 
     //Log_info1("cbInitSourceSel:afCb=0x%04x", (IArg)pCb->afCb); // debug
 
-    // set source select
+    // Set source select
     pCb->sourceSel = sourceSelect;
 
-    // set input frame length
+    // Set input frame length
     pCb->decOpFrameLen = decOpFrameLen;
     
-    // set output frame length
+    // Set output frame length
     pCb->strFrameLen = strFrameLen;
 
     //pCb->afInitialLag = 0;  // default No lag
@@ -132,13 +133,16 @@ Int cbInitSourceSel(
     // Initialize delta samples
     pCb->deltaSamps = 0;
     
-    // initialize circular buffer maximum number of audio frames
+    // Initialize circular buffer:
+    //  - maximum number of AFs
+    //  - target nominal delay
+    //  - AF write, read indices
+    //  - maximum AF channel and sample counts
     if (sourceSelect == PAF_SOURCE_PCM)
     {
         pCb->maxNumAfCb = ASP_DECOP_CB_MAX_NUM_AF_PCM;
         
         //pCb->afInitialLag = ASP_DECOP_CB_INIT_LAG_PCM;
-        // Initialize target nominal delay
         pCb->targetNDSamps = ASP_DECOP_CB_TARGET_ND_SAMPS_48kPCM;
         
         pCb->afWrtIdx = ASP_DECOP_CB_INIT_WRTIDX_PCM;
@@ -146,37 +150,14 @@ Int cbInitSourceSel(
         pCb->pcmRdIdx = 0;
         
         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++)
-        {
-            pAfCb = &pCb->afCb[n];
-            pAfCb->sampleDecode = sourceSelect;
-            PAF_PROCESS_ZERO(pAfCb->sampleProcess);
-            pAfCb->sampleRate = PAF_SAMPLERATE_48000HZ;
-            pAfCb->sampleCount = decOpFrameLen;
-            pAfCb->channelConfigurationRequest.full = 0;
-            pAfCb->channelConfigurationRequest.part.sat = PAF_CC_SAT_SURROUND4;
-            pAfCb->channelConfigurationRequest.part.sub = PAF_CC_SUB_ONE;
-            pAfCb->channelConfigurationStream.full = 0;
-            pAfCb->channelConfigurationStream.part.sat = PAF_CC_SAT_SURROUND4;
-            pAfCb->channelConfigurationStream.part.sub = PAF_CC_SUB_ONE;
-            
-            // write metadata information updated by decoder
-            pAfCb->bsMetadata_type     = PAF_bsMetadata_channelData;    /* non zero if metadata is attached. */
-            pAfCb->pafBsMetadataUpdate = 0;                             /* indicates whether bit-stream metadata update */
-            pAfCb->numPrivateMetadata  = 0;                             /* number of valid private metadata (0 or 1 if metadata filtering enabled) */
-            pAfCb->bsMetadata_offset   = 0;                             /* offset into audio frame for change in bsMetadata_type field */
-        }
+        pCb->maxAFSampCount = DEF_DEC_OP_FRAME_LEN;        
     }
     else if ((sourceSelect == PAF_SOURCE_DDP) || (sourceSelect == PAF_SOURCE_AC3))
     {
         pCb->maxNumAfCb = ASP_DECOP_CB_MAX_NUM_AF_DDP;
         
         //pCb->afInitialLag = ASP_DECOP_CB_INIT_LAG_DDP;
-        // Initialize target nominal delay
-        pCb->targetNDSamps = ASP_DECOP_CB_TARGET_ND_SAMPS_48kDDP;
+        pCb->targetNDSamps = ASP_DECOP_CB_TARGET_ND_SAMPS_DDP;
         
         pCb->afWrtIdx = ASP_DECOP_CB_INIT_WRTIDX_DDP;
         pCb->afRdIdx = ASP_DECOP_CB_INIT_RDIDX_DDP;
@@ -184,28 +165,6 @@ Int cbInitSourceSel(
         
         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++)
-        {
-            pAfCb = &pCb->afCb[n];
-            pAfCb->sampleDecode = sourceSelect;
-            PAF_PROCESS_ZERO(pAfCb->sampleProcess);
-            pAfCb->sampleRate = PAF_SAMPLERATE_48000HZ;
-            pAfCb->sampleCount = decOpFrameLen;
-            pAfCb->channelConfigurationRequest.full = 0;
-            pAfCb->channelConfigurationRequest.part.sat = PAF_CC_SAT_SURROUND4;
-            pAfCb->channelConfigurationRequest.part.sub = PAF_CC_SUB_ONE;
-            pAfCb->channelConfigurationStream.full = 0;
-            pAfCb->channelConfigurationStream.part.sat = PAF_CC_SAT_SURROUND4;
-            pAfCb->channelConfigurationStream.part.sub = PAF_CC_SUB_ONE;
-            
-            // write metadata information updated by decoder
-            pAfCb->bsMetadata_type     = PAF_bsMetadata_channelData;    /* non zero if metadata is attached. */
-            pAfCb->pafBsMetadataUpdate = 0;                             /* indicates whether bit-stream metadata update */
-            pAfCb->numPrivateMetadata  = 0;                             /* number of valid private metadata (0 or 1 if metadata filtering enabled) */
-            pAfCb->bsMetadata_offset   = 0;                             /* offset into audio frame for change in bsMetadata_type field */
-        }
     }
     else if (sourceSelect == PAF_SOURCE_THD)
     {
@@ -214,57 +173,76 @@ Int cbInitSourceSel(
         pCb->maxNumAfCb = ASP_DECOP_CB_MAX_NUM_AF_THD;
         
         //pCb->afInitialLag = ASP_DECOP_CB_INIT_LAG_THD;
-        // Initialize target nominal delay
-        pCb->targetNDSamps = ASP_DECOP_CB_TARGET_ND_SAMPS_48kTHD;
+        // FL: (***) set nominal delay per sampling rate -- need to review these settings
+        switch (pDecInfo1Af->sampleRate)
+        {
+            case PAF_SAMPLERATE_44100HZ:
+            case PAF_SAMPLERATE_48000HZ:
+                pCb->targetNDSamps = ASP_DECOP_CB_TARGET_ND_SAMPS_48kTHD;
+                break;
+            case PAF_SAMPLERATE_88200HZ:
+            case PAF_SAMPLERATE_96000HZ:
+                pCb->targetNDSamps = ASP_DECOP_CB_TARGET_ND_SAMPS_96kTHD;
+                break;
+            case PAF_SAMPLERATE_176400HZ:
+            case PAF_SAMPLERATE_192000HZ:
+                pCb->targetNDSamps = ASP_DECOP_CB_TARGET_ND_SAMPS_192kTHD;
+                break;
+        }
         
         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;
-        
-        // initialize audio frames
-        for (n=0; n<pCb->maxNumAfCb; n++)
-        {
-            pAfCb = &pCb->afCb[n];
-            pAfCb->sampleDecode = sourceSelect;
-            PAF_PROCESS_ZERO(pAfCb->sampleProcess);
-            pAfCb->sampleRate = PAF_SAMPLERATE_48000HZ;
-            pAfCb->sampleCount = decOpFrameLen;
-            pAfCb->channelConfigurationRequest.full = 0;
-            pAfCb->channelConfigurationRequest.part.sat = PAF_CC_SAT_SURROUND4;
-            pAfCb->channelConfigurationRequest.part.sub = PAF_CC_SUB_ONE;
-            pAfCb->channelConfigurationStream.full = 0;
-            pAfCb->channelConfigurationStream.part.sat = PAF_CC_SAT_SURROUND4;
-            pAfCb->channelConfigurationStream.part.sub = PAF_CC_SUB_ONE;
-            
-            // write metadata information updated by decoder
-            pAfCb->bsMetadata_type     = PAF_bsMetadata_channelData;    /* non zero if metadata is attached. */
-            pAfCb->pafBsMetadataUpdate = 0;                             /* indicates whether bit-stream metadata update */
-            pAfCb->numPrivateMetadata  = 0;                             /* number of valid private metadata (0 or 1 if metadata filtering enabled) */
-            pAfCb->bsMetadata_offset   = 0;                             /* offset into audio frame for change in bsMetadata_type field */
-        }
+        pCb->maxAFSampCount = ASP_DECOP_CB_MAX_PCM_FRAME_LEN_48kMAT;        
     }
     else
     {
-        SW_BREAKPOINT;
+        //
+        // Currently unsupported source select
+        //
+        
+        SW_BREAKPOINT; // debug
         
         // Leave the gate
         GateMP_leave(gateHandle, key);
 
         return ASP_DECOP_CB_INIT_INV_SOURCE_SEL;
     }
-
-    // initialize circular buffer current number of frames
+    
+    // Initialize audio frames
+    for (n = 0; n < pCb->maxNumAfCb; n++)
+    {
+        pAfCb = &pCb->afCb[n]; // get pointer to CB AF
+        
+        // Dec Info1 AF sample count not correct for CB AFs
+        pAfCb->sampleCount = decOpFrameLen;
+
+        // initialize CB AF using Dec Info1 AF
+        pAfCb->sampleDecode = pDecInfo1Af->sampleDecode;
+        PAF_PROCESS_COPY(pAfCb->sampleProcess, pDecInfo1Af->sampleProcess);
+        pAfCb->sampleRate = pDecInfo1Af->sampleRate;
+        pAfCb->channelConfigurationRequest.full = pDecInfo1Af->channelConfigurationRequest.full;
+        pAfCb->channelConfigurationStream.full = pDecInfo1Af->channelConfigurationStream.full;
+        
+        // initialize metadata information updated by decoder
+        pAfCb->bsMetadata_type     = PAF_bsMetadata_none;           /* non zero if metadata is attached. */
+        pAfCb->pafBsMetadataUpdate = 0;                             /* indicates whether bit-stream metadata update */
+        pAfCb->numPrivateMetadata  = 0;                             /* number of valid private metadata (0 or 1 if metadata filtering enabled) */
+        pAfCb->bsMetadata_offset   = 0;                             /* offset into audio frame for change in bsMetadata_type field */
+    }
+    
+    // Initialize circular buffer current number of frames
     pCb->numAfCb = pCb->afWrtIdx - pCb->afRdIdx;
     
-    // initialize audio frame PCM buffers
+    // Initialize audio frame PCM buffers
     pPcmBuf = pCb->pcmBuf;
     pMetaBuf = pCb->metaBuf;
     for (n=0; n<pCb->maxNumAfCb; n++)
     {
-        pAfCb = &pCb->afCb[n];
+        pAfCb = &pCb->afCb[n]; // get pointer to CB AF
+        
         pAfCb->data.nChannels = pCb->maxAFChanNum;
         pAfCb->data.nSamples = decOpFrameLen;
         for (i=0; i<pCb->maxAFChanNum; i++)
@@ -286,15 +264,15 @@ Int cbInitSourceSel(
         }
     }
     
-    // reset read/write flags
-    if (resetRwFlags)
+    // Reset read/write flags
+    if (resetRwFlags != 0)
     {
         pCb->writerActiveFlag = 0;
         pCb->readerActiveFlag = 0;
         pCb->drainFlag = 0;
     }
     
-    // reset stats
+    // Reset stats
     pCb->readAfWriterInactiveCnt = 0;
     pCb->wrtAfReaderInactiveCnt = 0;
     pCb->wrtAfZeroSampsCnt = 0;
index ba066492e6f5886ac50149a900967808ad894809..406af4450a78bf6a9681c07f089ff60f5051660f 100644 (file)
@@ -50,7 +50,8 @@ Int cbInitSourceSel(
     Int8 sourceSelect,                  // source select (PCM, DDP, etc.)
     Int16 decOpFrameLen,                // decoder output frame length (PCM samples)
     Int16 strFrameLen,                  // stream frame length (PCM samples)
-    Int8 resetRwFlags                   // whether to reset reader, writer, and drain flags
+    Int8 resetRwFlags,                  // whether to reset reader, writer, and drain flags
+    PAF_AudioFrame *pDecInfo1Af         // pointer to Dec Info1 audio frame
 );
 
     // Start writes to circular buffer
index d4ad58dddb67a8229d3ab6684aca4aa4570b2d34..a0a4fe4a4ff425fc27660010071cbfd3f80cabba 100644 (file)
@@ -165,7 +165,7 @@ Void taskAsdpFxn(
     PAF_AudioFrame *pAfWrt;             // pointer to audio frame written to CB
     Int cbErrno;                        // CB error number
     // Output Init-Sync
-    PAF_AudioFrame *pDecInitAf;         // pointer to Dec Info1 output audio frame
+    PAF_AudioFrame *pDecCtrlAf;         // pointer to Dec Control audio frame
     PAF_AST_OutInitSyncCtl *pOutIsCtl;  // OutIS control
     Int8 outIsDecInfo1Flag;             // indicates whether Dec Info Init-Sync has executed
     Int outIsErrno;                     // OutIS error number
@@ -549,13 +549,13 @@ Void taskAsdpFxn(
                         errno = dec->fxns->reset(dec, NULL, &pAstCfg->xDec[z].decodeControl, &pAstCfg->xDec[z].decodeStatus);
 
                         // get pointer to Dec Reset output audio frame
-                        pDecInitAf = pAstCfg->xDec[z].decodeControl.pAudioFrame;
+                        pDecCtrlAf = pAstCfg->xDec[z].decodeControl.pAudioFrame;
 
                         // Perform Dec Reset Init-Sync
                         //  - Write Dec Reset output audio frame
                         //  - Set Dec Reset decoder stage flag
                         outIsErrno = outIsWriteDecStageFlagAndAf(pOutIsCtl, z, 
-                            ASP_OUTIS_DEC_STAGE_RESET_IDX, 1, pDecInitAf);
+                            ASP_OUTIS_DEC_STAGE_RESET_IDX, 1, pDecCtrlAf);
                         if (outIsErrno < 0)
                         {
                             SW_BREAKPOINT; // debug
@@ -657,13 +657,13 @@ Void taskAsdpFxn(
                         if (outIsDecInfo1Flag == 0)
                         {
                             // get pointer to Dec Info1 output audio frame
-                            pDecInitAf = pAstCfg->xDec[z].decodeControl.pAudioFrame;
+                            pDecCtrlAf = pAstCfg->xDec[z].decodeControl.pAudioFrame;
 
                             // Perform Dec Info Init-Sync
                             //  - Write Dec Info1 output audio frame
                             //  - Set Dec Info1 decoder stage flag
                             outIsErrno = outIsWriteDecStageFlagAndAf(pOutIsCtl, z, 
-                                ASP_OUTIS_DEC_STAGE_INFO1_IDX, 1, pDecInitAf);
+                                ASP_OUTIS_DEC_STAGE_INFO1_IDX, 1, pDecCtrlAf);
                             if (outIsErrno < 0)
                             {
                                 SW_BREAKPOINT; // debug
@@ -681,7 +681,7 @@ Void taskAsdpFxn(
                             // Initialize decoder output circular buffer for selected source
                             errno = cbInitSourceSel(pCbCtl, z, sourceSelect, 
                                 pAstCfg->xDec[z].decodeControl.frameLength, 
-                                FRAMELENGTH, 0);
+                                FRAMELENGTH, 0, pDecCtrlAf);
                             if (errno)
                             {
                                 SW_BREAKPOINT; // debug