RawStructs.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. #if !defined(RawStructs_h_)
  5. #define RawStructs_h_
  6. static const uint32_t RAW_ID = 0x595556;
  7. struct nsRawVideo_PRUint24 {
  8. operator uint32_t() const { return value[2] << 16 | value[1] << 8 | value[0]; }
  9. nsRawVideo_PRUint24& operator= (const uint32_t& rhs)
  10. { value[2] = (rhs & 0x00FF0000) >> 16;
  11. value[1] = (rhs & 0x0000FF00) >> 8;
  12. value[0] = (rhs & 0x000000FF);
  13. return *this; }
  14. private:
  15. uint8_t value[3];
  16. };
  17. struct RawPacketHeader {
  18. typedef nsRawVideo_PRUint24 PRUint24;
  19. uint8_t packetID;
  20. PRUint24 codecID;
  21. };
  22. // This is Arc's draft from wiki.xiph.org/OggYUV
  23. struct RawVideoHeader {
  24. typedef nsRawVideo_PRUint24 PRUint24;
  25. uint8_t headerPacketID; // Header Packet ID (always 0)
  26. PRUint24 codecID; // Codec identifier (always "YUV")
  27. uint8_t majorVersion; // Version Major (breaks backwards compat)
  28. uint8_t minorVersion; // Version Minor (preserves backwards compat)
  29. uint16_t options; // Bit 1: Color (false = B/W)
  30. // Bits 2-4: Chroma Pixel Shape
  31. // Bit 5: 50% horizontal offset for Cr samples
  32. // Bit 6: 50% vertical ...
  33. // Bits 7-8: Chroma Blending
  34. // Bit 9: Packed (false = Planar)
  35. // Bit 10: Cr Staggered Horizontally
  36. // Bit 11: Cr Staggered Vertically
  37. // Bit 12: Unused (format is always little endian)
  38. // Bit 13: Interlaced (false = Progressive)
  39. // Bits 14-16: Interlace options (undefined)
  40. uint8_t alphaChannelBpp;
  41. uint8_t lumaChannelBpp;
  42. uint8_t chromaChannelBpp;
  43. uint8_t colorspace;
  44. PRUint24 frameWidth;
  45. PRUint24 frameHeight;
  46. PRUint24 aspectNumerator;
  47. PRUint24 aspectDenominator;
  48. uint32_t framerateNumerator;
  49. uint32_t framerateDenominator;
  50. };
  51. #endif // RawStructs_h_