[Ffmpeg-cvslog] r6495 - trunk/libavcodec/vorbis_enc.c
ods15
subversion
Mon Oct 2 08:08:58 CEST 2006
Author: ods15
Date: Mon Oct 2 08:08:57 2006
New Revision: 6495
Modified:
trunk/libavcodec/vorbis_enc.c
Log:
Original Commit: r91 | ods15 | 2006-09-30 10:05:16 +0300 (Sat, 30 Sep 2006) | 4 lines
even better psy.
My encoder officially kicks ass :) same bitrate to libvorbis, and (IMO)
same quality! :)
Modified: trunk/libavcodec/vorbis_enc.c
==============================================================================
--- trunk/libavcodec/vorbis_enc.c (original)
+++ trunk/libavcodec/vorbis_enc.c Mon Oct 2 08:08:57 2006
@@ -771,20 +771,30 @@
return p - *out;
}
+static float get_floor_average(floor_t * fc, float * coeffs, int i) {
+ int begin = fc->list[fc->list[FFMAX(i-1, 0)].sort].x;
+ int end = fc->list[fc->list[FFMIN(i+1, fc->values - 1)].sort].x;
+ int j;
+ float average = 0;
+
+ for (j = begin; j < end; j++) average += fabs(coeffs[j]);
+ return average / (end - begin);
+}
+
static void floor_fit(venc_context_t * venc, floor_t * fc, float * coeffs, int * posts, int samples) {
int range = 255 / fc->multiplier + 1;
int i;
+ float tot_average = 0.;
+ for (i = 0; i < fc->values; i++) tot_average += get_floor_average(fc, coeffs, i);
+ tot_average /= fc->values;
+ tot_average /= 0.5;
+
for (i = 0; i < fc->values; i++) {
int position = fc->list[fc->list[i].sort].x;
- int begin = fc->list[fc->list[FFMAX(i-1, 0)].sort].x;
- int end = fc->list[fc->list[FFMIN(i+1, fc->values - 1)].sort].x;
+ float average = get_floor_average(fc, coeffs, i);
int j;
- float average = 0;
- assert(end <= samples);
- for (j = begin; j < end; j++) average += fabs(coeffs[j]);
- average /= end - begin;
- average /= pow(4, 1 - position/400.); // MAGIC!
+ average /= pow(average, 0.7) / tot_average * pow(0.9, position/200.); // MAGIC!
for (j = 0; j < range - 1; j++) if (floor1_inverse_db_table[j * fc->multiplier] > average) break;
posts[fc->list[i].sort] = j;
}
More information about the ffmpeg-cvslog
mailing list