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_
11 #include "base/basictypes.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"
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,
31 // DO NOT ADD RANDOM VIDEO CODECS!
33 // The only acceptable time to add a new codec is if there is production code
34 // that uses said codec in the same CL.
36 kVideoCodecMax
= kCodecVP9
// Must equal the last "real" codec above.
39 // Video stream profile. This *must* match PP_VideoDecoder_Profile.
40 // (enforced in webkit/plugins/ppapi/ppb_video_decoder_impl.cc)
41 enum VideoCodecProfile
{
42 // Keep the values in this enum unique, as they imply format (h.264 vs. VP8,
43 // for example), and keep the values for a particular format grouped
44 // together for clarity.
45 VIDEO_CODEC_PROFILE_UNKNOWN
= -1,
47 H264PROFILE_BASELINE
= H264PROFILE_MIN
,
49 H264PROFILE_EXTENDED
= 2,
51 H264PROFILE_HIGH10PROFILE
= 4,
52 H264PROFILE_HIGH422PROFILE
= 5,
53 H264PROFILE_HIGH444PREDICTIVEPROFILE
= 6,
54 H264PROFILE_SCALABLEBASELINE
= 7,
55 H264PROFILE_SCALABLEHIGH
= 8,
56 H264PROFILE_STEREOHIGH
= 9,
57 H264PROFILE_MULTIVIEWHIGH
= 10,
58 H264PROFILE_MAX
= H264PROFILE_MULTIVIEWHIGH
,
60 VP8PROFILE_MAIN
= VP8PROFILE_MIN
,
61 VP8PROFILE_MAX
= VP8PROFILE_MAIN
,
63 VP9PROFILE_MAIN
= VP9PROFILE_MIN
,
64 VP9PROFILE_MAX
= VP9PROFILE_MAIN
,
65 VIDEO_CODEC_PROFILE_MAX
= VP9PROFILE_MAX
,
68 class MEDIA_EXPORT VideoDecoderConfig
{
70 // Constructs an uninitialized object. Clients should call Initialize() with
71 // appropriate values before using.
74 // Constructs an initialized object. It is acceptable to pass in NULL for
75 // |extra_data|, otherwise the memory is copied.
76 VideoDecoderConfig(VideoCodec codec
,
77 VideoCodecProfile profile
,
78 VideoFrame::Format format
,
79 const gfx::Size
& coded_size
,
80 const gfx::Rect
& visible_rect
,
81 const gfx::Size
& natural_size
,
82 const uint8
* extra_data
, size_t extra_data_size
,
85 ~VideoDecoderConfig();
87 // Resets the internal state of this object.
88 void Initialize(VideoCodec codec
,
89 VideoCodecProfile profile
,
90 VideoFrame::Format format
,
91 const gfx::Size
& coded_size
,
92 const gfx::Rect
& visible_rect
,
93 const gfx::Size
& natural_size
,
94 const uint8
* extra_data
, size_t extra_data_size
,
98 // Returns true if this object has appropriate configuration values, false
100 bool IsValidConfig() const;
102 // Returns true if all fields in |config| match this config.
103 // Note: The contents of |extra_data_| are compared not the raw pointers.
104 bool Matches(const VideoDecoderConfig
& config
) const;
106 // Returns a human-readable string describing |*this|. For debugging & test
108 std::string
AsHumanReadableString() const;
110 VideoCodec
codec() const;
111 VideoCodecProfile
profile() const;
113 // Video format used to determine YUV buffer sizes.
114 VideoFrame::Format
format() const;
116 // Width and height of video frame immediately post-decode. Not all pixels
117 // in this region are valid.
118 gfx::Size
coded_size() const;
120 // Region of |coded_size_| that is visible.
121 gfx::Rect
visible_rect() const;
123 // Final visible width and height of a video frame with aspect ratio taken
125 gfx::Size
natural_size() const;
127 // Optional byte data required to initialize video decoders, such as H.264
129 const uint8
* extra_data() const;
130 size_t extra_data_size() const;
132 // Whether the video stream is potentially encrypted.
133 // Note that in a potentially encrypted video stream, individual buffers
134 // can be encrypted or not encrypted.
135 bool is_encrypted() const;
139 VideoCodecProfile profile_
;
141 VideoFrame::Format format_
;
143 gfx::Size coded_size_
;
144 gfx::Rect visible_rect_
;
145 gfx::Size natural_size_
;
147 std::vector
<uint8
> extra_data_
;
151 // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler
152 // generated copy constructor and assignment operator. Since the extra data is
153 // typically small, the performance impact is minimal.
158 #endif // MEDIA_BASE_VIDEO_DECODER_CONFIG_H_