diff options
Diffstat (limited to 'apps/codecs')
-rw-r--r-- | apps/codecs/libmusepack/decoder.h | 4 | ||||
-rw-r--r-- | apps/codecs/libmusepack/mpc_decoder.c | 268 | ||||
-rw-r--r-- | apps/codecs/libmusepack/musepack.h | 7 | ||||
-rw-r--r-- | apps/codecs/libmusepack/requant.c | 27 | ||||
-rw-r--r-- | apps/codecs/libmusepack/requant.h | 12 | ||||
-rw-r--r-- | apps/codecs/mpc.c | 6 |
6 files changed, 123 insertions, 201 deletions
diff --git a/apps/codecs/libmusepack/decoder.h b/apps/codecs/libmusepack/decoder.h index bbd1aa9610..e36425bd1e 100644 --- a/apps/codecs/libmusepack/decoder.h +++ b/apps/codecs/libmusepack/decoder.h | |||
@@ -110,11 +110,7 @@ typedef struct mpc_decoder_t { | |||
110 | mpc_bool_t MS_Flag[32]; // MS used? | 110 | mpc_bool_t MS_Flag[32]; // MS used? |
111 | 111 | ||
112 | mpc_uint32_t* SeekTable; | 112 | mpc_uint32_t* SeekTable; |
113 | mpc_bool_t Use_SeekTable; | ||
114 | mpc_bool_t Use_FastSeek; | ||
115 | mpc_bool_t Use_StaticSeekTable; | ||
116 | mpc_uint8_t SeekTable_Step; | 113 | mpc_uint8_t SeekTable_Step; |
117 | mpc_uint32_t Max_SeekTable_Size; | ||
118 | 114 | ||
119 | #ifdef MPC_FIXED_POINT | 115 | #ifdef MPC_FIXED_POINT |
120 | unsigned char SCF_shift[256]; | 116 | unsigned char SCF_shift[256]; |
diff --git a/apps/codecs/libmusepack/mpc_decoder.c b/apps/codecs/libmusepack/mpc_decoder.c index f3aff7e54b..c41b17c54c 100644 --- a/apps/codecs/libmusepack/mpc_decoder.c +++ b/apps/codecs/libmusepack/mpc_decoder.c | |||
@@ -468,7 +468,7 @@ mpc_decoder_decode_internal(mpc_decoder *d, MPC_SAMPLE_FORMAT *buffer) | |||
468 | return (mpc_uint32_t)(-1); // end of file -> abort decoding | 468 | return (mpc_uint32_t)(-1); // end of file -> abort decoding |
469 | } | 469 | } |
470 | 470 | ||
471 | if (d->DecodedFrames == 0 && d->Use_SeekTable) | 471 | if (d->DecodedFrames == 0) |
472 | d->SeekTable[0] = mpc_decoder_bits_read(d); | 472 | d->SeekTable[0] = mpc_decoder_bits_read(d); |
473 | 473 | ||
474 | // read jump-info for validity check of frame | 474 | // read jump-info for validity check of frame |
@@ -497,25 +497,21 @@ mpc_decoder_decode_internal(mpc_decoder *d, MPC_SAMPLE_FORMAT *buffer) | |||
497 | 497 | ||
498 | d->DecodedFrames++; | 498 | d->DecodedFrames++; |
499 | 499 | ||
500 | if (d->Use_SeekTable) { | 500 | /* update seek table */ |
501 | if (d->SeekTable_Step == 1) { | 501 | if (d->SeekTable_Step == 1) { |
502 | d->SeekTable [d->DecodedFrames] = d->FwdJumpInfo + 20; | 502 | d->SeekTable [d->DecodedFrames] = d->FwdJumpInfo + 20; |
503 | } else { | 503 | } else { |
504 | if ((d->DecodedFrames-1) % d->SeekTable_Step == 0) { | 504 | if ((d->DecodedFrames-1) % d->SeekTable_Step == 0) { |
505 | d->SeekTable[d->SeekTableIndex] = d->SeekTableCounter; | 505 | d->SeekTable[d->SeekTableIndex] = d->SeekTableCounter; |
506 | d->SeekTableIndex += 1; | 506 | d->SeekTableIndex += 1; |
507 | d->SeekTableCounter = 0; | 507 | d->SeekTableCounter = 0; |
508 | } | ||
509 | d->SeekTableCounter += d->FwdJumpInfo + 20; | ||
510 | } | 508 | } |
509 | d->SeekTableCounter += d->FwdJumpInfo + 20; | ||
511 | } | 510 | } |
512 | 511 | ||
513 | // synthesize signal | 512 | // synthesize signal |
514 | mpc_decoder_requantisierung(d, d->Max_Band); | 513 | mpc_decoder_requantisierung(d, d->Max_Band); |
515 | 514 | ||
516 | //if ( d->EQ_activated && PluginSettings.EQbyMPC ) | ||
517 | // perform_EQ (); | ||
518 | |||
519 | mpc_decoder_synthese_filter_float(d, buffer); | 515 | mpc_decoder_synthese_filter_float(d, buffer); |
520 | 516 | ||
521 | // cut off first MPC_DECODER_SYNTH_DELAY zero-samples | 517 | // cut off first MPC_DECODER_SYNTH_DELAY zero-samples |
@@ -570,8 +566,6 @@ mpc_uint32_t mpc_decoder_decode( | |||
570 | { | 566 | { |
571 | for(;;) | 567 | for(;;) |
572 | { | 568 | { |
573 | //const mpc_int32_t MaxBrokenFrames = 0; // PluginSettings.MaxBrokenFrames | ||
574 | |||
575 | mpc_uint32_t RING = d->Zaehler; | 569 | mpc_uint32_t RING = d->Zaehler; |
576 | mpc_int32_t vbr_ring = (RING << 5) + d->pos; | 570 | mpc_int32_t vbr_ring = (RING << 5) + d->pos; |
577 | 571 | ||
@@ -764,7 +758,7 @@ mpc_decoder_requantisierung(mpc_decoder *d, const mpc_int32_t Last_Band) | |||
764 | } | 758 | } |
765 | 759 | ||
766 | #ifdef MPC_SUPPORT_SV456 | 760 | #ifdef MPC_SUPPORT_SV456 |
767 | static const unsigned char Q_res[32][16] = { | 761 | static const unsigned char Q_res[32][16] ICONST_ATTR = { |
768 | {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17}, | 762 | {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17}, |
769 | {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17}, | 763 | {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17}, |
770 | {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17}, | 764 | {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17}, |
@@ -974,8 +968,6 @@ mpc_decoder_read_bitstream_sv6(mpc_decoder *d) | |||
974 | break; | 968 | break; |
975 | } | 969 | } |
976 | } | 970 | } |
977 | // update Reference for DSCF | ||
978 | //d->DSCF_Reference_R[n] = R[2]; | ||
979 | } | 971 | } |
980 | } | 972 | } |
981 | 973 | ||
@@ -1010,13 +1002,6 @@ mpc_decoder_read_bitstream_sv6(mpc_decoder *d) | |||
1010 | void | 1002 | void |
1011 | mpc_decoder_read_bitstream_sv7(mpc_decoder *d, mpc_bool_t fastSeeking) | 1003 | mpc_decoder_read_bitstream_sv7(mpc_decoder *d, mpc_bool_t fastSeeking) |
1012 | { | 1004 | { |
1013 | // these arrays hold decoding results for bundled quantizers (3- and 5-step) | ||
1014 | /*static*/ mpc_int32_t idx30[] = { -1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1}; | ||
1015 | /*static*/ mpc_int32_t idx31[] = { -1,-1,-1, 0, 0, 0, 1, 1, 1,-1,-1,-1, 0, 0, 0, 1, 1, 1,-1,-1,-1, 0, 0, 0, 1, 1, 1}; | ||
1016 | /*static*/ mpc_int32_t idx32[] = { -1,-1,-1,-1,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1}; | ||
1017 | /*static*/ mpc_int32_t idx50[] = { -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2}; | ||
1018 | /*static*/ mpc_int32_t idx51[] = { -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2}; | ||
1019 | |||
1020 | mpc_int32_t n,k; | 1005 | mpc_int32_t n,k; |
1021 | mpc_int32_t Max_used_Band=0; | 1006 | mpc_int32_t Max_used_Band=0; |
1022 | const HuffmanTyp *Table; | 1007 | const HuffmanTyp *Table; |
@@ -1340,7 +1325,7 @@ mpc_decoder_read_bitstream_sv7(mpc_decoder *d, mpc_bool_t fastSeeking) | |||
1340 | { | 1325 | { |
1341 | idx = HUFFMAN_DECODE_FASTEST ( d, Table, LUT, max_length ); | 1326 | idx = HUFFMAN_DECODE_FASTEST ( d, Table, LUT, max_length ); |
1342 | *RQ++ = idx50[idx]; | 1327 | *RQ++ = idx50[idx]; |
1343 | *RQ++ = idx51[idx]; | 1328 | *RQ++ = idx51[idx]; |
1344 | } | 1329 | } |
1345 | break; | 1330 | break; |
1346 | case 3: | 1331 | case 3: |
@@ -1451,19 +1436,11 @@ void mpc_decoder_setup(mpc_decoder *d, mpc_reader *r) | |||
1451 | d->WordsRead = 0; | 1436 | d->WordsRead = 0; |
1452 | d->Max_Band = 0; | 1437 | d->Max_Band = 0; |
1453 | d->SeekTable = NULL; | 1438 | d->SeekTable = NULL; |
1454 | d->Use_FastSeek = TRUE; | ||
1455 | d->Use_SeekTable = TRUE; | ||
1456 | d->Use_StaticSeekTable = FALSE; | ||
1457 | d->SeekTable_Step = 1; | 1439 | d->SeekTable_Step = 1; |
1458 | d->SeekTableIndex = 0; | 1440 | d->SeekTableIndex = 0; |
1459 | d->SeekTableCounter = 0; | 1441 | d->SeekTableCounter = 0; |
1460 | d->Max_SeekTable_Size = 0; | ||
1461 | 1442 | ||
1462 | mpc_decoder_initialisiere_quantisierungstabellen(d, 1.0f); | 1443 | mpc_decoder_initialisiere_quantisierungstabellen(d, 1.0f); |
1463 | #if 0 | ||
1464 | mpc_decoder_init_huffman_sv6(d); | ||
1465 | mpc_decoder_init_huffman_sv7(d); | ||
1466 | #endif | ||
1467 | 1444 | ||
1468 | LOOKUP ( mpc_table_HuffQ[0][1], 27, LUT1_0 ); | 1445 | LOOKUP ( mpc_table_HuffQ[0][1], 27, LUT1_0 ); |
1469 | LOOKUP ( mpc_table_HuffQ[1][1], 27, LUT1_1 ); | 1446 | LOOKUP ( mpc_table_HuffQ[1][1], 27, LUT1_1 ); |
@@ -1490,16 +1467,15 @@ void mpc_decoder_setup(mpc_decoder *d, mpc_reader *r) | |||
1490 | #endif | 1467 | #endif |
1491 | } | 1468 | } |
1492 | 1469 | ||
1493 | void mpc_decoder_destroy(mpc_decoder *d) { | 1470 | void mpc_decoder_destroy(mpc_decoder *d) |
1494 | 1471 | { | |
1495 | if (d->SeekTable != NULL && d->Use_StaticSeekTable == FALSE) | 1472 | if (d->SeekTable != NULL) |
1496 | free(d->SeekTable); | 1473 | free(d->SeekTable); |
1497 | |||
1498 | } | 1474 | } |
1499 | 1475 | ||
1500 | void mpc_decoder_set_streaminfo(mpc_decoder *d, mpc_streaminfo *si) | 1476 | static void mpc_decoder_set_streaminfo(mpc_decoder *d, mpc_streaminfo *si) |
1501 | { | 1477 | { |
1502 | mpc_uint16_t seekTableSize; | 1478 | mpc_uint32_t seekTableSize; |
1503 | 1479 | ||
1504 | mpc_decoder_reset_synthesis(d); | 1480 | mpc_decoder_reset_synthesis(d); |
1505 | mpc_decoder_reset_globals(d); | 1481 | mpc_decoder_reset_globals(d); |
@@ -1514,28 +1490,14 @@ void mpc_decoder_set_streaminfo(mpc_decoder *d, mpc_streaminfo *si) | |||
1514 | 1490 | ||
1515 | d->samples_to_skip = MPC_DECODER_SYNTH_DELAY; | 1491 | d->samples_to_skip = MPC_DECODER_SYNTH_DELAY; |
1516 | 1492 | ||
1517 | if (d->SeekTable != NULL && d->Use_StaticSeekTable == FALSE) | 1493 | if (d->SeekTable != NULL) |
1518 | free(d->SeekTable); | 1494 | free(d->SeekTable); |
1519 | 1495 | ||
1520 | if (d->Use_SeekTable) { | 1496 | seekTableSize = si->frames; |
1521 | if (d->Use_StaticSeekTable == FALSE) { | 1497 | d->SeekTable = (mpc_uint32_t*) calloc( sizeof(mpc_uint32_t), seekTableSize); |
1522 | if (d->Max_SeekTable_Size == 0) { | 1498 | d->SeekTable_Step = si->frames / seekTableSize; |
1523 | seekTableSize = si->frames; | 1499 | if (si->frames % seekTableSize) |
1524 | } else { | 1500 | d->SeekTable_Step+=1; |
1525 | seekTableSize = min(si->frames, d->Max_SeekTable_Size / sizeof(mpc_uint32_t)); | ||
1526 | } | ||
1527 | d->SeekTable = (mpc_uint32_t*) calloc( sizeof(mpc_uint32_t), seekTableSize); | ||
1528 | d->SeekTable_Step = si->frames / seekTableSize; | ||
1529 | if (si->frames % seekTableSize) | ||
1530 | d->SeekTable_Step+=1; | ||
1531 | } else { | ||
1532 | seekTableSize = d->Max_SeekTable_Size / sizeof(mpc_uint32_t); | ||
1533 | d->SeekTable_Step = si->frames / seekTableSize; | ||
1534 | if (si->frames % seekTableSize) | ||
1535 | d->SeekTable_Step+=1; | ||
1536 | } | ||
1537 | } | ||
1538 | |||
1539 | } | 1501 | } |
1540 | 1502 | ||
1541 | mpc_bool_t mpc_decoder_initialize(mpc_decoder *d, mpc_streaminfo *si) | 1503 | mpc_bool_t mpc_decoder_initialize(mpc_decoder *d, mpc_streaminfo *si) |
@@ -1563,43 +1525,6 @@ mpc_bool_t mpc_decoder_initialize(mpc_decoder *d, mpc_streaminfo *si) | |||
1563 | return TRUE; | 1525 | return TRUE; |
1564 | } | 1526 | } |
1565 | 1527 | ||
1566 | //--------------------------------------------------------------- | ||
1567 | // will seek from the beginning of the file to the desired | ||
1568 | // position in ms (given by seek_needed) | ||
1569 | //--------------------------------------------------------------- | ||
1570 | #if 0 | ||
1571 | static void | ||
1572 | helper1(mpc_decoder *d, mpc_uint32_t bitpos) | ||
1573 | { | ||
1574 | f_seek(d, (bitpos >> 5) * 4 + d->MPCHeaderPos); | ||
1575 | f_read_dword(d, d->Speicher, 2); | ||
1576 | d->dword = SWAP(d->Speicher[d->Zaehler = 0]); | ||
1577 | d->pos = bitpos & 31; | ||
1578 | } | ||
1579 | |||
1580 | static void | ||
1581 | helper2(mpc_decoder *d, mpc_uint32_t bitpos) | ||
1582 | { | ||
1583 | f_seek(d, (bitpos>>5) * 4 + d->MPCHeaderPos); | ||
1584 | f_read_dword(d, d->Speicher, MEMSIZE); | ||
1585 | d->dword = SWAP(d->Speicher[d->Zaehler = 0]); | ||
1586 | d->pos = bitpos & 31; | ||
1587 | } | ||
1588 | |||
1589 | static void | ||
1590 | helper3(mpc_decoder *d, mpc_uint32_t bitpos, mpc_uint32_t* buffoffs) | ||
1591 | { | ||
1592 | d->pos = bitpos & 31; | ||
1593 | bitpos >>= 5; | ||
1594 | if ((mpc_uint32_t)(bitpos - *buffoffs) >= MEMSIZE - 2) { | ||
1595 | *buffoffs = bitpos; | ||
1596 | f_seek(d, bitpos * 4L + d->MPCHeaderPos); | ||
1597 | f_read_dword(d, d->Speicher, MEMSIZE ); | ||
1598 | } | ||
1599 | d->dword = SWAP(d->Speicher[d->Zaehler = bitpos - *buffoffs ]); | ||
1600 | } | ||
1601 | #endif | ||
1602 | |||
1603 | // jumps over the current frame | 1528 | // jumps over the current frame |
1604 | mpc_uint32_t mpc_decoder_jump_frame(mpc_decoder *d) { | 1529 | mpc_uint32_t mpc_decoder_jump_frame(mpc_decoder *d) { |
1605 | 1530 | ||
@@ -1622,7 +1547,9 @@ static mpc_uint32_t get_initial_fpos(mpc_decoder *d, mpc_uint32_t StreamVersion) | |||
1622 | { | 1547 | { |
1623 | mpc_uint32_t fpos = 0; | 1548 | mpc_uint32_t fpos = 0; |
1624 | (void) StreamVersion; | 1549 | (void) StreamVersion; |
1625 | switch ( d->StreamVersion ) { // setting position to the beginning of the data-bitstream | 1550 | |
1551 | // setting position to the beginning of the data-bitstream | ||
1552 | switch ( d->StreamVersion ) { | ||
1626 | case 0x04: fpos = 48; break; | 1553 | case 0x04: fpos = 48; break; |
1627 | case 0x05: | 1554 | case 0x05: |
1628 | case 0x06: fpos = 64; break; | 1555 | case 0x06: fpos = 64; break; |
@@ -1685,7 +1612,7 @@ mpc_bool_t mpc_decoder_seek_sample(mpc_decoder *d, mpc_int64_t destsample) | |||
1685 | if (seekFrame > 33) | 1612 | if (seekFrame > 33) |
1686 | lastFrame = seekFrame - 33 + 1 - d->SeekTable_Step; | 1613 | lastFrame = seekFrame - 33 + 1 - d->SeekTable_Step; |
1687 | 1614 | ||
1688 | if ((!d->Use_SeekTable && delta < 0) || d->MaxDecodedFrames == 0) { | 1615 | if (d->MaxDecodedFrames == 0) { |
1689 | 1616 | ||
1690 | mpc_decoder_reset_state(d); | 1617 | mpc_decoder_reset_state(d); |
1691 | 1618 | ||
@@ -1698,29 +1625,24 @@ mpc_bool_t mpc_decoder_seek_sample(mpc_decoder *d, mpc_int64_t destsample) | |||
1698 | // reset number of decoded frames | 1625 | // reset number of decoded frames |
1699 | d->DecodedFrames = 0; | 1626 | d->DecodedFrames = 0; |
1700 | 1627 | ||
1701 | if (d->Use_SeekTable) { | 1628 | // jump to the last frame, updating seek table |
1702 | // jump to the last frame, updating seek table | 1629 | if (d->SeekTable_Step == 1) { |
1703 | if (d->SeekTable_Step == 1) { | 1630 | d->SeekTable[0] = (mpc_uint32_t)fpos; |
1704 | d->SeekTable[0] = (mpc_uint32_t)fpos; | 1631 | for (;d->DecodedFrames < lastFrame; d->DecodedFrames++) |
1705 | for (;d->DecodedFrames < lastFrame; d->DecodedFrames++) | 1632 | d->SeekTable[d->DecodedFrames+1] = mpc_decoder_jump_frame(d); |
1706 | d->SeekTable[d->DecodedFrames+1] = mpc_decoder_jump_frame(d); | 1633 | } else { |
1707 | } else { | 1634 | d->SeekTableIndex = 0; |
1708 | d->SeekTableIndex = 0; | 1635 | d->SeekTableCounter = (mpc_uint32_t)fpos; |
1709 | d->SeekTableCounter = (mpc_uint32_t)fpos; | 1636 | for (;d->DecodedFrames < lastFrame; d->DecodedFrames++) { |
1710 | for (;d->DecodedFrames < lastFrame; d->DecodedFrames++) { | 1637 | if (d->DecodedFrames % d->SeekTable_Step == 0) { |
1711 | if (d->DecodedFrames % d->SeekTable_Step == 0) { | 1638 | d->SeekTable[d->SeekTableIndex] = d->SeekTableCounter; |
1712 | d->SeekTable[d->SeekTableIndex] = d->SeekTableCounter; | 1639 | d->SeekTableIndex += 1; |
1713 | d->SeekTableIndex += 1; | 1640 | d->SeekTableCounter = 0; |
1714 | d->SeekTableCounter = 0; | ||
1715 | } | ||
1716 | d->SeekTableCounter += mpc_decoder_jump_frame(d); | ||
1717 | } | 1641 | } |
1642 | d->SeekTableCounter += mpc_decoder_jump_frame(d); | ||
1718 | } | 1643 | } |
1719 | } else { | 1644 | } |
1720 | // just jump to the last frame | 1645 | |
1721 | for (;d->DecodedFrames < lastFrame; d->DecodedFrames++) | ||
1722 | mpc_decoder_jump_frame(d); | ||
1723 | } | ||
1724 | 1646 | ||
1725 | } else if (delta < 0) { | 1647 | } else if (delta < 0) { |
1726 | 1648 | ||
@@ -1745,45 +1667,38 @@ mpc_bool_t mpc_decoder_seek_sample(mpc_decoder *d, mpc_int64_t destsample) | |||
1745 | mpc_decoder_reset_state(d); | 1667 | mpc_decoder_reset_state(d); |
1746 | 1668 | ||
1747 | // jumps forward from the current position | 1669 | // jumps forward from the current position |
1748 | if (d->Use_SeekTable) { | 1670 | if (d->MaxDecodedFrames > lastFrame) { // REVIEW: Correct?? or (d->MaxDecodedFrames > d->DecodedFrames) |
1749 | 1671 | // jump to the last usable position in the seek table | |
1750 | if (d->MaxDecodedFrames > lastFrame) { // REVIEW: Correct?? or (d->MaxDecodedFrames > d->DecodedFrames) | ||
1751 | // jump to the last usable position in the seek table | ||
1752 | if (d->SeekTable_Step == 1) { | ||
1753 | fpos = mpc_decoder_bits_read(d); | ||
1754 | for (; d->DecodedFrames < d->MaxDecodedFrames && d->DecodedFrames < lastFrame; d->DecodedFrames++) | ||
1755 | fpos += d->SeekTable[d->DecodedFrames+1]; | ||
1756 | } else { | ||
1757 | // could test SeekTable offset and jump to next entry but this is easier for now... | ||
1758 | //d->SeekTableIndex = 0; | ||
1759 | //d->SeekTableCounter = 0; | ||
1760 | fpos = d->SeekTable[0]; | ||
1761 | d->SeekTableIndex = 0; | ||
1762 | for (d->DecodedFrames = 0;d->DecodedFrames < d->MaxDecodedFrames && d->DecodedFrames < lastFrame; d->DecodedFrames+=d->SeekTable_Step, d->SeekTableIndex++) | ||
1763 | fpos += d->SeekTable[d->SeekTableIndex+1]; | ||
1764 | d->SeekTableCounter = d->SeekTable[d->SeekTableIndex]; | ||
1765 | } | ||
1766 | |||
1767 | mpc_decoder_seek_to(d, fpos); | ||
1768 | } | ||
1769 | if (d->SeekTable_Step == 1) { | 1672 | if (d->SeekTable_Step == 1) { |
1770 | for (;d->DecodedFrames < lastFrame; d->DecodedFrames++) | 1673 | fpos = mpc_decoder_bits_read(d); |
1771 | d->SeekTable[d->DecodedFrames+1] = mpc_decoder_jump_frame(d); | 1674 | for (; d->DecodedFrames < d->MaxDecodedFrames && d->DecodedFrames < lastFrame; d->DecodedFrames++) |
1675 | fpos += d->SeekTable[d->DecodedFrames+1]; | ||
1772 | } else { | 1676 | } else { |
1773 | for (;d->DecodedFrames < lastFrame; d->DecodedFrames++) { | 1677 | // could test SeekTable offset and jump to next entry but this is easier for now... |
1774 | if (d->DecodedFrames % d->SeekTable_Step == 0) { | 1678 | //d->SeekTableIndex = 0; |
1775 | d->SeekTable[d->SeekTableIndex] = d->SeekTableCounter; | 1679 | //d->SeekTableCounter = 0; |
1776 | d->SeekTableIndex += 1; | 1680 | fpos = d->SeekTable[0]; |
1777 | d->SeekTableCounter = 0; | 1681 | d->SeekTableIndex = 0; |
1778 | } | 1682 | for (d->DecodedFrames = 0;d->DecodedFrames < d->MaxDecodedFrames && d->DecodedFrames < lastFrame; d->DecodedFrames+=d->SeekTable_Step, d->SeekTableIndex++) |
1779 | d->SeekTableCounter += mpc_decoder_jump_frame(d); | 1683 | fpos += d->SeekTable[d->SeekTableIndex+1]; |
1780 | } | 1684 | d->SeekTableCounter = d->SeekTable[d->SeekTableIndex]; |
1781 | } | 1685 | } |
1782 | } else { | 1686 | |
1687 | mpc_decoder_seek_to(d, fpos); | ||
1688 | } | ||
1689 | if (d->SeekTable_Step == 1) { | ||
1783 | for (;d->DecodedFrames < lastFrame; d->DecodedFrames++) | 1690 | for (;d->DecodedFrames < lastFrame; d->DecodedFrames++) |
1784 | mpc_decoder_jump_frame(d); | 1691 | d->SeekTable[d->DecodedFrames+1] = mpc_decoder_jump_frame(d); |
1692 | } else { | ||
1693 | for (;d->DecodedFrames < lastFrame; d->DecodedFrames++) { | ||
1694 | if (d->DecodedFrames % d->SeekTable_Step == 0) { | ||
1695 | d->SeekTable[d->SeekTableIndex] = d->SeekTableCounter; | ||
1696 | d->SeekTableIndex += 1; | ||
1697 | d->SeekTableCounter = 0; | ||
1698 | } | ||
1699 | d->SeekTableCounter += mpc_decoder_jump_frame(d); | ||
1700 | } | ||
1785 | } | 1701 | } |
1786 | |||
1787 | } | 1702 | } |
1788 | 1703 | ||
1789 | // REVIEW: Needed? | 1704 | // REVIEW: Needed? |
@@ -1798,7 +1713,7 @@ mpc_bool_t mpc_decoder_seek_sample(mpc_decoder *d, mpc_int64_t destsample) | |||
1798 | FrameBitCnt = mpc_decoder_bits_read(d); | 1713 | FrameBitCnt = mpc_decoder_bits_read(d); |
1799 | // scanning the scalefactors (and check for validity of frame) | 1714 | // scanning the scalefactors (and check for validity of frame) |
1800 | if (d->StreamVersion >= 7) { | 1715 | if (d->StreamVersion >= 7) { |
1801 | mpc_decoder_read_bitstream_sv7(d, d->Use_FastSeek && (d->DecodedFrames < seekFrame - 1)); | 1716 | mpc_decoder_read_bitstream_sv7(d, (d->DecodedFrames < seekFrame - 1)); |
1802 | } | 1717 | } |
1803 | else { | 1718 | else { |
1804 | #ifdef MPC_SUPPORT_SV456 | 1719 | #ifdef MPC_SUPPORT_SV456 |
@@ -1810,29 +1725,27 @@ mpc_bool_t mpc_decoder_seek_sample(mpc_decoder *d, mpc_int64_t destsample) | |||
1810 | 1725 | ||
1811 | FrameBitCnt = mpc_decoder_bits_read(d) - FrameBitCnt; | 1726 | FrameBitCnt = mpc_decoder_bits_read(d) - FrameBitCnt; |
1812 | 1727 | ||
1813 | if (d->Use_FastSeek && d->FwdJumpInfo > FrameBitCnt) | 1728 | if (d->FwdJumpInfo > FrameBitCnt) |
1814 | mpc_decoder_seek_forward(d, d->FwdJumpInfo - FrameBitCnt); | 1729 | mpc_decoder_seek_forward(d, d->FwdJumpInfo - FrameBitCnt); |
1815 | else if (FrameBitCnt != d->FwdJumpInfo ) | 1730 | else if (FrameBitCnt != d->FwdJumpInfo ) |
1816 | // Bug in perform_jump; | 1731 | // Bug in perform_jump; |
1817 | return FALSE; | 1732 | return FALSE; |
1818 | 1733 | ||
1819 | // REVIEW: Only if decodedFrames < maxDecodedFrames?? | 1734 | // REVIEW: Only if decodedFrames < maxDecodedFrames?? |
1820 | if (d->Use_SeekTable) { | 1735 | if (d->SeekTable_Step == 1) { |
1821 | if (d->SeekTable_Step == 1) { | 1736 | // check that the frame length corresponds with any data already in the seek table |
1822 | // check that the frame length corresponds with any data already in the seek table | 1737 | if (d->SeekTable[d->DecodedFrames+1] != 0 && d->SeekTable[d->DecodedFrames+1] != d->FwdJumpInfo + 20) |
1823 | if (d->SeekTable[d->DecodedFrames+1] != 0 && d->SeekTable[d->DecodedFrames+1] != d->FwdJumpInfo + 20) | 1738 | return FALSE; |
1739 | d->SeekTable [d->DecodedFrames+1] = d->FwdJumpInfo + 20; | ||
1740 | } else { | ||
1741 | if (d->DecodedFrames % d->SeekTable_Step == 0) { | ||
1742 | if (d->SeekTable[d->SeekTableIndex] != 0 && d->SeekTable[d->SeekTableIndex] != d->SeekTableCounter) | ||
1824 | return FALSE; | 1743 | return FALSE; |
1825 | d->SeekTable [d->DecodedFrames+1] = d->FwdJumpInfo + 20; | 1744 | d->SeekTable[d->SeekTableIndex] = d->SeekTableCounter; |
1826 | } else { | 1745 | d->SeekTableIndex += 1; |
1827 | if (d->DecodedFrames % d->SeekTable_Step == 0) { | 1746 | d->SeekTableCounter = 0; |
1828 | if (d->SeekTable[d->SeekTableIndex] != 0 && d->SeekTable[d->SeekTableIndex] != d->SeekTableCounter) | 1747 | } |
1829 | return FALSE; | 1748 | d->SeekTableCounter += d->FwdJumpInfo + 20; |
1830 | d->SeekTable[d->SeekTableIndex] = d->SeekTableCounter; | ||
1831 | d->SeekTableIndex += 1; | ||
1832 | d->SeekTableCounter = 0; | ||
1833 | } | ||
1834 | d->SeekTableCounter += d->FwdJumpInfo + 20; | ||
1835 | } | ||
1836 | } | 1749 | } |
1837 | 1750 | ||
1838 | // update buffer | 1751 | // update buffer |
@@ -1906,7 +1819,6 @@ void mpc_decoder_seek_to(mpc_decoder *d, mpc_uint32_t bitPos) { | |||
1906 | 1819 | ||
1907 | } | 1820 | } |
1908 | 1821 | ||
1909 | |||
1910 | void mpc_decoder_seek_forward(mpc_decoder *d, mpc_uint32_t bits) { | 1822 | void mpc_decoder_seek_forward(mpc_decoder *d, mpc_uint32_t bits) { |
1911 | 1823 | ||
1912 | bits += d->pos; | 1824 | bits += d->pos; |
@@ -1919,11 +1831,3 @@ void mpc_decoder_seek_forward(mpc_decoder *d, mpc_uint32_t bits) { | |||
1919 | 1831 | ||
1920 | } | 1832 | } |
1921 | 1833 | ||
1922 | |||
1923 | void mpc_decoder_set_seek_table(mpc_decoder *d, mpc_uint32_t *seek_table, mpc_uint32_t max_table_size) { | ||
1924 | |||
1925 | d->Use_StaticSeekTable = TRUE; | ||
1926 | d->SeekTable = seek_table; | ||
1927 | d->Max_SeekTable_Size = max_table_size; | ||
1928 | |||
1929 | } | ||
diff --git a/apps/codecs/libmusepack/musepack.h b/apps/codecs/libmusepack/musepack.h index 7e65c75c5a..8233f21f91 100644 --- a/apps/codecs/libmusepack/musepack.h +++ b/apps/codecs/libmusepack/musepack.h | |||
@@ -103,8 +103,6 @@ void mpc_decoder_setup(mpc_decoder *d, mpc_reader *r); | |||
103 | /// \return TRUE if decoder was initalized successfully, FALSE otherwise | 103 | /// \return TRUE if decoder was initalized successfully, FALSE otherwise |
104 | mpc_bool_t mpc_decoder_initialize(mpc_decoder *d, mpc_streaminfo *si); | 104 | mpc_bool_t mpc_decoder_initialize(mpc_decoder *d, mpc_streaminfo *si); |
105 | 105 | ||
106 | void mpc_decoder_set_streaminfo(mpc_decoder *d, mpc_streaminfo *si); | ||
107 | |||
108 | /// Sets decoder sample scaling factor. All decoded samples will be multiplied | 106 | /// Sets decoder sample scaling factor. All decoded samples will be multiplied |
109 | /// by this factor. | 107 | /// by this factor. |
110 | /// \param scale_factor multiplicative scaling factor | 108 | /// \param scale_factor multiplicative scaling factor |
@@ -136,10 +134,7 @@ mpc_bool_t mpc_decoder_seek_sample(mpc_decoder *d, mpc_int64_t destsample); | |||
136 | /// Seeks to specified position in seconds in the source stream. | 134 | /// Seeks to specified position in seconds in the source stream. |
137 | mpc_bool_t mpc_decoder_seek_seconds(mpc_decoder *d, double seconds); | 135 | mpc_bool_t mpc_decoder_seek_seconds(mpc_decoder *d, double seconds); |
138 | 136 | ||
139 | /// Sets the static seek table pointer. | 137 | /// Cleans up the decoder (seektable) |
140 | void mpc_decoder_set_seek_table(mpc_decoder *d, mpc_uint32_t *seek_table, mpc_uint32_t max_table_size); | ||
141 | |||
142 | /// Cleans up the decoder | ||
143 | void mpc_decoder_destroy(mpc_decoder *d); | 138 | void mpc_decoder_destroy(mpc_decoder *d); |
144 | 139 | ||
145 | #ifdef __cplusplus | 140 | #ifdef __cplusplus |
diff --git a/apps/codecs/libmusepack/requant.c b/apps/codecs/libmusepack/requant.c index 3282286d74..d40f36fded 100644 --- a/apps/codecs/libmusepack/requant.c +++ b/apps/codecs/libmusepack/requant.c | |||
@@ -69,6 +69,33 @@ const mpc_int32_t __Dc [1 + 18] ICONST_ATTR = { | |||
69 | 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767 | 69 | 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767 |
70 | }; | 70 | }; |
71 | 71 | ||
72 | // decoding results (requantized) for bundled quantizers (3- and 5-step) | ||
73 | // 1st value of bundled 3-step quantizer | ||
74 | const mpc_int32_t idx30[27] ICONST_ATTR = { -1, 0, 1,-1, 0, 1,-1, 0, 1, | ||
75 | -1, 0, 1,-1, 0, 1,-1, 0, 1, | ||
76 | -1, 0, 1,-1, 0, 1,-1, 0, 1}; | ||
77 | // 2nd value of bundled 3-step quantizer | ||
78 | const mpc_int32_t idx31[27] ICONST_ATTR = { -1,-1,-1, 0, 0, 0, 1, 1, 1, | ||
79 | -1,-1,-1, 0, 0, 0, 1, 1, 1, | ||
80 | -1,-1,-1, 0, 0, 0, 1, 1, 1}; | ||
81 | // 3rd value of bundled 3-step quantizer | ||
82 | const mpc_int32_t idx32[27] ICONST_ATTR = { -1,-1,-1,-1,-1,-1,-1,-1,-1, | ||
83 | 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
84 | 1, 1, 1, 1, 1, 1, 1, 1, 1}; | ||
85 | // 1st value of bundled 5-step quantizer | ||
86 | const mpc_int32_t idx50[25] ICONST_ATTR = { -2,-1, 0, 1, 2, | ||
87 | -2,-1, 0, 1, 2, | ||
88 | -2,-1, 0, 1, 2, | ||
89 | -2,-1, 0, 1, 2, | ||
90 | -2,-1, 0, 1, 2}; | ||
91 | // 2nd value of bundled 5-step quantizer | ||
92 | const mpc_int32_t idx51[25] ICONST_ATTR = { -2,-2,-2,-2,-2, | ||
93 | -1,-1,-1,-1,-1, | ||
94 | 0, 0, 0, 0, 0, | ||
95 | 1, 1, 1, 1, 1, | ||
96 | 2, 2, 2, 2, 2}; | ||
97 | |||
98 | |||
72 | #ifdef MPC_FIXED_POINT | 99 | #ifdef MPC_FIXED_POINT |
73 | static mpc_uint32_t find_shift(double fval) | 100 | static mpc_uint32_t find_shift(double fval) |
74 | { | 101 | { |
diff --git a/apps/codecs/libmusepack/requant.h b/apps/codecs/libmusepack/requant.h index e70dce7085..1a21c21143 100644 --- a/apps/codecs/libmusepack/requant.h +++ b/apps/codecs/libmusepack/requant.h | |||
@@ -41,9 +41,15 @@ | |||
41 | #include "musepack.h" | 41 | #include "musepack.h" |
42 | 42 | ||
43 | /* C O N S T A N T S */ | 43 | /* C O N S T A N T S */ |
44 | extern const mpc_uint32_t Res_bit [18]; // bits per sample for chosen quantizer | 44 | extern const mpc_uint32_t Res_bit[18]; // bits per sample for chosen quantizer |
45 | extern const MPC_SAMPLE_FORMAT __Cc [1 + 18]; // coefficients for requantization | 45 | extern const MPC_SAMPLE_FORMAT __Cc[1 + 18]; // coefficients for requantization |
46 | extern const mpc_int32_t __Dc [1 + 18]; // offset for requantization | 46 | extern const mpc_int32_t __Dc[1 + 18]; // offset for requantization |
47 | extern const mpc_int32_t idx30[27]; // 1st value of bundled 3-step quantizer | ||
48 | extern const mpc_int32_t idx31[27]; // 2nd value of bundled 3-step quantizer | ||
49 | extern const mpc_int32_t idx32[27]; // 3rd value of bundled 3-step quantizer | ||
50 | extern const mpc_int32_t idx50[25]; // 1st value of bundled 5-step quantizer | ||
51 | extern const mpc_int32_t idx51[25]; // 2nd value of bundled 5-step quantizer | ||
52 | |||
47 | 53 | ||
48 | #define Cc (__Cc + 1) | 54 | #define Cc (__Cc + 1) |
49 | #define Dc (__Dc + 1) | 55 | #define Dc (__Dc + 1) |
diff --git a/apps/codecs/mpc.c b/apps/codecs/mpc.c index c74c10ee64..c734915f68 100644 --- a/apps/codecs/mpc.c +++ b/apps/codecs/mpc.c | |||
@@ -65,7 +65,6 @@ mpc_bool_t canseek_impl(void *data) | |||
65 | 65 | ||
66 | MPC_SAMPLE_FORMAT sample_buffer[MPC_DECODER_BUFFER_LENGTH] | 66 | MPC_SAMPLE_FORMAT sample_buffer[MPC_DECODER_BUFFER_LENGTH] |
67 | IBSS_ATTR_MPC_SAMPLE_BUF; | 67 | IBSS_ATTR_MPC_SAMPLE_BUF; |
68 | mpc_uint32_t seek_table[10000]; | ||
69 | 68 | ||
70 | /* this is the codec entry point */ | 69 | /* this is the codec entry point */ |
71 | enum codec_status codec_main(void) | 70 | enum codec_status codec_main(void) |
@@ -87,11 +86,6 @@ enum codec_status codec_main(void) | |||
87 | reader.canseek = canseek_impl; | 86 | reader.canseek = canseek_impl; |
88 | reader.data = ci; | 87 | reader.data = ci; |
89 | 88 | ||
90 | /* Ensure that SeekTable is clear since decoder is reused */ | ||
91 | decoder.SeekTable = NULL; | ||
92 | |||
93 | mpc_decoder_set_seek_table(&decoder, seek_table, sizeof(seek_table)); | ||
94 | |||
95 | next_track: | 89 | next_track: |
96 | if (codec_init()) { | 90 | if (codec_init()) { |
97 | retval = CODEC_ERROR; | 91 | retval = CODEC_ERROR; |