Changeset 290 for libmpc/branches/r2d/libmpcdec/mpc_decoder.c
- Timestamp:
- 04/23/07 16:47:30 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libmpc/branches/r2d/libmpcdec/mpc_decoder.c
r288 r290 46 46 47 47 //SV7 tables 48 extern const mpc_ huffman* mpc_table_HuffQ [2] [8];49 extern const mpc_ huffman mpc_table_HuffHdr [10];48 extern const mpc_lut_data mpc_HuffQ [7] [2]; 49 extern const mpc_lut_data mpc_HuffHdr; 50 50 extern const mpc_huffman mpc_table_HuffSCFI [ 4]; 51 extern const mpc_ huffman mpc_table_HuffDSCF [16];51 extern const mpc_lut_data mpc_HuffDSCF; 52 52 53 53 //SV8 tables 54 extern const mpc_huffman mpc_table_Huff Res [2][17];55 extern const mpc_ huffman * mpc_table_HuffQ_8 [2][8];56 extern const mpc_ huffman mpc_table_HuffQ9up_8 [256];57 extern const mpc_ huffman mpc_table_HuffBands [33];58 extern const mpc_ huffman mpc_table_HuffSCFI_1 [4];59 extern const mpc_ huffman mpc_table_HuffSCFI_2 [16];60 extern const mpc_ huffman mpc_table_HuffDSCF_1 [64];61 extern const mpc_ huffman mpc_table_HuffDSCF_2 [65];54 extern const mpc_huffman mpc_table_HuffBands[33]; 55 extern const mpc_lut_data mpc_HuffRes [2]; 56 extern const mpc_lut_data mpc_HuffQ_8 [8][2]; 57 extern const mpc_lut_data mpc_HuffQ9up_8; 58 extern const mpc_lut_data mpc_HuffSCFI_1; 59 extern const mpc_lut_data mpc_HuffSCFI_2; 60 extern const mpc_lut_data mpc_HuffDSCF_1; 61 extern const mpc_lut_data mpc_HuffDSCF_2; 62 62 63 63 //------------------------------------------------------------------------------ … … 131 131 mpc_decoder_setup(p_tmp); 132 132 mpc_decoder_set_streaminfo(p_tmp, si); 133 huff_init_lut(LUT_DEPTH); // FIXME : this needs to be called only once when the library is loaded 133 134 } 134 135 … … 372 373 // consecutive subbands 373 374 for ( n = 1; n <= d->max_band; n++ ) { 374 idx = mpc_bits_huff_ dec(r, mpc_table_HuffHdr);375 idx = mpc_bits_huff_lut(r, & mpc_HuffHdr); 375 376 d->Res_L[n] = (idx!=4) ? d->Res_L[n - 1] + idx : (int) mpc_bits_read(r, 4); 376 377 377 idx = mpc_bits_huff_ dec(r, mpc_table_HuffHdr);378 idx = mpc_bits_huff_lut(r, & mpc_HuffHdr); 378 379 d->Res_R[n] = (idx!=4) ? d->Res_R[n - 1] + idx : (int) mpc_bits_read(r, 4); 379 380 … … 400 401 switch (SCFI) { 401 402 case 1: 402 idx = mpc_bits_huff_ dec(r, mpc_table_HuffDSCF);403 idx = mpc_bits_huff_lut(r, & mpc_HuffDSCF); 403 404 SCF[0] = (idx!=8) ? SCF[2] + idx : (int) mpc_bits_read(r, 6); 404 idx = mpc_bits_huff_ dec(r, mpc_table_HuffDSCF);405 idx = mpc_bits_huff_lut(r, & mpc_HuffDSCF); 405 406 SCF[1] = (idx!=8) ? SCF[0] + idx : (int) mpc_bits_read(r, 6); 406 407 SCF[2] = SCF[1]; 407 408 break; 408 409 case 3: 409 idx = mpc_bits_huff_ dec(r, mpc_table_HuffDSCF);410 idx = mpc_bits_huff_lut(r, & mpc_HuffDSCF); 410 411 SCF[0] = (idx!=8) ? SCF[2] + idx : (int) mpc_bits_read(r, 6); 411 412 SCF[1] = SCF[0]; … … 413 414 break; 414 415 case 2: 415 idx = mpc_bits_huff_ dec(r, mpc_table_HuffDSCF);416 idx = mpc_bits_huff_lut(r, & mpc_HuffDSCF); 416 417 SCF[0] = (idx!=8) ? SCF[2] + idx : (int) mpc_bits_read(r, 6); 417 418 SCF[1] = SCF[0]; 418 idx = mpc_bits_huff_ dec(r, mpc_table_HuffDSCF);419 idx = mpc_bits_huff_lut(r, & mpc_HuffDSCF); 419 420 SCF[2] = (idx!=8) ? SCF[1] + idx : (int) mpc_bits_read(r, 6); 420 421 break; 421 422 case 0: 422 idx = mpc_bits_huff_ dec(r, mpc_table_HuffDSCF);423 idx = mpc_bits_huff_lut(r, & mpc_HuffDSCF); 423 424 SCF[0] = (idx!=8) ? SCF[2] + idx : (int) mpc_bits_read(r, 6); 424 idx = mpc_bits_huff_ dec(r, mpc_table_HuffDSCF);425 idx = mpc_bits_huff_lut(r, & mpc_HuffDSCF); 425 426 SCF[1] = (idx!=8) ? SCF[0] + idx : (int) mpc_bits_read(r, 6); 426 idx = mpc_bits_huff_ dec(r, mpc_table_HuffDSCF);427 idx = mpc_bits_huff_lut(r, & mpc_HuffDSCF); 427 428 SCF[2] = (idx!=8) ? SCF[1] + idx : (int) mpc_bits_read(r, 6); 428 429 break; … … 450 451 do { 451 452 mpc_int32_t k; 452 const mpc_ huffman*Table;453 const mpc_lut_data *Table; 453 454 switch (Res) { 454 455 case -2: case -3: case -4: case -5: case -6: case -7: case -8: case -9: … … 462 463 break; 463 464 case 1: 464 Table = mpc_table_HuffQ[mpc_bits_read(r, 1)][1];465 Table = & mpc_HuffQ[0][mpc_bits_read(r, 1)]; 465 466 for ( k = 0; k < 36; k += 3) { 466 idx = mpc_bits_huff_ dec(r, Table);467 idx = mpc_bits_huff_lut(r, Table); 467 468 q[k] = idx30[idx]; 468 469 q[k + 1] = idx31[idx]; … … 471 472 break; 472 473 case 2: 473 Table = mpc_table_HuffQ[mpc_bits_read(r, 1)][2];474 Table = & mpc_HuffQ[1][mpc_bits_read(r, 1)]; 474 475 for ( k = 0; k < 36; k += 2) { 475 idx = mpc_bits_huff_ dec(r, Table);476 idx = mpc_bits_huff_lut(r, Table); 476 477 q[k] = idx50[idx]; 477 478 q[k + 1] = idx51[idx]; … … 483 484 case 6: 484 485 case 7: 485 Table = mpc_table_HuffQ[mpc_bits_read(r, 1)][Res];486 Table = & mpc_HuffQ[Res - 1][mpc_bits_read(r, 1)]; 486 487 for ( k = 0; k < 36; k++ ) 487 q[k] = mpc_bits_huff_ dec(r, Table);488 q[k] = mpc_bits_huff_lut(r, Table); 488 489 break; 489 490 case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15: case 16: case 17: … … 508 509 509 510 mpc_int32_t n, Max_used_Band; 510 const mpc_ huffman *Table, *Tables[2];511 const mpc_lut_data * Table, * Tables[2]; 511 512 512 513 /***************************** Header *****************************/ … … 521 522 522 523 if (Max_used_Band) { 523 d->Res_L[Max_used_Band-1] = mpc_bits_huff_ dec(r, mpc_table_HuffRes[0]);524 d->Res_R[Max_used_Band-1] = mpc_bits_huff_ dec(r, mpc_table_HuffRes[0]);524 d->Res_L[Max_used_Band-1] = mpc_bits_huff_lut(r, & mpc_HuffRes[0]); 525 d->Res_R[Max_used_Band-1] = mpc_bits_huff_lut(r, & mpc_HuffRes[0]); 525 526 if (d->Res_L[Max_used_Band-1] > 15) d->Res_L[Max_used_Band-1] -= 17; 526 527 if (d->Res_R[Max_used_Band-1] > 15) d->Res_R[Max_used_Band-1] -= 17; 527 528 for ( n = Max_used_Band - 2; n >= 0; n--) { 528 d->Res_L[n] = mpc_bits_huff_ dec(r, mpc_table_HuffRes[d->Res_L[n + 1] > 2]) + d->Res_L[n + 1];529 d->Res_L[n] = mpc_bits_huff_lut(r, & mpc_HuffRes[d->Res_L[n + 1] > 2]) + d->Res_L[n + 1]; 529 530 if (d->Res_L[n] > 15) d->Res_L[n] -= 17; 530 d->Res_R[n] = mpc_bits_huff_ dec(r, mpc_table_HuffRes[d->Res_R[n + 1] > 2]) + d->Res_R[n + 1];531 d->Res_R[n] = mpc_bits_huff_lut(r, & mpc_HuffRes[d->Res_R[n + 1] > 2]) + d->Res_R[n + 1]; 531 532 if (d->Res_R[n] > 15) d->Res_R[n] -= 17; 532 533 } … … 561 562 } 562 563 563 Tables[0] = mpc_table_HuffSCFI_1;564 Tables[1] = mpc_table_HuffSCFI_2;564 Tables[0] = & mpc_HuffSCFI_1; 565 Tables[1] = & mpc_HuffSCFI_2; 565 566 for ( n = 0; n < Max_used_Band; n++ ) { 566 567 int tmp = 0, cnt = -1; … … 568 569 if (d->Res_R[n]) cnt++; 569 570 if (cnt >= 0) { 570 tmp = mpc_bits_huff_ dec(r, Tables[cnt]);571 tmp = mpc_bits_huff_lut(r, Tables[cnt]); 571 572 if (d->Res_L[n]) d->SCFI_L[n] = tmp >> (2 * cnt); 572 573 if (d->Res_R[n]) d->SCFI_R[n] = tmp & 3; … … 588 589 *DSCF_Flag = 0; 589 590 } else { 590 mpc_uint_t tmp = mpc_bits_huff_ dec(r, mpc_table_HuffDSCF_2);591 mpc_uint_t tmp = mpc_bits_huff_lut(r, & mpc_HuffDSCF_2); 591 592 if (tmp == 64) 592 593 tmp += mpc_bits_read(r, 6); … … 595 596 for( m = 0; m < 2; m++){ 596 597 if (((SCFI << m) & 2) == 0) { 597 mpc_uint_t tmp = mpc_bits_huff_ dec(r, mpc_table_HuffDSCF_1);598 mpc_uint_t tmp = mpc_bits_huff_lut(r, & mpc_HuffDSCF_1); 598 599 if (tmp == 31) 599 600 tmp = 64 + mpc_bits_read(r, 6); … … 620 621 if (Res != 0) { 621 622 if (Res == 2) { 622 Tables[0] = mpc_table_HuffQ_8 [0][1];623 Tables[1] = mpc_table_HuffQ_8 [1][1];623 Tables[0] = & mpc_HuffQ_8 [1][0]; 624 Tables[1] = & mpc_HuffQ_8 [1][1]; 624 625 idx = 2 * thres[Res]; 625 626 for ( ; k < 36; k += 3) { 626 int tmp = mpc_bits_huff_ dec(r, Tables[idx > thres[Res]]);627 int tmp = mpc_bits_huff_lut(r, Tables[idx > thres[Res]]); 627 628 q[k] = idx50[tmp]; 628 629 q[k + 1] = idx51[tmp]; … … 631 632 } 632 633 } else if (Res == 1) { 633 Table = mpc_table_HuffQ_8 [0][0];634 Table = & mpc_HuffQ_8 [0][0]; 634 635 for( ; k < 36; ){ 635 636 int kmax = k + 18; 636 mpc_uint_t cnt = mpc_bits_huff_ dec(r, Table);637 mpc_uint_t cnt = mpc_bits_huff_lut(r, Table); 637 638 idx = 0; 638 639 if (cnt > 0 && cnt < 18) … … 652 653 } 653 654 } else if (Res <= 4) { 654 Table = mpc_table_HuffQ_8[0][Res - 1];655 Table = & mpc_HuffQ_8[Res - 1][0]; 655 656 for ( ; k < 36; k += 2 ) { 656 657 union { … … 658 659 struct { mpc_int8_t s1:4, s2:4; }; 659 660 } tmp; 660 tmp.sym = mpc_bits_huff_ dec(r, Table);661 tmp.sym = mpc_bits_huff_lut(r, Table); 661 662 q[k] = tmp.s1; 662 663 q[k + 1] = tmp.s2; 663 664 } 664 665 } else if (Res <= 8) { 665 Tables[0] = mpc_table_HuffQ_8 [0][Res - 1];666 Tables[1] = mpc_table_HuffQ_8 [1][Res -1];666 Tables[0] = & mpc_HuffQ_8 [Res - 1][0]; 667 Tables[1] = & mpc_HuffQ_8 [Res - 1][1]; 667 668 idx = 2 * thres[Res]; 668 669 for ( ; k < 36; k++ ) { 669 q[k] = mpc_bits_huff_ dec(r, Tables[idx > thres[Res]]);670 q[k] = mpc_bits_huff_lut(r, Tables[idx > thres[Res]]); 670 671 idx = (idx >> 1) + absi(q[k]); 671 672 } 672 673 } else { 673 674 for ( ; k < 36; k++ ) { 674 q[k] = (unsigned char) mpc_bits_huff_ dec(r, mpc_table_HuffQ9up_8);675 q[k] = (unsigned char) mpc_bits_huff_lut(r, & mpc_HuffQ9up_8); 675 676 if (Res != 9) 676 677 q[k] = (q[k] << (Res - 9)) | mpc_bits_read(r, Res - 9);
Note: See TracChangeset
for help on using the changeset viewer.