Go to the documentation of this file.
31 #define ENCODER_MAX_CHANNELS 2
55 int effective_bit_rate;
56 unsigned encoder_size;
58 if (frame_us != 2500 && frame_us != 5000 &&
59 frame_us != 7500 && frame_us != 10000 ) {
61 "Unsupported frame duration %.1f ms.\n", frame_us / 1000.
f);
66 "Invalid number of channels %d. Max %d channels are accepted\n",
71 hr_mode |= srate_hz > 48000;
72 hr_mode &= srate_hz >= 48000;
74 if (frame_us == 7500 && hr_mode) {
76 "High-resolution mode is not supported with 7.5 ms frames.\n");
87 effective_bit_rate = lc3_hr_resolve_bitrate(
90 if (avctx->
bit_rate != effective_bit_rate)
92 "Bitrate changed to %d bps.\n", effective_bit_rate);
93 avctx->
bit_rate = effective_bit_rate;
95 encoder_size = lc3_hr_encoder_size(hr_mode, frame_us, srate_hz);
103 for (
int ch = 0; ch <
channels; ch++) {
104 liblc3->
encoder[ch] = lc3_hr_setup_encoder(
105 hr_mode, frame_us, srate_hz, 0,
119 liblc3->
delay_samples = lc3_hr_delay_samples(hr_mode, frame_us, srate_hz);
140 void *zero_frame =
NULL;
148 int padding =
frame->nb_samples -
frame->duration;
161 for (
int ch = 0; ch <
channels; ch++) {
162 const float *pcm = zero_frame ? zero_frame :
frame->data[ch];
165 lc3_encode(liblc3->
encoder[ch],
166 LC3_PCM_FORMAT_FLOAT, pcm, 1, nbytes, data_ptr);
179 #define OFFSET(x) offsetof(LibLC3EncContext, opts.x)
180 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
182 {
"frame_duration",
"Duration of a frame in milliseconds",
184 { .dbl = 10.0 }, 2.5, 10.0,
FLAGS },
185 {
"high_resolution",
"Enable High-Resolution mode (48 KHz or 96 KHz)",
187 { .i64 = 0 }, 0, 1,
FLAGS },
204 .p.supported_samplerates = (
const int [])
205 { 96000, 48000, 32000, 24000, 16000, 8000, 0 },
208 .p.priv_class = &
class,
209 .p.wrapper_name =
"liblc3",
int frame_size
Number of samples per channel in an audio frame.
@ AV_SAMPLE_FMT_FLTP
float, planar
#define AV_LOG_WARNING
Something somehow does not look correct.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
int sample_rate
samples per second
This structure describes decoded (raw) audio or video data.
int nb_channels
Number of channels in this layout.
AVCodec p
The public AVCodec.
AVChannelLayout ch_layout
Audio channel layout.
lc3_encoder_t encoder[ENCODER_MAX_CHANNELS]
static const AVOption options[]
#define FF_CODEC_ENCODE_CB(func)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static av_cold int liblc3_encode_init(AVCodecContext *avctx)
#define ENCODER_MAX_CHANNELS
#define CODEC_LONG_NAME(str)
#define LIBAVUTIL_VERSION_INT
static av_cold int liblc3_encode_close(AVCodecContext *avctx)
Describe the class of an AVClass context structure.
int64_t bit_rate
the average bitrate
const char * av_default_item_name(void *ptr)
Return the context name.
int(* init)(AVBSFContext *ctx)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_LOG_INFO
Standard information.
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
#define av_malloc_array(a, b)
AVSampleFormat
Audio sample formats.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
const char * name
Name of the codec implementation.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
#define AV_INPUT_BUFFER_PADDING_SIZE
main external API structure.
const FFCodec ff_liblc3_encoder
int ff_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int flags)
Get a buffer for a packet.
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
static int liblc3_encode(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet_ptr)
This structure stores compressed data.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.