9302J19200E DTS HD PBR API Library Description
9302J19200E DTS HD PBR API Library Description
9302J19200E DTS HD PBR API Library Description
Description
DTS, Inc.
5220 Las Virgenes Road
Agoura Hills, CA 91302
USA
www.dts.com
Version 1.2
Confidential
This document contains confidential proprietary information owned by DTS, Inc. and/or its affiliates
("DTS"), including but not limited to trade secrets, know-how, technical and business information. Not
for disclosure except under terms of a fully-executed written confidential disclosure agreement by and
between the recipient hereof and DTS. Unauthorized disclosure is a violation of State, Federal, and
International laws.
NOT FOR USE EXCEPT UNDER TERMS OF A FULLY-EXECUTED WRITTEN LICENSE
AGREEMENT BY AND BETWEEN THE RECIPIENT HEREOF AND DTS.
THE TECHNOLOGY AND/OR WORKS ASSOCIATED WITH THIS DOCUMENT ARE (1)
CONFIDENTIAL, PROPRIETARY TRADE SECRETS; AND/OR (2) PROTECTED BY (A)
APPLICABLE COPYRIGHT LAW AND/OR (B) EUROPEAN PATENT NUMBERS:_ 0864146,
1741093 AND 1743326, AND U.S. PATENT NUMBERS_5,956,674, 5,974,380, 5,978,762,_6,487,535,
6,226,616, 7,212,872, 7,003,467, 7,272,567, 7,668,723, 7,392,195, 7,930,184, 7,333,929, 7,548,853
AND OTHER U.S. AND INTERNATIONAL PATENTS BOTH PENDING AND ISSUED.
No Warranty
THE FOLLOWING TERMS SHALL APPLY TO ANY USE OF ANY HARDWARE, SOFTWARE
AND METHODS ASSOCIATED WITH THIS DOCUMENT (THE PRODUCT) AND, AS
APPLICABLE, ANY RELATED DOCUMENTATION: (I) ANY USE OF THE PRODUCT AND ANY
RELATED DOCUMENTATION IS AT THE RECIPIENTS SOLE RISK; (II) THE PRODUCT AND
ANY RELATED DOCUMENTATION ARE PROVIDED AS IS AND WITHOUT WARRANTY OF
ANY KIND AND DTS EXPRESSLY DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR
FITNESS FOR A PARTICULAR PURPOSE, REGARDLESS OF WHETHER DTS KNOWS OR HAS
REASON TO KNOW OF THE USERS PARTICULAR NEEDS; (III) DTS DOES NOT WARRANT
THAT THE PRODUCT OR ANY RELATED DOCUMENTATION WILL MEET USERS
REQUIREMENTS, OR THAT DEFECTS IN THE PRODUCT OR ANY RELATED
DOCUMENTATION WILL BE CORRECTED; (IV) DTS DOES NOT WARRANT THAT THE
OPERATION OF ANY HARDWARE OR SOFTWARE ASSOCIATED WITH THIS DOCUMENT
WILL BE UNINTERRUPTED OR ERROR-FREE; AND (V) UNDER NO CIRCUMSTANCES,
INCLUDING BUT NOT LIMITED TO NEGLIGENCE, SHALL DTS OR THE DIRECTORS,
OFFICERS, EMPLOYEES, OR AGENTS OF DTS, BE LIABLE TO USER FOR ANY INCIDENTAL,
INDIRECT, SPECIAL, OR CONSEQUENTIAL DAMAGES (INCLUDING BUT NOT LIMITED TO
DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, AND LOSS OF
BUSINESS INFORMATION) ARISING OUT OF THE USE, MISUSE, OR INABILITY TO USE THE
PRODUCT OR ANY RELATED DOCUMENTATION.
Page ii of 33
Version 1.2
Copyright
DTS-HD PBR API Library Description
Do Not Duplicate. 2012 DTS, Inc. All Rights Reserved. Unauthorized duplication is a violation of
State, Federal, and International laws.
This publication and the Product are copyrighted and all rights are reserved by DTS, Inc. Without the
express prior written permission of DTS no part of this publication may be reproduced, photocopied,
stored on a retrieval system, translated, or transmitted in any form or by any means, electronic or
otherwise.
Due to ongoing improvements and revisions, DTS cannot guarantee the accuracy of printed material after
date of publication nor can it accept responsibility for any errors or omissions. DTS may publish updates
and revisions to this publication, however DTS has no obligation to notify you of any such update or
revision and nothing herein shall be construed as creating any obligation for DTS to do so, and DTS has
no obligation to update or revise this publication and nothing herein shall be construed as creating any
such obligation.
Conformity with any standards contained herein shall not constitute DTS certification. No product is
certified until it has passed DTS testing and DTS has issued a certification statement. Please note,
products containing unreleased, beta or outdated software versions may not be certified by DTS.
The content of this publication supersedes the content of any materials previously provided by DTS
pertaining to the subject matter of this publication.
DTS, the Symbol, DTS and the Symbol together and DTS-HD are registered trademarks of DTS, Inc.
Page iii of 33
Version 1.2
Table of Contents
1 INTRODUCTION 1
1.1 Overview 1
2 INITIALIZATION 2
2.1 Library Instantiation 2
2.2 Library Initialization 2
2.3 Loading of bit stream 2
2.3.1 Loading of bit-stream using PBR database data3
4 APPENDIX 16
4.1 API Headers 16
4.2 API Functions 16
4.2.1 DTSPBR_Allocate_Hdl 16
4.2.2 DTSPBR_Deallocate_Hdl16
4.2.3 DTSPBR_Init 16
4.2.4 DTSPBR_Load_EncFile 17
4.2.5 DTSPBR_Load_EncFile using PBR Database image17
4.2.6 DTSPBR_Get_Load_Progress 18
4.2.7 DTSPBR_Init_FrameNavigation 18
CONFIDENTIAL NOT For Distribution Do NOT Copy
24140 v3
Page iv of 33
Version 1.2
4.2.8 DTSPBR_Set_Schedule_Region 18
4.2.9 DTSPBR_Get_Frame_Schedule_SingleSubStream 18
4.2.10 DTSPBR_Get_Frame_Data_SingleSubStream 19
4.2.11 DTSPBR_Get_AccessUnit_Schedule_SingleSubStream 19
4.2.12 DTSPBR_Get_AccessUnit_Data_SingleSubStream 20
4.2.13 DTSPBR_Get_Frame_Schedule_TwoSubStream 20
4.2.14 DTSPBR_Get_Frame_Data_TwoSubStream 21
4.2.15 DTSPBR_Get_Stream_Duration 21
4.2.16 DTSPBR_Get_NumCodecDelayFrame 22
4.2.17 DTSPBR_Get_Schedule_BitRate 22
4.2.18 DTSPBR_Get_PBR_DBase_Size 22
4.2.19 DTSPBR_Get_PBR_DBase_Data 23
4.2.20 DTSPBR_Get_PBR_DBase_Loaded_Flag 23
4.2.21 DTSPBR_Get_Frame_Mpeg2_DTSHD_audio_stream_descriptor23
4.2.22 DTSPBR_Get_Frame_Mpeg2_DTS_audio_stream_descriptor 24
4.2.23 DTSPBR_Get_Frame_Mpeg4_DTSSampleEntryData24
4.3 CDTSDecRawFrameBuffer 24
4.4 CDTSMpeg2DTS_audio_stream_descriptor 26
4.5 CDTSMpeg2DTSHD_audio_stream_descriptor 27
4.6 CDTSSampleEntry 28
Page v of 33
Version 1.2
1 INTRODUCTION
1.1 Overview
This document describes the DTS PBR (Peak Bit-rate) and Bit-stream Parser API which provides a set of
"C++" Application Programming Interface functions to the DTS PBR and Parser Library so that it can be
linked in and called by a host application. The primary objective of this library is to provide disc
authoring applications with the ability to perform PBR smoothing on non-PBR smoothed DTS-HD
Master Audio encoded files and frame parsing. This functionality is achieved by providing API
functions for traversing the entire encoded file and extracting each frame of the bit-stream. The frame
bit-stream returned from the frame retrieval is PBR smoothed for DTS-HD Master Audio bit-streams
only. For all other bit-stream types, the actual encoded raw frame from the bit-stream is returned. For
applications requesting just a section of the bit-stream, there exists API functions to define the region of
extraction (and therefore, the region of PBR smoothing). To extend the functionality of this library, the
API frame extraction functions will also allow extraction of CBR encoded bit-stream frames.
This API provides the following functionality:
Functions to extract out individual encoded frames from DTS-HD (.dtshd) files or legacy DTS
CD/DVD (.cpt) files.
Functions to extract the frame payload/schedule (payload and PTS) from DTS-HD (.dtshd) files
or legacy DTS CD/DVD (.cpt) files.
Simultaneous PBR smoothing and frame parsing of non-PBR smoothed DTS-HD Master Audio
encoded (VBR encoded) .dtshd files
Frame parsing of previously PBR scheduled DTS-HD master audio encoded files.
Ability to designate region (start frame/end frame) for frame extraction (and PBR scheduling).
Ability to navigation to specific frame location to commence bit-stream extraction
Functions to extract Mp2TS and Mp4 DTS audio descriptors for each frame.
Page 1 of 33
Version 1.2
2 Initialization
The library initialization consists of the following steps:
Instantiation
Initialization
Page 2 of 33
Version 1.2
if ( ! DTSPBR_Load_EncFile(pDtsHDPBRHdl) )
{
DTSPBR_Deallocate_Hdl(pDtsHDPBRHdl);
return false;
}
For multi-threaded GUI applications where load progress is being reported, one thread can be assigned to
performing the call DTSPBR_Load_EncFile function while another thread calls the
DTSPBR_Get_Load_Progress() API function to check on the file loading percentage complete.
Page 3 of 33
Version 1.2
Page 4 of 33
Version 1.2
Upon retrieving the frame payload/schedule data, API functions are provided to retrieve Mp2TS and
Mp4 audio descriptors. The API functions
DTSPBR_Get_Frame_Mpeg2_DTS_audio_stream_descriptor and
DTSPBR_Get_Frame_Mpeg2_DTSHD_audio_stream_descriptor are provided for retrieving DTS audio
frame Mp2TS audio descriptors for both DTS and DTS-HD. Similarily, API function
DTSPBR_Get_Frame_Mpeg4_DTSSampleEntryData returns the frame Mp4 audio descriptor.
Page 5 of 33
Version 1.2
3.2.2 Example code for retrieving both the encoded data and schedule/payload data for each
frame of the encoded bit-stream (separate core and extension sub-stream method).
// Set library state to start from beginning of bit-stream
if ( ! DTSPBR_Init_FrameNavigation(pDtsHDPBRHdl) )
return false;
n = 0;
while (DTSPBR_Get_Frame_Data_TwoSubStream(pDtsHDPBRHdl, &coreData,
nuCoreBytes, &extData, nuExtBytes, nuPTS, nuDTS) )
{
if ( nuCoreBytes > 0 )
{
if ( fwrite(coreData.m_pucEncodedRawFrame,
sizeof(char),nuCoreBytes,pFile) != nuCoreBytes )
{
fprintf(stderr, Error writing %s.\n, sFileName);
fclose(pFile);
return false;
}
}
if ( nuExtBytes > 0 )
{
if ( fwrite(extData.m_pucEncodedRawFrame,
sizeof(char),nuExtBytes,pFile) != nuExtBytes )
{
fprintf(stderr, Error writing %s.\n, sFileName);
fclose(pFile);
return false;
}
}
#ifdef ENABLE_MPEG_DESCRIPTOR
// retrieve Mp2TS audio descriptor for current frame
if ( bEnableMp2TS && pFileMP2 != NULL)
{
CDTSMpeg2DTSHD_audio_stream_descriptor DTSHDdescriptor;
CDTSMpeg2DTS_audio_stream_descriptor DTSdescriptor;
if
( DTSPBR_Get_Frame_Mpeg2_DTSHD_audio_stream_descriptor(pDtsHDPBRHdl,
&DTSHDdescriptor) )
{
fprintf(pFileMP2, "Frame #%d\n", n);
Dump_Mpeg2_DTSHD_audio_stream_descriptor(pFileMP2,
&DTSHDdescriptor);
}
if
( DTSPBR_Get_Frame_Mpeg2_DTS_audio_stream_descriptor(pDtsHDPBRHdl, &DTSdescriptor) )
{
fprintf(pFileMP2, "Frame #%d\n", n);
CONFIDENTIAL NOT For Distribution Do NOT Copy
24140 v3
Page 6 of 33
Version 1.2
Dump_Mpeg2_DTS_audio_stream_descriptor(pFileMP2,
&DTSdescriptor);
}
}
// retrieve Mp2TS audio descriptor for current frame
if (bEnableMp && pFileMP4 != NULL )
{
CDTSSampleEntry
DTSSampleEntry;
if
( DTSPBR_Get_Frame_Mpeg4_DTSSampleEntryData(pDtsHDPBRHdl, &DTSSampleEntry) )
{
fprintf(pFileMP4, "Frame #%d\n", n);
Dump_Mpeg4_DTSSampleEntry(pFileMP4,
&DTSSampleEntry);
}
}
#endif // #ifdef ENABLE_MPEG _DESCRIPTOR
n++;
fprintf(stderr, Updating frame #:%d\r, n);
}
NOTE: Example extracts all frames from file including any codec delay frames.
3.3 Frame retrieval for single sub-stream (combined core and extension)
3.3.1 Example code for retrieving only schedule/payload data for each frame of the encoded bitstream (combined sub-stream method)
fprintf(pFile,PTS);
fprintf(pFile,\tDTS);
fprintf(pFile,\tFrmBytes\n);
// Set library state to start from beginning of bit-stream
if ( ! DTSPBR_Init_FrameNavigation(pDtsHDPBRHdl) )
return false;
while (DTSPBR_Get_Frame_Schedule_SingleSubStream(pDtsHDPBRHdl, nuPTS,
nuDTS, nuFrmBytes) )
{
#ifdef _WIN32
if ( nuPTS == 0 )
fprintf(pFile, 0\t0\t%d\n, nuFrmBytes);
else
fprintf(pFile, %.I64u\t0\t%d\n, nuPTS, nuFrmBytes);
#else
fprintf(pFile, %llu\t%llu\t%d\n,nuPTS, nuDTS, nuFrmBytes);
#endif
}
NOTE: Example extracts all frames from file including any codec delay frames
Page 7 of 33
Version 1.2
3.3.2 Example code for retrieving both the encoded data and schedule/payload data for each
frame of the encoded bit-stream (combined sub-stream method).
// Set library state to start from beginning of bit-stream
if ( ! DTSPBR_Init_FrameNavigation(pDtsHDPBRHdl) )
return false;
n = 0;
while (DTSPBR_Get_Frame_Data_SingleSubStream(pDtsHDPBRHdl, & nuFrmDatas,
nuFrmBytes, nuPTS, nuDTS) )
{
if ( fwrite(nuFrmData.m_pucEncodedRawFrame, sizeof(char),
nuFrmBytes,pFile) != nuFrmBytes)
{
fprintf(stderr, Error writing %s.\n, sFileName);
fclose(pFile);
return false;
}
n++;
fprintf(stderr, Updating frame #:%d\r, n);
}
NOTE: Example extracts all frames from file including any codec delay frames
Page 8 of 33
Version 1.2
3.4.1 Designating bit-stream section for retrieving frame data into separate core and extension
sub-streams.
3.4.1.1 Example code for retrieving only schedule/payload data for designated region of
the encoded bit-stream (separate core and extension sub-stream method).
// Sets bit-stream region using start and end frame index
if ( ! DTSPBR_Set_Schedule_Region(pDtsHDPBRHdl, nFrameStart, nFrameEnd) )
return false;
fprintf(pFile,PTS);
fprintf(pFile,\tDTS);
fprintf(pFile,\tCoreSubStreamBytes);
fprintf(pFile,\tExtSubStreamBytes\n);
// Set library state to start from beginning of selected region
if ( ! DTSPBR_Init_FrameNavigation(pPBRHdl) )
return false;
while (DTSPBR_Get_Frame_Schedule_TwoSubStream(pDtsHDPBRHdl, nuPTS,
nuDTS, nuCoreBytes, nuExtBytes) )
{
#ifdef _WIN32
if ( nuPTS == 0 )
fprintf(pFile, 0\t0\t%d\t%d\n, nuCoreBytes, nuExtBytes);
else
fprintf(pFile, %.I64u\t0\t%d\t%d\n, nuPTS, nuCoreBytes,
nuExtBytes);
#else
fprintf(pFile, %llu\t%llu\t%d\t%d\n,nuPTS, nuDTS, nuCoreBytes,
nuExtBytes);
#endif
#ifdef ENABLE_MPEG_DESCRIPTOR
// retrieve Mp2TS audio descriptor for current frame
if ( bEnableMp2TS && pFileMP2 != NULL)
{
CDTSMpeg2DTSHD_audio_stream_descriptor DTSHDdescriptor;
CDTSMpeg2DTS_audio_stream_descriptor DTSdescriptor;
if
( DTSPBR_Get_Frame_Mpeg2_DTSHD_audio_stream_descriptor(pDtsHDPBRHdl,
&DTSHDdescriptor) )
{
fprintf(pFileMP2, "Frame #%d\n", n);
Dump_Mpeg2_DTSHD_audio_stream_descriptor(pFileMP2,
&DTSHDdescriptor);
}
if
( DTSPBR_Get_Frame_Mpeg2_DTS_audio_stream_descriptor(pDtsHDPBRHdl, &DTSdescriptor) )
{
Page 9 of 33
Version 1.2
3.4.1.2 Example code for retrieving both the encoded data and schedule/payload data for
designated region of the encoded bit-stream (separate core and extension substream method).
// Sets bit-stream region using start and end frame index
if ( ! DTSPBR_Set_Schedule_Region(pDtsHDPBRHdl, nFrameStart, nFrameEnd) )
return false;
// Set library state to start from beginning of selected region
if ( ! DTSPBR_Init_FrameNavigation(pDtsHDPBRHdl) )
return false;
n = 0;
while (DTSPBR_Get_Frame_Data_TwoSubStream(pDtsHDPBRHdl, &coreData,
nuCoreBytes, &extData, nuExtBytes, nuPTS, nuDTS) )
{
if ( nuCoreBytes > 0 )
{
if ( fwrite(coreData.m_pucEncodedRawFrame,
sizeof(char),nuCoreBytes,pFile) != nuCoreBytes )
{
fprintf(stderr, Error writing %s.\n, sFileName);
fclose(pFile);
CONFIDENTIAL NOT For Distribution Do NOT Copy
24140 v3
Page 10 of 33
Version 1.2
return false;
}
}
if ( nuExtBytes > 0 )
{
if ( fwrite(extData.m_pucEncodedRawFrame,
sizeof(char),nuExtBytes,pFile) != nuExtBytes )
{
fprintf(stderr, Error writing %s.\n, sFileName);
fclose(pFile);
return false;
}
}
#ifdef ENABLE_MPEG_DESCRIPTOR
// retrieve Mp2TS audio descriptor for current frame
if ( bEnableMp2TS && pFileMP2 != NULL)
{
CDTSMpeg2DTSHD_audio_stream_descriptor DTSHDdescriptor;
CDTSMpeg2DTS_audio_stream_descriptor DTSdescriptor;
if
( DTSPBR_Get_Frame_Mpeg2_DTSHD_audio_stream_descriptor(pPBRHdl, &DTSHDdescriptor) )
{
fprintf(pFileMP2, "Frame #%d\n", n);
Dump_Mpeg2_DTSHD_audio_stream_descriptor(pFileMP2,
&DTSHDdescriptor);
}
if
( DTSPBR_Get_Frame_Mpeg2_DTS_audio_stream_descriptor(pPBRHdl, &DTSdescriptor) )
{
fprintf(pFileMP2, "Frame #%d\n", n);
Dump_Mpeg2_DTS_audio_stream_descriptor(pFileMP2,
&DTSdescriptor);
}
}
// retrieve Mp2TS audio descriptor for current frame
if (bEnableMp && pFileMP4 != NULL )
{
Page 11 of 33
Version 1.2
CDTSSampleEntry
DTSSampleEntry;
if ( DTSPBR_Get_Frame_Mpeg4_DTSSampleEntryData(pPBRHdl,
&DTSSampleEntry) )
{
fprintf(pFileMP4, "Frame #%d\n", n);
Dump_Mpeg4_DTSSampleEntry(pFileMP4,
&DTSSampleEntry);
}
}
#endif // #ifdef ENABLE_MPEG _DESCRIPTOR
n++;
fprintf(stderr, Updating frame #:%d\r, n);
}
NOTE: The designation of nFrameStart and nFrameEnd in DTSPBR_Set_Schedule_Region
should account for any codec delay frame(s) in the bit-stream.
3.4.2 Designating bit-stream section for retrieving frame data into single (combined core and
extension) sub-streams.
3.4.2.1 Example code for retrieving only schedule/payload data for designated bit-stream
region (combined sub-stream method).
// Sets bit-stream region using start and end frame index
if ( ! DTSPBR_Set_Schedule_Region(pDtsHDPBRHdl, nFrameStart, nFrameEnd) )
return false;
fprintf(pFile,PTS);
fprintf(pFile,\tDTS);
fprintf(pFile,\tFrmBytes\n);
// Set library state to start from beginning of selected region
if ( ! DTSPBR_Init_FrameNavigation(pDtsHDPBRHdl) )
return false;
while (DTSPBR_Get_Frame_Schedule_SingleSubStream(pDtsHDPBRHdl, nuPTS,
nuDTS, nuFrmBytes) )
{
#ifdef _WIN32
if ( nuPTS == 0 )
fprintf(pFile, 0\t0\t%d\n, nuFrmBytes);
else
fprintf(pFile, %.I64u\t0\t%d\n, nuPTS, nuFrmBytes);
#else
fprintf(pFile, %llu\t%llu\t%d\n,nuPTS, nuDTS, nuFrmBytes);
#endif
}
Page 12 of 33
Version 1.2
3.4.2.2 Example code for retrieving encoded frame data and schedule/payload data for
designated bit-stream region (combined sub-stream method).
// Sets bit-stream region using start and end frame index
if ( ! DTSPBR_Set_Schedule_Region(pDtsHDPBRHdl, nFrameStart, nFrameEnd) )
return false;
// Set library state to start from beginning of selected region
if ( ! DTSPBR_Init_FrameNavigation(pDtsHDPBRHdl) )
return false;
n = 0;
while (DTSPBR_Get_Frame_Data_SingleSubStream(pDtsHDPBRHdl, & nuFrmDatas,
nuFrmBytes, nuPTS, nuDTS) )
{
if ( fwrite(nuFrmData.m_pucEncodedRawFrame, sizeof(char),
nuFrmBytes,pFile) != nuFrmBytes)
{
fprintf(stderr, Error writing %s.\n, sFileName);
fclose(pFile);
return false;
}
#ifdef ENABLE_MPEG_DESCRIPTOR
// retrieve Mp2TS audio descriptor for current frame
if ( bEnableMp2TS && pFileMP2 != NULL)
{
CDTSMpeg2DTSHD_audio_stream_descriptor DTSHDdescriptor;
CDTSMpeg2DTS_audio_stream_descriptor DTSdescriptor;
if
( DTSPBR_Get_Frame_Mpeg2_DTSHD_audio_stream_descriptor(pPBRHdl, &DTSHDdescriptor) )
{
fprintf(pFileMP2, "Frame #%d\n", n);
Dump_Mpeg2_DTSHD_audio_stream_descriptor(pFileMP2,
&DTSHDdescriptor);
}
Page 13 of 33
Version 1.2
if
( DTSPBR_Get_Frame_Mpeg2_DTS_audio_stream_descriptor(pPBRHdl, &DTSdescriptor) )
{
fprintf(pFileMP2, "Frame #%d\n", n);
Dump_Mpeg2_DTS_audio_stream_descriptor(pFileMP2,
&DTSdescriptor);
}
}
// retrieve Mp2TS audio descriptor for current frame
if (bEnableMp && pFileMP4 != NULL )
{
CDTSSampleEntry
DTSSampleEntry;
if ( DTSPBR_Get_Frame_Mpeg4_DTSSampleEntryData(pPBRHdl,
&DTSSampleEntry) )
{
fprintf(pFileMP4, "Frame #%d\n", n);
Dump_Mpeg4_DTSSampleEntry(pFileMP4,
&DTSSampleEntry);
}
}
#endif // #ifdef ENABLE_MPEG _DESCRIPTOR
n++;
fprintf(stderr, Updating frame #:%d\r, n);
}
NOTE: The designation of nFrameStart and nFrameEnd in DTSPBR_Set_Schedule_Region should
account for any codec delay frame(s) in the bit-stream.
Page 14 of 33
Version 1.2
For applications processing a single non-PBR smoothed DTS-HD Master Audio bit-stream over multiple
sessions, it may be beneficial to create and store an image of the PBR database to reduce start up time in
subsequent sessions. Recall in order to perform PBR scheduling on a non-PBR smoothed DTS-HD
Master Audio bit-stream, the library must first initialize the PBR database by parsing frame payload data
from the entire bit-stream during the load step (via a call to the DTSPBR_Load_EncFile API function).
The PBR database is persistent in memory until the library handle is de-allocated. Any new subsequent
application sessions with the same master audio bit-stream will require a complete traversal of the entire
bit-stream upon session initialization. Although the bit-stream load process is not a computational
exhaustive step, it is limited by the I/O speed of the disc. As an estimate, a 2.2GB bit-stream may take 2
minutes to load and parse. An alternative to re-traversing the entire master audio bit-stream for each new
session, an application may elect to create, store, and manage a PBR database image. After initially
loading a non-PBR smoothed DTS-HD Master Audio encoded file for an inaugural session, an
application can command the library to create an image of the PBR database and use this database image
doing the load process of subsequent sessions instead of traversing the entire bit-stream during session
start-up. (As an estimate, a 2.2 Gbytes bit-stream yields a PBR database image of 11 Mbytes.)
Prior to requesting an image of the PBR database, the application should first query the library for the
database image size and allocate a buffer for this size.
if ( ! DTSPBR_Get_PBR_DBase_Size(pDtsHDPBRHdl, nPBRDataSize) ||
nPBRDataSize == 0 )
{
DTSPBR_Deallocate_Hdl(pDtsHDPBRHdl,);
return false;
}
unsigned char *pucPBRBuffer = new unsigned char[nPBRDataSize];
After creating a buffer of the appropriate size, the application can call the
DTSPBR_Get_PBR_DBase_Data API function to fill into the allocated buffer with the PBR database
image.
if ( ! DTSPBR_Get_PBR_DBase_Data(pDtsHDPBRHdl, pucPBRBuffer, nPBRDataSize) )
{
DTSPBR_Deallocate_Hdl(pDtsHDPBRHdl);
return false;
}
The PBR database image is managed by the application and is reloaded using the
DTSPBR_Load_EncFile API function.
Page 15 of 33
Version 1.2
4 Appendix
4.1 API Headers
The following list details the headers which need to be included in applications integrating the the DTS
PBR and Parser library.
DTSPbr.h contains the DTS PBR Parser API function prototypes and must be included in the
DTS PBR Parser application.
DTSVersion.h is optional and is only required for accessing the version of the DTS PBR
scheduling and frame parser library.
The following list details additional headers included in the DTS PBR and Parser library SDK package:
DTSDecFrameBuffer.h (referenced in DTSPbr.h) details the unsigned char buffer class holding
the encoded frame bit-stream.
DTSEncDecDefs.h contains some enumerated types.
DTSMpeg2Descriptor.h (referenced in DTSPbr.h) details the classes for retrieving the Mp2TS
audio descriptors for DTS and DTS-HD.
DTSMpeg4Descriptor.h (referenced in DTSPbr.h) details the classes for retrieving the Mp4
audio descriptors.
Failed to create.
4.2.2 DTSPBR_Deallocate_Hdl
De-allocates instance of DTS PBR Parser library.
void DTSPBR_Deallocate_Hdl(CDTSPBRHdl pDTSPbrHdl);
Parameters
pDTSPbrHdl
Return Values
None
4.2.3 DTSPBR_Init
Initialize the DTS PBR Parser library with name of DTS encoded bit-stream and optional initialization
flags.
CONFIDENTIAL NOT For Distribution Do NOT Copy
24140 v3
Page 16 of 33
Version 1.2
Return Values
true
false
Successful Initialization.
Unable to open file or invalid file designated or invalid handle
enum DTSPBRINIT
{
DTSPBRINIT_NONE
DTSPBRINIT_APAK_2FRM_CODEC_DELAY
DTSPBRINIT_NO_SEAMLESS_SWITCHING ,
DTSPBRINIT_NO_CBR
};
// == 0,
// Add 2 frame codec delay for APAK
// Disables seamless switching
// Disables parsing of CBR files
4.2.4 DTSPBR_Load_EncFile
Load the DTS encoded file designated in DTSPBR_Init.
bool DTSPBR_Load_EncFile(CDTSPBRHdl pDTSPbrHdl);
Parameters
pDTSPbrHdl
Return Values
true
false
Return Values
true
false
Page 17 of 33
Version 1.2
4.2.6 DTSPBR_Get_Load_Progress
Retrieve the percentage complete for loading DTS encoded file in DTSPBR_Load_EncFile().
bool DTSPBR_Get_Load_Progress(CDTSPBRHdl pDTSPbrHdl,
unsigned int &nPercentDone);
Parameters
pDTSPbrHdl
nPercentDone
Return Values
true
false
4.2.7 DTSPBR_Init_FrameNavigation
Sets the state of the library for retrieval of frame data by setting to first frame (either first frame of bitstream or first frame in designated bit-stream region).
bool DTSPBR_Init_FrameNavigation(CDTSPBRHdl pDTSPbrHdl);
Parameters
pDTSPbrHdl
Return Values
true
false
4.2.8 DTSPBR_Set_Schedule_Region
Selects bit-stream region or section for library to extract frames.
bool DTSPBR_Set_Schedule_Region(CDTSPBRHdl pDTSPbrHdl, int nFrmStartIndex, int
nFrmEndIndex);
Parameters
pDTSPbrHdl
Library instance handle created from DTSPBR_Allocate_Hdl
nFrmStartIndex
Bit-stream frame index to start extracting frames. (Set to -1 or 0 for first frame)
nFrmEndIndex
Bit-stream frame index to end extracting frames. (Set to -1 for last frame in file)
Return Values
true
false
4.2.9 DTSPBR_Get_Frame_Schedule_SingleSubStream
Retrieves the frame schedule/payload data and returns value as a single sub-stream (combines core and
extension sub-stream).
Page 18 of 33
Version 1.2
Return Values
true
false
4.2.10 DTSPBR_Get_Frame_Data_SingleSubStream
Retrieves the encoded frame data and schedule/payload and returns value as a single sub-stream
(combines core and extension sub-stream).
bool DTSPBR_Get_Frame_Data_SingleSubStream(CDTSPBRHdl pDTSPbrHdl,
CDTSDecRawFrameBuffer *pFrmData,
unsigned int &nuFrmDataBytes,
unsigned DTS__int64 &nuPTS,
unsigned DTS__int64 &nuDTS);
Parameters
pDTSPbrHdl
pFrmData
nuFrmDataBytes
nuPTS
nuDTS
Return Values
true
false
4.2.11 DTSPBR_Get_AccessUnit_Schedule_SingleSubStream
Retrieves the frame audio pack schedule/payload data and returns value as a single sub-stream (combines
core and extension sub-stream).
bool DTSPBR_Get_AccessUnit_Schedule_SingleSubStream(CDTSPBRHdl pDTSPbrHdl,
int &nENOBUFlag,
unsigned DTS__int64 &nuPTS,
unsigned DTS__int64 &nuDTS,
unsigned int &nuApakBytes,
unsigned int &nuBufOccup);
Page 19 of 33
Parameters
pDTSPbrHdl
nENOBUFlag
nuPTS
nuDTS
nuApakBytes
nuBufOccup
Return Values
true
false
Version 1.2
4.2.12 DTSPBR_Get_AccessUnit_Data_SingleSubStream
Retrieves the frame audio pack encoded data and schedule/payload data and returns value as a single substream (combines core and extension sub-stream).
bool DTSPBR_Get_AccessUnit_Data_SingleSubStream(CDTSPBRHdl pDTSPbrHdl,
int &nENOBUFlag,
unsigned DTS__int64 &nuPTS,
unsigned DTS__int64 &nuDTS,
CDTSDecRawFrameBuffer *pFrmData,
unsigned int &nuApakBytes,
unsigned int &nuBufOccup);
Parameters
pDTSPbrHdl
nENOBUFlag
nuPTS
nuDTS
pFrmData
nuApakBytes
nuBufOccup
Return Values
true
false
4.2.13 DTSPBR_Get_Frame_Schedule_TwoSubStream
Retrieves the frame schedule/payload data and returns value as a separate core and extension substreams.
bool DTSPBR_Get_Frame_Schedule_TwoSubStream(CDTSPBRHdl pDTSPbrHdl,
unsigned DTS__int64 &nuPTS,
unsigned DTS__int64 &nuDTS,
unsigned int &nuCoreBytes,
unsigned int &nuExtBytes);
Page 20 of 33
Parameters
pDTSPbrHdl
nuPTS
nuDTS
nuCoreBytes
nuExtBytes
Return Values
true
false
Version 1.2
4.2.14 DTSPBR_Get_Frame_Data_TwoSubStream
Retrieves the encoded frame data and schedule/payload and returns value as a separate core and
extension sub-streams.
bool DTSPBR_Get_Frame_Data_TwoSubStream(CDTSPBRHdl pDTSPbrHdl,
CDTSDecRawFrameBuffer *pCoreFrmData,
unsigned int &nuCoreFrmBytes,
CDTSDecRawFrameBuffer *pExtFrmData,
unsigned int &nuExtFrmBytes,
unsigned DTS__int64 &nuPTS,
unsigned DTS__int64 &nuDTS);
Parameters
pDTSPbrHdl
pCoreFrmData
nuCoreFrmBytes
pExtFrmData
nuExtFrmBytes
nuPTS
nuDTS
Return Values
true
false
4.2.15 DTSPBR_Get_Stream_Duration
Retrieve frame duration and total number of frames in the entire bit-stream file.
bool DTSPBR_Get_Stream_Duration(CDTSPBRHdl pDTSPbrHdl,
double &dFrameDuration,
unsigned int &nNumTotalFrames);
Parameters
pDTSPbrHdl
dFrameDuration
nNumTotalFrames
Page 21 of 33
Return Values
true
false
Version 1.2
4.2.16 DTSPBR_Get_NumCodecDelayFrame
Retrieve number of codec delay frames at start of encoded file.
bool DTSPBR_Get_NumCodecDelayFrame (CDTSPBRHdl pDTSPbrHdl,
unsigned int & nNumCodecDelayFrames);
Parameters
pDTSPbrHdl
nNumCodecDelayFrames
Return Values
true
false
Successful retrieval.
Invalid file designated in DTSPBR_Init
4.2.17 DTSPBR_Get_Schedule_BitRate
Returns the max PBR and avg PBR for entire selected region of the bit-stream.
bool DTSPBR_Get_Schedule_BitRate(CDTSPBRHdl pDTSPbrHdl,
int &nPBRMaxKBPS,
int &nPBRAvgKBPS);
Parameters
pDTSPbrHdl
nPBRMaxKBPS
nPBRAvgKBPS
Return Values
true
false
4.2.18 DTSPBR_Get_PBR_DBase_Size
Queries library for buffer size required to hold PBR database image. A size of 0 indicates no PBR
database is available.
bool DTSPBR_Get_PBR_DBase_Size(CDTSPBRHdl pDTSPbrHdl,
unsigned int &nuPBRDBaseSize);
Parameters
pDTSPbrHdl
Library instance handle created from DTSPBR_Allocate_Hdl
nuPBRDBaseSize
Number of bytes required for PBR database image.
Return Values
true
false
Page 22 of 33
Version 1.2
4.2.19 DTSPBR_Get_PBR_DBase_Data
Create PBR database image.
bool DTSPBR_Get_PBR_DBase_Data(CDTSPBRHdl pDTSPbrHdl,
unsigned char *pcBuffer,
unsigned int nuBufferAllocSize);
Parameters
pDTSPbrHdl
pcBuffer
nuBufferAllocSize
Return Values
true
false
4.2.20 DTSPBR_Get_PBR_DBase_Loaded_Flag
Check if DTSPBR_Load_EncFile using PBR Database image was successful. If the PBR database image
was corrupted, the DTSPBR_Load_EncFile will default back to loading the entire bit-stream.
bool DTSPBR_Get_PBR_DBase_Loaded_Flag (CDTSPBRHdl pDTSPbrHdl);
Parameters
pDTSPbrHdl
Return Values
true
false
4.2.21 DTSPBR_Get_Frame_Mpeg2_DTSHD_audio_stream_descriptor
Retrieves the Mp2TS DTS-HD audio descriptor associated with the DTSH format identifier. This
function may be called after any DTSPBR_Get_Frame_Data_[SingleSubStream,TwoSubStream] or
DTSPBR_Get_Frame_Schedule_[SingleSubStream,TwoSubStream] function call.
bool DTSPBR_Get_Frame_Mpeg2_DTSHD_audio_stream_descriptor (
CDTSPBRHdl pDTSPbrHdl
CDTSMpeg2DTSHD_audio_stream_descriptor *pDescriptor);
Parameters
pDTSPbrHdl
pDescriptor
Return Values
true
false
Successful retrieval
Unsuccessful retrieval.
Page 23 of 33
Version 1.2
4.2.22 DTSPBR_Get_Frame_Mpeg2_DTS_audio_stream_descriptor
Retrieves the Mp2TS DTS audio descriptor associated with format_identifiers DTS1, DTS2, or
DTS3. Function will return false if bit-stream can only be described using Mp2TS DTS-HD. This
function may be called after any DTSPBR_Get_Frame_Data_[SingleSubStream,TwoSubStream] or
DTSPBR_Get_Frame_Schedule_[SingleSubStream,TwoSubStream] function call.
bool DTSPBR_Get_Frame_Mpeg2_DTS_audio_stream_descriptor (
CDTSPBRHdl pDTSPbrHdl
CDTSMpeg2DTS_audio_stream_descriptor *pDescriptor);
Parameters
pDTSPbrHdl
pDescriptor
Return Values
true
false
Successful retrieval
Unsuccessful retrieval.
4.2.23 DTSPBR_Get_Frame_Mpeg4_DTSSampleEntryData
Retrieves the Mp4 DTS sample entry data audio descriptor. This function may be called after any
DTSPBR_Get_Frame_Data_[SingleSubStream,TwoSubStream] or
DTSPBR_Get_Frame_Schedule_[SingleSubStream,TwoSubStream] function call.
bool DTSPBR_Get_Frame_Mpeg4_DTSSampleEntryData (
CDTSPBRHdl pDTSPbrHdl
CDTSSampleEntry *pDescriptor);
Parameters
pDTSPbrHdl
pDescriptor
Return Values
true
false
Successful retrieval
Unsuccessful retrieval.
4.3 CDTSDecRawFrameBuffer
The CDTSDecRawFrameBuffer class is used for returning the encoded bit-stream frame and is declared
in DTSDecFrameBuffer.h.
Page 24 of 33
Version 1.2
Page 25 of 33
Version 1.2
4.4 CDTSMpeg2DTS_audio_stream_descriptor
The CDTSMpeg2DTS_audio_stream_descriptor class is used for returning the Mp2TS DTS audio
descriptor for encoded bit-stream frame and is declared in DTSMpeg2Descriptor.h.
class DLLEXPORT CDTSMpeg2DTS_audio_stream_descriptor
{
public:
unsigned char
m_ucsample_rate_code;
unsigned char
m_ucbit_rate_code;
unsigned char
m_ucnblks;
unsigned short
m_usfsize;
unsigned char
m_ucsurround_mode;
bool
m_blfe_flag;
unsigned char
m_ucextended_surround_flag;
unsigned char
m_uccomponent_type;
};
Page 26 of 33
Version 1.2
4.5 CDTSMpeg2DTSHD_audio_stream_descriptor
The CDTSMpeg2DTSHD_audio_stream_descriptor class is used for returning the Mp2TS DTS-HD
audio descriptor for encoded bit-stream frame and is declared in DTSMpeg2Descriptor.h.
class CDTSMpeg2Asset
{
public:
unsigned char m_ucasset_construction;
bool
m_bvbr_flag;
bool
m_bpost_encode_br_scaling_flag;
bool
m_bcomponent_type_flag;
bool
m_blanguage_code_flag;
unsigned short m_usbit_rate_scaled;
unsigned short m_usbit_rate;
unsigned char m_uccomponent_type;
unsigned int
m_unISO_639_language_code;
};
class CDTSMpeg2SubStream
{
public:
unsigned char m_ucNum_Assets;
unsigned char m_ucChannel_Count;
bool
m_bLFE_Flag;
unsigned char m_ucSampling_frequency;
unsigned char m_ucSample_Resolution;
CDTSMpeg2Asset
m_sAsset[8];
};
class DLLEXPORT CDTSMpeg2DTSHD_audio_stream_descriptor
{
public:
bool
m_bsubstream_core_flag;
bool
m_bsubstream_0_flag;
bool
m_bsubstream_1_flag;
bool
m_bsubstream_2_flag;
bool
m_bsubstream_3_flag;
CDTSMpeg2SubStream
m_ssubstream_core;
CDTSMpeg2SubStream
m_ssubstream_0;
CDTSMpeg2SubStream
m_ssubstream_1;
CDTSMpeg2SubStream
m_ssubstream_2;
CDTSMpeg2SubStream
m_ssubstream_3;
};
Page 27 of 33
Version 1.2
4.6 CDTSSampleEntry
The CDTSSampleEntry class is used for returning the Mp4 DTS audio descriptor for encoded bit-stream
frame and is declared in DTSMpeg4Descriptor.h.
class CDTSSpecificBox
{
public:
unsigned int
m_nSize;
unsigned char m_ucType[4];
unsigned int
m_nDTSSamplingFrequency;
unsigned int
m_nMaxBitrate;
unsigned int
m_nAvgBitRate;
unsigned char m_nPCMSampleDepth;
unsigned char m_nFrameDuration;
unsigned char m_nStreamConstruction;
bool
m_bCoreLFEPresent;
unsigned char m_nCoreLayout;
unsigned short m_nCoreSize;
bool
m_bStereoDownmix;
unsigned char m_nRepresentationType;
unsigned short m_nChannelLayout;
bool
m_bMultiAssetFlag;
bool
m_bLBRDurationMod;
};
class CDTSSampleEntry
{
public:
unsigned int
m_nSize;
unsigned char m_ucType[4];
unsigned int
m_nChannelCount;
unsigned int
m_nSampleSize;
unsigned int
m_nPredefined;
unsigned int
m_nSampleRate;
CDTSSpecificBox
m_dtssbox;
};
Page 28 of 33