2 * DCA compatible decoder data
3 * Copyright (C) 2004 Gildas Bazin
4 * Copyright (C) 2004 Benjamin Zores
5 * Copyright (C) 2006 Benjamin Larsson
6 * Copyright (C) 2007 Konstantin Shishkov
8 * This file is part of FFmpeg.
10 * FFmpeg is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
15 * FFmpeg is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with FFmpeg; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
28 #include "libavutil/error.h"
31 #include "dca_syncwords.h"
34 const uint32_t avpriv_dca_sample_rates[16] = {
35 0, 8000, 16000, 32000, 0, 0, 11025, 22050, 44100, 0, 0,
36 12000, 24000, 48000, 96000, 192000
39 const uint32_t ff_dca_sampling_freqs[16] = {
40 8000, 16000, 32000, 64000, 128000, 22050, 44100, 88200,
41 176400, 352800, 12000, 24000, 48000, 96000, 192000, 384000,
44 const uint8_t ff_dca_freq_ranges[16] = {
45 0, 1, 2, 3, 4, 1, 2, 3, 4, 4, 0, 1, 2, 3, 4, 4
48 int avpriv_dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst,
55 if ((unsigned) src_size > (unsigned) max_size)
60 case DCA_SYNCWORD_CORE_BE:
61 case DCA_SYNCWORD_SUBSTREAM:
62 memcpy(dst, src, src_size);
64 case DCA_SYNCWORD_CORE_LE:
65 for (i = 0; i < (src_size + 1) >> 1; i++) {
66 AV_WB16(dst, AV_RL16(src));
71 case DCA_SYNCWORD_CORE_14B_BE:
72 case DCA_SYNCWORD_CORE_14B_LE:
73 init_put_bits(&pb, dst, max_size);
74 for (i = 0; i < (src_size + 1) >> 1; i++, src += 2) {
75 tmp = ((mrk == DCA_SYNCWORD_CORE_14B_BE) ? AV_RB16(src) : AV_RL16(src)) & 0x3FFF;
76 put_bits(&pb, 14, tmp);
79 return (put_bits_count(&pb) + 7) >> 3;
81 return AVERROR_INVALIDDATA;