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

Unified 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: remove dependent files from this CL Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: media/filters/vp9_parser.h
diff --git a/media/filters/vp9_parser.h b/media/filters/vp9_parser.h
new file mode 100644
index 0000000000000000000000000000000000000000..e035033a794bd6a180d77dbad42847558d2b443a
--- /dev/null
+++ b/media/filters/vp9_parser.h
@@ -0,0 +1,188 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_FILTERS_VP9_PARSER_H_
+#define MEDIA_FILTERS_VP9_PARSER_H_
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include "base/macros.h"
+#include "media/base/media_export.h"
+#include "media/filters/vp9_raw_bits_reader.h"
+
+namespace media {
+
+const int kVp9MaxProfile = 4;
+const int kVp9RefFramesLog2 = 3;
+const int kVp9RefFrames = 1 << kVp9RefFramesLog2;
+const uint8_t kVp9MaxProb = 255;
+const int kVp9RefsPerFrame = 3;
Pawel Osciak 2015/07/30 11:52:31 kVp9NumRefFrames
kcwu1 2015/07/31 04:36:02 Ok, I changed the name kVp9RefFrames -> kVp9NumRef
+
+enum class Vp9ColorSpace {
+ UNKNOWN,
+ BT_601,
Pawel Osciak 2015/07/30 08:27:38 We should assign explicit values since this is per
kcwu1 2015/07/31 04:36:02 Done.
+ BT_709,
+ SMPTE_170,
+ SMPTE_240,
+ BT_2020,
+ RESERVED,
+ SRGB,
+};
+
+enum class Vp9InterpFilter {
+ INTERP_FILTER_SELECT,
+ EIGHTTAP_SMOOTH,
+ EIGHTTAP,
+ EIGHTTAP_SHARP,
+ BILINEAR,
+};
+
+struct MEDIA_EXPORT Vp9Segmentation {
+ static const int kNumSegment = 8;
Pawel Osciak 2015/07/30 08:27:38 kNumSegments
kcwu1 2015/07/31 04:36:02 Done.
+ static const int kTreeProbs = kNumSegment - 1;
Pawel Osciak 2015/07/30 08:27:38 kNumTreeProbs
kcwu1 2015/07/31 04:36:02 Done.
+ static const int kPredictionProbs = 3;
Pawel Osciak 2015/07/30 08:27:38 kNumPredictionProbs
kcwu1 2015/07/31 04:36:02 Done.
+ static const int kNumFeature = 4;
+
+ bool enabled;
+
+ bool update_map;
+ uint8_t tree_probs[kTreeProbs];
+ uint8_t pred_probs[kPredictionProbs];
+
+ bool update_data;
+ bool abs_delta;
+ bool feature_enabled[kNumSegment][kNumFeature];
+ int8_t feature_data[kNumSegment][kNumFeature];
+};
+
+struct MEDIA_EXPORT Vp9LoopFilter {
+ static const int kNumRefDeltas = 4;
+ static const int kNumModeDeltas = 2;
+
+ uint8_t filter_level;
+ uint8_t sharpness_level;
+
+ bool mode_ref_delta_enabled;
+ bool mode_ref_delta_update;
+ bool update_ref_deltas[kNumRefDeltas];
+ int8_t ref_deltas[kNumRefDeltas];
+ bool update_mode_deltas[kNumModeDeltas];
+ int8_t mode_deltas[kNumModeDeltas];
+};
+
+struct MEDIA_EXPORT Vp9QuantizationParams {
+ bool IsLossless() const {
+ return base_qindex == 0 && y_dc_delta == 0 && uv_dc_delta == 0;
Pawel Osciak 2015/07/30 11:52:31 Do we need && uv_ac_delta_q == 0 here as well?
kcwu1 2015/07/31 04:36:02 Done.
+ }
+
+ uint8_t base_qindex;
+ int8_t y_dc_delta;
+ int8_t uv_dc_delta;
+ int8_t uv_ac_delta;
+};
+
+// VP9 frame header.
+struct MEDIA_EXPORT Vp9FrameHeader {
+ enum FrameType {
+ KEYFRAME,
Pawel Osciak 2015/07/30 08:27:38 Explicit values please.
kcwu1 2015/07/31 04:36:02 Done.
+ INTERFRAME,
+ };
+
+ bool IsKeyframe() const { return frame_type == KEYFRAME; }
+
+ uint8_t profile;
+
+ bool show_existing_frame;
+ uint8_t frame_to_show;
+
+ enum FrameType frame_type;
Pawel Osciak 2015/07/30 08:27:38 s/enum//
kcwu1 2015/07/31 04:36:02 Done.
+
+ bool show_frame;
+ bool error_resilient_mode;
+
+ uint8_t bit_depth;
+ enum Vp9ColorSpace color_space;
+ bool yuv_range;
+ uint8_t subsampling_x;
+ uint8_t subsampling_y;
+
+ // The range of width and height is 1..2^16.
+ uint32_t width;
+ uint32_t height;
+ uint32_t display_width;
+ uint32_t display_height;
+
+ bool intra_only;
+ uint8_t reset_context;
+ bool refresh_flag[kVp9RefFrames];
+ uint8_t frame_refs[kVp9RefsPerFrame];
+ bool ref_sign_biases[kVp9RefsPerFrame];
+ bool allow_high_precision_mv;
+ enum Vp9InterpFilter interp_filter;
+
+ bool refresh_frame_context;
+ bool frame_parallel_decoding_mode;
+ uint8_t frame_context_idx;
+
+ Vp9LoopFilter loop_filter;
+ Vp9QuantizationParams quant_params;
+ Vp9Segmentation segment;
+
+ uint8_t log2_tile_cols;
+ uint8_t log2_tile_rows;
+
+ // If parsing out of order and |frame_type| is INTERFRAME, the value of
+ // |first_partition_size| and |compressed_header| may be invalid.
+ uint16_t first_partition_size;
+ const uint8_t* compressed_header;
+};
+
+class MEDIA_EXPORT Vp9Parser {
+ public:
+ Vp9Parser();
+
+ // Parses one frame.
+ // If parsing out of order (say, frame skip or seek), it still returns
+ // true for interframes but |fhdr| fields refering to previous frames
+ // will be undefined until next keyframe.
+ // ??? Do we need to support such case? Or should we check sizes strictly?
+ bool ParseFrame(const uint8_t* ptr, size_t size, Vp9FrameHeader* fhdr);
+
+ private:
+ struct ReferenceSlot {
+ bool used;
+ uint32_t width;
+ uint32_t height;
+ };
+
+ uint8_t ReadProfile();
+ bool VerifySyncCode();
+ bool ReadBitDepthColorSpaceSampling(Vp9FrameHeader* fhdr);
+ void ReadFrameSize(Vp9FrameHeader* fhdr);
+ void ReadFrameSizeFromRefs(Vp9FrameHeader* fhdr);
+ void ReadDisplayFrameSize(Vp9FrameHeader* fhdr);
+ Vp9InterpFilter ReadInterpFilter();
+ void ReadLoopFilter(Vp9LoopFilter* loop_filter);
+ void ReadQuantization(Vp9QuantizationParams* quants);
+ void ReadSegmentationMap(Vp9Segmentation* segment);
+ void ReadSegmentationData(Vp9Segmentation* segment);
+ void ReadSegmentation(Vp9Segmentation* segment);
+ bool ParseUncompressedHeader(Vp9FrameHeader* fhdr);
+ void ReadTiles(Vp9FrameHeader* fhdr);
+ void UpdateSlots(Vp9FrameHeader* fhdr);
+
+ const uint8_t* stream_;
+ size_t size_;
+ Vp9RawBitsReader reader_;
+
+ // The parsing context to keep track references.
+ ReferenceSlot ref_slots_[kVp9RefFrames];
+
+ DISALLOW_COPY_AND_ASSIGN(Vp9Parser);
+};
+
+} // namespace media
+
+#endif // MEDIA_FILTERS_VP9_PARSER_H_
« 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