aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiego Biurrun <diego@biurrun.de>2012-03-06 19:07:10 +0100
committerDiego Biurrun <diego@biurrun.de>2012-03-07 09:36:05 +0100
commit8ca6e523a604db69c151b20627fb3bcc52118392 (patch)
treec0f0d2b9150762825e4f8143b234a7fb036d02a6
parent3c715383ea7012ac69507e6b9189c98675c77461 (diff)
downloadffmpeg-8ca6e523a604db69c151b20627fb3bcc52118392.tar.gz
wma: Refactor common code to fix standalone compilation of WMA lossless decoder.
-rw-r--r--libavcodec/Makefile16
-rw-r--r--libavcodec/wma.c41
-rw-r--r--libavcodec/wma.h2
-rw-r--r--libavcodec/wma_common.c62
-rw-r--r--libavcodec/wma_common.h29
-rw-r--r--libavcodec/wmalosslessdec.c1
-rw-r--r--libavcodec/wmaprodec.c1
7 files changed, 102 insertions, 50 deletions
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index ba83d3576c..d4ad81cc92 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -92,8 +92,8 @@ OBJS-$(CONFIG_AVS_DECODER) += avs.o
OBJS-$(CONFIG_BETHSOFTVID_DECODER) += bethsoftvideo.o
OBJS-$(CONFIG_BFI_DECODER) += bfi.o
OBJS-$(CONFIG_BINK_DECODER) += bink.o binkdsp.o
-OBJS-$(CONFIG_BINKAUDIO_DCT_DECODER) += binkaudio.o wma.o
-OBJS-$(CONFIG_BINKAUDIO_RDFT_DECODER) += binkaudio.o wma.o
+OBJS-$(CONFIG_BINKAUDIO_DCT_DECODER) += binkaudio.o wma.o wma_common.o
+OBJS-$(CONFIG_BINKAUDIO_RDFT_DECODER) += binkaudio.o wma.o wma_common.o
OBJS-$(CONFIG_BMP_DECODER) += bmp.o msrledec.o
OBJS-$(CONFIG_BMP_ENCODER) += bmpenc.o
OBJS-$(CONFIG_BMV_VIDEO_DECODER) += bmv.o
@@ -419,12 +419,12 @@ OBJS-$(CONFIG_VP6_DECODER) += vp6.o vp56.o vp56data.o vp56dsp.o \
OBJS-$(CONFIG_VP8_DECODER) += vp8.o vp8dsp.o vp56rac.o
OBJS-$(CONFIG_VQA_DECODER) += vqavideo.o
OBJS-$(CONFIG_WAVPACK_DECODER) += wavpack.o
-OBJS-$(CONFIG_WMALOSSLESS_DECODER) += wmalosslessdec.o wma.o
-OBJS-$(CONFIG_WMAPRO_DECODER) += wmaprodec.o wma.o
-OBJS-$(CONFIG_WMAV1_DECODER) += wmadec.o wma.o aactab.o
-OBJS-$(CONFIG_WMAV1_ENCODER) += wmaenc.o wma.o aactab.o
-OBJS-$(CONFIG_WMAV2_DECODER) += wmadec.o wma.o aactab.o
-OBJS-$(CONFIG_WMAV2_ENCODER) += wmaenc.o wma.o aactab.o
+OBJS-$(CONFIG_WMALOSSLESS_DECODER) += wmalosslessdec.o wma_common.o
+OBJS-$(CONFIG_WMAPRO_DECODER) += wmaprodec.o wma.o wma_common.o
+OBJS-$(CONFIG_WMAV1_DECODER) += wmadec.o wma.o wma_common.o aactab.o
+OBJS-$(CONFIG_WMAV1_ENCODER) += wmaenc.o wma.o wma_common.o aactab.o
+OBJS-$(CONFIG_WMAV2_DECODER) += wmadec.o wma.o wma_common.o aactab.o
+OBJS-$(CONFIG_WMAV2_ENCODER) += wmaenc.o wma.o wma_common.o aactab.o
OBJS-$(CONFIG_WMAVOICE_DECODER) += wmavoice.o \
celp_math.o celp_filters.o \
acelp_vectors.o acelp_filters.o
diff --git a/libavcodec/wma.c b/libavcodec/wma.c
index 371aad574d..007653ffec 100644
--- a/libavcodec/wma.c
+++ b/libavcodec/wma.c
@@ -22,6 +22,7 @@
#include "avcodec.h"
#include "sinewin.h"
#include "wma.h"
+#include "wma_common.h"
#include "wmadata.h"
#undef NDEBUG
@@ -67,46 +68,6 @@ static void init_coef_vlc(VLC *vlc, uint16_t **prun_table,
av_free(level_table);
}
-/**
- *@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;
-}
-
int ff_wma_init(AVCodecContext *avctx, int flags2)
{
WMACodecContext *s = avctx->priv_data;
diff --git a/libavcodec/wma.h b/libavcodec/wma.h
index d6f4880c14..15838eb685 100644
--- a/libavcodec/wma.h
+++ b/libavcodec/wma.h
@@ -150,8 +150,6 @@ extern const float ff_wma_lsp_codebook[NB_LSP_COEFS][16];
extern const uint32_t ff_aac_scalefactor_code[121];
extern const uint8_t ff_aac_scalefactor_bits[121];
-int av_cold ff_wma_get_frame_len_bits(int sample_rate, int version,
- unsigned int decode_flags);
int ff_wma_init(AVCodecContext * avctx, int flags2);
int ff_wma_total_gain_to_bits(int total_gain);
int ff_wma_end(AVCodecContext *avctx);
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;
+}
diff --git a/libavcodec/wma_common.h b/libavcodec/wma_common.h
new file mode 100644
index 0000000000..cc4e38e149
--- /dev/null
+++ b/libavcodec/wma_common.h
@@ -0,0 +1,29 @@
+/*
+ * 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
+ */
+
+#ifndef AVCODEC_WMA_COMMON_H
+#define AVCODEC_WMA_COMMON_H
+
+#include "libavutil/attributes.h"
+
+int av_cold ff_wma_get_frame_len_bits(int sample_rate, int version,
+ unsigned int decode_flags);
+
+#endif /* AVCODEC_WMA_COMMON_H */
diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c
index d311c39605..db2d4844db 100644
--- a/libavcodec/wmalosslessdec.c
+++ b/libavcodec/wmalosslessdec.c
@@ -27,6 +27,7 @@
#include "get_bits.h"
#include "put_bits.h"
#include "wma.h"
+#include "wma_common.h"
/** current decoder limitations */
#define WMALL_MAX_CHANNELS 8 ///< max number of handled channels
diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c
index 2b9f4a5d8b..65ca3c8e58 100644
--- a/libavcodec/wmaprodec.c
+++ b/libavcodec/wmaprodec.c
@@ -97,6 +97,7 @@
#include "fmtconvert.h"
#include "sinewin.h"
#include "wma.h"
+#include "wma_common.h"
/** current decoder limitations */
#define WMAPRO_MAX_CHANNELS 8 ///< max number of handled channels