mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
wma: Refactor common code to fix standalone compilation of WMA lossless decoder.
This commit is contained in:
parent
3c715383ea
commit
8ca6e523a6
@ -92,8 +92,8 @@ OBJS-$(CONFIG_AVS_DECODER) += avs.o
|
|||||||
OBJS-$(CONFIG_BETHSOFTVID_DECODER) += bethsoftvideo.o
|
OBJS-$(CONFIG_BETHSOFTVID_DECODER) += bethsoftvideo.o
|
||||||
OBJS-$(CONFIG_BFI_DECODER) += bfi.o
|
OBJS-$(CONFIG_BFI_DECODER) += bfi.o
|
||||||
OBJS-$(CONFIG_BINK_DECODER) += bink.o binkdsp.o
|
OBJS-$(CONFIG_BINK_DECODER) += bink.o binkdsp.o
|
||||||
OBJS-$(CONFIG_BINKAUDIO_DCT_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
|
OBJS-$(CONFIG_BINKAUDIO_RDFT_DECODER) += binkaudio.o wma.o wma_common.o
|
||||||
OBJS-$(CONFIG_BMP_DECODER) += bmp.o msrledec.o
|
OBJS-$(CONFIG_BMP_DECODER) += bmp.o msrledec.o
|
||||||
OBJS-$(CONFIG_BMP_ENCODER) += bmpenc.o
|
OBJS-$(CONFIG_BMP_ENCODER) += bmpenc.o
|
||||||
OBJS-$(CONFIG_BMV_VIDEO_DECODER) += bmv.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_VP8_DECODER) += vp8.o vp8dsp.o vp56rac.o
|
||||||
OBJS-$(CONFIG_VQA_DECODER) += vqavideo.o
|
OBJS-$(CONFIG_VQA_DECODER) += vqavideo.o
|
||||||
OBJS-$(CONFIG_WAVPACK_DECODER) += wavpack.o
|
OBJS-$(CONFIG_WAVPACK_DECODER) += wavpack.o
|
||||||
OBJS-$(CONFIG_WMALOSSLESS_DECODER) += wmalosslessdec.o wma.o
|
OBJS-$(CONFIG_WMALOSSLESS_DECODER) += wmalosslessdec.o wma_common.o
|
||||||
OBJS-$(CONFIG_WMAPRO_DECODER) += wmaprodec.o wma.o
|
OBJS-$(CONFIG_WMAPRO_DECODER) += wmaprodec.o wma.o wma_common.o
|
||||||
OBJS-$(CONFIG_WMAV1_DECODER) += wmadec.o wma.o aactab.o
|
OBJS-$(CONFIG_WMAV1_DECODER) += wmadec.o wma.o wma_common.o aactab.o
|
||||||
OBJS-$(CONFIG_WMAV1_ENCODER) += wmaenc.o wma.o aactab.o
|
OBJS-$(CONFIG_WMAV1_ENCODER) += wmaenc.o wma.o wma_common.o aactab.o
|
||||||
OBJS-$(CONFIG_WMAV2_DECODER) += wmadec.o wma.o aactab.o
|
OBJS-$(CONFIG_WMAV2_DECODER) += wmadec.o wma.o wma_common.o aactab.o
|
||||||
OBJS-$(CONFIG_WMAV2_ENCODER) += wmaenc.o wma.o aactab.o
|
OBJS-$(CONFIG_WMAV2_ENCODER) += wmaenc.o wma.o wma_common.o aactab.o
|
||||||
OBJS-$(CONFIG_WMAVOICE_DECODER) += wmavoice.o \
|
OBJS-$(CONFIG_WMAVOICE_DECODER) += wmavoice.o \
|
||||||
celp_math.o celp_filters.o \
|
celp_math.o celp_filters.o \
|
||||||
acelp_vectors.o acelp_filters.o
|
acelp_vectors.o acelp_filters.o
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "avcodec.h"
|
#include "avcodec.h"
|
||||||
#include "sinewin.h"
|
#include "sinewin.h"
|
||||||
#include "wma.h"
|
#include "wma.h"
|
||||||
|
#include "wma_common.h"
|
||||||
#include "wmadata.h"
|
#include "wmadata.h"
|
||||||
|
|
||||||
#undef NDEBUG
|
#undef NDEBUG
|
||||||
@ -67,46 +68,6 @@ static void init_coef_vlc(VLC *vlc, uint16_t **prun_table,
|
|||||||
av_free(level_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)
|
int ff_wma_init(AVCodecContext *avctx, int flags2)
|
||||||
{
|
{
|
||||||
WMACodecContext *s = avctx->priv_data;
|
WMACodecContext *s = avctx->priv_data;
|
||||||
|
@ -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 uint32_t ff_aac_scalefactor_code[121];
|
||||||
extern const uint8_t ff_aac_scalefactor_bits[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_init(AVCodecContext * avctx, int flags2);
|
||||||
int ff_wma_total_gain_to_bits(int total_gain);
|
int ff_wma_total_gain_to_bits(int total_gain);
|
||||||
int ff_wma_end(AVCodecContext *avctx);
|
int ff_wma_end(AVCodecContext *avctx);
|
||||||
|
62
libavcodec/wma_common.c
Normal file
62
libavcodec/wma_common.c
Normal file
@ -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;
|
||||||
|
}
|
29
libavcodec/wma_common.h
Normal file
29
libavcodec/wma_common.h
Normal file
@ -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 */
|
@ -27,6 +27,7 @@
|
|||||||
#include "get_bits.h"
|
#include "get_bits.h"
|
||||||
#include "put_bits.h"
|
#include "put_bits.h"
|
||||||
#include "wma.h"
|
#include "wma.h"
|
||||||
|
#include "wma_common.h"
|
||||||
|
|
||||||
/** current decoder limitations */
|
/** current decoder limitations */
|
||||||
#define WMALL_MAX_CHANNELS 8 ///< max number of handled channels
|
#define WMALL_MAX_CHANNELS 8 ///< max number of handled channels
|
||||||
|
@ -97,6 +97,7 @@
|
|||||||
#include "fmtconvert.h"
|
#include "fmtconvert.h"
|
||||||
#include "sinewin.h"
|
#include "sinewin.h"
|
||||||
#include "wma.h"
|
#include "wma.h"
|
||||||
|
#include "wma_common.h"
|
||||||
|
|
||||||
/** current decoder limitations */
|
/** current decoder limitations */
|
||||||
#define WMAPRO_MAX_CHANNELS 8 ///< max number of handled channels
|
#define WMAPRO_MAX_CHANNELS 8 ///< max number of handled channels
|
||||||
|
Loading…
Reference in New Issue
Block a user