PASDK-218:Add function to get "decoder frame length" using source select.
authorFrank Livingston <frank-livingston@ti.com>
Sun, 2 Jul 2017 18:08:48 +0000 (13:08 -0500)
committerFrank Livingston <frank-livingston@ti.com>
Sun, 2 Jul 2017 18:08:48 +0000 (13:08 -0500)
Need to review decoder (and other) frame lengths used in system.

pasdk/test_dsp/framework/audioStreamInpProc.c

index fc677b05eb842126caea8d9b98ba01af22975782..ca53098ca095be30ee5dd00eeacfb4cb41c88d67 100644 (file)
@@ -306,6 +306,25 @@ extern UInt32 gAspProfileEnable;
 
 #define __TASK_NAME__  "TaskAsip"
 
+
+//
+// Audio Stream Output Task definitions
+//
+
+#define ASIP_FRAMELEN_SS_DEFAULT    ( 256 )
+// FL: pP->frameLength
+//#define ASIP_FRAMELEN_SS_PCM        ( FRAMELENGTH )
+// FL: (***) hard-coded
+#define ASIP_FRAMELEN_SS_DDP_AC3    ( 1536 )
+// FL: (***) hard-coded
+#define ASIP_FRAMELEN_SS_THD        ( 1536 )        //QIN FIX ME
+
+// Compute decoder frame length based on selected source
+static Int getFrameLengthSourceSel(
+    const PAF_ASIT_Params *pP, 
+    Int8 sourceSelect
+);
+
 LINNO_DEFN(TaskAsip); /* Line number macros */
 ERRNO_DEFN(TaskAsip); /* Error number macros */
 
@@ -780,11 +799,12 @@ Void taskAsipFxn(
         
         pfpBegin(PFP_ID_ASIT_1, pAsitCfg->taskHandle);  // PFP begin
         gNumPfpAsit1++;
+        // (***) FL: re-visit, hard-coded to use FRAMELENGTH (pP->frameLength) inside function
         errno = pP->fxns->autoProcessing(pP, pQ, pAsitCfg, tempVar8, NULL);
         pfpEnd(PFP_ID_ASIT_1, PFP_FINISH_MEAS);         // PFP end
         gNumPfpAsit1--;
 
-        if (errno) // (***) FL: re-visit this, hard-coded to use PCM framelength inside function
+        if (errno)
         {
             TRACE_VERBOSE1("TaskAsip: autoProcessing returns 0x%x, continue", errno);
             continue;
@@ -794,8 +814,10 @@ Void taskAsipFxn(
         // At this point we have an enabled input and want to decode something.
         // If no decoder selected then do nothing. Need to reset the sourceProgram, since
         // when no decoder is selected there are no calls to IB
+        
         //if (errno = pP->fxns->autoProcessing(pP, pQ, PC, pC->xDec[zMD].decodeStatus.sourceSelect, pC->xDec[zMD].decAlg[PAF_SOURCE_PCM]))
-        if (errno = pP->fxns->autoProcessing(pP, pQ, pAsitCfg, pAstCfg->xDec[zMD].decodeStatus.sourceSelect, NULL)) // (***) FL: re-visit this, hard-coded to use PCM framelength inside function
+        // (***) FL: re-visit this, hard-coded to use FRAMELENGTH (pP->frameLength) inside function
+        if (errno = pP->fxns->autoProcessing(pP, pQ, pAsitCfg, pAstCfg->xDec[zMD].decodeStatus.sourceSelect, NULL))
         {
             TRACE_VERBOSE1("TaskAsip: autoProcessing returns 0x%x, continue", errno);
             continue;
@@ -2016,8 +2038,8 @@ PAF_ASIT_autoProcessing(
     }
     //frameLength = pP->fxns->computeFrameLength (pcmAlgMaster, FRAMELENGTH,
     //                                            pC->xDec[zMD].decodeStatus.bufferRatio);
-    frameLength = FRAMELENGTH; // FL: fix PCM frameLength for alpha release.
-
+    frameLength = FRAMELENGTH; // (***) FL: fix PCM frameLength
+    
     if (errno = SIO_ctrl(pAstCfg->xInp[zMI].hRxSio,
                          PAF_SIO_CONTROL_SET_PCMFRAMELENGTH, frameLength))
     {
@@ -2802,27 +2824,13 @@ PAF_ASIT_decodeInit(
                 FRAMELENGTH,
                 pC->xDec[z].decodeStatus.bufferRatio);
 #endif
-#if 0 // (***) FL: revisit. Bypass computeFrameLength().
+#if 0 // (***) FL: revisit. Bypass decoder computeFrameLength() function.
             frameLength = pP->fxns->computeFrameLength(z, 
                 FRAMELENGTH, 
                 pC->xDec[z].decodeStatus.bufferRatio);
 #else
-            if (sourceSelect == PAF_SOURCE_PCM)
-            {
-               frameLength = PAF_SYS_FRAMELENGTH;
-            }
-            else if ((sourceSelect == PAF_SOURCE_DDP) || (sourceSelect == PAF_SOURCE_AC3))
-            {
-                frameLength = 1536;
-            }
-            else if (sourceSelect == PAF_SOURCE_THD)
-            {
-                frameLength = 1536; //QIN FIX ME
-            }
-            else
-            {
-                frameLength = 256;
-            }
+            // Compute decoder frame length based on source selection
+            frameLength = getFrameLengthSourceSel(pP, sourceSelect);
 #endif    
             
             pAstCfg->xDec[z].decodeControl.frameLength = frameLength;
@@ -3568,27 +3576,13 @@ PAF_ASIT_decodeDecode(
                 FRAMELENGTH, 
                 pC->xDec[z].decodeStatus.bufferRatio);
 #endif
-#if 0 // (***) FL: revisit. Bypass computeFrameLength().
+#if 0 // (***) FL: revisit. Bypass decoder computeFrameLength() function.
             frameLength = pP->fxns->computeFrameLength(z, 
                 FRAMELENGTH, 
                 pC->xDec[z].decodeStatus.bufferRatio);
 #else
-            if (sourceSelect == PAF_SOURCE_PCM)
-            {
-                frameLength = PAF_SYS_FRAMELENGTH;
-            }
-            else if ((sourceSelect == PAF_SOURCE_DDP) || (sourceSelect == PAF_SOURCE_AC3))
-            {
-                frameLength = 1536;
-            }
-            else if (sourceSelect == PAF_SOURCE_THD)
-            {
-                frameLength = 1536; //QIN FIX ME
-            }
-            else
-            {
-                frameLength = 256;
-            }
+            // Compute decoder frame length based on source selection
+            frameLength = getFrameLengthSourceSel(pP, sourceSelect);
 #endif
 
 
@@ -3596,7 +3590,7 @@ PAF_ASIT_decodeDecode(
 //            // modify for different decoders
 //            if (sourceSelect == PAF_SOURCE_THD)
 //            {
-//             start_profiling = 1;
+//                start_profiling = 1;
 //            }
 //            else
 //            {
@@ -4109,3 +4103,31 @@ void as_traceChannels(PAF_AST_Config *pC, int z)
     }
 }
 #endif
+
+// Compute decoder frame length based on selected source
+static Int getFrameLengthSourceSel(
+    const PAF_ASIT_Params *pP, 
+    Int8 sourceSelect
+)
+{
+    Int frameLength;
+    
+    switch(sourceSelect)
+    {
+        case PAF_SOURCE_PCM:
+            frameLength = FRAMELENGTH;
+            break;
+        case PAF_SOURCE_AC3: 
+        case PAF_SOURCE_DDP:
+            frameLength = ASIP_FRAMELEN_SS_DDP_AC3;
+            break;
+        case PAF_SOURCE_THD:
+            frameLength = ASIP_FRAMELEN_SS_THD;
+            break;
+        default:
+            frameLength = ASIP_FRAMELEN_SS_DEFAULT;
+            break;
+    }
+    
+    return frameLength;
+}