Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Side by Side Diff: media/filters/vp9_parser.h

Issue 1258083004: Add a Vp9Parser implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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.
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 struct MEDIA_EXPORT Vp9Segmentation {
44 static const int kNumSegments = 8;
45 static const int kNumTreeProbs = kNumSegments - 1;
46 static const int kNumPredictionProbs = 3;
47 static const int kNumFeature = 4;
Owen Lin 2015/07/31 13:34:00 kNumFeatures
kcwu 2015/08/03 10:05:52 Done.
48
49 bool enabled;
50
51 bool update_map;
52 uint8_t tree_probs[kNumTreeProbs];
53 bool temporal_update;
54 uint8_t pred_probs[kNumPredictionProbs];
55
56 bool update_data;
57 bool abs_delta;
58 bool feature_enabled[kNumSegments][kNumFeature];
59 int8_t feature_data[kNumSegments][kNumFeature];
60 };
61
62 struct MEDIA_EXPORT Vp9LoopFilter {
63 static const int kNumRefDeltas = 4;
64 static const int kNumModeDeltas = 2;
65
66 uint8_t filter_level;
67 uint8_t sharpness_level;
68
69 bool mode_ref_delta_enabled;
70 bool mode_ref_delta_update;
71 bool update_ref_deltas[kNumRefDeltas];
72 int8_t ref_deltas[kNumRefDeltas];
73 bool update_mode_deltas[kNumModeDeltas];
74 int8_t mode_deltas[kNumModeDeltas];
75 };
76
77 struct MEDIA_EXPORT Vp9QuantizationParams {
78 bool IsLossless() const {
79 return base_qindex == 0 && y_dc_delta == 0 && uv_dc_delta == 0 &&
80 uv_ac_delta == 0;
81 }
82
83 uint8_t base_qindex;
84 int8_t y_dc_delta;
85 int8_t uv_dc_delta;
86 int8_t uv_ac_delta;
87 };
88
89 // VP9 frame header.
90 struct MEDIA_EXPORT Vp9FrameHeader {
91 enum FrameType {
92 KEYFRAME = 0,
93 INTERFRAME = 1,
94 };
95
96 bool IsKeyframe() const { return frame_type == KEYFRAME; }
97
98 uint8_t profile;
99
100 bool show_existing_frame;
101 uint8_t frame_to_show;
102
103 FrameType frame_type;
104
105 bool show_frame;
106 bool error_resilient_mode;
107
108 uint8_t bit_depth;
109 Vp9ColorSpace color_space;
110 bool yuv_range;
111 uint8_t subsampling_x;
112 uint8_t subsampling_y;
113
114 // The range of width and height is 1..2^16.
115 uint32_t width;
116 uint32_t height;
117 uint32_t display_width;
118 uint32_t display_height;
119
120 bool intra_only;
121 uint8_t reset_context;
122 bool refresh_flag[kVp9NumRefFrames];
123 uint8_t frame_refs[kVp9NumRefsPerFrame];
124 bool ref_sign_biases[kVp9NumRefsPerFrame];
125 bool allow_high_precision_mv;
126 Vp9InterpFilter interp_filter;
127
128 bool refresh_frame_context;
129 bool frame_parallel_decoding_mode;
130 uint8_t frame_context_idx;
131
132 Vp9LoopFilter loop_filter;
133 Vp9QuantizationParams quant_params;
134 Vp9Segmentation segment;
135
136 uint8_t log2_tile_cols;
137 uint8_t log2_tile_rows;
138
139 // Size of compressed header in bytes.
140 size_t first_partition_size;
141
142 // Size of uncompressed header in bytes.
143 size_t uncompressed_header_size;
144 };
145
146 // The parsing context for Vp9Parser to keep track references.
147 struct MEDIA_EXPORT Vp9ReferenceSlots {
148 // Updates the reference slots according to |fhdr|.
149 void Update(const Vp9FrameHeader& fhdr);
150
151 gfx::Size slot[kVp9NumRefFrames];
152 };
153
154 class MEDIA_EXPORT Vp9Parser {
155 public:
156 Vp9Parser();
157
158 // Parses one frame and fill parsing result to |fhdr|.
159 // |stream| is the address of VP9 bitstream with |size|.
160 // |ref_slots| is the VP9 reference slots maintained by the caller.
Owen Lin 2015/07/31 13:34:00 explain the return value
kcwu 2015/08/03 10:05:52 Done.
161 bool ParseFrame(const uint8_t* stream,
162 size_t size,
163 const Vp9ReferenceSlots& ref_slots,
164 Vp9FrameHeader* fhdr);
165
166 private:
167 uint8_t ReadProfile();
168 bool VerifySyncCode();
169 bool ReadBitDepthColorSpaceSampling(Vp9FrameHeader* fhdr);
170 void ReadFrameSize(Vp9FrameHeader* fhdr);
171 bool ReadFrameSizeFromRefs(const Vp9ReferenceSlots& ref_slots,
172 Vp9FrameHeader* fhdr);
173 void ReadDisplayFrameSize(Vp9FrameHeader* fhdr);
174 Vp9InterpFilter ReadInterpFilter();
175 void ReadLoopFilter(Vp9LoopFilter* loop_filter);
176 void ReadQuantization(Vp9QuantizationParams* quants);
177 void ReadSegmentationMap(Vp9Segmentation* segment);
178 void ReadSegmentationData(Vp9Segmentation* segment);
179 void ReadSegmentation(Vp9Segmentation* segment);
180 bool ParseUncompressedHeader(const Vp9ReferenceSlots& ref_slots,
181 Vp9FrameHeader* fhdr);
182 void ReadTiles(Vp9FrameHeader* fhdr);
183 void UpdateSlots(Vp9FrameHeader* fhdr);
184
185 // Start address of VP9 bitstream buffer.
186 const uint8_t* stream_;
187
188 // Size of |stream_| in bytes.
189 size_t size_;
190
191 // Raw bits decoder for uncompressed frame header.
192 Vp9RawBitsReader reader_;
193
194 DISALLOW_COPY_AND_ASSIGN(Vp9Parser);
195 };
196
197 } // namespace media
198
199 #endif // MEDIA_FILTERS_VP9_PARSER_H_
OLDNEW
« no previous file with comments | « media/BUILD.gn ('k') | media/filters/vp9_parser.cc » ('j') | media/filters/vp9_parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698