mirror of
https://github.com/google/liblc3.git
synced 2026-05-18 17:38:02 +00:00
feature: Add 2.5 ms and 5 ms LC3 plus frame durations
fix: Check TNS bitstream data fix: LTPF Activation with 2.5 ms frame sizes
This commit is contained in:
committed by
Antoine Soulier
parent
a75f187e00
commit
149cb6537e
@@ -135,7 +135,7 @@ extern "C" {
|
||||
#define LC3_MIN_FRAME_BYTES 20
|
||||
#define LC3_MAX_FRAME_BYTES 400
|
||||
|
||||
#define LC3_MIN_FRAME_SAMPLES __LC3_NS( 7500, 8000)
|
||||
#define LC3_MIN_FRAME_SAMPLES __LC3_NS( 2500, 8000)
|
||||
#define LC3_MAX_FRAME_SAMPLES __LC3_NS(10000, 48000)
|
||||
|
||||
|
||||
@@ -146,7 +146,8 @@ extern "C" {
|
||||
*/
|
||||
|
||||
#define LC3_CHECK_DT_US(us) \
|
||||
( ((us) == 7500) || ((us) == 10000) )
|
||||
( ((us) == 2500) || ((us) == 5000) || \
|
||||
((us) == 7500) || ((us) == 10000) )
|
||||
|
||||
#define LC3_CHECK_SR_HZ(sr) \
|
||||
( ((sr) == 8000) || ((sr) == 16000) || ((sr) == 24000) || \
|
||||
@@ -196,7 +197,7 @@ typedef LC3_DECODER_MEM_T(10000, 48000) lc3_decoder_mem_48k_t;
|
||||
|
||||
/**
|
||||
* Return the number of PCM samples in a frame
|
||||
* dt_us Frame duration in us, 7500 or 10000
|
||||
* dt_us Frame duration in us, 2500, 5000, 7500 or 10000
|
||||
* sr_hz Samplerate in Hz, 8000, 16000, 24000, 32000 or 48000
|
||||
* return Number of PCM samples, -1 on bad parameters
|
||||
*/
|
||||
@@ -204,7 +205,7 @@ int lc3_frame_samples(int dt_us, int sr_hz);
|
||||
|
||||
/**
|
||||
* Return the size of frames, from bitrate
|
||||
* dt_us Frame duration in us, 7500 or 10000
|
||||
* dt_us Frame duration in us, 2500, 5000, 7500 or 10000
|
||||
* bitrate Target bitrate in bit per second
|
||||
* return The floor size in bytes of the frames, -1 on bad parameters
|
||||
*/
|
||||
@@ -212,7 +213,7 @@ int lc3_frame_bytes(int dt_us, int bitrate);
|
||||
|
||||
/**
|
||||
* Resolve the bitrate, from the size of frames
|
||||
* dt_us Frame duration in us, 7500 or 10000
|
||||
* dt_us Frame duration in us, 2500, 5000, 7500 or 10000
|
||||
* nbytes Size in bytes of the frames
|
||||
* return The according bitrate in bps, -1 on bad parameters
|
||||
*/
|
||||
@@ -220,7 +221,7 @@ int lc3_resolve_bitrate(int dt_us, int nbytes);
|
||||
|
||||
/**
|
||||
* Return algorithmic delay, as a number of samples
|
||||
* dt_us Frame duration in us, 7500 or 10000
|
||||
* dt_us Frame duration in us, 2500, 5000, 7500 or 10000
|
||||
* sr_hz Samplerate in Hz, 8000, 16000, 24000, 32000 or 48000
|
||||
* return Number of algorithmic delay samples, -1 on bad parameters
|
||||
*/
|
||||
@@ -228,7 +229,7 @@ int lc3_delay_samples(int dt_us, int sr_hz);
|
||||
|
||||
/**
|
||||
* Return size needed for an encoder
|
||||
* dt_us Frame duration in us, 7500 or 10000
|
||||
* dt_us Frame duration in us, 2500, 5000, 7500 or 10000
|
||||
* sr_hz Samplerate in Hz, 8000, 16000, 24000, 32000 or 48000
|
||||
* return Size of then encoder in bytes, 0 on bad parameters
|
||||
*
|
||||
@@ -239,7 +240,7 @@ unsigned lc3_encoder_size(int dt_us, int sr_hz);
|
||||
|
||||
/**
|
||||
* Setup encoder
|
||||
* dt_us Frame duration in us, 7500 or 10000
|
||||
* dt_us Frame duration in us, 2500, 5000, 7500 or 10000
|
||||
* sr_hz Samplerate in Hz, 8000, 16000, 24000, 32000 or 48000
|
||||
* sr_pcm_hz Input samplerate, downsampling option of input, or 0
|
||||
* mem Encoder memory space, aligned to pointer type
|
||||
@@ -268,7 +269,7 @@ int lc3_encode(lc3_encoder_t encoder, enum lc3_pcm_format fmt,
|
||||
|
||||
/**
|
||||
* Return size needed for an decoder
|
||||
* dt_us Frame duration in us, 7500 or 10000
|
||||
* dt_us Frame duration in us, 2500, 5000, 7500 or 10000
|
||||
* sr_hz Samplerate in Hz, 8000, 16000, 24000, 32000 or 48000
|
||||
* return Size of then decoder in bytes, 0 on bad parameters
|
||||
*
|
||||
@@ -279,7 +280,7 @@ unsigned lc3_decoder_size(int dt_us, int sr_hz);
|
||||
|
||||
/**
|
||||
* Setup decoder
|
||||
* dt_us Frame duration in us, 7500 or 10000
|
||||
* dt_us Frame duration in us, 2500, 5000, 7500 or 10000
|
||||
* sr_hz Samplerate in Hz, 8000, 16000, 24000, 32000 or 48000
|
||||
* sr_pcm_hz Output samplerate, upsampling option of output (or 0)
|
||||
* mem Decoder memory space, aligned to pointer type
|
||||
|
||||
@@ -25,46 +25,55 @@
|
||||
|
||||
/**
|
||||
* Return number of samples, delayed samples and
|
||||
* encoded spectrum coefficients within a frame
|
||||
* - For encoding, keep 1.25 ms of temporal winodw
|
||||
* encoded spectrum coefficients within a frame.
|
||||
*
|
||||
* - The number of MDCT delayed samples is the sum of half a frame and
|
||||
* an ovelap of future by 1.25 ms (2.5ms, 5ms and 10ms frame durations)
|
||||
* or 2 ms (7.5ms frame duration).
|
||||
*
|
||||
* - For encoding, keep 1.25 ms of temporal previous samples
|
||||
* - For decoding, keep 18 ms of history, aligned on frames, and a frame
|
||||
*/
|
||||
|
||||
#define __LC3_NS(dt_us, sr_hz) \
|
||||
( (dt_us * sr_hz) / 1000 / 1000 )
|
||||
( (dt_us) * (sr_hz) / 1000 / 1000 )
|
||||
|
||||
#define __LC3_ND(dt_us, sr_hz) \
|
||||
( (dt_us) == 7500 ? 23 * __LC3_NS(dt_us, sr_hz) / 30 \
|
||||
: 5 * __LC3_NS(dt_us, sr_hz) / 8 )
|
||||
( __LC3_NS(dt_us, sr_hz) / 2 + \
|
||||
__LC3_NS((dt_us) == 7500 ? 2000 : 1250, sr_hz) )
|
||||
|
||||
#define __LC3_NT(sr_hz) \
|
||||
( (5 * sr_hz) / 4000 )
|
||||
( __LC3_NS(1250, sr_hz) )
|
||||
|
||||
#define __LC3_NH(dt_us, sr_hz) \
|
||||
( ((3 - ((dt_us) >= 10000)) + 1) * __LC3_NS(dt_us, sr_hz) )
|
||||
( __LC3_NS(18000, sr_hz) + 2*__LC3_NS(dt_us, sr_hz) - \
|
||||
(__LC3_NS(18000, sr_hz) % __LC3_NS(dt_us, sr_hz)) )
|
||||
|
||||
|
||||
/**
|
||||
* Frame duration 7.5ms or 10ms
|
||||
* Frame duration
|
||||
*/
|
||||
|
||||
enum lc3_dt {
|
||||
LC3_DT_7M5,
|
||||
LC3_DT_10M,
|
||||
LC3_DT_2M5 = 0,
|
||||
LC3_DT_5M = 1,
|
||||
LC3_DT_7M5 = 2,
|
||||
LC3_DT_10M = 3,
|
||||
|
||||
LC3_NUM_DT
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Sampling frequency
|
||||
*/
|
||||
|
||||
enum lc3_srate {
|
||||
LC3_SRATE_8K,
|
||||
LC3_SRATE_16K,
|
||||
LC3_SRATE_24K,
|
||||
LC3_SRATE_32K,
|
||||
LC3_SRATE_48K,
|
||||
LC3_SRATE_8K = 0,
|
||||
LC3_SRATE_16K = 1,
|
||||
LC3_SRATE_24K = 2,
|
||||
LC3_SRATE_32K = 3,
|
||||
LC3_SRATE_48K = 4,
|
||||
|
||||
LC3_NUM_SRATE,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user