comparison vorbis_enc.c @ 3910:aada0ac47451 libavcodec

Original Commit: r111 | ods15 | 2006-10-01 19:40:50 +0200 (Sun, 01 Oct 2006) | 2 lines update to use ff_vorbis_floor1_render_list
author ods15
date Mon, 02 Oct 2006 06:09:45 +0000
parents 3cac42cde8ea
children a1b41e814052
comparison
equal deleted inserted replaced
3909:3cac42cde8ea 3910:aada0ac47451
1115 1115
1116 for (j = begin; j < end; j++) average += fabs(coeffs[j]); 1116 for (j = begin; j < end; j++) average += fabs(coeffs[j]);
1117 return average / (end - begin); 1117 return average / (end - begin);
1118 } 1118 }
1119 1119
1120 static void floor_fit(venc_context_t * venc, floor_t * fc, float * coeffs, int * posts, int samples) { 1120 static void floor_fit(venc_context_t * venc, floor_t * fc, float * coeffs, uint_fast16_t * posts, int samples) {
1121 int range = 255 / fc->multiplier + 1; 1121 int range = 255 / fc->multiplier + 1;
1122 int i; 1122 int i;
1123 float tot_average = 0.; 1123 float tot_average = 0.;
1124 float averages[fc->values]; 1124 float averages[fc->values];
1125 for (i = 0; i < fc->values; i++) tot_average += averages[i] = get_floor_average(fc, coeffs, i); 1125 for (i = 0; i < fc->values; i++) tot_average += averages[i] = get_floor_average(fc, coeffs, i);
1139 1139
1140 static int render_point(int x0, int y0, int x1, int y1, int x) { 1140 static int render_point(int x0, int y0, int x1, int y1, int x) {
1141 return y0 + (x - x0) * (y1 - y0) / (x1 - x0); 1141 return y0 + (x - x0) * (y1 - y0) / (x1 - x0);
1142 } 1142 }
1143 1143
1144 static void floor_encode(venc_context_t * venc, floor_t * fc, PutBitContext * pb, int * posts, float * floor, int samples) { 1144 static void floor_encode(venc_context_t * venc, floor_t * fc, PutBitContext * pb, uint_fast16_t * posts, float * floor, int samples) {
1145 int range = 255 / fc->multiplier + 1; 1145 int range = 255 / fc->multiplier + 1;
1146 int coded[fc->values]; // first 2 values are unused 1146 int coded[fc->values]; // first 2 values are unused
1147 int i, counter; 1147 int i, counter;
1148 int lx, ly;
1149 1148
1150 put_bits(pb, 1, 1); // non zero 1149 put_bits(pb, 1, 1); // non zero
1151 put_bits(pb, ilog(range - 1), posts[0]); 1150 put_bits(pb, ilog(range - 1), posts[0]);
1152 put_bits(pb, ilog(range - 1), posts[1]); 1151 put_bits(pb, ilog(range - 1), posts[1]);
1153 coded[0] = coded[1] = 1; 1152 coded[0] = coded[1] = 1;
1206 if (entry == -1) entry = 0; 1205 if (entry == -1) entry = 0;
1207 put_codeword(pb, &venc->codebooks[book], entry); 1206 put_codeword(pb, &venc->codebooks[book], entry);
1208 } 1207 }
1209 } 1208 }
1210 1209
1211 lx = 0; 1210 ff_vorbis_floor1_render_list(fc->list, fc->values, posts, coded, fc->multiplier, floor, samples);
1212 ly = posts[0] * fc->multiplier; // sorted 0 is still 0
1213 for (i = 1; i < fc->values; i++) {
1214 int pos = fc->list[i].sort;
1215 if (coded[pos]) {
1216 render_line(lx, ly, fc->list[pos].x, posts[pos] * fc->multiplier, floor, samples);
1217 lx = fc->list[pos].x;
1218 ly = posts[pos] * fc->multiplier;
1219 }
1220 if (lx >= samples) break;
1221 }
1222 if (lx < samples) render_line(lx, ly, samples, ly, floor, samples);
1223 } 1211 }
1224 1212
1225 static float * put_vector(codebook_t * book, PutBitContext * pb, float * num) { 1213 static float * put_vector(codebook_t * book, PutBitContext * pb, float * num) {
1226 int i, entry = -1; 1214 int i, entry = -1;
1227 float distance = FLT_MAX; 1215 float distance = FLT_MAX;
1417 put_bits(&pb, 1, 0); 1405 put_bits(&pb, 1, 0);
1418 } 1406 }
1419 1407
1420 for (i = 0; i < venc->channels; i++) { 1408 for (i = 0; i < venc->channels; i++) {
1421 floor_t * fc = &venc->floors[mapping->floor[mapping->mux[i]]]; 1409 floor_t * fc = &venc->floors[mapping->floor[mapping->mux[i]]];
1422 int posts[fc->values]; 1410 uint_fast16_t posts[fc->values];
1423 floor_fit(venc, fc, &venc->coeffs[i * samples], posts, samples); 1411 floor_fit(venc, fc, &venc->coeffs[i * samples], posts, samples);
1424 floor_encode(venc, fc, &pb, posts, &venc->floor[i * samples], samples); 1412 floor_encode(venc, fc, &pb, posts, &venc->floor[i * samples], samples);
1425 } 1413 }
1426 1414
1427 for (i = 0; i < venc->channels * samples; i++) { 1415 for (i = 0; i < venc->channels * samples; i++) {