diff --git a/frame/frame.go b/frame/frame.go index 525fd5d..b54d1ae 100644 --- a/frame/frame.go +++ b/frame/frame.go @@ -171,7 +171,7 @@ func (frame *Frame) Hash(md5sum hash.Hash) { buf[2] = uint8(sample >> 16) md5sum.Write(buf[:]) default: - log.Printf("frame.Frame.Hash: support for %d-bit sample size not yet implemented.\n", bps) + log.Printf("frame.Frame.Hash: support for %d-bit sample size not yet implemented", bps) } } } @@ -312,12 +312,16 @@ func (frame *Frame) parseHeader() error { case 0x2: // 010: 12 bits-per-sample. frame.BitsPerSample = 12 + // TODO(u): Remove log message when the test cases have been extended. + log.Printf("frame.Frame.parseHeader: The flac library test cases do not yet include any audio files with %d bits-per-sample. If possible please consider contributing this audio sample to improve the reliability of the test cases.", frame.BitsPerSample) case 0x4: // 100: 16 bits-per-sample. frame.BitsPerSample = 16 case 0x5: // 101: 20 bits-per-sample. frame.BitsPerSample = 20 + // TODO(u): Remove log message when the test cases have been extended. + log.Printf("frame.Frame.parseHeader: The flac library test cases do not yet include any audio files with %d bits-per-sample. If possible please consider contributing this audio sample to improve the reliability of the test cases.", frame.BitsPerSample) case 0x6: // 110: 24 bits-per-sample. frame.BitsPerSample = 24 @@ -362,6 +366,8 @@ func (frame *Frame) parseHeader() error { case n == 0x1: // 0001: 192 samples. frame.BlockSize = 192 + // TODO(u): Remove log message when the test cases have been extended. + log.Printf("frame.Frame.parseHeader: The flac library test cases do not yet include any audio files with block size %d. If possible please consider contributing this audio sample to improve the reliability of the test cases.", frame.BlockSize) case n >= 0x2 && n <= 0x5: // 0010-0101: 576 * 2^(n-2) samples. frame.BlockSize = 576 * (1 << (n - 2)) @@ -412,6 +418,8 @@ func (frame *Frame) parseHeader() error { case 0x2: // 0010: 176.4 kHz. frame.SampleRate = 176400 + // TODO(u): Remove log message when the test cases have been extended. + log.Printf("frame.Frame.parseHeader: The flac library test cases do not yet include any audio files with sample rate %d. If possible please consider contributing this audio sample to improve the reliability of the test cases.", frame.SampleRate) case 0x3: // 0011: 192 kHz. frame.SampleRate = 192000 @@ -421,12 +429,16 @@ func (frame *Frame) parseHeader() error { case 0x5: // 0101: 16 kHz. frame.SampleRate = 16000 + // TODO(u): Remove log message when the test cases have been extended. + log.Printf("frame.Frame.parseHeader: The flac library test cases do not yet include any audio files with sample rate %d. If possible please consider contributing this audio sample to improve the reliability of the test cases.", frame.SampleRate) case 0x6: // 0110: 22.05 kHz. frame.SampleRate = 22050 case 0x7: // 0111: 24 kHz. frame.SampleRate = 24000 + // TODO(u): Remove log message when the test cases have been extended. + log.Printf("frame.Frame.parseHeader: The flac library test cases do not yet include any audio files with sample rate %d. If possible please consider contributing this audio sample to improve the reliability of the test cases.", frame.SampleRate) case 0x8: // 1000: 32 kHz. frame.SampleRate = 32000 @@ -446,6 +458,8 @@ func (frame *Frame) parseHeader() error { return unexpected(err) } frame.SampleRate = uint32(x * 1000) + // TODO(u): Remove log message when the test cases have been extended. + log.Printf("frame.Frame.parseHeader: The flac library test cases do not yet include any audio files with sample rate %d. If possible please consider contributing this audio sample to improve the reliability of the test cases.", frame.SampleRate) case 0xD: // 1101: get 16 bit sample rate (in Hz) from the end of the header. x, err = br.Read(16) @@ -460,6 +474,8 @@ func (frame *Frame) parseHeader() error { return unexpected(err) } frame.SampleRate = uint32(x * 10) + // TODO(u): Remove log message when the test cases have been extended. + log.Printf("frame.Frame.parseHeader: The flac library test cases do not yet include any audio files with sample rate %d. If possible please consider contributing this audio sample to improve the reliability of the test cases.", frame.SampleRate) default: // 1111: invalid. return errors.New("frame.Frame.parseHeader: invalid sample rate bit pattern (1111)") diff --git a/frame/frame_test.go b/frame/frame_test.go index 9381e17..de0c1fc 100644 --- a/frame/frame_test.go +++ b/frame/frame_test.go @@ -4,6 +4,7 @@ import ( "bytes" "crypto/md5" "io" + "log" "testing" "gopkg.in/mewkiz/flac.v1" @@ -12,29 +13,24 @@ import ( var golden = []struct { name string }{ - // i=0 - { - name: "../testdata/59996.flac", - }, - - // i=1 - { - name: "../testdata/172960.flac", - }, - - // i=2 - { - name: "../testdata/189983.flac", - }, - - // i=3 - { - name: "../testdata/love.flac", - }, + {name: "../testdata/love.flac"}, // i=0 + {name: "../testdata/19875.flac"}, // i=1 + {name: "../testdata/44127.flac"}, // i=2 + {name: "../testdata/59996.flac"}, // i=3 + {name: "../testdata/80574.flac"}, // i=4 + {name: "../testdata/172960.flac"}, // i=5 + {name: "../testdata/189983.flac"}, // i=6 + {name: "../testdata/191885.flac"}, // i=7 + {name: "../testdata/212768.flac"}, // i=8 + {name: "../testdata/220014.flac"}, // i=9 + {name: "../testdata/243749.flac"}, // i=10 + {name: "../testdata/256529.flac"}, // i=11 + {name: "../testdata/257344.flac"}, // i=12 } func TestFrameHash(t *testing.T) { for i, g := range golden { + log.Printf("i=%d: %v\n", i, g.name) stream, err := flac.ParseFile(g.name) if err != nil { t.Fatal(err) diff --git a/frame/subframe.go b/frame/subframe.go index bf144ee..af5361a 100644 --- a/frame/subframe.go +++ b/frame/subframe.go @@ -398,6 +398,8 @@ func (subframe *Subframe) decodeRicePart(br *bits.Reader, paramSize uint) error nsamples = subframe.NSamples/nparts - subframe.Order } + // TODO(u): Verify that decoding of subframes with Rice parameter escape + // codes have been implemented correctly. if paramSize == 4 && param == 0xF || paramSize == 5 && param == 0x1F { // 1111 or 11111: Escape code, meaning the partition is in unencoded // binary form using n bits per sample; n follows as a 5-bit number. @@ -413,7 +415,8 @@ func (subframe *Subframe) decodeRicePart(br *bits.Reader, paramSize uint) error } subframe.Samples = append(subframe.Samples, int32(sample)) } - log.Printf("frame.Subframe.decodeRicePart: not yet implemented; Rice parameter escape code. Please send this file to us, we would like to verify this part of the code.") + // TODO(u): Remove log message when the test cases have been extended. + log.Print("frame.Subframe.decodeRicePart: The flac library test cases do not yet include any audio files with Rice parameter escape codes. If possible please consider contributing this audio sample to improve the reliability of the test cases.") return nil } diff --git a/frame/utf8.go b/frame/utf8.go index 0ee3adf..eb10c40 100644 --- a/frame/utf8.go +++ b/frame/utf8.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "io" + "log" ) const ( @@ -92,21 +93,29 @@ func decodeUTF8Int(r io.Reader) (n uint64, err error) { // total: 21 bits (3 + 6 + 6 + 6) l = 3 n = uint64(c0 & mask4) + // TODO(u): Remove log message when the test cases have been extended. + log.Printf("frame.decodeUTF8Int: The flac library test cases do not yet include any audio files with %d UTF-8 continuation bytes. If possible please consider contributing this audio sample to improve the reliability of the test cases.", l) case c0 < t6: // if c0 == 111110xx // total: 26 bits (2 + 6 + 6 + 6 + 6) l = 4 n = uint64(c0 & mask5) + // TODO(u): Remove log message when the test cases have been extended. + log.Printf("frame.decodeUTF8Int: The flac library test cases do not yet include any audio files with %d UTF-8 continuation bytes. If possible please consider contributing this audio sample to improve the reliability of the test cases.", l) case c0 < t7: // if c0 == 1111110x // total: 31 bits (1 + 6 + 6 + 6 + 6 + 6) l = 5 n = uint64(c0 & mask6) + // TODO(u): Remove log message when the test cases have been extended. + log.Printf("frame.decodeUTF8Int: The flac library test cases do not yet include any audio files with %d UTF-8 continuation bytes. If possible please consider contributing this audio sample to improve the reliability of the test cases.", l) case c0 < t8: // if c0 == 11111110 // total: 36 bits (0 + 6 + 6 + 6 + 6 + 6 + 6) l = 6 n = 0 + // TODO(u): Remove log message when the test cases have been extended. + log.Printf("frame.decodeUTF8Int: The flac library test cases do not yet include any audio files with %d UTF-8 continuation bytes. If possible please consider contributing this audio sample to improve the reliability of the test cases.", l) } // store bits from continuation bytes. diff --git a/testdata/191885.flac b/testdata/191885.flac new file mode 100644 index 0000000..9655a82 Binary files /dev/null and b/testdata/191885.flac differ diff --git a/testdata/19875.flac b/testdata/19875.flac new file mode 100644 index 0000000..e5a2eb8 Binary files /dev/null and b/testdata/19875.flac differ diff --git a/testdata/212768.flac b/testdata/212768.flac new file mode 100644 index 0000000..67bc303 Binary files /dev/null and b/testdata/212768.flac differ diff --git a/testdata/220014.flac b/testdata/220014.flac new file mode 100644 index 0000000..94a1772 Binary files /dev/null and b/testdata/220014.flac differ diff --git a/testdata/243749.flac b/testdata/243749.flac new file mode 100644 index 0000000..fb19be0 Binary files /dev/null and b/testdata/243749.flac differ diff --git a/testdata/256529.flac b/testdata/256529.flac new file mode 100644 index 0000000..ca3dc4d Binary files /dev/null and b/testdata/256529.flac differ diff --git a/testdata/257344.flac b/testdata/257344.flac new file mode 100644 index 0000000..20b8020 Binary files /dev/null and b/testdata/257344.flac differ diff --git a/testdata/44127.flac b/testdata/44127.flac new file mode 100644 index 0000000..b104963 Binary files /dev/null and b/testdata/44127.flac differ diff --git a/testdata/80574.flac b/testdata/80574.flac new file mode 100644 index 0000000..2567e17 Binary files /dev/null and b/testdata/80574.flac differ diff --git a/testdata/README.md b/testdata/README.md index dd49981..0155d95 100644 --- a/testdata/README.md +++ b/testdata/README.md @@ -6,10 +6,28 @@ The testcase sounds have all been released into the [public domain]. The source of each sound is listed below: -* [59996.flac] -* [172960.flac] -* [189983.flac] +* [19875] +* [44127] +* [59996] +* [80574] +* [172960] +* [189983] +* [191885] +* [212768] +* [220014] +* [243749] +* [256529] +* [257344] -[59996.flac]: http://www.freesound.org/people/qubodup/sounds/59996/ -[172960.flac]: http://www.freesound.org/people/qubodup/sounds/172960/ -[189983.flac]: http://www.freesound.org/people/raygrote/sounds/189983/ +[19875]: http://freesound.org/people/yawfle/sounds/19875/ +[44127]: http://freesound.org/people/dland/sounds/44127/ +[59996]: http://freesound.org/people/qubodup/sounds/59996/ +[80574]: http://freesound.org/people/EsbenSloth/sounds/80574/ +[172960]: http://freesound.org/people/qubodup/sounds/172960/ +[189983]: http://freesound.org/people/raygrote/sounds/189983/ +[191885]: http://freesound.org/people/Hedmarking/sounds/191885/ +[212768]: http://freesound.org/people/qubodup/sounds/212768/ +[220014]: http://freesound.org/people/djani00/sounds/220014/ +[243749]: http://freesound.org/people/unfa/sounds/243749/ +[256529]: http://freesound.org/people/tymorafarr/sounds/256529/ +[257344]: http://freesound.org/people/arseniiv/sounds/257344/