Mercurial > libavcodec.hg
comparison vorbis.c @ 3805:5ad55a4e42c2 libavcodec
remove render_line from vorbis.h, add ff_vorbis_floor1_render_list instead
author | ods15 |
---|---|
date | Sun, 01 Oct 2006 17:38:07 +0000 |
parents | 094fe185d054 |
children | c8c591fe26f8 |
comparison
equal
deleted
inserted
replaced
3804:f472f55953bb | 3805:5ad55a4e42c2 |
---|---|
1228 | 1228 |
1229 AV_DEBUG(" Floor0 decoded\n"); | 1229 AV_DEBUG(" Floor0 decoded\n"); |
1230 | 1230 |
1231 return 0; | 1231 return 0; |
1232 } | 1232 } |
1233 | |
1234 static void render_line(int x0, int y0, int x1, int y1, float * buf, int n) { | |
1235 int dy = y1 - y0; | |
1236 int adx = x1 - x0; | |
1237 int ady = ABS(dy); | |
1238 int base = dy / adx; | |
1239 int x = x0; | |
1240 int y = y0; | |
1241 int err = 0; | |
1242 int sy; | |
1243 if (dy < 0) sy = base - 1; | |
1244 else sy = base + 1; | |
1245 ady = ady - ABS(base) * adx; | |
1246 if (x >= n) return; | |
1247 buf[x] = ff_vorbis_floor1_inverse_db_table[y]; | |
1248 for (x = x0 + 1; x < x1; x++) { | |
1249 if (x >= n) return; | |
1250 err += ady; | |
1251 if (err >= adx) { | |
1252 err -= adx; | |
1253 y += sy; | |
1254 } else { | |
1255 y += base; | |
1256 } | |
1257 buf[x] = ff_vorbis_floor1_inverse_db_table[y]; | |
1258 } | |
1259 } | |
1260 | |
1261 void ff_vorbis_floor1_render_list(floor1_entry_t * list, int values, uint_fast16_t * y_list, int * flag, int multiplier, float * out, int samples) { | |
1262 int lx, ly, i; | |
1263 lx = 0; | |
1264 ly = y_list[0] * multiplier; | |
1265 for (i = 1; i < values; i++) { | |
1266 int pos = list[i].sort; | |
1267 if (flag[pos]) { | |
1268 render_line(lx, ly, list[pos].x, y_list[pos] * multiplier, out, samples); | |
1269 lx = list[pos].x; | |
1270 ly = y_list[pos] * multiplier; | |
1271 } | |
1272 if (lx >= samples) break; | |
1273 } | |
1274 if (lx < samples) render_line(lx, ly, samples, ly, out, samples); | |
1275 } | |
1276 | |
1233 static uint_fast8_t vorbis_floor1_decode(vorbis_context *vc, vorbis_floor_data *vfu, float *vec) { | 1277 static uint_fast8_t vorbis_floor1_decode(vorbis_context *vc, vorbis_floor_data *vfu, float *vec) { |
1234 vorbis_floor1 * vf=&vfu->t1; | 1278 vorbis_floor1 * vf=&vfu->t1; |
1235 GetBitContext *gb=&vc->gb; | 1279 GetBitContext *gb=&vc->gb; |
1236 uint_fast16_t range_v[4]={ 256, 128, 86, 64 }; | 1280 uint_fast16_t range_v[4]={ 256, 128, 86, 64 }; |
1237 uint_fast16_t range=range_v[vf->multiplier-1]; | 1281 uint_fast16_t range=range_v[vf->multiplier-1]; |
1238 uint_fast16_t floor1_Y[vf->x_list_dim]; | 1282 uint_fast16_t floor1_Y[vf->x_list_dim]; |
1239 uint_fast16_t floor1_Y_final[vf->x_list_dim]; | 1283 uint_fast16_t floor1_Y_final[vf->x_list_dim]; |
1240 uint_fast8_t floor1_flag[vf->x_list_dim]; | 1284 int floor1_flag[vf->x_list_dim]; |
1241 uint_fast8_t class_; | 1285 uint_fast8_t class_; |
1242 uint_fast8_t cdim; | 1286 uint_fast8_t cdim; |
1243 uint_fast8_t cbits; | 1287 uint_fast8_t cbits; |
1244 uint_fast8_t csub; | 1288 uint_fast8_t csub; |
1245 uint_fast8_t cval; | 1289 uint_fast8_t cval; |
1246 int_fast16_t book; | 1290 int_fast16_t book; |
1247 uint_fast16_t offset; | 1291 uint_fast16_t offset; |
1248 uint_fast16_t i,j; | 1292 uint_fast16_t i,j; |
1249 /*u*/int_fast16_t adx, ady, off, predicted; // WTF ? dy/adx= (unsigned)dy/adx ? | 1293 /*u*/int_fast16_t adx, ady, off, predicted; // WTF ? dy/adx= (unsigned)dy/adx ? |
1250 int_fast16_t dy, err; | 1294 int_fast16_t dy, err; |
1251 uint_fast16_t lx,hx, ly, hy=0; | |
1252 | 1295 |
1253 | 1296 |
1254 if (!get_bits1(gb)) return 1; // silence | 1297 if (!get_bits1(gb)) return 1; // silence |
1255 | 1298 |
1256 // Read values (or differences) for the floor's points | 1299 // Read values (or differences) for the floor's points |
1351 AV_DEBUG(" Decoded floor(%d) = %d / val %d \n", vf->list[i].x, floor1_Y_final[i], val); | 1394 AV_DEBUG(" Decoded floor(%d) = %d / val %d \n", vf->list[i].x, floor1_Y_final[i], val); |
1352 } | 1395 } |
1353 | 1396 |
1354 // Curve synth - connect the calculated dots and convert from dB scale FIXME optimize ? | 1397 // Curve synth - connect the calculated dots and convert from dB scale FIXME optimize ? |
1355 | 1398 |
1356 hx=0; | 1399 ff_vorbis_floor1_render_list(vf->list, vf->x_list_dim, floor1_Y_final, floor1_flag, vf->multiplier, vec, vf->list[1].x); |
1357 lx=0; | |
1358 ly=floor1_Y_final[0]*vf->multiplier; // conforms to SPEC | |
1359 | |
1360 vec[0]=ff_vorbis_floor1_inverse_db_table[ly]; | |
1361 | |
1362 for(i=1;i<vf->x_list_dim;++i) { | |
1363 AV_DEBUG(" Looking at post %d \n", i); | |
1364 | |
1365 if (floor1_flag[vf->list[i].sort]) { // SPEC mispelled | |
1366 hy=floor1_Y_final[vf->list[i].sort]*vf->multiplier; | |
1367 hx=vf->list[vf->list[i].sort].x; | |
1368 | |
1369 render_line(lx, ly, hx, hy, vec, vc->blocksize[1]); | |
1370 | |
1371 lx=hx; | |
1372 ly=hy; | |
1373 } | |
1374 } | |
1375 | |
1376 if (hx<vf->list[1].x) { | |
1377 render_line(hx, hy, vf->list[1].x, hy, vec, vc->blocksize[1]); | |
1378 } | |
1379 | 1400 |
1380 AV_DEBUG(" Floor decoded\n"); | 1401 AV_DEBUG(" Floor decoded\n"); |
1381 | 1402 |
1382 return 0; | 1403 return 0; |
1383 } | 1404 } |