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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 curr_frame_hdr_.reset(new 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::Rect new_visible_rect(curr_frame_hdr_->width, curr_frame_hdr_->height); |
69 if (new_pic_size.IsEmpty()) | 69 if (new_visible_rect.IsEmpty()) |
70 return kDecodeError; | 70 return kDecodeError; |
71 visible_rect_ = new_visible_rect; | |
72 DVLOG(2) << "Visible size: " << visible_rect_.ToString(); | |
73 | |
74 // Per spec, frame size is not necessarily evenly divisible by 16, while | |
75 // frame is encoded by 16x16 macroblock units. Add excess width and height | |
76 // to be divisible by 16. | |
77 uint16_t coded_width = | |
Owen Lin
2017/06/14 02:28:25
You may use base::bits::Align.
https://cs.chromiu
johnylin1
2017/06/14 14:11:22
Sounds good to me. Let's create another CL then.
| |
78 (curr_frame_hdr_->width & 15) | |
79 ? curr_frame_hdr_->width + 16 - (curr_frame_hdr_->width & 15) | |
80 : curr_frame_hdr_->width; | |
81 uint16_t coded_height = | |
82 (curr_frame_hdr_->height & 15) | |
83 ? curr_frame_hdr_->height + 16 - (curr_frame_hdr_->height & 15) | |
84 : curr_frame_hdr_->height; | |
85 gfx::Size new_pic_size(coded_width, coded_height); | |
71 | 86 |
72 if (new_pic_size != pic_size_) { | 87 if (new_pic_size != pic_size_) { |
73 DVLOG(2) << "New resolution: " << new_pic_size.ToString(); | 88 DVLOG(2) << "New resolution: " << new_pic_size.ToString(); |
74 pic_size_ = new_pic_size; | 89 pic_size_ = new_pic_size; |
75 | 90 |
76 DCHECK(!curr_pic_); | 91 DCHECK(!curr_pic_); |
77 last_frame_ = nullptr; | 92 last_frame_ = nullptr; |
78 golden_frame_ = nullptr; | 93 golden_frame_ = nullptr; |
79 alt_frame_ = nullptr; | 94 alt_frame_ = nullptr; |
80 | 95 |
81 return kAllocateNewSurfaces; | 96 return kAllocateNewSurfaces; |
82 } | 97 } |
83 | 98 |
84 state_ = kDecoding; | 99 state_ = kDecoding; |
85 } else { | 100 } else { |
86 if (state_ != kDecoding) { | 101 if (state_ != kDecoding) { |
87 // Need a resume point. | 102 // Need a resume point. |
88 curr_frame_hdr_.reset(); | 103 curr_frame_hdr_.reset(); |
89 return kRanOutOfStreamData; | 104 return kRanOutOfStreamData; |
90 } | 105 } |
91 } | 106 } |
92 | 107 |
93 curr_pic_ = accelerator_->CreateVP8Picture(); | 108 curr_pic_ = accelerator_->CreateVP8Picture(); |
94 if (!curr_pic_) | 109 if (!curr_pic_) |
95 return kRanOutOfSurfaces; | 110 return kRanOutOfSurfaces; |
96 | 111 |
112 curr_pic_->visible_rect = visible_rect_; | |
97 if (!DecodeAndOutputCurrentFrame()) | 113 if (!DecodeAndOutputCurrentFrame()) |
98 return kDecodeError; | 114 return kDecodeError; |
99 | 115 |
100 return kRanOutOfStreamData; | 116 return kRanOutOfStreamData; |
101 } | 117 } |
102 | 118 |
103 void VP8Decoder::RefreshReferenceFrames() { | 119 void VP8Decoder::RefreshReferenceFrames() { |
104 if (curr_frame_hdr_->IsKeyframe()) { | 120 if (curr_frame_hdr_->IsKeyframe()) { |
105 last_frame_ = curr_pic_; | 121 last_frame_ = curr_pic_; |
106 golden_frame_ = curr_pic_; | 122 golden_frame_ = curr_pic_; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
185 return pic_size_; | 201 return pic_size_; |
186 } | 202 } |
187 | 203 |
188 size_t VP8Decoder::GetRequiredNumOfPictures() const { | 204 size_t VP8Decoder::GetRequiredNumOfPictures() const { |
189 const size_t kVP8NumFramesActive = 4; | 205 const size_t kVP8NumFramesActive = 4; |
190 const size_t kPicsInPipeline = limits::kMaxVideoFrames + 2; | 206 const size_t kPicsInPipeline = limits::kMaxVideoFrames + 2; |
191 return kVP8NumFramesActive + kPicsInPipeline; | 207 return kVP8NumFramesActive + kPicsInPipeline; |
192 } | 208 } |
193 | 209 |
194 } // namespace media | 210 } // namespace media |
OLD | NEW |