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/vp9_decoder.h" | 5 #include "media/gpu/vp9_decoder.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 // This frame header only instructs us to display one of the | 92 // This frame header only instructs us to display one of the |
93 // previously-decoded frames, but has no frame data otherwise. Display | 93 // previously-decoded frames, but has no frame data otherwise. Display |
94 // and continue decoding subsequent frames. | 94 // and continue decoding subsequent frames. |
95 size_t frame_to_show = curr_frame_hdr_->frame_to_show_map_idx; | 95 size_t frame_to_show = curr_frame_hdr_->frame_to_show_map_idx; |
96 if (frame_to_show >= ref_frames_.size() || !ref_frames_[frame_to_show]) { | 96 if (frame_to_show >= ref_frames_.size() || !ref_frames_[frame_to_show]) { |
97 DVLOG(1) << "Request to show an invalid frame"; | 97 DVLOG(1) << "Request to show an invalid frame"; |
98 SetError(); | 98 SetError(); |
99 return kDecodeError; | 99 return kDecodeError; |
100 } | 100 } |
101 | 101 |
102 if (!accelerator_->OutputPicture(ref_frames_[frame_to_show])) { | 102 if (!accelerator_->OutputPicture(ref_frames_[frame_to_show], |
103 render_rect_)) { | |
103 SetError(); | 104 SetError(); |
104 return kDecodeError; | 105 return kDecodeError; |
105 } | 106 } |
106 | 107 |
107 curr_frame_hdr_.reset(); | 108 curr_frame_hdr_.reset(); |
108 continue; | 109 continue; |
109 } | 110 } |
110 | 111 |
111 gfx::Size new_pic_size(curr_frame_hdr_->frame_width, | 112 gfx::Size new_pic_size(curr_frame_hdr_->frame_width, |
112 curr_frame_hdr_->frame_height); | 113 curr_frame_hdr_->frame_height); |
113 DCHECK(!new_pic_size.IsEmpty()); | 114 DCHECK(!new_pic_size.IsEmpty()); |
114 | 115 |
116 gfx::Rect new_render_rect; | |
117 // Due to specification render size should be set as not larger than frame | |
118 // size, or set as frame size if render_and_frame_size_different == 0. For | |
119 // safety we check the validity of render size or leave it as (0, 0). | |
120 if (curr_frame_hdr_->render_width > 0 && | |
Pawel Osciak
2017/06/08 04:58:25
Perhaps:
gfx::Rect new_render_rect(curr_frame_hdr
johnylin1
2017/06/12 13:41:53
Done.
| |
121 curr_frame_hdr_->render_width <= curr_frame_hdr_->frame_width && | |
122 curr_frame_hdr_->render_height > 0 && | |
123 curr_frame_hdr_->render_height <= curr_frame_hdr_->frame_height) { | |
124 new_render_rect.SetRect(0, 0, curr_frame_hdr_->render_width, | |
125 curr_frame_hdr_->render_height); | |
126 } | |
127 if (new_render_rect != render_rect_) { | |
128 DVLOG(1) << "New render resolution: " << new_render_rect.ToString(); | |
129 render_rect_ = new_render_rect; | |
130 } | |
131 | |
115 if (new_pic_size != pic_size_) { | 132 if (new_pic_size != pic_size_) { |
116 DVLOG(1) << "New resolution: " << new_pic_size.ToString(); | 133 DVLOG(1) << "New resolution: " << new_pic_size.ToString(); |
117 | 134 |
118 if (!curr_frame_hdr_->IsKeyframe()) { | 135 if (!curr_frame_hdr_->IsKeyframe()) { |
119 // TODO(posciak): This is doable, but requires a few modifications to | 136 // TODO(posciak): This is doable, but requires a few modifications to |
120 // VDA implementations to allow multiple picture buffer sets in flight. | 137 // VDA implementations to allow multiple picture buffer sets in flight. |
121 DVLOG(1) << "Resolution change currently supported for keyframes only"; | 138 DVLOG(1) << "Resolution change currently supported for keyframes only"; |
122 SetError(); | 139 SetError(); |
123 return kDecodeError; | 140 return kDecodeError; |
124 } | 141 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
180 if (!context_refresh_cb.is_null()) | 197 if (!context_refresh_cb.is_null()) |
181 done_cb = base::Bind(&VP9Decoder::UpdateFrameContext, | 198 done_cb = base::Bind(&VP9Decoder::UpdateFrameContext, |
182 base::Unretained(this), pic, context_refresh_cb); | 199 base::Unretained(this), pic, context_refresh_cb); |
183 | 200 |
184 const Vp9Parser::Context& context = parser_.context(); | 201 const Vp9Parser::Context& context = parser_.context(); |
185 if (!accelerator_->SubmitDecode(pic, context.segmentation(), | 202 if (!accelerator_->SubmitDecode(pic, context.segmentation(), |
186 context.loop_filter(), ref_frames_, done_cb)) | 203 context.loop_filter(), ref_frames_, done_cb)) |
187 return false; | 204 return false; |
188 | 205 |
189 if (pic->frame_hdr->show_frame) { | 206 if (pic->frame_hdr->show_frame) { |
190 if (!accelerator_->OutputPicture(pic)) | 207 if (!accelerator_->OutputPicture(pic, render_rect_)) |
191 return false; | 208 return false; |
192 } | 209 } |
193 | 210 |
194 RefreshReferenceFrames(pic); | 211 RefreshReferenceFrames(pic); |
195 return true; | 212 return true; |
196 } | 213 } |
197 | 214 |
198 void VP9Decoder::SetError() { | 215 void VP9Decoder::SetError() { |
199 Reset(); | 216 Reset(); |
200 state_ = kError; | 217 state_ = kError; |
201 } | 218 } |
202 | 219 |
203 gfx::Size VP9Decoder::GetPicSize() const { | 220 gfx::Size VP9Decoder::GetPicSize() const { |
204 return pic_size_; | 221 return pic_size_; |
205 } | 222 } |
206 | 223 |
207 size_t VP9Decoder::GetRequiredNumOfPictures() const { | 224 size_t VP9Decoder::GetRequiredNumOfPictures() const { |
208 // kMaxVideoFrames to keep higher level media pipeline populated, +2 for the | 225 // kMaxVideoFrames to keep higher level media pipeline populated, +2 for the |
209 // pictures being parsed and decoded currently. | 226 // pictures being parsed and decoded currently. |
210 return limits::kMaxVideoFrames + kVp9NumRefFrames + 2; | 227 return limits::kMaxVideoFrames + kVp9NumRefFrames + 2; |
211 } | 228 } |
212 | 229 |
213 } // namespace media | 230 } // namespace media |
OLD | NEW |