Skip to content

Commit

Permalink
scalar,mp4,gzip,tar: Add timestamp to description
Browse files Browse the repository at this point in the history
Scalar api for this needs some work
  • Loading branch information
wader committed May 7, 2022
1 parent 2b25cca commit 76161a1
Show file tree
Hide file tree
Showing 22 changed files with 135 additions and 104 deletions.
2 changes: 1 addition & 1 deletion format/gzip/gzip.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func gzDecode(d *decode.D, in interface{}) interface{} {
hasComment = d.FieldBool("comment")
d.FieldU3("reserved")
})
d.FieldU32("mtime") // TODO: unix time
d.FieldU32("mtime", scalar.DescriptionActualUUnixTime)
switch compressionMethod {
case delfateMethod:
d.FieldU8("extra_flags", deflateExtraFlagsNames)
Expand Down
2 changes: 1 addition & 1 deletion format/gzip/testdata/compressed_size.fqtest
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ $ fq -d gzip 'tobits | chunk(3) | gzip' test.gz
0x00|1f 8b |.. | identification: raw bits (valid)
0x00| 08 | . | compression_method: "deflate" (8)
0x00| 00 | . | flags{}:
0x00| 41 02 ea 5f | A.._ | mtime: 1609171521
0x00| 41 02 ea 5f | A.._ | mtime: 1609171521 (2020-12-28T16:05:21Z)
0x00| 00 | . | extra_flags: 0
0x00| 03 | . | os: "unix" (3)
0x0|74 65 73 74 0a| |test.| | uncompressed: raw bits
Expand Down
2 changes: 1 addition & 1 deletion format/gzip/testdata/test.fqtest
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ $ fq -d gzip dv /test.gz
0x00| 00 | . | name: false 0x3.3-0x3.3 (0.1)
0x00| 00 | . | comment: false 0x3.4-0x3.4 (0.1)
0x00| 00 | . | reserved: 0 0x3.5-0x3.7 (0.3)
0x00| 41 02 ea 5f | A.._ | mtime: 1609171521 0x4-0x7.7 (4)
0x00| 41 02 ea 5f | A.._ | mtime: 1609171521 (2020-12-28T16:05:21Z) 0x4-0x7.7 (4)
0x00| 00 | . | extra_flags: 0 0x8-0x8.7 (1)
0x00| 03 | . | os: "unix" (3) 0x9-0x9.7 (1)
0x0|74 65 73 74 0a| |test.| | uncompressed: raw bits 0x0-0x4.7 (5)
Expand Down
2 changes: 1 addition & 1 deletion format/json/testdata/json.fqtest
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ $ fq . /json.gz
0x00|1f 8b |.. | identification: raw bits (valid)
0x00| 08 | . | compression_method: "deflate" (8)
0x00| 00 | . | flags{}:
0x00| 65 0a 08 61 | e..a | mtime: 1627916901
0x00| 65 0a 08 61 | e..a | mtime: 1627916901 (2021-08-02T15:08:21Z)
0x00| 00 | . | extra_flags: 0
0x00| 03 | . | os: "unix" (3)
0x0|7b 22 61 22 3a 20 31 32 33 7d 0a| |{"a": 123}.| | uncompressed: {} (json)
Expand Down
10 changes: 1 addition & 9 deletions format/mp4/boxes.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,7 @@ func decodeLang(d *decode.D) string {

// Quicktime time seconds in January 1, 1904 UTC
var quicktimeEpochDate = time.Date(1904, time.January, 4, 0, 0, 0, 0, time.UTC)

var quicktimeEpoch = scalar.Fn(func(s scalar.S) (scalar.S, error) {
uv, ok := s.Actual.(uint64)
if !ok {
return s, nil
}
s.Sym = quicktimeEpochDate.Add(time.Second * time.Duration(uv)).Format(time.RFC3339)
return s, nil
})
var quicktimeEpoch = scalar.DescriptionActualUTime(quicktimeEpochDate, time.RFC3339)

func decodeFieldMatrix(d *decode.D, name string) {
d.FieldStruct(name, func(d *decode.D) {
Expand Down
12 changes: 6 additions & 6 deletions format/mp4/testdata/aac.fqtest
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ $ fq -d mp4 dv /aac.mp4
0x2a0|68 64 |hd |
0x2a0| 00 | . | version: 0 0x2a2-0x2a2.7 (1)
0x2a0| 00 00 00 | ... | flags: 0 0x2a3-0x2a5.7 (3)
0x2a0| 00 00 00 00 | .... | creation_time: "1904-01-04T00:00:00Z" (0) 0x2a6-0x2a9.7 (4)
0x2a0| 00 00 00 00 | .... | modification_time: "1904-01-04T00:00:00Z" (0) 0x2aa-0x2ad.7 (4)
0x2a0| 00 00 00 00 | .... | creation_time: 0 (1904-01-04T00:00:00Z) 0x2a6-0x2a9.7 (4)
0x2a0| 00 00 00 00 | .... | modification_time: 0 (1904-01-04T00:00:00Z) 0x2aa-0x2ad.7 (4)
0x2a0| 00 00| ..| time_scale: 1000 0x2ae-0x2b1.7 (4)
0x2b0|03 e8 |.. |
0x2b0| 00 00 00 4a | ...J | duration: 74 0x2b2-0x2b5.7 (4)
Expand Down Expand Up @@ -71,8 +71,8 @@ $ fq -d mp4 dv /aac.mp4
0x310| 74 6b 68 64 | tkhd | type: "tkhd" (Track header, overall information about the track) 0x312-0x315.7 (4)
0x310| 00 | . | version: 0 0x316-0x316.7 (1)
0x310| 00 00 03 | ... | flags: 3 0x317-0x319.7 (3)
0x310| 00 00 00 00 | .... | creation_time: "1904-01-04T00:00:00Z" (0) 0x31a-0x31d.7 (4)
0x310| 00 00| ..| modification_time: "1904-01-04T00:00:00Z" (0) 0x31e-0x321.7 (4)
0x310| 00 00 00 00 | .... | creation_time: 0 (1904-01-04T00:00:00Z) 0x31a-0x31d.7 (4)
0x310| 00 00| ..| modification_time: 0 (1904-01-04T00:00:00Z) 0x31e-0x321.7 (4)
0x320|00 00 |.. |
0x320| 00 00 00 01 | .... | track_id: 1 0x322-0x325.7 (4)
0x320| 00 00 00 00 | .... | reserved1: 0 0x326-0x329.7 (4)
Expand Down Expand Up @@ -126,8 +126,8 @@ $ fq -d mp4 dv /aac.mp4
0x390| 00 | . | version: 0 0x39e-0x39e.7 (1)
0x390| 00| .| flags: 0 0x39f-0x3a1.7 (3)
0x3a0|00 00 |.. |
0x3a0| 00 00 00 00 | .... | creation_time: "1904-01-04T00:00:00Z" (0) 0x3a2-0x3a5.7 (4)
0x3a0| 00 00 00 00 | .... | modification_time: "1904-01-04T00:00:00Z" (0) 0x3a6-0x3a9.7 (4)
0x3a0| 00 00 00 00 | .... | creation_time: 0 (1904-01-04T00:00:00Z) 0x3a2-0x3a5.7 (4)
0x3a0| 00 00 00 00 | .... | modification_time: 0 (1904-01-04T00:00:00Z) 0x3a6-0x3a9.7 (4)
0x3a0| 00 00 ac 44 | ...D | time_scale: 44100 0x3aa-0x3ad.7 (4)
0x3a0| 00 00| ..| duration: 3229 0x3ae-0x3b1.7 (4)
0x3b0|0c 9d |.. |
Expand Down
12 changes: 6 additions & 6 deletions format/mp4/testdata/av1.fqtest
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ $ fq -d mp4 dv /av1.mp4
0x11c0| 6d 76 68 64| mvhd| type: "mvhd" (Movie header, overall declarations) 0x11cc-0x11cf.7 (4)
0x11d0|00 |. | version: 0 0x11d0-0x11d0.7 (1)
0x11d0| 00 00 00 | ... | flags: 0 0x11d1-0x11d3.7 (3)
0x11d0| 00 00 00 00 | .... | creation_time: "1904-01-04T00:00:00Z" (0) 0x11d4-0x11d7.7 (4)
0x11d0| 00 00 00 00 | .... | modification_time: "1904-01-04T00:00:00Z" (0) 0x11d8-0x11db.7 (4)
0x11d0| 00 00 00 00 | .... | creation_time: 0 (1904-01-04T00:00:00Z) 0x11d4-0x11d7.7 (4)
0x11d0| 00 00 00 00 | .... | modification_time: 0 (1904-01-04T00:00:00Z) 0x11d8-0x11db.7 (4)
0x11d0| 00 00 03 e8| ....| time_scale: 1000 0x11dc-0x11df.7 (4)
0x11e0|00 00 00 28 |...( | duration: 40 0x11e0-0x11e3.7 (4)
0x11e0| 00 01 00 00 | .... | preferred_rate: 1 0x11e4-0x11e7.7 (4)
Expand Down Expand Up @@ -64,8 +64,8 @@ $ fq -d mp4 dv /av1.mp4
0x1240|74 6b 68 64 |tkhd | type: "tkhd" (Track header, overall information about the track) 0x1240-0x1243.7 (4)
0x1240| 00 | . | version: 0 0x1244-0x1244.7 (1)
0x1240| 00 00 03 | ... | flags: 3 0x1245-0x1247.7 (3)
0x1240| 00 00 00 00 | .... | creation_time: "1904-01-04T00:00:00Z" (0) 0x1248-0x124b.7 (4)
0x1240| 00 00 00 00| ....| modification_time: "1904-01-04T00:00:00Z" (0) 0x124c-0x124f.7 (4)
0x1240| 00 00 00 00 | .... | creation_time: 0 (1904-01-04T00:00:00Z) 0x1248-0x124b.7 (4)
0x1240| 00 00 00 00| ....| modification_time: 0 (1904-01-04T00:00:00Z) 0x124c-0x124f.7 (4)
0x1250|00 00 00 01 |.... | track_id: 1 0x1250-0x1253.7 (4)
0x1250| 00 00 00 00 | .... | reserved1: 0 0x1254-0x1257.7 (4)
0x1250| 00 00 00 28 | ...( | duration: 40 0x1258-0x125b.7 (4)
Expand Down Expand Up @@ -111,8 +111,8 @@ $ fq -d mp4 dv /av1.mp4
0x12c0| 6d 64 68 64 | mdhd | type: "mdhd" (Media header, overall information about the media) 0x12c8-0x12cb.7 (4)
0x12c0| 00 | . | version: 0 0x12cc-0x12cc.7 (1)
0x12c0| 00 00 00| ...| flags: 0 0x12cd-0x12cf.7 (3)
0x12d0|00 00 00 00 |.... | creation_time: "1904-01-04T00:00:00Z" (0) 0x12d0-0x12d3.7 (4)
0x12d0| 00 00 00 00 | .... | modification_time: "1904-01-04T00:00:00Z" (0) 0x12d4-0x12d7.7 (4)
0x12d0|00 00 00 00 |.... | creation_time: 0 (1904-01-04T00:00:00Z) 0x12d0-0x12d3.7 (4)
0x12d0| 00 00 00 00 | .... | modification_time: 0 (1904-01-04T00:00:00Z) 0x12d4-0x12d7.7 (4)
0x12d0| 00 00 32 00 | ..2. | time_scale: 12800 0x12d8-0x12db.7 (4)
0x12d0| 00 00 02 00| ....| duration: 512 0x12dc-0x12df.7 (4)
0x12e0|55 c4 |U. | language: "und" 0x12e0-0x12e1.7 (2)
Expand Down
12 changes: 6 additions & 6 deletions format/mp4/testdata/avc.fqtest
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ $ fq -d mp4 dv /avc.mp4
0x0d90|64 |d |
0x0d90| 00 | . | version: 0 0xd91-0xd91.7 (1)
0x0d90| 00 00 00 | ... | flags: 0 0xd92-0xd94.7 (3)
0x0d90| 00 00 00 00 | .... | creation_time: "1904-01-04T00:00:00Z" (0) 0xd95-0xd98.7 (4)
0x0d90| 00 00 00 00 | .... | modification_time: "1904-01-04T00:00:00Z" (0) 0xd99-0xd9c.7 (4)
0x0d90| 00 00 00 00 | .... | creation_time: 0 (1904-01-04T00:00:00Z) 0xd95-0xd98.7 (4)
0x0d90| 00 00 00 00 | .... | modification_time: 0 (1904-01-04T00:00:00Z) 0xd99-0xd9c.7 (4)
0x0d90| 00 00 03| ...| time_scale: 1000 0xd9d-0xda0.7 (4)
0x0da0|e8 |. |
0x0da0| 00 00 00 78 | ...x | duration: 120 0xda1-0xda4.7 (4)
Expand Down Expand Up @@ -71,8 +71,8 @@ $ fq -d mp4 dv /avc.mp4
0x0e00| 74 6b 68 64 | tkhd | type: "tkhd" (Track header, overall information about the track) 0xe01-0xe04.7 (4)
0x0e00| 00 | . | version: 0 0xe05-0xe05.7 (1)
0x0e00| 00 00 03 | ... | flags: 3 0xe06-0xe08.7 (3)
0x0e00| 00 00 00 00 | .... | creation_time: "1904-01-04T00:00:00Z" (0) 0xe09-0xe0c.7 (4)
0x0e00| 00 00 00| ...| modification_time: "1904-01-04T00:00:00Z" (0) 0xe0d-0xe10.7 (4)
0x0e00| 00 00 00 00 | .... | creation_time: 0 (1904-01-04T00:00:00Z) 0xe09-0xe0c.7 (4)
0x0e00| 00 00 00| ...| modification_time: 0 (1904-01-04T00:00:00Z) 0xe0d-0xe10.7 (4)
0x0e10|00 |. |
0x0e10| 00 00 00 01 | .... | track_id: 1 0xe11-0xe14.7 (4)
0x0e10| 00 00 00 00 | .... | reserved1: 0 0xe15-0xe18.7 (4)
Expand Down Expand Up @@ -126,8 +126,8 @@ $ fq -d mp4 dv /avc.mp4
0x0e80| 00 | . | version: 0 0xe8d-0xe8d.7 (1)
0x0e80| 00 00| ..| flags: 0 0xe8e-0xe90.7 (3)
0x0e90|00 |. |
0x0e90| 00 00 00 00 | .... | creation_time: "1904-01-04T00:00:00Z" (0) 0xe91-0xe94.7 (4)
0x0e90| 00 00 00 00 | .... | modification_time: "1904-01-04T00:00:00Z" (0) 0xe95-0xe98.7 (4)
0x0e90| 00 00 00 00 | .... | creation_time: 0 (1904-01-04T00:00:00Z) 0xe91-0xe94.7 (4)
0x0e90| 00 00 00 00 | .... | modification_time: 0 (1904-01-04T00:00:00Z) 0xe95-0xe98.7 (4)
0x0e90| 00 00 32 00 | ..2. | time_scale: 12800 0xe99-0xe9c.7 (4)
0x0e90| 00 00 06| ...| duration: 1536 0xe9d-0xea0.7 (4)
0x0ea0|00 |. |
Expand Down

0 comments on commit 76161a1

Please sign in to comment.