InStreamDrcToFileFormatDrc

Author:
Armin Trattnig
Version:
1.0
Includes:
"DRCAtoms.h"
"../include/uniDrc.h"
<writeonlybitbuf.h>
<uniDrcBitstreamDecoder_api.h>

Introduction

Use the links in the table of contents to the left to access the documentation.

Updated:
Friday, October 03, 2014


Functions

createStaticDrcDataFromAudioTrack
initDrcBitstream
prepareDrcBitStreamHelper
writeDrcGainToBitstream
writeStaticDrcDataToBitstream

createStaticDrcDataFromAudioTrack


MP4Err createStaticDrcDataFromAudioTrack (
    MP4Track trak,
    StaticDrcData *staticDrcData);  
Parameters
trak

The audio track

staticDrcData

Pointer to an allocated StaticDrcData structure

Return Value

An MP4Err, which is defined libisomediafile.a; MP4NoErr if nothing fails

Discussion

Collects the static drc data contained inside an audio track


initDrcBitstream


MP4Err initDrcBitstream (
    StaticDrcData *staticDrcData,
    DrcBitstreamHandle *drcBitStreamHandle);  
Parameters
staticDrcData

Data for static drc. Used to estimate buffer size

drcBitStreamHandle

Pointer to a drcBitStreamHandle, must be allocated

Return Value

An MP4Err, which is defined libisomediafile.a; MP4NoErr if nothing fails

Discussion

Initializes the buffer for the drc output file


prepareDrcBitStreamHelper


MP4Err prepareDrcBitStreamHelper (
    DrcBitStreamHelper *drcBitStreamHelper,
    DrcBitstreamHandle *drcBitStreamHandle,
    StaticDrcData *staticDrcData);  
Parameters
drcBitStreamHelper

Pointer to DrcBitStreamHelper, must be allocated *

drcBitStreamHandle

Pointer to a drcBitStreamHandle, must already contain static drc data *

staticDrcData

Data for static drc *

Return Value

An MP4Err, which is defined libisomediafile.a; MP4NoErr if nothing fails

Discussion

Prepares a DrcBitStreamHelper by checking static drc data and set buffer position and offset correctly *


writeDrcGainToBitstream


MP4Err writeDrcGainToBitstream (
    MP4Handle packetH,
    DrcBitstreamHandle *drcBitStreamHandle,
    DrcBitStreamHelper *drcBitStreamHelper);  
Parameters
packetH

MP4Handle containing a dynamic drc sample from a drc metadata track *

drcBitStreamHandle

Pointer to a drcBitStreamHandle, must already contain static drc data *

drcBitStreamHelper

Pointer to a DrcBitStreamHelper, must be prepared with prepareDrcBitStreamHelper *

Return Value

An MP4Err, which is defined libisomediafile.a; MP4NoErr if nothing fails

Discussion

Writes 0 for uniDrcLoudnessInfoSetPresent flag and checks the uniDrcGain() contained in the packetH. It then writes the bits of the gain to the bitstreamBuffer. Additional buffersize will be allocated and the padding bits will be dropped. *


writeStaticDrcDataToBitstream


MP4Err writeStaticDrcDataToBitstream (
    StaticDrcData *staticDrcData,
    DrcBitstreamHandle *drcBitStreamHandle);  
Parameters
staticDrcData

Data for static drc *

drcBitStreamHandle

Pointer to a drcBitStreamHandle, must be allocated *

Return Value

An MP4Err, which is defined libisomediafile.a; MP4NoErr if nothing fails

Discussion

Converts the file format syntax to in stream syntax for static drc data and writes the in stream data in the drc buffer. *


Typedefs

DrcBitstreamHandle

Contains information to control a writeonlybitbuf, which operates on bit level. *

DrcBitStreamHelper

Contains handles for the DrcBitstreamDecoderLib. Will be used for checking written drc data and to obtain the exact size in bits for specific drc parts. *

StaticDrcData

Represents the static drc data in file format syntax. Contains all drc related atoms and fields. *


DrcBitstreamHandle


Contains information to control a writeonlybitbuf, which operates on bit level. *

typedef struct DrcBitstreamHandle { 
    int totalBufferSizeInBytes; 
    int currentBytePosition; 
    int offsetInBits; 
    unsigned char *bitstreamBuffer; 
    wobitbufHandle bitstream; 
} DrcBitstreamHandle;  
Fields
totalBufferSizeInBytes

Total number of bytes allocated for the bistreamBuffer *

currentBytePosition

The current byte position in the bitstreamBuffer *

offsetInBits

The offset in bits from the current byte position *

bitstreamBuffer

The actual buffer for the drc data *

bitstream

writeonlybitbuf handle


DrcBitStreamHelper


Contains handles for the DrcBitstreamDecoderLib. Will be used for checking written drc data and to obtain the exact size in bits for specific drc parts. *

typedef struct DrcBitStreamHelper { 
    HANDLE_UNI_DRC_BS_DEC_STRUCT hUniDrcBsDecStruct; 
    HANDLE_UNI_DRC_CONFIG hUniDrcConfig; 
    HANDLE_LOUDNESS_INFO_SET hLoudnessInfoSet; 
    HANDLE_UNI_DRC_GAIN hUniDrcGain; 
    int gainCount; 
} DrcBitStreamHelper;  
Fields
hUniDrcBsDecStruct

Handle for uniDrcBitstreamDecoder *

hUniDrcConfig

Contains instream data of a uniDrcConfig *

hLoudnessInfoSet

Contains instream data of a LoudnessInfoSet *

hUniDrcGain

Contains instream data of a UniDrcGain *

gainCount

Number of gains processed


StaticDrcData


Represents the static drc data in file format syntax. Contains all drc related atoms and fields. *

typedef struct StaticDrcData { 
    int channelCount; 
    int sampleRate; 
    int bytesPerSample; 
    int drcLocation; 
    MP4LoudnessAtomPtr loudnessAtom; 
    MP4ChannelLayoutAtomPtr channelLayoutAtom; 
    MP4LinkedList downMixInstructionsAtoms; 
    MP4LinkedList drcCoefficientsBasicAtoms; 
    MP4LinkedList drcInstructionsBasicAtoms; 
    MP4LinkedList drcCoefficientsUniDrcAtoms; 
    MP4LinkedList drcInstructionsUniDrcAtoms; 
} StaticDrcData;  
Fields
channelCount

Number of channels *

sampleRate

The sample rate of the base audio signal *

bytesPerSample

Byte depth of a single audio sample *

drcLocation

Location of the drc data, will be used for writing in stream drc *

loudnessAtom

LoudnessBox, according to ISO/IEC 14496-12 Amd.4 *

channelLayoutAtom

ChannelLayoutBox *

downMixInstructionsAtoms

LinkedList of DownMixInstructionBoxes *

drcCoefficientsBasicAtoms

LinkedList of CoefficientsBasicBoxes *

drcInstructionsBasicAtoms

LinkedList of InstructionsBasicBoxes *

drcCoefficientsUniDrcAtoms

LinkedList of CoefficientUniDrcBoxes *

drcInstructionsUniDrcAtoms

LinkedList of InstructionsUniDrcBoxes