mirror of
https://github.com/wader/fq.git
synced 2024-12-23 13:22:58 +03:00
format: Some claeanup
This commit is contained in:
parent
527f917698
commit
d1b514edeb
@ -28,9 +28,9 @@ func metadatablocksDecode(d *decode.D, in interface{}) interface{} {
|
|||||||
|
|
||||||
isLastBlock := false
|
isLastBlock := false
|
||||||
for !isLastBlock {
|
for !isLastBlock {
|
||||||
v, dv := d.FieldFormat("metadatablock", flacMetadatablockForamt, nil)
|
dv, v := d.FieldFormat("metadatablock", flacMetadatablockForamt, nil)
|
||||||
flacMetadatablockOut, ok := dv.(format.FlacMetadatablockOut)
|
flacMetadatablockOut, ok := v.(format.FlacMetadatablockOut)
|
||||||
if v != nil && !ok {
|
if dv != nil && !ok {
|
||||||
panic(fmt.Sprintf("expected FlacMetadatablocksOut, got %#+v", flacMetadatablockOut))
|
panic(fmt.Sprintf("expected FlacMetadatablocksOut, got %#+v", flacMetadatablockOut))
|
||||||
}
|
}
|
||||||
isLastBlock = flacMetadatablockOut.IsLastBlock
|
isLastBlock = flacMetadatablockOut.IsLastBlock
|
||||||
|
@ -360,9 +360,9 @@ func matroskaDecode(d *decode.D, in interface{}) interface{} {
|
|||||||
t.parentD.RangeFn(t.codecPrivatePos, t.codecPrivateTagSize, func(d *decode.D) {
|
t.parentD.RangeFn(t.codecPrivatePos, t.codecPrivateTagSize, func(d *decode.D) {
|
||||||
d.FieldStruct("value", func(d *decode.D) {
|
d.FieldStruct("value", func(d *decode.D) {
|
||||||
d.FieldUTF8("magic", 4, d.AssertStr("fLaC"))
|
d.FieldUTF8("magic", 4, d.AssertStr("fLaC"))
|
||||||
v, dv := d.FieldFormat("metadatablocks", flacMetadatablocksFormat, nil)
|
dv, v := d.FieldFormat("metadatablocks", flacMetadatablocksFormat, nil)
|
||||||
flacMetadatablockOut, ok := dv.(format.FlacMetadatablocksOut)
|
flacMetadatablockOut, ok := v.(format.FlacMetadatablocksOut)
|
||||||
if v != nil && !ok {
|
if dv != nil && !ok {
|
||||||
panic(fmt.Sprintf("expected FlacMetadatablockOut got %#+v", v))
|
panic(fmt.Sprintf("expected FlacMetadatablockOut got %#+v", v))
|
||||||
}
|
}
|
||||||
if flacMetadatablockOut.HasStreamInfo {
|
if flacMetadatablockOut.HasStreamInfo {
|
||||||
@ -371,16 +371,16 @@ func matroskaDecode(d *decode.D, in interface{}) interface{} {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
case "V_MPEG4/ISO/AVC":
|
case "V_MPEG4/ISO/AVC":
|
||||||
v, dv := t.parentD.FieldFormatRange("value", t.codecPrivatePos, t.codecPrivateTagSize, mpegAVCDCRFormat, nil)
|
dv, v := t.parentD.FieldFormatRange("value", t.codecPrivatePos, t.codecPrivateTagSize, mpegAVCDCRFormat, nil)
|
||||||
avcDcrOut, ok := dv.(format.AvcDcrOut)
|
avcDcrOut, ok := v.(format.AvcDcrOut)
|
||||||
if v != nil && !ok {
|
if dv != nil && !ok {
|
||||||
panic(fmt.Sprintf("expected AvcDcrOut got %#+v", v))
|
panic(fmt.Sprintf("expected AvcDcrOut got %#+v", v))
|
||||||
}
|
}
|
||||||
t.formatInArg = format.AvcIn{LengthSize: avcDcrOut.LengthSize} //nolint:gosimple
|
t.formatInArg = format.AvcIn{LengthSize: avcDcrOut.LengthSize} //nolint:gosimple
|
||||||
case "V_MPEGH/ISO/HEVC":
|
case "V_MPEGH/ISO/HEVC":
|
||||||
v, dv := t.parentD.FieldFormatRange("value", t.codecPrivatePos, t.codecPrivateTagSize, mpegHEVCDCRFormat, nil)
|
dv, v := t.parentD.FieldFormatRange("value", t.codecPrivatePos, t.codecPrivateTagSize, mpegHEVCDCRFormat, nil)
|
||||||
hevcDcrOut, ok := dv.(format.HevcDcrOut)
|
hevcDcrOut, ok := v.(format.HevcDcrOut)
|
||||||
if v != nil && !ok {
|
if dv != nil && !ok {
|
||||||
panic(fmt.Sprintf("expected HevcDcrOut got %#+v", v))
|
panic(fmt.Sprintf("expected HevcDcrOut got %#+v", v))
|
||||||
}
|
}
|
||||||
t.formatInArg = format.HevcIn{LengthSize: hevcDcrOut.LengthSize} //nolint:gosimple
|
t.formatInArg = format.HevcIn{LengthSize: hevcDcrOut.LengthSize} //nolint:gosimple
|
||||||
|
@ -23,11 +23,14 @@ func init() {
|
|||||||
DecodeFn: mp3Decode,
|
DecodeFn: mp3Decode,
|
||||||
Dependencies: []decode.Dependency{
|
Dependencies: []decode.Dependency{
|
||||||
{Names: []string{format.ID3V2}, Group: &headerFormat},
|
{Names: []string{format.ID3V2}, Group: &headerFormat},
|
||||||
{Names: []string{
|
{
|
||||||
format.ID3V1,
|
Names: []string{
|
||||||
format.ID3V11,
|
format.ID3V1,
|
||||||
format.APEV2,
|
format.ID3V11,
|
||||||
}, Group: &footerFormat},
|
format.APEV2,
|
||||||
|
},
|
||||||
|
Group: &footerFormat,
|
||||||
|
},
|
||||||
{Names: []string{format.MP3_FRAME}, Group: &mp3Frame},
|
{Names: []string{format.MP3_FRAME}, Group: &mp3Frame},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -431,9 +431,9 @@ func init() {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
"avcC": func(ctx *decodeContext, d *decode.D) {
|
"avcC": func(ctx *decodeContext, d *decode.D) {
|
||||||
v, dv := d.FieldFormat("descriptor", mpegAVCDCRFormat, nil)
|
dv, v := d.FieldFormat("descriptor", mpegAVCDCRFormat, nil)
|
||||||
avcDcrOut, ok := dv.(format.AvcDcrOut)
|
avcDcrOut, ok := v.(format.AvcDcrOut)
|
||||||
if v != nil && !ok {
|
if dv != nil && !ok {
|
||||||
panic(fmt.Sprintf("expected AvcDcrOut got %#+v", v))
|
panic(fmt.Sprintf("expected AvcDcrOut got %#+v", v))
|
||||||
}
|
}
|
||||||
if ctx.currentTrack != nil {
|
if ctx.currentTrack != nil {
|
||||||
@ -441,9 +441,9 @@ func init() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"hvcC": func(ctx *decodeContext, d *decode.D) {
|
"hvcC": func(ctx *decodeContext, d *decode.D) {
|
||||||
v, dv := d.FieldFormat("descriptor", mpegHEVCDCRFrameFormat, nil)
|
dv, v := d.FieldFormat("descriptor", mpegHEVCDCRFrameFormat, nil)
|
||||||
hevcDcrOut, ok := dv.(format.HevcDcrOut)
|
hevcDcrOut, ok := v.(format.HevcDcrOut)
|
||||||
if v != nil && !ok {
|
if dv != nil && !ok {
|
||||||
panic(fmt.Sprintf("expected HevcDcrOut got %#+v", v))
|
panic(fmt.Sprintf("expected HevcDcrOut got %#+v", v))
|
||||||
}
|
}
|
||||||
if ctx.currentTrack != nil {
|
if ctx.currentTrack != nil {
|
||||||
@ -453,9 +453,9 @@ func init() {
|
|||||||
"dfLa": func(ctx *decodeContext, d *decode.D) {
|
"dfLa": func(ctx *decodeContext, d *decode.D) {
|
||||||
d.FieldU8("version")
|
d.FieldU8("version")
|
||||||
d.FieldU24("flags")
|
d.FieldU24("flags")
|
||||||
v, dv := d.FieldFormat("descriptor", flacMetadatablocksFormat, nil)
|
dv, v := d.FieldFormat("descriptor", flacMetadatablocksFormat, nil)
|
||||||
flacMetadatablockOut, ok := dv.(format.FlacMetadatablocksOut)
|
flacMetadatablockOut, ok := v.(format.FlacMetadatablocksOut)
|
||||||
if v != nil && !ok {
|
if dv != nil && !ok {
|
||||||
panic(fmt.Sprintf("expected FlacMetadatablockOut got %#+v", v))
|
panic(fmt.Sprintf("expected FlacMetadatablockOut got %#+v", v))
|
||||||
}
|
}
|
||||||
if flacMetadatablockOut.HasStreamInfo {
|
if flacMetadatablockOut.HasStreamInfo {
|
||||||
@ -478,9 +478,9 @@ func init() {
|
|||||||
"esds": func(ctx *decodeContext, d *decode.D) {
|
"esds": func(ctx *decodeContext, d *decode.D) {
|
||||||
d.FieldU32("version")
|
d.FieldU32("version")
|
||||||
|
|
||||||
v, dv := d.FieldFormat("descriptor", mpegESFormat, nil)
|
dv, v := d.FieldFormat("descriptor", mpegESFormat, nil)
|
||||||
mpegEsOut, ok := dv.(format.MpegEsOut)
|
mpegEsOut, ok := v.(format.MpegEsOut)
|
||||||
if v != nil && !ok {
|
if dv != nil && !ok {
|
||||||
panic(fmt.Sprintf("expected mpegEsOut got %#+v", v))
|
panic(fmt.Sprintf("expected mpegEsOut got %#+v", v))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,9 +242,9 @@ func odDecodeTag(d *decode.D, edc *esDecodeContext, expectedTagID int, fn func(d
|
|||||||
switch format.MpegObjectTypeStreamType[objectType] {
|
switch format.MpegObjectTypeStreamType[objectType] {
|
||||||
case format.MPEGStreamTypeAudio:
|
case format.MPEGStreamTypeAudio:
|
||||||
fieldODDecodeTag(d, edc, "decoder_specific_info", -1, func(d *decode.D) {
|
fieldODDecodeTag(d, edc, "decoder_specific_info", -1, func(d *decode.D) {
|
||||||
v, dv := d.FieldFormat("audio_specific_config", mpegASCFormat, nil)
|
dv, v := d.FieldFormat("audio_specific_config", mpegASCFormat, nil)
|
||||||
mpegASCout, ok := dv.(format.MPEGASCOut)
|
mpegASCout, ok := v.(format.MPEGASCOut)
|
||||||
if v != nil && !ok {
|
if dv != nil && !ok {
|
||||||
panic(fmt.Sprintf("expected MPEGASCOut got %#+v", v))
|
panic(fmt.Sprintf("expected MPEGASCOut got %#+v", v))
|
||||||
}
|
}
|
||||||
if edc.currentDecoderConfig != nil {
|
if edc.currentDecoderConfig != nil {
|
||||||
|
@ -137,7 +137,6 @@ func pesPacketDecode(d *decode.D, in interface{}) interface{} {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
case startCode >= 0xbd:
|
case startCode >= 0xbd:
|
||||||
//log.Printf("startCode: %#+v\n", startCode)
|
|
||||||
length := d.FieldU16("length")
|
length := d.FieldU16("length")
|
||||||
// 0xbd-0xbd // Privatestream1
|
// 0xbd-0xbd // Privatestream1
|
||||||
// 0xc0-0xdf // MPEG1OrMPEG2AudioStream
|
// 0xc0-0xdf // MPEG1OrMPEG2AudioStream
|
||||||
|
@ -49,6 +49,7 @@ var commandNames = decode.UToStr{
|
|||||||
func rleValue(d *decode.D) (uint64, uint64, int) {
|
func rleValue(d *decode.D) (uint64, uint64, int) {
|
||||||
p := uint(d.PeekBits(8))
|
p := uint(d.PeekBits(8))
|
||||||
|
|
||||||
|
// match zero prefix
|
||||||
switch {
|
switch {
|
||||||
case p&0b1111_1100 == 0:
|
case p&0b1111_1100 == 0:
|
||||||
// 000000nnnnnnnncc
|
// 000000nnnnnnnncc
|
||||||
@ -80,17 +81,12 @@ func decodeLines(d *decode.D, lines int, width int) []string { //nolint:unparam
|
|||||||
pixel = fmt.Sprintf("%d", c)
|
pixel = fmt.Sprintf("%d", c)
|
||||||
}
|
}
|
||||||
|
|
||||||
//log.Printf("n=%d c=%d b=%d\n", n, c, b)
|
|
||||||
|
|
||||||
if n == 0 && b == 16 {
|
if n == 0 && b == 16 {
|
||||||
l += strings.Repeat(pixel, width-len(l))
|
l += strings.Repeat(pixel, width-len(l))
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
x += int(n)
|
x += int(n)
|
||||||
|
|
||||||
//log.Printf("n: %d c %d b %d\n", n, c, b)
|
|
||||||
// l += strings.Repeat(pixel, int(n))
|
|
||||||
}
|
}
|
||||||
if d.ByteAlignBits() > 0 {
|
if d.ByteAlignBits() > 0 {
|
||||||
d.U(d.ByteAlignBits())
|
d.U(d.ByteAlignBits())
|
||||||
|
@ -147,9 +147,9 @@ func decodeOgg(d *decode.D, in interface{}) interface{} {
|
|||||||
d.FieldU8("minor")
|
d.FieldU8("minor")
|
||||||
d.FieldU16("header_packets")
|
d.FieldU16("header_packets")
|
||||||
d.FieldUTF8("flac_signature", 4)
|
d.FieldUTF8("flac_signature", 4)
|
||||||
v, dv := d.FieldFormat("metadatablock", flacMetadatablockFormat, nil)
|
dv, v := d.FieldFormat("metadatablock", flacMetadatablockFormat, nil)
|
||||||
flacMetadatablockOut, ok := dv.(format.FlacMetadatablockOut)
|
flacMetadatablockOut, ok := v.(format.FlacMetadatablockOut)
|
||||||
if v != nil && !ok {
|
if dv != nil && !ok {
|
||||||
panic(fmt.Sprintf("expected FlacMetadatablockOut, got %#+v", flacMetadatablockOut))
|
panic(fmt.Sprintf("expected FlacMetadatablockOut, got %#+v", flacMetadatablockOut))
|
||||||
}
|
}
|
||||||
s.flacStreamInfo = flacMetadatablockOut.StreamInfo
|
s.flacStreamInfo = flacMetadatablockOut.StreamInfo
|
||||||
@ -158,8 +158,6 @@ func decodeOgg(d *decode.D, in interface{}) interface{} {
|
|||||||
s.packetD.FieldFormatBitBuf("packet", bb, flacFrameFormat, nil)
|
s.packetD.FieldFormatBitBuf("packet", bb, flacFrameFormat, nil)
|
||||||
default:
|
default:
|
||||||
s.packetD.FieldFormatBitBuf("packet", bb, flacMetadatablockFormat, nil)
|
s.packetD.FieldFormatBitBuf("packet", bb, flacMetadatablockFormat, nil)
|
||||||
|
|
||||||
//d.Format(flacFrame, nil)
|
|
||||||
}
|
}
|
||||||
case codecUnknown:
|
case codecUnknown:
|
||||||
s.packetD.FieldRootBitBuf("packet", bb)
|
s.packetD.FieldRootBitBuf("packet", bb)
|
||||||
|
Loading…
Reference in New Issue
Block a user