1 // Copyright (C) 2020 The Android Open Source Project 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 // A parser for VpxFrame 16 // the specified data. 17 18 #pragma once 19 20 #include <cstdint> 21 #include <string> 22 23 namespace android { 24 namespace emulation { 25 26 class VpxFrameParser { 27 public: 28 VpxFrameParser(int vpxtype, const uint8_t* data, size_t size); 29 ~VpxFrameParser() = default; 30 31 public: isKeyFrame()32 bool isKeyFrame() const { return m_is_key_frame; } 33 34 private: 35 int type = 0; // 8: vp8, 9: vp9 36 const uint8_t* bit_buffer = nullptr; 37 const uint8_t* bit_buffer_end = nullptr; 38 size_t bit_offset = 0; 39 40 bool m_is_key_frame = false; 41 42 private: 43 static constexpr int KEY_FRAME = 0; 44 static constexpr int INTER_FRAME = 1; 45 46 int read_bit(); 47 int read_literal(int bits); 48 49 void parse_vp9_uncompressed_header(); 50 void parse_vp8_uncompressed_header(); 51 }; 52 53 } // namespace emulation 54 } // namespace android 55