annotate ffmpeg/libavcodec/dca.c @ 13:844d341cf643 tip

Back up before ISMIR
author Yading Song <yading.song@eecs.qmul.ac.uk>
date Thu, 31 Oct 2013 13:17:06 +0000
parents 6840f77b83aa
children
rev   line source
yading@10 1 /*
yading@10 2 * DCA compatible decoder data
yading@10 3 * Copyright (C) 2004 Gildas Bazin
yading@10 4 * Copyright (C) 2004 Benjamin Zores
yading@10 5 * Copyright (C) 2006 Benjamin Larsson
yading@10 6 * Copyright (C) 2007 Konstantin Shishkov
yading@10 7 *
yading@10 8 * This file is part of FFmpeg.
yading@10 9 *
yading@10 10 * FFmpeg is free software; you can redistribute it and/or
yading@10 11 * modify it under the terms of the GNU Lesser General Public
yading@10 12 * License as published by the Free Software Foundation; either
yading@10 13 * version 2.1 of the License, or (at your option) any later version.
yading@10 14 *
yading@10 15 * FFmpeg is distributed in the hope that it will be useful,
yading@10 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
yading@10 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
yading@10 18 * Lesser General Public License for more details.
yading@10 19 *
yading@10 20 * You should have received a copy of the GNU Lesser General Public
yading@10 21 * License along with FFmpeg; if not, write to the Free Software
yading@10 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
yading@10 23 */
yading@10 24
yading@10 25 #include <stdint.h>
yading@10 26 #include <string.h>
yading@10 27
yading@10 28 #include "put_bits.h"
yading@10 29 #include "dca.h"
yading@10 30
yading@10 31 const uint32_t avpriv_dca_sample_rates[16] =
yading@10 32 {
yading@10 33 0, 8000, 16000, 32000, 0, 0, 11025, 22050, 44100, 0, 0,
yading@10 34 12000, 24000, 48000, 96000, 192000
yading@10 35 };
yading@10 36
yading@10 37 int ff_dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst,
yading@10 38 int max_size)
yading@10 39 {
yading@10 40 uint32_t mrk;
yading@10 41 int i, tmp;
yading@10 42 const uint16_t *ssrc = (const uint16_t *) src;
yading@10 43 uint16_t *sdst = (uint16_t *) dst;
yading@10 44 PutBitContext pb;
yading@10 45
yading@10 46 if ((unsigned) src_size > (unsigned) max_size)
yading@10 47 src_size = max_size;
yading@10 48
yading@10 49 mrk = AV_RB32(src);
yading@10 50 switch (mrk) {
yading@10 51 case DCA_MARKER_RAW_BE:
yading@10 52 memcpy(dst, src, src_size);
yading@10 53 return src_size;
yading@10 54 case DCA_MARKER_RAW_LE:
yading@10 55 for (i = 0; i < (src_size + 1) >> 1; i++)
yading@10 56 *sdst++ = av_bswap16(*ssrc++);
yading@10 57 return src_size;
yading@10 58 case DCA_MARKER_14B_BE:
yading@10 59 case DCA_MARKER_14B_LE:
yading@10 60 init_put_bits(&pb, dst, max_size);
yading@10 61 for (i = 0; i < (src_size + 1) >> 1; i++, src += 2) {
yading@10 62 tmp = ((mrk == DCA_MARKER_14B_BE) ? AV_RB16(src) : AV_RL16(src)) & 0x3FFF;
yading@10 63 put_bits(&pb, 14, tmp);
yading@10 64 }
yading@10 65 flush_put_bits(&pb);
yading@10 66 return (put_bits_count(&pb) + 7) >> 3;
yading@10 67 default:
yading@10 68 return AVERROR_INVALIDDATA;
yading@10 69 }
yading@10 70 }