whitespace cosmetics, prettyprinting, K&R coding style

Originally committed as revision 20080 to svn://svn.ffmpeg.org/ffmpeg/trunk
release/0.6
Diego Biurrun 15 years ago
parent badce93dad
commit a7adcf29cf
  1. 5
      libavcodec/vorbis.c
  2. 1
      libavcodec/vorbis_data.c
  3. 29
      libavcodec/vorbis_dec.c
  4. 42
      libavcodec/vorbis_enc.c
  5. 3
      libavcodec/vorbis_enc_data.h

@ -2,7 +2,7 @@
* @file libavcodec/vorbis.c * @file libavcodec/vorbis.c
* Common code for Vorbis I encoder and decoder * Common code for Vorbis I encoder and decoder
* @author Denes Balatoni ( dbalatoni programozo hu ) * @author Denes Balatoni ( dbalatoni programozo hu )
*
* This file is part of FFmpeg. * This file is part of FFmpeg.
* *
* FFmpeg is free software; you can redistribute it and/or * 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. // reasonable to check redundantly.
int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, uint_fast32_t num) 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 }; 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
uint_fast8_t i, j; uint_fast8_t i, j;

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

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

@ -149,9 +149,9 @@ static void ready_codebook(vorbis_enc_codebook * cb)
ff_vorbis_len2vlc(cb->lens, cb->codewords, cb->nentries); ff_vorbis_len2vlc(cb->lens, cb->codewords, cb->nentries);
if (!cb->lookup) if (!cb->lookup) {
cb->pow2 = cb->dimentions = NULL; cb->pow2 = cb->dimentions = NULL;
else { } else {
int vals = cb_lookup_vals(cb->lookup, cb->ndimentions, cb->nentries); int vals = cb_lookup_vals(cb->lookup, cb->ndimentions, cb->nentries);
cb->dimentions = av_malloc(sizeof(float) * cb->nentries * cb->ndimentions); cb->dimentions = av_malloc(sizeof(float) * cb->nentries * cb->ndimentions);
cb->pow2 = av_mallocz(sizeof(float) * cb->nentries); 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++) for (j = 0; j < 8; j++)
if (rc->books[i][j] != -1) if (rc->books[i][j] != -1)
break; break;
if (j == 8) if (j == 8) // zero
continue; // zero continue;
cb = &venc->codebooks[rc->books[i][j]]; cb = &venc->codebooks[rc->books[i][j]];
assert(cb->ndimentions >= 2); assert(cb->ndimentions >= 2);
assert(cb->lookup); 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; int i, entry = -1;
float distance = FLT_MAX; 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, static int apply_window_and_mdct(vorbis_enc_context *venc, signed short *audio,
signed short * audio, int samples) int samples)
{ {
int i, j, channel; int i, j, channel;
const float * win = venc->win[0]; 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) if (!venc->have_saved && !samples)
return 0; return 0;
if (venc->have_saved) if (venc->have_saved) {
for (channel = 0; channel < venc->channels; channel++) for (channel = 0; channel < venc->channels; channel++)
memcpy(venc->samples + channel*window_len*2, venc->saved + channel*window_len, sizeof(float)*window_len); memcpy(venc->samples + channel * window_len * 2,
else venc->saved + channel * window_len, sizeof(float) * window_len);
} else {
for (channel = 0; channel < venc->channels; channel++) 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) { if (samples) {
for (channel = 0; channel < venc->channels; channel++) { for (channel = 0; channel < venc->channels; channel++) {
@ -913,11 +918,13 @@ static int apply_window_and_mdct(vorbis_enc_context * venc,
} }
} else { } else {
for (channel = 0; channel < venc->channels; channel++) 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++) 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) { if (samples) {
for (channel = 0; channel < venc->channels; channel++) { for (channel = 0; channel < venc->channels; channel++) {
@ -960,7 +967,9 @@ static av_cold int vorbis_encode_init(AVCodecContext * avccontext)
return 0; 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; vorbis_enc_context *venc = avccontext->priv_data;
signed short *audio = 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; avccontext->coded_frame->pts = venc->sample_count;
venc->sample_count += avccontext->frame_size; venc->sample_count += avccontext->frame_size;

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

Loading…
Cancel
Save