Skip to content

Commit

Permalink
format: Cleanup comments
Browse files Browse the repository at this point in the history
  • Loading branch information
wader committed Sep 14, 2021
1 parent 1ccab2d commit 798141a
Show file tree
Hide file tree
Showing 23 changed files with 11 additions and 118 deletions.
2 changes: 1 addition & 1 deletion format/all/all.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Package all imports all standard formats
// Package all imports and registers all formats in the default registry
package all

import (
Expand Down
3 changes: 0 additions & 3 deletions format/flac/flac.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ package flac

// https://xiph.org/flac/format.html

// TODO: reuse samples buffer
// TODO: mime audio/x-flac

import (
"bytes"
"crypto/md5"
Expand Down
2 changes: 0 additions & 2 deletions format/flac/flac_frame.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package flac

// TODO: reuse samples buffer. pass in buf?

import (
"encoding/binary"
"fmt"
Expand Down
1 change: 0 additions & 1 deletion format/gif/gif.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package gif

// TODO: local color map
// TODO: bit depth done correct?
// TDOO: mime mage/gif

import (
"bytes"
Expand Down
1 change: 0 additions & 1 deletion format/gzip/gzip.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package gz
// https://tools.ietf.org/html/rfc1952
// TODO: test name, comment etc
// TODO: verify isize?
// TODO: mime application/gzip

import (
"bytes"
Expand Down
1 change: 0 additions & 1 deletion format/id3/id3v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/wader/fq/pkg/decode"
)

// TODO: trim strings?
// TODO: comment 28 long, zero byte, track number

func init() {
Expand Down
1 change: 0 additions & 1 deletion format/jpeg/jpeg.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package jpeg
// https://www.w3.org/Graphics/JPEG/itu-t81.pdf
// TODO: warning on junk before marker?
// TODO: extract photohop to own decoder?
// TODO: image/jpeg

import (
"bytes"
Expand Down
69 changes: 5 additions & 64 deletions format/mp4/boxes.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package mp4

// TODO: flags?

import (
"bytes"
"fmt"
Expand Down Expand Up @@ -205,7 +207,6 @@ func init() {
"tref": decodeBoxes,
"tkhd": func(ctx *decodeContext, d *decode.D) {
d.FieldU8("version")
// TODO: values
d.FieldU24("flags")
_ = decodeFieldTime(d, "creation_time")
_ = decodeFieldTime(d, "modification_time")
Expand All @@ -214,7 +215,6 @@ func init() {
d.FieldU32("duration")
d.FieldBitBufLen("reserved2", 8*8)
d.FieldU16("layer")
// TODO: values
d.FieldU16("alternate_group")
d.FieldFP16("volume")
d.FieldU16("reserved3")
Expand All @@ -232,7 +232,6 @@ func init() {
"mdia": decodeBoxes,
"mdhd": func(_ *decodeContext, d *decode.D) {
d.FieldU8("version")
// TODO: values
d.FieldU24("flags")
// TODO: timestamps
_ = decodeFieldTime(d, "creation_time")
Expand All @@ -254,7 +253,6 @@ func init() {
},
"hdlr": func(ctx *decodeContext, d *decode.D) {
d.FieldU8("version")
// TODO: values
d.FieldU24("flags")
d.FieldUTF8("component_type", 4)
subTypeNames := map[string]string{
Expand Down Expand Up @@ -306,7 +304,6 @@ func init() {
"dinf": decodeBoxes,
"dref": func(_ *decodeContext, d *decode.D) {
d.FieldU8("version")
// TODO: values
d.FieldU24("flags")
entryCount := d.FieldU32("entry_count")
var i uint64
Expand All @@ -323,7 +320,6 @@ func init() {
"stbl": decodeBoxes,
"stsd": func(ctx *decodeContext, d *decode.D) {
d.FieldU8("version")
// TODO: values
d.FieldU24("flags")
entryCount := d.FieldU32("entry_count")
var i uint64
Expand All @@ -350,24 +346,7 @@ func init() {

version := d.FieldU16("version")
d.FieldU16("revision_level")
d.FieldU32("max_packet_size") // TODO: vendor?

// "Some sample descriptions terminate with four zero bytes that are not otherwise indicated."
// uses decodeBoxes

// Timecode sample
// TODO: tc64
// d.DecodeRangeFn(firstBit, nBits, func(d *decode.D) {
// d.FieldStructFn("sample", func(d *decode.D) {
// d.FieldU32("reserved0")
// d.FieldBitBufLen("data", d.BitsLeft())
// // d.FieldU32("flags")
// // d.FieldS32("timescale")
// // d.FieldS32("frame_duration")
// // d.FieldS32("num_frames")
// // d.FieldU8("reserved1")
// })
// })
d.FieldU32("max_packet_size") // TODO: vendor for some subtype?

switch subType {
case "soun":
Expand Down Expand Up @@ -476,7 +455,6 @@ func init() {
},
"dfLa": func(ctx *decodeContext, d *decode.D) {
d.FieldU8("version")
// TODO: values
d.FieldU24("flags")
d.FieldArrayFn("metadatablocks", func(d *decode.D) {
for {
Expand Down Expand Up @@ -511,15 +489,6 @@ func init() {
"esds": func(ctx *decodeContext, d *decode.D) {
d.FieldU32("version")

// TODO: some other way to know how to decode?
// TODO: why not always? was there a reason?
// dataFormat := ""
// if ctx.currentTrack != nil && len(ctx.currentTrack.sampleDescriptions) > 0 {
// dataFormat = ctx.currentTrack.sampleDescriptions[0].dataFormat
// }

// switch dataFormat {
// case "mp4a", "mp4v":
_, v := d.FieldFormat("es_descriptor", mpegESFormat)
mpegEsOut, ok := v.(format.MpegEsOut)
if !ok {
Expand All @@ -532,15 +501,9 @@ func init() {
ctx.currentTrack.decodeOpts = append(ctx.currentTrack.decodeOpts,
decode.FormatOptions{InArg: format.AACFrameIn{ObjectType: dc.ASCObjectType}})
}

// default:
// d.FieldBitBufLen("data", d.BitsLeft())
// }

},
"stts": func(_ *decodeContext, d *decode.D) {
d.FieldU8("version")
// TODO: values
d.FieldU24("flags")
numEntries := d.FieldU32("entry_count")
var i uint64
Expand All @@ -552,7 +515,6 @@ func init() {
},
"stsc": func(ctx *decodeContext, d *decode.D) {
d.FieldU8("version")
// TODO: values
d.FieldU24("flags")
entryCount := d.FieldU32("entry_count")
var i uint64
Expand All @@ -572,7 +534,6 @@ func init() {
},
"stsz": func(ctx *decodeContext, d *decode.D) {
d.FieldU8("version")
// TODO: values
d.FieldU24("flags")
// TODO: bytes_per_sample from audio stsd?
sampleSize := d.FieldU32("sample_size")
Expand All @@ -596,7 +557,6 @@ func init() {
},
"stco": func(ctx *decodeContext, d *decode.D) {
d.FieldU8("version")
// TODO: values
d.FieldU24("flags")
entryCount := d.FieldU32("entry_count")
var i uint64
Expand Down Expand Up @@ -653,7 +613,6 @@ func init() {
// TODO: refactor: merge with stco?
"co64": func(ctx *decodeContext, d *decode.D) {
d.FieldU8("version")
// TODO: values
d.FieldU24("flags")
entryCount := d.FieldU32("entry_count")
var i uint64
Expand Down Expand Up @@ -971,7 +930,7 @@ func init() {
d.FieldU8("version")
d.FieldU24("flags")
d.FieldU1("pad")
// ISO-639-2/T as 3*5 bit intgers - 0x60
// ISO-639-2/T as 3*5 bit integers - 0x60
d.FieldStrFn("language", func() (string, string) {
s := ""
for i := 0; i < 3; i++ {
Expand Down Expand Up @@ -1170,25 +1129,7 @@ func init() {
d.FieldU24("flags")

d.FieldU32("sample_count")
// d.FieldArrayFn("samples", func(d *decode.D) {
// for i := uint64(0); i < sampleCount; i++ {
// d.FieldStructFn("sample", func(d *decode.D) {
// // TODO: IV_size?
// d.FieldBitBufLen("iv", 8*8)
// if flags&0b10 != 0 {
// subSampleCount := d.FieldU32("sub_sample_count")
// d.FieldArrayFn("subsamples", func(d *decode.D) {
// for i := uint64(0); i < subSampleCount; i++ {
// d.FieldStructFn("subsample", func(d *decode.D) {
// d.FieldU16("bytes_of_clear_data")
// d.FieldU32("bytes_fo_encrypted_data")
// })
// }
// })
// }
// })
// }
// })
// TODO need iv size here
},
"tenc": func(_ *decodeContext, d *decode.D) {
version := d.FieldU8("version")
Expand Down
2 changes: 1 addition & 1 deletion format/mp4/brands.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package mp4

// from
// from:
// https://cconcolato.github.io/mp4ra/filetype.html
// https://exiftool.org/TagNames/QuickTime.html
var brandDescriptions = map[string]string{
Expand Down
12 changes: 4 additions & 8 deletions format/mp4/mp4.go
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
package mp4

// Tries to decode both ISOBMFF and quicktime
// Tries to decode ISOBMFF quicktime mov
// Uses naming from ISOBMFF when possible
// ISO/IEC 14496-12
// Quicktime file format https://developer.apple.com/standards/qtff-2001.pdf
// FLAC in ISOBMFF https://github.com/xiph/flac/blob/master/doc/isoflac.txt
// https://www.webmproject.org/vp9/mp4/
// vp9 in ISOBMFF https://www.webmproject.org/vp9/mp4/
// https://developer.apple.com/library/archive/documentation/QuickTime/QTFF/Metadata/Metadata.html#//apple_ref/doc/uid/TP40000939-CH1-SW43

// TODO: validate structure better? trak/stco etc
// TODO: fmp4, default samples sizes etc
// TODO: keep track of structure somehow to detect errors
// TODO: ISO-14496 says mp4 mdat can begin and end with original header/trailer (no used i guess?)
// TODO: more metadata
// https://developer.apple.com/library/archive/documentation/QuickTime/QTFF/Metadata/Metadata.html#//apple_ref/doc/uid/TP40000939-CH1-SW43
// TODO: ISO-14496 says mp4 mdat can begin and end with original header/trailer (no used?)
// TODO: split into mov and mp4 decoder?
// TODO: split into mp4_box decoder? needs complex in/out args?
// TODO: fragmented: tracks per fragment? fragment_index in samples?
// TODO: better probe, find first 2 boxes, should be free,ftyp or mdat?
// TODO: mime

import (
"embed"
Expand Down
4 changes: 0 additions & 4 deletions format/mpeg/adts_frame.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package mpeg

// TODO: move aac things to mpeg?

// TODO:
// create ASC decoder
// https://github.com/mstorsjo/fdk-aac/blob/f285813ec15e7c6f8e4839c9eb4f6b0cd2da1990/libMpegTPEnc/src/tpenc_asc.cpp
// https://www.iis.fraunhofer.de/content/dam/iis/de/doc/ame/wp/FraunhoferIIS_Application-Bulletin_AAC-Transport-Formats.pdf
// https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/aac_adtstoasc_bsf.c
Expand Down
2 changes: 0 additions & 2 deletions format/mpeg/avc_dcr.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ package mpeg
// ISO/IEC 14496-15 AVC file format, 5.3.3.1.2 Syntax
// ISO_IEC_14496-10 AVC

// TODO: PPS
// TODO: use avcLevels
// TODO: nal unescape function?

import (
"github.com/wader/fq/format"
Expand Down
1 change: 0 additions & 1 deletion format/mpeg/avc_nalu.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package mpeg

// TODO: unescape configurable? merge with AVC_NAL? merge with HEVC?
// TODO: naming

import (
"github.com/wader/fq/format"
Expand Down
3 changes: 0 additions & 3 deletions format/mpeg/avc_sps.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package mpeg

// ISO/IEC 14496-15 AVC file format, 5.3.3.1.2 Syntax
// ISO_IEC_14496-10 AVC

import (
"github.com/wader/fq/format"
"github.com/wader/fq/format/registry"
Expand Down
7 changes: 0 additions & 7 deletions format/mpeg/mp3_frame.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,6 @@ func init() {
// 15: {4, 3},
// }

// func huffmanDecode(d *decode.D, table []int) {
// i := 0
// for table[i] < 0 {

// }
// }

var blockTypeNames = map[uint64]string{
0: "reserved",
1: "start block",
Expand Down
1 change: 0 additions & 1 deletion format/mpeg/mpeg_pes.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package mpeg

// TODO: probeable?
// TODO: add ts

// http://dvdnav.mplayerhq.hu/dvdinfo/mpeghdrs.html

Expand Down
2 changes: 0 additions & 2 deletions format/ogg/ogg.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package ogg

// https://xiph.org/ogg/doc/framing.html
// TODO: audio/ogg"

import (
"bytes"
Expand Down Expand Up @@ -101,7 +100,6 @@ func decodeOgg(d *decode.D, in interface{}) interface{} {
s.firstBit = d.Pos()
}

// TODO: decoder buffer api that panics?
psBytes := ps.Len() / 8

// TODO: cleanup
Expand Down
2 changes: 0 additions & 2 deletions format/ogg/ogg_page.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package ogg

// https://xiph.org/ogg/doc/framing.html

import (
"bytes"

Expand Down
1 change: 0 additions & 1 deletion format/png/png.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package png
// https://ftp-osl.osuosl.org/pub/libpng/documents/pngext-1.5.0.html
// https://wiki.mozilla.org/APNG_Specification
// TODO: color types
// TODO: image/png

import (
"hash/crc32"
Expand Down
1 change: 0 additions & 1 deletion format/tar/tar.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package tar

// https://www.gnu.org/software/tar/manual/html_node/Standard.html
// TODO: extensions?
// TODO: application/x-tar

import (
"bytes"
Expand Down
1 change: 0 additions & 1 deletion format/tiff/tiff.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package tiff

// https://www.adobe.io/content/dam/udp/en/open/standards/tiff/TIFF6.pdf
// TODO: image/tiff

import (
"github.com/wader/fq/format"
Expand Down

0 comments on commit 798141a

Please sign in to comment.