webp_parser.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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_PARSERS_WEBP_PARSER_H_
  5. #define MEDIA_PARSERS_WEBP_PARSER_H_
  6. #include <stdint.h>
  7. #include <memory>
  8. #include "base/containers/span.h"
  9. #include "media/parsers/media_parsers_export.h"
  10. namespace media {
  11. struct Vp8FrameHeader;
  12. // A lightweight WebP file header parser to extract feature and size
  13. // information. It validates that a given data stream encodes a simple lossy
  14. // WebP image and populates a Vp8FrameHeader upon successful parsing.
  15. // For more information, see the WebP Container Specification:
  16. // https://developers.google.com/speed/webp/docs/riff_container
  17. // Returns true if |encoded_data| claims to encode a simple (non-extended) lossy
  18. // WebP image. Returns false otherwise.
  19. MEDIA_PARSERS_EXPORT
  20. bool IsLossyWebPImage(base::span<const uint8_t> encoded_data);
  21. // Parses a simple (non-extended) lossy WebP image and returns a Vp8FrameHeader
  22. // containing the parsed VP8 frame contained by the image. Returns nullptr on
  23. // failure.
  24. MEDIA_PARSERS_EXPORT
  25. std::unique_ptr<Vp8FrameHeader> ParseWebPImage(
  26. base::span<const uint8_t> encoded_data);
  27. } // namespace media
  28. #endif // MEDIA_PARSERS_WEBP_PARSER_H_