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. | |
Ami GONE FROM CHROMIUM
2013/07/31 23:01:12
Did you mean to add a query/response API pair here
sheu
2013/08/03 01:31:03
Not at the moment; this is statically queried. (S
| |
28 struct SupportedProfile { | |
29 VideoCodecProfile profile; | |
30 gfx::Size max_resolution; | |
31 struct { | |
32 uint32 numerator; | |
33 uint32 denominator; | |
34 } max_framerate; | |
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. | |
Ami GONE FROM CHROMIUM
2013/07/31 23:01:12
s/browser layer/GPU process/
sheu
2013/08/03 01:31:03
Done.
| |
44 // Examples of such failures include GPU hardware failures, GPU driver | |
45 // failures, GPU library failures, browser programming errors, and so on. | |
Ami GONE FROM CHROMIUM
2013/07/31 23:01:12
s/browser/GPU process/
sheu
2013/08/03 01:31:03
Done.
| |
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 the client what size of buffers to provide for input and | |
56 // output. The VEA disclaims use or ownership of all previously provided | |
57 // buffers once this callback is made. | |
Ami GONE FROM CHROMIUM
2013/07/31 23:01:12
This seems unfortunate in that it makes it higher-
sheu
2013/08/03 01:31:03
VDA::Client::DismissBitstreamBuffer ended up being
Pawel Osciak
2013/08/03 01:57:47
Not ignored anymore, since we have support for MSE
Ami GONE FROM CHROMIUM
2013/08/05 18:44:38
Pawel I think this comment was part of your confus
Pawel Osciak
2013/08/06 06:47:33
Sorry, my point was how do we want to handle chang
sheu
2013/08/07 09:25:03
Until we have actual HW support for resolution cha
| |
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. | |
Ami GONE FROM CHROMIUM
2013/07/31 23:01:12
The method name deals in bitstreambuffers but here
sheu
2013/08/03 01:31:03
moving to media::VideoFrame.
| |
62 // |input_dimensions| are the logical dimensions of the input frames to | |
63 // encode, in pixels. The encoder may have hardware alignment requirements | |
64 // that make this different from |input_resolution|, as requested in | |
65 // Initialize(), in which case the input buffer should be padded to | |
Ami GONE FROM CHROMIUM
2013/07/31 23:01:12
s/input buffer/input to VEA::Encode()/
sheu
2013/08/03 01:31:03
Done.
| |
66 // |input_dimensions|. | |
67 // |output_size| is the required size of output buffers for this encoder, | |
Ami GONE FROM CHROMIUM
2013/07/31 23:01:12
s/output_size/buffer_size/
sheu
2013/08/03 01:31:03
output_buffer_size_, then. I'd like to make it cl
| |
68 // in bytes. | |
69 virtual void RequireBitstreamBuffers(int input_count, | |
Pawel Osciak
2013/08/01 09:00:42
I think we are missing a Flush() or something simi
Ami GONE FROM CHROMIUM
2013/08/01 20:49:22
We dropped Flush() from go/vea (see resolved comme
Pawel Osciak
2013/08/02 00:25:10
In terms of a hangout, no. This came up while writ
| |
70 const gfx::Size& input_dimensions, | |
71 size_t output_size) = 0; | |
72 | |
73 // Callback to notify that encoder has finished with an input frame. | |
74 virtual void NotifyInputDone(int32 bitstream_buffer_id) = 0; | |
Ami GONE FROM CHROMIUM
2013/07/31 23:01:12
s/Input/Encode/ (and in the comment)
sheu
2013/08/03 01:31:03
I renamed it to Input a while back. I wanted to a
| |
75 | |
76 // Callback to deliver encoded bitstream buffers. The VEA disclaims use or | |
77 // ownership of the specified buffer once this callback is made. | |
Ami GONE FROM CHROMIUM
2013/07/31 23:01:13
"disclaims use and ownership" is blort.
What is tr
| |
78 // |bitstream_buffer_id| is the id of the buffer that is ready. | |
79 // |size| is the byte size of the used portion of the buffer. | |
Ami GONE FROM CHROMIUM
2013/07/31 23:01:13
missing "payload_" from param name
sheu
2013/08/03 01:31:03
Done.
| |
80 virtual void BitstreamBufferReady(int32 bitstream_buffer_id, | |
81 size_t payload_size, | |
82 bool key_frame) = 0; | |
Ami GONE FROM CHROMIUM
2013/07/31 23:01:13
doco param
sheu
2013/08/03 01:31:03
Done.
| |
83 | |
84 // Error notification callback. | |
85 virtual void NotifyError(Error error) = 0; | |
86 | |
87 protected: | |
Ami GONE FROM CHROMIUM
2013/07/31 23:01:13
Why protected the dtor?
sheu
2013/08/03 01:31:03
Because VDA::Client does the same?
Not sure if th
| |
88 virtual ~Client() {} | |
89 }; | |
90 | |
91 // Video encoder functions. | |
92 | |
93 // Initialize the video encoder with a specific configuration. Called once | |
94 // per encoder construction. | |
95 // Parameters: | |
96 // |input_format| is the frame format of the input stream. | |
97 // |input_resolution| is the resolution of the input stream. | |
Ami GONE FROM CHROMIUM
2013/07/31 23:01:13
It is unfortunate that this needs to be specified
sheu
2013/08/03 01:31:03
Unfortunately, we'd best tear down and reinstantia
| |
98 // |output_profile| is the codec profile of the encoded output stream. | |
99 // |initial_bitrate| is the initial bitrate of the encoded output stream, | |
100 // in bits per second. | |
101 virtual void Initialize(media::VideoFrame::Format input_format, | |
102 const gfx::Size& input_resolution, | |
103 VideoCodecProfile output_profile, | |
104 int32 initial_bitrate) = 0; | |
105 | |
106 // Encodes the given frame. | |
107 // Parameters: | |
108 // |buffer| is the buffer holding the frame that is to be encoded (with a | |
109 // buffer logical size/width as specified in RequireBitstreamBuffers(), and | |
110 // visible size/width as specified in Initialize()). | |
Ami GONE FROM CHROMIUM
2013/07/31 23:01:13
This should be a VideoFrame, not a BitstreamBuffer
Ami GONE FROM CHROMIUM
2013/07/31 23:01:13
Please make sure (DCHECK) the requirements on visi
sheu
2013/08/03 01:31:03
Alright, retargeting for media::VideoFrame.
| |
111 // |force_keyframe| forces the encoding of a keyframe for this frame. | |
112 virtual void Encode(const BitstreamBuffer& buffer, bool force_keyframe) = 0; | |
113 | |
114 // Send a bitstream buffer to the encoder to be used for storing future | |
115 // encoded output. | |
116 // Parameters: | |
117 // |buffer| is the bitstream buffer to use for output. | |
118 virtual void UseOutputBitstreamBuffer(const BitstreamBuffer& buffer) = 0; | |
119 | |
120 // Request a change to the encoding parameters. This is only a request, | |
121 // fulfilled on a best-effort basis. | |
122 // Parameters: | |
123 // |bitrate| is the requested new bitrate, in bits per second. | |
124 virtual void RequestEncodingParameterChange(int32 bitrate) = 0; | |
125 | |
126 // Destroys the encoder: all pending inputs are dropped immediately and the | |
Ami GONE FROM CHROMIUM
2013/07/31 23:01:13
s/inputs/inputs and outputs/
sheu
2013/08/03 01:31:03
Done.
| |
127 // component is freed. This call may asynchronously free system resources, | |
128 // but its client-visible effects are synchronous. After this method returns | |
129 // no more callbacks will be made on the client. Deletes |this| | |
130 // unconditionally, so make sure to drop all pointers to it! | |
131 virtual void Destroy() = 0; | |
132 }; | |
133 | |
134 } // namespace media | |
135 | |
136 #endif // MEDIA_VIDEO_VIDEO_ENCODE_ACCELERATOR_H_ | |
OLD | NEW |