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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 DCHECK(!new_pic_size.IsEmpty()); | 113 DCHECK(!new_pic_size.IsEmpty()); |
| 114 | 114 |
| 115 gfx::Rect new_render_rect(curr_frame_hdr_->render_width, | |
|
Pawel Osciak
2017/06/16 07:14:01
Perhaps move this to after new_pic_size checks and
johnylin1
2017/06/16 08:15:10
Done.
| |
| 116 curr_frame_hdr_->render_height); | |
| 117 // For safety, check the validity of render size or leave it as (0, 0). | |
| 118 if (!gfx::Rect(new_pic_size).Contains(new_render_rect)) | |
| 119 new_render_rect = gfx::Rect(); | |
|
Pawel Osciak
2017/06/16 07:14:01
Please add a log for this error.
johnylin1
2017/06/16 08:15:10
Done.
| |
| 120 DVLOG(1) << "Render resolution: " << new_render_rect.ToString(); | |
| 121 | |
| 115 if (new_pic_size != pic_size_) { | 122 if (new_pic_size != pic_size_) { |
| 116 DVLOG(1) << "New resolution: " << new_pic_size.ToString(); | 123 DVLOG(1) << "New resolution: " << new_pic_size.ToString(); |
| 117 | 124 |
| 118 if (!curr_frame_hdr_->IsKeyframe()) { | 125 if (!curr_frame_hdr_->IsKeyframe()) { |
| 119 // TODO(posciak): This is doable, but requires a few modifications to | 126 // TODO(posciak): This is doable, but requires a few modifications to |
| 120 // VDA implementations to allow multiple picture buffer sets in flight. | 127 // VDA implementations to allow multiple picture buffer sets in flight. |
| 121 DVLOG(1) << "Resolution change currently supported for keyframes only"; | 128 DVLOG(1) << "Resolution change currently supported for keyframes only"; |
| 122 SetError(); | 129 SetError(); |
| 123 return kDecodeError; | 130 return kDecodeError; |
| 124 } | 131 } |
| 125 | 132 |
| 126 // TODO(posciak): This requires us to be on a keyframe (see above) and is | 133 // 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 | 134 // required, because VDA clients expect all surfaces to be returned before |
| 128 // they can cycle surface sets after receiving kAllocateNewSurfaces. | 135 // they can cycle surface sets after receiving kAllocateNewSurfaces. |
| 129 // This is only an implementation detail of VDAs and can be improved. | 136 // This is only an implementation detail of VDAs and can be improved. |
| 130 for (auto& ref_frame : ref_frames_) | 137 for (auto& ref_frame : ref_frames_) |
| 131 ref_frame = nullptr; | 138 ref_frame = nullptr; |
| 132 | 139 |
| 133 pic_size_ = new_pic_size; | 140 pic_size_ = new_pic_size; |
| 134 return kAllocateNewSurfaces; | 141 return kAllocateNewSurfaces; |
| 135 } | 142 } |
| 136 | 143 |
| 137 scoped_refptr<VP9Picture> pic = accelerator_->CreateVP9Picture(); | 144 scoped_refptr<VP9Picture> pic = accelerator_->CreateVP9Picture(); |
| 138 if (!pic) | 145 if (!pic) |
| 139 return kRanOutOfSurfaces; | 146 return kRanOutOfSurfaces; |
| 140 | 147 |
| 148 pic->visible_rect = new_render_rect; | |
| 141 pic->frame_hdr.reset(curr_frame_hdr_.release()); | 149 pic->frame_hdr.reset(curr_frame_hdr_.release()); |
| 142 | 150 |
| 143 if (!DecodeAndOutputPicture(pic)) { | 151 if (!DecodeAndOutputPicture(pic)) { |
| 144 SetError(); | 152 SetError(); |
| 145 return kDecodeError; | 153 return kDecodeError; |
| 146 } | 154 } |
| 147 } | 155 } |
| 148 } | 156 } |
| 149 | 157 |
| 150 void VP9Decoder::RefreshReferenceFrames(const scoped_refptr<VP9Picture>& pic) { | 158 void VP9Decoder::RefreshReferenceFrames(const scoped_refptr<VP9Picture>& pic) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 return pic_size_; | 212 return pic_size_; |
| 205 } | 213 } |
| 206 | 214 |
| 207 size_t VP9Decoder::GetRequiredNumOfPictures() const { | 215 size_t VP9Decoder::GetRequiredNumOfPictures() const { |
| 208 // kMaxVideoFrames to keep higher level media pipeline populated, +2 for the | 216 // kMaxVideoFrames to keep higher level media pipeline populated, +2 for the |
| 209 // pictures being parsed and decoded currently. | 217 // pictures being parsed and decoded currently. |
| 210 return limits::kMaxVideoFrames + kVp9NumRefFrames + 2; | 218 return limits::kMaxVideoFrames + kVp9NumRefFrames + 2; |
| 211 } | 219 } |
| 212 | 220 |
| 213 } // namespace media | 221 } // namespace media |
| OLD | NEW |