blob: 7aab0fb0db0138589ccef22a0ccfb4a31bf5ebcc [file] [log] [blame]
[email protected]50686142011-02-04 02:08:321// Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]622b7882010-09-29 17:34:322// 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
10typedef struct vpx_codec_ctx vpx_codec_ctx_t;
[email protected]47379e92011-07-26 15:33:1511typedef struct vpx_image vpx_image_t;
[email protected]622b7882010-09-29 17:34:3212
13namespace remoting {
14
15class DecoderVp8 : public Decoder {
16 public:
17 DecoderVp8();
[email protected]04b36142010-11-02 01:08:1918 virtual ~DecoderVp8();
[email protected]622b7882010-09-29 17:34:3219
20 // Decoder implementations.
[email protected]3adf1b22010-11-09 23:22:2021 virtual void Initialize(scoped_refptr<media::VideoFrame> frame);
22 virtual DecodeResult DecodePacket(const VideoPacket* packet);
23 virtual void GetUpdatedRects(UpdatedRects* rects);
[email protected]04b36142010-11-02 01:08:1924 virtual bool IsReadyForData();
[email protected]3adf1b22010-11-09 23:22:2025 virtual void Reset();
[email protected]04b36142010-11-02 01:08:1926 virtual VideoPacketFormat::Encoding Encoding();
[email protected]47379e92011-07-26 15:33:1527 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]622b7882010-09-29 17:34:3230
31 private:
[email protected]04b36142010-11-02 01:08:1932 enum State {
33 kUninitialized,
34 kReady,
35 kError,
36 };
[email protected]622b7882010-09-29 17:34:3237
[email protected]47379e92011-07-26 15:33:1538 // 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]622b7882010-09-29 17:34:3252 // The internal state of the decoder.
53 State state_;
54
[email protected]622b7882010-09-29 17:34:3255 // The video frame to write to.
56 scoped_refptr<media::VideoFrame> frame_;
[email protected]622b7882010-09-29 17:34:3257
58 vpx_codec_ctx_t* codec_;
59
[email protected]47379e92011-07-26 15:33:1560 // Pointer to the last decoded image.
61 vpx_image_t* last_image_;
62
[email protected]50686142011-02-04 02:08:3263 // Record the updated rects in the last decode.
64 UpdatedRects updated_rects_;
65
[email protected]47379e92011-07-26 15:33:1566 // 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]622b7882010-09-29 17:34:3273 DISALLOW_COPY_AND_ASSIGN(DecoderVp8);
74};
75
76} // namespace remoting
77
78#endif // REMOTING_BASE_DECODER_VP8_H_