OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MEDIA_VIDEO_VIDEO_DECODE_ACCELERATOR_H_ | 5 #ifndef MEDIA_VIDEO_VIDEO_DECODE_ACCELERATOR_H_ |
6 #define MEDIA_VIDEO_VIDEO_DECODE_ACCELERATOR_H_ | 6 #define MEDIA_VIDEO_VIDEO_DECODE_ACCELERATOR_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/callback_old.h" | 11 #include "base/callback_old.h" |
12 #include "media/base/bitstream_buffer.h" | 12 #include "media/base/bitstream_buffer.h" |
13 #include "media/video/picture.h" | 13 #include "media/video/picture.h" |
14 #include "ui/gfx/size.h" | 14 #include "ui/gfx/size.h" |
15 | 15 |
16 namespace media { | 16 namespace media { |
17 | 17 |
18 // Enumeration defining global dictionary ranges for various purposes that are | |
19 // used to handle the configurations of the video decoder. | |
20 // | |
21 // IMPORTANT! Dictionary keys and corresponding values MUST match the ones found | |
22 // in Pepper API dictionary for video (ppapi/c/dev/pp_video_dev.h)! | |
23 enum VideoAttributeKey { | |
24 VIDEOATTRIBUTEKEY_TERMINATOR = 0, | |
25 | |
26 VIDEOATTRIBUTEKEY_BITSTREAM_FORMAT_BASE = 0x100, | |
27 // Array of key/value pairs describing video configuration. | |
28 // It could include any keys from PP_VideoKey. Its last element shall be | |
29 // VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_NONE with no corresponding value. | |
30 // An example: | |
31 // { | |
32 // VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_FOURCC, PP_VIDEODECODECID_VP8, | |
33 // VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_VP8_PROFILE, (VP8PROFILE_1 | | |
34 // VP8PROFILE_2 | | |
35 // VP8PROFILE_3), | |
36 // VIDEOATTRIBUTEKEY_TERMINATOR | |
37 // }; | |
38 // Keys for defining video bitstream format. | |
39 // Value is type of PP_VideoCodecFourcc. Commonly known attributes values are | |
40 // defined in PP_VideoCodecFourcc enumeration. | |
41 VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_FOURCC, | |
42 // Bitrate in bits/s. Attribute value is 32-bit unsigned integer. | |
43 VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_BITRATE, | |
44 // Width and height of the input video bitstream, if known by the application. | |
45 // Decoder will expect the bitstream to match these values and does memory | |
46 // considerations accordingly. | |
47 VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_WIDTH, | |
48 VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_HEIGHT, | |
49 // Following attributes are applicable only in case of VP8. | |
50 // Key for VP8 profile attribute. Attribute value is bitmask of flags defined | |
51 // in PP_VP8Profile_Dev enumeration. | |
52 VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_VP8_PROFILE, | |
53 // Number of partitions per picture. Attribute value is unsigned 32-bit | |
54 // integer. | |
55 VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_VP8_NUM_OF_PARTITIONS, | |
56 // Following attributes are applicable only in case of H.264. | |
57 // Value is bitmask collection from the flags defined in PP_H264Profile. | |
58 VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_H264_PROFILE, | |
59 // Value is type of PP_H264Level. | |
60 VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_H264_LEVEL, | |
61 // Value is type of PP_H264PayloadFormat_Dev. | |
62 VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_H264_PAYLOADFORMAT, | |
63 // Subset for H.264 features, attribute value 0 signifies unsupported. | |
64 // This is needed in case decoder has partial support for certain profile. | |
65 // Default for features are enabled if they're part of supported profile. | |
66 // H264 tool called Flexible Macroblock Ordering. | |
67 VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_H264_FEATURE_FMO, | |
68 // H264 tool called Arbitrary Slice Ordering. | |
69 VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_H264_FEATURE_ASO, | |
70 // H264 tool called Interlacing. | |
71 VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_H264_FEATURE_INTERLACE, | |
72 // H264 tool called Context-Adaptive Binary Arithmetic Coding. | |
73 VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_H264_FEATURE_CABAC, | |
74 // H264 tool called Weighted Prediction. | |
75 VIDEOATTRIBUTEKEY_BITSTREAMFORMAT_H264_FEATURE_WEIGHTEDPREDICTION, | |
76 | |
77 VIDEOATTRIBUTEKEY_COLOR_FORMAT_BASE = 0x1000, | |
78 // This specifies the output color format for a decoded frame. Value is one | |
79 // of the values in VideoColorFormat enumeration. | |
80 VIDEOATTRIBUTEKEY_VIDEOCOLORFORMAT, | |
81 }; | |
82 | |
83 enum VideoCodecFourcc { | |
84 VIDEOCODECFOURCC_NONE = 0, | |
85 VIDEOCODECFOURCC_VP8 = 0x00385056, // a.k.a. Fourcc 'VP8\0'. | |
86 VIDEOCODECFOURCC_H264 = 0x31637661, // a.k.a. Fourcc 'avc1'. | |
87 }; | |
88 | |
89 // VP8 specific information to be carried over the APIs. | |
90 // Enumeration for flags defining supported VP8 profiles. | |
91 enum VP8Profile { | |
92 VP8PROFILE_NONE = 0, | |
93 VP8PROFILE_0 = 1, | |
94 VP8PROFILE_1 = 1 << 1, | |
95 VP8PROFILE_2 = 1 << 2, | |
96 VP8PROFILE_3 = 1 << 3, | |
97 }; | |
98 | |
99 // H.264 specific information to be carried over the APIs. | |
100 // Enumeration for flags defining supported H.264 profiles. | |
101 enum H264Profile { | |
102 H264PROFILE_NONE = 0, | |
103 H264PROFILE_BASELINE = 1, | |
104 H264PROFILE_MAIN = 1 << 2, | |
105 H264PROFILE_EXTENDED = 1 << 3, | |
106 H264PROFILE_HIGH = 1 << 4, | |
107 H264PROFILE_HIGH10PROFILE = 1 << 5, | |
108 H264PROFILE_HIGH422PROFILE = 1 << 6, | |
109 H264PROFILE_HIGH444PREDICTIVEPROFILE = 1 << 7, | |
110 H264PROFILE_SCALABLEBASELINE = 1 << 8, | |
111 H264PROFILE_SCALABLEHIGH = 1 << 9, | |
112 H264PROFILE_STEREOHIGH = 1 << 10, | |
113 H264PROFILE_MULTIVIEWHIGH = 1 << 11, | |
114 }; | |
115 | |
116 // Enumeration for defining H.264 level of decoder implementation. | |
117 enum H264Level { | |
118 H264LEVEL_NONE = 0, | |
119 H264LEVEL_10 = 1, | |
120 H264LEVEL_1B = H264LEVEL_10 | 1 << 1, | |
121 H264LEVEL_11 = H264LEVEL_1B | 1 << 2, | |
122 H264LEVEL_12 = H264LEVEL_11 | 1 << 3, | |
123 H264LEVEL_13 = H264LEVEL_12 | 1 << 4, | |
124 H264LEVEL_20 = H264LEVEL_13 | 1 << 5, | |
125 H264LEVEL_21 = H264LEVEL_20 | 1 << 6, | |
126 H264LEVEL_22 = H264LEVEL_21 | 1 << 7, | |
127 H264LEVEL_30 = H264LEVEL_22 | 1 << 8, | |
128 H264LEVEL_31 = H264LEVEL_30 | 1 << 9, | |
129 H264LEVEL_32 = H264LEVEL_31 | 1 << 10, | |
130 H264LEVEL_40 = H264LEVEL_32 | 1 << 11, | |
131 H264LEVEL_41 = H264LEVEL_40 | 1 << 12, | |
132 H264LEVEL_42 = H264LEVEL_41 | 1 << 13, | |
133 H264LEVEL_50 = H264LEVEL_42 | 1 << 14, | |
134 H264LEVEL_51 = H264LEVEL_50 | 1 << 15, | |
135 }; | |
136 | |
137 // Enumeration to describe which payload format is used within the exchanged | |
138 // bitstream buffers. | |
139 enum H264PayloadFormat { | |
140 H264PAYLOADFORMAT_NONE = 0, | |
141 // NALUs separated by Start Code. | |
142 H264PAYLOADFORMAT_BYTESTREAM = 1, | |
143 // Exactly one raw NALU per buffer. | |
144 H264PAYLOADFORMAT_ONE_NALU_PER_BUFFER = 1 << 1, | |
145 // NALU separated by 1-byte interleaved length field. | |
146 H264PAYLOADFORMAT_ONE_BYTE_INTERLEAVED_LENGTH = 1 << 2, | |
147 // NALU separated by 2-byte interleaved length field. | |
148 H264PAYLOADFORMAT_TWO_BYTE_INTERLEAVED_LENGTH = 1 << 3, | |
149 // NALU separated by 4-byte interleaved length field. | |
150 H264PAYLOADFORMAT_FOUR_BYTE_INTERLEAVED_LENGTH = 1 << 4, | |
151 }; | |
152 | |
153 // Enumeration for various color formats. | |
154 enum VideoColorFormat { | |
155 // Value represents 32-bit RGBA format where each component is 8-bit in order | |
156 // R-G-B-A. Regardless of endianness of the architecture color components are | |
157 // stored in this order in the memory. | |
158 VIDEOCOLORFORMAT_RGBA = 0, | |
159 }; | |
160 | |
161 // Video decoder interface. | 18 // Video decoder interface. |
162 // This interface is extended by the various components that ultimately | 19 // This interface is extended by the various components that ultimately |
163 // implement the backend of PPB_VideoDecode_Dev. | 20 // implement the backend of PPB_VideoDecode_Dev. |
164 // | 21 // |
165 // No thread-safety guarantees are implied by the use of RefCountedThreadSafe | 22 // No thread-safety guarantees are implied by the use of RefCountedThreadSafe |
166 // below. | 23 // below. |
167 class MEDIA_EXPORT VideoDecodeAccelerator | 24 class MEDIA_EXPORT VideoDecodeAccelerator |
168 : public base::RefCountedThreadSafe<VideoDecodeAccelerator> { | 25 : public base::RefCountedThreadSafe<VideoDecodeAccelerator> { |
169 public: | 26 public: |
| 27 // Video stream profile. This *must* match PP_VideoDecoder_Profile. |
| 28 enum Profile { |
| 29 // Keep the values in this enum unique, as they imply format (h.264 vs. VP8, |
| 30 // for example), and keep the values for a particular format grouped |
| 31 // together for clarity. |
| 32 H264PROFILE_MIN = 0, |
| 33 H264PROFILE_BASELINE = H264PROFILE_MIN, |
| 34 H264PROFILE_MAIN, |
| 35 H264PROFILE_EXTENDED, |
| 36 H264PROFILE_HIGH, |
| 37 H264PROFILE_HIGH10PROFILE, |
| 38 H264PROFILE_HIGH422PROFILE, |
| 39 H264PROFILE_HIGH444PREDICTIVEPROFILE, |
| 40 H264PROFILE_SCALABLEBASELINE, |
| 41 H264PROFILE_SCALABLEHIGH, |
| 42 H264PROFILE_STEREOHIGH, |
| 43 H264PROFILE_MULTIVIEWHIGH, |
| 44 H264PROFILE_MAX = H264PROFILE_MULTIVIEWHIGH, |
| 45 }; |
| 46 |
170 // Enumeration of potential errors generated by the API. | 47 // Enumeration of potential errors generated by the API. |
171 // Note: Keep these in sync with PP_VideoDecodeError_Dev. | 48 // Note: Keep these in sync with PP_VideoDecodeError_Dev. |
172 enum Error { | 49 enum Error { |
173 // An operation was attempted during an incompatible decoder state. | 50 // An operation was attempted during an incompatible decoder state. |
174 ILLEGAL_STATE = 1, | 51 ILLEGAL_STATE = 1, |
175 // Invalid argument was passed to an API method. | 52 // Invalid argument was passed to an API method. |
176 INVALID_ARGUMENT, | 53 INVALID_ARGUMENT, |
177 // Encoded input is unreadable. | 54 // Encoded input is unreadable. |
178 UNREADABLE_INPUT, | 55 UNREADABLE_INPUT, |
179 // A failure occurred at the browser layer or one of its dependencies. | 56 // A failure occurred at the browser layer or one of its dependencies. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 virtual void NotifyResetDone() = 0; | 96 virtual void NotifyResetDone() = 0; |
220 | 97 |
221 // Callback to notify about decoding errors. | 98 // Callback to notify about decoding errors. |
222 virtual void NotifyError(Error error) = 0; | 99 virtual void NotifyError(Error error) = 0; |
223 }; | 100 }; |
224 | 101 |
225 // Video decoder functions. | 102 // Video decoder functions. |
226 | 103 |
227 // Initializes the video decoder with specific configuration. | 104 // Initializes the video decoder with specific configuration. |
228 // Parameters: | 105 // Parameters: |
229 // |config| is the configuration on which the decoder should be initialized. | 106 // |profile| is the video stream's format profile. |
230 // | 107 // |
231 // Returns true when command successfully accepted. Otherwise false. | 108 // Returns true when command successfully accepted. Otherwise false. |
232 virtual bool Initialize(const std::vector<int32>& config) = 0; | 109 virtual bool Initialize(Profile profile) = 0; |
233 | 110 |
234 // Decodes given bitstream buffer. Once decoder is done with processing | 111 // Decodes given bitstream buffer. Once decoder is done with processing |
235 // |bitstream_buffer| it will call NotifyEndOfBitstreamBuffer() with the | 112 // |bitstream_buffer| it will call NotifyEndOfBitstreamBuffer() with the |
236 // bitstream buffer id. | 113 // bitstream buffer id. |
237 // Parameters: | 114 // Parameters: |
238 // |bitstream_buffer| is the input bitstream that is sent for decoding. | 115 // |bitstream_buffer| is the input bitstream that is sent for decoding. |
239 virtual void Decode(const BitstreamBuffer& bitstream_buffer) = 0; | 116 virtual void Decode(const BitstreamBuffer& bitstream_buffer) = 0; |
240 | 117 |
241 // Assigns a set of texture-backed picture buffers to the video decoder. | 118 // Assigns a set of texture-backed picture buffers to the video decoder. |
242 // | 119 // |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 virtual void Destroy() = 0; | 152 virtual void Destroy() = 0; |
276 | 153 |
277 protected: | 154 protected: |
278 friend class base::RefCountedThreadSafe<VideoDecodeAccelerator>; | 155 friend class base::RefCountedThreadSafe<VideoDecodeAccelerator>; |
279 virtual ~VideoDecodeAccelerator(); | 156 virtual ~VideoDecodeAccelerator(); |
280 }; | 157 }; |
281 | 158 |
282 } // namespace media | 159 } // namespace media |
283 | 160 |
284 #endif // MEDIA_VIDEO_VIDEO_DECODE_ACCELERATOR_H_ | 161 #endif // MEDIA_VIDEO_VIDEO_DECODE_ACCELERATOR_H_ |
OLD | NEW |