Remove stale dependency in "ozone_demo" GN target.
[chromium-blink-merge.git] / remoting / codec / video_encoder_vpx.h
blob7d80592b0302ef3b7b5be596475c560354474f79
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.
5 #ifndef REMOTING_CODEC_VIDEO_ENCODER_VPX_H_
6 #define REMOTING_CODEC_VIDEO_ENCODER_VPX_H_
8 #include "base/callback.h"
9 #include "base/time/time.h"
10 #include "remoting/codec/scoped_vpx_codec.h"
11 #include "remoting/codec/video_encoder.h"
12 #include "remoting/codec/video_encoder_helper.h"
14 typedef struct vpx_image vpx_image_t;
16 namespace webrtc {
17 class DesktopRegion;
18 class DesktopSize;
19 } // namespace webrtc
21 namespace remoting {
23 class VideoEncoderVpx : public VideoEncoder {
24 public:
25 // Create encoder for the specified protocol.
26 static scoped_ptr<VideoEncoderVpx> CreateForVP8();
27 static scoped_ptr<VideoEncoderVpx> CreateForVP9();
29 ~VideoEncoderVpx() override;
31 // VideoEncoder interface.
32 void SetLosslessEncode(bool want_lossless) override;
33 void SetLosslessColor(bool want_lossless) override;
34 scoped_ptr<VideoPacket> Encode(const webrtc::DesktopFrame& frame) override;
36 private:
37 explicit VideoEncoderVpx(bool use_vp9);
39 // (Re)Configures this instance to encode frames of the specified |size|,
40 // with the configured lossless color & encoding modes.
41 void Configure(const webrtc::DesktopSize& size);
43 // Prepares |image_| for encoding. Writes updated rectangles into
44 // |updated_region|.
45 void PrepareImage(const webrtc::DesktopFrame& frame,
46 webrtc::DesktopRegion* updated_region);
48 // Updates the active map according to |updated_region|. Active map is then
49 // given to the encoder to speed up encoding.
50 void SetActiveMapFromRegion(const webrtc::DesktopRegion& updated_region);
52 // Adds areas changed in the most recent frame to |updated_region|. This
53 // includes both content changes and areas enhanced by cyclic refresh.
54 void UpdateRegionFromActiveMap(webrtc::DesktopRegion* updated_region);
56 // True if the encoder is for VP9, false for VP8.
57 const bool use_vp9_;
59 // Options controlling VP9 encode quantization and color space.
60 // These are always off (false) for VP8.
61 bool lossless_encode_ = false;
62 bool lossless_color_ = false;
64 // Holds the initialized & configured codec.
65 ScopedVpxCodec codec_;
67 // Used to generate zero-based frame timestamps.
68 base::TimeTicks timestamp_base_;
70 // VPX image and buffer to hold the actual YUV planes.
71 scoped_ptr<vpx_image_t> image_;
72 scoped_ptr<uint8[]> image_buffer_;
74 // Active map used to optimize out processing of un-changed macroblocks.
75 scoped_ptr<uint8[]> active_map_;
76 webrtc::DesktopSize active_map_size_;
78 // True if the codec wants unchanged frames to finish topping-off with.
79 bool encode_unchanged_frame_;
81 // Used to help initialize VideoPackets from DesktopFrames.
82 VideoEncoderHelper helper_;
84 DISALLOW_COPY_AND_ASSIGN(VideoEncoderVpx);
87 } // namespace remoting
89 #endif // REMOTING_CODEC_VIDEO_ENCODER_VP8_H_