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 #include "media/gpu/vp8_decoder.h" | 5 #include "media/gpu/vp8_decoder.h" |
6 #include "media/base/limits.h" | 6 #include "media/base/limits.h" |
7 | 7 |
8 namespace media { | 8 namespace media { |
9 | 9 |
10 VP8Decoder::VP8Accelerator::VP8Accelerator() {} | 10 VP8Decoder::VP8Accelerator::VP8Accelerator() {} |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 | 48 |
49 if (state_ == kDecoding) | 49 if (state_ == kDecoding) |
50 state_ = kAfterReset; | 50 state_ = kAfterReset; |
51 } | 51 } |
52 | 52 |
53 VP8Decoder::DecodeResult VP8Decoder::Decode() { | 53 VP8Decoder::DecodeResult VP8Decoder::Decode() { |
54 if (!curr_frame_start_ || frame_size_ == 0) | 54 if (!curr_frame_start_ || frame_size_ == 0) |
55 return kRanOutOfStreamData; | 55 return kRanOutOfStreamData; |
56 | 56 |
57 if (!curr_frame_hdr_) { | 57 if (!curr_frame_hdr_) { |
58 curr_frame_hdr_.reset(new media::Vp8FrameHeader()); | 58 curr_frame_hdr_.reset(new Vp8FrameHeader()); |
59 if (!parser_.ParseFrame(curr_frame_start_, frame_size_, | 59 if (!parser_.ParseFrame(curr_frame_start_, frame_size_, |
60 curr_frame_hdr_.get())) { | 60 curr_frame_hdr_.get())) { |
61 DVLOG(1) << "Error during decode"; | 61 DVLOG(1) << "Error during decode"; |
62 state_ = kError; | 62 state_ = kError; |
63 return kDecodeError; | 63 return kDecodeError; |
64 } | 64 } |
65 } | 65 } |
66 | 66 |
67 if (curr_frame_hdr_->IsKeyframe()) { | 67 if (curr_frame_hdr_->IsKeyframe()) { |
68 gfx::Size new_pic_size(curr_frame_hdr_->width, curr_frame_hdr_->height); | 68 gfx::Size new_pic_size(curr_frame_hdr_->width, curr_frame_hdr_->height); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 } | 109 } |
110 | 110 |
111 // Save current golden since we overwrite it here, | 111 // Save current golden since we overwrite it here, |
112 // but may have to use it to update alt below. | 112 // but may have to use it to update alt below. |
113 scoped_refptr<VP8Picture> curr_golden = golden_frame_; | 113 scoped_refptr<VP8Picture> curr_golden = golden_frame_; |
114 | 114 |
115 if (curr_frame_hdr_->refresh_golden_frame) { | 115 if (curr_frame_hdr_->refresh_golden_frame) { |
116 golden_frame_ = curr_pic_; | 116 golden_frame_ = curr_pic_; |
117 } else { | 117 } else { |
118 switch (curr_frame_hdr_->copy_buffer_to_golden) { | 118 switch (curr_frame_hdr_->copy_buffer_to_golden) { |
119 case media::Vp8FrameHeader::COPY_LAST_TO_GOLDEN: | 119 case Vp8FrameHeader::COPY_LAST_TO_GOLDEN: |
120 DCHECK(last_frame_); | 120 DCHECK(last_frame_); |
121 golden_frame_ = last_frame_; | 121 golden_frame_ = last_frame_; |
122 break; | 122 break; |
123 | 123 |
124 case media::Vp8FrameHeader::COPY_ALT_TO_GOLDEN: | 124 case Vp8FrameHeader::COPY_ALT_TO_GOLDEN: |
125 DCHECK(alt_frame_); | 125 DCHECK(alt_frame_); |
126 golden_frame_ = alt_frame_; | 126 golden_frame_ = alt_frame_; |
127 break; | 127 break; |
128 } | 128 } |
129 } | 129 } |
130 | 130 |
131 if (curr_frame_hdr_->refresh_alternate_frame) { | 131 if (curr_frame_hdr_->refresh_alternate_frame) { |
132 alt_frame_ = curr_pic_; | 132 alt_frame_ = curr_pic_; |
133 } else { | 133 } else { |
134 switch (curr_frame_hdr_->copy_buffer_to_alternate) { | 134 switch (curr_frame_hdr_->copy_buffer_to_alternate) { |
135 case media::Vp8FrameHeader::COPY_LAST_TO_ALT: | 135 case Vp8FrameHeader::COPY_LAST_TO_ALT: |
136 DCHECK(last_frame_); | 136 DCHECK(last_frame_); |
137 alt_frame_ = last_frame_; | 137 alt_frame_ = last_frame_; |
138 break; | 138 break; |
139 | 139 |
140 case media::Vp8FrameHeader::COPY_GOLDEN_TO_ALT: | 140 case Vp8FrameHeader::COPY_GOLDEN_TO_ALT: |
141 DCHECK(curr_golden); | 141 DCHECK(curr_golden); |
142 alt_frame_ = curr_golden; | 142 alt_frame_ = curr_golden; |
143 break; | 143 break; |
144 } | 144 } |
145 } | 145 } |
146 | 146 |
147 if (curr_frame_hdr_->refresh_last) | 147 if (curr_frame_hdr_->refresh_last) |
148 last_frame_ = curr_pic_; | 148 last_frame_ = curr_pic_; |
149 } | 149 } |
150 | 150 |
(...skipping 29 matching lines...) Expand all Loading... |
180 frame_size_ = 0; | 180 frame_size_ = 0; |
181 return true; | 181 return true; |
182 } | 182 } |
183 | 183 |
184 gfx::Size VP8Decoder::GetPicSize() const { | 184 gfx::Size VP8Decoder::GetPicSize() const { |
185 return pic_size_; | 185 return pic_size_; |
186 } | 186 } |
187 | 187 |
188 size_t VP8Decoder::GetRequiredNumOfPictures() const { | 188 size_t VP8Decoder::GetRequiredNumOfPictures() const { |
189 const size_t kVP8NumFramesActive = 4; | 189 const size_t kVP8NumFramesActive = 4; |
190 const size_t kPicsInPipeline = media::limits::kMaxVideoFrames + 2; | 190 const size_t kPicsInPipeline = limits::kMaxVideoFrames + 2; |
191 return kVP8NumFramesActive + kPicsInPipeline; | 191 return kVP8NumFramesActive + kPicsInPipeline; |
192 } | 192 } |
193 | 193 |
194 } // namespace media | 194 } // namespace media |
OLD | NEW |