1 /*
2 * LC3 decoder wrapper
3 * Copyright (C) 2024 Antoine Soulier <asoulier@google.com>
4 *
5 * This file is part of FFmpeg.
6 *
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
20 #include <lc3.h>
21
24
30
31 #define DECODER_MAX_CHANNELS 2
32
38
40 {
43 int ep_mode;
44 unsigned decoder_size;
45
50 "Invalid number of channels %d. Max %d channels are accepted\n",
53 }
54
59 if (ep_mode != 0) {
61 "Error protection mode is not supported.\n");
63 }
64
66 "Decoding %.1f ms frames.\n", liblc3->
frame_us / 1000.f);
69
70 decoder_size = lc3_hr_decoder_size(
72 if (!decoder_size)
74
78
79 for (
int ch = 0; ch <
channels; ch++) {
80 liblc3->
decoder[ch] = lc3_hr_setup_decoder(
83 }
84
86 avctx->
delay = lc3_hr_delay_samples(
89
90 return 0;
91 }
92
94 {
96
98
99 return 0;
100 }
101
103 int *got_frame_ptr,
AVPacket *avpkt)
104 {
107 uint8_t *in = avpkt->
data;
108 int block_bytes,
ret;
109
114
115 block_bytes = avpkt->
size;
116 for (
int ch = 0; ch <
channels; ch++) {
118
119 ret = lc3_decode(liblc3->
decoder[ch], in, nbytes,
120 LC3_PCM_FORMAT_FLOAT,
frame->data[ch], 1);
123
124 in += nbytes;
125 }
126
128
129 *got_frame_ptr = 1;
130
132 }
133
140 .p.wrapper_name = "liblc3",
146 };