OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013 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. | |
4 | |
5 #ifndef MEDIA_VIDEO_VIDEO_ENCODE_ACCELERATOR_H_ | |
6 #define MEDIA_VIDEO_VIDEO_ENCODE_ACCELERATOR_H_ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "base/memory/ref_counted.h" | |
12 #include "media/base/bitstream_buffer.h" | |
13 #include "media/base/media_export.h" | |
14 #include "media/base/video_decoder_config.h" | |
15 #include "media/base/video_frame.h" | |
16 | |
17 namespace media { | |
18 | |
19 class BitstreamBuffer; | |
20 class VideoFrame; | |
21 | |
22 // Video encoder interface. | |
23 class MEDIA_EXPORT VideoEncodeAccelerator { | |
24 public: | |
25 virtual ~VideoEncodeAccelerator(); | |
26 | |
27 // Specification of an encoding profile supported by an encoder. | |
28 struct SupportedProfile { | |
29 VideoCodecProfile profile; | |
30 gfx::Size max_resolution; | |
31 struct { | |
32 uint32 numerator; | |
33 uint32 denominator; | |
34 } max_framerate; | |
Pawel Osciak
2013/07/26 02:26:43
I'm not sure about this. Is this because of someth
sheu
2013/07/26 19:09:07
Right, this struct is used by the VEA to export a
Pawel Osciak
2013/07/27 08:35:48
Ok, but how does max_framerate relate to max_resol
sheu
2013/07/29 18:24:52
I suppose we could have a vector of supported max
Pawel Osciak
2013/08/01 03:21:39
How will this be used now then? Is there anything
| |
35 }; | |
36 | |
37 // Enumeration of potential errors generated by the API. | |
38 enum Error { | |
39 // An operation was attempted during an incompatible encoder state. | |
40 kIllegalStateError, | |
41 // Invalid argument was passed to an API method. | |
42 kInvalidArgumentError, | |
43 // A failure occurred at the browser layer or one of its dependencies. | |
44 // Examples of such failures include GPU hardware failures, GPU driver | |
45 // failures, GPU library failures, browser programming errors, and so on. | |
46 kPlatformFailureError, | |
47 }; | |
48 | |
49 // Interface for clients that use VideoEncodeAccelerator. | |
50 class MEDIA_EXPORT Client { | |
51 public: | |
52 // Callback to notify client that encoder has been successfully initialized. | |
53 virtual void NotifyInitializeDone() = 0; | |
54 | |
55 // Callback to tell client what size of buffers to provide for input and | |
Pawel Osciak
2013/07/26 02:26:43
s/tell client/tell the client/
sheu
2013/07/26 19:09:07
Done.
| |
56 // output. The VEA disclaims use or ownership of all previously provided | |
Pawel Osciak
2013/07/26 02:26:43
So this means that we can have one set of input/ou
sheu
2013/07/26 19:09:07
Right, that's the "disclaims use or _ownership_" p
| |
57 // buffers once this callback is made. | |
58 // Parameters: | |
59 // |input_count| is the number of input frames required for encoding. The | |
60 // client should provide at least this many frames, since the encoder may | |
61 // need to hold onto some subset of inputs as reference pictures. | |
62 // |input_dimensions| is the logical dimensions of the input frames to | |
Pawel Osciak
2013/07/26 02:26:43
s/is/are perhaps?
I understand the dimensions par
sheu
2013/07/26 19:09:07
Done.
| |
63 // encode. The encoder may have hardware alignment requirements that make | |
64 // this different from |input_resolution|, as requested in Initialize(), in | |
65 // which case the input buffer should be padded to |nput_dimensions|. | |
Pawel Osciak
2013/07/26 02:26:43
s/nput_/input_/
sheu
2013/07/26 19:09:07
Done.
| |
66 // |output_size| is the required size of output buffers for this encoder. | |
Pawel Osciak
2013/07/26 02:26:43
in bytes
sheu
2013/07/26 19:09:07
Done.
| |
67 virtual void RequireBitstreamBuffers(int input_count, | |
68 const gfx::Size& input_dimensions, | |
69 size_t output_size) = 0; | |
70 | |
71 // Callback to notify that encoder has finished with an input frame. | |
72 virtual void NotifyInputDone(int32 bitstream_buffer_id) = 0; | |
73 | |
74 // Callback to deliver encoded bitstream buffers. The VEA disclaims use or | |
75 // ownership of the specified buffer once this callback is made. | |
76 // |bitstream_buffer_id| is the id of the buffer that is ready. | |
77 // |size| is the byte size of the used portion of the buffer. | |
78 virtual void BitstreamBufferReady(int32 bitstream_buffer_id, | |
79 size_t size, | |
Pawel Osciak
2013/07/26 02:26:43
s/size/payload_size ?
sheu
2013/07/26 19:09:07
Done. Now to run through all the rest of the sour
| |
80 bool key_frame) = 0; | |
81 | |
82 // Error notification callback. | |
83 virtual void NotifyError(Error error) = 0; | |
84 | |
85 protected: | |
86 virtual ~Client() {} | |
87 }; | |
88 | |
89 // Video encoder functions. | |
90 | |
91 // Initialize the video encoder with a specific configuration. Called once | |
92 // per encoder construction. | |
93 // Parameters: | |
94 // |input_format| is the frame format of the input stream. | |
95 // |input_resolution| is the resolution of the input stream. | |
96 // |output_profile| is the codec profile of the encoded output stream. | |
97 // |initial_bitrate| is the initial bitrate of the encoded output stream, | |
98 // in bits/s. | |
99 virtual void Initialize(media::VideoFrame::Format input_format, | |
100 const gfx::Size& input_resolution, | |
101 VideoCodecProfile output_profile, | |
102 int32 initial_bitrate) = 0; | |
Pawel Osciak
2013/07/26 02:26:43
Perhaps we could drop initial_bitrate and simply c
sheu
2013/07/26 19:09:07
Thought about this. fischman@'s initial VEA spec
Pawel Osciak
2013/07/27 08:35:48
Not following you. I agree bitrate change or any o
sheu
2013/07/29 18:24:52
You need an initial bitrate to start encoding; can
Pawel Osciak
2013/08/01 03:21:39
Or you could let encoder choose a default. I don't
Ami GONE FROM CHROMIUM
2013/08/01 20:49:22
FTR I don't care about this question (I can easily
| |
103 | |
104 // Encodes the given frame. | |
105 // Parameters: | |
106 // |buffer| is the buffer holding the frame that is to be encoded (with a | |
107 // buffer logical size/width as specified in RequireBitstreamBuffers(), and | |
108 // visible size/width as specified in Initialize()). | |
109 // |force_keyframe| forces the encoding of a keyframe for this frame. | |
110 virtual void Encode(const BitstreamBuffer& buffer, bool force_keyframe) = 0; | |
Pawel Osciak
2013/07/26 02:26:43
Btw, why are we using BitstreamBuffer for inputs?
sheu
2013/07/26 19:09:07
Yep. They also hold a size and ID nicely.
Pawel Osciak
2013/07/27 08:35:48
Well, it's going to be less useful when we start u
sheu
2013/07/29 18:24:52
DMABUFs are also FDs, which can be dup()ed and IPC
Pawel Osciak
2013/08/01 03:21:39
Well, I won't push too hard. I just find unpleasan
| |
111 | |
112 // Send a bitstream buffer to the encoder to be used for storing future | |
113 // encoded output. | |
114 // Parameters: | |
115 // |buffer| is the bitstream buffer to use for output. | |
116 virtual void UseOutputBitstreamBuffer(const BitstreamBuffer& buffer) = 0; | |
117 | |
118 // Request a change in the encoding parameters. This is only a request, | |
Pawel Osciak
2013/07/26 02:26:43
s/in/to/ ?
sheu
2013/07/26 19:09:07
Not a big deal, but sure :-P
| |
119 // fulfilled on a best-effort basis. | |
Pawel Osciak
2013/07/26 02:26:43
If the change is possible, is there a requirement
sheu
2013/07/26 19:09:07
I was hoping this to be fire-and-forget thing for
Pawel Osciak
2013/07/27 08:35:48
Ok, I guess it's ok not to have it frame-precise a
sheu
2013/07/29 18:24:52
I'll let fischman@ weigh in on this one, since the
Ami GONE FROM CHROMIUM
2013/07/31 23:01:12
I don't see the value in having the callback indic
Pawel Osciak
2013/08/01 03:21:39
But the client can't tell when the change in bitra
Ami GONE FROM CHROMIUM
2013/08/01 20:49:22
Generally I want to minimize the amount of convers
Pawel Osciak
2013/08/02 00:25:10
Ok. I give up, you are right, too much detail for
| |
120 // Parameters: | |
121 // |bitrate| is the requested new bitrate. | |
Pawel Osciak
2013/07/26 02:26:43
in kbps, in bps?
sheu
2013/07/26 19:09:07
Done.
| |
122 virtual void RequestEncodingParameterChange(int32 bitrate) = 0; | |
123 | |
124 // Destroys the encoder: all pending inputs are dropped immediately and the | |
125 // component is freed. This call may asynchronously free system resources, | |
126 // but its client-visible effects are synchronous. After this method returns | |
127 // no more callbacks will be made on the client. Deletes |this| | |
128 // unconditionally, so make sure to drop all pointers to it! | |
129 virtual void Destroy() = 0; | |
130 }; | |
131 | |
132 } // namespace media | |
133 | |
134 #endif // MEDIA_VIDEO_VIDEO_ENCODE_ACCELERATOR_H_ | |
OLD | NEW |