2022-08-26 15:44:59 +00:00
|
|
|
// Copyright 2015 Google LLC. All rights reserved.
|
2015-11-11 21:54:45 +00:00
|
|
|
//
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file or at
|
|
|
|
// https://developers.google.com/open-source/licenses/bsd
|
|
|
|
|
2017-12-20 00:56:36 +00:00
|
|
|
#ifndef PACKAGER_MEDIA_CODECS_VP9_PARSER_H_
|
|
|
|
#define PACKAGER_MEDIA_CODECS_VP9_PARSER_H_
|
2015-11-11 21:54:45 +00:00
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2023-10-10 23:51:11 +00:00
|
|
|
#include <packager/macros.h>
|
|
|
|
#include <packager/media/codecs/vpx_parser.h>
|
2015-11-11 21:54:45 +00:00
|
|
|
|
2016-05-20 21:19:33 +00:00
|
|
|
namespace shaka {
|
2015-11-11 21:54:45 +00:00
|
|
|
namespace media {
|
|
|
|
|
|
|
|
/// Class to parse a vp9 bit stream.
|
2015-11-20 19:28:45 +00:00
|
|
|
class VP9Parser : public VPxParser {
|
2015-11-11 21:54:45 +00:00
|
|
|
public:
|
|
|
|
VP9Parser();
|
2015-11-20 19:28:45 +00:00
|
|
|
~VP9Parser() override;
|
2015-11-11 21:54:45 +00:00
|
|
|
|
|
|
|
/// Parse @a data with size @a data_size.
|
|
|
|
/// @param data_size Size of the sample in bytes. Note that it should be a
|
|
|
|
/// full sample.
|
|
|
|
/// @param[out] vpx_frames points to the list of VPx frames for the current
|
|
|
|
/// sample on success. Cannot be NULL.
|
|
|
|
/// @return true on success, false otherwise.
|
|
|
|
bool Parse(const uint8_t* data,
|
|
|
|
size_t data_size,
|
2015-11-20 19:28:45 +00:00
|
|
|
std::vector<VPxFrameInfo>* vpx_frames) override;
|
2015-11-11 21:54:45 +00:00
|
|
|
|
2015-11-18 19:51:15 +00:00
|
|
|
/// A convenient utility function to check whether the frame is a keyframe.
|
|
|
|
/// Note that this function does not do a full parse of the frame header, so
|
|
|
|
/// should be more efficient than Parse().
|
|
|
|
/// @param data_size Size of the sample in bytes.
|
|
|
|
/// @return true if it is, false if it is not or if there is parsing error.
|
|
|
|
static bool IsKeyframe(const uint8_t* data, size_t data_size);
|
|
|
|
|
2015-11-11 21:54:45 +00:00
|
|
|
private:
|
|
|
|
// Keep track of the current width and height. Note that they may change from
|
|
|
|
// frame to frame.
|
|
|
|
uint32_t width_;
|
|
|
|
uint32_t height_;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(VP9Parser);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace media
|
2016-05-20 21:19:33 +00:00
|
|
|
} // namespace shaka
|
2015-11-11 21:54:45 +00:00
|
|
|
|
2017-12-20 00:56:36 +00:00
|
|
|
#endif // PACKAGER_MEDIA_CODECS_VP9_PARSER_H_
|