aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/wma_common.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-03-08 02:28:40 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-03-08 02:51:45 +0100
commitbf807a5e874442aa3fe1b475459cdd509e34bff4 (patch)
treef8067bfb5e99b8b8e2716a7ea8519a4aaa8ac60f /libavcodec/wma_common.c
parent4cda8aa1c5bc58f8a7f53a21a19b03e7379bbcdc (diff)
parent6eda85e15b38863a627fd0602098aa3250174698 (diff)
downloadffmpeg-bf807a5e874442aa3fe1b475459cdd509e34bff4.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: (29 commits) sbrdsp.asm: convert all instructions to float/SSE ones. dv: cosmetics. dv: check buffer size before reading profile. Revert "AAC SBR: group some writes." udp: Print an error message if bind fails cook: extend channel uncoupling tables so the full bit range is covered. roqvideo: cosmetics. roqvideo: convert to bytestream2 API. dca: don't use av_clip_uintp2(). wmall: fix build with -DDEBUG enabled. smc: port to bytestream2 API. AAC SBR: group some writes. dsputil: remove shift parameter from scalarproduct_int16 SBR DSP: unroll sum_square rv34: remove dead code in intra availability check rv34: clean a bit availability checks. v4l2: update documentation tgq: convert to bytestream2 API. parser: remove forward declaration of MpegEncContext dca: prevent accessing static arrays with invalid indexes. ... Conflicts: doc/indevs.texi libavcodec/Makefile libavcodec/dca.c libavcodec/dvdata.c libavcodec/eatgq.c libavcodec/mmvideo.c libavcodec/roqvideodec.c libavcodec/smc.c libswscale/output.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/wma_common.c')
-rw-r--r--libavcodec/wma_common.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/libavcodec/wma_common.c b/libavcodec/wma_common.c
new file mode 100644
index 0000000000..6ba5337f6a
--- /dev/null
+++ b/libavcodec/wma_common.c
@@ -0,0 +1,62 @@
+/*
+ * common code shared by all WMA variants
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/attributes.h"
+#include "wma_common.h"
+
+/**
+ *@brief Get the samples per frame for this stream.
+ *@param sample_rate output sample_rate
+ *@param version wma version
+ *@param decode_flags codec compression features
+ *@return log2 of the number of output samples per frame
+ */
+int av_cold ff_wma_get_frame_len_bits(int sample_rate, int version,
+ unsigned int decode_flags)
+{
+
+ int frame_len_bits;
+
+ if (sample_rate <= 16000) {
+ frame_len_bits = 9;
+ } else if (sample_rate <= 22050 ||
+ (sample_rate <= 32000 && version == 1)) {
+ frame_len_bits = 10;
+ } else if (sample_rate <= 48000 || version < 3) {
+ frame_len_bits = 11;
+ } else if (sample_rate <= 96000) {
+ frame_len_bits = 12;
+ } else {
+ frame_len_bits = 13;
+ }
+
+ if (version == 3) {
+ int tmp = decode_flags & 0x6;
+ if (tmp == 0x2) {
+ ++frame_len_bits;
+ } else if (tmp == 0x4) {
+ --frame_len_bits;
+ } else if (tmp == 0x6) {
+ frame_len_bits -= 2;
+ }
+ }
+
+ return frame_len_bits;
+}