Commit graph

62 commits

Author SHA1 Message Date
DataHoarder 42f940f815
Update module url 2022-07-26 16:14:37 +02:00
Henry Eklind 11466d8af8
Absolute seek (#46)
* frame: Add frame.SampleNumber()

* flac/seek: Make stream.Seek seek to absolute sample numbers

* seek/test: Update test case for absolute seeking

* Update flac.go

Co-authored-by: Robin <mewmew@users.noreply.github.com>

* Update flac.go

Co-authored-by: Robin <mewmew@users.noreply.github.com>

* Update flac.go

Co-authored-by: Robin <mewmew@users.noreply.github.com>

* Update flac.go

Co-authored-by: Robin <mewmew@users.noreply.github.com>

* Update flac_test.go

Co-authored-by: Robin <mewmew@users.noreply.github.com>

* Update frame/frame.go

Co-authored-by: Robin <mewmew@users.noreply.github.com>

* flac: Improve code styling

* flac: Add ErrNoSeeker documentation comment

* flac: Make searchFromStart return an error instead of panic

* Update flac.go

Co-authored-by: Robin <mewmew@users.noreply.github.com>

* Update flac.go

Co-authored-by: Robin <mewmew@users.noreply.github.com>

Co-authored-by: Robin <mewmew@users.noreply.github.com>
2021-01-28 00:23:27 +01:00
Robin Eklind 3e3f4b5fcf
flac: add Encoder API to encode audio samples and metadata blocks (#32)
* flac: encode frame header

* flac: calculate CRC-8 when encoding frame headers

* flac: fix encoding of frame header

* flac: add preliminary subframe encoder

* flac: fix UTF-8 encoding of frame number

* frame: add sanity check for sample count in decodeLPC

Updates #31.

* flac: update flac encoding API, depricate flac.Encode

Encode has been removed in favour of using NewEncoder.
The Encode function was temporarily added to support
re-encoding FLAC streams to update the metadata, but
it had no support for encoding audio samples.

The added flac.Encoder has support for encoding both
metadata and audio samples. It also does not require
that you first decode a FLAC file to later re-encode
it by calling Encode (as was the previous behaviour).

* flac: add MD5 running hash of unencoded audio samples to StreamInfo

* flac: remove unused encodePadding

Reported by golangci

* flac: fix golangci lint issues

	frame/utf8.go:57:6: `decodeUTF8Int` is unused (deadcode)
	func decodeUTF8Int(r io.Reader) (n uint64, err error) {
		  ^
	internal/utf8/encode.go:32:16: unnecessary conversion (unconvert)
			bits = uint64(t2 | (x>>6)&mask2)
							 ^
	internal/utf8/encode.go:37:16: unnecessary conversion (unconvert)
			bits = uint64(t3 | (x>>(6*2))&mask3)
							 ^
	internal/utf8/encode.go:42:16: unnecessary conversion (unconvert)
			bits = uint64(t4 | (x>>(6*3))&mask4)
							 ^

* flac: fix golangci lint issues

	encode_frame.go:89:1: cyclomatic complexity 52 of func `(*Encoder).encodeFrameHeader` is high (> 30) (gocyclo)
	func (enc *Encoder) encodeFrameHeader(w io.Writer, hdr frame.Header) error {
	^
	internal/utf8/encode.go:66:17: unnecessary conversion (unconvert)
			bits := uint64(tx | (x>>uint(6*i))&maskx)
							  ^
	encode_subframe.go:105:46: unnecessary conversion (unconvert)
			if err := bw.WriteBits(uint64(sample), byte(hdr.BitsPerSample)); err != nil {
																	 ^

* flac: clarify that frame.Header.Num is calculated by the encoder

* flac: minor re-phrasing
2018-08-19 03:18:12 +09:00
mewmew 8c556856f4 frame: make CRC mismatch warnings instead of fatal errors
Updates #31.
2018-08-19 03:50:28 +09:00
mewmew 46e9cd6b14 frame: simplify parseHeader by refactoring
Fixes lint issue reported by gocyclo:

frame/frame.go:212:1: cyclomatic complexity 52 of func `(*Frame).parseHeader` is high (> 30) (gocyclo)
func (frame *Frame) parseHeader() error {
^

Updates #25.
2018-05-27 15:10:15 +02:00
mewmew e8384a1c1b frame: use exclusion regexp instead of _ to skip error check of md5sum.Write and md5 import
golangci-lint run --enable-all -e "(Error return value of .md5sum\.Write. is not checked)"
2018-05-27 14:39:47 +02:00
mewmew 95b4b1d046 flac: fix issues reported by errcheck and unconvert
enc.go:178:35: unnecessary conversion (unconvert)
	if err := enc.bw.WriteBits(uint64(si.NSamples), 36); err != nil {
	                                 ^
enc.go:543:34: unnecessary conversion (unconvert)
	if _, err := enc.bw.Write([]byte(pic.Data)); err != nil {
	                                ^

frame/frame.go:161:17: Error return value of `md5sum.Write` is not checked (errcheck)
				md5sum.Write(buf[:1])
				            ^
frame/frame.go:165:17: Error return value of `md5sum.Write` is not checked (errcheck)
				md5sum.Write(buf[:2])
				            ^
frame/frame.go:170:17: Error return value of `md5sum.Write` is not checked (errcheck)
				md5sum.Write(buf[:])
				            ^

Updates #25.
2018-05-27 14:28:25 +02:00
mewmew d1bcf309b2 Merge branch 'master' of github.com:mewkiz/flac 2017-12-26 15:14:36 +01:00
mewmew 9c66335d65 frame: fix typo reported by misspell 2017-12-26 15:14:11 +01:00
chewxy 43fbacf007 Added 8297-275156-0011.flac, which is a 16kHz sampled file, derived from the LibriSpeech ASR corpus by Vassil Panayotov and Daniel Povey. The file is CCBY-4.0 2017-10-01 09:09:15 +11:00
Henry Eklind 0dc1119122
denser error handling 2016-07-22 00:56:37 +02:00
mewmew 3f1d1096d8 internal: Add bits and hashutil packages to make the flac package self-contained. 2016-04-05 02:40:46 +02:00
mewmew 9970b89a55 flac: Drop use of gopkg.in in import paths. Rely on vendoring instead.
ref: azul3d/engine#1
2016-03-07 00:06:54 +01:00
mewmew dd4d1cd9dd frame: Evaluate and remove TODO about potential optimization.
It did not improve the performance of Frame.Hash.
2016-02-11 23:26:32 +01:00
mewmew aadf80aa28 frame: Extend test cases to increase code coverage.
Test a corpus of 585 public domain FLAC files with a duration of less than 1 minute from freesound.org.

Out of these files, the following increased code coverage and where thus added to the test suit.

* 19875 (sample rate 48 kHz)
* 44127 (8 bits-per-sample, sample rate 22254)
* 80574 (sample rate 22050)
* 191885 (block size 1, verbatim)
* 212768 (sample rate 88200)
* 220014 (utf-8 continuation byte)
* 243749 (sample rate 8000)
* 257344 (sample rate 32000)
* 256529 (sample rate 192000)
2016-02-11 04:12:51 +01:00
Sergey Didyk 88d6a93e63 Bugfix for frame.HasFixedBlockSize 2015-05-16 18:45:39 +03:00
mewmew e95c34c138 all: Update godoc links to use gopkg.in/mewkiz/flac.v1 2015-01-30 01:58:04 +01:00
mewmew 6e68e06c25 frame: Remove the bit reader field from the SubFrame structure. This change will facilitate future test cases by allowing the use of reflect.DeepEqual on subframes. 2015-01-30 01:18:22 +01:00
mewmew 50ad5a4321 flac: Use versioned imports. 2014-09-30 02:24:15 +02:00
mewmew d97155529f flac,frame,meta: Fix display of links. 2014-08-08 08:52:08 +02:00
mewmew 0e7b20bac7 frame: Update Frame.Hash documentation. This is the last API update, and as such fixes issue #4. 2014-08-08 08:27:05 +02:00
mewmew 01ac9e9530 frame: Implement Frame.Hash method which adds the frame's unencoded audio samples to a running MD5 hash. 2014-08-08 08:20:59 +02:00
mewmew 7a33256cf7 meta: Return io.ErrUnexpectedEOF if EOF occurs in the middle of a metadata block. 2014-08-08 06:42:26 +02:00
mewmew 654f26264a frame: Return io.ErrUnexpectedEOF if EOF occurs in the middle of an audio frame. 2014-08-08 05:33:21 +02:00
mewmew 88de0bd4a7 meta: Add a brief introduction of the FLAC metadata format. 2014-08-08 02:38:26 +02:00
mewmew 0bfe584626 frame: Add a brief introduction of the FLAC audio format and describe the various prediction methods. 2014-08-08 01:04:38 +02:00
mewmew b30021351f frame: Reuse existing bit reader. 2014-08-07 02:18:12 +02:00
mewmew 23da211707 frame: Implement LPC decoding. 2014-08-07 02:10:14 +02:00
mewmew 4eab65d99b frame: Implement inter-channel correlation and decoding of constant and verbatim subframes. 2014-08-06 23:19:33 +02:00
mewmew 5743fb0574 frame: Implement subframe header parsing. 2014-08-06 20:29:06 +02:00
mewmew c8442ce5b6 frame: Add Parse and remove Frame.Next. Stub out a few functions. 2014-08-06 18:49:18 +02:00
mewmew 8a948cf6c0 frame: Implement frame header decoding. This is the first piece of the new frame API. Updates issue #4. 2014-08-06 17:58:55 +02:00
mewmew 3c81d18bb2 frame: Use pointers in Frame for subframes. 2014-08-06 04:43:38 +02:00
mewmew cfd1e6af0a frame: Add Channels.Count. 2014-08-06 04:38:58 +02:00
mewmew 923cdff51a frame: Add Header, Channels, SubHeader and Pred definitions. This was the last piece of the new frame API. Updates issue #4. 2014-08-06 04:24:36 +02:00
mewmew 7e1f8d2b03 frame: Initial version of the new frame API. Updates issue #4. 2014-08-06 03:08:32 +02:00
mewmew 51d342ff4b flac: Clean start in preparation for the new API. All functionality will be back ported later on. 2014-08-05 21:51:52 +02:00
mewmew 9370982910 frame: Verify decoded audio data using md5. 2014-08-05 15:33:23 +02:00
mewmew 6d8d6f28a4 frame: Implement rice2 decoding. 2014-08-03 15:59:00 +02:00
mewmew a5595f088c flac: Add license notice for eaburns/flac code segments. 2014-08-03 15:26:35 +02:00
mewmew 060f13b6f9 frame: Make use of mewkiz/pkg/bit instead of eaburns/bit.
The real time it takes to decode a 32 MB flac file is on average 5.5% less.
2014-08-03 14:57:12 +02:00
mewmew 15bc88aadd frame: Implement channel decorrelation (part 2). flac-frame is now able to decode most flac files :) 2014-08-02 21:58:36 +02:00
mewmew d1efb29881 frame: Interchannel decorrelation (part 1). 2014-08-02 21:43:13 +02:00
mewmew 5057601481 frame: Update TODO comments. 2014-07-31 03:05:39 +02:00
mewmew 7a122b13ac frame: Use bitutil.DecodeUnary and pre-allocate samples instead of using append. 2013-11-18 17:33:29 +01:00
mewmew b3530e6d6e frame: Remove old code which was out commented. 2013-11-17 00:10:31 +01:00
mewmew 51f30c32ef frame: Use io.TeeReader instead of hashutil.HashReader. 2013-11-16 23:48:45 +01:00
mewmew 56fd51d329 frame: Use ReadFields instead of bit masks in header.go. 2013-11-16 17:55:22 +01:00
mewmew dfd18aa2cb frame: Refactor to make use of github.com/eaburns/bit and hash readers. 2013-11-16 14:57:18 +01:00
mewmew f583bf6928 all: Fix issues located by golint.
- "error strings should not end with punctuation"
2013-10-29 14:45:05 +01:00