• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 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 // Note: ported from Chromium commit head: 9e40822e3a3d
5 // Note: only necessary functions are ported.
6 
7 #ifndef MEDIA_VIDEO_VIDEO_ENCODE_ACCELERATOR_H_
8 #define MEDIA_VIDEO_VIDEO_ENCODE_ACCELERATOR_H_
9 
10 #include <stddef.h>
11 #include <stdint.h>
12 
13 #include <memory>
14 #include <vector>
15 
16 #include "base/macros.h"
17 #include "base/optional.h"
18 #include "base/time/time.h"
19 
20 #include "size.h"
21 #include "video_codecs.h"
22 
23 namespace media {
24 
25 // class BitstreamBuffer;
26 // class VideoFrame;
27 
28 //  Metadata for a VP8 bitstream buffer.
29 //  |non_reference| is true iff this frame does not update any reference buffer,
30 //                  meaning dropping this frame still results in a decodable
31 //                  stream.
32 //  |temporal_idx|  indicates the temporal index for this frame.
33 //  |layer_sync|    if true iff this frame has |temporal_idx| > 0 and does NOT
34 //                  reference any reference buffer containing a frame with
35 //                  temporal_idx > 0.
36 struct Vp8Metadata final {
37   Vp8Metadata();
38   Vp8Metadata(const Vp8Metadata& other);
39   Vp8Metadata(Vp8Metadata&& other);
40   ~Vp8Metadata();
41   bool non_reference;
42   uint8_t temporal_idx;
43   bool layer_sync;
44 };
45 
46 //  Metadata associated with a bitstream buffer.
47 //  |payload_size| is the byte size of the used portion of the buffer.
48 //  |key_frame| is true if this delivered frame is a keyframe.
49 //  |timestamp| is the same timestamp as in VideoFrame passed to Encode().
50 //  |vp8|, if set, contains metadata specific to VP8. See above.
51 struct BitstreamBufferMetadata final {
52   BitstreamBufferMetadata();
53   BitstreamBufferMetadata(BitstreamBufferMetadata&& other);
54   BitstreamBufferMetadata(size_t payload_size_bytes,
55                           bool key_frame,
56                           base::TimeDelta timestamp);
57   ~BitstreamBufferMetadata();
58   size_t payload_size_bytes;
59   bool key_frame;
60   base::TimeDelta timestamp;
61   base::Optional<Vp8Metadata> vp8;
62 };
63 
64 // Video encoder interface.
65 class VideoEncodeAccelerator {
66  public:
67   // Specification of an encoding profile supported by an encoder.
68   struct SupportedProfile {
69     SupportedProfile();
70     SupportedProfile(VideoCodecProfile profile,
71                      const Size& max_resolution,
72                      uint32_t max_framerate_numerator = 0u,
73                      uint32_t max_framerate_denominator = 1u);
74     ~SupportedProfile();
75 
76     VideoCodecProfile profile;
77     Size min_resolution;
78     Size max_resolution;
79     uint32_t max_framerate_numerator;
80     uint32_t max_framerate_denominator;
81   };
82   using SupportedProfiles = std::vector<SupportedProfile>;
83 };
84 
85 }  // namespace media
86 
87 #endif  // MEDIA_VIDEO_VIDEO_ENCODE_ACCELERATOR_H_
88