1
1
mirror of https://github.com/wader/fq.git synced 2024-09-11 20:07:11 +03:00

Merge pull request #816 from wader/riff-trim-id

webp,avi,wav,aiff: Trim RIFF id string
This commit is contained in:
Mattias Wadman 2023-11-25 15:23:53 +01:00 committed by GitHub
commit 1bdcafe060
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 12 additions and 12 deletions

View File

@ -38,7 +38,7 @@ func aiffDecode(d *decode.D) any {
d,
nil,
func(d *decode.D, path path) (string, int64) {
id := d.FieldUTF8("id", 4, chunkIDDescriptions)
id := d.FieldUTF8("id", 4, scalar.ActualTrimSpace, chunkIDDescriptions)
const restOfFileLen = 0xffffffff
size := int64(d.FieldScalarUintFn("size", func(d *decode.D) scalar.Uint {

View File

@ -233,7 +233,7 @@ func aviDecodeEx(d *decode.D, ai format.AVI_In, extendedChunk bool) {
d,
nil,
func(d *decode.D, path path) (string, int64) {
id := d.FieldUTF8("id", 4, chunkIDDescriptions)
id := d.FieldUTF8("id", 4, scalar.ActualTrimSpace, chunkIDDescriptions)
aviDecorateStreamID(d, id)
size := d.FieldU32("size")
return id, int64(size)

View File

@ -6,7 +6,7 @@ $ fq -d webp dv 4x4.webp
0x00| 57 45 42 50 | WEBP | format: "WEBP" (valid) 0x8-0xc (4)
| | | chunks[0:1]: 0xc-0x2c (32)
| | | [0]{}: chunk 0xc-0x2c (32)
0x00| 56 50 38 20| VP8 | id: "VP8 " 0xc-0x10 (4)
0x00| 56 50 38 20| VP8 | id: "VP8" 0xc-0x10 (4)
0x10|18 00 00 00 |.... | size: 24 0x10-0x14 (4)
| | | tag{}: 0x14-0x17 (3)
0x10| 30 | 0 | first_part_size0: 1 0x14-0x14.3 (0.3)

View File

@ -6,7 +6,7 @@ $ fq -d wav dv end-of-file.wav
0x000| 57 41 56 45 | WAVE | format: "WAVE" (valid) 0x8-0xc (4)
| | | chunks[0:3]: 0xc-0x732 (1830)
| | | [0]{}: chunk 0xc-0x24 (24)
0x000| 66 6d 74 20| fmt | id: "fmt " 0xc-0x10 (4)
0x000| 66 6d 74 20| fmt | id: "fmt" 0xc-0x10 (4)
0x010|10 00 00 00 |.... | size: 16 0x10-0x14 (4)
0x010| 01 00 | .. | audio_format: "pcm_s16le" (1) 0x14-0x16 (2)
0x010| 02 00 | .. | num_channels: 2 0x16-0x18 (2)

View File

@ -6,7 +6,7 @@ $ fq -d wav dv stereo.wav
0x000| 57 41 56 45 | WAVE | format: "WAVE" (valid) 0x8-0xc (4)
| | | chunks[0:3]: 0xc-0x732 (1830)
| | | [0]{}: chunk 0xc-0x24 (24)
0x000| 66 6d 74 20| fmt | id: "fmt " 0xc-0x10 (4)
0x000| 66 6d 74 20| fmt | id: "fmt" 0xc-0x10 (4)
0x010|10 00 00 00 |.... | size: 16 0x10-0x14 (4)
0x010| 01 00 | .. | audio_format: "pcm_s16le" (1) 0x14-0x16 (2)
0x010| 02 00 | .. | num_channels: 2 0x16-0x18 (2)

View File

@ -19,7 +19,7 @@ $ fq -d webp dv xmp_exif.webp
0x010| 03 00 00 | ... | width: 4 0x18-0x1b (3)
0x010| 03 00 00 | ... | height: 4 0x1b-0x1e (3)
| | | [1]{}: chunk 0x1e-0x3e (32)
0x010| 56 50| VP| id: "VP8 " 0x1e-0x22 (4)
0x010| 56 50| VP| id: "VP8" 0x1e-0x22 (4)
0x020|38 20 |8 |
0x020| 18 00 00 00 | .... | size: 24 0x22-0x26 (4)
| | | tag{}: 0x26-0x29 (3)
@ -152,7 +152,7 @@ $ fq -d webp dv xmp_exif.webp
0x100|00 00 |.. |
0x0a0|00 00 00 00 |.... | next_ifd: 0x0 0xa0-0xa4 (4)
| | | [3]{}: chunk 0x102-0xd02 (3072)
0x100| 58 4d 50 20 | XMP | id: "XMP " 0x102-0x106 (4)
0x100| 58 4d 50 20 | XMP | id: "XMP" 0x102-0x106 (4)
0x100| f7 0b 00 00 | .... | size: 3063 0x106-0x10a (4)
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
0x100| 3c 3f 78 70 61 63| <?xpac| data: {} (xml) 0x10a-0xd01 (3063)

View File

@ -59,7 +59,7 @@ func wavDecode(d *decode.D) any {
d,
nil,
func(d *decode.D, path path) (string, int64) {
id := d.FieldUTF8("id", 4, chunkIDDescriptions)
id := d.FieldUTF8("id", 4, scalar.ActualTrimSpace, chunkIDDescriptions)
const restOfFileLen = 0xffffffff
size := int64(d.FieldScalarUintFn("size", func(d *decode.D) scalar.Uint {
@ -86,7 +86,7 @@ func wavDecode(d *decode.D) any {
d.FieldUTF8("type", 4)
return true, nil
case "fmt ":
case "fmt":
audioFormat := d.FieldU16("audio_format", format.WAVTagNames)
d.FieldU16("num_channels")
d.FieldU32("sample_rate")

View File

@ -40,7 +40,7 @@ func webpDecode(d *decode.D) any {
d,
nil,
func(d *decode.D, path path) (string, int64) {
id := d.FieldUTF8("id", 4, chunkIDDescriptions)
id := d.FieldUTF8("id", 4, scalar.ActualTrimSpace, chunkIDDescriptions)
size := d.FieldU32("size")
return id, int64(size)
},
@ -49,7 +49,7 @@ func webpDecode(d *decode.D) any {
case "RIFF":
riffType = d.FieldUTF8("format", 4, d.StrAssert(webpRiffType))
return true, nil
case "VP8 ":
case "VP8":
d.Format(&vp8FrameGroup, nil)
return false, nil
case "VP8X":
@ -76,7 +76,7 @@ func webpDecode(d *decode.D) any {
case "ICCP":
d.Format(&iccpGroup, nil)
return false, nil
case "XMP ":
case "XMP":
d.FieldFormatOrRawLen("data", d.BitsLeft(), &xmlGroup, nil)
return false, nil
default: