1
1
mirror of https://github.com/wader/fq.git synced 2024-11-23 00:57:15 +03:00

format: Cleanup comments

This commit is contained in:
Mattias Wadman 2021-09-14 17:01:25 +02:00
parent 1ccab2da1e
commit 798141a0b0
23 changed files with 11 additions and 118 deletions

View File

@ -1,4 +1,4 @@
// Package all imports all standard formats
// Package all imports and registers all formats in the default registry
package all
import (

View File

@ -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"

View File

@ -1,7 +1,5 @@
package flac
// TODO: reuse samples buffer. pass in buf?
import (
"encoding/binary"
"fmt"

View File

@ -6,7 +6,6 @@ package gif
// TODO: local color map
// TODO: bit depth done correct?
// TDOO: mime mage/gif
import (
"bytes"

View File

@ -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"

View File

@ -8,7 +8,6 @@ import (
"github.com/wader/fq/pkg/decode"
)
// TODO: trim strings?
// TODO: comment 28 long, zero byte, track number
func init() {

View File

@ -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"

View File

@ -1,5 +1,7 @@
package mp4
// TODO: flags?
import (
"bytes"
"fmt"
@ -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")
@ -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")
@ -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")
@ -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{
@ -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
@ -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
@ -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":
@ -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 {
@ -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 {
@ -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
@ -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
@ -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")
@ -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
@ -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
@ -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++ {
@ -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")

View File

@ -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{

View File

@ -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"

View File

@ -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

View File

@ -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"

View File

@ -1,7 +1,6 @@
package mpeg
// TODO: unescape configurable? merge with AVC_NAL? merge with HEVC?
// TODO: naming
import (
"github.com/wader/fq/format"

View File

@ -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"

View File

@ -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",

View File

@ -1,7 +1,6 @@
package mpeg
// TODO: probeable?
// TODO: add ts
// http://dvdnav.mplayerhq.hu/dvdinfo/mpeghdrs.html

View File

@ -1,7 +1,6 @@
package ogg
// https://xiph.org/ogg/doc/framing.html
// TODO: audio/ogg"
import (
"bytes"
@ -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

View File

@ -1,7 +1,5 @@
package ogg
// https://xiph.org/ogg/doc/framing.html
import (
"bytes"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -91,10 +91,6 @@ func vorbisDecode(d *decode.D, in interface{}) interface{} {
// TODO: warning if not 64-8192
d.FieldValidateZeroPadding("padding0", 7)
d.FieldValidateUFn("framing_flag", 1, d.U1)
// if d.BitsLeft() > 0 {
// d.FieldValidateZeroPadding("padding1", int(d.BitsLeft()))
// }
case packetTypeSetup:
d.FieldUFn("vorbis_codebook_count", func() (uint64, decode.DisplayFormat, string) {
return d.U8() + 1, decode.NumberDecimal, ""
@ -123,16 +119,11 @@ func vorbisDecode(d *decode.D, in interface{}) interface{} {
// }
case packetTypeComment:
// TODO: should not be try, FieldFormat?
d.FieldFormat("comment", vorbisComment)
// note this uses vorbis bitpacking convention, bits are added LSB first per byte
d.FieldValidateZeroPadding("padding0", 7)
d.FieldValidateUFn("frame_bit", 1, d.U1)
// if d.BitsLeft() > 0 {
// d.FieldValidateZeroPadding("padding1", int(d.BitsLeft()))
// }
}
return nil

View File

@ -1,7 +1,6 @@
package webp
// https://developers.google.com/speed/webp/docs/riff_container
// TODO: image/webp
import (
"bytes"