avi_mp3_decoder.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #pragma once
  2. #include "../Plugins/Input/in_avi/svc_avidecoder.h"
  3. #include "../Plugins/Input/in_avi/ifc_aviaudiodecoder.h"
  4. #include <mpg123.h>
  5. // {11D89BF5-014E-463a-B284-385FF0662FCC}
  6. static const GUID avi_mp3_guid =
  7. { 0x11d89bf5, 0x14e, 0x463a, { 0xb2, 0x84, 0x38, 0x5f, 0xf0, 0x66, 0x2f, 0xcc } };
  8. class AVIDecoder : public svc_avidecoder
  9. {
  10. public:
  11. static const char *getServiceName() { return "MP3 AVI Decoder"; }
  12. static GUID getServiceGuid() { return avi_mp3_guid; }
  13. int CreateAudioDecoder(const nsavi::AVIH *avi_header, const nsavi::STRH *stream_header, const nsavi::STRF *stream_format, const nsavi::STRD *stream_data, unsigned int preferred_bits, unsigned int max_channels, bool floating_point, ifc_aviaudiodecoder **decoder);
  14. protected:
  15. RECVS_DISPATCH;
  16. };
  17. class AVIMP3Decoder : public ifc_aviaudiodecoder
  18. {
  19. public:
  20. AVIMP3Decoder(mpg123_handle *mp3, unsigned int bps, unsigned max_channels, bool floating_point);
  21. ~AVIMP3Decoder();
  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 DecodeChunk(uint16_t type, 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. bool floating_point;
  37. unsigned int channels;
  38. float *decode_buffer;
  39. size_t decode_buffer_length;
  40. };