Giter Site home page Giter Site logo

Coping with damaged flac files about flac HOT 3 CLOSED

mewkiz avatar mewkiz commented on July 16, 2024
Coping with damaged flac files

from flac.

Comments (3)

mewmew avatar mewmew commented on July 16, 2024

All crc mismatch messages lead to a program abort, which is not ideal.

Turning CRC mismatches into warnings, rather than fatal errors seems reasonable. We'll push this change momentarily.

Do you agree that making the decoder more robust against damaged flac files is a reasonable goal?

As for CRC, sure. However, for the later two cases, it seems better to try to get a working FLAC file when it is broken is incorrectly encoded. Otherwise we may end up with something similar to quirks mode in HTML, which is a mess. Better to stay true to the FLAC standard.

As far as I'm aware, it should never be the case that a valid FLAC file has different number of samples in the side and left channels (i.e. in correlate). So, the FLAC files exhibiting this property must be incorrectly encoded or damaged.

For the LPC case, it seems your file does not have subframe.NSamples == len(subframe.Samples) which is strange. Would you please verify if this is the case?

I.e. add the following to decodeLPC:

if subframe.NSamples != len(subframe.Samples) {
	log.Fatalf("subframe sample count mismatch; expected %d, got %d", subframe.NSamples, len(subframe.Samples))
}

from flac.

mewmew avatar mewmew commented on July 16, 2024

Turning CRC mismatches into warnings, rather than fatal errors seems reasonable. We'll push this change momentarily.

Done as of rev 8c55685.

from flac.

mehrvarz avatar mehrvarz commented on July 16, 2024

for the later two cases, it seems better to try to get a working FLAC file when it is broken is incorrectly encoded. Otherwise we may end up with something similar to quirks mode in HTML, which is a mess. Better to stay true to the FLAC standard.

Let us not call it quirks mode. Quirks mode is about dealing with human ignorance. Here we have flipping bits. Why not call it error correction? Or maybe better "error resilience". Apparently mp3 decoders never panic on such issues. They attempt to be robust about damages and try to (sometimes audibly) skip over. I find this preferable.

Turning CRC mismatches into warnings

Thank you. However, this change alone may not be sufficient. What this does is that...

frame, err := flacstream.ParseNext()

may now return incomplete number of subframes or samples. You either get "len(frame.Subframes) < channels" or "len(frame.Subframes[n].Samples) < int(frame.BlockSize). Without any precaution this will likely crash the consumer of the API. Some guidance is expedient.

Btw, you can use this to find damaged flac files (I just learned):

find "path2musicfolder" -name \*.flac -type f -exec flac -t "$1" {} \+

from flac.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.