1
0

mkv_mp3_decoder.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #pragma once
  2. #include "../Plugins/Input/in_mkv/svc_mkvdecoder.h"
  3. #include "../Plugins/Input/in_mkv/ifc_mkvaudiodecoder.h"
  4. #include <mpg123.h>
  5. // {A08A5A0C-DEF7-4604-9F35-D5A5E9B1F4DF}
  6. static const GUID mkv_mp3_guid =
  7. { 0xa08a5a0c, 0xdef7, 0x4604, { 0x9f, 0x35, 0xd5, 0xa5, 0xe9, 0xb1, 0xf4, 0xdf } };
  8. class MKVDecoder : public svc_mkvdecoder
  9. {
  10. public:
  11. static const char *getServiceName() { return "MP3 MKV Decoder"; }
  12. static GUID getServiceGuid() { return mkv_mp3_guid; }
  13. int CreateAudioDecoder(const char *codec_id, const nsmkv::TrackEntryData *track_entry_data, const nsmkv::AudioData *audio_data, unsigned int preferred_bits, unsigned int preferred_channels, bool floating_point, ifc_mkvaudiodecoder **decoder);
  14. protected:
  15. RECVS_DISPATCH;
  16. };
  17. class MKVMP3Decoder : public ifc_mkvaudiodecoder
  18. {
  19. public:
  20. MKVMP3Decoder(mpg123_handle *mp3, unsigned int bps, unsigned max_channels, bool floating_point);
  21. ~MKVMP3Decoder();
  22. protected:
  23. RECVS_DISPATCH;
  24. private:
  25. /* ifc_mkvaudiodecoder implementation */
  26. int OutputFrameSize(size_t *frame_size);
  27. int GetOutputProperties(unsigned int *sampleRate, unsigned int *channels, unsigned int *bitsPerSample, bool *isFloat);
  28. int DecodeBlock(void *inputBuffer, size_t inputBufferBytes, void *outputBuffer, size_t *outputBufferBytes);
  29. void Flush();
  30. void Close();
  31. private:
  32. mpg123_handle *mp3;
  33. unsigned int bits;
  34. int pregap;
  35. unsigned int max_channels;
  36. unsigned int channels;
  37. unsigned int sample_rate;
  38. bool floating_point;
  39. bool _UpdateProperties();
  40. float *decode_buffer;
  41. size_t decode_buffer_length;
  42. };