OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_BASE_DECODER_VP8_H_ | 5 #ifndef REMOTING_BASE_DECODER_VP8_H_ |
6 #define REMOTING_BASE_DECODER_VP8_H_ | 6 #define REMOTING_BASE_DECODER_VP8_H_ |
7 | 7 |
8 #include "remoting/base/decoder.h" | 8 #include "remoting/base/decoder.h" |
9 | 9 |
10 typedef struct vpx_codec_ctx vpx_codec_ctx_t; | 10 typedef struct vpx_codec_ctx vpx_codec_ctx_t; |
11 typedef struct vpx_image vpx_image_t; | 11 typedef struct vpx_image vpx_image_t; |
12 | 12 |
13 namespace remoting { | 13 namespace remoting { |
14 | 14 |
15 class DecoderVp8 : public Decoder { | 15 class DecoderVp8 : public Decoder { |
16 public: | 16 public: |
17 DecoderVp8(); | 17 DecoderVp8(); |
18 virtual ~DecoderVp8(); | 18 virtual ~DecoderVp8(); |
19 | 19 |
20 // Decoder implementations. | 20 // Decoder implementations. |
21 virtual void Initialize(scoped_refptr<media::VideoFrame> frame) OVERRIDE; | 21 virtual void Initialize(scoped_refptr<media::VideoFrame> frame) OVERRIDE; |
22 virtual DecodeResult DecodePacket(const VideoPacket* packet) OVERRIDE; | 22 virtual DecodeResult DecodePacket(const VideoPacket* packet) OVERRIDE; |
23 virtual void GetUpdatedRects(RectVector* rects) OVERRIDE; | 23 virtual void GetUpdatedRegion(SkRegion* region) OVERRIDE; |
24 virtual bool IsReadyForData() OVERRIDE; | 24 virtual bool IsReadyForData() OVERRIDE; |
25 virtual void Reset() OVERRIDE; | 25 virtual void Reset() OVERRIDE; |
26 virtual VideoPacketFormat::Encoding Encoding() OVERRIDE; | 26 virtual VideoPacketFormat::Encoding Encoding() OVERRIDE; |
27 virtual void SetOutputSize(const SkISize& size) OVERRIDE; | 27 virtual void SetOutputSize(const SkISize& size) OVERRIDE; |
28 virtual void SetClipRect(const SkIRect& clip_rect) OVERRIDE; | 28 virtual void SetClipRect(const SkIRect& clip_rect) OVERRIDE; |
29 virtual void RefreshRects(const RectVector& rects) OVERRIDE; | 29 virtual void RefreshRegion(const SkRegion& region) OVERRIDE; |
30 | 30 |
31 private: | 31 private: |
32 enum State { | 32 enum State { |
33 kUninitialized, | 33 kUninitialized, |
34 kReady, | 34 kReady, |
35 kError, | 35 kError, |
36 }; | 36 }; |
37 | 37 |
38 // Return true if scaling is enabled | 38 // Return true if scaling is enabled |
39 bool DoScaling() const; | 39 bool DoScaling() const; |
40 | 40 |
41 // Perform color space conversion on the specified rectangles. | 41 // Perform color space conversion on the specified region. |
42 // Write the updated rectangles to |output_rects|. | 42 // Writes the updated region to |output_region|. |
43 void ConvertRects(const RectVector& rects, | 43 void ConvertRegion(const SkRegion& region, |
44 RectVector* output_rects); | 44 SkRegion* output_region); |
45 | 45 |
46 // Perform scaling and color space conversion on the specified | 46 // Perform scaling and color space conversion on the specified |
47 // rectangles. | 47 // region. Writes the updated rectangles to |output_region|. |
48 // Write the updated rectangles to |output_rects|. | 48 void ScaleAndConvertRegion(const SkRegion& region, |
49 void ScaleAndConvertRects(const RectVector& rects, | 49 SkRegion* output_region); |
50 RectVector* output_rects); | |
51 | 50 |
52 // The internal state of the decoder. | 51 // The internal state of the decoder. |
53 State state_; | 52 State state_; |
54 | 53 |
55 // The video frame to write to. | 54 // The video frame to write to. |
56 scoped_refptr<media::VideoFrame> frame_; | 55 scoped_refptr<media::VideoFrame> frame_; |
57 | 56 |
58 vpx_codec_ctx_t* codec_; | 57 vpx_codec_ctx_t* codec_; |
59 | 58 |
60 // Pointer to the last decoded image. | 59 // Pointer to the last decoded image. |
61 vpx_image_t* last_image_; | 60 vpx_image_t* last_image_; |
62 | 61 |
63 // Record the updated rects in the last decode. | 62 // The region updated by the most recent decode. |
64 RectVector updated_rects_; | 63 SkRegion updated_region_; |
65 | 64 |
66 // Clipping rect for the output of the decoder. | 65 // Clipping rect for the output of the decoder. |
67 SkIRect clip_rect_; | 66 SkIRect clip_rect_; |
68 | 67 |
69 // Output dimensions. | 68 // Output dimensions. |
70 SkISize output_size_; | 69 SkISize output_size_; |
71 | 70 |
72 DISALLOW_COPY_AND_ASSIGN(DecoderVp8); | 71 DISALLOW_COPY_AND_ASSIGN(DecoderVp8); |
73 }; | 72 }; |
74 | 73 |
75 } // namespace remoting | 74 } // namespace remoting |
76 | 75 |
77 #endif // REMOTING_BASE_DECODER_VP8_H_ | 76 #endif // REMOTING_BASE_DECODER_VP8_H_ |
OLD | NEW |