Improve performance of registering font preferences
[chromium-blink-merge.git] / media / base / video_decoder_config.h
blobb5ac79210c6076f034f67b758824f633bb32a1e2
1 // Copyright (c) 2012 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.
5 #ifndef MEDIA_BASE_VIDEO_DECODER_CONFIG_H_
6 #define MEDIA_BASE_VIDEO_DECODER_CONFIG_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "media/base/media_export.h"
13 #include "media/base/video_frame.h"
14 #include "ui/gfx/rect.h"
15 #include "ui/gfx/size.h"
17 namespace media {
19 enum VideoCodec {
20 // These values are histogrammed over time; do not change their ordinal
21 // values. When deleting a codec replace it with a dummy value; when adding a
22 // codec, do so at the bottom (and update kVideoCodecMax).
23 kUnknownVideoCodec = 0,
24 kCodecH264,
25 kCodecVC1,
26 kCodecMPEG2,
27 kCodecMPEG4,
28 kCodecTheora,
29 kCodecVP8,
30 // DO NOT ADD RANDOM VIDEO CODECS!
32 // The only acceptable time to add a new codec is if there is production code
33 // that uses said codec in the same CL.
35 kVideoCodecMax = kCodecVP8 // Must equal the last "real" codec above.
38 // Video stream profile. This *must* match PP_VideoDecoder_Profile.
39 // (enforced in webkit/plugins/ppapi/ppb_video_decoder_impl.cc)
40 enum VideoCodecProfile {
41 // Keep the values in this enum unique, as they imply format (h.264 vs. VP8,
42 // for example), and keep the values for a particular format grouped
43 // together for clarity.
44 VIDEO_CODEC_PROFILE_UNKNOWN = -1,
45 H264PROFILE_MIN = 0,
46 H264PROFILE_BASELINE = H264PROFILE_MIN,
47 H264PROFILE_MAIN = 1,
48 H264PROFILE_EXTENDED = 2,
49 H264PROFILE_HIGH = 3,
50 H264PROFILE_HIGH10PROFILE = 4,
51 H264PROFILE_HIGH422PROFILE = 5,
52 H264PROFILE_HIGH444PREDICTIVEPROFILE = 6,
53 H264PROFILE_SCALABLEBASELINE = 7,
54 H264PROFILE_SCALABLEHIGH = 8,
55 H264PROFILE_STEREOHIGH = 9,
56 H264PROFILE_MULTIVIEWHIGH = 10,
57 H264PROFILE_MAX = H264PROFILE_MULTIVIEWHIGH,
58 VP8PROFILE_MIN = 11,
59 VP8PROFILE_MAIN = VP8PROFILE_MIN,
60 VP8PROFILE_MAX = VP8PROFILE_MAIN,
61 VIDEO_CODEC_PROFILE_MAX = VP8PROFILE_MAX,
64 class MEDIA_EXPORT VideoDecoderConfig {
65 public:
66 // Constructs an uninitialized object. Clients should call Initialize() with
67 // appropriate values before using.
68 VideoDecoderConfig();
70 // Constructs an initialized object. It is acceptable to pass in NULL for
71 // |extra_data|, otherwise the memory is copied.
72 VideoDecoderConfig(VideoCodec codec,
73 VideoCodecProfile profile,
74 VideoFrame::Format format,
75 const gfx::Size& coded_size,
76 const gfx::Rect& visible_rect,
77 const gfx::Size& natural_size,
78 const uint8* extra_data, size_t extra_data_size,
79 bool is_encrypted);
81 ~VideoDecoderConfig();
83 // Resets the internal state of this object.
84 void Initialize(VideoCodec codec,
85 VideoCodecProfile profile,
86 VideoFrame::Format format,
87 const gfx::Size& coded_size,
88 const gfx::Rect& visible_rect,
89 const gfx::Size& natural_size,
90 const uint8* extra_data, size_t extra_data_size,
91 bool is_encrypted,
92 bool record_stats);
94 // Deep copies |video_config|.
95 void CopyFrom(const VideoDecoderConfig& video_config);
97 // Returns true if this object has appropriate configuration values, false
98 // otherwise.
99 bool IsValidConfig() const;
101 // Returns true if all fields in |config| match this config.
102 // Note: The contents of |extra_data_| are compared not the raw pointers.
103 bool Matches(const VideoDecoderConfig& config) const;
105 // Returns a human-readable string describing |*this|. For debugging & test
106 // output only.
107 std::string AsHumanReadableString() const;
109 VideoCodec codec() const;
110 VideoCodecProfile profile() const;
112 // Video format used to determine YUV buffer sizes.
113 VideoFrame::Format format() const;
115 // Width and height of video frame immediately post-decode. Not all pixels
116 // in this region are valid.
117 gfx::Size coded_size() const;
119 // Region of |coded_size_| that is visible.
120 gfx::Rect visible_rect() const;
122 // Final visible width and height of a video frame with aspect ratio taken
123 // into account.
124 gfx::Size natural_size() const;
126 // Optional byte data required to initialize video decoders, such as H.264
127 // AAVC data.
128 uint8* extra_data() const;
129 size_t extra_data_size() const;
131 // Whether the video stream is potentially encrypted.
132 // Note that in a potentially encrypted video stream, individual buffers
133 // can be encrypted or not encrypted.
134 bool is_encrypted() const;
136 private:
137 VideoCodec codec_;
138 VideoCodecProfile profile_;
140 VideoFrame::Format format_;
142 gfx::Size coded_size_;
143 gfx::Rect visible_rect_;
144 gfx::Size natural_size_;
146 scoped_array<uint8> extra_data_;
147 size_t extra_data_size_;
149 bool is_encrypted_;
151 DISALLOW_COPY_AND_ASSIGN(VideoDecoderConfig);
154 } // namespace media
156 #endif // MEDIA_BASE_VIDEO_DECODER_CONFIG_H_