h264_annex_b_to_avc_bitstream_converter_fuzztest.cc 824 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright 2020 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. #include <stdint.h>
  5. #include <memory>
  6. #include "media/formats/mp4/h264_annex_b_to_avc_bitstream_converter.h"
  7. // Entry point for LibFuzzer.
  8. extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
  9. if (!size)
  10. return 0;
  11. std::vector<uint8_t> output(size);
  12. size_t size_out;
  13. bool config_changed;
  14. media::H264AnnexBToAvcBitstreamConverter converter;
  15. base::span<const uint8_t> input(data, data + size);
  16. auto status =
  17. converter.ConvertChunk(input, output, &config_changed, &size_out);
  18. auto& config = converter.GetCurrentConfig();
  19. std::vector<uint8_t> avc_config(size);
  20. config.Serialize(avc_config);
  21. return 0;
  22. }