Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 REMOTING_CODEC_VIDEO_ENCODER_VPX_H_ | 5 #ifndef REMOTING_CODEC_VIDEO_ENCODER_VPX_H_ |
| 6 #define REMOTING_CODEC_VIDEO_ENCODER_VPX_H_ | 6 #define REMOTING_CODEC_VIDEO_ENCODER_VPX_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "remoting/codec/scoped_vpx_codec.h" | 10 #include "remoting/codec/scoped_vpx_codec.h" |
| 11 #include "remoting/codec/video_encoder.h" | 11 #include "remoting/codec/video_encoder.h" |
| 12 | 12 |
| 13 typedef struct vpx_image vpx_image_t; | 13 typedef struct vpx_image vpx_image_t; |
| 14 | 14 |
| 15 namespace webrtc { | 15 namespace webrtc { |
| 16 class DesktopRegion; | 16 class DesktopRegion; |
| 17 class DesktopSize; | 17 class DesktopSize; |
| 18 } // namespace webrtc | 18 } // namespace webrtc |
| 19 | 19 |
| 20 namespace remoting { | 20 namespace remoting { |
| 21 | 21 |
| 22 class VideoEncoderVpx : public VideoEncoder { | 22 class VideoEncoderVpx : public VideoEncoder { |
| 23 public: | 23 public: |
| 24 // Create encoder for the specified protocol. | 24 // Create encoder for the specified protocol. |
| 25 static scoped_ptr<VideoEncoderVpx> CreateForVP8(); | 25 static scoped_ptr<VideoEncoderVpx> CreateForVP8(); |
| 26 static scoped_ptr<VideoEncoderVpx> CreateForVP9I420(); | 26 static scoped_ptr<VideoEncoderVpx> CreateForVP9(); |
| 27 static scoped_ptr<VideoEncoderVpx> CreateForVP9I444(); | |
| 28 | 27 |
| 29 virtual ~VideoEncoderVpx(); | 28 virtual ~VideoEncoderVpx(); |
| 30 | 29 |
| 31 // VideoEncoder interface. | 30 // VideoEncoder interface. |
| 31 virtual void SetLosslessEncode(bool want_lossless) OVERRIDE; | |
| 32 virtual void SetLosslessColor(bool want_lossless) OVERRIDE; | |
| 32 virtual scoped_ptr<VideoPacket> Encode( | 33 virtual scoped_ptr<VideoPacket> Encode( |
| 33 const webrtc::DesktopFrame& frame) OVERRIDE; | 34 const webrtc::DesktopFrame& frame) OVERRIDE; |
| 34 | 35 |
| 35 private: | 36 private: |
| 36 typedef base::Callback<ScopedVpxCodec(const webrtc::DesktopSize&)> | 37 VideoEncoderVpx(bool use_vp9); |
|
Jamie
2014/05/29 22:19:41
Nit: Add explicit?
Wez
2014/05/29 22:39:26
Done.
| |
| 37 CreateCodecCallback; | |
| 38 typedef base::Callback<void(const webrtc::DesktopSize&, | |
| 39 scoped_ptr<vpx_image_t>* out_image, | |
| 40 scoped_ptr<uint8[]>* out_image_buffer)> | |
| 41 CreateImageCallback; | |
| 42 | |
| 43 VideoEncoderVpx(const CreateCodecCallback& create_codec, | |
| 44 const CreateImageCallback& create_image); | |
| 45 | 38 |
| 46 // Initializes the codec for frames of |size|. Returns true if successful. | 39 // Initializes the codec for frames of |size|. Returns true if successful. |
| 47 bool Initialize(const webrtc::DesktopSize& size); | 40 bool Initialize(const webrtc::DesktopSize& size); |
| 48 | 41 |
| 49 // Prepares |image_| for encoding. Writes updated rectangles into | 42 // Prepares |image_| for encoding. Writes updated rectangles into |
| 50 // |updated_region|. | 43 // |updated_region|. |
| 51 void PrepareImage(const webrtc::DesktopFrame& frame, | 44 void PrepareImage(const webrtc::DesktopFrame& frame, |
| 52 webrtc::DesktopRegion* updated_region); | 45 webrtc::DesktopRegion* updated_region); |
| 53 | 46 |
| 54 // Updates the active map according to |updated_region|. Active map is then | 47 // Updates the active map according to |updated_region|. Active map is then |
| 55 // given to the encoder to speed up encoding. | 48 // given to the encoder to speed up encoding. |
| 56 void PrepareActiveMap(const webrtc::DesktopRegion& updated_region); | 49 void PrepareActiveMap(const webrtc::DesktopRegion& updated_region); |
| 57 | 50 |
| 58 CreateCodecCallback create_codec_; | 51 // True if the encoder should generate VP9, false for VP8. |
| 59 CreateImageCallback create_image_; | 52 bool use_vp9_; |
| 53 | |
| 54 // Options controlling VP9 encode quantization and color space. | |
| 55 // These are always off (false) for VP8. | |
| 56 bool lossless_encode_; | |
| 57 bool lossless_color_; | |
| 60 | 58 |
| 61 ScopedVpxCodec codec_; | 59 ScopedVpxCodec codec_; |
| 62 base::TimeTicks timestamp_base_; | 60 base::TimeTicks timestamp_base_; |
| 63 | 61 |
| 64 // VPX image and buffer to hold the actual YUV planes. | 62 // VPX image and buffer to hold the actual YUV planes. |
| 65 scoped_ptr<vpx_image_t> image_; | 63 scoped_ptr<vpx_image_t> image_; |
| 66 scoped_ptr<uint8[]> image_buffer_; | 64 scoped_ptr<uint8[]> image_buffer_; |
| 67 | 65 |
| 68 // Active map used to optimize out processing of un-changed macroblocks. | 66 // Active map used to optimize out processing of un-changed macroblocks. |
| 69 scoped_ptr<uint8[]> active_map_; | 67 scoped_ptr<uint8[]> active_map_; |
| 70 int active_map_width_; | 68 int active_map_width_; |
| 71 int active_map_height_; | 69 int active_map_height_; |
| 72 | 70 |
| 73 DISALLOW_COPY_AND_ASSIGN(VideoEncoderVpx); | 71 DISALLOW_COPY_AND_ASSIGN(VideoEncoderVpx); |
| 74 }; | 72 }; |
| 75 | 73 |
| 76 } // namespace remoting | 74 } // namespace remoting |
| 77 | 75 |
| 78 #endif // REMOTING_CODEC_VIDEO_ENCODER_VP8_H_ | 76 #endif // REMOTING_CODEC_VIDEO_ENCODER_VP8_H_ |
| OLD | NEW |