mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-13 21:28:01 +02:00
mpegaudiodec: cosmetics: basic pretty-printing
This commit is contained in:
parent
c17e534f2e
commit
cd816d9bbb
@ -21,7 +21,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* MPEG Audio decoder.
|
||||
* MPEG Audio decoder
|
||||
*/
|
||||
|
||||
#include "libavutil/audioconvert.h"
|
||||
@ -92,7 +92,7 @@ typedef struct MPADecodeContext {
|
||||
# define OUT_FMT AV_SAMPLE_FMT_FLT
|
||||
#else
|
||||
# define SHR(a,b) ((a)>>(b))
|
||||
/* WARNING: only correct for posititive numbers */
|
||||
/* WARNING: only correct for positive numbers */
|
||||
# define FIXR_OLD(a) ((int)((a) * FRAC_ONE + 0.5))
|
||||
# define FIXR(a) ((int)((a) * FRAC_ONE + 0.5))
|
||||
# define FIXHR(a) ((int)((a) * (1LL<<32) + 0.5))
|
||||
@ -121,9 +121,7 @@ static const int huff_vlc_tables_sizes[16] = {
|
||||
};
|
||||
static VLC huff_quad_vlc[2];
|
||||
static VLC_TYPE huff_quad_vlc_tables[128+16][2];
|
||||
static const int huff_quad_vlc_tables_sizes[2] = {
|
||||
128, 16
|
||||
};
|
||||
static const int huff_quad_vlc_tables_sizes[2] = { 128, 16 };
|
||||
/* computed from band_size_long */
|
||||
static uint16_t band_index_long[9][23];
|
||||
#include "mpegaudio_tablegen.h"
|
||||
@ -160,9 +158,10 @@ static const int32_t scale_factor_mult2[3][3] = {
|
||||
* Convert region offsets to region sizes and truncate
|
||||
* size to big_values.
|
||||
*/
|
||||
static void ff_region_offset2size(GranuleDef *g){
|
||||
static void ff_region_offset2size(GranuleDef *g)
|
||||
{
|
||||
int i, k, j = 0;
|
||||
g->region_size[2] = (576 / 2);
|
||||
g->region_size[2] = 576 / 2;
|
||||
for (i = 0; i < 3; i++) {
|
||||
k = FFMIN(g->region_size[i], g->big_values);
|
||||
g->region_size[i] = k - j;
|
||||
@ -170,7 +169,8 @@ static void ff_region_offset2size(GranuleDef *g){
|
||||
}
|
||||
}
|
||||
|
||||
static void ff_init_short_region(MPADecodeContext *s, GranuleDef *g){
|
||||
static void ff_init_short_region(MPADecodeContext *s, GranuleDef *g)
|
||||
{
|
||||
if (g->block_type == 2)
|
||||
g->region_size[0] = (36 / 2);
|
||||
else {
|
||||
@ -184,17 +184,17 @@ static void ff_init_short_region(MPADecodeContext *s, GranuleDef *g){
|
||||
g->region_size[1] = (576 / 2);
|
||||
}
|
||||
|
||||
static void ff_init_long_region(MPADecodeContext *s, GranuleDef *g, int ra1, int ra2){
|
||||
static void ff_init_long_region(MPADecodeContext *s, GranuleDef *g, int ra1, int ra2)
|
||||
{
|
||||
int l;
|
||||
g->region_size[0] =
|
||||
band_index_long[s->sample_rate_index][ra1 + 1] >> 1;
|
||||
g->region_size[0] = band_index_long[s->sample_rate_index][ra1 + 1] >> 1;
|
||||
/* should not overflow */
|
||||
l = FFMIN(ra1 + ra2 + 2, 22);
|
||||
g->region_size[1] =
|
||||
band_index_long[s->sample_rate_index][l] >> 1;
|
||||
g->region_size[1] = band_index_long[s->sample_rate_index][ l] >> 1;
|
||||
}
|
||||
|
||||
static void ff_compute_band_indexes(MPADecodeContext *s, GranuleDef *g){
|
||||
static void ff_compute_band_indexes(MPADecodeContext *s, GranuleDef *g)
|
||||
{
|
||||
if (g->block_type == 2) {
|
||||
if (g->switch_point) {
|
||||
/* if switched mode, we handle the 36 first samples as
|
||||
@ -257,7 +257,7 @@ static inline int l3_unscale(int value, int exponent)
|
||||
|
||||
e = table_4_3_exp [4 * value + (exponent & 3)];
|
||||
m = table_4_3_value[4 * value + (exponent & 3)];
|
||||
e -= (exponent >> 2);
|
||||
e -= exponent >> 2;
|
||||
assert(e >= 1);
|
||||
if (e > 31)
|
||||
return 0;
|
||||
@ -286,7 +286,7 @@ static av_cold int decode_init(AVCodecContext * avctx)
|
||||
for (i = 0; i < 64; i++) {
|
||||
int shift, mod;
|
||||
/* 1.0 (i = 3) is normalized to 2 ^ FRAC_BITS */
|
||||
shift = (i / 3);
|
||||
shift = i / 3;
|
||||
mod = i % 3;
|
||||
scale_factor_modshift[i] = mod | (shift << 2);
|
||||
}
|
||||
@ -299,8 +299,7 @@ static av_cold int decode_init(AVCodecContext * avctx)
|
||||
scale_factor_mult[i][0] = MULLx(norm, FIXR(1.0 * 2.0), FRAC_BITS);
|
||||
scale_factor_mult[i][1] = MULLx(norm, FIXR(0.7937005259 * 2.0), FRAC_BITS);
|
||||
scale_factor_mult[i][2] = MULLx(norm, FIXR(0.6299605249 * 2.0), FRAC_BITS);
|
||||
av_dlog(avctx, "%d: norm=%x s=%x %x %x\n",
|
||||
i, norm,
|
||||
av_dlog(avctx, "%d: norm=%x s=%x %x %x\n", i, norm,
|
||||
scale_factor_mult[i][0],
|
||||
scale_factor_mult[i][1],
|
||||
scale_factor_mult[i][2]);
|
||||
@ -363,8 +362,8 @@ static av_cold int decode_init(AVCodecContext * avctx)
|
||||
|
||||
mpegaudio_tableinit();
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
if (ff_mpa_quant_bits[i] < 0)
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (ff_mpa_quant_bits[i] < 0) {
|
||||
for (j = 0; j < (1 << (-ff_mpa_quant_bits[i]+1)); j++) {
|
||||
int val1, val2, val3, steps;
|
||||
int val = j;
|
||||
@ -375,6 +374,8 @@ static av_cold int decode_init(AVCodecContext * avctx)
|
||||
val3 = val / steps;
|
||||
division_tabs[i][j] = val1 + (val2 << 4) + (val3 << 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (i = 0; i < 7; i++) {
|
||||
@ -619,9 +620,9 @@ static void imdct36(INTFLOAT *out, INTFLOAT *buf, INTFLOAT *in, INTFLOAT *win)
|
||||
t0 = s2 + s3;
|
||||
t1 = s2 - s3;
|
||||
out[(9 + 8 - j) * SBLIMIT] = MULH3(t1, win[ 9 + 8 - j], 1) + buf[9 + 8 - j];
|
||||
out[( j)*SBLIMIT] = MULH3(t1, win[ j], 1) + buf[ j];
|
||||
out[ j * SBLIMIT] = MULH3(t1, win[ j], 1) + buf[ j];
|
||||
buf[ 9 + 8 - j ] = MULH3(t0, win[18 + 9 + 8 - j], 1);
|
||||
buf[ + j] = MULH3(t0, win[18 + j], 1);
|
||||
buf[ j ] = MULH3(t0, win[18 + j], 1);
|
||||
i += 4;
|
||||
}
|
||||
|
||||
@ -653,9 +654,8 @@ static int mp_decode_layer1(MPADecodeContext *s)
|
||||
allocation[ch][i] = get_bits(&s->gb, 4);
|
||||
}
|
||||
}
|
||||
for(i=bound;i<SBLIMIT;i++) {
|
||||
for (i = bound; i < SBLIMIT; i++)
|
||||
allocation[0][i] = get_bits(&s->gb, 4);
|
||||
}
|
||||
|
||||
/* scale factors */
|
||||
for (i = 0; i < bound; i++) {
|
||||
@ -726,15 +726,15 @@ static int mp_decode_layer2(MPADecodeContext *s)
|
||||
av_dlog(s->avctx, "bound=%d sblimit=%d\n", bound, sblimit);
|
||||
|
||||
/* sanity check */
|
||||
if( bound > sblimit ) bound = sblimit;
|
||||
if (bound > sblimit)
|
||||
bound = sblimit;
|
||||
|
||||
/* parse bit allocation */
|
||||
j = 0;
|
||||
for (i = 0; i < bound; i++) {
|
||||
bit_alloc_bits = alloc_table[j];
|
||||
for(ch=0;ch<s->nb_channels;ch++) {
|
||||
for (ch = 0; ch < s->nb_channels; ch++)
|
||||
bit_alloc[ch][i] = get_bits(&s->gb, bit_alloc_bits);
|
||||
}
|
||||
j += 1 << bit_alloc_bits;
|
||||
}
|
||||
for (i = bound; i < sblimit; i++) {
|
||||
@ -909,8 +909,8 @@ static int mp_decode_layer2(MPADecodeContext *s)
|
||||
dst = 0; \
|
||||
}
|
||||
|
||||
static av_always_inline void lsf_sf_expand(int *slen,
|
||||
int sf, int n1, int n2, int n3)
|
||||
static av_always_inline void lsf_sf_expand(int *slen, int sf, int n1, int n2,
|
||||
int n3)
|
||||
{
|
||||
SPLIT(slen[3], sf, n3)
|
||||
SPLIT(slen[2], sf, n2)
|
||||
@ -918,8 +918,7 @@ static av_always_inline void lsf_sf_expand(int *slen,
|
||||
slen[0] = sf;
|
||||
}
|
||||
|
||||
static void exponents_from_scale_factors(MPADecodeContext *s,
|
||||
GranuleDef *g,
|
||||
static void exponents_from_scale_factors(MPADecodeContext *s, GranuleDef *g,
|
||||
int16_t *exponents)
|
||||
{
|
||||
const uint8_t *bstab, *pretab;
|
||||
@ -959,14 +958,13 @@ static void exponents_from_scale_factors(MPADecodeContext *s,
|
||||
/* handle n = 0 too */
|
||||
static inline int get_bitsz(GetBitContext *s, int n)
|
||||
{
|
||||
if (n == 0)
|
||||
return 0;
|
||||
else
|
||||
return get_bits(s, n);
|
||||
return n ? get_bits(s, n) : 0;
|
||||
}
|
||||
|
||||
|
||||
static void switch_buffer(MPADecodeContext *s, int *pos, int *end_pos, int *end_pos2){
|
||||
static void switch_buffer(MPADecodeContext *s, int *pos, int *end_pos,
|
||||
int *end_pos2)
|
||||
{
|
||||
if (s->in_gb.buffer && *pos >= s->gb.size_in_bits) {
|
||||
s->gb = s->in_gb;
|
||||
s->in_gb.buffer = NULL;
|
||||
@ -1160,11 +1158,10 @@ static void reorder_block(MPADecodeContext *s, GranuleDef *g)
|
||||
return;
|
||||
|
||||
if (g->switch_point) {
|
||||
if (s->sample_rate_index != 8) {
|
||||
if (s->sample_rate_index != 8)
|
||||
ptr = g->sb_hybrid + 36;
|
||||
} else {
|
||||
else
|
||||
ptr = g->sb_hybrid + 48;
|
||||
}
|
||||
} else {
|
||||
ptr = g->sb_hybrid;
|
||||
}
|
||||
@ -1186,8 +1183,7 @@ static void reorder_block(MPADecodeContext *s, GranuleDef *g)
|
||||
|
||||
#define ISQRT2 FIXR(0.70710678118654752440)
|
||||
|
||||
static void compute_stereo(MPADecodeContext *s,
|
||||
GranuleDef *g0, GranuleDef *g1)
|
||||
static void compute_stereo(MPADecodeContext *s, GranuleDef *g0, GranuleDef *g1)
|
||||
{
|
||||
int i, j, k, l;
|
||||
int sf_max, sf, len, non_zero_found;
|
||||
@ -1358,10 +1354,8 @@ static void compute_antialias(MPADecodeContext *s, GranuleDef *g)
|
||||
}
|
||||
}
|
||||
|
||||
static void compute_imdct(MPADecodeContext *s,
|
||||
GranuleDef *g,
|
||||
INTFLOAT *sb_samples,
|
||||
INTFLOAT *mdct_buf)
|
||||
static void compute_imdct(MPADecodeContext *s, GranuleDef *g,
|
||||
INTFLOAT *sb_samples, INTFLOAT *mdct_buf)
|
||||
{
|
||||
INTFLOAT *win, *win1, *out_ptr, *ptr, *buf, *ptr1;
|
||||
INTFLOAT out2[12];
|
||||
@ -1597,7 +1591,7 @@ static int mp_decode_layer3(MPADecodeContext *s)
|
||||
sc = s->granules[ch][0].scale_factors;
|
||||
j = 0;
|
||||
for (k = 0; k < 4; k++) {
|
||||
n = (k == 0 ? 6 : 5);
|
||||
n = k == 0 ? 6 : 5;
|
||||
if ((g->scfsi & (0x8 >> k)) == 0) {
|
||||
slen = (k < 2) ? slen1 : slen2;
|
||||
if (slen) {
|
||||
@ -1621,11 +1615,11 @@ static int mp_decode_layer3(MPADecodeContext *s)
|
||||
int tindex, tindex2, slen[4], sl, sf;
|
||||
|
||||
/* LSF scale factors */
|
||||
if (g->block_type == 2) {
|
||||
if (g->block_type == 2)
|
||||
tindex = g->switch_point ? 2 : 1;
|
||||
} else {
|
||||
else
|
||||
tindex = 0;
|
||||
}
|
||||
|
||||
sf = g->scalefac_compress;
|
||||
if ((s->mode_ext & MODE_EXT_I_STEREO) && ch == 1) {
|
||||
/* intensity stereo case */
|
||||
@ -1694,8 +1688,8 @@ static int mp_decode_layer3(MPADecodeContext *s)
|
||||
return nb_granules * 18;
|
||||
}
|
||||
|
||||
static int mp_decode_frame(MPADecodeContext *s,
|
||||
OUT_INT *samples, const uint8_t *buf, int buf_size)
|
||||
static int mp_decode_frame(MPADecodeContext *s, OUT_INT *samples,
|
||||
const uint8_t *buf, int buf_size)
|
||||
{
|
||||
int i, nb_frames, ch;
|
||||
OUT_INT *samples_ptr;
|
||||
@ -1766,8 +1760,7 @@ static int mp_decode_frame(MPADecodeContext *s,
|
||||
return nb_frames * 32 * sizeof(OUT_INT) * s->nb_channels;
|
||||
}
|
||||
|
||||
static int decode_frame(AVCodecContext * avctx,
|
||||
void *data, int *data_size,
|
||||
static int decode_frame(AVCodecContext * avctx, void *data, int *data_size,
|
||||
AVPacket *avpkt)
|
||||
{
|
||||
const uint8_t *buf = avpkt->data;
|
||||
@ -1828,15 +1821,15 @@ static int decode_frame(AVCodecContext * avctx,
|
||||
return buf_size;
|
||||
}
|
||||
|
||||
static void flush(AVCodecContext *avctx){
|
||||
static void flush(AVCodecContext *avctx)
|
||||
{
|
||||
MPADecodeContext *s = avctx->priv_data;
|
||||
memset(s->synth_buf, 0, sizeof(s->synth_buf));
|
||||
s->last_buf_size = 0;
|
||||
}
|
||||
|
||||
#if CONFIG_MP3ADU_DECODER || CONFIG_MP3ADUFLOAT_DECODER
|
||||
static int decode_frame_adu(AVCodecContext * avctx,
|
||||
void *data, int *data_size,
|
||||
static int decode_frame_adu(AVCodecContext *avctx, void *data, int *data_size,
|
||||
AVPacket *avpkt)
|
||||
{
|
||||
const uint8_t *buf = avpkt->data;
|
||||
@ -1876,11 +1869,10 @@ static int decode_frame_adu(AVCodecContext * avctx,
|
||||
|
||||
s->frame_size = len;
|
||||
|
||||
if (avctx->parse_only) {
|
||||
if (avctx->parse_only)
|
||||
out_size = buf_size;
|
||||
} else {
|
||||
else
|
||||
out_size = mp_decode_frame(s, out_samples, buf, buf_size);
|
||||
}
|
||||
|
||||
*data_size = out_size;
|
||||
return buf_size;
|
||||
@ -1895,7 +1887,7 @@ static int decode_frame_adu(AVCodecContext * avctx,
|
||||
typedef struct MP3On4DecodeContext {
|
||||
int frames; ///< number of mp3 frames per block (number of mp3 decoder instances)
|
||||
int syncword; ///< syncword patch
|
||||
const uint8_t *coff; ///< channels offsets in output buffer
|
||||
const uint8_t *coff; ///< channel offsets in output buffer
|
||||
MPADecodeContext *mp3decctx[5]; ///< MPADecodeContext for every decoder instance
|
||||
OUT_INT *decoded_buf; ///< output buffer for decoded samples
|
||||
} MP3On4DecodeContext;
|
||||
@ -1903,7 +1895,10 @@ typedef struct MP3On4DecodeContext {
|
||||
#include "mpeg4audio.h"
|
||||
|
||||
/* Next 3 arrays are indexed by channel config number (passed via codecdata) */
|
||||
static const uint8_t mp3Frames[8] = {0,1,1,2,3,3,4,5}; /* number of mp3 decoder instances */
|
||||
|
||||
/* number of mp3 decoder instances */
|
||||
static const uint8_t mp3Frames[8] = { 0, 1, 1, 2, 3, 3, 4, 5 };
|
||||
|
||||
/* offsets into output buffer, assume output order is FL FR C LFE BL BR SL SR */
|
||||
static const uint8_t chan_offset[8][5] = {
|
||||
{ 0 },
|
||||
|
Loading…
Reference in New Issue
Block a user