Chromium Code Reviews| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 103 SetError(); | 103 SetError(); |
| 104 return kDecodeError; | 104 return kDecodeError; |
| 105 } | 105 } |
| 106 | 106 |
| 107 curr_frame_hdr_.reset(); | 107 curr_frame_hdr_.reset(); |
| 108 continue; | 108 continue; |
| 109 } | 109 } |
| 110 | 110 |
| 111 gfx::Size new_pic_size(curr_frame_hdr_->frame_width, | 111 gfx::Size new_pic_size(curr_frame_hdr_->frame_width, |
| 112 curr_frame_hdr_->frame_height); | 112 curr_frame_hdr_->frame_height); |
| 113 gfx::Rect new_render_rect(curr_frame_hdr_->render_width, | |
| 114 curr_frame_hdr_->render_height); | |
| 113 DCHECK(!new_pic_size.IsEmpty()); | 115 DCHECK(!new_pic_size.IsEmpty()); |
| 116 DCHECK(!new_render_rect.IsEmpty()); | |
| 114 | 117 |
| 115 if (new_pic_size != pic_size_) { | 118 if (new_pic_size != pic_size_ || new_render_rect != render_rect_) { |
|
Owen Lin
2017/06/07 06:11:00
Same, we don't care about the visible crop here.
johnylin1
2017/06/07 15:38:37
Done.
| |
| 116 DVLOG(1) << "New resolution: " << new_pic_size.ToString(); | 119 DVLOG(1) << "New resolution: " << new_pic_size.ToString() |
| 120 << ", New render resolution: " << new_render_rect.ToString(); | |
| 117 | 121 |
| 118 if (!curr_frame_hdr_->IsKeyframe()) { | 122 if (!curr_frame_hdr_->IsKeyframe()) { |
| 119 // TODO(posciak): This is doable, but requires a few modifications to | 123 // TODO(posciak): This is doable, but requires a few modifications to |
| 120 // VDA implementations to allow multiple picture buffer sets in flight. | 124 // VDA implementations to allow multiple picture buffer sets in flight. |
| 121 DVLOG(1) << "Resolution change currently supported for keyframes only"; | 125 DVLOG(1) << "Resolution change currently supported for keyframes only"; |
| 122 SetError(); | 126 SetError(); |
| 123 return kDecodeError; | 127 return kDecodeError; |
| 124 } | 128 } |
| 125 | 129 |
| 126 // TODO(posciak): This requires us to be on a keyframe (see above) and is | 130 // TODO(posciak): This requires us to be on a keyframe (see above) and is |
| 127 // required, because VDA clients expect all surfaces to be returned before | 131 // required, because VDA clients expect all surfaces to be returned before |
| 128 // they can cycle surface sets after receiving kAllocateNewSurfaces. | 132 // they can cycle surface sets after receiving kAllocateNewSurfaces. |
| 129 // This is only an implementation detail of VDAs and can be improved. | 133 // This is only an implementation detail of VDAs and can be improved. |
| 130 for (auto& ref_frame : ref_frames_) | 134 for (auto& ref_frame : ref_frames_) |
| 131 ref_frame = nullptr; | 135 ref_frame = nullptr; |
| 132 | 136 |
| 133 pic_size_ = new_pic_size; | 137 pic_size_ = new_pic_size; |
| 138 render_rect_ = new_render_rect; | |
| 134 return kAllocateNewSurfaces; | 139 return kAllocateNewSurfaces; |
| 135 } | 140 } |
| 136 | 141 |
| 137 scoped_refptr<VP9Picture> pic = accelerator_->CreateVP9Picture(); | 142 scoped_refptr<VP9Picture> pic = accelerator_->CreateVP9Picture(); |
| 138 if (!pic) | 143 if (!pic) |
| 139 return kRanOutOfSurfaces; | 144 return kRanOutOfSurfaces; |
| 140 | 145 |
| 141 pic->frame_hdr.reset(curr_frame_hdr_.release()); | 146 pic->frame_hdr.reset(curr_frame_hdr_.release()); |
| 142 | 147 |
| 143 if (!DecodeAndOutputPicture(pic)) { | 148 if (!DecodeAndOutputPicture(pic)) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 197 | 202 |
| 198 void VP9Decoder::SetError() { | 203 void VP9Decoder::SetError() { |
| 199 Reset(); | 204 Reset(); |
| 200 state_ = kError; | 205 state_ = kError; |
| 201 } | 206 } |
| 202 | 207 |
| 203 gfx::Size VP9Decoder::GetPicSize() const { | 208 gfx::Size VP9Decoder::GetPicSize() const { |
| 204 return pic_size_; | 209 return pic_size_; |
| 205 } | 210 } |
| 206 | 211 |
| 212 gfx::Rect VP9Decoder::GetVisibleRect() const { | |
| 213 return render_rect_; | |
| 214 } | |
| 215 | |
| 207 size_t VP9Decoder::GetRequiredNumOfPictures() const { | 216 size_t VP9Decoder::GetRequiredNumOfPictures() const { |
| 208 // kMaxVideoFrames to keep higher level media pipeline populated, +2 for the | 217 // kMaxVideoFrames to keep higher level media pipeline populated, +2 for the |
| 209 // pictures being parsed and decoded currently. | 218 // pictures being parsed and decoded currently. |
| 210 return limits::kMaxVideoFrames + kVp9NumRefFrames + 2; | 219 return limits::kMaxVideoFrames + kVp9NumRefFrames + 2; |
| 211 } | 220 } |
| 212 | 221 |
| 213 } // namespace media | 222 } // namespace media |
| OLD | NEW |