Commit 0ef78da1 authored by ods15's avatar ods15

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.

git-svn-id: file:///var/local/repositories/ffmpeg/trunk@6496 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 1304597e
...@@ -114,6 +114,7 @@ typedef struct { ...@@ -114,6 +114,7 @@ typedef struct {
float * samples; float * samples;
float * floor; // also used for tmp values for mdct float * floor; // also used for tmp values for mdct
float * coeffs; // also used for residue after floor float * coeffs; // also used for residue after floor
float quality;
int ncodebooks; int ncodebooks;
codebook_t * codebooks; codebook_t * codebooks;
...@@ -787,14 +788,14 @@ static void floor_fit(venc_context_t * venc, floor_t * fc, float * coeffs, int * ...@@ -787,14 +788,14 @@ static void floor_fit(venc_context_t * venc, floor_t * fc, float * coeffs, int *
float tot_average = 0.; float tot_average = 0.;
for (i = 0; i < fc->values; i++) tot_average += get_floor_average(fc, coeffs, i); for (i = 0; i < fc->values; i++) tot_average += get_floor_average(fc, coeffs, i);
tot_average /= fc->values; tot_average /= fc->values;
tot_average /= 0.5; tot_average /= venc->quality;
for (i = 0; i < fc->values; i++) { for (i = 0; i < fc->values; i++) {
int position = fc->list[fc->list[i].sort].x; int position = fc->list[fc->list[i].sort].x;
float average = get_floor_average(fc, coeffs, i); float average = get_floor_average(fc, coeffs, i);
int j; 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; for (j = 0; j < range - 1; j++) if (floor1_inverse_db_table[j * fc->multiplier] > average) break;
posts[fc->list[i].sort] = j; posts[fc->list[i].sort] = j;
} }
...@@ -1064,7 +1065,8 @@ static int vorbis_encode_init(AVCodecContext * avccontext) ...@@ -1064,7 +1065,8 @@ static int vorbis_encode_init(AVCodecContext * avccontext)
create_vorbis_context(venc, avccontext); 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; //if(avccontext->cutoff > 0) cfreq = avccontext->cutoff / 1000.0;
avccontext->extradata_size = put_main_header(venc, (uint8_t**)&avccontext->extradata); avccontext->extradata_size = put_main_header(venc, (uint8_t**)&avccontext->extradata);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment