Menu

#4 CRC Checking

open
nobody
mpg123 (18)
5
2020-01-31
2007-04-13
No

Add proper CRC checking to mpg123 (with option to turn off).

Make sure that layer2 support works too.

Discussion

  • Thomas Orgis

    Thomas Orgis - 2014-09-26

    The crc checking should be employed by a certain function that explicitly checks for MPEG file correctness. Actually two:

    mpg123_check_init() for guessing if the loaded stream is valid(trying to initialize track and check crc for first frame(s)) ... I'm not sure about the name, as I suppose it would mainly call init_track() and be ready for further decoding. CRC check ob top.

    mpg123_check_stream() check the whole stream with crc ... one needs to wonder about return values; a stream can contain good frames and bad frames and just junk. Those counts might be returned by this function, with MPG123_OK being main return value if any valid frames have been found.

     
  • Stefan Pöschel

    Stefan Pöschel - 2017-05-25

    I would really appreciate if libmpg123 had support for CRC check, as in DAB it is used by audio services in MP2.

     
  • Thomas Orgis

    Thomas Orgis - 2017-05-26

    Maybe we should talk about the implementation. My intial comment reads like I only though about files back then. Streaming radio is different.

    As a start: Stefan, can you prepare a little stream dump from DAB as test data? Instead of fabricating files, I would like to test with the real thing.

    I am wondering now what libmpg123 (and cmdline mpg123) should do with the crc. Just use it as another way to detect junk and ignore frames with bad checksum? Or rather decode them as equivalent silence (in case the headers are good and only crc bad), as this has less chance of messing up the stream position? For streaming you might want to skip ahead over broken frames or not.

     
  • Thomas Orgis

    Thomas Orgis - 2017-05-26

    That being said … what is the main benefit you want from the CRC check? Is it avoidance of nasty artifacts from damanged frames that still decode (to crap)? Is it for the warm fuzzy feeling of having good reception confirmed?

     
  • Stefan Pöschel

    Stefan Pöschel - 2017-05-26

    Since a while there are only DAB+ (= AAC) services in Germany, but in the UK and other countries DAB (= MP2) is still in use (due to earlier launch). So I attach a short dump of Deutschlandfunk from 2013. It is mostly free of errors (at least it sounds like); it just has audible errors at 0:06, 1:11 and 1:22.

    I think it would be enough to just have the information whether the last parsed frame (if the CRC is present; in DAB it is required to be) passes the CRC check e.g. by invoking a new function. If the check is not passed, it should be up to the lib user on how to proceed with this result. He/She could forward the audio to the listener despite of the present errors, or decide to instead forward silence (or to just entirely skip the frame).

    In terms of DAB I maintain a software called DABlin that plays a DAB/DAB+ audio service from a complete DAB ensemble. At that stage I don't have any information regarding reception etc., so I have to just rely on the data e.g. the audio stream (which is decoded by mpg123 for DAB services, see /src/dab_decoder.cpp).

    Thus I think I will abstain from throwing away the decoded audio, as it usually is still good enough to be forwarded to the listener. But I would like to inform the user that there are reception errors, so that he/she might want to adjust the antenna.

    While reading the DAB spec, I just realize that DAB adds a further CRC (ScF-CRC) near the frame end (I initially though that this was the actual CRC -.-), that protects a part of the scale factors, see figures 4/6 and annexes B.2/B.3 in ETSI TS 103 466. I'm not sure if you want to add also support for that second CRC ;-)

     

    Last edit: Stefan Pöschel 2017-05-26
  • Stefan Pöschel

    Stefan Pöschel - 2017-06-13

    Some weeks later, I dove into MP2 and implemented the MP2 CRC in my DAB player, so at least I myself don't need this feature anymore. But of course for the sake of completeness it would be great if mpg123 supported the CRC check.

    And just forget about the additional ScF-CRC of DAB: Despite the fact that it is only useful with DAB, the ScF-CRC of frame n is transmitted in frame n-1, which leads to further dependency issues...

     
  • Thomas Orgis

    Thomas Orgis - 2020-01-31

    Still have that on the list … we store the crc, just don't check.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.