From e51c746db4d7de893b06330439bc180905c38ff9 Mon Sep 17 00:00:00 2001 From: Mattias Wadman Date: Mon, 29 Jan 2024 12:12:59 +0100 Subject: [PATCH] aac_frame: CPE: Decode instance tag and common window flag --- format/mpeg/aac_frame.go | 15 ++++++++++++--- format/mpeg/testdata/aac_frame.fqtest | 6 ++++-- format/mpeg/testdata/adts.fqtest | 24 ++++++++++++++---------- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/format/mpeg/aac_frame.go b/format/mpeg/aac_frame.go index 52a124e91..35f12fd5b 100644 --- a/format/mpeg/aac_frame.go +++ b/format/mpeg/aac_frame.go @@ -162,6 +162,15 @@ func aacIndividualChannelStream(d *decode.D, objectType int, commonWindow bool, } } +func aacChannelPairElement(d *decode.D) { + d.FieldU4("element_instance_tag") + d.FieldBool("common_window") + // TODO: + // if commonWindow ... + // aacIndividualChannelStream + // aacIndividualChannelStream +} + func aacSingleChannelElement(d *decode.D, objectType int) { d.FieldU4("element_instance_tag") aacIndividualChannelStream(d, objectType, false, false) @@ -294,15 +303,15 @@ func aacDecode(d *decode.D) any { switch se { case FIL: aacFillElement(d) - + case CPE: + aacChannelPairElement(d) + seenTerm = true case SCE: aacSingleChannelElement(d, ai.ObjectType) seenTerm = true - case PCE: aacProgramConfigElement(d, 0) seenTerm = true - default: fallthrough case TERM: diff --git a/format/mpeg/testdata/aac_frame.fqtest b/format/mpeg/testdata/aac_frame.fqtest index f3ec140f7..4778ee372 100644 --- a/format/mpeg/testdata/aac_frame.fqtest +++ b/format/mpeg/testdata/aac_frame.fqtest @@ -11,9 +11,11 @@ $ fq -d aac_frame dv aac_frame 0x000| 00 | . | fill_nibble: 0 0x2.3-0x2.7 (0.4) 0x000| 00 4c 61 76 63 35 38 2e 31 33 34 2e 31 30| .Lavc58.134.10| fill_byte: raw bits 0x2.7-0x11.7 (15) 0x010|30 00 |0. | - | | | [1]{}: element 0x11.7-0x12.2 (0.3) + | | | [1]{}: element 0x11.7-0x12.7 (1) 0x010| 00 42 | .B | syntax_element: "CPE" (1) 0x11.7-0x12.2 (0.3) -0x010| 42 | B | [2]: raw bits byte_align 0x12.2-0x13 (0.6) +0x010| 42 | B | element_instance_tag: 0 0x12.2-0x12.6 (0.4) +0x010| 42 | B | common_window: true 0x12.6-0x12.7 (0.1) +0x010| 42 | B | [2]: raw bits byte_align 0x12.7-0x13 (0.1) 0x010| 55 9f ff ff ff c0 01 29 68 a7 33 11 20| U......)h.3. | [3]: raw bits data 0x13-0x14d (314) 0x020|02 6a e5 c4 96 89 11 11 04 20 36 76 e1 e2 ee 35|.j....... 6v...5| * |until 0x14c.7 (end) (314) | | diff --git a/format/mpeg/testdata/adts.fqtest b/format/mpeg/testdata/adts.fqtest index c0624dd97..976f7d261 100644 --- a/format/mpeg/testdata/adts.fqtest +++ b/format/mpeg/testdata/adts.fqtest @@ -30,9 +30,11 @@ $ fq -d adts dv adts 0x000| 00 | . | fill_nibble: 0 0x9.3-0x9.7 (0.4) 0x000| 00 4c 61 76 63 35 38| .Lavc58| fill_byte: raw bits 0x9.7-0x18.7 (15) 0x010|2e 31 33 34 2e 31 30 30 00 |.134.100. | - | | | [1]{}: element 0x18.7-0x19.2 (0.3) + | | | [1]{}: element 0x18.7-0x19.7 (1) 0x010| 00 42 | .B | syntax_element: "CPE" (1) 0x18.7-0x19.2 (0.3) -0x010| 42 | B | [2]: raw bits byte_align 0x19.2-0x1a (0.6) +0x010| 42 | B | element_instance_tag: 0 0x19.2-0x19.6 (0.4) +0x010| 42 | B | common_window: true 0x19.6-0x19.7 (0.1) +0x010| 42 | B | [2]: raw bits byte_align 0x19.7-0x1a (0.1) 0x010| 55 9f ff ff ff c0| U.....| [3]: raw bits data 0x1a-0x154 (314) 0x020|01 29 68 a7 33 11 20 02 6a e5 c4 96 89 11 11 04|.)h.3. .j.......| * |until 0x153.7 (314) | | @@ -53,11 +55,12 @@ $ fq -d adts dv adts 0x150| 7f fc | .. | buffer_fullness: 2047 0x159.3-0x15a.6 (1.3) 0x150| fc | . | number_of_rdbs: 1 0x15a.6-0x15b (0.2) | | | raw_data_blocks[0:1]: 0x15b-0x2bf (356) - |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef| [0][0:3]: raw_data_block (aac_frame) 0x15b-0x2bf (356) - | | | [0]{}: element 0x15b-0x15b.3 (0.3) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef| [0][0:2]: raw_data_block (aac_frame) 0x15b-0x2bf (356) + | | | [0]{}: element 0x15b-0x15c (1) 0x150| 21 | ! | syntax_element: "CPE" (1) 0x15b-0x15b.3 (0.3) -0x150| 21 | ! | [1]: raw bits byte_align 0x15b.3-0x15c (0.5) -0x150| 4c 6c fe 07| Ll..| [2]: raw bits data 0x15c-0x2bf (355) +0x150| 21 | ! | element_instance_tag: 0 0x15b.3-0x15b.7 (0.4) +0x150| 21 | ! | common_window: true 0x15b.7-0x15c (0.1) +0x150| 4c 6c fe 07| Ll..| [1]: raw bits data 0x15c-0x2bf (355) 0x160|fc 7f c7 fc 41 db 47 ba dc 24 80 ed 57 0c ef 43|....A.G..$..W..C| * |until 0x2be.7 (355) | | |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef| [2]{}: frame (adts_frame) 0x2bf-0x407 (328) @@ -78,10 +81,11 @@ $ fq -d adts dv adts 0x2c0| 1f fc | .. | buffer_fullness: 2047 0x2c4.3-0x2c5.6 (1.3) 0x2c0| fc | . | number_of_rdbs: 1 0x2c5.6-0x2c6 (0.2) | | | raw_data_blocks[0:1]: 0x2c6-0x407 (321) - |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef| [0][0:3]: raw_data_block (aac_frame) 0x2c6-0x407 (321) - | | | [0]{}: element 0x2c6-0x2c6.3 (0.3) + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef| [0][0:2]: raw_data_block (aac_frame) 0x2c6-0x407 (321) + | | | [0]{}: element 0x2c6-0x2c7 (1) 0x2c0| 21 | ! | syntax_element: "CPE" (1) 0x2c6-0x2c6.3 (0.3) -0x2c0| 21 | ! | [1]: raw bits byte_align 0x2c6.3-0x2c7 (0.5) -0x2c0| 4c da ff c0 00 00 03 fd fa| L........| [2]: raw bits data 0x2c7-0x407 (320) +0x2c0| 21 | ! | element_instance_tag: 0 0x2c6.3-0x2c6.7 (0.4) +0x2c0| 21 | ! | common_window: true 0x2c6.7-0x2c7 (0.1) +0x2c0| 4c da ff c0 00 00 03 fd fa| L........| [1]: raw bits data 0x2c7-0x407 (320) 0x2d0|1e 87 a5 fc 68 00 23 77 a0 90 f1 ef 6d 27 b8 8e|....h.#w....m'..| * |until 0x406.7 (end) (320) | |