| // Copyright 2016 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #include "base/numerics/safe_conversions.h" |
| #include "cobalt/media/filters/ivf_parser.h" |
| #include "cobalt/media/filters/vp9_parser.h" |
| #include "starboard/types.h" |
| |
| // Entry point for LibFuzzer. |
| extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { |
| const uint8_t* ivf_payload = NULL; |
| media::IvfParser ivf_parser; |
| media::IvfFileHeader ivf_file_header; |
| media::IvfFrameHeader ivf_frame_header; |
| |
| if (!ivf_parser.Initialize(data, size, &ivf_file_header)) return 0; |
| |
| // Parse until the end of stream/unsupported stream/error in stream is found. |
| while (ivf_parser.ParseNextFrame(&ivf_frame_header, &ivf_payload)) { |
| // TODO(kcwu): fuzzing with parsing_compressed_header=true. |
| media::Vp9Parser vp9_parser(false); |
| media::Vp9FrameHeader vp9_frame_header; |
| vp9_parser.SetStream(ivf_payload, ivf_frame_header.frame_size); |
| while (vp9_parser.ParseNextFrame(&vp9_frame_header) == |
| media::Vp9Parser::kOk) { |
| // Repeat until all frames processed. |
| } |
| } |
| |
| return 0; |
| } |