BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / media / base / video_decoder_config.h
blob0dae77c86a860a9e17528e2200b1d2bc4a8cdcb5
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>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "media/base/media_export.h"
13 #include "media/base/video_codecs.h"
14 #include "media/base/video_types.h"
15 #include "ui/gfx/geometry/rect.h"
16 #include "ui/gfx/geometry/size.h"
18 namespace media {
20 MEDIA_EXPORT VideoCodec
21 VideoCodecProfileToVideoCodec(VideoCodecProfile profile);
23 class MEDIA_EXPORT VideoDecoderConfig {
24 public:
25 // Constructs an uninitialized object. Clients should call Initialize() with
26 // appropriate values before using.
27 VideoDecoderConfig();
29 // Constructs an initialized object. It is acceptable to pass in NULL for
30 // |extra_data|, otherwise the memory is copied.
31 VideoDecoderConfig(VideoCodec codec,
32 VideoCodecProfile profile,
33 VideoPixelFormat format,
34 ColorSpace color_space,
35 const gfx::Size& coded_size,
36 const gfx::Rect& visible_rect,
37 const gfx::Size& natural_size,
38 const uint8* extra_data,
39 size_t extra_data_size,
40 bool is_encrypted);
42 ~VideoDecoderConfig();
44 // Resets the internal state of this object.
45 void Initialize(VideoCodec codec,
46 VideoCodecProfile profile,
47 VideoPixelFormat format,
48 ColorSpace color_space,
49 const gfx::Size& coded_size,
50 const gfx::Rect& visible_rect,
51 const gfx::Size& natural_size,
52 const uint8* extra_data,
53 size_t extra_data_size,
54 bool is_encrypted);
56 // Returns true if this object has appropriate configuration values, false
57 // otherwise.
58 bool IsValidConfig() const;
60 // Returns true if all fields in |config| match this config.
61 // Note: The contents of |extra_data_| are compared not the raw pointers.
62 bool Matches(const VideoDecoderConfig& config) const;
64 // Returns a human-readable string describing |*this|. For debugging & test
65 // output only.
66 std::string AsHumanReadableString() const;
68 std::string GetHumanReadableCodecName() const;
70 VideoCodec codec() const { return codec_; }
71 VideoCodecProfile profile() const { return profile_; }
73 // Video format used to determine YUV buffer sizes.
74 VideoPixelFormat format() const { return format_; }
76 // The default color space of the decoded frames. Decoders should output
77 // frames tagged with this color space unless they find a different value in
78 // the bitstream.
79 ColorSpace color_space() const { return color_space_; }
81 // Width and height of video frame immediately post-decode. Not all pixels
82 // in this region are valid.
83 gfx::Size coded_size() const { return coded_size_; }
85 // Region of |coded_size_| that is visible.
86 gfx::Rect visible_rect() const { return visible_rect_; }
88 // Final visible width and height of a video frame with aspect ratio taken
89 // into account.
90 gfx::Size natural_size() const { return natural_size_; }
92 // Optional byte data required to initialize video decoders, such as H.264
93 // AAVC data.
94 const uint8* extra_data() const;
95 size_t extra_data_size() const { return extra_data_.size(); }
97 // Whether the video stream is potentially encrypted.
98 // Note that in a potentially encrypted video stream, individual buffers
99 // can be encrypted or not encrypted.
100 bool is_encrypted() const { return is_encrypted_; }
102 private:
103 VideoCodec codec_;
104 VideoCodecProfile profile_;
106 VideoPixelFormat format_;
107 ColorSpace color_space_;
109 gfx::Size coded_size_;
110 gfx::Rect visible_rect_;
111 gfx::Size natural_size_;
113 std::vector<uint8> extra_data_;
115 bool is_encrypted_;
117 // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler
118 // generated copy constructor and assignment operator. Since the extra data is
119 // typically small, the performance impact is minimal.
122 } // namespace media
124 #endif // MEDIA_BASE_VIDEO_DECODER_CONFIG_H_