1 /*
2 * Xiph CELT decoder using libcelt
3 * Copyright (c) 2011 Nicolas George
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #include <celt/celt.h>
23 #include <celt/celt_header.h>
27
32 };
33
35 {
36 switch (err) {
37 case CELT_BAD_ARG:
return AVERROR(EINVAL);
38 #ifdef CELT_BUFFER_TOO_SMALL
39 case CELT_BUFFER_TOO_SMALL:
return AVERROR(ENOBUFS);
40 #endif
41 case CELT_INTERNAL_ERROR:
return AVERROR(EFAULT);
43 case CELT_UNIMPLEMENTED:
return AVERROR(ENOSYS);
44 #ifdef ENOTRECOVERABLE
45 case CELT_INVALID_STATE:
return AVERROR(ENOTRECOVERABLE);
46 #endif
47 case CELT_ALLOC_FAIL:
return AVERROR(ENOMEM);
48 default:
return AVERROR(EINVAL);
49 }
50 }
51
53 {
54 CELTHeader header = { .version_id = 0 };
55 celt_header_init(&header, mode, 960, 2);
56 return header.version_id;
57 }
58
60 {
62 int err;
63
72 celt_mode_destroy(celt->
mode);
74 }
79 "Invalid overlap (%d), ignored.\n", celt->
discard);
81 }
82 }
86 if (version != lib_version)
88 "CELT bitstream version 0x%x may be "
89 "improperly decoded by libcelt for version 0x%x.\n",
90 version, lib_version);
91 }
93 return 0;
94 }
95
97 {
99
100 celt_decoder_destroy(celt->
dec);
101 celt_mode_destroy(celt->
mode);
102 return 0;
103 }
104
107 {
110 int err;
111 int16_t *pcm;
112
115 return err;
116 pcm = (int16_t *)frame->
data[0];
118 if (err < 0)
125 }
126 *got_frame_ptr = 1;
128 }
129
140 };