Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 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. | |
|
Ville-Mikko Rautio
2015/08/02 23:43:49
It would be easier to understand this file, if the
kcwu
2015/08/03 10:05:52
Done.
| |
| 4 | |
| 5 #ifndef MEDIA_FILTERS_VP9_PARSER_H_ | |
| 6 #define MEDIA_FILTERS_VP9_PARSER_H_ | |
| 7 | |
| 8 #include <stddef.h> | |
| 9 #include <stdint.h> | |
| 10 | |
| 11 #include "base/macros.h" | |
| 12 #include "media/base/media_export.h" | |
| 13 #include "media/filters/vp9_raw_bits_reader.h" | |
| 14 #include "ui/gfx/geometry/size.h" | |
| 15 | |
| 16 namespace media { | |
| 17 | |
| 18 const int kVp9MaxProfile = 4; | |
| 19 const int kVp9NumRefFramesLog2 = 3; | |
| 20 const int kVp9NumRefFrames = 1 << kVp9NumRefFramesLog2; | |
| 21 const uint8_t kVp9MaxProb = 255; | |
| 22 const int kVp9NumRefsPerFrame = 3; | |
| 23 | |
| 24 enum class Vp9ColorSpace { | |
| 25 UNKNOWN = 0, | |
| 26 BT_601 = 1, | |
| 27 BT_709 = 2, | |
| 28 SMPTE_170 = 3, | |
| 29 SMPTE_240 = 4, | |
| 30 BT_2020 = 5, | |
| 31 RESERVED = 6, | |
| 32 SRGB = 7, | |
| 33 }; | |
| 34 | |
| 35 enum class Vp9InterpFilter { | |
| 36 INTERP_FILTER_SELECT = 0, | |
| 37 EIGHTTAP_SMOOTH = 1, | |
| 38 EIGHTTAP = 2, | |
| 39 EIGHTTAP_SHARP = 3, | |
| 40 BILINEAR = 4, | |
| 41 }; | |
| 42 | |
| 43 // Member of Vp9FrameHeader and will be 0-initialized in Vp9FrameHeader's ctor. | |
|
Ville-Mikko Rautio
2015/08/02 23:43:50
There's no (explicit) Vp9FrameHeader ctor. Maybe y
Pawel Osciak
2015/08/02 23:58:15
Good catch, I think we were both thinking about th
kcwu
2015/08/03 10:05:52
I'm not so comfortable to write memset(this). If a
kcwu
2015/08/03 10:05:53
Done.
| |
| 44 struct MEDIA_EXPORT Vp9Segmentation { | |
| 45 static const int kNumSegments = 8; | |
| 46 static const int kNumTreeProbs = kNumSegments - 1; | |
| 47 static const int kNumPredictionProbs = 3; | |
| 48 static const int kNumFeature = 4; | |
| 49 | |
| 50 bool enabled; | |
| 51 | |
| 52 bool update_map; | |
| 53 uint8_t tree_probs[kNumTreeProbs]; | |
| 54 bool temporal_update; | |
| 55 uint8_t pred_probs[kNumPredictionProbs]; | |
| 56 | |
| 57 bool update_data; | |
| 58 bool abs_delta; | |
| 59 bool feature_enabled[kNumSegments][kNumFeature]; | |
| 60 int8_t feature_data[kNumSegments][kNumFeature]; | |
| 61 }; | |
| 62 | |
| 63 // Member of Vp9FrameHeader and will be 0-initialized in Vp9FrameHeader's ctor. | |
|
Pawel Osciak
2015/08/01 15:22:48
s/Member/Members/
s/and //
Ville-Mikko Rautio
2015/08/02 23:43:49
ditto
kcwu
2015/08/03 10:05:52
Done.
kcwu
2015/08/03 10:05:52
Done.
| |
| 64 struct MEDIA_EXPORT Vp9LoopFilter { | |
| 65 static const int kNumRefDeltas = 4; | |
| 66 static const int kNumModeDeltas = 2; | |
| 67 | |
| 68 uint8_t filter_level; | |
| 69 uint8_t sharpness_level; | |
| 70 | |
| 71 bool mode_ref_delta_enabled; | |
| 72 bool mode_ref_delta_update; | |
| 73 bool update_ref_deltas[kNumRefDeltas]; | |
| 74 int8_t ref_deltas[kNumRefDeltas]; | |
| 75 bool update_mode_deltas[kNumModeDeltas]; | |
| 76 int8_t mode_deltas[kNumModeDeltas]; | |
| 77 }; | |
| 78 | |
| 79 // Member of Vp9FrameHeader and will be 0-initialized in Vp9FrameHeader's ctor. | |
|
Pawel Osciak
2015/08/01 15:22:49
Ditto.
Ville-Mikko Rautio
2015/08/02 23:43:49
ditto
kcwu
2015/08/03 10:05:52
Done.
kcwu
2015/08/03 10:05:53
Done.
| |
| 80 struct MEDIA_EXPORT Vp9QuantizationParams { | |
| 81 bool IsLossless() const { | |
| 82 return base_qindex == 0 && y_dc_delta == 0 && uv_dc_delta == 0 && | |
| 83 uv_ac_delta == 0; | |
|
Pawel Osciak
2015/08/01 15:22:48
Is this a correct indent (not 4 spaces?). What doe
kcwu
2015/08/03 10:05:52
This is "git cl format" did.
| |
| 84 } | |
| 85 | |
| 86 uint8_t base_qindex; | |
| 87 int8_t y_dc_delta; | |
| 88 int8_t uv_dc_delta; | |
| 89 int8_t uv_ac_delta; | |
| 90 }; | |
| 91 | |
| 92 // VP9 frame header. | |
| 93 struct MEDIA_EXPORT Vp9FrameHeader { | |
| 94 enum FrameType { | |
| 95 KEYFRAME = 0, | |
| 96 INTERFRAME = 1, | |
| 97 }; | |
| 98 | |
| 99 bool IsKeyframe() const { return frame_type == KEYFRAME; } | |
| 100 | |
| 101 uint8_t profile; | |
| 102 | |
| 103 bool show_existing_frame; | |
| 104 uint8_t frame_to_show; | |
| 105 | |
| 106 FrameType frame_type; | |
| 107 | |
| 108 bool show_frame; | |
| 109 bool error_resilient_mode; | |
| 110 | |
| 111 uint8_t bit_depth; | |
| 112 Vp9ColorSpace color_space; | |
| 113 bool yuv_range; | |
| 114 uint8_t subsampling_x; | |
| 115 uint8_t subsampling_y; | |
| 116 | |
| 117 // The range of width and height is 1..2^16. | |
| 118 uint32_t width; | |
| 119 uint32_t height; | |
| 120 uint32_t display_width; | |
| 121 uint32_t display_height; | |
| 122 | |
| 123 bool intra_only; | |
| 124 uint8_t reset_context; | |
| 125 bool refresh_flag[kVp9NumRefFrames]; | |
| 126 uint8_t frame_refs[kVp9NumRefsPerFrame]; | |
| 127 bool ref_sign_biases[kVp9NumRefsPerFrame]; | |
| 128 bool allow_high_precision_mv; | |
| 129 Vp9InterpFilter interp_filter; | |
| 130 | |
| 131 bool refresh_frame_context; | |
| 132 bool frame_parallel_decoding_mode; | |
| 133 uint8_t frame_context_idx; | |
| 134 | |
| 135 Vp9LoopFilter loop_filter; | |
| 136 Vp9QuantizationParams quant_params; | |
| 137 Vp9Segmentation segment; | |
| 138 | |
| 139 uint8_t log2_tile_cols; | |
| 140 uint8_t log2_tile_rows; | |
| 141 | |
| 142 // Size of compressed header in bytes. | |
| 143 size_t first_partition_size; | |
| 144 | |
| 145 // Size of uncompressed header in bytes. | |
| 146 size_t uncompressed_header_size; | |
| 147 }; | |
| 148 | |
| 149 // The parsing context for Vp9Parser to keep track references. | |
|
Pawel Osciak
2015/08/01 15:22:48
s/track/track of/
Ville-Mikko Rautio
2015/08/02 23:43:49
What is the designed purpose for having the list o
kcwu
2015/08/03 10:05:52
Done.
kcwu
2015/08/03 10:05:52
The sizes are needed to parse next frames as ReadF
| |
| 150 struct MEDIA_EXPORT Vp9ReferenceSlots { | |
|
Pawel Osciak
2015/08/01 15:22:48
Do we need this 1-member structure? Perhaps move t
kcwu
2015/08/03 10:05:52
I was under impression that it will be used by vp9
| |
| 151 // Updates the reference slots according to |fhdr|. | |
| 152 void Update(const Vp9FrameHeader& fhdr); | |
|
Ville-Mikko Rautio
2015/08/02 23:43:49
You're not using Vp9ReferenceSlots::Update current
kcwu
2015/08/03 10:05:52
I was misunderstood it will be used by vp9 decoder
| |
| 153 | |
| 154 gfx::Size slot[kVp9NumRefFrames]; | |
| 155 }; | |
| 156 | |
| 157 // A parser for VP9 bitstream. | |
| 158 class MEDIA_EXPORT Vp9Parser { | |
| 159 public: | |
| 160 Vp9Parser(); | |
| 161 | |
| 162 // Parses one frame and fill parsing result to |fhdr|. | |
|
Pawel Osciak
2015/08/01 15:22:49
s/fill/fills/
Returns true on success, false other
kcwu
2015/08/03 10:05:52
Done.
| |
| 163 // |stream| is the address of VP9 bitstream with |size|. | |
| 164 // |ref_slots| is the VP9 reference slots maintained by the caller. | |
|
Ville-Mikko Rautio
2015/08/02 23:43:49
Explain also the return value.
kcwu
2015/08/03 10:05:52
Done.
| |
| 165 bool ParseFrame(const uint8_t* stream, | |
| 166 size_t size, | |
| 167 const Vp9ReferenceSlots& ref_slots, | |
| 168 Vp9FrameHeader* fhdr); | |
| 169 | |
| 170 private: | |
| 171 uint8_t ReadProfile(); | |
|
Ville-Mikko Rautio
2015/08/02 23:43:49
As far as I can tell all the private members are j
kcwu
2015/08/03 10:05:52
Indeed they are implementation detail. However I'm
| |
| 172 bool VerifySyncCode(); | |
| 173 bool ReadBitDepthColorSpaceSampling(Vp9FrameHeader* fhdr); | |
| 174 void ReadFrameSize(Vp9FrameHeader* fhdr); | |
| 175 bool ReadFrameSizeFromRefs(const Vp9ReferenceSlots& ref_slots, | |
| 176 Vp9FrameHeader* fhdr); | |
| 177 void ReadDisplayFrameSize(Vp9FrameHeader* fhdr); | |
| 178 Vp9InterpFilter ReadInterpFilter(); | |
| 179 void ReadLoopFilter(Vp9LoopFilter* loop_filter); | |
| 180 void ReadQuantization(Vp9QuantizationParams* quants); | |
| 181 void ReadSegmentationMap(Vp9Segmentation* segment); | |
| 182 void ReadSegmentationData(Vp9Segmentation* segment); | |
| 183 void ReadSegmentation(Vp9Segmentation* segment); | |
| 184 void ReadTiles(Vp9FrameHeader* fhdr); | |
| 185 bool ParseUncompressedHeader(const Vp9ReferenceSlots& ref_slots, | |
| 186 Vp9FrameHeader* fhdr); | |
| 187 | |
| 188 // Start address of VP9 bitstream buffer. | |
| 189 const uint8_t* stream_; | |
| 190 | |
| 191 // Size of |stream_| in bytes. | |
| 192 size_t size_; | |
| 193 | |
| 194 // Raw bits decoder for uncompressed frame header. | |
| 195 Vp9RawBitsReader reader_; | |
| 196 | |
| 197 DISALLOW_COPY_AND_ASSIGN(Vp9Parser); | |
| 198 }; | |
| 199 | |
| 200 } // namespace media | |
| 201 | |
| 202 #endif // MEDIA_FILTERS_VP9_PARSER_H_ | |
| OLD | NEW |