Changeset 68 for libmpcdec/branches/zorg/src/mpc_decoder.c
- Timestamp:
- 10/06/06 17:14:05 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libmpcdec/branches/zorg/src/mpc_decoder.c
r40 r68 32 32 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 33 */ 34 35 34 /// \file mpc_decoder.c 36 35 /// Core decoding routines and logic. 37 36 #include <string.h> 38 37 #include <mpcdec/mpcdec.h> 39 #include <mpcdec/internal.h> 40 #include <mpcdec/requant.h> 41 #include <mpcdec/huffman.h> 38 #include "decoder.h" 39 #include "huffman.h" 40 #include "internal.h" 41 #include "math.h" 42 #include "requant.h" 42 43 43 44 //SV7 tables 44 extern const HuffmanTyp* mpc_table_HuffQ [2] [8]; 45 extern const HuffmanTyp mpc_table_HuffHdr [10]; 46 extern const HuffmanTyp mpc_table_HuffSCFI [ 4]; 47 extern const HuffmanTyp mpc_table_HuffDSCF [16]; 48 49 50 #ifdef MPC_SUPPORT_SV456 51 //SV4/5/6 tables 52 extern const HuffmanTyp* mpc_table_SampleHuff [18]; 53 extern const HuffmanTyp mpc_table_SCFI_Bundle [ 8]; 54 extern const HuffmanTyp mpc_table_DSCF_Entropie [13]; 55 extern const HuffmanTyp mpc_table_Region_A [16]; 56 extern const HuffmanTyp mpc_table_Region_B [ 8]; 57 extern const HuffmanTyp mpc_table_Region_C [ 4]; 58 59 #endif 45 extern const mpc_huffman* mpc_table_HuffQ [2] [8]; 46 extern const mpc_huffman mpc_table_HuffHdr [10]; 47 extern const mpc_huffman mpc_table_HuffSCFI [ 4]; 48 extern const mpc_huffman mpc_table_HuffDSCF [16]; 60 49 61 50 #ifndef MPC_LITTLE_ENDIAN … … 69 58 //------------------------------------------------------------------------------ 70 59 enum 71 72 EQ_TAP = 13,// length of FIR filter for EQ73 DELAY = ((EQ_TAP + 1) / 2),// delay of FIR74 FIR_BANDS = 4,// number of subbands to be FIR filtered75 MEMSIZE = MPC_DECODER_MEMSIZE,// overall buffer size76 MEMSIZE2 = (MEMSIZE/2),// size of one buffer77 MEMMASK= (MEMSIZE-1)78 60 { 61 EQ_TAP = 13, // length of FIR filter for EQ 62 DELAY = ((EQ_TAP + 1) / 2), // delay of FIR 63 FIR_BANDS = 4, // number of subbands to be FIR filtered 64 MEMSIZE = MPC_DECODER_MEMSIZE, // overall buffer size 65 MEMSIZE2 = (MEMSIZE/2), // size of one buffer 66 MEMMASK = (MEMSIZE-1) 67 }; 79 68 80 69 //------------------------------------------------------------------------------ 81 70 // forward declarations 82 71 //------------------------------------------------------------------------------ 83 void mpc_decoder_read_bitstream_sv6(mpc_decoder *d, mpc_bool_t seeking); 84 void mpc_decoder_read_bitstream_sv7(mpc_decoder *d, mpc_bool_t seeking); 85 mpc_bool_t mpc_decoder_seek_sample(mpc_decoder *d, mpc_int64_t destsample); 86 void mpc_decoder_requantisierung(mpc_decoder *d, const mpc_int32_t Last_Band); 72 static void mpc_decoder_read_bitstream_sv6(mpc_decoder *d, mpc_bool_t seeking); 73 static void mpc_decoder_read_bitstream_sv7(mpc_decoder *d, mpc_bool_t seeking); 74 static void mpc_decoder_requantisierung(mpc_decoder *d, const mpc_int32_t Last_Band); 87 75 88 76 //------------------------------------------------------------------------------ … … 183 171 // works with maximum lengths up to max_length 184 172 static mpc_int32_t 185 mpc_decoder_huffman_decode(mpc_decoder *d, const HuffmanTyp*Table,173 mpc_decoder_huffman_decode(mpc_decoder *d, const mpc_huffman *Table, 186 174 const mpc_uint32_t max_length) 187 175 { … … 205 193 // decode SCFI-bundle (sv4,5,6) 206 194 static void 207 mpc_decoder_scfi_bundle_read(mpc_decoder *d, const HuffmanTyp* Table,195 mpc_decoder_scfi_bundle_read(mpc_decoder *d, const mpc_huffman* Table, 208 196 mpc_int32_t* SCFI, mpc_bool_t* DSCF) 209 197 { … … 267 255 d->dword = SWAP(d->Speicher[0]); 268 256 switch (d->StreamVersion) { 269 #ifdef MPC_SUPPORT_SV456270 case 0x04:271 case 0x05:272 case 0x06:273 mpc_decoder_read_bitstream_sv6(d, FALSE);274 break;275 #endif276 257 case 0x07: 277 258 case 0x17: … … 310 291 FrameBitCnt = mpc_decoder_bits_read(d); 311 292 switch (d->StreamVersion) { 312 #ifdef MPC_SUPPORT_SV456313 case 0x04:314 case 0x05:315 case 0x06:316 mpc_decoder_read_bitstream_sv6(d, FALSE);317 break;318 #endif319 293 case 0x07: 320 294 case 0x17: … … 461 435 if ( d->Res_L [Band] ) { 462 436 if ( d->Res_R [Band] ) { // M!=0, S!=0 463 facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , ( unsigned char)d->SCF_Index_L[Band][0]);464 facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , ( unsigned char)d->SCF_Index_R[Band][0]);437 facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , (mpc_uint8_t) d->SCF_Index_L[Band][0]); 438 facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , (mpc_uint8_t) d->SCF_Index_R[Band][0]); 465 439 for ( n = 0; n < 12; n++, YL += 32, YR += 32 ) { 466 440 *YL = (templ = MPC_MULTIPLY_FLOAT_INT(facL,*L++))+(tempr = MPC_MULTIPLY_FLOAT_INT(facR,*R++)); 467 441 *YR = templ - tempr; 468 442 } 469 facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , ( unsigned char)d->SCF_Index_L[Band][1]);470 facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , ( unsigned char)d->SCF_Index_R[Band][1]);443 facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , (mpc_uint8_t) d->SCF_Index_L[Band][1]); 444 facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , (mpc_uint8_t) d->SCF_Index_R[Band][1]); 471 445 for ( ; n < 24; n++, YL += 32, YR += 32 ) { 472 446 *YL = (templ = MPC_MULTIPLY_FLOAT_INT(facL,*L++))+(tempr = MPC_MULTIPLY_FLOAT_INT(facR,*R++)); 473 447 *YR = templ - tempr; 474 448 } 475 facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , ( unsigned char)d->SCF_Index_L[Band][2]);476 facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , ( unsigned char)d->SCF_Index_R[Band][2]);449 facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , (mpc_uint8_t) d->SCF_Index_L[Band][2]); 450 facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , (mpc_uint8_t) d->SCF_Index_R[Band][2]); 477 451 for ( ; n < 36; n++, YL += 32, YR += 32 ) { 478 452 *YL = (templ = MPC_MULTIPLY_FLOAT_INT(facL,*L++))+(tempr = MPC_MULTIPLY_FLOAT_INT(facR,*R++)); … … 480 454 } 481 455 } else { // M!=0, S==0 482 facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , ( unsigned char)d->SCF_Index_L[Band][0]);456 facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , (mpc_uint8_t) d->SCF_Index_L[Band][0]); 483 457 for ( n = 0; n < 12; n++, YL += 32, YR += 32 ) { 484 458 *YR = *YL = MPC_MULTIPLY_FLOAT_INT(facL,*L++); 485 459 } 486 facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , ( unsigned char)d->SCF_Index_L[Band][1]);460 facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , (mpc_uint8_t) d->SCF_Index_L[Band][1]); 487 461 for ( ; n < 24; n++, YL += 32, YR += 32 ) { 488 462 *YR = *YL = MPC_MULTIPLY_FLOAT_INT(facL,*L++); 489 463 } 490 facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , ( unsigned char)d->SCF_Index_L[Band][2]);464 facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , (mpc_uint8_t) d->SCF_Index_L[Band][2]); 491 465 for ( ; n < 36; n++, YL += 32, YR += 32 ) { 492 466 *YR = *YL = MPC_MULTIPLY_FLOAT_INT(facL,*L++); … … 496 470 if (d->Res_R[Band]) // M==0, S!=0 497 471 { 498 facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , ( unsigned char)d->SCF_Index_R[Band][0]);472 facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , (mpc_uint8_t) d->SCF_Index_R[Band][0]); 499 473 for ( n = 0; n < 12; n++, YL += 32, YR += 32 ) { 500 474 *YR = - (*YL = MPC_MULTIPLY_FLOAT_INT(facR,*(R++))); 501 475 } 502 facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , ( unsigned char)d->SCF_Index_R[Band][1]);476 facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , (mpc_uint8_t) d->SCF_Index_R[Band][1]); 503 477 for ( ; n < 24; n++, YL += 32, YR += 32 ) { 504 478 *YR = - (*YL = MPC_MULTIPLY_FLOAT_INT(facR,*(R++))); 505 479 } 506 facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , ( unsigned char)d->SCF_Index_R[Band][2]);480 facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , (mpc_uint8_t) d->SCF_Index_R[Band][2]); 507 481 for ( ; n < 36; n++, YL += 32, YR += 32 ) { 508 482 *YR = - (*YL = MPC_MULTIPLY_FLOAT_INT(facR,*(R++))); … … 519 493 if ( d->Res_L [Band] ) { 520 494 if ( d->Res_R [Band] ) { // L!=0, R!=0 521 facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , ( unsigned char)d->SCF_Index_L[Band][0]);522 facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , ( unsigned char)d->SCF_Index_R[Band][0]);495 facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , (mpc_uint8_t) d->SCF_Index_L[Band][0]); 496 facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , (mpc_uint8_t) d->SCF_Index_R[Band][0]); 523 497 for (n = 0; n < 12; n++, YL += 32, YR += 32 ) { 524 498 *YL = MPC_MULTIPLY_FLOAT_INT(facL,*L++); 525 499 *YR = MPC_MULTIPLY_FLOAT_INT(facR,*R++); 526 500 } 527 facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , ( unsigned char)d->SCF_Index_L[Band][1]);528 facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , ( unsigned char)d->SCF_Index_R[Band][1]);501 facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , (mpc_uint8_t) d->SCF_Index_L[Band][1]); 502 facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , (mpc_uint8_t) d->SCF_Index_R[Band][1]); 529 503 for (; n < 24; n++, YL += 32, YR += 32 ) { 530 504 *YL = MPC_MULTIPLY_FLOAT_INT(facL,*L++); 531 505 *YR = MPC_MULTIPLY_FLOAT_INT(facR,*R++); 532 506 } 533 facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , ( unsigned char)d->SCF_Index_L[Band][2]);534 facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , ( unsigned char)d->SCF_Index_R[Band][2]);507 facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , (mpc_uint8_t) d->SCF_Index_L[Band][2]); 508 facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , (mpc_uint8_t) d->SCF_Index_R[Band][2]); 535 509 for (; n < 36; n++, YL += 32, YR += 32 ) { 536 510 *YL = MPC_MULTIPLY_FLOAT_INT(facL,*L++); … … 538 512 } 539 513 } else { // L!=0, R==0 540 facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , ( unsigned char)d->SCF_Index_L[Band][0]);514 facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , (mpc_uint8_t) d->SCF_Index_L[Band][0]); 541 515 for ( n = 0; n < 12; n++, YL += 32, YR += 32 ) { 542 516 *YL = MPC_MULTIPLY_FLOAT_INT(facL,*L++); 543 517 *YR = 0; 544 518 } 545 facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , ( unsigned char)d->SCF_Index_L[Band][1]);519 facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , (mpc_uint8_t) d->SCF_Index_L[Band][1]); 546 520 for ( ; n < 24; n++, YL += 32, YR += 32 ) { 547 521 *YL = MPC_MULTIPLY_FLOAT_INT(facL,*L++); 548 522 *YR = 0; 549 523 } 550 facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , ( unsigned char)d->SCF_Index_L[Band][2]);524 facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , (mpc_uint8_t) d->SCF_Index_L[Band][2]); 551 525 for ( ; n < 36; n++, YL += 32, YR += 32 ) { 552 526 *YL = MPC_MULTIPLY_FLOAT_INT(facL,*L++); … … 557 531 else { 558 532 if ( d->Res_R [Band] ) { // L==0, R!=0 559 facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , ( unsigned char)d->SCF_Index_R[Band][0]);533 facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , (mpc_uint8_t) d->SCF_Index_R[Band][0]); 560 534 for ( n = 0; n < 12; n++, YL += 32, YR += 32 ) { 561 535 *YL = 0; 562 536 *YR = MPC_MULTIPLY_FLOAT_INT(facR,*R++); 563 537 } 564 facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , ( unsigned char)d->SCF_Index_R[Band][1]);538 facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , (mpc_uint8_t) d->SCF_Index_R[Band][1]); 565 539 for ( ; n < 24; n++, YL += 32, YR += 32 ) { 566 540 *YL = 0; 567 541 *YR = MPC_MULTIPLY_FLOAT_INT(facR,*R++); 568 542 } 569 facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , ( unsigned char)d->SCF_Index_R[Band][2]);543 facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , (mpc_uint8_t) d->SCF_Index_R[Band][2]); 570 544 for ( ; n < 36; n++, YL += 32, YR += 32 ) { 571 545 *YL = 0; … … 582 556 } 583 557 584 #ifdef MPC_SUPPORT_SV456585 static const unsigned char Q_res[32][16] = {586 {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},587 {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},588 {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},589 {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},590 {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},591 {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},592 {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},593 {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},594 {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},595 {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},596 {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},597 {0,1,2,3,4,5,6,17,0,0,0,0,0,0,0,0},598 {0,1,2,3,4,5,6,17,0,0,0,0,0,0,0,0},599 {0,1,2,3,4,5,6,17,0,0,0,0,0,0,0,0},600 {0,1,2,3,4,5,6,17,0,0,0,0,0,0,0,0},601 {0,1,2,3,4,5,6,17,0,0,0,0,0,0,0,0},602 {0,1,2,3,4,5,6,17,0,0,0,0,0,0,0,0},603 {0,1,2,3,4,5,6,17,0,0,0,0,0,0,0,0},604 {0,1,2,3,4,5,6,17,0,0,0,0,0,0,0,0},605 {0,1,2,3,4,5,6,17,0,0,0,0,0,0,0,0},606 {0,1,2,3,4,5,6,17,0,0,0,0,0,0,0,0},607 {0,1,2,3,4,5,6,17,0,0,0,0,0,0,0,0},608 {0,1,2,3,4,5,6,17,0,0,0,0,0,0,0,0},609 {0,1,2,17,0,0,0,0,0,0,0,0,0,0,0,0},610 {0,1,2,17,0,0,0,0,0,0,0,0,0,0,0,0},611 {0,1,2,17,0,0,0,0,0,0,0,0,0,0,0,0},612 {0,1,2,17,0,0,0,0,0,0,0,0,0,0,0,0},613 {0,1,2,17,0,0,0,0,0,0,0,0,0,0,0,0},614 {0,1,2,17,0,0,0,0,0,0,0,0,0,0,0,0},615 {0,1,2,17,0,0,0,0,0,0,0,0,0,0,0,0},616 {0,1,2,17,0,0,0,0,0,0,0,0,0,0,0,0},617 {0,1,2,17,0,0,0,0,0,0,0,0,0,0,0,0},618 };619 620 /****************************************** SV 6 ******************************************/621 void622 mpc_decoder_read_bitstream_sv6(mpc_decoder *d, mpc_bool_t seeking)623 {624 mpc_int32_t n,k;625 mpc_int32_t Max_used_Band=0;626 const HuffmanTyp *Table;627 const HuffmanTyp *x1;628 const HuffmanTyp *x2;629 mpc_int32_t *L;630 mpc_int32_t *R;631 mpc_int32_t *ResL = d->Res_L;632 mpc_int32_t *ResR = d->Res_R;633 634 /************************ HEADER **************************/635 ResL = d->Res_L;636 ResR = d->Res_R;637 for (n=0; n <= d->Max_Band; ++n, ++ResL, ++ResR)638 {639 if (n<11) Table = mpc_table_Region_A;640 else if (n>=11 && n<=22) Table = mpc_table_Region_B;641 else /*if (n>=23)*/ Table = mpc_table_Region_C;642 643 *ResL = Q_res[n][mpc_decoder_huffman_decode(d, Table, 14)];644 if (d->MS_used) {645 d->MS_Flag[n] = mpc_decoder_bitstream_read(d, 1);646 }647 *ResR = Q_res[n][mpc_decoder_huffman_decode(d, Table, 14)];648 649 // only perform the following procedure up to the maximum non-zero subband650 if (*ResL || *ResR) Max_used_Band = n;651 }652 653 /************************* SCFI-Bundle *****************************/654 ResL = d->Res_L;655 ResR = d->Res_R;656 for (n=0; n<=Max_used_Band; ++n, ++ResL, ++ResR) {657 if (*ResL) mpc_decoder_scfi_bundle_read(d, mpc_table_SCFI_Bundle, &(d->SCFI_L[n]), &(d->DSCF_Flag_L[n]));658 if (*ResR) mpc_decoder_scfi_bundle_read(d, mpc_table_SCFI_Bundle, &(d->SCFI_R[n]), &(d->DSCF_Flag_R[n]));659 }660 661 /***************************** SCFI ********************************/662 ResL = d->Res_L;663 ResR = d->Res_R;664 L = d->SCF_Index_L[0];665 R = d->SCF_Index_R[0];666 for (n=0; n <= Max_used_Band; ++n, ++ResL, ++ResR, L+=3, R+=3)667 {668 if (*ResL)669 {670 /*********** DSCF ************/671 if (d->DSCF_Flag_L[n]==1)672 {673 switch (d->SCFI_L[n])674 {675 case 3:676 L[0] = L[2] + mpc_decoder_huffman_decode(d, mpc_table_DSCF_Entropie, 6);677 L[1] = L[0];678 L[2] = L[1];679 break;680 case 1:681 L[0] = L[2] + mpc_decoder_huffman_decode(d, mpc_table_DSCF_Entropie, 6);682 L[1] = L[0] + mpc_decoder_huffman_decode(d, mpc_table_DSCF_Entropie, 6);683 L[2] = L[1];684 break;685 case 2:686 L[0] = L[2] + mpc_decoder_huffman_decode(d, mpc_table_DSCF_Entropie, 6);687 L[1] = L[0];688 L[2] = L[1] + mpc_decoder_huffman_decode(d, mpc_table_DSCF_Entropie, 6);689 break;690 case 0:691 L[0] = L[2] + mpc_decoder_huffman_decode(d, mpc_table_DSCF_Entropie, 6);692 L[1] = L[0] + mpc_decoder_huffman_decode(d, mpc_table_DSCF_Entropie, 6);693 L[2] = L[1] + mpc_decoder_huffman_decode(d, mpc_table_DSCF_Entropie, 6);694 break;695 default:696 return;697 }698 if (L[0] > 1024)699 L[0] = 0x8080;700 if (L[1] > 1024)701 L[1] = 0x8080;702 if (L[2] > 1024)703 L[2] = 0x8080;704 }705 /************ SCF ************/706 else707 {708 switch (d->SCFI_L[n])709 {710 case 3:711 L[0] = mpc_decoder_bitstream_read(d, 6);712 L[1] = L[0];713 L[2] = L[1];714 break;715 case 1:716 L[0] = mpc_decoder_bitstream_read(d, 6);717 L[1] = mpc_decoder_bitstream_read(d, 6);718 L[2] = L[1];719 break;720 case 2:721 L[0] = mpc_decoder_bitstream_read(d, 6);722 L[1] = L[0];723 L[2] = mpc_decoder_bitstream_read(d, 6);724 break;725 case 0:726 L[0] = mpc_decoder_bitstream_read(d, 6);727 L[1] = mpc_decoder_bitstream_read(d, 6);728 L[2] = mpc_decoder_bitstream_read(d, 6);729 break;730 default:731 return;732 }733 }734 }735 if (*ResR)736 {737 /*********** DSCF ************/738 if (d->DSCF_Flag_R[n]==1)739 {740 switch (d->SCFI_R[n])741 {742 case 3:743 R[0] = R[2] + mpc_decoder_huffman_decode(d, mpc_table_DSCF_Entropie, 6);744 R[1] = R[0];745 R[2] = R[1];746 break;747 case 1:748 R[0] = R[2] + mpc_decoder_huffman_decode(d, mpc_table_DSCF_Entropie, 6);749 R[1] = R[0] + mpc_decoder_huffman_decode(d, mpc_table_DSCF_Entropie, 6);750 R[2] = R[1];751 break;752 case 2:753 R[0] = R[2] + mpc_decoder_huffman_decode(d, mpc_table_DSCF_Entropie, 6);754 R[1] = R[0];755 R[2] = R[1] + mpc_decoder_huffman_decode(d, mpc_table_DSCF_Entropie, 6);756 break;757 case 0:758 R[0] = R[2] + mpc_decoder_huffman_decode(d, mpc_table_DSCF_Entropie, 6);759 R[1] = R[0] + mpc_decoder_huffman_decode(d, mpc_table_DSCF_Entropie, 6);760 R[2] = R[1] + mpc_decoder_huffman_decode(d, mpc_table_DSCF_Entropie, 6);761 break;762 default:763 return;764 }765 if (R[0] > 1024)766 R[0] = 0x8080;767 if (R[1] > 1024)768 R[1] = 0x8080;769 if (R[2] > 1024)770 R[2] = 0x8080;771 }772 /************ SCF ************/773 else774 {775 switch (d->SCFI_R[n])776 {777 case 3:778 R[0] = mpc_decoder_bitstream_read(d, 6);779 R[1] = R[0];780 R[2] = R[1];781 break;782 case 1:783 R[0] = mpc_decoder_bitstream_read(d, 6);784 R[1] = mpc_decoder_bitstream_read(d, 6);785 R[2] = R[1];786 break;787 case 2:788 R[0] = mpc_decoder_bitstream_read(d, 6);789 R[1] = R[0];790 R[2] = mpc_decoder_bitstream_read(d, 6);791 break;792 case 0:793 R[0] = mpc_decoder_bitstream_read(d, 6);794 R[1] = mpc_decoder_bitstream_read(d, 6);795 R[2] = mpc_decoder_bitstream_read(d, 6);796 break;797 default:798 return;799 break;800 }801 }802 }803 }804 805 if (seeking == TRUE)806 return;807 808 /**************************** Samples ****************************/809 ResL = d->Res_L;810 ResR = d->Res_R;811 for (n=0; n <= Max_used_Band; ++n, ++ResL, ++ResR)812 {813 // setting pointers814 x1 = mpc_table_SampleHuff[*ResL];815 x2 = mpc_table_SampleHuff[*ResR];816 L = d->Q[n].L;817 R = d->Q[n].R;818 819 if (x1!=NULL || x2!=NULL)820 for (k=0; k<36; ++k)821 {822 if (x1 != NULL) *L++ = mpc_decoder_huffman_decode(d, x1, 8);823 if (x2 != NULL) *R++ = mpc_decoder_huffman_decode(d, x2, 8);824 }825 826 if (*ResL>7 || *ResR>7)827 for (k=0; k<36; ++k)828 {829 if (*ResL>7) *L++ = (mpc_int32_t)mpc_decoder_bitstream_read(d, Res_bit[*ResL]) - Dc[*ResL];830 if (*ResR>7) *R++ = (mpc_int32_t)mpc_decoder_bitstream_read(d, Res_bit[*ResR]) - Dc[*ResR];831 }832 }833 }834 #endif //MPC_SUPPORT_SV456835 /****************************************** SV 7 ******************************************/836 558 void 837 559 mpc_decoder_read_bitstream_sv7(mpc_decoder *d, mpc_bool_t seeking) … … 846 568 mpc_int32_t n,k; 847 569 mpc_int32_t Max_used_Band=0; 848 const HuffmanTyp*Table;570 const mpc_huffman *Table; 849 571 mpc_int32_t idx; 850 572 mpc_int32_t *L ,*R; … … 1246 968 1247 969 if (fwd <= d->DecodedFrames + d->seeking_window) { 1248 if (d->StreamVersion >= 7) {970 if (d->StreamVersion >= 7) 1249 971 mpc_decoder_read_bitstream_sv7(d, TRUE); 1250 } else { 1251 #ifdef MPC_SUPPORT_SV456 1252 mpc_decoder_read_bitstream_sv6(d, TRUE); 1253 #else 972 else 1254 973 return FALSE; 1255 #endif1256 }1257 974 } 1258 975 mpc_decoder_bitstream_jump(d, FwdJumpInfo - mpc_decoder_bits_read(d));
Note: See TracChangeset
for help on using the changeset viewer.