DRCAtoms

Author:
Armin Trattnig
Version:
1.0
Includes:
"MP4Atoms.h"

Introduction

DRCAtoms defines DRC specific atoms for the file format version of the DRC bitstream as defined in ISO/IEC DIS 23003-4.

Updated:
Friday, September 19, 2014


Functions

MP4CreateDRCAtom
MP4CreateDrcAudioSampleEntryAtom
MP4CreateDRCCoefficientBasicAtom
MP4CreateDRCCoefficientUniDRCAtom
MP4CreateDRCInstructionsBasicAtom
MP4CreateDRCInstructionsUniDRCAtom
MP4CreateDRCUniDrcSampleEntryAtom
MP4ParseDRCAtom
MP4ParseDRCAtomUsingProtoList

MP4CreateDRCAtom


MP4Err MP4CreateDRCAtom (
    u32 atomType,
    MP4AtomPtr *outAtom );  
Parameters
atomType

Type of the atom, which will be created

outAtom

pointer to a structure, which will be created

Return Value

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

Discussion

Creates and initializes a atom structure with a certain type, memory will be allocated


MP4CreateDrcAudioSampleEntryAtom


MP4Err MP4CreateDrcAudioSampleEntryAtom (
    MP4AudioSampleEntryAtomPtr *outAtom );  
Parameters
outAtom

pointer to MP4AudioSampleEntryAtom structure, which will be created

Return Value

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

Discussion

Creates and initializes a MP4AudioSampleEntryAtom structure, memory will be allocated


MP4CreateDRCCoefficientBasicAtom


Parameters
outAtom

pointer to DRCCoefficientBasicAtom structure, which will be created

Return Value

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

Discussion

Creates and initializes a DRCCoefficientBasicAtom structure, memory will be allocated


MP4CreateDRCCoefficientUniDRCAtom


Parameters
outAtom

pointer to DRCCoefficientUniDRCAtom structure, which will be created

Return Value

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

Discussion

Creates and initializes a DRCCoefficientUniDRCAtom structure, memory will be allocated


MP4CreateDRCInstructionsBasicAtom


Parameters
outAtom

pointer to DRCInstructionsBasicAtom structure, which will be created

Return Value

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

Discussion

Creates and initializes a DRCInstructionsBasicAtom structure, memory will be allocated


MP4CreateDRCInstructionsUniDRCAtom


Parameters
outAtom

pointer to DRCInstructionsUniDRCAtom structure, which will be created

Return Value

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

Discussion

Creates and initializes a DRCInstructionsUniDRCAtom structure, memory will be allocated


MP4CreateDRCUniDrcSampleEntryAtom


Parameters
outAtom

pointer to DRCUniDrcSampleEntryAtom structure, which will be created

Return Value

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

Discussion

Creates and initializes a DRCUniDrcSampleEntryAtom structure, memory will be allocated


MP4ParseDRCAtom


MP4Err MP4ParseDRCAtom (
    MP4InputStreamPtr inputStream,
    MP4AtomPtr *outAtom );  
Parameters
inputStream

MP4InputStreamPtr (can be found in libisomediafile.a). Data will be read from this stream.

outAtom

pointer to a structure, which will be created

Return Value

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

Discussion

Reads an atom from inputStream.


MP4ParseDRCAtomUsingProtoList


MP4Err MP4ParseDRCAtomUsingProtoList (
    MP4InputStreamPtr inputStream,
    u32 *protoList,
    u32 defaultAtom,
    MP4AtomPtr *outAtom );  
Parameters
inputStream

MP4InputStreamPtr (can be found in libisomediafile.a). Data will be read from this stream.

protoList

List of atoms, which are valid for being parsed. Can be NULL.

defaultAtom

Prototype of parsed atom. Can be NULL.

outAtom

pointer to a structure, which will be created

Return Value

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

Discussion

Reads an atom from inputStream. If type of atom not in protolist it fails.


Typedefs

DRCCoefficientBasicAtom

Represents a DRCCoefficientBasicAtom.

DRCCoefficientBasicAtomPtr

Points to a DRCCoefficientBasicAtom structure

DRCCoefficientUniDRCAtom

Represents a DRCCoefficientUniDRCAtom

DRCCoefficientUniDRCAtomPtr

Points to a DRCCoefficientUniDRCAtom structure

DRCCoefficientUniDRCSequence

Part of DRCCoefficientUniDRCAtom

DRCCoefficientUniDRCSequenceBandCharacteristic

Part of DRCCoefficientUniDRCSequence

DRCCoefficientUniDRCSequenceBandIndex

Part of DRCCoefficientUniDRCSequence

DRCInstructionsAdditionalDownMixID

Part of DRCInstructionsBasicAtom and DRCInstructionsUniDRCAtom

DRCInstructionsBasicAtom

Represents a DRCInstructionsBasicAtom

DRCInstructionsBasicAtomPtr

Points to a DRCInstructionsBasicAtom structure

DRCInstructionsChannelGroupDuckingScaling

Part of DRCInstructionsUniDRCAtom

DRCInstructionsChannelGroupGainScaling

Part of DRCInstructionsUniDRCAtom

DRCInstructionsChannelSequenceIndex

Part of DRCInstructionsUniDRCAtom

DRCInstructionsUniDRCAtom

Represents a DRCInstructionsUniDRCAtom

DRCInstructionsUniDRCAtomPtr

Points to a DRCInstructionsUniDRCAtom structure

DRCUniDrcSampleEntryAtom

Represents a DRCUniDrcSampleEntryAtom.

DRCUniDrcSampleEntryAtomPtr

Points to a DRCUniDrcSampleEntryAtom structure


DRCCoefficientBasicAtom


Represents a DRCCoefficientBasicAtom.

typedef struct DRCCoefficientBasicAtom { 
    MP4_FULL_ATOM u8 reserved; // bit(4) = 0 
    s8 DRC_location; // int(5) 
    u8 DRC_characteristic; // uint(7) 
} DRCCoefficientBasicAtom;  
Fields
MP4_FULL_ATOM

MP4Atoms.h macro to add all fields needed by a full atom

reserved

bit(4) reserved = 0;

DRC_location

signed int(5) DRC_location;

DRC_characteristic

unsigned int(7) DRC_characteristic;


DRCCoefficientBasicAtomPtr


Points to a DRCCoefficientBasicAtom structure

typedef struct DRCCoefficientBasicAtom *DRCCoefficientBasicAtomPtr;  

DRCCoefficientUniDRCAtom


Represents a DRCCoefficientUniDRCAtom

typedef struct DRCCoefficientUniDRCAtom { 
    MP4_FULL_ATOM u8 reserved1; // bit(2) = 0 
    s8 DRC_location; // int(5) 
    u8 drc_frame_size_present; // bit(1) 
    u8 reserved2; // bit(1) 
    u16 bs_drc_frame_size; // uint(15) 
    u8 reserved3; // bit(2) = 0 
    u8 sequence_count; // uint(6) 
    MP4LinkedList sequences; // List of DRCCoefficientUniDRCSequences 
} DRCCoefficientUniDRCAtom;  
Fields
MP4_FULL_ATOM

MP4Atoms.h macro to add all fields needed by a full atom

reserved1

bit(2) reserved = 0;

DRC_location

signed int(5) DRC_location;

drc_frame_size_present

bit(1) drc_frame_size_present;

reserved2

bit(1) reserved = 0;

bs_drc_frame_size

unsigned int(15) bs_drc_frame_size;

reserved3

bit(2) reserved = 0;

sequence_count

unsigned int(6) sequence_count;

sequences

List of DRCCoefficientUniDRCSequences


DRCCoefficientUniDRCAtomPtr


Points to a DRCCoefficientUniDRCAtom structure

typedef struct DRCCoefficientUniDRCAtom *DRCCoefficientUniDRCAtomPtr;  

DRCCoefficientUniDRCSequence


Part of DRCCoefficientUniDRCAtom

typedef struct DRCCoefficientUniDRCSequence { 
    u8 reserved1; // bit(2) = 0 
    u8 gain_coding_profile; // uint(2) 
    u8 gain_interpolation_type; // uint(1) 
    u8 full_frame; // uint(1) 
    u8 time_alignment; // uint(1) 
    u8 time_delta_min_present; // bit(1) 
    u8 reserved2; // bit(5) = 0 
    u16 bs_time_delta_min; // uint(11) 
    u8 reserved3; // bit(3) = 0 
    u8 band_count; // uint(4) 
    u8 drc_band_type; // uint(1) 
    MP4LinkedList bandCharacteristics; // List of DRCCoefficientUniDRCSequenceBandCharacteristics 
    MP4LinkedList bandIndexes; // List of DRCCoefficientUniDRCSequenceBandIndex 
} DRCCoefficientUniDRCSequence;  
Fields
reserved1

bit(2) reserved = 0;

gain_coding_profile

unsigned int(2) gain_coding_profile;

gain_interpolation_type

unsigned int(1) gain_interpolation_type;

full_frame

unsigned int(1) full_frame;

time_alignment

unsigned int(1) time_alignment;

time_delta_min_present

bit(1) time_delta_min_present;

reserved2

bit(5) reserved = 0;

bs_time_delta_min

unsigned int(11) bs_time_delta_min;

reserved3

bit(3) reserved = 0;

band_count

unsigned int(4) band_count; // must be >= 1

drc_band_type

unsigned int(1) drc_band_type;

bandCharacteristics

List of DRCCoefficientUniDRCSequenceBandCharacteristics

bandIndexes

List of DRCCoefficientUniDRCSequenceBandIndex


DRCCoefficientUniDRCSequenceBandCharacteristic


Part of DRCCoefficientUniDRCSequence

typedef struct DRCCoefficientUniDRCSequenceBandCharacteristic { 
    u8 reserved; // bit(1) = 0 
    u8 DRC_characteristic; // uint(7) 
} DRCCoefficientUniDRCSequenceBandCharacteristic;  
Fields
reserved

bit(1) reserved = 0;

DRC_characteristic

unsigned int(7) DRC_characteristic;


DRCCoefficientUniDRCSequenceBandIndex


Part of DRCCoefficientUniDRCSequence

typedef struct DRCCoefficientUniDRCSequenceBandIndex { 
    u8 reserved1; // bit(4) = 0 
    u8 crossover_freq_index; // uint(4) 
    u8 reserved2; // bit(6) = 0 
    u16 start_sub_band_index; // uint(10) 
} DRCCoefficientUniDRCSequenceBandIndex;  
Fields
reserved

bit(4) reserved = 0;

bit(6) reserved = 0;

crossover_freq_index

unsigned int(4) crossover_freq_index;

start_sub_band_index

unsigned int(10) start_sub_band_index;


DRCInstructionsAdditionalDownMixID


Part of DRCInstructionsBasicAtom and DRCInstructionsUniDRCAtom

typedef struct DRCInstructionsAdditionalDownMixID { 
    u8 reserved; // bit(1) = 0 
    u8 additional_dowmix_ID; // uint(7) 
} DRCInstructionsAdditionalDownMixID;  
Fields
reserved

bit(1) reserved = 0;

additional_dowmix_ID

unsigned int(7) additional_dowmix_ID;


DRCInstructionsBasicAtom


Represents a DRCInstructionsBasicAtom

typedef struct DRCInstructionsBasicAtom { 
    MP4_FULL_ATOM u8 reserved1; // bit(3) = 0 
    u8 DRC_set_ID; // uint(6) 
    s8 DRC_location; // int(5) 
    u8 downmix_ID; // uint(7) 
    u8 additional_dowmix_ID_count; // uint(3) 
    MP4LinkedList additionalDownMixIDs; // List of DRCInstructionsAdditionalDownMixIDs 
    u16 DRC_set_effect; // bit(16) 
    u8 reserved2; // bit(7) = 0 
    u8 limiter_peak_target_present; // bit(1) 
    u8 bs_limiter_peak_target; // uint(8) 
    u8 reserved3; // bit(7) = 0 
    u8 DRC_set_target_loudness_present; // bit(1) 
    u8 reserved4; // bit(4) = 0 
    u8 bs_DRC_set_target_loudness_value_upper; // uint(6) 
    u8 bs_DRC_set_target_loudness_value_lower; // uint(6) 
} DRCInstructionsBasicAtom;  
Fields
MP4_FULL_ATOM

MP4Atoms.h macro to add all fields needed by a full atom

reserved1

bit(3) reserved = 0;

DRC_set_ID

unsigned int(6) DRC_set_ID;

DRC_location

signed int(5) DRC_location;

downmix_ID

unsigned int(7) downmix_ID;

additional_dowmix_ID_count

unsigned int(3) additional_downmix_ID_count;

additionalDownMixIDs

List of DRCInstructionsAdditionalDownMixIDs

DRC_set_effect

bit(16) DRC_set_effect;

reserved2

bit(7) reserved = 0;

limiter_peak_target_present

bit(1) limiter_peak_target_present;

bs_limiter_peak_target

unsigned int(8) bs_limiter_peak_target;

reserved3

bit(7) reserved = 0;

DRC_set_target_loudness_present

bit(1) DRC_set_target_loudness_present;

reserved4

bit(4) reserved = 0;

bs_DRC_set_target_loudness_value_upper

unsigned int(6) bs_DRC_set_target_loudness_value_upper;

bs_DRC_set_target_loudness_value_lower

unsigned int(6) bs_DRC_set_target_loudness_value_lower;


DRCInstructionsBasicAtomPtr


Points to a DRCInstructionsBasicAtom structure

typedef struct DRCInstructionsBasicAtom *DRCInstructionsBasicAtomPtr;  

DRCInstructionsChannelGroupDuckingScaling


Part of DRCInstructionsUniDRCAtom

typedef struct DRCInstructionsChannelGroupDuckingScaling { 
    u8 reserved1; // bit(7) = 0 
    u8 ducking_scaling_present; // bit(1) 
    u8 reserved2; // bit(4) = 0 
    u8 bs_ducking_scaling; // bit(4) 
} DRCInstructionsChannelGroupDuckingScaling;  
Fields
reserved1

bit(7) reserved = 0;

ducking_scaling_present

bit(1) ducking_scaling_present;

reserved2

bit(4) reserved = 0;

bs_ducking_scaling

bit(4) bs_ducking_scaling;


DRCInstructionsChannelGroupGainScaling


Part of DRCInstructionsUniDRCAtom

typedef struct DRCInstructionsChannelGroupGainScaling { 
    u8 reserved1; // bit(7) = 0 
    u8 gain_scaling_present; // bit(1) 
    u8 bs_attenuation_scaling; // uint(4) 
    u8 bs_amplification_scaling; // uint(4) 
    u8 reserved2; // bit(7) = 0 
    u8 gain_offset_present; // bit(1) 
    u8 reserved3; // bit(2) 
    u8 bs_gain_offset; // bit(6) 
} DRCInstructionsChannelGroupGainScaling;  
Fields
reserved1

bit(7) reserved = 0;

gain_scaling_present

bit(1) gain_scaling_present;

bs_attenuation_scaling

uint(4) bs_attenuation_scaling = 0;

bs_amplification_scaling

uint(4) bs_amplification_scaling;

reserved2

bit(7) reserved = 0;

gain_offset_present

bit(1) gain_offset_present;

reserved3

bit(2) reserved = 0;

bs_gain_offset

bit(6) bs_gain_offset;


DRCInstructionsChannelSequenceIndex


Part of DRCInstructionsUniDRCAtom

typedef struct DRCInstructionsChannelSequenceIndex { 
    u8 reserved; // bit(2) = 0 
    u8 bs_sequence_index; // uint(6) 
} DRCInstructionsChannelSequenceIndex;  
Fields
reserved

bit(2) reserved = 0;

bs_sequence_index

unsigned int(6) bs_sequence_index;


DRCInstructionsUniDRCAtom


Represents a DRCInstructionsUniDRCAtom

typedef struct DRCInstructionsUniDRCAtom { 
    MP4_FULL_ATOM u8 reserved1; // bit(3) = 0 
    u8 DRC_set_ID; // uint(6) 
    s8 DRC_location; // int(5) 
    u8 downmix_ID; // uint(7) 
    u8 additional_dowmix_ID_count; // uint(3) 
    MP4LinkedList additionalDownMixIDs; // List of DRCInstructionsAdditionalDownMixIDs 
    u16 DRC_set_effect; // bit(16) 
    u8 reserved2; // bit(7) = 0 
    u8 limiter_peak_target_present; // bit(1) 
    u8 bs_limiter_peak_target; // uint(8) 
    u8 reserved3; // bit(7) = 0 
    u8 DRC_set_target_loudness_present; // bit(1) 
    u8 reserved4; // bit(4) = 0 
    u8 bs_DRC_set_target_loudness_value_upper; // uint(6) 
    u8 bs_DRC_set_target_loudness_value_lower; // uint(6)  
    u8 reserved5; // bit(1) = 0 
    u8 depends_on_DRC_set; // uint(3) 
    u8 no_independent_use; // bit(1) 
    u8 reserved6; // bit(1) = 0 
    u8 channel_count; // uint(8) 
    MP4LinkedList channelSequenceIndexes; // List of DRCInstructionsChannelSequenceIndexes 
    u8 channel_group_count; // uint(8) 
    MP4LinkedList channelGroupDuckingScalings; // List of DRCInstructionsChannelGroupDuckingScalings 
    MP4LinkedList channelGroupGainScalings; // List of DRCInstructionsChannelGroupGainScaling 
} DRCInstructionsUniDRCAtom;  
Fields
MP4_FULL_ATOM

MP4Atoms.h macro to add all fields needed by a full atom

reserved1

bit(3) reserved = 0;

DRC_set_ID

unsigned int(6) DRC_set_ID;

DRC_location

signed int(5) DRC_location;

downmix_ID

unsigned int(7) downmix_ID;

additional_dowmix_ID_count

unsigned int(3) additional_downmix_ID_count;

additionalDownMixIDs

List of DRCInstructionsAdditionalDownMixIDs

DRC_set_effect

bit(16) DRC_set_effect;

reserved2

bit(7) reserved = 0;

limiter_peak_target_present

bit(1) limiter_peak_target_present;

bs_limiter_peak_target

unsigned int(8) bs_limiter_peak_target;

reserved3

bit(7) reserved = 0;

DRC_set_target_loudness_present

bit(1) DRC_set_target_loudness_present;

reserved4

bit(4) reserved = 0;

bs_DRC_set_target_loudness_value_upper

unsigned int(6) bs_DRC_set_target_loudness_value_upper;

bs_DRC_set_target_loudness_value_lower

unsigned int(6) bs_DRC_set_target_loudness_value_lower;

reserved5

bit(1) reserved = 0;

depends_on_DRC_set

unsigned int(6) depends_on_DRC_set;

no_independent_use

bit(1) no_independent_use;

reserved6

bit(1) reserved = 0;

channel_count

unsigned int(8) channel_count;

channelSequenceIndexes

List of DRCInstructionsChannelSequenceIndexes

channel_group_count

unsigned int(8) channel_group_count;

channelGroupDuckingScalings

List of DRCInstructionsChannelGroupDuckingScalings

channelGroupGainScalings

List of DRCInstructionsChannelGroupGainScaling


DRCInstructionsUniDRCAtomPtr


Points to a DRCInstructionsUniDRCAtom structure

typedef struct DRCInstructionsUniDRCAtom *DRCInstructionsUniDRCAtomPtr;  

DRCUniDrcSampleEntryAtom


Represents a DRCUniDrcSampleEntryAtom.

typedef struct DRCUniDrcSampleEntryAtom { 
    MP4_BASE_ATOM COMMON_SAMPLE_ENTRY_FIELDS 
} DRCUniDrcSampleEntryAtom;  
Fields
MP4_BASE_ATOM

MP4Atoms.h macro to add all fields needed by a base atom

COMMON_SAMPLE_ENTRY_FIELDS

Fields used by a generic sample entry


DRCUniDrcSampleEntryAtomPtr


Points to a DRCUniDrcSampleEntryAtom structure

typedef struct DRCUniDrcSampleEntryAtom *DRCUniDrcSampleEntryAtomPtr;  

Enumerated Types

DRC

Extends the list of atom types from MP4Atoms.h with atoms used with drc data


DRC


Extends the list of atom types from MP4Atoms.h with atoms used with drc data

enum { 
    DRCTrackReferenceAtomType = MP4_FOUR_CHAR_CODE(
        'a',
        'd',
        'r',
        'c' ), 
    DRCUniDrcSampleEntryAtomType = MP4_FOUR_CHAR_CODE(
        'u',
        'n',
        'i',
        'd' ), 
    DRCCoefficientBasicAtomType = MP4_FOUR_CHAR_CODE(
        'u',
        'd',
        'c',
        '1' ), 
    DRCInstructionsBasicAtomType = MP4_FOUR_CHAR_CODE(
        'u',
        'd',
        'i',
        '1' ), 
    DRCCoefficientUniDRCAtomType = MP4_FOUR_CHAR_CODE(
        'u',
        'd',
        'c',
        '2' ), 
    DRCInstructionsUniDRCAtomType = MP4_FOUR_CHAR_CODE(
        'u',
        'd',
        'i',
        '2' ) 
};  
Constants
DRCUniDrcSampleEntryAtomType

Type for DRCUniDrcSampleEntry. "unid"

DRCCoefficientBasicAtomType

Type for DRCCoefficientBasic. "udc1"

DRCInstructionsBasicAtomType

Type for DRCInstructionsBasic. "udi1"

DRCCoefficientUniDRCAtomType

Type for DRCCoefficientUniDRC. "udc2"

DRCInstructionsUniDRCAtomType

Type for DRCInstructionsUniDRC. "udi2"

Discussion

Atoms