VPXDecoder.hpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. MIT License
  3. Copyright (c) 2016 Błażej Szczygieł
  4. Permission is hereby granted, free of charge, to any person obtaining a copy
  5. of this software and associated documentation files (the "Software"), to deal
  6. in the Software without restriction, including without limitation the rights
  7. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. copies of the Software, and to permit persons to whom the Software is
  9. furnished to do so, subject to the following conditions:
  10. The above copyright notice and this permission notice shall be included in all
  11. copies or substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  18. SOFTWARE.
  19. */
  20. #ifndef VPXDECODER_HPP
  21. #define VPXDECODER_HPP
  22. #include "WebMDemuxer.hpp"
  23. struct vpx_codec_ctx;
  24. class VPXDecoder
  25. {
  26. VPXDecoder(const VPXDecoder &);
  27. void operator =(const VPXDecoder &);
  28. public:
  29. class Image
  30. {
  31. public:
  32. #if 0
  33. int getWidth(int plane) const;
  34. int getHeight(int plane) const;
  35. #endif
  36. int w, h;
  37. int chromaShiftW, chromaShiftH;
  38. unsigned char *planes[3];
  39. int linesize[3];
  40. };
  41. enum IMAGE_ERROR
  42. {
  43. UNSUPPORTED_FRAME = -1,
  44. NO_ERROR,
  45. NO_FRAME
  46. };
  47. VPXDecoder(const WebMDemuxer &demuxer, unsigned threads = 1);
  48. ~VPXDecoder();
  49. inline bool isOpen() const
  50. {
  51. return (bool)m_ctx;
  52. }
  53. inline int getFramesDelay() const
  54. {
  55. return m_delay;
  56. }
  57. bool decode(const WebMFrame &frame);
  58. IMAGE_ERROR getImage(Image &image); //The data is NOT copied! Only 3-plane, 8-bit images are supported.
  59. private:
  60. vpx_codec_ctx *m_ctx;
  61. const void *m_iter;
  62. int m_delay;
  63. };
  64. #endif // VPXDECODER_HPP