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