Merge branch 'dev_pasdk_frank_pasdk376Beta3Release' of ssh://git@bitbucket.itg.ti...
authorSu <qsu@ti.com>
Fri, 25 Aug 2017 20:31:27 +0000 (16:31 -0400)
committerSu <qsu@ti.com>
Fri, 25 Aug 2017 20:31:27 +0000 (16:31 -0400)
# Conflicts:
# build_all.bat
# pasdk/common/aspDecOpCircBuf_common.c
# pasdk/common/aspDecOpCircBuf_common.h
# pasdk/paf
# pasdk/test_arm/.ccsproject
# pasdk/test_arm/.cproject
# pasdk/test_arm/.project
# pasdk/test_arm/application/app.cfg
# pasdk/test_arm/application/app.cmd
# pasdk/test_arm/application/app_pkgs.cmd
# pasdk/test_arm/framework/aspDecOpCircBuf_slave.c
# pasdk/test_arm/macros.ini_initial
# pasdk/test_dsp/.ccsproject
# pasdk/test_dsp/.cproject
# pasdk/test_dsp/.project
# pasdk/test_dsp/application/app.cfg
# pasdk/test_dsp/application/app.cmd
# pasdk/test_dsp/application/app_pkgs.cmd
# pasdk/test_dsp/application/itopo/evmk2g/alpha/i13_a.h
# pasdk/test_dsp/framework/aspDecOpCircBuf_master.c
# pasdk/test_dsp/framework/audioStreamInpProc.c
# pasdk/test_dsp/framework/itopo/patchs.c
# pasdk/test_dsp/macros.ini_initial
# scripts/build_dtsxip_pkg.bat
# scripts/build_dtsxip_pkgs.bat
# tools

21 files changed:
1  2 
pasdk/common/aspDecOpCircBuf_common.c
pasdk/common/aspDecOpCircBuf_common.h
pasdk/paf
pasdk/test_arm/.cproject
pasdk/test_arm/application/app.cfg
pasdk/test_arm/application/app.cmd
pasdk/test_arm/application/app_pkgs.cmd
pasdk/test_arm/framework/aspDecOpCircBuf_slave.c
pasdk/test_arm/framework/audioStreamDecodeProc.c
pasdk/test_arm/macros.ini_initial
pasdk/test_dsp/.cproject
pasdk/test_dsp/application/app.cfg
pasdk/test_dsp/application/app.cmd
pasdk/test_dsp/application/app_pkgs.cmd
pasdk/test_dsp/application/itopo/evmk2g/alpha/i13_a.h
pasdk/test_dsp/application/itopo/evmk2g/atboot.c
pasdk/test_dsp/framework/aspDecOpCircBuf_master.c
pasdk/test_dsp/framework/audioStreamInpProc.c
pasdk/test_dsp/framework/itopo/params.c
pasdk/test_dsp/macros.ini_initial
tools

index 095ebb4f842caec80ab2a7c1655e44aed3a36c0d,e0192d0e669952701c0b8946a4957aabdb427049..74e570a2021e3861f7fb4072e554bf4a0da8de2a
@@@ -81,26 -145,24 +145,38 @@@ Int cbReset
      }
      else if (pCb->sourceSel == PAF_SOURCE_THD)
      {
-         // 0 in behind
          pCb->afWrtIdx = ASP_DECOP_CB_INIT_WRTIDX_THD;
          pCb->afRdIdx = ASP_DECOP_CB_INIT_RDIDX_THD;
-         pCb->pcmRdIdx = 0;
      }
 +    else if ((pCb->sourceSel == PAF_SOURCE_DTS)   ||
 +             (pCb->sourceSel == PAF_SOURCE_DTSHD) ||
 +             (pCb->sourceSel == PAF_SOURCE_DTS12) ||
 +             (pCb->sourceSel == PAF_SOURCE_DTS13) ||
 +             (pCb->sourceSel == PAF_SOURCE_DTS14) ||
 +             (pCb->sourceSel == PAF_SOURCE_DTS16) ||
 +             (pCb->sourceSel == PAF_SOURCE_DTSALL)
 +            )
 +    {
 +
 +        pCb->afWrtIdx = ASP_DECOP_CB_INIT_WRTIDX_DTS;
 +        pCb->afRdIdx = ASP_DECOP_CB_INIT_RDIDX_DTS;
 +        pCb->pcmRdIdx = pCb->decOpFrameLen - ASP_DECOP_CB_INIT_LAG_DTS*pCb->strFrameLen;
 +    }
+     else
+     {
+         //
+         // Currently unsupported source select
+         //
+         return ASP_DECOP_CB_RESET_INV_SOURCE_SEL;
+     }
+         
+     // Reset circular buffer:
+     //  - PCM read index
+     //  - Private metadata read index
+     //  - number of PCM samples in CB
+     pCb->pcmRdIdx = 0;
+     pCb->prvMdRdIdx = 0;
+     pCb->numPcmSampsPerCh = 0;
  
      // initialize circular buffer current number of frames
      pCb->numAfCb = pCb->afWrtIdx - pCb->afRdIdx;
index 48b8f7b6f3147d79ed30fc947d9e821975314118,d6e443af9c9f565825e2db71f64678c16331cece..f533e9dbcd9ff84e0e54bbf73d2e9066b94c3810
@@@ -66,11 -73,15 +73,18 @@@ All rights reserved
  #define ASP_DECOP_CB_MAX_NUM_PCM_CH_MAT         ( 32 )      // decoder output circular buffer maximum number audio PCM channels for MAT
  #define ASP_DECOP_CB_MAX_PCM_FRAME_LEN_48kMAT   ( 4*256 )   // decoder output circular buffer maximum PCM frame length at 48kHz sampling rate
  
- // TODO: update for dts
 +#define ASP_DECOP_CB_MAX_NUM_PCM_CH_DTS        ( 32 )      // decoder output circular buffer maximum number audio PCM channels for MAT
 +#define ASP_DECOP_CB_MAX_PCM_FRAME_LEN_48kDTS  ( 16*256 )  // decoder output circular buffer maximum PCM frame length at 48kHz sampling rate
- #define ASP_DECOP_CB_PCM_BUF_SZ                 ( ASP_DECOP_CB_MAX_NUM_PCM_CH * ASP_DECOP_CB_MAX_NUM_PCM_FRAMES * ASP_DECOP_CB_MAX_PCM_FRAME_LEN )
- #define ASP_DECOP_CB_PCM_BUF_SZ_32CH48kMAT      ( ASP_DECOP_CB_MAX_NUM_PCM_CH_MAT * ASP_DECOP_CB_MAX_NUM_PCM_FRAMES * ASP_DECOP_CB_MAX_PCM_FRAME_LEN_48kMAT )
++
+ // (***) FL: !!! REVISIT!!! THD 192 kHz "fudge factor" for CB PCM buffer size.
+ // Using this factor in PCM buffer size definition, buffer large enough to execute 192 kHz w/o CB OVR/UND.
+ // Need to define CB size in different terms than existing macros.
+ // (***) FL: !!! REVISIT!!! Allocating memory for max # channels (e.g. 32 for THD).
+ // GROSS over allocation for THD 192 kHz, 6ch max.
+ #define THD_HSR_FUDGE_FACTOR                    ( 368640 + 240000 )  
+ #define ASP_DECOP_CB_PCM_BUF_SZ                 ( ASP_DECOP_CB_MAX_NUM_PCM_CH * ASP_DECOP_CB_MAX_NUM_PCM_FRAMES * ASP_DECOP_CB_MAX_PCM_FRAME_LEN + THD_HSR_FUDGE_FACTOR)
+ // FL: unused
+ //#define ASP_DECOP_CB_PCM_BUF_SZ_32CH48kMAT      ( ASP_DECOP_CB_MAX_NUM_PCM_CH_MAT * ASP_DECOP_CB_MAX_NUM_PCM_FRAMES * ASP_DECOP_CB_MAX_PCM_FRAME_LEN_48kMAT )
  
  #define ASP_DECOP_CB_MAX_NUM_AF_PCM             ( 4 )
  #if (ASP_DECOP_CB_MAX_NUM_AF_PCM > ASP_DECOP_CB_MAX_NUM_AF)
  #define ASP_DECOP_CB_INIT_WRTIDX_THD            ( 0 )
  #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
- // DTS - TODO: to update for DTS
+ #define ASP_DECOP_CB_TARGET_ND_SAMPS_48kTHD     ( 3600 ) //( 3504 ) //( 2224 ) // THD target Nominal Delay in number of samples, fs=48 kHz
+ #define ASP_DECOP_CB_TARGET_ND_SAMPS_96kTHD     ( 2*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    ( 4*ASP_DECOP_CB_TARGET_ND_SAMPS_48kTHD ) // THD target Nominal Delay in number of samples, fs=192 kHz
 -
+ //#define DEF_SOURCE_SEL                          ( PAF_SOURCE_PCM )          // default source select
+ //#define DEF_DEC_OP_FRAME_LEN                    ( PAF_SYS_FRAMELENGTH )     // default decoder output frame length
+ //#define DEF_STR_FRAME_LEN                       ( PAF_SYS_FRAMELENGTH )     // default stream frame length
++// DTS - update for DTS
 +#define ASP_DECOP_CB_MAX_NUM_AF_DTS         ( 10 )
 +#if (ASP_DECOP_CB_MAX_NUM_AF_DTS > ASP_DECOP_CB_MAX_NUM_AF)
 +    #error "CB Max AF DTS error"
 +#endif
 +#define ASP_DECOP_CB_INIT_LAG_DTS           ( 2 )
 +#define ASP_DECOP_CB_INIT_WRTIDX_DTS        ( 3 )
 +#define ASP_DECOP_CB_INIT_RDIDX_DTS         ( 0 )
 +
- #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   
 +
+ // Decoder output circular buffer status
+ typedef struct PAF_AST_DecOpCircBufStatus
+ {
+     Int size;
+     Int16 strFrameLen;                      // stream frame length (output transaction size)
+ } PAF_AST_DecOpCircBufStatus;
  
  // Decoder output circular buffer
  typedef struct PAF_AST_DecOpCircBuf 
diff --cc pasdk/paf
index 9245565a872a94f63acbda013f7e958c75f13f54,537f318a5eb6b22535dcea27f7b26bd245049b53..87b178537f95548bc9589dfbfebb974c49f30ea6
+++ b/pasdk/paf
@@@ -1,1 -1,1 +1,1 @@@
- Subproject commit 9245565a872a94f63acbda013f7e958c75f13f54
 -Subproject commit 537f318a5eb6b22535dcea27f7b26bd245049b53
++Subproject commit 87b178537f95548bc9589dfbfebb974c49f30ea6
index 9b4b844f041438d0e533f831e0623381621db628,446638c859440307679c1140e6e0e37a365fdf12..3d19f81adf21773ec0202ecde303b35d5112cbbb
                                        <stringMacro name="CSL_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="MMCSD_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="ICSS_EMAC_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="PDK_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti/processor_audio_sdk_1_00_00_04/psdk_cust/pdk_k2g_1_0_1_2_eng/packages"/>
 -                                      <stringMacro name="PDK_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti/processor_audio_sdk_1_00_00_05/psdk_cust/pdk_k2g_1_0_1_2_eng/packages"/>
++                                      <stringMacro name="PDK_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti/pdk_k2g_1_0_6/packages"/>
                                        <stringMacro name="USB_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="I2C_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="CPPI_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
Simple merge
index 15df0566bdf24d65a3a2ec76ab168e88309a913d,0549d5c47543d44bf563c7ca76dc1001372512b7..b31dc05f13c080894f7697555576866575dea131
@@@ -31,48 -31,22 +31,31 @@@ All rights reserved
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  */
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\pasdk\paf\pa\build\a15\release )
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\pasdk\paf\pa\util\da10x_misc\a15\release )
- /*
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\dolby_ip\intrinsics\Dolby_Intrinsics_Imp\lib_float_A15 )
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\dolby_ip\ddp\Dolby_Digital_Plus_Decoder_Imp\Source_Code\make\ddp_udc_lib\a15 )
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\dolby_ip\ddp\Dolby_Digital_Plus_Decoder_Imp\Source_Code\make\ddp_udc_wrapper\a15 )
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\dolby_ip\mat-thd\Dolby_MAT_Decoder_Imp\Source_Code\mat_dec\make\dthd_dec_lib\a15 )
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\dolby_ip\mat-thd\Dolby_MAT_Decoder_Imp\Source_Code\mat_dec\make\mat_dec_lib\a15 )
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\dolby_ip\mat-thd\Dolby_MAT_Decoder_Imp\Source_Code\mat_dec\make\thd_alg_lib\a15 )
- */
- /*
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\dts-3d\misc\build\a15\Debug )
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\dts-base\misc\build\a15\Debug )
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\common-flib\misc\build\a15\Debug )
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\lbr\misc\build\a15\lbr\Debug )
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\lbr\misc\build\a15\lbrdec\Debug )
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\parma-dec\misc\build\a15\Debug )
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\dtshd-c-decoder\misc\build\a15\lib\Debug )
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\la-strm-reconstruction\misc\build\a15\Debug )
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\alg\misc\build\a15\Debug )
- */
--
 +SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\dts-3d\misc\build\a15\Release )
 +SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\dts-base\misc\build\a15\Release )
 +SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\common-flib\misc\build\a15\Release )
 +SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\lbr\misc\build\a15\lbr\Release )
 +SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\lbr\misc\build\a15\lbrdec\Release )
 +SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\parma-dec\misc\build\a15\Release )
 +SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\dtshd-c-decoder\misc\build\a15\lib\Release )
 +SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\la-strm-reconstruction\misc\build\a15\Release )
 +SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\alg\misc\build\a15\Release )
+ SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_05\pasdk\paf\pa\build\a15\release )
+ SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_05\dolby_ip\intrinsics\Dolby_Intrinsics_Imp\lib_float_A15 )
+ SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_05\dolby_ip\ddp\Dolby_Digital_Plus_Decoder_Imp\Source_Code\make\ddp_udc_lib\a15 )
+ SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_05\dolby_ip\ddp\Dolby_Digital_Plus_Decoder_Imp\Source_Code\make\ddp_udc_wrapper\a15 )
+ SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_05\dolby_ip\mat-thd\Dolby_MAT_Decoder_Imp\Source_Code\mat_dec\make\dthd_dec_lib\a15 )
+ SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_05\dolby_ip\mat-thd\Dolby_MAT_Decoder_Imp\Source_Code\mat_dec\make\mat_dec_lib\a15 )
+ SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_05\dolby_ip\mat-thd\Dolby_MAT_Decoder_Imp\Source_Code\mat_dec\make\thd_alg_lib\a15 )
+ SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_05\pasdk\paf\pa\util\da10x_misc\a15\release )
  
  INPUT ( c67x_cintrins_elf.lib simulate_dma_elf.lib )
  INPUT ( acp_elf.lib asp_std_elf.lib com_asp_elf.lib com_dec_elf.lib pcm1_elf.lib statusop_common_elf.lib )
- INPUT ( misc_elf.lib )
 -INPUT ( dlb_intrinsics_generic_float32_release.a )
 -INPUT ( ddp_dec_lib_generic_wrapper_release.a ddp_dec_lib_generic_float32_release.a )
 -INPUT ( mat_dec_lib_generic_float32_release.lib thd_alg_lib_generic_float32_release.lib dthd_dec_lib_generic_float32_release.lib )
 +/* INPUT ( dlb_intrinsics_generic_float32_release.a ) */
- /* INPUT ( ddp_dec_lib_generic_wrapper_release.a ddp_dec_lib_generic_float32_release.a ) */
++/* INPUT ( ddp_dec_lib_generic_wrapper_release.a ddp_dec_lib_generic_float32_release.a )*/
 +/* INPUT ( mat_dec_lib_generic_float32_release.lib thd_alg_lib_generic_float32_release.lib dthd_dec_lib_generic_float32_release.lib ) */
+ INPUT ( misc_elf.lib )
 +INPUT ( dts-3d.lib dts-base.lib dts-flib.lib dts-lbr.lib dts-lbr-dec.lib dts-parma-dec.lib dtsx-c-decoder.lib la-strm-reconstruction.lib dts-alg.lib )
  
  SECTIONS
  {
index ebc1e4da4f70213b5d6b777b740c2a86fc60db92,aa7cb7ce8261ad23324cf6ef3684167409dd3e0a..4e0da93877087ead82a9f4f3c0c7f6781be3675e
@@@ -32,43 -32,17 +32,29 @@@ All rights reserved
  *
  */
  
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\pasdk\paf\pa\build\a15\release )
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\pasdk\paf\pa\util\da10x_misc\a15\release )
+ SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_05\pasdk\paf\pa\build\a15\release )
  /*
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\dolby_ip\intrinsics\Dolby_Intrinsics_Imp\lib_float_A15 )
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\dolby_ip\ddp\Dolby_Digital_Plus_Decoder_Imp\Source_Code\make\ddp_udc_lib\a15 )
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\dolby_ip\ddp\Dolby_Digital_Plus_Decoder_Imp\Source_Code\make\ddp_udc_wrapper\a15 )
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\dolby_ip\mat-thd\Dolby_MAT_Decoder_Imp\Source_Code\mat_dec\make\dthd_dec_lib\a15 )
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\dolby_ip\mat-thd\Dolby_MAT_Decoder_Imp\Source_Code\mat_dec\make\mat_dec_lib\a15 )
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\dolby_ip\mat-thd\Dolby_MAT_Decoder_Imp\Source_Code\mat_dec\make\thd_alg_lib\a15 )
+ SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_05\dolby_ip\intrinsics\Dolby_Intrinsics_Imp\lib_float_A15 )
+ SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_05\dolby_ip\ddp\Dolby_Digital_Plus_Decoder_Imp\Source_Code\make\ddp_udc_lib\a15 )
+ SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_05\dolby_ip\ddp\Dolby_Digital_Plus_Decoder_Imp\Source_Code\make\ddp_udc_wrapper\a15 )
+ SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_05\dolby_ip\mat-thd\Dolby_MAT_Decoder_Imp\Source_Code\mat_dec\make\dthd_dec_lib\a15 )
+ SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_05\dolby_ip\mat-thd\Dolby_MAT_Decoder_Imp\Source_Code\mat_dec\make\mat_dec_lib\a15 )
+ SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_05\dolby_ip\mat-thd\Dolby_MAT_Decoder_Imp\Source_Code\mat_dec\make\thd_alg_lib\a15 )
 -*/
+ SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_05\dolby_ip\dh-ip\build\a15\release )
 +*/
- /* SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\dolby_ip\dh-ip\build\a15\release ) */
- /*
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\dts-3d\misc\build\a15\Debug )
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\dts-base\misc\build\a15\Debug )
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\common-flib\misc\build\a15\Debug )
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\lbr\misc\build\a15\lbr\Debug )
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\lbr\misc\build\a15\lbrdec\Debug )
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\parma-dec\misc\build\a15\Debug )
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\dtshd-c-decoder\misc\build\a15\lib\Debug )
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\la-strm-reconstruction\misc\build\a15\Debug )
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\alg\misc\build\a15\Debug )
- */
 +/*
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\dts-3d\misc\build\a15\Release )
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\dts-base\misc\build\a15\Release )
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\common-flib\misc\build\a15\Release )
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\lbr\misc\build\a15\lbr\Release )
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\lbr\misc\build\a15\lbrdec\Release )
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\parma-dec\misc\build\a15\Release )
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\dtshd-c-decoder\misc\build\a15\lib\Release )
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\la-strm-reconstruction\misc\build\a15\Release )
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\alg\misc\build\a15\Release )
++SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_05\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\dts-3d\misc\build\a15\Release )
++SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_05\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\dts-base\misc\build\a15\Release )
++SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_05\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\common-flib\misc\build\a15\Release )
++SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_05\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\lbr\misc\build\a15\lbr\Release )
++SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_05\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\lbr\misc\build\a15\lbrdec\Release )
++SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_05\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\parma-dec\misc\build\a15\Release )
++SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_05\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\dtshd-c-decoder\misc\build\a15\lib\Release )
++SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_05\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\la-strm-reconstruction\misc\build\a15\Release )
++SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_05\3p-ip-dts\Source_Code\sdk-dts-uhd-no-guidedparma-src\alg\misc\build\a15\Release )
 +*/
- SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\dtsx-ip\build\a15\release )
++SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_05\3p-ip-dts\dtsx-ip\build\a15\release )
+ SEARCH_DIR ( C:\ti\processor_audio_sdk_1_00_00_05\pasdk\paf\pa\util\da10x_misc\a15\release )
  
  INPUT ( c67x_cintrins_elf.lib simulate_dma_elf.lib )
  INPUT ( acp_elf.lib asp_std_elf.lib com_asp_elf.lib com_dec_elf.lib pcm1_elf.lib statusop_common_elf.lib )
index 7952c57b3c8021221c70736066ad183e293b015d,f82709b398c6b8e3d8c485615df90ca31c39e6b3..25b6a56352be91eb6dc8c2e424d6de976d1d1f32
@@@ -69,10 -77,254 +77,292 @@@ Int cbCtlInit
          return ASP_DECOP_CB_CTL_INIT_INV_GATE;
      }
      
-     pCbCtl->pXDecOpCb = pXDecOpCb;
+     pCbCtl->numCb = numCb;          // init number of circular buffers
+     pCbCtl->pXDecOpCb = pXDecOpCb;  // init base address of circular buffers
      
      return ASP_DECOP_CB_SOK;
+ }
+ #endif
+ // debug
+ //Int8 gCbInitDecWriteCnt=0;
+ //Int8 gCbInitDecWriteThdCnt=0;
+ /// Initialize circular buffer for Decoder writes
+ Int cbInitDecWrite(
+     PAF_AST_DecOpCircBufCtl *pCbCtl,    // decoder output circular buffer control
+     Int8 cbIdx,                         // decoder output circular buffer index
+     Int8 sourceSelect,                  // source select (PCM, DDP, etc.)
+     Int16 decOpFrameLen,                // decoder output frame length (PCM samples)
+     Int8 resetRwFlags,                  // whether to reset reader, writer, and drain flags
+     PAF_AudioFrame *pDecInitAf          // pointer to Dec output audio frame used for CB initialization
+ )
+ {
+     IArg key;
+     GateMP_Handle gateHandle;
+     PAF_AST_DecOpCircBuf *pCb;
+     PAF_AudioFrame *pAfCb;
+     PAF_AudioData *pPcmBuf;
+     UInt8 *pMetaBuf;
+     Int8 n;
+     Int8 i;
+     //gCbInitDecWriteCnt++; // debug
+     
+     // Get gate handle
+     gateHandle = pCbCtl->gateHandle;
+     // Enter gate
+     key = GateMP_enter(gateHandle);
+     // Get circular buffer base pointer
+     pCb = &((*pCbCtl->pXDecOpCb)[cbIdx]);
+     
+     // Invalidate circular buffer configuration
+     Cache_inv(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
+     Cache_wait();
+     //Log_info1("cbInitDecWrite:afCb=0x%04x", (IArg)pCb->afCb); // debug
+     // Set source select
+     pCb->sourceSel = sourceSelect;
+     // Set input frame length
+     pCb->decOpFrameLen = decOpFrameLen;
+     
+     //pCb->afInitialLag = 0;  // default No lag
+     //pCb->afLagIdx = 0;
+     // Initialize CB primed flag
+     pCb->primedFlag = 0;
+     // Initialize delta samples
+     pCb->deltaSamps = 0;
      
+     // Initialize circular buffer:
+     //  - maximum number of AFs
+     //  - target nominal delay
+     //  - AF write, read indices
+     //  - maximum AF channel and sample counts
+     //  - maximum number of PCM samples per channel
+     if (sourceSelect == PAF_SOURCE_PCM)
+     {
+         pCb->maxNumAfCb = ASP_DECOP_CB_MAX_NUM_AF_PCM;
+         
+         //pCb->afInitialLag = ASP_DECOP_CB_INIT_LAG_PCM;
+         pCb->targetNDSamps = ASP_DECOP_CB_TARGET_ND_SAMPS_48kPCM;
+         
+         pCb->afWrtIdx = ASP_DECOP_CB_INIT_WRTIDX_PCM;
+         pCb->afRdIdx = ASP_DECOP_CB_INIT_RDIDX_PCM;
+         
+         pCb->maxAFChanNum = ASP_DECOP_CB_MAX_NUM_PCM_CH;
+         pCb->maxAFSampCount = DEF_DEC_OP_FRAME_LEN; 
+         pCb->maxNumPcmSampsPerCh = (Int32)(pCb->pcmBufEnd - pCb->pcmBuf)/pCb->maxAFChanNum;
+     }
+     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;
+         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;
+         
+         pCb->maxAFChanNum = ASP_DECOP_CB_MAX_NUM_PCM_CH_DDP;
+         pCb->maxAFSampCount = ASP_DECOP_CB_MAX_PCM_FRAME_LEN_48kDDP;
+         pCb->maxNumPcmSampsPerCh = (Int32)(pCb->pcmBufEnd - pCb->pcmBuf)/pCb->maxAFChanNum;
+     }
+     else if (sourceSelect == PAF_SOURCE_THD)
+     {
+         //gCbInitSourceSelThdCnt++; //debug
+         
+         pCb->maxNumAfCb = ASP_DECOP_CB_MAX_NUM_AF_THD;
+         
+         //pCb->afInitialLag = ASP_DECOP_CB_INIT_LAG_THD;
+         // FL: (***) set nominal delay per sampling rate -- need to review these settings
+         switch (pDecInitAf->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;
+             default:
+                 pCb->targetNDSamps = ASP_DECOP_CB_TARGET_ND_SAMPS_48kTHD;
+                 break;
+         }
+         
+         pCb->afWrtIdx = ASP_DECOP_CB_INIT_WRTIDX_THD;
+         pCb->afRdIdx = ASP_DECOP_CB_INIT_RDIDX_THD;
+         
+         pCb->maxAFChanNum = ASP_DECOP_CB_MAX_NUM_PCM_CH_MAT;
+         pCb->maxAFSampCount = ASP_DECOP_CB_MAX_PCM_FRAME_LEN_48kMAT;        
+         pCb->maxNumPcmSampsPerCh = (Int32)(pCb->pcmBufEnd - pCb->pcmBuf)/pCb->maxAFChanNum;
++    }
++      else if ((sourceSelect == PAF_SOURCE_DTS)   ||
++               (sourceSelect == PAF_SOURCE_DTSHD) ||
++               (sourceSelect == PAF_SOURCE_DTS12) ||
++               (sourceSelect == PAF_SOURCE_DTS13) ||
++               (sourceSelect == PAF_SOURCE_DTS14) ||
++               (sourceSelect == PAF_SOURCE_DTS16) ||
++               (sourceSelect == PAF_SOURCE_DTSALL)
++              )
++    {
++        pCb->maxNumAfCb = ASP_DECOP_CB_MAX_NUM_AF_DTS;
++        pCb->afWrtIdx = ASP_DECOP_CB_INIT_WRTIDX_DTS;
++        pCb->afRdIdx = ASP_DECOP_CB_INIT_RDIDX_DTS;
++        pCb->pcmRdIdx = 0;
++        pCb->maxAFChanNum = ASP_DECOP_CB_MAX_NUM_PCM_CH_DTS;
++        pCb->maxAFSampCount = ASP_DECOP_CB_MAX_PCM_FRAME_LEN_48kDTS;
++
++        // 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_DTS_X;          /* Audio data from DTSX decoder. */
++            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
+     {
+         //
+         // 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:
+     //  - PCM read index
+     //  - Private metadata read index
+     //  - number of PCM samples in CB
+     pCb->pcmRdIdx = 0;
+     pCb->prvMdRdIdx = 0;
+     pCb->numPcmSampsPerCh = 0;
+     // Initialize audio frames
+     for (n = 0; n < pCb->maxNumAfCb; n++)
+     {
+         pAfCb = &pCb->afCb[n]; // get pointer to CB AF
+         
+         // Dec init AF sample count not correct for CB AFs.
+         // Dec Op frame length is computed in framework based on selected source.
+         pAfCb->sampleCount = decOpFrameLen;
+         // initialize CB AF using Dec init AF
+         pAfCb->sampleDecode = pDecInitAf->sampleDecode;
+         PAF_PROCESS_COPY(pAfCb->sampleProcess, pDecInitAf->sampleProcess);
+         pAfCb->sampleRate = pDecInitAf->sampleRate;
+         pAfCb->channelConfigurationRequest.full = pDecInitAf->channelConfigurationRequest.full;
+         pAfCb->channelConfigurationStream.full = pDecInitAf->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
+     pPcmBuf = pCb->pcmBuf;
+     pMetaBuf = pCb->metaBuf;
+     for (n=0; n<pCb->maxNumAfCb; 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++)
+         {
+             pAfCb->data.sample[i] = pPcmBuf;
+             memset(pAfCb->data.sample[i], 0, pCb->maxAFSampCount);
+             pPcmBuf += pCb->maxAFSampCount;
+             
+             pAfCb->data.samsiz[i] = 0;
+         }
+         
+         // Initialize metadata buffers
+         for (i=0; i<PAF_MAX_NUM_PRIVATE_MD; i++)
+         {
+             pAfCb->pafPrivateMetadata[i].offset = 0; 
+             pAfCb->pafPrivateMetadata[i].size   = 0; 
+             pAfCb->pafPrivateMetadata[i].pMdBuf = pMetaBuf;
+             pMetaBuf += PAF_MAX_PRIVATE_MD_SZ;
+         }
+     }
+     
+     // Initialize last audio frame configuration info
+     cbInitLastAfInfo(pCb, pDecInitAf);
+     
+     // Reset read/write flags
+     if (resetRwFlags != 0)
+     {
+         pCb->writerActiveFlag = 0;
+         pCb->readerActiveFlag = 0;
+         pCb->drainFlag = 0;
+     }
+     
+     // Reset stats
+     pCb->readAfWriterInactiveCnt = 0;
+     pCb->readAfNdCnt = 0;
+     pCb->wrtAfReaderInactiveCnt = 0;
+     pCb->wrtAfZeroSampsCnt = 0;
+     pCb->errAfUndCnt = 0;
+     pCb->errAfOvrCnt = 0;
+     pCb->errPcmUndCnt = 0;
+     pCb->errPcmOvrCnt = 0;
+     
+     // Write back circular buffer configuration
+     Cache_wb(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
+     // Write back AF circular buffer
+     Cache_wb(pCb->afCb, pCb->maxNumAfCb*sizeof(PAF_AudioFrame), Cache_Type_ALLD, 0);
+     // Write back PCM data
+     for (n=0; n<pCb->maxNumAfCb; n++)
+     {
+         pAfCb = &pCb->afCb[n];
+         Cache_wb(pAfCb->data.samsiz, pCb->maxAFChanNum*sizeof(PAF_AudioSize), Cache_Type_ALLD, 0);
+         Cache_wb(pAfCb->data.sample, pCb->maxAFChanNum*sizeof(PAF_AudioData *), Cache_Type_ALLD, 0);
+         for (i=0; i<pCb->maxAFChanNum; i++)
+         {
+             Cache_wb(pAfCb->data.sample[i], pCb->maxAFSampCount*sizeof(PAF_AudioData), Cache_Type_ALLD, 0);
+         }
+     }
+     Cache_wait();
+     // Leave the gate
+     GateMP_leave(gateHandle, key);
+     
+     return ASP_DECOP_CB_SOK;
  }
  
  //Int8 gCbWriteStartCnt=0; // debug
@@@ -210,188 -465,345 +503,355 @@@ Int cbWriteAf
      //Log_info1("cbWriteAf:afCb=0x%04x", (IArg)pCb->afCb); // debug
      //Log_info2("cbWriteAf:pCb->readerActiveFlag=%d, pCb->writerActiveFlag=%d", (IArg)pCb->readerActiveFlag, (IArg)pCb->writerActiveFlag); // debug
  
-     if ((pCb->readerActiveFlag == 1) && (pAfWrt->sampleCount)) //QIN ?
-     {
-         //
-         // Normal case, reader active.
-         // If reader not active, don't write to circular buffer or check OVRflow.
- #if 0        
-         if (pCb->cbWriteAfInit == 0)
-         {
-             // Invalidate AF circular buffer
-             Cache_inv(pCb->afCb, pCb->maxNumAfCb*sizeof(PAF_AudioFrame), Cache_Type_ALLD, 0);
-             for (n=0; n<pCb->maxNumAfCb; n++)
-             {
-                 pAfCb = &pCb->afCb[n];
-                 Cache_inv(pAfCb->data.sample, pCb->maxAFChanNum*sizeof(PAF_AudioData *), Cache_Type_ALLD, 0);
-             }
-             Cache_wait();
-             pCb->cbWriteAfInit = 1;
-         }
- #endif        
-         //Log_info2("cbWriteAf:pCb->numAfCb=%d, pCb->maxNumAfCb=%d", (IArg)pCb->readerActiveFlag, (IArg)pCb->maxNumAfCb); // debug
-         // check overflow
-         //while (pCb->numAfCb >= pCb->maxNumAfCb); // debug
-         if (pCb->numAfCb >= pCb->maxNumAfCb)
+     //if (pCb->readerActiveFlag == 1)
+     //{
+     //    //
+     //    // Normal case, reader active.
+     //    //
+         
+         if (pAfWrt->sampleCount != 0)
          {
-             pCb->errOvrCnt++;
-             //SW_BREAKPOINT;
-             Log_info1("cbWriteAf: ERROR: overflow, numAfCb=%d", pCb->numAfCb);
+             //Log_info2("cbWriteAf:pCb->numAfCb=%d, pCb->maxNumAfCb=%d", (IArg)pCb->readerActiveFlag, (IArg)pCb->maxNumAfCb); // debug
  
-             // Write back circular buffer configuration
-             Cache_wb(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
+             // check AF overflow
+             if (pCb->numAfCb >= pCb->maxNumAfCb)
+             {
+                 pCb->errAfOvrCnt++;
  
-             // Leave the gate
-             GateMP_leave(gateHandle, key);
+                 //SW_BREAKPOINT;
+                 Log_info1("cbWriteAf: ERROR: AF CB overflow, numAfCb=%d", pCb->numAfCb);
  
-             //Log_info2("cbWriteAf:gate leave, gateHandle=0x%04x, key=%d", (IArg)gateHandle, (IArg)key); // debug
+                 // Write back circular buffer configuration
+                 Cache_wb(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
+                 Cache_wait();
  
-             return ASP_DECOP_CB_WRITE_OVERFLOW;
-         }
+                 // Leave the gate
+                 GateMP_leave(gateHandle, key);
  
-         pAfCb = &pCb->afCb[pCb->afWrtIdx];
-         pPcmBuf = pAfCb->data.sample[0];
-         pMetaBuf = pAfCb->pafPrivateMetadata[0].pMdBuf;
-         if((pPcmBuf + (pAfWrt->sampleCount * pCb->maxAFChanNum )) > (pCb->pcmBufEnd))
-         {
-             pPcmBuf = pCb->pcmBuf;
-         }
-         for (i=0; i<pCb->maxAFChanNum; i++)
-         {
-             pAfCb->data.sample[i] = pPcmBuf;
-             pPcmBuf += pAfWrt->sampleCount;
-             pAfCb->data.samsiz[i] = 0;
-         }
-         Cache_inv(pAfCb->data.sample, pCb->maxAFChanNum*sizeof(PAF_AudioData *), Cache_Type_ALLD, 0); // FL: this is write back and invalidate??
-         Cache_wait();
+                 //Log_info2("cbWriteAf:gate leave, gateHandle=0x%04x, key=%d", (IArg)gateHandle, (IArg)key); // debug
  
+                 return ASP_DECOP_CB_AF_WRITE_OVERFLOW;
+             }
+             
+             // FL: this won't reliably detect overflow because of PCM buffer write address wrap
+             // check PCM overflow
+             //if ((pCb->numPcmSampsPerCh + pAfWrt->sampleCount) > pCb->maxNumPcmSampsPerCh)
+             //{
+             //    pCb->errPcmOvrCnt++;
+             //
+             //    Log_info3("cbWriteAf: ERROR: PCM CB overflow, sampleCount=%d, numPcmSampsPerCh=%d, maxNumPcmSampsPerCh=%d",
+             //        pCb->numPcmSampsPerCh, pAfWrt->sampleCount, pCb->maxNumPcmSampsPerCh);
+             //
+             //    // Write back circular buffer configuration
+             //    Cache_wb(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
+             //    Cache_wait();
+             //
+             //    // Leave the gate
+             //    GateMP_leave(gateHandle, key);
+             //
+             //    return ASP_DECOP_CB_PCM_WRITE_OVERFLOW;
+             //}
+             // get CB AF write info
+             pAfCb = &pCb->afCb[pCb->afWrtIdx];                      // get CB AF to be written
+             pPcmBufWrt = pAfCb->data.sample[0];                     // get current location in PCM buffer to be written
+             // (***) FL: currently no metadata buffer overflow detection
+             pMetaBuf = pAfCb->pafPrivateMetadata[0].pMdBuf;         // get current location in MD buffer to be written
+             
+             // get CB AF read info
+             pAfCbRd = &pCb->afCb[pCb->afRdIdx];                     // get CB AF being read
+             //pPcmBufRd = pAfCbRd->data.sample[0];                    // FL: starting location of PCM samples for AF being read
+             pPcmBufRd = pAfCbRd->data.sample[0] + pCb->pcmRdIdx;    // FL: current location of PCM samples for AF being read
+             
+             // Check PCM buffer overflow
+             pPcmBuf = pPcmBufWrt;
+             pcmOvr = 0;
+             for (i = 0; i < pCb->maxAFChanNum; i++)
+             {
+                 //
+                 // Writes of PCM to PCM CB use CC stream, but this isn't considered here.
+                 // For each channel which *can* be written, check the current reader location won't be overwritten.
+                 // The current reader location is the earliest channel which *could have been* written for that CB AF.
+                 //
+                 if ((pPcmBuf + pAfWrt->sampleCount) >= pCb->pcmBufEnd)
+                 {
+                     // this write will wrap
+                     
+                     // check OVR before wrap
+                     if ((pPcmBuf < pPcmBufRd) && 
+                         ((pPcmBuf + pAfWrt->sampleCount) >= pPcmBufRd))
+                     {
+                         pCb->errPcmOvrCnt++;
+                         pcmOvr = 1;
+                     }
+                     
+                     if (pcmOvr == 0)
+                     {
+                         // wrap pointer
+                         pPcmBuf = pCb->pcmBuf;   
+                         // check OVR after wrap
+                         if ((pPcmBuf < pPcmBufRd) && 
+                             ((pPcmBuf + pAfWrt->sampleCount) >= pPcmBufRd))
+                         {
+                             pCb->errPcmOvrCnt++;
+                             pcmOvr = 1;
+                         }                                                                
+                     }
+                 }
+                 else if ((pPcmBuf < pPcmBufRd) && 
+                     ((pPcmBuf + pAfWrt->sampleCount) >= pPcmBufRd))
+                 {
+                     // this write won't wrap
+                     
+                     pCb->errPcmOvrCnt++;
+                     pcmOvr = 1;
+                 }
+                 else
+                 {
+                     // update pointer
+                     pPcmBuf += pAfWrt->sampleCount;                                        
+                 }
+                 
+                 if (pcmOvr == 1)
+                 {
+                     Log_info2("cbWriteAf: ERROR: PCM CB overflow, sampleCount=%d, numPcmSampsPerCh=%d", 
+                          pAfWrt->sampleCount, pCb->numPcmSampsPerCh);
+             
+                     //SW_BREAKPOINT; // debug
+                     
+                     // Write back circular buffer configuration
+                     Cache_wb(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
+                     Cache_wait();
+             
+                     // Leave the gate
+                     GateMP_leave(gateHandle, key);
+             
+                     return ASP_DECOP_CB_PCM_WRITE_OVERFLOW;
+                 }
+             }
+             
+             // (***) FL: !!! REVISIT!!! 
+             //           Allocating memory for max # channels (e.g. 32 for THD).
+             //           GROSS over allocation for THD 192 kHz, 6ch max.
+             // configure AF sample pointers
+             pPcmBuf = pPcmBufWrt;
+             for (i = 0; i < pCb->maxAFChanNum; i++)
+             {
+                 // check PCM buffer wrap
+                 if ((pPcmBuf + pAfWrt->sampleCount) >= pCb->pcmBufEnd)
+                 {
+                     pPcmBuf = pCb->pcmBuf;
+                 }
+                 
+                 pAfCb->data.sample[i] = pPcmBuf;                
+                 pPcmBuf += pAfWrt->sampleCount;
+                 pAfCb->data.samsiz[i] = 0;
+             }
+             Cache_inv(pAfCb->data.sample, pCb->maxAFChanNum*sizeof(PAF_AudioData *), Cache_Type_ALLD, 0); // FL: this is write back and invalidate??
+             Cache_wait();
  
-         for (i=0; i<PAF_MAX_NUM_PRIVATE_MD; i++)
-         {
-             pAfCb->pafPrivateMetadata[i].offset = 0;
-             pAfCb->pafPrivateMetadata[i].size   = 0;
-             pAfCb->pafPrivateMetadata[i].pMdBuf = pMetaBuf;
-             pMetaBuf += PAF_MAX_PRIVATE_MD_SZ;
-         }
+             // FL: brute force reset of all metadata in CB AF?
+             for (i=0; i<PAF_MAX_NUM_PRIVATE_MD; i++)
+             {
+                 pAfCb->pafPrivateMetadata[i].offset = 0;
+                 pAfCb->pafPrivateMetadata[i].size   = 0;
+                 pAfCb->pafPrivateMetadata[i].pMdBuf = pMetaBuf;
+                 pMetaBuf += PAF_MAX_PRIVATE_MD_SZ;
+             }
  
-         nextWrtIdx = 0;
-         if ((pCb->afWrtIdx +1) >= pCb->maxNumAfCb)
-         {
-             //Log_info0("cbWriteAf: AF Wrap around **** ");
-             // next audio frame will be audio frame 0
+ #if 0 // FL: unused
              nextWrtIdx = 0;
-         }else{
-             // next audio frame will be current audio frame + 1
-             nextWrtIdx = pCb->afWrtIdx + 1;
-         }
-         pAfCbNextAf = &pCb->afCb[nextWrtIdx]; // +1 or last AF if overflow
-         pAfCbNextAf->data.sample[0] = &pAfCb->data.sample[pCb->maxAFChanNum - 1][pAfWrt->sampleCount];// pAfCb->data.sample[15] + (pAfCb->sampleCount * sizeof(PAF_AudioData));
-         // write audio frame information updated by decoder
-         pAfCb->sampleDecode = pAfWrt->sampleDecode;
-         PAF_PROCESS_COPY(pAfCb->sampleProcess, pAfWrt->sampleProcess);
-         pAfCb->sampleRate = pAfWrt->sampleRate;
-         pAfCb->sampleCount = pAfWrt->sampleCount;
-         pAfCb->channelConfigurationRequest = pAfWrt->channelConfigurationRequest;
-         pAfCb->channelConfigurationStream = pAfWrt->channelConfigurationStream;
-         // write metadata information updated by decoder
-         pAfCb->bsMetadata_type     = pAfWrt->bsMetadata_type;        /* non zero if metadata is attached. */
-         pAfCb->pafBsMetadataUpdate = pAfWrt->pafBsMetadataUpdate;    /* indicates whether bit-stream metadata update */
-         pAfCb->numPrivateMetadata  = pAfWrt->numPrivateMetadata;     /* number of valid private metadata (0 or 1 if metadata filtering enabled) */
-         pAfCb->bsMetadata_offset   = pAfWrt->bsMetadata_offset;      /* offset into audio frame for change in bsMetadata_type field */
-               
+             if ((pCb->afWrtIdx + 1) >= pCb->maxNumAfCb)
+             {
+                 //Log_info0("cbWriteAf: AF Wrap around **** ");
+                 // next audio frame will be audio frame 0
+                 nextWrtIdx = 0;
+             }
+             else
+             {
+                 // next audio frame will be current audio frame + 1
+                 nextWrtIdx = pCb->afWrtIdx + 1;
+             }
+             
+             pAfCbNextAf = &pCb->afCb[nextWrtIdx]; // +1 or last AF if overflow
+             pAfCbNextAf->data.sample[0] = &pAfCb->data.sample[pCb->maxAFChanNum - 1][pAfWrt->sampleCount]; // pAfCb->data.sample[15] + (pAfCb->sampleCount * sizeof(PAF_AudioData));
+ #endif
+             
+             // write audio frame information updated by decoder
+             pAfCb->sampleDecode = pAfWrt->sampleDecode;
+             PAF_PROCESS_COPY(pAfCb->sampleProcess, pAfWrt->sampleProcess);
+             pAfCb->sampleRate = pAfWrt->sampleRate;
+             pAfCb->sampleCount = pAfWrt->sampleCount;
+             pAfCb->channelConfigurationRequest = pAfWrt->channelConfigurationRequest;
+             pAfCb->channelConfigurationStream = pAfWrt->channelConfigurationStream;
+             // write metadata information updated by decoder
+             pAfCb->bsMetadata_type     = pAfWrt->bsMetadata_type;        /* non zero if metadata is attached. */
+             pAfCb->pafBsMetadataUpdate = pAfWrt->pafBsMetadataUpdate;    /* indicates whether bit-stream metadata update */
+             pAfCb->numPrivateMetadata  = pAfWrt->numPrivateMetadata;     /* number of valid private metadata (0 or 1 if metadata filtering enabled) */
+             pAfCb->bsMetadata_offset   = pAfWrt->bsMetadata_offset;      /* offset into audio frame for change in bsMetadata_type field */
+             
 +#ifdef DTS_BUILD
 +        pAfCb->mode = pAfWrt->mode;                                       /* mode is used in DTSX to pass info to PARMA */
 +        pAfCb->numChansUsedForMetadata = pAfWrt->numChansUsedForMetadata; /* if metadata is used in DTSX*/
 +        pAfCb->pafBsFixedData = pAfWrt->pafBsFixedData;                   /* if true, do not convert float to fixed in DTSX metadata transfer */
 +        pAfCb->root = pAfWrt->root;                                       /* used for channel MASK in DTSX . BAD IDEA, need fix */
 +#endif                
-         // write PCM samples
-         streamMask = pAfWrt->fxns->channelMask(pAfWrt, pAfCb->channelConfigurationStream);
-         for (i = 0; i < pCb->maxAFChanNum; i++)
-         {
+             // write PCM samples
+             streamMask = pAfWrt->fxns->channelMask(pAfWrt, pAfCb->channelConfigurationStream);
+             for (i = 0; i < pCb->maxAFChanNum; i++)
+             {
 -                if ((streamMask >> i) & 0x1)
 -                {
 +#ifndef DTS_BUILD
 +            if ((streamMask >> i) & 0x1)
 +#endif
 +            { //DTSX needs up to 16 channels to transfer metadata.
-                 for (j = 0; j < pAfWrt->sampleCount; j++)
+                     for (j = 0; j < pAfWrt->sampleCount; j++)
+                     {
+                         pAfCb->data.sample[i][j] = pAfWrt->data.sample[i][j];
+                     }
+                     pAfCb->data.samsiz[i] = pAfWrt->data.samsiz[i];
+                 }
+             }
+             
+             // Update PCM samples per channel
+             pCb->numPcmSampsPerCh += pAfWrt->sampleCount;
+             
+             #ifdef CB_RW_OP_CAP_PP // debug
+             if (pCb->cb_opCnt < CB_OP_COUNT_MAX)
+             {
+                 if ((pCb->cb_samples_op != NULL) && (pCb->cb_op_owner != NULL))
                  {
-                     pAfCb->data.sample[i][j] = pAfWrt->data.sample[i][j];
+                     // log sample count
+                     pCb->cb_samples_op[pCb->cb_opCnt] = pAfWrt->sampleCount;
+                     pCb->cb_op_owner[pCb->cb_opCnt] = CB_OP_W;
+                     // log idxs
+                     pCb->cb_afRdIdx[pCb->cb_opCnt] = pCb->afRdIdx;
+                     pCb->cb_afWrtIdx[pCb->cb_opCnt] = pCb->afWrtIdx;
+                     pCb->cb_numAfCb[pCb->cb_opCnt] = pCb->numAfCb; // numAfCb might not be pointing to this instance
+                     pCb->cb_opCnt++;
                  }
+             }
+             #endif
  
-                 pAfCb->data.samsiz[i] = pAfWrt->data.samsiz[i];
+             // prepare metadata buffer pointers according to the metadata and buffer sizes
+             for (i = 0; i < pAfWrt->numPrivateMetadata; i++)
+             {
+                 UInt8 *nextMdBuf;
+                 if (i == 0)
+                 {
+                     nextMdBuf = (pAfCb->pafPrivateMetadata[0].pMdBuf + pAfWrt->pafPrivateMetadata[0].size);                    
+                 }
+                 else
+                 {
+                     nextMdBuf = (pAfCb->pafPrivateMetadata[i-1].pMdBuf + pAfWrt->pafPrivateMetadata[i-1].size);                    
+                 }
+                 if (nextMdBuf >= pCb->metaBufEnd) // metadata buffer overflow
+                 {
+                     pAfCb->pafPrivateMetadata[i].pMdBuf = pCb->metaBuf;
+                 }
+                 else if (i != 0)
+                 {
+                     pAfCb->pafPrivateMetadata[i].pMdBuf = nextMdBuf;
+                 }
+                 Cache_inv(pAfCb->pafPrivateMetadata[i].pMdBuf, sizeof(UInt8 *), Cache_Type_ALLD, 0);
              }
-         }
  
-         #ifdef CB_RW_OP_CAP_PP // debug
-         if (pCb->cb_opCnt < CB_OP_COUNT_MAX)
-         {
-             if ((pCb->cb_samples_op != NULL) && (pCb->cb_op_owner != NULL))
+             // Write metadata to circular buffer
+             for (i = 0; i < pAfWrt->numPrivateMetadata; i++) // only copy numPrivateMetadata
              {
-                 // log sample count
-                 pCb->cb_samples_op[pCb->cb_opCnt] = pAfWrt->sampleCount;
-                 pCb->cb_op_owner[pCb->cb_opCnt] = CB_OP_W;
-                 // log idxs
-                 pCb->cb_afRdIdx[pCb->cb_opCnt] = pCb->afRdIdx;
-                 pCb->cb_afWrtIdx[pCb->cb_opCnt] = pCb->afWrtIdx;
-                 pCb->cb_numAfCb[pCb->cb_opCnt] = pCb->numAfCb; // numAfCb might not be pointing to this instance
-                 pCb->cb_opCnt++;
+                 pAfCb->pafPrivateMetadata[i].offset = pAfWrt->pafPrivateMetadata[i].offset;
+                 pAfCb->pafPrivateMetadata[i].size   = pAfWrt->pafPrivateMetadata[i].size;
+                 memcpy(pAfCb->pafPrivateMetadata[i].pMdBuf, pAfWrt->pafPrivateMetadata[i].pMdBuf, pAfWrt->pafPrivateMetadata[i].size);
              }
-         }
-         #endif
  
-         // prepare metadata buffer pointers according to the metadata and buffer sizes
-         for (i=0; i < pAfWrt->numPrivateMetadata; i++)
-         {
-             UInt8 *nextMdBuf;
-             if(i == 0)
-               nextMdBuf = (pAfCb->pafPrivateMetadata[0].pMdBuf + pAfWrt->pafPrivateMetadata[0].size);
+             Cache_inv(pAfCb->pafPrivateMetadata, pAfWrt->numPrivateMetadata*sizeof(PAF_PrivateMetadata *), Cache_Type_ALLD, 0); // FL: this is write back and invalidate??
+             Cache_wait();
+             for (i = 0; i < pAfCb->numPrivateMetadata; i++) // only write back numPrivateMetadata
+             {
+                 //Log_info4("cbWriteAf: AF: %d nummd: %d offset: %d size: %d ", pCb->afWrtIdx, pAfCb->numPrivateMetadata, pAfCb->pafPrivateMetadata[i].offset,  pAfCb->pafPrivateMetadata[i].size);
+                 Cache_wb(pAfCb->pafPrivateMetadata[i].pMdBuf, pAfCb->pafPrivateMetadata[i].size, Cache_Type_ALLD, 0);
+             }
+             // update audio frame write index
+             pCb->afWrtIdx++;
+             if (pCb->afWrtIdx >= pCb->maxNumAfCb)
+             {
+                 pCb->afWrtIdx = 0;
+             }
+             pCb->afCb[pCb->afWrtIdx].data.sample[0] = &pAfCb->data.sample[pCb->maxAFChanNum - 1][pAfWrt->sampleCount];
+             if (pAfWrt->numPrivateMetadata > 0)
+             {
+                 pCb->afCb[pCb->afWrtIdx].pafPrivateMetadata[0].pMdBuf = pAfCb->pafPrivateMetadata[pAfWrt->numPrivateMetadata - 1].pMdBuf + pAfWrt->pafPrivateMetadata[pAfWrt->numPrivateMetadata - 1].size;
+             }
              else
-               nextMdBuf = (pAfCb->pafPrivateMetadata[i-1].pMdBuf + pAfWrt->pafPrivateMetadata[i-1].size);
-             if(nextMdBuf >= pCb->metaBufEnd) // metadata buffer overflow
              {
-                 pAfCb->pafPrivateMetadata[i].pMdBuf = pCb->metaBuf;
+                 pCb->afCb[pCb->afWrtIdx].pafPrivateMetadata[0].pMdBuf = pAfCb->pafPrivateMetadata[0].pMdBuf;
+                 Cache_wb(pCb->afCb , ASP_DECOP_CB_MAX_NUM_PCM_FRAMES*sizeof(PAF_AudioFrame *), Cache_Type_ALLD, 0);
+                 Cache_wait();
              }
-             else if(i != 0)
+             Cache_inv(pCb->afCb[pCb->afWrtIdx].pafPrivateMetadata[0].pMdBuf, sizeof(UInt8 *), Cache_Type_ALLD, 0);
+             Cache_wait();
+             // update number of audio frames in circular buffer
+             pCb->numAfCb++;
+             
+             // Update CB Lag index 
+             //if (pCb->afLagIdx < pCb->afInitialLag)
+             //{
+             //    pCb->afLagIdx += 1;
+             //}
+             
+             // Update CB primed flag
+             // calculate number of delta samples before allowing CB read
+             if (pCb->primedFlag == 0)
              {
-                 pAfCb->pafPrivateMetadata[i].pMdBuf = nextMdBuf;
+                 pCb->primedFlag = 1;
+                 
+                 // Calculate number of output frames to block reader.
+                 // This is sample count reader waits before allowed to actually read samples from the CB.
+                 //pCb->deltaSamps = (pCb->targetNDSamps - pAfWrt->sampleCount + (pCb->strFrameLen-1)) / pCb->strFrameLen * pCb->strFrameLen;
+                 // FL: CB read decrements by strFrameLen and tests for >0, so rounding to strFrameLen is unnecessary
+                 pCb->deltaSamps = pCb->targetNDSamps - pAfWrt->sampleCount;
+                 
+                 // debug
+                 //gSampleCountBuf[gPrimedFlagCnt] = pAfWrt->sampleCount;
+                 //gCalcDeltaSampsBuf[gPrimedFlagCnt] = pCb->deltaSamps;
+                 //if (gPrimedFlagCnt < 10)
+                 //    gPrimedFlagCnt++;
              }
-             Cache_inv(pAfCb->pafPrivateMetadata[i].pMdBuf, sizeof(UInt8 *), Cache_Type_ALLD, 0);
-         }
  
-         // Write metadata to circular buffer
-         for (i = 0; i < pAfWrt->numPrivateMetadata; i++) // only copy numPrivateMetadata
-         {
-             pAfCb->pafPrivateMetadata[i].offset = pAfWrt->pafPrivateMetadata[i].offset;
-             pAfCb->pafPrivateMetadata[i].size   = pAfWrt->pafPrivateMetadata[i].size;
-             memcpy(pAfCb->pafPrivateMetadata[i].pMdBuf, pAfWrt->pafPrivateMetadata[i].pMdBuf, pAfWrt->pafPrivateMetadata[i].size);
-         }
+             // Write back circular buffer configuration
+             Cache_wb(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
+             // write back audio frame
+             Cache_wb(pAfCb, sizeof(PAF_AudioFrame), Cache_Type_ALLD, 0);
+             Cache_wb(pAfCb->data.samsiz, pCb->maxAFChanNum*sizeof(PAF_AudioSize), Cache_Type_ALLD, 0);
+             Cache_wb(pAfCb->pafPrivateMetadata, pAfWrt->numPrivateMetadata*sizeof(PAF_PrivateMetadata *), Cache_Type_ALLD, 0);
+             Cache_wait();
+             // write back PCM data
+             for (i = 0; i < pCb->maxAFChanNum; i++)
+             {
 -                if ((streamMask >> i) & 0x1)
 -                {
++#ifndef DTS_BUILD
++            if ((streamMask >> i) & 0x1)
++#endif
++            {//DTSX needs up to 16 channels to transfer metadata.
+                     Cache_wb(pAfCb->data.sample[i], pAfWrt->sampleCount * sizeof(PAF_AudioData), Cache_Type_ALLD, 0);
+                 }
+             }
+             Cache_wait();
  
-         Cache_inv(pAfCb->pafPrivateMetadata, pAfWrt->numPrivateMetadata*sizeof(PAF_PrivateMetadata *), Cache_Type_ALLD, 0); // FL: this is write back and invalidate??
-         Cache_wait();
-         for (i=0; i<pAfCb->numPrivateMetadata; i++) // only write back numPrivateMetadata
-         {
-             //Log_info4("cbWriteAf: AF: %d nummd: %d offset: %d size: %d ", pCb->afWrtIdx, pAfCb->numPrivateMetadata, pAfCb->pafPrivateMetadata[i].offset,  pAfCb->pafPrivateMetadata[i].size);
-             Cache_wb(pAfCb->pafPrivateMetadata[i].pMdBuf, pAfCb->pafPrivateMetadata[i].size, Cache_Type_ALLD, 0);
-         }
-         // update audio frame write index
-         pCb->afWrtIdx++;
-         if (pCb->afWrtIdx >= pCb->maxNumAfCb)
-         {
-             pCb->afWrtIdx = 0;
-         }
+ #if 0 // (***) FL: shows timing of CB write
+             // debug
+             {
+                 static Uint8 toggleState = 0;
+                if (toggleState == 0)
+                    GPIOSetOutput(GPIO_PORT_0, GPIO_PIN_99);
+                else
+                    GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_99);
+                toggleState = ~(toggleState);
+             }
+ #endif
  
-         pCb->afCb[pCb->afWrtIdx].data.sample[0] = &pAfCb->data.sample[pCb->maxAFChanNum - 1][pAfWrt->sampleCount];
-         if(pAfWrt->numPrivateMetadata > 0)
-         {
-             pCb->afCb[pCb->afWrtIdx].pafPrivateMetadata[0].pMdBuf = pAfCb->pafPrivateMetadata[pAfWrt->numPrivateMetadata - 1].pMdBuf + pAfWrt->pafPrivateMetadata[pAfWrt->numPrivateMetadata - 1].size;
+             Log_info3("wrote %d samples into AF %d sourceSel: %d", pAfCb->sampleCount, pCb->afWrtIdx, pCb->sourceSel);
+             Log_info4("CBWMETA num=%d  size=%d  offset=%d chrequest=0x%04x", pAfCb->numPrivateMetadata, pAfCb->pafPrivateMetadata[0].size, pAfCb->pafPrivateMetadata[0].offset, pAfCb->channelConfigurationRequest.full);
          }
          else
          {
index 60e0f129d86bcc483796edcfca95a371a616da01,a3b16baa15f02a209ed4c9525b26a79cebb8fee3..98c27aafd3445b172512908a7851eab663778a31
@@@ -276,8 -291,29 +291,32 @@@ Void taskAsdpFxn
          TRACE_TERSE2("TaskAsdp: AS%d: initialization phase - %d completed", as+zMS, i);
          LINNO_RPRT(TaskAsdp, -i-3);
      }
 -      
 +    
+ #ifdef NON_CACHE_STATUS
+     //
+     // init Status structure Gate
      //
 -
+     if (statusOp_Init(GATEMP_INDEX_DEC) == STATUSOP_INIT_FAIL)
+     {
+         TRACE_TERSE1("TaskAsdp: Gate Index %d:initialization status GateMP Fail.", GATEMP_INDEX_DEC);
+     }
+     if (statusOp_Init(GATEMP_INDEX_DDP) == STATUSOP_INIT_FAIL)
+     {
+         TRACE_TERSE1("TaskAsdp: Gate Index %d:initialization status GateMP Fail.", GATEMP_INDEX_DDP);
+     }
+     if (statusOp_Init(GATEMP_INDEX_PCM) == STATUSOP_INIT_FAIL)
+     {
+         TRACE_TERSE1("TaskAsdp: Gate Index %d:initialization status GateMP Fail.", GATEMP_INDEX_PCM);
+     }
+     if (statusOp_Init(GATEMP_INDEX_THD) == STATUSOP_INIT_FAIL)
+     {
+         TRACE_TERSE1("TaskAsdp: Gate Index %d:initialization status GateMP Fail.", GATEMP_INDEX_THD);
+     }
++    if (statusOp_Init(GATEMP_INDEX_DTS) == STATUSOP_INIT_FAIL)
++    {
++        TRACE_TERSE1("TaskAsdp: Gate Index %d:initialization status GateMP Fail.", GATEMP_INDEX_DTS);
++    }
+ #endif
      //
      // End of Initialization -- final memory usage report.
      //
index 586332988ee3b8d9f38029adf1fd1478413f6988,378c125826753f6a3ed0ebf8a21ad1135d2d68ef..d85ae6b5e7584a8c0fe70faa930ef81c264be3fc
@@@ -1,4 -1,4 +1,4 @@@
- PDK_INSTALL_PATH        = C:/ti/processor_audio_sdk_1_00_00_04/psdk_cust/pdk_k2g_1_0_1_2_eng/packages
 -PDK_INSTALL_PATH        = C:/ti/processor_audio_sdk_1_00_00_05/psdk_cust/pdk_k2g_1_0_1_2_eng/packages
++PDK_INSTALL_PATH        = C:/ti/pdk_k2g_1_0_6/packages
  CSL_INSTALL_PATH        = C:/ti/
  BOARD_INSTALL_PATH      = C:/ti/
  SBL_BOOT_INSTALL_PATH   = C:/ti/
@@@ -30,4 -30,4 +30,4 @@@ DFE_INSTALL_PATH        = C:/ti
  IQN_INSTALL_PATH        = C:/ti/
  IQN2_INSTALL_PATH       = C:/ti/
  PKTLIB_INSTALL_PATH     = C:/ti/
- PROC_AUDIO_SDK_ROOT     = C:/ti/processor_audio_sdk_1_00_00_04
 -PROC_AUDIO_SDK_ROOT     = C:/ti/processor_audio_sdk_1_00_00_05
++PROC_AUDIO_SDK_ROOT     = C:/ti/processor_audio_sdk_1_00_00_05
index 48c32b53c92990fd32003c3e42066cdbbfaeefa4,f0580ce9a06801c3fadf5c57ee20eb6b154d50e8..bfff70ea86d340c7aa087831c97b41f165bb3cde
                                        <stringMacro name="AIF2_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="CSL_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="MMCSD_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="PDK_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti/processor_audio_sdk_1_00_00_04/psdk_cust/pdk_k2g_1_0_1_2_eng/packages"/>
                                        <stringMacro name="ICSS_EMAC_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
 -                                      <stringMacro name="PDK_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti/processor_audio_sdk_1_00_00_05/psdk_cust/pdk_k2g_1_0_1_2_eng/packages"/>
++                                      <stringMacro name="PDK_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti/pdk_k2g_1_0_6/packages"/>
                                        <stringMacro name="USB_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="I2C_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="IQN2_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="AIF2_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="CSL_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="MMCSD_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
-                                       <stringMacro name="PDK_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti/processor_audio_sdk_1_00_00_04/psdk_cust/pdk_k2g_1_0_1_2_eng/packages"/>
                                        <stringMacro name="ICSS_EMAC_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
 -                                      <stringMacro name="PDK_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti/processor_audio_sdk_1_00_00_05/psdk_cust/pdk_k2g_1_0_1_2_eng/packages"/>
++                                      <stringMacro name="PDK_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti/pdk_k2g_1_0_6/packages"/>
                                        <stringMacro name="USB_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="I2C_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
                                        <stringMacro name="IQN2_INSTALL_PATH" type="VALUE_PATH_DIR" value="C:/ti"/>
Simple merge
index 39c69b62b3e90e6d006f3dfb20d0c97e762b4b80,b13aea3e3d8ca2b1f7b3bb30f4ab98c10eb08aac..25bb49f4f83c50073638962ae93452c04ca88cf8
@@@ -32,32 -32,17 +32,30 @@@ All rights reserved
  *
  */
  
- -i"C:\ti\processor_audio_sdk_1_00_00_04\pasdk\paf\pa\build\c66x\release"
- -i"C:\ti\processor_audio_sdk_1_00_00_04\pasdk\paf\pa\util\da10x_misc\c66x\release"
- -i"C:\ti\dsplib_c66x_3_4_0_0\packages\ti\dsplib\lib"
- -i"C:\ti\mathlib_c66x_3_1_1_0\packages\ti\mathlib\lib"
+ -i"C:\ti\processor_audio_sdk_1_00_00_05\pasdk\paf\pa\build\c66x\release"
 +/*
- -i"C:\ti\processor_audio_sdk_1_00_00_04\dolby_ip\oar\CCS_OAR_lib\make"
- -i"C:\ti\processor_audio_sdk_1_00_00_04\dolby_ip\car\Source_Code\car\make\alg_car\tisim_eabi_c66_ccs"
- -i"C:\ti\processor_audio_sdk_1_00_00_04\dolby_ip\car\Source_Code\car\make\libcar\tisim_eabi_c66_ccs"
- -i"C:\ti\processor_audio_sdk_1_00_00_04\dolby_ip\dap\Dolby_Audio_Processing_Home_Theatre_Imp\Source_Code\dap_ht\make\algdap_ht\linux_omap_eabi_c66_c6run"
- -i"C:\ti\processor_audio_sdk_1_00_00_04\dolby_ip\dap\Dolby_Audio_Processing_Home_Theatre_Imp\Source_Code\dap_ht\make\libdap_ht\linux_omap_eabi_c66_c6run"
- -i"C:\ti\processor_audio_sdk_1_00_00_04\dolby_ip\bmda\Source_Code\make\c66x\release"
- -i"C:\ti\processor_audio_sdk_1_00_00_04\dolby_ip\intrinsics\Dolby_Intrinsics_Imp\lib_elf_C66"
+ -i"C:\ti\processor_audio_sdk_1_00_00_05\dolby_ip\oar\CCS_OAR_lib\make"
+ -i"C:\ti\processor_audio_sdk_1_00_00_05\dolby_ip\car\Source_Code\car\make\alg_car\tisim_eabi_c66_ccs"
+ -i"C:\ti\processor_audio_sdk_1_00_00_05\dolby_ip\car\Source_Code\car\make\libcar\tisim_eabi_c66_ccs"
+ -i"C:\ti\processor_audio_sdk_1_00_00_05\dolby_ip\dap\Dolby_Audio_Processing_Home_Theatre_Imp\Source_Code\dap_ht\make\algdap_ht\linux_omap_eabi_c66_c6run"
+ -i"C:\ti\processor_audio_sdk_1_00_00_05\dolby_ip\dap\Dolby_Audio_Processing_Home_Theatre_Imp\Source_Code\dap_ht\make\libdap_ht\linux_omap_eabi_c66_c6run"
+ -i"C:\ti\processor_audio_sdk_1_00_00_05\dolby_ip\bmda\Source_Code\make\c66x\release"
+ -i"C:\ti\processor_audio_sdk_1_00_00_05\dolby_ip\intrinsics\Dolby_Intrinsics_Imp\lib_elf_C66"
 +*/
+ -i"C:\ti\dsplib_c66x_3_4_0_0\packages\ti\dsplib\lib"
++-i"C:\ti\mathlib_c66x_3_1_1_0\packages\ti\mathlib\lib"
+ -i"C:\ti\processor_audio_sdk_1_00_00_05\pasdk\paf\pa\util\da10x_misc\c66x\release"
  
 +-i"C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\PARMA\dts-3d\misc\build\c66x\Release"
 +-i"C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\PARMA\dts-base\misc\build\c66x\Release"
 +-i"C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\PARMA\common-flib\misc\build\c66x\Release"
 +-i"C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\PARMA\lbr\misc\build\c66x\lbr\Release"
 +-i"C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\PARMA\lbr\misc\build\c66x\lbrdec\Release"
 +-i"C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\PARMA\parma-dec\misc\build\c66x\Release"
 +-i"C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\PARMA\dtshd-c-decoder\misc\build\c66x\lib\Release"
 +-i"C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\PARMA\la-strm-reconstruction\misc\build\c66x\Release"
 +-i"C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\PARMA\alg\misc\build\c66x\Release"
 +
  
  -l"acp_elf.lib"
  -l"asp_std_elf.lib"
  -l"dcs7_elf.lib"
  -l"statusop_common_elf.lib"
  -l"misc_elf.lib"
---l"src4_elf.lib"
++/* -l"src4_elf.lib"*/
  -l"fil_elf.lib"
- -l"ae0_elf.lib"
- -l"ml_elf.lib"
- -l"dsplib.lib"
- -l"mathlib.ae66"
  
- /* -l"dolby_oar_lib.lib" */
- /* -l"libcar_c66_float_release.lib" */
- /* -l"algcar_c66_float_release.lib" */
 +/* -l"algdap_ht_c66_float_release.lib" */
 +/* -l"libdap_ht_c66_float_release.lib" */
- /* -l"bmda_elf.lib" */
- /* -l"dlb_intrinsics_c66_float_release.lib" */
++/*
+ -l"dolby_oar_lib.lib"
+ -l"libcar_c66_float_release.lib"
+ -l"algcar_c66_float_release.lib"
 -/* -l"algdap_ht_c66_float_release.lib" */
 -/* -l"libdap_ht_c66_float_release.lib" */
 --l"dsplib.lib"
+ -l"bmda_elf.lib"
+ -l"dlb_intrinsics_c66_float_release.lib"
 -
+ -l"ae0_elf.lib"
+ -l"ml_elf.lib"
++*/
 +-l"dts-3d.lib" 
 +-l"dts-base.lib" 
 +-l"dts-flib.lib" 
 +-l"dts-lbr.lib" 
 +-l"dts-lbr-dec.lib" 
 +-l"dts-parma-dec.lib" 
 +-l"dtsx-c-decoder.lib" 
 +-l"la-strm-reconstruction.lib" 
 +-l"dts-alg.lib"
 +
++-l"dsplib.lib"
++-l"mathlib.ae66"
  SECTIONS
  {
      .globalSectionPafAsitConfig :> CORE0_DDR3
index f5b9775dcab25617c469cf35b57566efda05d7b8,1eb4e6b0aaf960b0773c468fe264a465a3daf914..52d03a4cd039d4059e726ae4b7b1232b0ab6a6f0
@@@ -32,35 -32,20 +32,34 @@@ All rights reserved
  *
  */
  
- -i"C:\ti\processor_audio_sdk_1_00_00_04\pasdk\paf\pa\build\c66x\release"
- -i"C:\ti\processor_audio_sdk_1_00_00_04\pasdk\paf\pa\util\da10x_misc\c66x\release"
- -i"C:\ti\dsplib_c66x_3_4_0_0\packages\ti\dsplib\lib"
- -i"C:\ti\mathlib_c66x_3_1_1_0\packages\ti\mathlib\lib"
+ -i"C:\ti\processor_audio_sdk_1_00_00_05\pasdk\paf\pa\build\c66x\release"
  /*
- -i"C:\ti\processor_audio_sdk_1_00_00_04\dolby_ip\oar\CCS_OAR_lib\make"
- -i"C:\ti\processor_audio_sdk_1_00_00_04\dolby_ip\car\Source_Code\car\make\alg_car\tisim_eabi_c66_ccs"
- -i"C:\ti\processor_audio_sdk_1_00_00_04\dolby_ip\car\Source_Code\car\make\libcar\tisim_eabi_c66_ccs"
- -i"C:\ti\processor_audio_sdk_1_00_00_04\dolby_ip\dap\Dolby_Audio_Processing_Home_Theatre_Imp\Source_Code\dap_ht\make\algdap_ht\linux_omap_eabi_c66_c6run"
- -i"C:\ti\processor_audio_sdk_1_00_00_04\dolby_ip\dap\Dolby_Audio_Processing_Home_Theatre_Imp\Source_Code\dap_ht\make\libdap_ht\linux_omap_eabi_c66_c6run"
- -i"C:\ti\processor_audio_sdk_1_00_00_04\dolby_ip\bmda\Source_Code\make\c66x\release"
- -i"C:\ti\processor_audio_sdk_1_00_00_04\dolby_ip\intrinsics\Dolby_Intrinsics_Imp\lib_elf_C66"
+ -i"C:\ti\processor_audio_sdk_1_00_00_05\dolby_ip\oar\CCS_OAR_lib\make"
+ -i"C:\ti\processor_audio_sdk_1_00_00_05\dolby_ip\car\Source_Code\car\make\alg_car\tisim_eabi_c66_ccs"
+ -i"C:\ti\processor_audio_sdk_1_00_00_05\dolby_ip\car\Source_Code\car\make\libcar\tisim_eabi_c66_ccs"
+ -i"C:\ti\processor_audio_sdk_1_00_00_05\dolby_ip\dap\Dolby_Audio_Processing_Home_Theatre_Imp\Source_Code\dap_ht\make\algdap_ht\linux_omap_eabi_c66_c6run"
+ -i"C:\ti\processor_audio_sdk_1_00_00_05\dolby_ip\dap\Dolby_Audio_Processing_Home_Theatre_Imp\Source_Code\dap_ht\make\libdap_ht\linux_omap_eabi_c66_c6run"
+ -i"C:\ti\processor_audio_sdk_1_00_00_05\dolby_ip\bmda\Source_Code\make\c66x\release"
+ -i"C:\ti\processor_audio_sdk_1_00_00_05\dolby_ip\intrinsics\Dolby_Intrinsics_Imp\lib_elf_C66"
  */
- /* -i"C:\ti\processor_audio_sdk_1_00_00_04\dolby_ip\dh-ip\build\c66x\release" */
 --i"C:\ti\processor_audio_sdk_1_00_00_05\dolby_ip\dh-ip\build\c66x\release"
++/* -i"C:\ti\processor_audio_sdk_1_00_00_05\dolby_ip\dh-ip\build\c66x\release" */
 +/*
- -i"C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\PARMA\dts-3d\misc\build\c66x\Release"
- -i"C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\PARMA\dts-base\misc\build\c66x\Release"
- -i"C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\PARMA\common-flib\misc\build\c66x\Release"
- -i"C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\PARMA\lbr\misc\build\c66x\lbr\Release"
- -i"C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\PARMA\lbr\misc\build\c66x\lbrdec\Release"
- -i"C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\PARMA\parma-dec\misc\build\c66x\Release"
- -i"C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\PARMA\dtshd-c-decoder\misc\build\c66x\lib\Release"
- -i"C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\PARMA\la-strm-reconstruction\misc\build\c66x\Release"
- -i"C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\Source_Code\PARMA\alg\misc\build\c66x\Release"
++-i"C:\ti\processor_audio_sdk_1_00_00_05\3p-ip-dts\Source_Code\PARMA\dts-3d\misc\build\c66x\Release"
++-i"C:\ti\processor_audio_sdk_1_00_00_05\3p-ip-dts\Source_Code\PARMA\dts-base\misc\build\c66x\Release"
++-i"C:\ti\processor_audio_sdk_1_00_00_05\3p-ip-dts\Source_Code\PARMA\common-flib\misc\build\c66x\Release"
++-i"C:\ti\processor_audio_sdk_1_00_00_05\3p-ip-dts\Source_Code\PARMA\lbr\misc\build\c66x\lbr\Release"
++-i"C:\ti\processor_audio_sdk_1_00_00_05\3p-ip-dts\Source_Code\PARMA\lbr\misc\build\c66x\lbrdec\Release"
++-i"C:\ti\processor_audio_sdk_1_00_00_05\3p-ip-dts\Source_Code\PARMA\parma-dec\misc\build\c66x\Release"
++-i"C:\ti\processor_audio_sdk_1_00_00_05\3p-ip-dts\Source_Code\PARMA\dtshd-c-decoder\misc\build\c66x\lib\Release"
++-i"C:\ti\processor_audio_sdk_1_00_00_05\3p-ip-dts\Source_Code\PARMA\la-strm-reconstruction\misc\build\c66x\Release"
++-i"C:\ti\processor_audio_sdk_1_00_00_05\3p-ip-dts\Source_Code\PARMA\alg\misc\build\c66x\Debug"
 +*/
- -i"C:\ti\processor_audio_sdk_1_00_00_04\3p-ip-dts\dtsx-ip\build\c66x\release"
++-i"C:\ti\processor_audio_sdk_1_00_00_05\3p-ip-dts\dtsx-ip\build\c66x\release"
++
++-i"C:\ti\mathlib_c66x_3_1_1_0\packages\ti\mathlib\lib"
+ -i"C:\ti\dsplib_c66x_3_4_0_0\packages\ti\dsplib\lib"
+ -i"C:\ti\processor_audio_sdk_1_00_00_05\pasdk\paf\pa\util\da10x_misc\c66x\release"
  
  -l"acp_elf.lib"
  -l"asp_std_elf.lib"
  -l"dcs7_elf.lib"
  -l"statusop_common_elf.lib"
  -l"misc_elf.lib"
---l"src4_elf.lib"
++/* -l"src4_elf.lib" */
  -l"fil_elf.lib"
- -l"ae0_elf.lib"
- -l"ml_elf.lib"
  
- -l"dsplib.lib"
- -l"mathlib.ae66"
- /* -l"dolby_oar_lib.lib" */
- /* -l"libcar_c66_float_release.lib" */
- /* -l"algcar_c66_float_release.lib" */
 +/* -l"algdap_ht_c66_float_release.lib" */
 +/* -l"libdap_ht_c66_float_release.lib" */
- /* -l"bmda_elf.lib" */
- /* -l"dlb_intrinsics_c66_float_release.lib" */
++/*
+ -l"dolby_oar_lib.lib"
+ -l"libcar_c66_float_release.lib"
+ -l"algcar_c66_float_release.lib"
 -/* -l"algdap_ht_c66_float_release.lib" */
 -/* -l"libdap_ht_c66_float_release.lib" */
 --l"dsplib.lib"
+ -l"bmda_elf.lib"
+ -l"dlb_intrinsics_c66_float_release.lib"
  
+ -l"ae0_elf.lib"
+ -l"ml_elf.lib"
++*/
 +-l"dts-3d.lib" 
 +-l"dts-base.lib" 
 +-l"dts-flib.lib" 
 +-l"dts-lbr.lib" 
 +-l"dts-lbr-dec.lib" 
 +-l"dts-parma-dec.lib" 
 +-l"dtsx-c-decoder.lib" 
 +-l"la-strm-reconstruction.lib" 
 +-l"dts-alg.lib"
 +
++-l"dsplib.lib"
++-l"mathlib.ae66"
  SECTIONS
  {
      .globalSectionPafAsitConfig :> CORE0_DDR3
index 42f06f7b0b42196647822d9e4afa295b01bf3364,55368b74c491397489c44fd0cbfd236680e7adea..08f3cdef898bae4978fb5a5b7bf0e0bdedcd98b6
@@@ -57,12 -57,11 +57,13 @@@ All rights reserved
  #include <ae_a.h>
  #include <ml_a.h>
  #include <src_a.h>
 -#include <ddpat_a.h>
 -#include <thd_a.h>
 -#include <car_a.h>
 -#include <oar_a.h>
 -#include <bmda_a.h>
 +//#include <ddpat_a.h>
 +//#include <thd_a.h>
 +//#include <car_a.h>
 +//#include <oar_a.h>
 +//#include <bmda_a.h>
  //#include <dap_a.h>
 +#include <dtsuhda_a.h>
 +#include <dtsuhdb_a.h>
+ #include <pafdecopcb_a.h>
  #endif /* _I13_A_H_ */
index c2a93a638c7771ffb4158bf31eb0041e80e97543,2b0bdf0649ff8dee2dda65de98593aa29572634e..f78d2a8d1d5f8bb04ebee5f5ae3eb73c10571c71
@@@ -48,21 -48,6 +48,22 @@@ All rights reserved
  
  #include "dbgBenchmark.h" // PCM high-sampling rate + SRC + CAR benchmarking
  
- #define DTS 1
- #define DDP_ATBOOT_CFG 1
- #ifdef DTS    
- //DTS
++#define DTS_ATBOOT_CFG 1
++
++#ifdef DTS_ATBOOT_CFG    
++//DTS_ATBOOT_CFG
 +#define CUS_ATBOOT_S \
 +      writeDECChannelMapTo16(PAF_LEFT,PAF_RGHT,8,9,2,12,10,11,-3,-3,-3,-3,-3,-3,-3,-3), \
 +      writeENCChannelMapFrom16(PAF_LEFT,PAF_RGHT,8,9,2,12,10,11,-3,-3,-3,-3,-3,-3,-3,-3), \
 +      writeVOLControlMasterN(0), \
 +      writeVOLOffsetMasterN(0x7fff), \
 +      writeSYSRecreationModeDirect, \
 +      writeSYSChannelConfigurationRequestSurround4_1, \
 +      execPAIOutAnalog, \
 +      execPAIInHDMIStereo
 +#else 
- //Not DTS
++//Not DTS_ATBOOT_CFG
++
  #ifndef DDP_ATBOOT_CFG
  //
  // NOT DDP at-boot configuration
      execPAIInHDMIStereo
      
  #endif // DDP_ATBOOT_CFG
- #endif //#ifdef DTS
++#endif // NOT DTS_ATBOOT_CFG
  
  #pragma DATA_SECTION(cus_atboot_s0_patch, ".none")
  const ACP_Unit cus_atboot_s0_patch[] = {
index 1ce33336f2af85e6c3791e9063f4f896e772d258,f2331ae9240009e7683777ffe1bd3f93bfeeae0c..fce627ba953a92be28281ee0aa156239831f0c50
@@@ -780,56 -864,27 +864,35 @@@ Int cbReadAf
          pAfRd->sampleDecode = pAfCb->sampleDecode;
          PAF_PROCESS_COPY(pAfRd->sampleProcess, pAfCb->sampleProcess);
          pAfRd->sampleRate = pAfCb->sampleRate;
-         pAfRd->sampleCount = pCb->strFrameLen;
          pAfRd->channelConfigurationRequest = pAfCb->channelConfigurationRequest;
          pAfRd->channelConfigurationStream = pAfCb->channelConfigurationStream;
-         
-         // read metadata information updated by decoder
-         pAfRd->bsMetadata_type     = pAfCb->bsMetadata_type;        /* non zero if metadata is attached. */
+         // Read CB AF bit-stream metadata information updated by decoder
+         pAfRd->bsMetadata_type     = pAfCb->bsMetadata_type;        /* non zero if private metadata is attached. */
          pAfRd->pafBsMetadataUpdate = pAfCb->pafBsMetadataUpdate;    /* indicates whether bit-stream metadata update */
-         pAfRd->numPrivateMetadata  = pAfCb->numPrivateMetadata;     /* number of valid private metadata (0 or 1 if metadata filtering enabled) */
          pAfRd->bsMetadata_offset   = pAfCb->bsMetadata_offset;      /* offset into audio frame for change in bsMetadata_type field */
          
 +#ifdef DTS_BUILD
 +        pAfRd->mode = pAfCb->mode;                                       /* mode is used in DTSX to pass info to PARMA */
 +        pAfRd->numChansUsedForMetadata = pAfCb->numChansUsedForMetadata; /* if metadata is used in DTSX */
 +        pAfRd->pafBsFixedData = pAfCb->pafBsFixedData;                   /* if true, do not convert float to fixed in DTSX metadata transfer */
 +        pAfRd->root = pAfCb->root;                                       /* used for channel MASK in DTSX. BAD IDEA, need fix */
 +#endif                
+         // Compute stream mask for current CB AF.
+         // Mask indicates which channels are present in AF.
+         // Mask needed for cache invalidate and read of PCM samples in AF.
+         streamMask = pAfRd->fxns->channelMask(pAfRd, pAfCb->channelConfigurationStream);
  
-         #ifdef CB_RW_OP_CAP_PP // debug
-         if (pCb->cb_opCnt < CB_OP_COUNT_MAX)
-         {
-             if ((pCb->cb_samples_op != NULL) && (pCb->cb_op_owner != NULL))
-             {
-                 // log sample count
-                 pCb->cb_samples_op[pCb->cb_opCnt] = pAfRd->sampleCount;
-                 pCb->cb_op_owner[pCb->cb_opCnt] = CB_OP_R;
-                 // log idxs
-                 pCb->cb_afRdIdx[pCb->cb_opCnt] = pCb->afRdIdx;
-                 pCb->cb_afWrtIdx[pCb->cb_opCnt] = pCb->afWrtIdx;
-                 pCb->cb_numAfCb[pCb->cb_opCnt] = pCb->numAfCb; // numAfCb might not be pointing to this instance
-                 pCb->cb_opCnt++;
-             }
-         }
-         #endif
-         // update Last Cb info as per actual stream
-         pCb->lastAf.sampleCount = pCb->strFrameLen;
-         pCb->lastAf.sampleRate = pAfCb->sampleRate;
-               // read PCM samples
+         // Cache invalidate CB AF samsiz (volume scaling exponent) array
+         Cache_inv(pAfCb->data.samsiz, pCb->maxAFChanNum*sizeof(PAF_AudioSize), Cache_Type_ALLD, 0);
+         Cache_wait();
+         
+         // Read CB AF samsiz array
          for (i = 0; i < pCb->maxAFChanNum; i++)
          {
 +#ifndef DTS_BUILD
              if ((streamMask >> i) & 0x1)
 -            {
 +#endif
 +                      {//DTSX needs up to 16 channels to transfer metadata.
-                 for (j = 0; j < pCb->strFrameLen; j++)
-                 {
-                     pAfRd->data.sample[i][j] = pAfCb->data.sample[i][pCb->pcmRdIdx+j];
-                 }
                  pAfRd->data.samsiz[i] = pAfCb->data.samsiz[i];
              }
          }
              pAfRd->pafPrivateMetadata[i].size   = 0;
          }
          
-         // read metadata
-         for (i = 0; i < pAfCb->numPrivateMetadata; i++) // only read numPrivateMetadata
+         totNumSampsRd = 0;  // init total number of samples read from CB
+         pcmWrtIdx = 0;      // init Read AF PCM write index
+         prvMdWrtIdx = 0;    // init Read AF metadata write index
+         while ((totNumSampsRd < pCb->strFrameLen) && (pCb->numAfCb > 0))
          {
-             if ((pAfCb->pafPrivateMetadata[i].offset >= pCb->pcmRdIdx) 
-                  &&(pAfCb->pafPrivateMetadata[i].offset < (pCb->pcmRdIdx + pCb->strFrameLen))
-                  &&(pAfCb->pafPrivateMetadata[i].size))
+             // Compute how many PCM samples can be read from CB AF
+             //  Number of samples left in current CB AF: pAfCb->sampleCount - pCb->pcmRdIdx
+             //  Number of samples left to write to Read AF: pCb->strFrameLen - totNumSampsRd
+             numSampsRd = (pAfCb->sampleCount - pCb->pcmRdIdx) < (pCb->strFrameLen - totNumSampsRd) ? 
+                 (pAfCb->sampleCount - pCb->pcmRdIdx) : (pCb->strFrameLen - totNumSampsRd);
+             // Cache invalidate CB AF PCM sample channel pointers
+             Cache_inv(pAfCb->data.sample, pCb->maxAFChanNum*sizeof(PAF_AudioData *), Cache_Type_ALLD, 0);
+             Cache_wait();
+             // Cache invalidate CB AF PCM samples
+             for (i = 0; i < pCb->maxAFChanNum; i++)
              {
-                 // the offset is adjusted for segment [pCb->pcmRdIdx, (pCb->pcmRdIdx + pCb->pafFrameLen)]
-                 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
 -                if ((streamMask >> i) & 0x1)
 -                {
++#ifndef DTS_BUILD
++                              if ((streamMask >> i) & 0x1)
++#endif
++                              {//DTSX needs up to 16 channels to transfer metadata.
+                     Cache_inv(&pAfCb->data.sample[i][pCb->pcmRdIdx], numSampsRd*sizeof(PAF_AudioData), Cache_Type_ALLD, 0);
+                 }
              }
-             else //reset un-used buf
+             Cache_wait();
+             // Read PCM samples from CB AF
+             for (i = 0; i < pCb->maxAFChanNum; i++)
              {
-                 pAfRd->pafPrivateMetadata[i].offset = 0;
-                 pAfRd->pafPrivateMetadata[i].size   = 0;
 -                if ((streamMask >> i) & 0x1)
 -                {
++#ifndef DTS_BUILD
++                              if ((streamMask >> i) & 0x1)
++#endif
++                              {//DTSX needs up to 16 channels to transfer metadata.
+                     for (j = 0; j < numSampsRd; j++)
+                     {
+                         pAfRd->data.sample[i][pcmWrtIdx+j] = pAfCb->data.sample[i][pCb->pcmRdIdx+j];
+                     }
+                 }
              }
  
+             // Cache invalidate CB AF unused metadata
+             for (i = pCb->prvMdRdIdx; i < pAfCb->numPrivateMetadata; i++)
+             {
+                 Cache_inv(pAfCb->pafPrivateMetadata[i].pMdBuf, pAfCb->pafPrivateMetadata[i].size, Cache_Type_ALLD, 0); // only update metadata package size
+             }
+             Cache_wait();
+             // Read CB AF metadata
+             while (((pCb->prvMdRdIdx < pAfCb->numPrivateMetadata) && 
+                 (pAfCb->pafPrivateMetadata[pCb->prvMdRdIdx].offset >= pCb->pcmRdIdx) &&
+                 (pAfCb->pafPrivateMetadata[pCb->prvMdRdIdx].offset < (pCb->pcmRdIdx + numSampsRd)) &&
+                 (pAfCb->pafPrivateMetadata[pCb->prvMdRdIdx].size)) &&
+                 (prvMdWrtIdx < PAF_MAX_NUM_PRIVATE_MD))
+             {
+                 // Write Read AF metadata offset.
+                 //  Compute relative offset of PCM samples being read from CB AF.
+                 //  Compute absolute offset of PCM samples written to Read AF by 
+                 //  adding relative offset to Read AF PCM write index.
+                 pAfRd->pafPrivateMetadata[prvMdWrtIdx].offset = 
+                     (pAfCb->pafPrivateMetadata[pCb->prvMdRdIdx].offset - pCb->pcmRdIdx) +   // offset relative to samples being read from CB AF
+                     pcmWrtIdx;                                                              // absolute offset into samples being written to read AF
+                 // Write Read AF metadata size    
+                 pAfRd->pafPrivateMetadata[prvMdWrtIdx].size = pAfCb->pafPrivateMetadata[pCb->prvMdRdIdx].size;
+                 // Write Read AF metadata payload
+                 memcpy(pAfRd->pafPrivateMetadata[prvMdWrtIdx].pMdBuf, pAfCb->pafPrivateMetadata[pCb->prvMdRdIdx].pMdBuf, pAfCb->pafPrivateMetadata[pCb->prvMdRdIdx].size);
+                 
+                 pCb->prvMdRdIdx++;  // update CB metadata read index
+                 prvMdWrtIdx++;      // update CB metadata write index
+             }
+             
+             // Update CB control
+             pCb->pcmRdIdx += numSampsRd; // update PCM read index
+             if (pCb->pcmRdIdx >= pAfCb->sampleCount) 
+             {
+                 // Finished reading PCM samples from current CB AF.
+                 // Move to next AF in CB.
+                 
+                 // Update audio frame read index.
+                 // Wrap index if required.
+                 pCb->afRdIdx++;
+                 if (pCb->afRdIdx >= pCb->maxNumAfCb)
+                 {
+                     pCb->afRdIdx = 0;
+                 }
+                 
+                 // Reset PCM read index
+                 pCb->pcmRdIdx = 0;
+                 // Reset metadata read index
+                 pCb->prvMdRdIdx = 0;
+                 
+                 // Update number of audio frames in circular buffer
+                 pCb->numAfCb--;
+             }
+             
+             // Update PCM write index
+             pcmWrtIdx += numSampsRd;
+             // Update total number of samples read
+             totNumSampsRd += numSampsRd;
+             
+             if (totNumSampsRd < pCb->strFrameLen)
+             {
+                 //
+                 // Need to read another AF from CB to obtain all PCM/metadata for Read AF
+                 //
+                 
+                 // Get pointer to current CB Audio Frame
+                 pAfCb = &pCb->afCb[pCb->afRdIdx];
+                 
+                 // Cache invalidate CB AF
+                 Cache_inv(pAfCb, sizeof(PAF_AudioFrame), Cache_Type_ALLD, 0);
+                 Cache_wait();
+             }
          }
-         pAfRd->numPrivateMetadata = numMetadata; //number of metadata associated with current 256 segment of audio samples
+        
+         pAfRd->sampleCount = totNumSampsRd;         // write Read AF sample count
+         pAfRd->numPrivateMetadata = prvMdWrtIdx;    // write Read AF number of metadata
          
-         pCb->pcmRdIdx += pCb->strFrameLen; // update PCM read index
-         if (pCb->pcmRdIdx >= pAfCb->sampleCount) 
+         pCb->numPcmSampsPerCh -= totNumSampsRd;     // update PCM samples per channel
+        
+         if (totNumSampsRd < pCb->strFrameLen)
          {
-             // update audio frame read index
-             pCb->afRdIdx++;
-             if (pCb->afRdIdx >= pCb->maxNumAfCb)
+             // Clear remaining Read AF PCM samples
+             for (i = 0; i < pCb->maxAFChanNum; i++)
              {
-                 pCb->afRdIdx = 0;
 -                if ((streamMask >> i) & 0x1)
 -                {
++#ifndef DTS_BUILD
++                              if ((streamMask >> i) & 0x1)
++#endif
++                              {//DTSX needs up to 16 channels to transfer metadata.
+                     memset(&pAfRd->data.sample[i][pcmWrtIdx], 0, (pCb->strFrameLen-totNumSampsRd));
+                 }
              }
              
-             // update PCM read index
-             pCb->pcmRdIdx = 0;
+             if (pCb->writerActiveFlag == 1)
+             {
+                 //
+                 // UNDerflow, 
+                 // read stopped due to insufficient PCM samples in CB to fill Read AF
+                 //
              
-             // update number of audio frames in circular buffer
-             pCb->numAfCb--;
+                 // 
+                 // Increment underflow count
+                 //
+                 pCb->errPcmUndCnt++;
+                 // Mute output on underflow
+                 cbReadMuteWithLastAfInfo(pCb, pAfRd);
+                 
+ #if 0 // (***) FL: shows timing of CB underflow
+                 // debug
+                 {
+                     static Uint8 toggleState = 0;
+                     if (toggleState == 0)
+                         GPIOSetOutput(GPIO_PORT_0, GPIO_PIN_107);
+                     else
+                         GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_107);
+                     toggleState = ~(toggleState);
+                 }
+ #endif
+                 #ifdef CB_RW_OP_CAP_PP // debug
+                 if (pCb->cb_opCnt < CB_OP_COUNT_MAX)
+                 {
+                     if ((pCb->cb_samples_op != NULL) && (pCb->cb_op_owner != NULL))
+                     {
+                         // log sample count
+                         pCb->cb_samples_op[pCb->cb_opCnt] = 0;  // due to underflow
+                         pCb->cb_op_owner[pCb->cb_opCnt] = CB_OP_R;
+                         // log idxs
+                         pCb->cb_afRdIdx[pCb->cb_opCnt] = pCb->afRdIdx;
+                         pCb->cb_afWrtIdx[pCb->cb_opCnt] = pCb->afWrtIdx;
+                         pCb->cb_numAfCb[pCb->cb_opCnt] = pCb->numAfCb; // numAfCb might not be pointing to this instance
+                         pCb->cb_opCnt++;
+                     }
+                 }
+                 #endif
+                 // Write back circular buffer configuration.
+                 Cache_wb(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
+                 Cache_wait();    
+                 
+                 // Leave the gate
+                 GateMP_leave(gateHandle, key);
+                 
+                 return ASP_DECOP_CB_PCM_READ_UNDERFLOW;
+             }
          }
-         memcpy (&pCb->lastAf, pAfRd, sizeof(PAF_AudioFrame));
+         
+         // Read AF complete, update Last CB AF Info
+         cbUpdateLastAfInfo(pCb, pAfRd);
  
+ #if 0 // (***) FL: shows timing of successful CB read
          {
              static Uint8 toggleState = 0;
              if (toggleState == 0)
@@@ -939,8 -1175,8 +1189,10 @@@ static Void cbReadAfMute
      // Clear PCM data
      for (i = 0; i < ASP_DECOP_CB_MAX_NUM_PCM_CH; i++)
      {
++#ifndef DTS_BUILD
          if ((streamMask >> i) & 0x1)
--        {
++#endif
++              {//DTSX needs up to 16 channels to transfer metadata.
              memset(pAfRd->data.sample[i], 0, strFrameLen*sizeof(PAF_AudioData));
          }
          pAfRd->data.samsiz[i] = 0;
@@@ -1008,8 -1256,8 +1272,10 @@@ static Void cbReadMuteWithLastAfInfo
      // Clear PCM data
      for (i = 0; i < ASP_DECOP_CB_MAX_NUM_PCM_CH; i++)
      {
++#ifndef DTS_BUILD
          if ((streamMask >> i) & 0x1)
--        {
++#endif
++              {//DTSX needs up to 16 channels to transfer metadata.
              memset(pAfRd->data.sample[i], 0, pAfRd->sampleCount*sizeof(PAF_AudioData));
          }
          pAfRd->data.samsiz[i] = 0;
      pAfRd->pafBsMetadataUpdate = 0;                             /* indicates whether bit-stream metadata update */
      pAfRd->numPrivateMetadata  = 0;                             /* number of valid private metadata (0 or 1 if metadata filtering enabled) */
      pAfRd->bsMetadata_offset   = 0;                             /* offset into audio frame for change in bsMetadata_type field */
 +#ifdef DTS_BUILD
 +      pAfRd->mode = 0;                                            /* mode used by PARMA */
 +      pAfRd->numChansUsedForMetadata = 15;                        /* constant of 15 */
 +      pAfRd->pafBsFixedData = TRUE;                               /* if true, do not convert float to fixed in DTSX metadata transfer */
 +      pAfRd->root = 0x1BF;                                        /* used for channel MASK in DTSX. 0x1BF = 7.1 as defined in dtshd_dec_api_common.h */
 +#endif                
  }
  
+ // Check circular buffer drain state
+ Int cbCheckDrainState(
+     PAF_AST_DecOpCircBufCtl *pCbCtl,    // decoder output circular buffer control
+     Int8 cbIdx,                         // decoder output circular buffer index, or indicator combined drain state desired
+     Int8 *pDrainedFlag                  // output drain state indicator (combined or for selected circular buffer)
+ )
+ {
+     IArg key;
+     GateMP_Handle gateHandle;
+     PAF_AST_DecOpCircBuf *pCb;
+     Int8 drainedFlag;
+     Int8 i;
+     
+     // Get gate handle
+     gateHandle = pCbCtl->gateHandle;
+     // Enter gate
+     key = GateMP_enter(gateHandle);
+     if (cbIdx != ASP_DECOP_CHECK_DRAINSTATE_ALL)
+     {
+         //
+         // Check drain state for selected circular buffer
+         //
+         
+         // Get circular buffer base pointer
+         pCb = &((*pCbCtl->pXDecOpCb)[cbIdx]);
+         // Invalidate circular buffer configuration
+         Cache_inv(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
+         Cache_wait();
+         drainedFlag = !pCb->writerActiveFlag && !pCb->drainFlag;
+     }
+     else
+     {
+         //
+         // Check combined drain state for all circular buffers.
+         // Combined drain state is logical AND of drain state for all circular buffers.
+         //
+         drainedFlag = 1; // init combined drained flag to TRUE
+         for (i = 0; i < pCbCtl->numDecOpCb; i++)
+         {
+             // Get circular buffer base pointer
+             pCb = &((*pCbCtl->pXDecOpCb)[i]);
+             // Invalidate circular buffer configuration
+             Cache_inv(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
+             Cache_wait();
+             
+             // Update combined drain state
+             drainedFlag = drainedFlag && (!pCb->writerActiveFlag && !pCb->drainFlag);
+         }
+     }
+     
+     *pDrainedFlag = drainedFlag;
+     
+     // Leave the gate
+     GateMP_leave(gateHandle, key);
+     return ASP_DECOP_CB_SOK;
+ }
index 8b131e6574b3b2301128c5e3c5be21f2e8b8cc53,6d8580367872d10150cba449685e7af1bc0d776a..112d17715faf224cb260d766c30d0049f4cbe372
@@@ -305,6 -306,25 +306,27 @@@ extern UInt32 gAspProfileEnable
  
  #define __TASK_NAME__  "TaskAsip"
  
 -#define ASIP_FRAMELEN_SS_THD        ( 1536 )        //QIN FIX ME
+ //
+ // Audio Stream Input 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 )        
++
++#define ASIP_FRAMELEN_SS_DTS        ( 512 )         
+ // 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 */
  
@@@ -565,10 -582,28 +586,33 @@@ Void taskAsipFxn
      Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD2]), sizeof(Int), Cache_Type_ALLD, 0);
      size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD2]->size;
      Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_THD2]), size, Cache_Type_ALLD, 0);
 +    size = IACP_STD_BETA_TABLE.pStatus[STD_BETA_DTSUHDA]->size;
 +    Cache_inv((Ptr)(IACP_STD_BETA_TABLE.pStatus[STD_BETA_DTSUHDA]), size, Cache_Type_ALLD, 0);
      Cache_wait();
      
 -
+ #ifdef NON_CACHE_STATUS
+     // Get the shared status structure GateMP handles. Initialized at slave.
+     if (statusOp_Init(GATEMP_INDEX_DEC) == STATUSOP_INIT_FAIL)
+     {
+         Log_info1("TaskAfp: Gate Index %d:Open status GateMP Fail.", GATEMP_INDEX_DEC);
+     }
+     if (statusOp_Init(GATEMP_INDEX_DDP) == STATUSOP_INIT_FAIL)
+     {
+         Log_info1("TaskAfp: Gate Index %d:Open status GateMP Fail.", GATEMP_INDEX_DDP);
+     }
+     if (statusOp_Init(GATEMP_INDEX_PCM) == STATUSOP_INIT_FAIL)
+     {
+         Log_info1("TaskAfp: Gate Index %d:Open status GateMP Fail.", GATEMP_INDEX_PCM);
+     }
+     if (statusOp_Init(GATEMP_INDEX_THD) == STATUSOP_INIT_FAIL)
+     {
+         Log_info1("TaskAfp: Gate Index %d:Open status GateMP Fail.", GATEMP_INDEX_THD);
+     }
++    if (statusOp_Init(GATEMP_INDEX_DTS) == STATUSOP_INIT_FAIL)
++    {
++        Log_info1("TaskAfp: Gate Index %d:Open status GateMP Fail.", GATEMP_INDEX_DTS);
++    }
+ #endif
      // (***) FL: revisit
      // invalidate Dec configuration
      Cache_inv(&gPAF_AST_config.xDec[0], DECODEN*sizeof(PAF_AST_Decode), Cache_Type_ALLD, 0);
@@@ -4064,3 -3560,31 +3569,40 @@@ void as_traceChannels(PAF_AST_Config *p
      }
  }
  #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;
++        case PAF_SOURCE_DTS:
++        case PAF_SOURCE_DTSHD:
++        case PAF_SOURCE_DTS12:
++        case PAF_SOURCE_DTS13:
++        case PAF_SOURCE_DTS14:
++        case PAF_SOURCE_DTS16:
++        case PAF_SOURCE_DTSALL:
++            frameLength = ASIP_FRAMELEN_SS_DTS;
++            break;
+         default:
+             frameLength = ASIP_FRAMELEN_SS_DEFAULT;
+             break;
+     }
+     
+     return frameLength;
+ }
index 586332988ee3b8d9f38029adf1fd1478413f6988,378c125826753f6a3ed0ebf8a21ad1135d2d68ef..d85ae6b5e7584a8c0fe70faa930ef81c264be3fc
@@@ -1,4 -1,4 +1,4 @@@
- PDK_INSTALL_PATH        = C:/ti/processor_audio_sdk_1_00_00_04/psdk_cust/pdk_k2g_1_0_1_2_eng/packages
 -PDK_INSTALL_PATH        = C:/ti/processor_audio_sdk_1_00_00_05/psdk_cust/pdk_k2g_1_0_1_2_eng/packages
++PDK_INSTALL_PATH        = C:/ti/pdk_k2g_1_0_6/packages
  CSL_INSTALL_PATH        = C:/ti/
  BOARD_INSTALL_PATH      = C:/ti/
  SBL_BOOT_INSTALL_PATH   = C:/ti/
@@@ -30,4 -30,4 +30,4 @@@ DFE_INSTALL_PATH        = C:/ti
  IQN_INSTALL_PATH        = C:/ti/
  IQN2_INSTALL_PATH       = C:/ti/
  PKTLIB_INSTALL_PATH     = C:/ti/
- PROC_AUDIO_SDK_ROOT     = C:/ti/processor_audio_sdk_1_00_00_04
 -PROC_AUDIO_SDK_ROOT     = C:/ti/processor_audio_sdk_1_00_00_05
++PROC_AUDIO_SDK_ROOT     = C:/ti/processor_audio_sdk_1_00_00_05
diff --cc tools
index 974e256dc9b4ebdc286d893c3a06d3c4393cfa22,18f010815af7c0ddca06bd6fb67e1a67f095736c..e41ca0686c11440074ba3f0a0ca584a6272d4ca7
--- 1/tools
--- 2/tools
+++ b/tools
@@@ -1,1 -1,1 +1,1 @@@
- Subproject commit 974e256dc9b4ebdc286d893c3a06d3c4393cfa22
 -Subproject commit 18f010815af7c0ddca06bd6fb67e1a67f095736c
++Subproject commit e41ca0686c11440074ba3f0a0ca584a6272d4ca7