roll skia to 4057
[chromium-blink-merge.git] / media / base / video_decoder_config.h
blob3d4d98cab0a083551febd422af1027a989e2e3f6
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 "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "media/base/media_export.h"
11 #include "media/base/video_frame.h"
12 #include "ui/gfx/rect.h"
13 #include "ui/gfx/size.h"
15 namespace media {
17 enum MEDIA_EXPORT VideoCodec {
18 // These values are histogrammed over time; do not change their ordinal
19 // values. When deleting a codec replace it with a dummy value; when adding a
20 // codec, do so at the bottom (and update kVideoCodecMax).
21 kUnknownVideoCodec = 0,
22 kCodecH264,
23 kCodecVC1,
24 kCodecMPEG2,
25 kCodecMPEG4,
26 kCodecTheora,
27 kCodecVP8,
28 // DO NOT ADD RANDOM VIDEO CODECS!
30 // The only acceptable time to add a new codec is if there is production code
31 // that uses said codec in the same CL.
33 kVideoCodecMax = kCodecVP8 // Must equal the last "real" codec above.
36 // Video stream profile. This *must* match PP_VideoDecoder_Profile.
37 // (enforced in webkit/plugins/ppapi/ppb_video_decoder_impl.cc)
38 enum MEDIA_EXPORT VideoCodecProfile {
39 // Keep the values in this enum unique, as they imply format (h.264 vs. VP8,
40 // for example), and keep the values for a particular format grouped
41 // together for clarity.
42 VIDEO_CODEC_PROFILE_UNKNOWN = -1,
43 H264PROFILE_MIN = 0,
44 H264PROFILE_BASELINE = H264PROFILE_MIN,
45 H264PROFILE_MAIN,
46 H264PROFILE_EXTENDED,
47 H264PROFILE_HIGH,
48 H264PROFILE_HIGH10PROFILE,
49 H264PROFILE_HIGH422PROFILE,
50 H264PROFILE_HIGH444PREDICTIVEPROFILE,
51 H264PROFILE_SCALABLEBASELINE,
52 H264PROFILE_SCALABLEHIGH,
53 H264PROFILE_STEREOHIGH,
54 H264PROFILE_MULTIVIEWHIGH,
55 H264PROFILE_MAX = H264PROFILE_MULTIVIEWHIGH,
56 VIDEO_CODEC_PROFILE_MAX = H264PROFILE_MAX,
59 class MEDIA_EXPORT VideoDecoderConfig {
60 public:
61 // Constructs an uninitialized object. Clients should call Initialize() with
62 // appropriate values before using.
63 VideoDecoderConfig();
65 // Constructs an initialized object. It is acceptable to pass in NULL for
66 // |extra_data|, otherwise the memory is copied.
67 VideoDecoderConfig(VideoCodec codec,
68 VideoCodecProfile profile,
69 VideoFrame::Format format,
70 const gfx::Size& coded_size,
71 const gfx::Rect& visible_rect,
72 int frame_rate_numerator, int frame_rate_denominator,
73 int aspect_ratio_numerator, int aspect_ratio_denominator,
74 const uint8* extra_data, size_t extra_data_size);
76 ~VideoDecoderConfig();
78 // Resets the internal state of this object.
79 void Initialize(VideoCodec codec,
80 VideoCodecProfile profile,
81 VideoFrame::Format format,
82 const gfx::Size& coded_size,
83 const gfx::Rect& visible_rect,
84 int frame_rate_numerator, int frame_rate_denominator,
85 int aspect_ratio_numerator, int aspect_ratio_denominator,
86 const uint8* extra_data, size_t extra_data_size,
87 bool record_stats);
89 // Deep copies |video_config|.
90 void CopyFrom(const VideoDecoderConfig& video_config);
92 // Returns true if this object has appropriate configuration values, false
93 // otherwise.
94 bool IsValidConfig() const;
96 // Returns a human-readable string describing |*this|. For debugging & test
97 // output only.
98 std::string AsHumanReadableString() const;
100 VideoCodec codec() const;
101 VideoCodecProfile profile() const;
103 // Video format used to determine YUV buffer sizes.
104 VideoFrame::Format format() const;
106 // Width and height of video frame immediately post-decode. Not all pixels
107 // in this region are valid.
108 gfx::Size coded_size() const;
110 // Region of |coded_size_| that is visible.
111 gfx::Rect visible_rect() const;
113 // Final visible width and height of a video frame with aspect ratio taken
114 // into account.
115 gfx::Size natural_size() const;
117 // Frame rate in seconds expressed as a fraction.
119 // This information is required to properly timestamp video frames for
120 // codecs that contain repeated frames, such as found in H.264's
121 // supplemental enhancement information.
122 int frame_rate_numerator() const;
123 int frame_rate_denominator() const;
125 // Aspect ratio of the decoded video frame expressed as a fraction.
127 // TODO(scherkus): think of a better way to avoid having video decoders
128 // handle tricky aspect ratio dimension calculations.
129 int aspect_ratio_numerator() const;
130 int aspect_ratio_denominator() const;
132 // Optional byte data required to initialize video decoders, such as H.264
133 // AAVC data.
134 uint8* extra_data() const;
135 size_t extra_data_size() const;
137 private:
138 VideoCodec codec_;
139 VideoCodecProfile profile_;
141 VideoFrame::Format format_;
143 gfx::Size coded_size_;
144 gfx::Rect visible_rect_;
145 gfx::Size natural_size_;
147 int frame_rate_numerator_;
148 int frame_rate_denominator_;
150 int aspect_ratio_numerator_;
151 int aspect_ratio_denominator_;
153 scoped_array<uint8> extra_data_;
154 size_t extra_data_size_;
156 DISALLOW_COPY_AND_ASSIGN(VideoDecoderConfig);
159 } // namespace media
161 #endif // MEDIA_BASE_VIDEO_DECODER_CONFIG_H_