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! :)

Originally committed as revision 6495 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Oded Shimon 2006-10-02 06:08:57 +00:00
parent 68e75e4dec
commit b002eec985

View File

@ -771,20 +771,30 @@ static int put_main_header(venc_context_t * venc, uint8_t ** out) {
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;
}