comparison vorbis_enc.c @ 3890:de883494646e libavcodec

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! :)
author ods15
date Mon, 02 Oct 2006 06:08:57 +0000
parents a0462572fefa
children 50e912426a32
comparison
equal deleted inserted replaced
3889:a0462572fefa 3890:de883494646e
769 } 769 }
770 770
771 return p - *out; 771 return p - *out;
772 } 772 }
773 773
774 static float get_floor_average(floor_t * fc, float * coeffs, int i) {
775 int begin = fc->list[fc->list[FFMAX(i-1, 0)].sort].x;
776 int end = fc->list[fc->list[FFMIN(i+1, fc->values - 1)].sort].x;
777 int j;
778 float average = 0;
779
780 for (j = begin; j < end; j++) average += fabs(coeffs[j]);
781 return average / (end - begin);
782 }
783
774 static void floor_fit(venc_context_t * venc, floor_t * fc, float * coeffs, int * posts, int samples) { 784 static void floor_fit(venc_context_t * venc, floor_t * fc, float * coeffs, int * posts, int samples) {
775 int range = 255 / fc->multiplier + 1; 785 int range = 255 / fc->multiplier + 1;
776 int i; 786 int i;
787 float tot_average = 0.;
788 for (i = 0; i < fc->values; i++) tot_average += get_floor_average(fc, coeffs, i);
789 tot_average /= fc->values;
790 tot_average /= 0.5;
791
777 for (i = 0; i < fc->values; i++) { 792 for (i = 0; i < fc->values; i++) {
778 int position = fc->list[fc->list[i].sort].x; 793 int position = fc->list[fc->list[i].sort].x;
779 int begin = fc->list[fc->list[FFMAX(i-1, 0)].sort].x; 794 float average = get_floor_average(fc, coeffs, i);
780 int end = fc->list[fc->list[FFMIN(i+1, fc->values - 1)].sort].x;
781 int j; 795 int j;
782 float average = 0; 796
783 797 average /= pow(average, 0.7) / tot_average * pow(0.9, position/200.); // MAGIC!
784 assert(end <= samples);
785 for (j = begin; j < end; j++) average += fabs(coeffs[j]);
786 average /= end - begin;
787 average /= pow(4, 1 - position/400.); // MAGIC!
788 for (j = 0; j < range - 1; j++) if (floor1_inverse_db_table[j * fc->multiplier] > average) break; 798 for (j = 0; j < range - 1; j++) if (floor1_inverse_db_table[j * fc->multiplier] > average) break;
789 posts[fc->list[i].sort] = j; 799 posts[fc->list[i].sort] = j;
790 } 800 }
791 } 801 }
792 802