Skip to content

Commit cad5670

Browse files
Luiz-Monadtobbee
authored andcommitted
feat: iamf dump logger
1 parent 258a543 commit cad5670

3 files changed

Lines changed: 95 additions & 10 deletions

File tree

iamf/parser.go

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,6 +1451,91 @@ func (obu ObuInfo) ReadDescriptors(r *ObuReader) (*IamfContext, error) {
14511451
return nil, nil
14521452
}
14531453

1454+
func (o *ObuInfo) Info(writer func(format string, p ...interface{})) error {
1455+
writer("obu: Type=%s Size=%d Start=%d", o.Type, o.Size, o.Start)
1456+
return nil
1457+
}
1458+
1459+
func (i *IamfContext) Info(f func(level int, format string, p ...interface{})) error {
1460+
f(0, "IAMF Context:")
1461+
f(1, "Codec Configs (%d):", i.NumCodecConfigs)
1462+
for _, cc := range i.CodecConfigs[:i.NumCodecConfigs] {
1463+
f(2, "CodecConfigID=%d Codec=%s SampleRate=%d NumSamples=%d RollDistance=%d",
1464+
cc.CodecConfigID, cc.CodecID, cc.SampleRate, cc.NumSamples, cc.AudioRollDistance)
1465+
}
1466+
1467+
f(1, "Audio Elements (%d):", i.NumAudioElements)
1468+
for _, ae := range i.AudioElements[:i.NumAudioElements] {
1469+
f(2, "AudioElementID=%d Type=%s CodecConfigID=%d NumSubstreams=%d NumLayers=%d",
1470+
ae.AudioElementID, ae.Element.AudioElementType, ae.CodecConfigID, ae.NumSubstreams, ae.NumLayers)
1471+
for j, layer := range ae.Element.Layers {
1472+
f(3, "Layer[%d]: %s", j, layer.ChannelLayout)
1473+
if layer.AmbisonicsMode != 0 {
1474+
f(4, "AmbisonicsMode: %s", layer.AmbisonicsMode)
1475+
}
1476+
if layer.OutputGain.Num != 0 || layer.OutputGain.Den != 1 {
1477+
f(4, "OutputGain: %d/%d", layer.OutputGain.Num, layer.OutputGain.Den)
1478+
}
1479+
}
1480+
for j, ss := range ae.Substreams {
1481+
f(3, "Substream[%d]: ID=%d", j, ss.AudioSubstreamID)
1482+
}
1483+
if ae.Element.DemixingInfo != nil {
1484+
f(3, "Demixing: ID=%d Rate=%d Duration=%d",
1485+
ae.Element.DemixingInfo.ParameterID,
1486+
ae.Element.DemixingInfo.ParameterRate,
1487+
ae.Element.DemixingInfo.Duration)
1488+
}
1489+
if ae.Element.ReconGainInfo != nil {
1490+
f(3, "ReconGain: ID=%d Rate=%d Duration=%d",
1491+
ae.Element.ReconGainInfo.ParameterID,
1492+
ae.Element.ReconGainInfo.ParameterRate,
1493+
ae.Element.ReconGainInfo.Duration)
1494+
}
1495+
}
1496+
1497+
f(1, "Mix Presentations (%d):", i.NumMixPresentations)
1498+
for _, mp := range i.MixPresentations[:i.NumMixPresentations] {
1499+
f(2, "MixPresentationID=%d Labels=%v", mp.MixPresentationID, mp.LanguageLabel)
1500+
for lang, ann := range mp.Mix.Annotations {
1501+
f(3, "%s: %s", lang, ann)
1502+
}
1503+
for j, submix := range mp.Mix.Submixes {
1504+
f(3, "Submix[%d]: NumElements=%d NumLayouts=%d", j, submix.NumElements, submix.NumLayouts)
1505+
for k, elem := range submix.Elements {
1506+
f(4, "Element[%d]: AudioElementID=%d HeadphonesMode=%s",
1507+
k, elem.AudioElementID, elem.HeadphonesRenderingMode)
1508+
f(5, "DefaultMixGain: %d/%d", elem.DefaultMixGain.Num, elem.DefaultMixGain.Den)
1509+
for lang, ann := range elem.Annotations {
1510+
f(6, "%s: %s", lang, ann)
1511+
}
1512+
}
1513+
for k, layout := range submix.Layouts {
1514+
f(4, "Layout[%d]: Type=%s", k, layout.LayoutType)
1515+
if layout.SoundSystem.NumChannels > 0 {
1516+
f(5, "SoundSystem: %s", layout.SoundSystem)
1517+
f(5, "Channels: %d", layout.SoundSystem.NumChannels)
1518+
}
1519+
f(5, "IntegratedLoudness: %d/%d", layout.IntegratedLoudness.Num, layout.IntegratedLoudness.Den)
1520+
f(5, "DigitalPeak: %d/%d", layout.DigitalPeak.Num, layout.DigitalPeak.Den)
1521+
if layout.TruePeak.Num != 0 {
1522+
f(5, "TruePeak: %d/%d", layout.TruePeak.Num, layout.TruePeak.Den)
1523+
}
1524+
}
1525+
}
1526+
}
1527+
1528+
f(1, "Param Definitions (%d):", i.NumParamDefinitions)
1529+
for _, pd := range i.ParamDefinitions[:i.NumParamDefinitions] {
1530+
f(2, "Type=%s ParameterID=%d ParameterRate=%d Duration=%d",
1531+
pd.Param.Type, pd.Param.ParameterID, pd.Param.ParameterRate, pd.Param.Duration)
1532+
f(3, "Mode=%d NumSubblocks=%d", pd.Mode, pd.Param.NumSubblocks)
1533+
if pd.AudioElement != nil {
1534+
f(3, "AudioElementID=%d", pd.AudioElement.AudioElementID)
1535+
}
1536+
}
1537+
1538+
return nil
14541539
}
14551540

14561541
func (c channelLayout) toChannelLayout() ChannelLayout {

iamf/types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,13 @@ const (
114114
func (p ParamDefinitionType) String() string {
115115
switch p {
116116
case ParamDefinitionMixGain:
117-
return "MIX_GAIN"
117+
return "MixGain"
118118
case ParamDefinitionDemixing:
119-
return "DEMIXING"
119+
return "Demixing"
120120
case ParamDefinitionReconGain:
121-
return "RECON_GAIN"
121+
return "ReconGain"
122122
default:
123-
return fmt.Sprintf("UNKNOWN(%d)", p)
123+
return fmt.Sprintf("Unknown(%d)", p)
124124
}
125125
}
126126

mp4/iacb.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ func (b *IacbBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string
100100
if obu == nil {
101101
break
102102
}
103-
// err = obu.Info(func(format string, p ...interface{}) {
104-
// bd.write(" "+format, p...)
105-
// })
103+
err = obu.Info(func(format string, p ...interface{}) {
104+
bd.write(" "+format, p...)
105+
})
106106
if err != nil {
107107
return err
108108
}
@@ -115,9 +115,9 @@ func (b *IacbBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string
115115
if ctx == nil {
116116
continue
117117
}
118-
// err = ctx.Info(func(level int, format string, p ...interface{}) {
119-
// bd.write(" "+indentStep+strings.Repeat(indentStep, level)+format, p...)
120-
// })
118+
err = ctx.Info(func(level int, format string, p ...interface{}) {
119+
bd.write(" "+indentStep+strings.Repeat(indentStep, level)+format, p...)
120+
})
121121
if err != nil {
122122
return err
123123
}

0 commit comments

Comments
 (0)