/*
* copyright (c) 2006 Oded Shimon <ods15@ods15.dyndns.org>
*
- * This file is part of FFmpeg.
+ * This file is part of Libav.
*
- * FFmpeg is free software; you can redistribute it and/or
+ * 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.
*
- * FFmpeg is distributed in the hope that it will be useful,
+ * 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 FFmpeg; if not, write to the Free Software
+ * License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
int64_t sample_count;
} vorbis_enc_context;
+#define MAX_CHANNELS 2
+#define MAX_CODEBOOK_DIM 8
+
+#define MAX_FLOOR_CLASS_DIM 4
+#define NUM_FLOOR_PARTITIONS 8
+#define MAX_FLOOR_VALUES (MAX_FLOOR_CLASS_DIM*NUM_FLOOR_PARTITIONS+2)
+
+#define RESIDUE_SIZE 1600
+#define RESIDUE_PART_SIZE 32
+#define NUM_RESIDUE_PARTITIONS (RESIDUE_SIZE/RESIDUE_PART_SIZE)
+
static inline void put_codeword(PutBitContext *pb, vorbis_enc_codebook *cb,
int entry)
{
// just 1 floor
fc = &venc->floors[0];
- fc->partitions = 8;
+ fc->partitions = NUM_FLOOR_PARTITIONS;
fc->partition_to_class = av_malloc(sizeof(int) * fc->partitions);
fc->nclasses = 0;
for (i = 0; i < fc->partitions; i++) {
int range = 255 / fc->multiplier + 1;
int i;
float tot_average = 0.;
- float averages[fc->values];
+ float averages[MAX_FLOOR_VALUES];
for (i = 0; i < fc->values; i++) {
averages[i] = get_floor_average(fc, coeffs, i);
tot_average += averages[i];
float *floor, int samples)
{
int range = 255 / fc->multiplier + 1;
- int coded[fc->values]; // first 2 values are unused
+ int coded[MAX_FLOOR_VALUES]; // first 2 values are unused
int i, counter;
put_bits(pb, 1, 1); // non zero
int psize = rc->partition_size;
int partitions = (rc->end - rc->begin) / psize;
int channels = (rc->type == 2) ? 1 : real_ch;
- int classes[channels][partitions];
+ int classes[MAX_CHANNELS][NUM_RESIDUE_PARTITIONS];
int classwords = venc->codebooks[rc->classbook].ndimentions;
assert(rc->type == 2);
s = real_ch * samples;
for (k = 0; k < psize; k += book->ndimentions) {
int dim, a2 = a1, b2 = b1;
- float vec[book->ndimentions], *pv = vec;
+ float vec[MAX_CODEBOOK_DIM], *pv = vec;
for (dim = book->ndimentions; dim--; ) {
*pv++ = coeffs[a2 + b2];
if ((a2 += samples) == s) {
}
}
-static int apply_window_and_mdct(vorbis_enc_context *venc, signed short *audio,
+static int apply_window_and_mdct(vorbis_enc_context *venc, const signed short *audio,
int samples)
{
int i, j, channel;
}
for (channel = 0; channel < venc->channels; channel++)
- ff_mdct_calc(&venc->mdct[0], venc->coeffs + channel * window_len,
+ venc->mdct[0].mdct_calc(&venc->mdct[0], venc->coeffs + channel * window_len,
venc->samples + channel * window_len * 2);
if (samples) {
if (avccontext->flags & CODEC_FLAG_QSCALE)
venc->quality = avccontext->global_quality / (float)FF_QP2LAMBDA / 10.;
else
- venc->quality = 1.;
+ venc->quality = 0.03;
venc->quality *= venc->quality;
avccontext->extradata_size = put_main_header(venc, (uint8_t**)&avccontext->extradata);
int buf_size, void *data)
{
vorbis_enc_context *venc = avccontext->priv_data;
- signed short *audio = data;
+ const signed short *audio = data;
int samples = data ? avccontext->frame_size : 0;
vorbis_enc_mode *mode;
vorbis_enc_mapping *mapping;
for (i = 0; i < venc->channels; i++) {
vorbis_enc_floor *fc = &venc->floors[mapping->floor[mapping->mux[i]]];
- uint_fast16_t posts[fc->values];
+ uint_fast16_t posts[MAX_FLOOR_VALUES];
floor_fit(venc, fc, &venc->coeffs[i * samples], posts, samples);
floor_encode(venc, fc, &pb, posts, &venc->floor[i * samples], samples);
}
return 0 ;
}
-AVCodec vorbis_encoder = {
+AVCodec ff_vorbis_encoder = {
"vorbis",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_VORBIS,
vorbis_encode_frame,
vorbis_encode_close,
.capabilities= CODEC_CAP_DELAY | CODEC_CAP_EXPERIMENTAL,
- .sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE},
+ .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
.long_name = NULL_IF_CONFIG_SMALL("Vorbis"),
};