changeset 3891:50e912426a32 libavcodec

Original Commit: r92 | ods15 | 2006-09-30 12:13:47 +0300 (Sat, 30 Sep 2006) | 3 lines user settable audio quality, with -aq. values between 0.1 to 0.3 are sane. the higher the better.
author ods15
date Mon, 02 Oct 2006 06:08:59 +0000
parents de883494646e
children 4fb6be21be4b
files vorbis_enc.c
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/vorbis_enc.c	Mon Oct 02 06:08:57 2006 +0000
+++ b/vorbis_enc.c	Mon Oct 02 06:08:59 2006 +0000
@@ -114,6 +114,7 @@
     float * samples;
     float * floor; // also used for tmp values for mdct
     float * coeffs; // also used for residue after floor
+    float quality;
 
     int ncodebooks;
     codebook_t * codebooks;
@@ -787,14 +788,14 @@
     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;
+    tot_average /= venc->quality;
 
     for (i = 0; i < fc->values; i++) {
         int position = fc->list[fc->list[i].sort].x;
         float average = get_floor_average(fc, coeffs, i);
         int j;
 
-        average /= pow(average, 0.7) / tot_average * pow(0.9, position/200.); // MAGIC!
+        average /= pow(average, 0.5) / tot_average * pow(0.8, 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;
     }
@@ -1064,7 +1065,8 @@
 
     create_vorbis_context(venc, avccontext);
 
-    //if (avccontext->flags & CODEC_FLAG_QSCALE) avccontext->global_quality / (float)FF_QP2LAMBDA); else avccontext->bit_rate;
+    if (avccontext->flags & CODEC_FLAG_QSCALE) venc->quality = avccontext->global_quality / (float)FF_QP2LAMBDA;
+    else venc->quality = 0.17;
     //if(avccontext->cutoff > 0) cfreq = avccontext->cutoff / 1000.0;
 
     avccontext->extradata_size = put_main_header(venc, (uint8_t**)&avccontext->extradata);