From 3f209c46cace4e3173e74906edcc568ecabe3f2b Mon Sep 17 00:00:00 2001 From: Martijn van Beurden Date: Thu, 18 Aug 2022 10:09:49 +0200 Subject: [PATCH] Fix decoding of FLAC raw entropy partition --- format/flac/flac.go | 3 --- format/flac/flac_frame.go | 8 +++++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/format/flac/flac.go b/format/flac/flac.go index 8e657181..ca635ae1 100644 --- a/format/flac/flac.go +++ b/format/flac/flac.go @@ -2,9 +2,6 @@ package flac // https://xiph.org/flac/format.html // https://wiki.hydrogenaud.io/index.php?title=FLAC_decoder_testbench -// TODO: -// 16 - Part 6 of Ladybug Castle (partition order 8 with escape codes) -// 32 - Part 5 of The Four of Us Are Dying (partition order 8 with escape codes) import ( "bytes" diff --git a/format/flac/flac_frame.go b/format/flac/flac_frame.go index e38487d5..683f999a 100644 --- a/format/flac/flac_frame.go +++ b/format/flac/flac_frame.go @@ -463,7 +463,13 @@ func frameDecode(d *decode.D, in interface{}) interface{} { if riceParameter == riceEscape { escapeSampleSize := int(d.FieldU5("escape_sample_size")) - d.FieldRawLen("samples", int64(count*escapeSampleSize)) + d.RangeFn(d.Pos(), int64(count*escapeSampleSize), func(d *decode.D) { + d.FieldRawLen("samples", int64(count*escapeSampleSize)) + }) + for j := 0; j < count; j++ { + samples[n] = d.S(escapeSampleSize) + n++ + } } else { samplesStart := d.Pos() for j := 0; j < count; j++ {