mirror of
https://github.com/wader/fq.git
synced 2024-12-23 05:13:30 +03:00
decode: Make FieldFormat usage more consistent
Will make it easier to refactor later on
This commit is contained in:
parent
ec01566fea
commit
a85da29544
@ -28,9 +28,9 @@ func metadatablocksDecode(d *decode.D, _ any) any {
|
||||
|
||||
isLastBlock := false
|
||||
for !isLastBlock {
|
||||
dv, v := d.FieldFormat("metadatablock", flacMetadatablockFormat, nil)
|
||||
_, v := d.FieldFormat("metadatablock", flacMetadatablockFormat, nil)
|
||||
flacMetadatablockOut, ok := v.(format.FlacMetadatablockOut)
|
||||
if dv != nil && !ok {
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("expected FlacMetadatablocksOut, got %#+v", flacMetadatablockOut))
|
||||
}
|
||||
isLastBlock = flacMetadatablockOut.IsLastBlock
|
||||
|
@ -441,9 +441,9 @@ func matroskaDecode(d *decode.D, _ any) any {
|
||||
})
|
||||
})
|
||||
case "A_AAC":
|
||||
dv, v := t.parentD.FieldFormatRange("value", t.codecPrivatePos, t.codecPrivateTagSize, mpegASCFrameFormat, nil)
|
||||
_, v := t.parentD.FieldFormatRange("value", t.codecPrivatePos, t.codecPrivateTagSize, mpegASCFrameFormat, nil)
|
||||
mpegASCOut, ok := v.(format.MPEGASCOut)
|
||||
if dv != nil && !ok {
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("expected mpegASCOut got %#+v", v))
|
||||
}
|
||||
//nolint:gosimple
|
||||
@ -454,9 +454,9 @@ func matroskaDecode(d *decode.D, _ any) any {
|
||||
t.parentD.RangeFn(t.codecPrivatePos, t.codecPrivateTagSize, func(d *decode.D) {
|
||||
d.FieldStruct("value", func(d *decode.D) {
|
||||
d.FieldUTF8("magic", 4, d.StrAssert("fLaC"))
|
||||
dv, v := d.FieldFormat("metadatablocks", flacMetadatablocksFormat, nil)
|
||||
_, v := d.FieldFormat("metadatablocks", flacMetadatablocksFormat, nil)
|
||||
flacMetadatablockOut, ok := v.(format.FlacMetadatablocksOut)
|
||||
if dv != nil && !ok {
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("expected FlacMetadatablockOut got %#+v", v))
|
||||
}
|
||||
if flacMetadatablockOut.HasStreamInfo {
|
||||
@ -465,16 +465,16 @@ func matroskaDecode(d *decode.D, _ any) any {
|
||||
})
|
||||
})
|
||||
case "V_MPEG4/ISO/AVC":
|
||||
dv, v := t.parentD.FieldFormatRange("value", t.codecPrivatePos, t.codecPrivateTagSize, mpegAVCDCRFormat, nil)
|
||||
_, v := t.parentD.FieldFormatRange("value", t.codecPrivatePos, t.codecPrivateTagSize, mpegAVCDCRFormat, nil)
|
||||
avcDcrOut, ok := v.(format.AvcDcrOut)
|
||||
if dv != nil && !ok {
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("expected AvcDcrOut got %#+v", v))
|
||||
}
|
||||
t.formatInArg = format.AvcAuIn{LengthSize: avcDcrOut.LengthSize} //nolint:gosimple
|
||||
case "V_MPEGH/ISO/HEVC":
|
||||
dv, v := t.parentD.FieldFormatRange("value", t.codecPrivatePos, t.codecPrivateTagSize, mpegHEVCDCRFormat, nil)
|
||||
_, v := t.parentD.FieldFormatRange("value", t.codecPrivatePos, t.codecPrivateTagSize, mpegHEVCDCRFormat, nil)
|
||||
hevcDcrOut, ok := v.(format.HevcDcrOut)
|
||||
if dv != nil && !ok {
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("expected HevcDcrOut got %#+v", v))
|
||||
}
|
||||
t.formatInArg = format.HevcAuIn{LengthSize: hevcDcrOut.LengthSize} //nolint:gosimple
|
||||
|
@ -662,18 +662,18 @@ func decodeBox(ctx *decodeContext, d *decode.D, typ string) {
|
||||
i++
|
||||
})
|
||||
case "avcC":
|
||||
dv, v := d.FieldFormat("descriptor", avcDCRFormat, nil)
|
||||
_, v := d.FieldFormat("descriptor", avcDCRFormat, nil)
|
||||
avcDcrOut, ok := v.(format.AvcDcrOut)
|
||||
if dv != nil && !ok {
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("expected AvcDcrOut got %#+v", v))
|
||||
}
|
||||
if t := ctx.currentTrack(); t != nil {
|
||||
t.formatInArg = format.AvcAuIn{LengthSize: avcDcrOut.LengthSize} //nolint:gosimple
|
||||
}
|
||||
case "hvcC":
|
||||
dv, v := d.FieldFormat("descriptor", hevcCDCRFormat, nil)
|
||||
_, v := d.FieldFormat("descriptor", hevcCDCRFormat, nil)
|
||||
hevcDcrOut, ok := v.(format.HevcDcrOut)
|
||||
if dv != nil && !ok {
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("expected HevcDcrOut got %#+v", v))
|
||||
}
|
||||
if t := ctx.currentTrack(); t != nil {
|
||||
@ -682,9 +682,9 @@ func decodeBox(ctx *decodeContext, d *decode.D, typ string) {
|
||||
case "dfLa":
|
||||
d.FieldU8("version")
|
||||
d.FieldU24("flags")
|
||||
dv, v := d.FieldFormat("descriptor", flacMetadatablocksFormat, nil)
|
||||
_, v := d.FieldFormat("descriptor", flacMetadatablocksFormat, nil)
|
||||
flacMetadatablockOut, ok := v.(format.FlacMetadatablocksOut)
|
||||
if dv != nil && !ok {
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("expected FlacMetadatablockOut got %#+v", v))
|
||||
}
|
||||
if flacMetadatablockOut.HasStreamInfo {
|
||||
@ -702,10 +702,9 @@ func decodeBox(ctx *decodeContext, d *decode.D, typ string) {
|
||||
d.FieldFormat("descriptor", vpxCCRFormat, nil)
|
||||
case "esds":
|
||||
d.FieldU32("version")
|
||||
|
||||
dv, v := d.FieldFormat("descriptor", mpegESFormat, nil)
|
||||
_, v := d.FieldFormat("descriptor", mpegESFormat, nil)
|
||||
mpegEsOut, ok := v.(format.MpegEsOut)
|
||||
if dv != nil && !ok {
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("expected mpegEsOut got %#+v", v))
|
||||
}
|
||||
|
||||
|
@ -244,9 +244,9 @@ func odDecodeTag(d *decode.D, edc *esDecodeContext, _ int, fn func(d *decode.D))
|
||||
switch format.MpegObjectTypeStreamType[objectType] {
|
||||
case format.MPEGStreamTypeAudio:
|
||||
fieldODDecodeTag(d, edc, "decoder_specific_info", -1, func(d *decode.D) {
|
||||
dv, v := d.FieldFormat("audio_specific_config", mpegASCFormat, nil)
|
||||
_, v := d.FieldFormat("audio_specific_config", mpegASCFormat, nil)
|
||||
mpegASCout, ok := v.(format.MPEGASCOut)
|
||||
if dv != nil && !ok {
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("expected MPEGASCOut got %#+v", v))
|
||||
}
|
||||
if edc.currentDecoderConfig != nil {
|
||||
|
@ -142,9 +142,9 @@ func decodeOgg(d *decode.D, _ any) any {
|
||||
d.FieldU8("minor")
|
||||
d.FieldU16("header_packets")
|
||||
d.FieldUTF8("flac_signature", 4)
|
||||
dv, v := d.FieldFormat("metadatablock", flacMetadatablockFormat, nil)
|
||||
_, v := d.FieldFormat("metadatablock", flacMetadatablockFormat, nil)
|
||||
flacMetadatablockOut, ok := v.(format.FlacMetadatablockOut)
|
||||
if dv != nil && !ok {
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("expected FlacMetadatablockOut, got %#+v", flacMetadatablockOut))
|
||||
}
|
||||
s.flacStreamInfo = flacMetadatablockOut.StreamInfo
|
||||
|
Loading…
Reference in New Issue
Block a user