annotate ffmpeg/libavcodec/wma_common.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 * common code shared by all WMA variants
yading@10 3 *
yading@10 4 * This file is part of Libav.
yading@10 5 *
yading@10 6 * Libav is free software; you can redistribute it and/or
yading@10 7 * modify it under the terms of the GNU Lesser General Public
yading@10 8 * License as published by the Free Software Foundation; either
yading@10 9 * version 2.1 of the License, or (at your option) any later version.
yading@10 10 *
yading@10 11 * Libav is distributed in the hope that it will be useful,
yading@10 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
yading@10 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
yading@10 14 * Lesser General Public License for more details.
yading@10 15 *
yading@10 16 * You should have received a copy of the GNU Lesser General Public
yading@10 17 * License along with Libav; if not, write to the Free Software
yading@10 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
yading@10 19 */
yading@10 20
yading@10 21 #include "libavutil/attributes.h"
yading@10 22 #include "wma_common.h"
yading@10 23
yading@10 24 /**
yading@10 25 *@brief Get the samples per frame for this stream.
yading@10 26 *@param sample_rate output sample_rate
yading@10 27 *@param version wma version
yading@10 28 *@param decode_flags codec compression features
yading@10 29 *@return log2 of the number of output samples per frame
yading@10 30 */
yading@10 31 av_cold int ff_wma_get_frame_len_bits(int sample_rate, int version,
yading@10 32 unsigned int decode_flags)
yading@10 33 {
yading@10 34
yading@10 35 int frame_len_bits;
yading@10 36
yading@10 37 if (sample_rate <= 16000) {
yading@10 38 frame_len_bits = 9;
yading@10 39 } else if (sample_rate <= 22050 ||
yading@10 40 (sample_rate <= 32000 && version == 1)) {
yading@10 41 frame_len_bits = 10;
yading@10 42 } else if (sample_rate <= 48000 || version < 3) {
yading@10 43 frame_len_bits = 11;
yading@10 44 } else if (sample_rate <= 96000) {
yading@10 45 frame_len_bits = 12;
yading@10 46 } else {
yading@10 47 frame_len_bits = 13;
yading@10 48 }
yading@10 49
yading@10 50 if (version == 3) {
yading@10 51 int tmp = decode_flags & 0x6;
yading@10 52 if (tmp == 0x2) {
yading@10 53 ++frame_len_bits;
yading@10 54 } else if (tmp == 0x4) {
yading@10 55 --frame_len_bits;
yading@10 56 } else if (tmp == 0x6) {
yading@10 57 frame_len_bits -= 2;
yading@10 58 }
yading@10 59 }
yading@10 60
yading@10 61 return frame_len_bits;
yading@10 62 }