OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 MEDIA_GPU_VP8_DECODER_H_ | 5 #ifndef MEDIA_GPU_VP8_DECODER_H_ |
6 #define MEDIA_GPU_VP8_DECODER_H_ | 6 #define MEDIA_GPU_VP8_DECODER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 28 matching lines...) Expand all Loading... |
39 // any new pictures at given time. The decoder is expected to handle | 39 // any new pictures at given time. The decoder is expected to handle |
40 // this situation as normal and return from Decode() with kRanOutOfSurfaces. | 40 // this situation as normal and return from Decode() with kRanOutOfSurfaces. |
41 virtual scoped_refptr<VP8Picture> CreateVP8Picture() = 0; | 41 virtual scoped_refptr<VP8Picture> CreateVP8Picture() = 0; |
42 | 42 |
43 // Submit decode for |pic|, taking as arguments |frame_hdr| with parsed | 43 // Submit decode for |pic|, taking as arguments |frame_hdr| with parsed |
44 // VP8 frame header information for current frame, and using |last_frame|, | 44 // VP8 frame header information for current frame, and using |last_frame|, |
45 // |golden_frame| and |alt_frame| as references, as per VP8 specification. | 45 // |golden_frame| and |alt_frame| as references, as per VP8 specification. |
46 // Note that this runs the decode in hardware. | 46 // Note that this runs the decode in hardware. |
47 // Return true if successful. | 47 // Return true if successful. |
48 virtual bool SubmitDecode(const scoped_refptr<VP8Picture>& pic, | 48 virtual bool SubmitDecode(const scoped_refptr<VP8Picture>& pic, |
49 const media::Vp8FrameHeader* frame_hdr, | 49 const Vp8FrameHeader* frame_hdr, |
50 const scoped_refptr<VP8Picture>& last_frame, | 50 const scoped_refptr<VP8Picture>& last_frame, |
51 const scoped_refptr<VP8Picture>& golden_frame, | 51 const scoped_refptr<VP8Picture>& golden_frame, |
52 const scoped_refptr<VP8Picture>& alt_frame) = 0; | 52 const scoped_refptr<VP8Picture>& alt_frame) = 0; |
53 | 53 |
54 // Schedule output (display) of |pic|. Note that returning from this | 54 // Schedule output (display) of |pic|. Note that returning from this |
55 // method does not mean that |pic| has already been outputted (displayed), | 55 // method does not mean that |pic| has already been outputted (displayed), |
56 // but guarantees that all pictures will be outputted in the same order | 56 // but guarantees that all pictures will be outputted in the same order |
57 // as this method was called for them. Decoder may drop its reference | 57 // as this method was called for them. Decoder may drop its reference |
58 // to |pic| after calling this method. | 58 // to |pic| after calling this method. |
59 // Return true if successful. | 59 // Return true if successful. |
60 virtual bool OutputPicture(const scoped_refptr<VP8Picture>& pic) = 0; | 60 virtual bool OutputPicture(const scoped_refptr<VP8Picture>& pic) = 0; |
61 | 61 |
62 private: | 62 private: |
63 DISALLOW_COPY_AND_ASSIGN(VP8Accelerator); | 63 DISALLOW_COPY_AND_ASSIGN(VP8Accelerator); |
64 }; | 64 }; |
65 | 65 |
66 VP8Decoder(VP8Accelerator* accelerator); | 66 VP8Decoder(VP8Accelerator* accelerator); |
67 ~VP8Decoder() override; | 67 ~VP8Decoder() override; |
68 | 68 |
69 // media::AcceleratedVideoDecoder implementation. | 69 // AcceleratedVideoDecoder implementation. |
70 bool Flush() override WARN_UNUSED_RESULT; | 70 bool Flush() override WARN_UNUSED_RESULT; |
71 void Reset() override; | 71 void Reset() override; |
72 void SetStream(const uint8_t* ptr, size_t size) override; | 72 void SetStream(const uint8_t* ptr, size_t size) override; |
73 DecodeResult Decode() override WARN_UNUSED_RESULT; | 73 DecodeResult Decode() override WARN_UNUSED_RESULT; |
74 gfx::Size GetPicSize() const override; | 74 gfx::Size GetPicSize() const override; |
75 size_t GetRequiredNumOfPictures() const override; | 75 size_t GetRequiredNumOfPictures() const override; |
76 | 76 |
77 private: | 77 private: |
78 bool DecodeAndOutputCurrentFrame(); | 78 bool DecodeAndOutputCurrentFrame(); |
79 void RefreshReferenceFrames(); | 79 void RefreshReferenceFrames(); |
80 | 80 |
81 enum State { | 81 enum State { |
82 kNeedStreamMetadata, // After initialization, need a keyframe. | 82 kNeedStreamMetadata, // After initialization, need a keyframe. |
83 kDecoding, // Ready to decode from any point. | 83 kDecoding, // Ready to decode from any point. |
84 kAfterReset, // After Reset(), need a resume point. | 84 kAfterReset, // After Reset(), need a resume point. |
85 kError, // Error in decode, can't continue. | 85 kError, // Error in decode, can't continue. |
86 }; | 86 }; |
87 | 87 |
88 State state_; | 88 State state_; |
89 | 89 |
90 media::Vp8Parser parser_; | 90 Vp8Parser parser_; |
91 | 91 |
92 std::unique_ptr<media::Vp8FrameHeader> curr_frame_hdr_; | 92 std::unique_ptr<Vp8FrameHeader> curr_frame_hdr_; |
93 scoped_refptr<VP8Picture> curr_pic_; | 93 scoped_refptr<VP8Picture> curr_pic_; |
94 scoped_refptr<VP8Picture> last_frame_; | 94 scoped_refptr<VP8Picture> last_frame_; |
95 scoped_refptr<VP8Picture> golden_frame_; | 95 scoped_refptr<VP8Picture> golden_frame_; |
96 scoped_refptr<VP8Picture> alt_frame_; | 96 scoped_refptr<VP8Picture> alt_frame_; |
97 | 97 |
98 const uint8_t* curr_frame_start_; | 98 const uint8_t* curr_frame_start_; |
99 size_t frame_size_; | 99 size_t frame_size_; |
100 | 100 |
101 gfx::Size pic_size_; | 101 gfx::Size pic_size_; |
102 int horizontal_scale_; | 102 int horizontal_scale_; |
103 int vertical_scale_; | 103 int vertical_scale_; |
104 | 104 |
105 VP8Accelerator* accelerator_; | 105 VP8Accelerator* accelerator_; |
106 | 106 |
107 DISALLOW_COPY_AND_ASSIGN(VP8Decoder); | 107 DISALLOW_COPY_AND_ASSIGN(VP8Decoder); |
108 }; | 108 }; |
109 | 109 |
110 } // namespace media | 110 } // namespace media |
111 | 111 |
112 #endif // MEDIA_GPU_VP8_DECODER_H_ | 112 #endif // MEDIA_GPU_VP8_DECODER_H_ |
OLD | NEW |