decoder.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Direct Stream Transfer (DST) codec
  3. * ISO/IEC 14496-3 Part 3 Subpart 10: Technical description of lossless coding of oversampled audio
  4. */
  5. #ifndef DECODER_H
  6. #define DECODER_H
  7. #include <stdint.h>
  8. #include <array>
  9. #include <vector>
  10. #include "segment.h"
  11. #include "ct.h"
  12. #include "fh.h"
  13. #include "ac.h"
  14. #include "fr.h"
  15. #include "stream.h"
  16. using std::array;
  17. using std::vector;
  18. namespace dst
  19. {
  20. class decoder_t {
  21. static int GC_ICoefSign[256];
  22. static unsigned int GC_ICoefIndex[256];
  23. static bool GC_ICoefInit;
  24. public:
  25. fr_t m_fr; // Contains frame based header information
  26. ft_t m_ft; // Contains FIR-coef. compression data
  27. pt_t m_pt; // Contains Ptable-entry compression data
  28. vector<array<unsigned int, AC_HISMAX>> P_one; // Probability table for arithmetic coder
  29. vector<uint8_t> AData; // Contains the arithmetic coded bit stream of a complete frame vector<uint8_t> AData; // Contains the arithmetic coded bit stream of a complete frame
  30. int ADataLen; // Number of code bits contained in AData[]
  31. vector<array<array<int16_t, 256>, 16>> LT_ICoefI;
  32. vector<array<uint8_t, 16>> LT_Status;
  33. public:
  34. decoder_t();
  35. ~decoder_t();
  36. int init(unsigned int channels, unsigned int channel_frame_size);
  37. int close();
  38. int decode(const uint8_t* dst_data, unsigned int dst_bits, uint8_t* dsd_data);
  39. private:
  40. int unpack(const uint8_t* dst_data, uint8_t* dsd_data);
  41. int16_t reverse7LSBs(int16_t c);
  42. void fillTable4Bit(segment_t& S, vector<vector<uint8_t>>& Table4Bit);
  43. void LT_InitCoefTables(vector<array<array<int16_t, 256>, 16>>& ICoefI);
  44. void GC_InitCoefTables(vector<array<array<int16_t, 256>, 16>>& ICoefI);
  45. void LT_InitStatus(vector<array<uint8_t, 16>>& Status);
  46. int16_t LT_RunFilter(array<array<int16_t, 256>, 16>& FilterTable, array<uint8_t, 16>& ChannelStatus);
  47. };
  48. }
  49. #endif