1
1
mirror of https://github.com/wader/fq.git synced 2024-12-12 02:22:44 +03:00
fq/format/mp3/testdata/headerfooter.fqtest
Mattias Wadman cf15661e9c mp3_frame: Add LSF support and fix incorrect main data handling
Some mpeg versions use LSF (low sampling frequency) when encoding
low sample rates which changes a bit how the side info is layed out.

Also skip trying to separate data and other_data as after reading up
a bit on how main data begin and bit reservoir works i think it was done
incorrectly. To know the real audio data length i think you need to decode
the huffman tables. Instead just have a "audio_data" field which are the
bits with audo data for current and possibly following frames.
2022-08-17 21:36:39 +02:00

184 lines
20 KiB
Plaintext

# ffmpeg -f lavfi -i sine -t 1ms -write_xing 0 -write_id3v2 4 -write_id3v1 1 -metadata title=test -f mp3 headerfooter.mp3
$ fq -d mp3 dv headerfooter.mp3
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: headerfooter.mp3 (mp3) 0x0-0x25d.7 (606)
| | | headers[0:1]: 0x0-0x3c.7 (61)
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef| [0]{}: header (id3v2) 0x0-0x3c.7 (61)
0x000|49 44 33 |ID3 | magic: "ID3" (valid) 0x0-0x2.7 (3)
0x000| 04 | . | version: 4 0x3-0x3.7 (1)
0x000| 00 | . | revision: 0 0x4-0x4.7 (1)
| | | flags{}: 0x5-0x5.7 (1)
0x000| 00 | . | unsynchronisation: false 0x5-0x5 (0.1)
0x000| 00 | . | extended_header: false 0x5.1-0x5.1 (0.1)
0x000| 00 | . | experimental_indicator: false 0x5.2-0x5.2 (0.1)
0x000| 00 | . | unused: 0 0x5.3-0x5.7 (0.5)
0x000| 00 00 00 33 | ...3 | size: 51 0x6-0x9.7 (4)
| | | frames[0:2]: 0xa-0x32.7 (41)
| | | [0]{}: frame 0xa-0x19.7 (16)
0x000| 54 49 54 32 | TIT2 | id: "TIT2" (Title/songname/content description) 0xa-0xd.7 (4)
0x000| 00 00| ..| size: 6 0xe-0x11.7 (4)
0x010|00 06 |.. |
| | | flags{}: 0x12-0x13.7 (2)
0x010| 00 | . | unused0: 0 0x12-0x12 (0.1)
0x010| 00 | . | tag_alter_preservation: false 0x12.1-0x12.1 (0.1)
0x010| 00 | . | file_alter_preservation: false 0x12.2-0x12.2 (0.1)
0x010| 00 | . | read_only: false 0x12.3-0x12.3 (0.1)
0x010| 00 00 | .. | unused1: 0 0x12.4-0x13 (0.5)
0x010| 00 | . | grouping_identity: false 0x13.1-0x13.1 (0.1)
0x010| 00 | . | unused2: 0 0x13.2-0x13.3 (0.2)
0x010| 00 | . | compression: false 0x13.4-0x13.4 (0.1)
0x010| 00 | . | encryption: false 0x13.5-0x13.5 (0.1)
0x010| 00 | . | unsync: false 0x13.6-0x13.6 (0.1)
0x010| 00 | . | data_length_indicator: false 0x13.7-0x13.7 (0.1)
0x010| 03 | . | text_encoding: "utf8" (3) 0x14-0x14.7 (1)
0x010| 74 65 73 74 00 | test. | text: "test" 0x15-0x19.7 (5)
| | | [1]{}: frame 0x1a-0x32.7 (25)
0x010| 54 53 53 45 | TSSE | id: "TSSE" (Software/Hardware and settings used for encoding) 0x1a-0x1d.7 (4)
0x010| 00 00| ..| size: 15 0x1e-0x21.7 (4)
0x020|00 0f |.. |
| | | flags{}: 0x22-0x23.7 (2)
0x020| 00 | . | unused0: 0 0x22-0x22 (0.1)
0x020| 00 | . | tag_alter_preservation: false 0x22.1-0x22.1 (0.1)
0x020| 00 | . | file_alter_preservation: false 0x22.2-0x22.2 (0.1)
0x020| 00 | . | read_only: false 0x22.3-0x22.3 (0.1)
0x020| 00 00 | .. | unused1: 0 0x22.4-0x23 (0.5)
0x020| 00 | . | grouping_identity: false 0x23.1-0x23.1 (0.1)
0x020| 00 | . | unused2: 0 0x23.2-0x23.3 (0.2)
0x020| 00 | . | compression: false 0x23.4-0x23.4 (0.1)
0x020| 00 | . | encryption: false 0x23.5-0x23.5 (0.1)
0x020| 00 | . | unsync: false 0x23.6-0x23.6 (0.1)
0x020| 00 | . | data_length_indicator: false 0x23.7-0x23.7 (0.1)
0x020| 03 | . | text_encoding: "utf8" (3) 0x24-0x24.7 (1)
0x020| 4c 61 76 66 35 38 2e 37 36 2e 31| Lavf58.76.1| text: "Lavf58.76.100" 0x25-0x32.7 (14)
0x030|30 30 00 |00. |
0x030| 00 00 00 00 00 00 00 00 00 00 | .......... | padding: raw bits (all zero) 0x33-0x3c.7 (10)
| | | frames[0:2]: 0x3d-0x1dd.7 (417)
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef| [0]{}: frame (mp3_frame) 0x3d-0x10c.7 (208)
| | | header{}: 0x3d-0x40.7 (4)
0x030| ff fb | .. | sync: 0b11111111111 (valid) 0x3d-0x3e.2 (1.3)
0x030| fb | . | mpeg_version: "1" (3) (MPEG Version 1) 0x3e.3-0x3e.4 (0.2)
0x030| fb | . | layer: 3 (1) (MPEG Layer 3) 0x3e.5-0x3e.6 (0.2)
| | | sample_count: 1152 0x3e.7-NA (0)
0x030| fb | . | protection_absent: true (No CRC) 0x3e.7-0x3e.7 (0.1)
0x030| 50| P| bitrate: 64000 (5) 0x3f-0x3f.3 (0.4)
0x030| 50| P| sample_rate: 44100 (0) 0x3f.4-0x3f.5 (0.2)
0x030| 50| P| padding: "not_padded" (0b0) 0x3f.6-0x3f.6 (0.1)
0x030| 50| P| private: 0 0x3f.7-0x3f.7 (0.1)
0x040|c4 |. | channels: "mono" (0b11) 0x40-0x40.1 (0.2)
0x040|c4 |. | channel_mode: "none" (0b0) 0x40.2-0x40.3 (0.2)
0x040|c4 |. | copyright: 0 0x40.4-0x40.4 (0.1)
0x040|c4 |. | original: 1 0x40.5-0x40.5 (0.1)
0x040|c4 |. | emphasis: "none" (0b0) 0x40.6-0x40.7 (0.2)
| | | side_info{}: 0x41-0x51.7 (17)
0x040| 00 00 | .. | main_data_begin: 0 0x41-0x42 (1.1)
0x040| 00 | . | share: 0 0x42.1-0x42.5 (0.5)
0x040| 00 09 | .. | scfsi0: 0 0x42.6-0x43.1 (0.4)
| | | granules[0:2]: 0x43.2-0x51.7 (14.6)
| | | [0][0:1]: granule 0x43.2-0x4a.4 (7.3)
| | | [0]{}: channel 0x43.2-0x4a.4 (7.3)
0x040| 09 bc | .. | part2_3_length: 623 0x43.2-0x44.5 (1.4)
0x040| bc 33 | .3 | big_values: 25 0x44.6-0x45.6 (1.1)
0x040| 33 46 | 3F | global_gain: 163 0x45.7-0x46.6 (1)
0x040| 46 47 | FG | scalefac_compress: 2 0x46.7-0x47.2 (0.4)
0x040| 47 | G | blocksplit_flag: 0 0x47.3-0x47.3 (0.1)
0x040| 47 bc | G. | table_select0: 15 0x47.4-0x48 (0.5)
0x040| bc | . | table_select1: 15 0x48.1-0x48.5 (0.5)
0x040| bc c1 | .. | table_select2: 6 0x48.6-0x49.2 (0.5)
0x040| c1 | . | region_address1: 0 0x49.3-0x49.6 (0.4)
0x040| c1 01 | .. | region_address2: 4 0x49.7-0x4a.1 (0.3)
0x040| 01 | . | preflag: 0 0x4a.2-0x4a.2 (0.1)
0x040| 01 | . | scalefac_scale: 0 0x4a.3-0x4a.3 (0.1)
0x040| 01 | . | count1table_select: 0 0x4a.4-0x4a.4 (0.1)
| | | [1][0:1]: granule 0x4a.5-0x51.7 (7.3)
| | | [0]{}: channel 0x4a.5-0x51.7 (7.3)
0x040| 01 4a 86 | .J. | part2_3_length: 661 0x4a.5-0x4c (1.4)
0x040| 86 ab | .. | big_values: 26 0x4c.1-0x4d.1 (1.1)
0x040| ab 34 | .4 | global_gain: 172 0x4d.2-0x4e.1 (1)
0x040| 34 | 4 | scalefac_compress: 13 0x4e.2-0x4e.5 (0.4)
0x040| 34 | 4 | blocksplit_flag: 0 0x4e.6-0x4e.6 (0.1)
0x040| 34 c4| 4.| table_select0: 12 0x4e.7-0x4f.3 (0.5)
0x040| c4| .| table_select1: 9 0x4f.4-0x50 (0.5)
0x050|a4 |. |
0x050|a4 |. | table_select2: 9 0x50.1-0x50.5 (0.5)
0x050|a4 c4 |.. | region_address1: 3 0x50.6-0x51.1 (0.4)
0x050| c4 | . | region_address2: 0 0x51.2-0x51.4 (0.3)
0x050| c4 | . | preflag: 1 0x51.5-0x51.5 (0.1)
0x050| c4 | . | scalefac_scale: 0 0x51.6-0x51.6 (0.1)
0x050| c4 | . | count1table_select: 0 0x51.7-0x51.7 (0.1)
0x050| 00 5a b0 55 89 9a ad 48 5b 05 b0 42 03 50| .Z.U...H[..B.P| audio_data: raw bits 0x52-0x10c.7 (187)
0x060|26 02 66 42 ce b0 b4 da 23 1a 08 10 20 84 2c 10|&.fB....#... .,.|
* |until 0x10c.7 (187) | |
| | | crc_calculated: "3c54" (raw bits) 0x10d-NA (0)
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef| [1]{}: frame (mp3_frame) 0x10d-0x1dd.7 (209)
| | | header{}: 0x10d-0x110.7 (4)
0x100| ff fb | .. | sync: 0b11111111111 (valid) 0x10d-0x10e.2 (1.3)
0x100| fb | . | mpeg_version: "1" (3) (MPEG Version 1) 0x10e.3-0x10e.4 (0.2)
0x100| fb | . | layer: 3 (1) (MPEG Layer 3) 0x10e.5-0x10e.6 (0.2)
| | | sample_count: 1152 0x10e.7-NA (0)
0x100| fb | . | protection_absent: true (No CRC) 0x10e.7-0x10e.7 (0.1)
0x100| 52| R| bitrate: 64000 (5) 0x10f-0x10f.3 (0.4)
0x100| 52| R| sample_rate: 44100 (0) 0x10f.4-0x10f.5 (0.2)
0x100| 52| R| padding: "padded" (0b1) 0x10f.6-0x10f.6 (0.1)
0x100| 52| R| private: 0 0x10f.7-0x10f.7 (0.1)
0x110|c4 |. | channels: "mono" (0b11) 0x110-0x110.1 (0.2)
0x110|c4 |. | channel_mode: "none" (0b0) 0x110.2-0x110.3 (0.2)
0x110|c4 |. | copyright: 0 0x110.4-0x110.4 (0.1)
0x110|c4 |. | original: 1 0x110.5-0x110.5 (0.1)
0x110|c4 |. | emphasis: "none" (0b0) 0x110.6-0x110.7 (0.2)
| | | side_info{}: 0x111-0x121.7 (17)
0x110| 0d 03 | .. | main_data_begin: 26 0x111-0x112 (1.1)
0x110| 03 | . | share: 0 0x112.1-0x112.5 (0.5)
0x110| 03 c0 | .. | scfsi0: 15 0x112.6-0x113.1 (0.4)
| | | granules[0:2]: 0x113.2-0x121.7 (14.6)
| | | [0][0:1]: granule 0x113.2-0x11a.4 (7.3)
| | | [0]{}: channel 0x113.2-0x11a.4 (7.3)
0x110| c0 00 | .. | part2_3_length: 0 0x113.2-0x114.5 (1.4)
0x110| 00 01 | .. | big_values: 0 0x114.6-0x115.6 (1.1)
0x110| 01 a4 | .. | global_gain: 210 0x115.7-0x116.6 (1)
0x110| a4 00 | .. | scalefac_compress: 0 0x116.7-0x117.2 (0.4)
0x110| 00 | . | blocksplit_flag: 0 0x117.3-0x117.3 (0.1)
0x110| 00 00 | .. | table_select0: 0 0x117.4-0x118 (0.5)
0x110| 00 | . | table_select1: 0 0x118.1-0x118.5 (0.5)
0x110| 00 00 | .. | table_select2: 0 0x118.6-0x119.2 (0.5)
0x110| 00 | . | region_address1: 0 0x119.3-0x119.6 (0.4)
0x110| 00 20 | . | region_address2: 0 0x119.7-0x11a.1 (0.3)
0x110| 20 | | preflag: 1 0x11a.2-0x11a.2 (0.1)
0x110| 20 | | scalefac_scale: 0 0x11a.3-0x11a.3 (0.1)
0x110| 20 | | count1table_select: 0 0x11a.4-0x11a.4 (0.1)
| | | [1][0:1]: granule 0x11a.5-0x121.7 (7.3)
| | | [0]{}: channel 0x11a.5-0x121.7 (7.3)
0x110| 20 00 00 | .. | part2_3_length: 0 0x11a.5-0x11c (1.4)
0x110| 00 34 | .4 | big_values: 0 0x11c.1-0x11d.1 (1.1)
0x110| 34 80 | 4. | global_gain: 210 0x11d.2-0x11e.1 (1)
0x110| 80 | . | scalefac_compress: 0 0x11e.2-0x11e.5 (0.4)
0x110| 80 | . | blocksplit_flag: 0 0x11e.6-0x11e.6 (0.1)
0x110| 80 00| ..| table_select0: 0 0x11e.7-0x11f.3 (0.5)
0x110| 00| .| table_select1: 0 0x11f.4-0x120 (0.5)
0x120|00 |. |
0x120|00 |. | table_select2: 0 0x120.1-0x120.5 (0.5)
0x120|00 04 |.. | region_address1: 0 0x120.6-0x121.1 (0.4)
0x120| 04 | . | region_address2: 0 0x121.2-0x121.4 (0.3)
0x120| 04 | . | preflag: 1 0x121.5-0x121.5 (0.1)
0x120| 04 | . | scalefac_scale: 0 0x121.6-0x121.6 (0.1)
0x120| 04 | . | count1table_select: 0 0x121.7-0x121.7 (0.1)
0x120| 55 55 55 55 55 55 55 55 55 55 55 55 55 55| UUUUUUUUUUUUUU| audio_data: raw bits 0x122-0x1dd.7 (188)
0x130|55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55|UUUUUUUUUUUUUUUU|
* |until 0x1dd.7 (188) | |
| | | crc_calculated: "ea58" (raw bits) 0x1de-NA (0)
| | | footers[0:1]: 0x1de-0x25d.7 (128)
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef| [0]{}: footer (id3v1) 0x1de-0x25d.7 (128)
0x1d0| 54 41| TA| magic: "TAG" (valid) 0x1de-0x1e0.7 (3)
0x1e0|47 |G |
0x1e0| 74 65 73 74 00 00 00 00 00 00 00 00 00 00 00| test...........| song_name: "test" 0x1e1-0x1fe.7 (30)
0x1f0|00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |............... |
0x1f0| 00| .| artist: "" 0x1ff-0x21c.7 (30)
0x200|00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00|................|
0x210|00 00 00 00 00 00 00 00 00 00 00 00 00 |............. |
0x210| 00 00 00| ...| album_name: "" 0x21d-0x23a.7 (30)
0x220|00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00|................|
0x230|00 00 00 00 00 00 00 00 00 00 00 |........... |
0x230| 00 00 00 00 | .... | year: "" 0x23b-0x23e.7 (4)
0x230| 00| .| comment: "" 0x23f-0x25c.7 (30)
0x240|00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00|................|
0x250|00 00 00 00 00 00 00 00 00 00 00 00 00 |............. |
0x250| ff| | .| | genre: 255 0x25d-0x25d.7 (1)