Commit d2a4e4b9 authored by Gabriel Dume's avatar Gabriel Dume Committed by Diego Biurrun

wma: K&R formatting cosmetics

Signed-off-by: 's avatarDiego Biurrun <diego@biurrun.de>
parent c487972e
This diff is collapsed.
...@@ -23,10 +23,11 @@ ...@@ -23,10 +23,11 @@
#define AVCODEC_WMA_H #define AVCODEC_WMA_H
#include "libavutil/float_dsp.h" #include "libavutil/float_dsp.h"
#include "get_bits.h"
#include "put_bits.h"
#include "fft.h" #include "fft.h"
#include "fmtconvert.h" #include "fmtconvert.h"
#include "get_bits.h"
#include "put_bits.h"
/* size of blocks */ /* size of blocks */
#define BLOCK_MIN_BITS 7 #define BLOCK_MIN_BITS 7
...@@ -49,9 +50,9 @@ ...@@ -49,9 +50,9 @@
#define LSP_POW_BITS 7 #define LSP_POW_BITS 7
//FIXME should be in wmadec // FIXME should be in wmadec
#define VLCBITS 9 #define VLCBITS 9
#define VLCMAX ((22+VLCBITS-1)/VLCBITS) #define VLCMAX ((22 + VLCBITS - 1) / VLCBITS)
typedef float WMACoef; ///< type for decoded coefficients, int16_t would be enough for wma 1/2 typedef float WMACoef; ///< type for decoded coefficients, int16_t would be enough for wma 1/2
...@@ -64,7 +65,7 @@ typedef struct CoefVLCTable { ...@@ -64,7 +65,7 @@ typedef struct CoefVLCTable {
} CoefVLCTable; } CoefVLCTable;
typedef struct WMACodecContext { typedef struct WMACodecContext {
AVCodecContext* avctx; AVCodecContext *avctx;
GetBitContext gb; GetBitContext gb;
PutBitContext pb; PutBitContext pb;
int version; ///< 1 = 0x160 (WMAV1), 2 = 0x161 (WMAV2) int version; ///< 1 = 0x160 (WMAV1), 2 = 0x161 (WMAV2)
...@@ -88,7 +89,7 @@ typedef struct WMACodecContext { ...@@ -88,7 +89,7 @@ typedef struct WMACodecContext {
int high_band_values[MAX_CHANNELS][HIGH_BAND_MAX_SIZE]; int high_band_values[MAX_CHANNELS][HIGH_BAND_MAX_SIZE];
/* there are two possible tables for spectral coefficients */ /* there are two possible tables for spectral coefficients */
//FIXME the following 3 tables should be shared between decoders // FIXME the following 3 tables should be shared between decoders
VLC coef_vlc[2]; VLC coef_vlc[2];
uint16_t *run_table[2]; uint16_t *run_table[2];
float *level_table[2]; float *level_table[2];
...@@ -135,7 +136,7 @@ typedef struct WMACodecContext { ...@@ -135,7 +136,7 @@ typedef struct WMACodecContext {
#ifdef TRACE #ifdef TRACE
int frame_count; int frame_count;
#endif #endif /* TRACE */
} WMACodecContext; } WMACodecContext;
extern const uint16_t ff_wma_critical_freqs[25]; extern const uint16_t ff_wma_critical_freqs[25];
...@@ -145,15 +146,15 @@ extern const float ff_wma_lsp_codebook[NB_LSP_COEFS][16]; ...@@ -145,15 +146,15 @@ 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 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);
unsigned int ff_wma_get_large_val(GetBitContext* gb); unsigned int ff_wma_get_large_val(GetBitContext *gb);
int ff_wma_run_level_decode(AVCodecContext* avctx, GetBitContext* gb, int ff_wma_run_level_decode(AVCodecContext *avctx, GetBitContext *gb,
VLC *vlc, VLC *vlc, const float *level_table,
const float *level_table, const uint16_t *run_table, const uint16_t *run_table, int version,
int version, WMACoef *ptr, int offset, WMACoef *ptr, int offset, int num_coefs,
int num_coefs, int block_len, int frame_len_bits, int block_len, int frame_len_bits,
int coef_nb_bits); int coef_nb_bits);
#endif /* AVCODEC_WMA_H */ #endif /* AVCODEC_WMA_H */
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
*/ */
#include "libavutil/attributes.h" #include "libavutil/attributes.h"
#include "wma_common.h" #include "wma_common.h"
/** /**
...@@ -31,32 +32,28 @@ ...@@ -31,32 +32,28 @@
av_cold int ff_wma_get_frame_len_bits(int sample_rate, int version, av_cold int ff_wma_get_frame_len_bits(int sample_rate, int version,
unsigned int decode_flags) unsigned int decode_flags)
{ {
int frame_len_bits; int frame_len_bits;
if (sample_rate <= 16000) { if (sample_rate <= 16000)
frame_len_bits = 9; frame_len_bits = 9;
} else if (sample_rate <= 22050 || else if (sample_rate <= 22050 || (sample_rate <= 32000 && version == 1))
(sample_rate <= 32000 && version == 1)) {
frame_len_bits = 10; frame_len_bits = 10;
} else if (sample_rate <= 48000 || version < 3) { else if (sample_rate <= 48000 || version < 3)
frame_len_bits = 11; frame_len_bits = 11;
} else if (sample_rate <= 96000) { else if (sample_rate <= 96000)
frame_len_bits = 12; frame_len_bits = 12;
} else { else
frame_len_bits = 13; frame_len_bits = 13;
}
if (version == 3) { if (version == 3) {
int tmp = decode_flags & 0x6; int tmp = decode_flags & 0x6;
if (tmp == 0x2) { if (tmp == 0x2)
++frame_len_bits; ++frame_len_bits;
} else if (tmp == 0x4) { else if (tmp == 0x4)
--frame_len_bits; --frame_len_bits;
} else if (tmp == 0x6) { else if (tmp == 0x6)
frame_len_bits -= 2; frame_len_bits -= 2;
} }
}
return frame_len_bits; return frame_len_bits;
} }
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#define AVCODEC_WMADATA_H #define AVCODEC_WMADATA_H
#include <stdint.h> #include <stdint.h>
#include "wma.h" #include "wma.h"
const uint16_t ff_wma_critical_freqs[25] = { const uint16_t ff_wma_critical_freqs[25] = {
...@@ -41,7 +42,8 @@ const uint16_t ff_wma_critical_freqs[25] = { ...@@ -41,7 +42,8 @@ const uint16_t ff_wma_critical_freqs[25] = {
static const uint8_t exponent_band_22050[3][25] = { static const uint8_t exponent_band_22050[3][25] = {
{ 10, 4, 8, 4, 8, 8, 12, 20, 24, 24, 16, }, { 10, 4, 8, 4, 8, 8, 12, 20, 24, 24, 16, },
{ 14, 4, 8, 8, 4, 12, 12, 16, 24, 16, 20, 24, 32, 40, 36, }, { 14, 4, 8, 8, 4, 12, 12, 16, 24, 16, 20, 24, 32, 40, 36, },
{ 23, 4, 4, 4, 8, 4, 4, 8, 8, 8, 8, 8, 12, 12, 16, 16, 24, 24, 32, 44, 48, 60, 84, 72, }, { 23, 4, 4, 4, 8, 4, 4, 8, 8, 8, 8, 8, 12, 12, 16, 16,
24, 24, 32, 44, 48, 60, 84, 72, },
}; };
static const uint8_t exponent_band_32000[3][25] = { static const uint8_t exponent_band_32000[3][25] = {
...@@ -65,10 +67,8 @@ const uint16_t ff_wma_hgain_huffcodes[37] = { ...@@ -65,10 +67,8 @@ const uint16_t ff_wma_hgain_huffcodes[37] = {
}; };
const uint8_t ff_wma_hgain_huffbits[37] = { const uint8_t ff_wma_hgain_huffbits[37] = {
10, 12, 10, 13, 9, 13, 9, 8, 10, 12, 10, 13, 9, 13, 9, 8, 7, 5, 5, 4, 4, 3, 3, 3,
7, 5, 5, 4, 4, 3, 3, 3, 4, 3, 4, 4, 5, 5, 6, 8, 7, 10, 8, 10, 9, 8, 9, 9,
4, 3, 4, 4, 5, 5, 6, 8,
7, 10, 8, 10, 9, 8, 9, 9,
13, 10, 13, 13, 13, 13, 10, 13, 13, 13,
}; };
...@@ -1269,7 +1269,7 @@ static const uint8_t coef5_huffbits[435] = { ...@@ -1269,7 +1269,7 @@ static const uint8_t coef5_huffbits[435] = {
}; };
static const uint16_t levels0[60] = { static const uint16_t levels0[60] = {
317, 92, 62, 60, 19, 17, 10, 7, 317, 92, 62, 60, 19, 17, 10, 7,
6, 5, 5, 3, 3, 3, 2, 2, 6, 5, 5, 3, 3, 3, 2, 2,
2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
...@@ -1280,7 +1280,7 @@ static const uint16_t levels0[60] = { ...@@ -1280,7 +1280,7 @@ static const uint16_t levels0[60] = {
}; };
static const uint16_t levels1[40] = { static const uint16_t levels1[40] = {
311, 91, 61, 28, 10, 6, 5, 2, 311, 91, 61, 28, 10, 6, 5, 2,
2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
...@@ -1288,7 +1288,7 @@ static const uint16_t levels1[40] = { ...@@ -1288,7 +1288,7 @@ static const uint16_t levels1[40] = {
}; };
static const uint16_t levels2[340] = { static const uint16_t levels2[340] = {
181,110, 78, 63, 61, 62, 60, 61, 181, 110, 78, 63, 61, 62, 60, 61,
33, 41, 41, 19, 17, 19, 12, 11, 33, 41, 41, 19, 17, 19, 12, 11,
9, 11, 10, 6, 8, 7, 6, 4, 9, 11, 10, 6, 8, 7, 6, 4,
5, 5, 4, 4, 3, 4, 3, 5, 5, 5, 4, 4, 3, 4, 3, 5,
...@@ -1334,7 +1334,7 @@ static const uint16_t levels2[340] = { ...@@ -1334,7 +1334,7 @@ static const uint16_t levels2[340] = {
}; };
static const uint16_t levels3[180] = { static const uint16_t levels3[180] = {
351,122, 76, 61, 41, 42, 24, 30, 351, 122, 76, 61, 41, 42, 24, 30,
22, 19, 11, 9, 10, 8, 5, 5, 22, 19, 11, 9, 10, 8, 5, 5,
4, 5, 5, 3, 3, 3, 3, 3, 4, 5, 5, 3, 3, 3, 3, 3,
3, 3, 2, 2, 3, 2, 2, 2, 3, 3, 2, 2, 3, 2, 2, 2,
...@@ -1360,7 +1360,7 @@ static const uint16_t levels3[180] = { ...@@ -1360,7 +1360,7 @@ static const uint16_t levels3[180] = {
}; };
static const uint16_t levels4[70] = { static const uint16_t levels4[70] = {
113, 68, 49, 42, 40, 32, 27, 15, 113, 68, 49, 42, 40, 32, 27, 15,
10, 5, 3, 3, 3, 3, 2, 2, 10, 5, 3, 3, 3, 3, 2, 2,
2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
...@@ -1372,7 +1372,7 @@ static const uint16_t levels4[70] = { ...@@ -1372,7 +1372,7 @@ static const uint16_t levels4[70] = {
}; };
static const uint16_t levels5[40] = { static const uint16_t levels5[40] = {
214, 72, 42, 40, 18, 4, 4, 2, 214, 72, 42, 40, 18, 4, 4, 2,
2, 2, 2, 2, 1, 1, 2, 1, 2, 2, 2, 2, 1, 1, 2, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
...@@ -1380,24 +1380,12 @@ static const uint16_t levels5[40] = { ...@@ -1380,24 +1380,12 @@ static const uint16_t levels5[40] = {
}; };
static const CoefVLCTable coef_vlcs[6] = { static const CoefVLCTable coef_vlcs[6] = {
{ { sizeof(coef0_huffbits), sizeof(levels0) / 2, coef0_huffcodes, coef0_huffbits, levels0, },
sizeof(coef0_huffbits), sizeof(levels0)/2, coef0_huffcodes, coef0_huffbits, levels0, { sizeof(coef1_huffbits), sizeof(levels1) / 2, coef1_huffcodes, coef1_huffbits, levels1, },
}, { sizeof(coef2_huffbits), sizeof(levels2) / 2, coef2_huffcodes, coef2_huffbits, levels2, },
{ { sizeof(coef3_huffbits), sizeof(levels3) / 2, coef3_huffcodes, coef3_huffbits, levels3, },
sizeof(coef1_huffbits), sizeof(levels1)/2, coef1_huffcodes, coef1_huffbits, levels1, { sizeof(coef4_huffbits), sizeof(levels4) / 2, coef4_huffcodes, coef4_huffbits, levels4, },
}, { sizeof(coef5_huffbits), sizeof(levels5) / 2, coef5_huffcodes, coef5_huffbits, levels5, },
{
sizeof(coef2_huffbits), sizeof(levels2)/2, coef2_huffcodes, coef2_huffbits, levels2,
},
{
sizeof(coef3_huffbits), sizeof(levels3)/2, coef3_huffcodes, coef3_huffbits, levels3,
},
{
sizeof(coef4_huffbits), sizeof(levels4)/2, coef4_huffcodes, coef4_huffbits, levels4,
},
{
sizeof(coef5_huffbits), sizeof(levels5)/2, coef5_huffcodes, coef5_huffbits, levels5,
},
}; };
#endif /* AVCODEC_WMADATA_H */ #endif /* AVCODEC_WMADATA_H */
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment