1 // Copyright 2016 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 // Note: ported from Chromium commit head: e5a9a62 5 6 #ifndef VP9_COMPRESSED_HEADER_PARSER_H_ 7 #define VP9_COMPRESSED_HEADER_PARSER_H_ 8 9 #include "vp9_bool_decoder.h" 10 #include "vp9_parser.h" 11 12 namespace media { 13 14 class Vp9CompressedHeaderParser { 15 public: 16 Vp9CompressedHeaderParser(); 17 18 // Parses VP9 compressed header in |stream| with |frame_size| into |fhdr|. 19 // Returns true if no error. 20 bool Parse(const uint8_t* stream, off_t frame_size, Vp9FrameHeader* fhdr); 21 22 private: 23 void ReadTxMode(Vp9FrameHeader* fhdr); 24 uint8_t DecodeTermSubexp(); 25 void DiffUpdateProb(Vp9Prob* prob); 26 template <int N> 27 void DiffUpdateProbArray(Vp9Prob (&prob_array)[N]); 28 void ReadTxModeProbs(Vp9FrameContext* frame_context); 29 void ReadCoefProbs(Vp9FrameHeader* fhdr); 30 void ReadSkipProb(Vp9FrameContext* frame_context); 31 void ReadInterModeProbs(Vp9FrameContext* frame_context); 32 void ReadInterpFilterProbs(Vp9FrameContext* frame_context); 33 void ReadIsInterProbs(Vp9FrameContext* frame_context); 34 void ReadFrameReferenceMode(Vp9FrameHeader* fhdr); 35 void ReadFrameReferenceModeProbs(Vp9FrameHeader* fhdr); 36 void ReadYModeProbs(Vp9FrameContext* frame_context); 37 void ReadPartitionProbs(Vp9FrameContext* frame_context); 38 void ReadMvProbs(bool allow_high_precision_mv, 39 Vp9FrameContext* frame_context); 40 void UpdateMvProb(Vp9Prob* prob); 41 template <int N> 42 void UpdateMvProbArray(Vp9Prob (&prob_array)[N]); 43 44 // Bool decoder for compressed frame header. 45 Vp9BoolDecoder reader_; 46 47 DISALLOW_COPY_AND_ASSIGN(Vp9CompressedHeaderParser); 48 }; 49 50 } // namespace media 51 52 #endif // VP9_COMPRESSED_HEADER_PARSER_H_ 53