dtsx.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. // Copyright 2021 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef MEDIA_FORMATS_MP4_DTSX_H_
  5. #define MEDIA_FORMATS_MP4_DTSX_H_
  6. #include <stdint.h>
  7. #include <vector>
  8. #include "media/base/media_export.h"
  9. #include "media/base/media_log.h"
  10. namespace media {
  11. namespace mp4 {
  12. enum class DtsxChannelMask : uint32_t {
  13. C = 0x00000001,
  14. L = 0x00000002,
  15. R = 0x00000004,
  16. LS = 0x00000008,
  17. RS = 0x00000010,
  18. LFE1 = 0x00000020,
  19. CS = 0x00000040,
  20. LSR = 0x00000080,
  21. RSR = 0x00000100,
  22. LSS = 0x00000200,
  23. RSS = 0x00000400,
  24. LC = 0x00000800,
  25. RC = 0x00001000,
  26. LH = 0x00002000,
  27. CH = 0x00004000,
  28. RH = 0x00008000,
  29. LFE2 = 0x00010000,
  30. LW = 0x00020000,
  31. RW = 0x00040000,
  32. OH = 0x00080000,
  33. LHS = 0x00100000,
  34. RHS = 0x00200000,
  35. CHR = 0x00400000,
  36. LHR = 0x00800000,
  37. RHR = 0x01000000,
  38. CB = 0x02000000,
  39. LB = 0x04000000,
  40. RB = 0x08000000,
  41. LTF = 0x10000000,
  42. RTF = 0x20000000,
  43. LTR = 0x40000000,
  44. RTR = 0x80000000
  45. };
  46. // This class parses the DTSX information from decoder specific information
  47. // embedded in the udts box in an ISO BMFF file.
  48. // Please refer to SCTE DVS 243-4 Part 4 Table 12 - DTS-UHD Specific Box for
  49. // more details.
  50. class MEDIA_EXPORT DTSX {
  51. public:
  52. DTSX();
  53. DTSX(const DTSX& other);
  54. ~DTSX();
  55. // Parse the DTSX config from the udts box.
  56. bool Parse(const std::vector<uint8_t>& data, MediaLog* media_log);
  57. uint8_t GetDecoderProfileCode() const;
  58. int GetFrameDuration() const;
  59. int GetMaxPayload() const;
  60. int GetNumPresentations() const;
  61. uint32_t GetChannelMask() const;
  62. int GetSamplingFrequency() const;
  63. private:
  64. // Logs the parameters of a DTSX stream to DVLOG level 3.
  65. void LogDtsxParameters();
  66. // Indicates the DTS-UHD decoder profile required to decode this stream
  67. uint8_t decoder_profile_code_ = 0;
  68. // Frame duration in samples.
  69. // Relative to BaseSamplingFrequency.
  70. int frame_duration_ = 0;
  71. // Indicates the maximum size of the audio payload.
  72. // Maxpayload is not the size of the largest audio frame in the presentation,
  73. // but rather a "not to exceed" value for buffer configuration and digital
  74. // audio interface purposes, and is inclusive of all required preambles,
  75. // headers, burst spacing, etc.
  76. int max_payload_ = 0;
  77. // The num of audio presentations encoded within DTS-UHD elementary stream.
  78. int num_presentations_ = 0;
  79. // A bit mask that indicates the channel layout encoded in the default
  80. // resentation
  81. // of the DTS-UHD bitstream.
  82. uint32_t channel_mask_ = 0;
  83. // The sampling frequency of the audio samples stored in the bitstream.
  84. // Calucalated by multiplying the BaseSamplingFrequency by SampleRateMod.
  85. int sampling_frequency_ = 0;
  86. };
  87. } // namespace mp4
  88. } // namespace media
  89. #endif // MEDIA_FORMATS_MP4_DTSX_H_