[email protected] | 5068614 | 2011-02-04 02:08:32 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
[email protected] | 622b788 | 2010-09-29 17:34:32 | [diff] [blame] | 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 REMOTING_BASE_DECODER_VP8_H_ | ||||
6 | #define REMOTING_BASE_DECODER_VP8_H_ | ||||
7 | |||||
8 | #include "remoting/base/decoder.h" | ||||
9 | |||||
10 | typedef struct vpx_codec_ctx vpx_codec_ctx_t; | ||||
[email protected] | 47379e9 | 2011-07-26 15:33:15 | [diff] [blame] | 11 | typedef struct vpx_image vpx_image_t; |
[email protected] | 622b788 | 2010-09-29 17:34:32 | [diff] [blame] | 12 | |
13 | namespace remoting { | ||||
14 | |||||
15 | class DecoderVp8 : public Decoder { | ||||
16 | public: | ||||
17 | DecoderVp8(); | ||||
[email protected] | 04b3614 | 2010-11-02 01:08:19 | [diff] [blame] | 18 | virtual ~DecoderVp8(); |
[email protected] | 622b788 | 2010-09-29 17:34:32 | [diff] [blame] | 19 | |
20 | // Decoder implementations. | ||||
[email protected] | bcad268 | 2011-09-30 20:35:26 | [diff] [blame] | 21 | virtual void Initialize(scoped_refptr<media::VideoFrame> frame) OVERRIDE; |
22 | virtual DecodeResult DecodePacket(const VideoPacket* packet) OVERRIDE; | ||||
23 | virtual void GetUpdatedRects(RectVector* rects) OVERRIDE; | ||||
24 | virtual bool IsReadyForData() OVERRIDE; | ||||
25 | virtual void Reset() OVERRIDE; | ||||
26 | virtual VideoPacketFormat::Encoding Encoding() OVERRIDE; | ||||
27 | virtual void SetScaleRatios(double horizontal_ratio, | ||||
28 | double vertical_ratio) OVERRIDE; | ||||
29 | virtual void SetClipRect(const SkIRect& clip_rect) OVERRIDE; | ||||
30 | virtual void RefreshRects(const RectVector& rects) OVERRIDE; | ||||
[email protected] | 622b788 | 2010-09-29 17:34:32 | [diff] [blame] | 31 | |
32 | private: | ||||
[email protected] | 04b3614 | 2010-11-02 01:08:19 | [diff] [blame] | 33 | enum State { |
34 | kUninitialized, | ||||
35 | kReady, | ||||
36 | kError, | ||||
37 | }; | ||||
[email protected] | 622b788 | 2010-09-29 17:34:32 | [diff] [blame] | 38 | |
[email protected] | 47379e9 | 2011-07-26 15:33:15 | [diff] [blame] | 39 | // Return true if scaling is enabled |
40 | bool DoScaling() const; | ||||
41 | |||||
42 | // Perform color space conversion on the specified rectangles. | ||||
43 | // Write the updated rectangles to |output_rects|. | ||||
[email protected] | bcad268 | 2011-09-30 20:35:26 | [diff] [blame] | 44 | void ConvertRects(const RectVector& rects, |
45 | RectVector* output_rects); | ||||
[email protected] | 47379e9 | 2011-07-26 15:33:15 | [diff] [blame] | 46 | |
47 | // Perform scaling and color space conversion on the specified | ||||
48 | // rectangles. | ||||
49 | // Write the updated rectangles to |output_rects|. | ||||
[email protected] | bcad268 | 2011-09-30 20:35:26 | [diff] [blame] | 50 | void ScaleAndConvertRects(const RectVector& rects, |
51 | RectVector* output_rects); | ||||
[email protected] | 47379e9 | 2011-07-26 15:33:15 | [diff] [blame] | 52 | |
[email protected] | 622b788 | 2010-09-29 17:34:32 | [diff] [blame] | 53 | // The internal state of the decoder. |
54 | State state_; | ||||
55 | |||||
[email protected] | 622b788 | 2010-09-29 17:34:32 | [diff] [blame] | 56 | // The video frame to write to. |
57 | scoped_refptr<media::VideoFrame> frame_; | ||||
[email protected] | 622b788 | 2010-09-29 17:34:32 | [diff] [blame] | 58 | |
59 | vpx_codec_ctx_t* codec_; | ||||
60 | |||||
[email protected] | 47379e9 | 2011-07-26 15:33:15 | [diff] [blame] | 61 | // Pointer to the last decoded image. |
62 | vpx_image_t* last_image_; | ||||
63 | |||||
[email protected] | 5068614 | 2011-02-04 02:08:32 | [diff] [blame] | 64 | // Record the updated rects in the last decode. |
[email protected] | bcad268 | 2011-09-30 20:35:26 | [diff] [blame] | 65 | RectVector updated_rects_; |
[email protected] | 5068614 | 2011-02-04 02:08:32 | [diff] [blame] | 66 | |
[email protected] | 47379e9 | 2011-07-26 15:33:15 | [diff] [blame] | 67 | // Clipping rect for the output of the decoder. |
[email protected] | bcad268 | 2011-09-30 20:35:26 | [diff] [blame] | 68 | SkIRect clip_rect_; |
[email protected] | 47379e9 | 2011-07-26 15:33:15 | [diff] [blame] | 69 | |
70 | // Scale factors of the decoded output. | ||||
71 | double horizontal_scale_ratio_; | ||||
72 | double vertical_scale_ratio_; | ||||
73 | |||||
[email protected] | 622b788 | 2010-09-29 17:34:32 | [diff] [blame] | 74 | DISALLOW_COPY_AND_ASSIGN(DecoderVp8); |
75 | }; | ||||
76 | |||||
77 | } // namespace remoting | ||||
78 | |||||
79 | #endif // REMOTING_BASE_DECODER_VP8_H_ |