nalu_test_helper.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright 2019 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_NALU_TEST_HELPER_H_
  5. #define MEDIA_FORMATS_MP4_NALU_TEST_HELPER_H_
  6. #include <string>
  7. #include <vector>
  8. #include "media/base/subsample_entry.h"
  9. #include "media/formats/mp4/bitstream_converter.h"
  10. #include "media/media_buildflags.h"
  11. namespace media {
  12. namespace mp4 {
  13. // Input string should be one or more NALU types separated with spaces or
  14. // commas. NALU grouped together and separated by commas are placed into the
  15. // same subsample, NALU groups separated by spaces are placed into separate
  16. // subsamples.
  17. // For example: in AVC, input string "SPS PPS I" produces Annex B buffer
  18. // containing SPS, PPS and I NALUs, each in a separate subsample. While input
  19. // string "SPS,PPS I" produces Annex B buffer where the first subsample contains
  20. // SPS and PPS NALUs and the second subsample contains the I-slice NALU.
  21. // The output buffer will contain a valid-looking Annex B (it's valid-looking in
  22. // the sense that it has start codes and correct NALU types, but the actual NALU
  23. // payload is junk).
  24. void AvcStringToAnnexB(const std::string& str,
  25. std::vector<uint8_t>* buffer,
  26. std::vector<SubsampleEntry>* subsamples);
  27. #if BUILDFLAG(ENABLE_PLATFORM_HEVC)
  28. void HevcStringToAnnexB(const std::string& str,
  29. std::vector<uint8_t>* buffer,
  30. std::vector<SubsampleEntry>* subsamples);
  31. #endif // BUILDFLAG(ENABLE_PLATFORM_HEVC)
  32. // Helper to compare two results of AVC::Analyze().
  33. bool AnalysesMatch(const BitstreamConverter::AnalysisResult& r1,
  34. const BitstreamConverter::AnalysisResult& r2);
  35. } // namespace mp4
  36. } // namespace media
  37. #endif // MEDIA_FORMATS_MP4_NALU_TEST_HELPER_H_