Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix decoding of FLAC raw entropy partition #379

Merged
merged 1 commit into from
Aug 18, 2022

Conversation

ktmf01
Copy link
Contributor

@ktmf01 ktmf01 commented Aug 18, 2022

As was mentioned in the TODO of format/flac/flac.go

Please review. Go is new to me, and I don't understand the syntaxis used here, simple copy-paste-trial-error approach.

I think the problem was that (as in flac.tcl, samples were read unsigned, but) samples were read unsigned instead of signed, but I really don't understand what d.FieldRawLen does, so maybe it didn't read any samples at all?

for j := 0; j < count; j++ {
samples[n] = d.S(escapeSampleSize)
n++
}
Copy link
Owner

@wader wader Aug 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha that was the reason the failing test files produced different samples, nice catch. As you suspected, before this change escaped samples were not read as samples at all, only a raw bit field was added for the bits. FieldRawLen reads raw bits without doing any interpretation of them.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW we could add an option to optionally add fields for each sample if you think that is useful? the reason i skipped doing it for now is that it would use lots of memory and make the output not very useful.

Then one could for example decode a specific frame with sample fields enabled, something like .frames[10] | flac_frames({decode_samples: true})

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flac has a similar --residual-text option that I've used a few times when debugging some patches. For example, sometimes it wasn't clear whether a bug was in the encoder or decoder, then looking at these values would help. It could be helpful, but it might be too specific for fq?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fq is all about debugging and details so is fine i think :) but maybe it would be a flac_frame decoder option that is disable by default (current behaviour). I think it would be more or less just add a DecodeSamples bool to FlacFrameIn struct (in format.go) etc and initialize it to false and then decode conditionally on it. The interpreter code takes care of all the translation of jq function opts and such.

@wader
Copy link
Owner

wader commented Aug 18, 2022

LGTM, will merge once tests pass. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants