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