blob: 33ec147e2790f61fdd209a062607864171479a32 [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]bcad2682011-09-30 20:35:2621 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]622b7882010-09-29 17:34:3231
32 private:
[email protected]04b36142010-11-02 01:08:1933 enum State {
34 kUninitialized,
35 kReady,
36 kError,
37 };
[email protected]622b7882010-09-29 17:34:3238
[email protected]47379e92011-07-26 15:33:1539 // 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]bcad2682011-09-30 20:35:2644 void ConvertRects(const RectVector& rects,
45 RectVector* output_rects);
[email protected]47379e92011-07-26 15:33:1546
47 // Perform scaling and color space conversion on the specified
48 // rectangles.
49 // Write the updated rectangles to |output_rects|.
[email protected]bcad2682011-09-30 20:35:2650 void ScaleAndConvertRects(const RectVector& rects,
51 RectVector* output_rects);
[email protected]47379e92011-07-26 15:33:1552
[email protected]622b7882010-09-29 17:34:3253 // The internal state of the decoder.
54 State state_;
55
[email protected]622b7882010-09-29 17:34:3256 // The video frame to write to.
57 scoped_refptr<media::VideoFrame> frame_;
[email protected]622b7882010-09-29 17:34:3258
59 vpx_codec_ctx_t* codec_;
60
[email protected]47379e92011-07-26 15:33:1561 // Pointer to the last decoded image.
62 vpx_image_t* last_image_;
63
[email protected]50686142011-02-04 02:08:3264 // Record the updated rects in the last decode.
[email protected]bcad2682011-09-30 20:35:2665 RectVector updated_rects_;
[email protected]50686142011-02-04 02:08:3266
[email protected]47379e92011-07-26 15:33:1567 // Clipping rect for the output of the decoder.
[email protected]bcad2682011-09-30 20:35:2668 SkIRect clip_rect_;
[email protected]47379e92011-07-26 15:33:1569
70 // Scale factors of the decoded output.
71 double horizontal_scale_ratio_;
72 double vertical_scale_ratio_;
73
[email protected]622b7882010-09-29 17:34:3274 DISALLOW_COPY_AND_ASSIGN(DecoderVp8);
75};
76
77} // namespace remoting
78
79#endif // REMOTING_BASE_DECODER_VP8_H_