diff options
author | Oded Shimon <ods15@ods15.dyndns.org> | 2006-10-02 06:08:57 +0000 |
---|---|---|
committer | Oded Shimon <ods15@ods15.dyndns.org> | 2006-10-02 06:08:57 +0000 |
commit | b002eec9850900cfa098ec25513cb11e2c694fe5 (patch) | |
tree | 8c930f324e3d14342fba95f4408d84fb846b2a1b /libavcodec/vorbis_enc.c | |
parent | 68e75e4dec6b5f46a190118eecbba1e95c396e3d (diff) | |
download | ffmpeg-streaming-b002eec9850900cfa098ec25513cb11e2c694fe5.zip ffmpeg-streaming-b002eec9850900cfa098ec25513cb11e2c694fe5.tar.gz |
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
Diffstat (limited to 'libavcodec/vorbis_enc.c')
-rw-r--r-- | libavcodec/vorbis_enc.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/libavcodec/vorbis_enc.c b/libavcodec/vorbis_enc.c index 581ab41..ff4e9d0 100644 --- a/libavcodec/vorbis_enc.c +++ b/libavcodec/vorbis_enc.c @@ -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; } |