Git Product home page Git Product logo

liblc3's People

Contributors

anonymix007 avatar asoulier avatar carlescufi avatar daissi avatar dane1122 avatar deltaevo avatar eli-schwartz avatar kirankrishnappa-intel avatar leytou avatar mariuszskamra avatar mringwal avatar t-8ch avatar tkanakamalla avatar xyz1001 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

liblc3's Issues

Sweep sine get more harmonics when increasing the bitrate

@WenzhengQ has reported:

I disable ltpf unconditionally  in analyse() function of the lc3.c file; output sine signal is normal; 

//    if (nn_flag)
        lc3_ltpf_disable(&side->ltpf);

But I set encode bitrate=500kbps, encode the same full scale sweep sine(20hz-24khz)  and decode the bitstream;  the ouput sine signal has more harmonic at higher sinus frequency; when i set encode bitrate=128kbps, output sine has less harmonic  than bitrate=500kbps;

1.encode the wav
./elc3 -b 500000 -m 10 48khz_16bit_2ch.wav 48khz_16bit_2ch_enc_500kbps.bin
2.decode the bitstream
./dlc3 48khz_16bit_2ch_enc_500kbps.bin 48khz_16bit_2ch_enc_500kbps_dec.wav

Originally posted by @WenzhengQ in #33 (comment)

Conformance test problem

I did the conformance test by Test Software v1.0.6. However, the encode and encode-decode report with 7.5ms frame were failed. I found out the ODG of LC3 is much larger than the reference ODG that cause the delta ODG exceed the threshold(0.06). I guess it is due to the PEAQ algorithm. Could you let me know which PEAQ did you implement?

Status of Packet Loss Concealment (PLC)

Thanks for providing this excellent and fast LC3 Codec as an open source project.

I'd like to ask about the status of the Packet Loss Concealment.

When I run a simple test encoding a sine wave and dropping every 20th packet, it clearly becomes audible. The test is here: https://github.com/bluekitchen/liblc3/tree/plc-test/plc-test (regular CMake project, should build with no other dependencies).

The LC3 specifications defines a minimal PLC in Appendix B. Is that implemented (and just not good enough), or would this help?

For SBC, it was possible to replace a dropped packet with a fixed 'zero frame', which worked well at least for the simple case with a periodic dropped packet.

Thanks
Matthias

bluetooth samplerates not supported.

Hello LC3 guys. Thanks for the great library.

There are some frequencies missing which are used in e.g. bluetooth:

11025
22050
44100

Is there any reason these are not there?

Thanks,

/pedro

Next release

Is there any indication or roadmap when the next release is planned? The last one was over half a year ago, and it would be beneficial to have the latest bugfixes in a stable, tagged release.

Integrate with google/oss-fuzz for continuous fuzz-testing

Hey I'd like to suggest adding liblc3 to google/oss-fuzz. If you aren't familiar with fuzz testing, here is a bit of a run down (from Wikipedia);

In programming and software development, fuzzing or fuzz testing is an automated software testing technique that involves providing invalid, unexpected, or random data as inputs to a computer program. The program is then monitored for exceptions such as crashes, failing built-in code assertions, or potential memory leaks.

Fuzz tests differ a little to the unit/integration tests already in the liblc3 repository as the fuzzer will attempt to generate malformed inputs that may trigger those otherwise hard to find edge-cases or bugs that wouldn't be capture using regular testing.

If liblc3 is integrated into oss-fuzz, the fuzz tests under liblc3 will be built and then run once a day, to search for bugs and vulnerabilities in liblc3. This service can be integrated with the CI for liblc3, so that the fuzz tests are run for 10min or so for every pull request, preventing buggy code from being merged.

I've opened up a pull request to add a basic fuzz-testing harness here #30 just to demonstrate what this would look like. If you are keen on adding liblc3 to oss-fuzz I'd be happy to champion the integration :)

[Feature Request] Additional frame sizes

This file was encoded with some kind of LC3-based codec and appears to have 5 ms frame size (but original library seems to also support 2.5 ms). It's just a simple sine wave.

Here's the program I've tried for decoding (each frame is represented as [length][frame], length is uint32_t little-endian):

#include <assert.h>
#include <errno.h>
#include <float.h>
#include <math.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <lc3.h>

#include "sndfile.h"

SNDFILE *openAudioFile(const char *fileName, int freq, int channels) {
    SF_INFO sfinfo = {
        .samplerate = freq,
        .channels = channels,
        .format = SF_FORMAT_WAV | SF_FORMAT_PCM_24,
    };
    printf("opening \"%s\" for writing ...\n", fileName);
    printf("sampling frequency: %d\n", freq);
    printf("channel count:      %d\n", channels);
    SNDFILE *out = sf_open(fileName, SFM_WRITE, &sfinfo);
    if (out == NULL) {
        printf("can't open output: %s\n", sf_strerror(NULL));
        return NULL;
    }
    return out;
}

#define BUFFER_SIZE (680 * 2 * 2)
#define PCM_BUFFER_SIZE (256 * 2 * 2)

int main(int argc, char *argv[]) {
    const char *inputFile = "data.bin";
    const char *audioFile = "decoded.wav";


    if (argc > 2) {
        audioFile = argv[2];
    }
    if (argc > 1) {
        inputFile = argv[1];
    }

    printf("opening \"%s\" ...\n", inputFile);

    lc3_decoder_t dec[2];

    int frame_us = 5000;
    int srate_hz = 48000;

    for (int ich = 0; ich < 2; ich++) {
        dec[ich] = lc3_setup_decoder(frame_us, srate_hz, 0,
            malloc(lc3_decoder_size(frame_us, srate_hz)));
    }

    int pcm_samples = lc3_frame_samples(frame_us, srate_hz);


    FILE *in = fopen(inputFile, "rb");
    if (in == NULL) {
        perror("can't open stream file");
        return EXIT_FAILURE;
    }

    SNDFILE *out = openAudioFile(audioFile, srate_hz, 2);

    uint8_t buf[BUFFER_SIZE];
    uint8_t *ptr = NULL;
    int32_t pcm[PCM_BUFFER_SIZE] = {0};
    while (1) {
        uint32_t size = 0;
        if (fread(&size, sizeof(size), 1, in) != 1) {
            printf("End of file!\n");
            break;
        }

        if (fread(buf, 1, size, in) != size) {
            printf("Not enough data (corrupted packet)!\n");
            break;
        }

        int frame_bytes = size / 2;

        for (int ich = 0; ich < 2; ich++) { 
                lc3_decode(dec[ich], 
                    buf + 2 + ich * frame_bytes, frame_bytes, // +2 is for bitrate, which seems to prepend frame.
                    LC3_PCM_FORMAT_S24, pcm + ich * 4, 2);
        }
        sf_writef_int(out, pcm, pcm_samples);

    }

    printf("Done!\n");
    sf_close(out);
    fclose(in);

    return EXIT_SUCCESS;
}

The following patch was used to add 2.5 and 5 ms frames:

diff --git a/include/lc3_private.h b/include/lc3_private.h
index c4d6703..58b0d7c 100644
--- a/include/lc3_private.h
+++ b/include/lc3_private.h
@@ -45,10 +45,12 @@
 
 
 /**
- * Frame duration 7.5ms or 10ms
+ * Frame duration 2.5ms, 5ms, 7.5ms or 10ms
  */
 
 enum lc3_dt {
+    LC3_DT_2M5,
+    LC3_DT_05M,
     LC3_DT_7M5,
     LC3_DT_10M,
 
diff --git a/src/common.h b/src/common.h
index d60ad9e..a023328 100644
--- a/src/common.h
+++ b/src/common.h
@@ -87,7 +87,7 @@
  */
 
 #define LC3_DT_US(dt) \
-    ( (3 + (dt)) * 2500 )
+    ( (1 + (dt)) * 2500 )
 
 #define LC3_SRATE_KHZ(sr) \
     ( (1 + (sr) + ((sr) == LC3_SRATE_48K)) * 8 )
@@ -101,14 +101,14 @@
  */
 
 #define LC3_NS(dt, sr) \
-    ( 20 * (3 + (dt)) * (1 + (sr) + ((sr) == LC3_SRATE_48K)) )
+    ( 20 * (1 + (dt)) * (1 + (sr) + ((sr) == LC3_SRATE_48K)) )
 
 #define LC3_ND(dt, sr) \
     ( (dt) == LC3_DT_7M5 ? 23 * LC3_NS(dt, sr) / 30 \
                          :  5 * LC3_NS(dt, sr) /  8 )
 
 #define LC3_NE(dt, sr) \
-    ( 20 * (3 + (dt)) * (1 + (sr)) )
+    ( 20 * (1 + (dt)) * (1 + (sr)) )
 
 #define LC3_MAX_NS \
     LC3_NS(LC3_DT_10M, LC3_SRATE_48K)
@@ -120,7 +120,7 @@
     ( (5 * LC3_SRATE_KHZ(sr)) / 4 )
 
 #define LC3_NH(dt, sr) \
-    ( ((3 - dt) + 1) * LC3_NS(dt, sr) )
+    ( ((3 - dt) + 3 + ((dt) == LC3_DT_05M)) * (((dt) == LC3_DT_2M5) + 1) * LC3_NS(dt, sr) )
 
 
 /**
diff --git a/src/lc3.c b/src/lc3.c
index 6f54300..0f6dca7 100644
--- a/src/lc3.c
+++ b/src/lc3.c
@@ -57,7 +57,9 @@ struct side_data {
  */
 static enum lc3_dt resolve_dt(int us)
 {
-    return us ==  7500 ? LC3_DT_7M5 :
+    return us ==  2500 ? LC3_DT_10M :
+           us ==  5000 ? LC3_DT_05M :
+           us ==  7500 ? LC3_DT_7M5 :
            us == 10000 ? LC3_DT_10M : LC3_NUM_DT;
 }

Apparently, this isn't enough, as library segfaults in spectral_shaping

Is there some way to make liblc3 compatible with this format? Ideally it would be able to both encode and decode, but encoding only is good enough.

lc3_decode: Query on leading and trailing extra samples in the decoded output

The pcm output of the decoder seems to have some leading and trailing extra samples? Why is the decoder producing those additional bytes?

From the dlc3.c code, I see it strips off those bytes before writing them to wav file. So apparently those are unwanted.

liblc3/tools/dlc3.c

Lines 234 to 236 in 3d76930

int pcm_offset = i > 0 ? 0 : encode_samples - pcm_samples;
int pcm_nwrite = MIN(frame_samples - pcm_offset,
encode_samples - i*frame_samples);

[feature request] manipulate mono channel enc/dec from tool

Thanks for the great liblc3! Pardon me to raise a feature request in here. Since I found the elc3 from tool cannot handle the mono channel WAV file, would it possible to extend the the tool for handling the mono channel audio ? that would be wonderful! Many thanks!

License compatibility

From the first look it seems the intention is to allow building with the likes of glibc but since it is LGPL 2.1 (https://sourceware.org/git/?p=glibc.git;a=blob;f=COPYING.LIB) I wonder if that would be compatible, at least some sources says they are not:

'One lax license, Apache 2.0, has patent clauses which are incompatible with GPL version 2;'
[https://www.gnu.org/licenses/license-compatibility.html]

"The Apache 2.0’s license partner rights make it incompatible with GPL v2"
[https://www.whitesourcesoftware.com/resources/blog/license-compatibility/]

I see that projects like https://github.com/tensorflow/tensorflow are also on the same license so I do wonder if there are taken care of the possible incompatibilities somehow, anyway we can use this very issue to explain to explains how to handle such problems.

LC3 decoding is slow

 Are there plans to improve fixed-point computing? 
 In the decoding comparison test, LC3 is much slower than opus custom's decoding speed. The test samples are 16000 sample rate, 32000 bits rate, frame 10ms, Opus Custom decoding time is 6ms, LC3 is 18~19ms.
The test platform is a 48MHz Cortex-M0+.

Volume adjustment

Is it possible to support volume adjustment when decoding like OPUS, so that some cases without external volume adjustment can be adjusted by software?
 if(st->decode_gain)
   {
      opus_val32 gain;
      gain = celt_exp2(MULT16_16_P15(QCONST16(6.48814081e-4f, 25), st->decode_gain));
      for (i=0;i< (frame_size/st->downsample)*st->channels;i++)
      {
         opus_val32 x;
         x = MULT16_32_P16(pcm[i],gain);
         pcm[i] = SATURATE(x, 32767);
      }
   }

LC3_EXPORT macro breaks compilation with MSVC

Hi,

This is to report that on #44 a LC3_EXPORT macro was added to aid in managing the ABI of liblc3. However, using this macro prevents compiling the library at all on MSVC, it needs to be changed to __declspec(dllexport) in that case.

Fixing this issue will also enable building shared libraries without further change under MSVC -- previous to that PR, the shared library had an empty ABI and so had no import library generated at link time.

Releases ?

I note that project like pipewire and possibly pulseaudio is starting to impl. LC3 and I figure doing proper releases of this LC3 lib would simply for distributions to make use of LC3.
Is that something you would be interested in?

Introduce LC3_PCM_FORMAT_FLOAT

Looks like the internal processing is using floating point with the existing formats (s16,s24) just converting to it so perhaps it would be a good idea to introduce the floating point at API level in case the audio server is already using floating point then it doesn't have to convert to fixed point just to call liblc3 APIs.

Floating Point Exception in tools/wave.c:117

I found a FPE in tools/wave.c:117:

int wave_read_header(FILE *fp, int *bitdepth, int *samplesize,
    int *samplerate, int *nchannels, int *nframes)
{
    ...
    *samplesize = format.framesize / format.channels;
    ...

No validation of the input is performed so format.channels can be 0.
I attached an example wav.
example.zip

build failed with MSVC

MSVC does not support VLA(Variable Length Array ), can you make compatibility please?

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.