Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Side by Side Diff: media/video/video_decode_accelerator.h

Issue 7779001: Replace the use of an int32* with a proper struct for decoder configuration. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 decoder configuration. This *must* match PP_VideoDecoderConfig_Dev.
28 struct Config {
29 // Format of the video data, as a FourCC code.
30 enum Format {
31 // VP8 = 0x00385056, // 'VP8\0', not yet supported.
32 H264 = 0x31637661 // 'avc1'
33 } format;
34
35 // h.264 profile; ignored if |format| above is not H264.
36 enum H264Profile {
37 H264PROFILE_NONE = 0,
38 H264PROFILE_BASELINE = 1,
39 H264PROFILE_MAIN = 1 << 2,
40 H264PROFILE_EXTENDED = 1 << 3,
41 H264PROFILE_HIGH = 1 << 4,
42 H264PROFILE_HIGH10PROFILE = 1 << 5,
43 H264PROFILE_HIGH422PROFILE = 1 << 6,
44 H264PROFILE_HIGH444PREDICTIVEPROFILE = 1 << 7,
45 H264PROFILE_SCALABLEBASELINE = 1 << 8,
46 H264PROFILE_SCALABLEHIGH = 1 << 9,
47 H264PROFILE_STEREOHIGH = 1 << 10,
48 H264PROFILE_MULTIVIEWHIGH = 1 << 11
49 } h264_profile;
50 };
51
170 // Enumeration of potential errors generated by the API. 52 // Enumeration of potential errors generated by the API.
171 // Note: Keep these in sync with PP_VideoDecodeError_Dev. 53 // Note: Keep these in sync with PP_VideoDecodeError_Dev.
172 enum Error { 54 enum Error {
173 // An operation was attempted during an incompatible decoder state. 55 // An operation was attempted during an incompatible decoder state.
174 ILLEGAL_STATE = 1, 56 ILLEGAL_STATE = 1,
175 // Invalid argument was passed to an API method. 57 // Invalid argument was passed to an API method.
176 INVALID_ARGUMENT, 58 INVALID_ARGUMENT,
177 // Encoded input is unreadable. 59 // Encoded input is unreadable.
178 UNREADABLE_INPUT, 60 UNREADABLE_INPUT,
179 // A failure occurred at the browser layer or one of its dependencies. 61 // A failure occurred at the browser layer or one of its dependencies.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 virtual void NotifyError(Error error) = 0; 104 virtual void NotifyError(Error error) = 0;
223 }; 105 };
224 106
225 // Video decoder functions. 107 // Video decoder functions.
226 108
227 // Initializes the video decoder with specific configuration. 109 // Initializes the video decoder with specific configuration.
228 // Parameters: 110 // Parameters:
229 // |config| is the configuration on which the decoder should be initialized. 111 // |config| is the configuration on which the decoder should be initialized.
230 // 112 //
231 // Returns true when command successfully accepted. Otherwise false. 113 // Returns true when command successfully accepted. Otherwise false.
232 virtual bool Initialize(const std::vector<int32>& config) = 0; 114 virtual bool Initialize(const Config& config) = 0;
233 115
234 // Decodes given bitstream buffer. Once decoder is done with processing 116 // Decodes given bitstream buffer. Once decoder is done with processing
235 // |bitstream_buffer| it will call NotifyEndOfBitstreamBuffer() with the 117 // |bitstream_buffer| it will call NotifyEndOfBitstreamBuffer() with the
236 // bitstream buffer id. 118 // bitstream buffer id.
237 // Parameters: 119 // Parameters:
238 // |bitstream_buffer| is the input bitstream that is sent for decoding. 120 // |bitstream_buffer| is the input bitstream that is sent for decoding.
239 virtual void Decode(const BitstreamBuffer& bitstream_buffer) = 0; 121 virtual void Decode(const BitstreamBuffer& bitstream_buffer) = 0;
240 122
241 // Assigns a set of texture-backed picture buffers to the video decoder. 123 // Assigns a set of texture-backed picture buffers to the video decoder.
242 // 124 //
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 virtual void Destroy() = 0; 157 virtual void Destroy() = 0;
276 158
277 protected: 159 protected:
278 friend class base::RefCountedThreadSafe<VideoDecodeAccelerator>; 160 friend class base::RefCountedThreadSafe<VideoDecodeAccelerator>;
279 virtual ~VideoDecodeAccelerator(); 161 virtual ~VideoDecodeAccelerator();
280 }; 162 };
281 163
282 } // namespace media 164 } // namespace media
283 165
284 #endif // MEDIA_VIDEO_VIDEO_DECODE_ACCELERATOR_H_ 166 #endif // MEDIA_VIDEO_VIDEO_DECODE_ACCELERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698