1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

whitespace cosmetics, prettyprinting, K&R coding style

Originally committed as revision 20080 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Diego Biurrun 2009-09-29 11:43:58 +00:00
parent badce93dad
commit a7adcf29cf
5 changed files with 3190 additions and 3186 deletions

View File

@ -2,7 +2,7 @@
* @file libavcodec/vorbis.c
* Common code for Vorbis I encoder and decoder
* @author Denes Balatoni ( dbalatoni programozo hu )
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
@ -53,7 +53,8 @@ unsigned int ff_vorbis_nth_root(unsigned int x, unsigned int n)
// reasonable to check redundantly.
int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, uint_fast32_t num)
{
uint_fast32_t exit_at_level[33]={404,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
uint_fast32_t exit_at_level[33] = {
404, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
uint_fast8_t i, j;

View File

@ -2156,4 +2156,3 @@ const float * const ff_vorbis_vwin[8] = {
vwin64, vwin128, vwin256, vwin512,
vwin1024, vwin2048, vwin4096, vwin8192
};

View File

@ -2,7 +2,7 @@
* @file libavcodec/vorbis_dec.c
* Vorbis I decoder
* @author Denes Balatoni ( dbalatoni programozo hu )
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
@ -642,9 +642,9 @@ static int vorbis_parse_setup_hdr_residues(vorbis_context *vc)
res_setup->end = get_bits(gb, 24);
res_setup->partition_size = get_bits(gb, 24) + 1;
/* Validations to prevent a buffer overflow later. */
if (res_setup->begin>res_setup->end
|| res_setup->end>vc->blocksize[1]/(res_setup->type==2?1:2)
|| (res_setup->end-res_setup->begin)/res_setup->partition_size>V_MAX_PARTITIONS) {
if (res_setup->begin>res_setup->end ||
res_setup->end>vc->blocksize[1] / (res_setup->type == 2 ? 1 : 2) ||
(res_setup->end-res_setup->begin) / res_setup->partition_size > V_MAX_PARTITIONS) {
av_log(vc->avccontext, AV_LOG_ERROR, "partition out of bounds: type, begin, end, size, blocksize: %"PRIdFAST16", %"PRIdFAST32", %"PRIdFAST32", %"PRIdFAST32", %"PRIdFAST32"\n", res_setup->type, res_setup->begin, res_setup->end, res_setup->partition_size, vc->blocksize[1] / 2);
return -1;
}
@ -920,8 +920,7 @@ static int vorbis_parse_id_hdr(vorbis_context *vc)
return -3;
}
// output format int16
if (vc->blocksize[1]/2 * vc->audio_channels * 2 >
AVCODEC_MAX_AUDIO_FRAME_SIZE) {
if (vc->blocksize[1] / 2 * vc->audio_channels * 2 > AVCODEC_MAX_AUDIO_FRAME_SIZE) {
av_log(vc->avccontext, AV_LOG_ERROR, "Vorbis channel count makes "
"output packets too large.\n");
return -4;
@ -1057,11 +1056,9 @@ static uint_fast8_t vorbis_floor0_decode(vorbis_context *vc,
AV_DEBUG("floor0 dec: book dimension: %d\n", codebook.dimensions);
AV_DEBUG("floor0 dec: maximum depth: %d\n", codebook.maxdepth);
/* read temp vector */
vec_off=get_vlc2(&vc->gb,
codebook.vlc.table,
codebook.nb_bits,
codebook.maxdepth ) *
codebook.dimensions;
vec_off = get_vlc2(&vc->gb, codebook.vlc.table,
codebook.nb_bits, codebook.maxdepth)
* codebook.dimensions;
AV_DEBUG("floor0 dec: vector offset: %d\n", vec_off);
/* copy each vector component and add last to it */
for (idx = 0; idx < codebook.dimensions; ++idx)
@ -1116,11 +1113,9 @@ static uint_fast8_t vorbis_floor0_decode(vorbis_context *vc,
/* calculate linear floor value */
{
q=exp( (
( (amplitude*vf->amplitude_offset)/
q = exp((((amplitude*vf->amplitude_offset) /
(((1 << vf->amplitude_bits) - 1) * sqrt(p + q)))
- vf->amplitude_offset ) * .11512925f
);
- vf->amplitude_offset) * .11512925f);
}
/* fill vector */
@ -1277,8 +1272,8 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc,
uint_fast8_t ch,
uint_fast8_t *do_not_decode,
float *vec,
uint_fast16_t
vlen, int vr_type)
uint_fast16_t vlen,
int vr_type)
{
GetBitContext *gb = &vc->gb;
uint_fast8_t c_p_c = vc->codebooks[vr->classbook].dimensions;

View File

@ -149,9 +149,9 @@ static void ready_codebook(vorbis_enc_codebook * cb)
ff_vorbis_len2vlc(cb->lens, cb->codewords, cb->nentries);
if (!cb->lookup)
if (!cb->lookup) {
cb->pow2 = cb->dimentions = NULL;
else {
} else {
int vals = cb_lookup_vals(cb->lookup, cb->ndimentions, cb->nentries);
cb->dimentions = av_malloc(sizeof(float) * cb->nentries * cb->ndimentions);
cb->pow2 = av_mallocz(sizeof(float) * cb->nentries);
@ -188,8 +188,8 @@ static void ready_residue(vorbis_enc_residue * rc, vorbis_enc_context * venc)
for (j = 0; j < 8; j++)
if (rc->books[i][j] != -1)
break;
if (j == 8)
continue; // zero
if (j == 8) // zero
continue;
cb = &venc->codebooks[rc->books[i][j]];
assert(cb->ndimentions >= 2);
assert(cb->lookup);
@ -772,10 +772,12 @@ static void floor_encode(vorbis_enc_context * venc, vorbis_enc_floor * fc,
}
}
ff_vorbis_floor1_render_list(fc->list, fc->values, posts, coded, fc->multiplier, floor, samples);
ff_vorbis_floor1_render_list(fc->list, fc->values, posts, coded,
fc->multiplier, floor, samples);
}
static float * put_vector(vorbis_enc_codebook * book, PutBitContext * pb, float * num)
static float *put_vector(vorbis_enc_codebook *book, PutBitContext *pb,
float *num)
{
int i, entry = -1;
float distance = FLT_MAX;
@ -885,8 +887,8 @@ static void residue_encode(vorbis_enc_context * venc, vorbis_enc_residue * rc,
}
}
static int apply_window_and_mdct(vorbis_enc_context * venc,
signed short * audio, int samples)
static int apply_window_and_mdct(vorbis_enc_context *venc, signed short *audio,
int samples)
{
int i, j, channel;
const float * win = venc->win[0];
@ -897,12 +899,15 @@ static int apply_window_and_mdct(vorbis_enc_context * venc,
if (!venc->have_saved && !samples)
return 0;
if (venc->have_saved)
if (venc->have_saved) {
for (channel = 0; channel < venc->channels; channel++)
memcpy(venc->samples + channel*window_len*2, venc->saved + channel*window_len, sizeof(float)*window_len);
else
memcpy(venc->samples + channel * window_len * 2,
venc->saved + channel * window_len, sizeof(float) * window_len);
} else {
for (channel = 0; channel < venc->channels; channel++)
memset(venc->samples + channel*window_len*2, 0, sizeof(float)*window_len);
memset(venc->samples + channel * window_len * 2, 0,
sizeof(float) * window_len);
}
if (samples) {
for (channel = 0; channel < venc->channels; channel++) {
@ -913,11 +918,13 @@ static int apply_window_and_mdct(vorbis_enc_context * venc,
}
} else {
for (channel = 0; channel < venc->channels; channel++)
memset(venc->samples + channel*window_len*2 + window_len, 0, sizeof(float)*window_len);
memset(venc->samples + channel * window_len * 2 + window_len,
0, sizeof(float) * window_len);
}
for (channel = 0; channel < venc->channels; channel++)
ff_mdct_calc(&venc->mdct[0], venc->coeffs + channel*window_len, venc->samples + channel*window_len*2);
ff_mdct_calc(&venc->mdct[0], venc->coeffs + channel * window_len,
venc->samples + channel * window_len * 2);
if (samples) {
for (channel = 0; channel < venc->channels; channel++) {
@ -960,7 +967,9 @@ static av_cold int vorbis_encode_init(AVCodecContext * avccontext)
return 0;
}
static int vorbis_encode_frame(AVCodecContext * avccontext, unsigned char * packets, int buf_size, void *data)
static int vorbis_encode_frame(AVCodecContext *avccontext,
unsigned char *packets,
int buf_size, void *data)
{
vorbis_enc_context *venc = avccontext->priv_data;
signed short *audio = data;
@ -1011,7 +1020,8 @@ static int vorbis_encode_frame(AVCodecContext * avccontext, unsigned char * pack
}
}
residue_encode(venc, &venc->residues[mapping->residue[mapping->mux[0]]], &pb, venc->coeffs, samples, venc->channels);
residue_encode(venc, &venc->residues[mapping->residue[mapping->mux[0]]],
&pb, venc->coeffs, samples, venc->channels);
avccontext->coded_frame->pts = venc->sample_count;
venc->sample_count += avccontext->frame_size;

View File

@ -24,8 +24,7 @@
#include <stdint.h>
static const uint8_t codebook0[] = {
2, 10, 8, 14, 7, 12, 11, 14, 1, 5, 3, 7, 4, 9, 7,
13,
2, 10, 8, 14, 7, 12, 11, 14, 1, 5, 3, 7, 4, 9, 7, 13,
};
static const uint8_t codebook1[] = {