posciak | d94b2b08 | 2015-09-18 04:03:40 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
markdittmer | 6e70beb8 | 2016-05-02 05:40:47 | [diff] [blame] | 5 | #include "media/gpu/vp9_decoder.h" |
mostynb | 6682b1c4 | 2016-04-19 10:17:30 | [diff] [blame] | 6 | |
| 7 | #include <memory> |
| 8 | |
posciak | 77118c9 | 2016-08-28 13:18:39 | [diff] [blame] | 9 | #include "base/bind.h" |
Hirokazu Honda | 10df95d | 2019-07-19 19:31:43 | [diff] [blame] | 10 | #include "base/feature_list.h" |
mostynb | 6682b1c4 | 2016-04-19 10:17:30 | [diff] [blame] | 11 | #include "base/logging.h" |
Hirokazu Honda | 967b919 | 2019-08-27 00:59:42 | [diff] [blame] | 12 | #include "build/build_config.h" |
posciak | d94b2b08 | 2015-09-18 04:03:40 | [diff] [blame] | 13 | #include "media/base/limits.h" |
Hirokazu Honda | 10df95d | 2019-07-19 19:31:43 | [diff] [blame] | 14 | #include "media/base/media_switches.h" |
markdittmer | 6e70beb8 | 2016-05-02 05:40:47 | [diff] [blame] | 15 | #include "media/gpu/vp9_decoder.h" |
posciak | d94b2b08 | 2015-09-18 04:03:40 | [diff] [blame] | 16 | |
markdittmer | 6e70beb8 | 2016-05-02 05:40:47 | [diff] [blame] | 17 | namespace media { |
posciak | d94b2b08 | 2015-09-18 04:03:40 | [diff] [blame] | 18 | |
Hirokazu Honda | 10df95d | 2019-07-19 19:31:43 | [diff] [blame] | 19 | namespace { |
| 20 | std::vector<uint32_t> GetSpatialLayerFrameSize( |
| 21 | const DecoderBuffer& decoder_buffer) { |
Hirokazu Honda | 967b919 | 2019-08-27 00:59:42 | [diff] [blame] | 22 | #if defined(ARCH_CPU_X86_FAMILY) && defined(OS_CHROMEOS) |
Hirokazu Honda | 10df95d | 2019-07-19 19:31:43 | [diff] [blame] | 23 | const uint32_t* cue_data = |
| 24 | reinterpret_cast<const uint32_t*>(decoder_buffer.side_data()); |
| 25 | if (!cue_data) |
| 26 | return {}; |
| 27 | if (!base::FeatureList::IsEnabled(media::kVp9kSVCHWDecoding)) { |
| 28 | DLOG(ERROR) << "Vp9Parser doesn't support parsing SVC stream"; |
| 29 | return {}; |
| 30 | } |
| 31 | |
| 32 | size_t num_of_layers = decoder_buffer.side_data_size() / sizeof(uint32_t); |
| 33 | if (num_of_layers > 3u) { |
| 34 | DLOG(WARNING) << "The maximum number of spatial layers in VP9 is three"; |
| 35 | return {}; |
| 36 | } |
| 37 | return std::vector<uint32_t>(cue_data, cue_data + num_of_layers); |
Hirokazu Honda | 967b919 | 2019-08-27 00:59:42 | [diff] [blame] | 38 | #endif // defined(ARCH_CPU_X86_FAMILY) && defined(OS_CHROMEOS) |
| 39 | return {}; |
Hirokazu Honda | 10df95d | 2019-07-19 19:31:43 | [diff] [blame] | 40 | } |
Hirokazu Honda | 7ec3265 | 2019-11-22 09:40:21 | [diff] [blame^] | 41 | |
| 42 | VideoCodecProfile VP9ProfileToVideoCodecProfile(uint8_t profile) { |
| 43 | switch (profile) { |
| 44 | case 0: |
| 45 | return VP9PROFILE_PROFILE0; |
| 46 | case 1: |
| 47 | return VP9PROFILE_PROFILE1; |
| 48 | case 2: |
| 49 | return VP9PROFILE_PROFILE2; |
| 50 | case 3: |
| 51 | return VP9PROFILE_PROFILE3; |
| 52 | default: |
| 53 | return VIDEO_CODEC_PROFILE_UNKNOWN; |
| 54 | } |
| 55 | } |
| 56 | |
Hirokazu Honda | 10df95d | 2019-07-19 19:31:43 | [diff] [blame] | 57 | } // namespace |
| 58 | |
posciak | d94b2b08 | 2015-09-18 04:03:40 | [diff] [blame] | 59 | VP9Decoder::VP9Accelerator::VP9Accelerator() {} |
| 60 | |
| 61 | VP9Decoder::VP9Accelerator::~VP9Accelerator() {} |
| 62 | |
Fredrik Hubinette | 3cebc62 | 2018-10-27 01:01:12 | [diff] [blame] | 63 | VP9Decoder::VP9Decoder(std::unique_ptr<VP9Accelerator> accelerator, |
Hirokazu Honda | 7ec3265 | 2019-11-22 09:40:21 | [diff] [blame^] | 64 | VideoCodecProfile profile, |
Fredrik Hubinette | 3cebc62 | 2018-10-27 01:01:12 | [diff] [blame] | 65 | const VideoColorSpace& container_color_space) |
posciak | 77118c9 | 2016-08-28 13:18:39 | [diff] [blame] | 66 | : state_(kNeedStreamMetadata), |
Fredrik Hubinette | 3cebc62 | 2018-10-27 01:01:12 | [diff] [blame] | 67 | container_color_space_(container_color_space), |
Hirokazu Honda | 7ec3265 | 2019-11-22 09:40:21 | [diff] [blame^] | 68 | // TODO(hiroh): Set profile to UNKNOWN. |
| 69 | profile_(profile), |
Miguel Casas | 2d5ecad8 | 2018-02-22 19:03:05 | [diff] [blame] | 70 | accelerator_(std::move(accelerator)), |
Hirokazu Honda | 7ec3265 | 2019-11-22 09:40:21 | [diff] [blame^] | 71 | parser_(accelerator_->IsFrameContextRequired()) {} |
posciak | d94b2b08 | 2015-09-18 04:03:40 | [diff] [blame] | 72 | |
Miguel Casas | 2d5ecad8 | 2018-02-22 19:03:05 | [diff] [blame] | 73 | VP9Decoder::~VP9Decoder() = default; |
posciak | d94b2b08 | 2015-09-18 04:03:40 | [diff] [blame] | 74 | |
Hirokazu Honda | 23132c3 | 2019-07-09 14:31:20 | [diff] [blame] | 75 | void VP9Decoder::SetStream(int32_t id, const DecoderBuffer& decoder_buffer) { |
| 76 | const uint8_t* ptr = decoder_buffer.data(); |
| 77 | const size_t size = decoder_buffer.data_size(); |
| 78 | const DecryptConfig* decrypt_config = decoder_buffer.decrypt_config(); |
| 79 | |
posciak | d94b2b08 | 2015-09-18 04:03:40 | [diff] [blame] | 80 | DCHECK(ptr); |
| 81 | DCHECK(size); |
Pawel Osciak | ec6e21b | 2018-03-19 09:13:06 | [diff] [blame] | 82 | DVLOG(4) << "New input stream id: " << id << " at: " << (void*)ptr |
| 83 | << " size: " << size; |
| 84 | stream_id_ = id; |
Ted Meyer | 0b35c5fd | 2018-11-27 22:29:29 | [diff] [blame] | 85 | if (decrypt_config) { |
Hirokazu Honda | 10df95d | 2019-07-19 19:31:43 | [diff] [blame] | 86 | parser_.SetStream(ptr, size, GetSpatialLayerFrameSize(decoder_buffer), |
| 87 | decrypt_config->Clone()); |
Ted Meyer | 0b35c5fd | 2018-11-27 22:29:29 | [diff] [blame] | 88 | } else { |
Hirokazu Honda | 10df95d | 2019-07-19 19:31:43 | [diff] [blame] | 89 | parser_.SetStream(ptr, size, GetSpatialLayerFrameSize(decoder_buffer), |
| 90 | nullptr); |
Ted Meyer | 0b35c5fd | 2018-11-27 22:29:29 | [diff] [blame] | 91 | } |
posciak | d94b2b08 | 2015-09-18 04:03:40 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | bool VP9Decoder::Flush() { |
| 95 | DVLOG(2) << "Decoder flush"; |
| 96 | Reset(); |
| 97 | return true; |
| 98 | } |
| 99 | |
| 100 | void VP9Decoder::Reset() { |
| 101 | curr_frame_hdr_ = nullptr; |
Sreerenj Balachandran | 1beb548 | 2019-04-03 03:40:05 | [diff] [blame] | 102 | |
| 103 | ref_frames_.Clear(); |
posciak | d94b2b08 | 2015-09-18 04:03:40 | [diff] [blame] | 104 | |
| 105 | parser_.Reset(); |
| 106 | |
| 107 | if (state_ == kDecoding) |
| 108 | state_ = kAfterReset; |
| 109 | } |
| 110 | |
| 111 | VP9Decoder::DecodeResult VP9Decoder::Decode() { |
| 112 | while (1) { |
| 113 | // Read a new frame header if one is not awaiting decoding already. |
Ted Meyer | 0b35c5fd | 2018-11-27 22:29:29 | [diff] [blame] | 114 | std::unique_ptr<DecryptConfig> decrypt_config; |
posciak | d94b2b08 | 2015-09-18 04:03:40 | [diff] [blame] | 115 | if (!curr_frame_hdr_) { |
Hirokazu Honda | 10df95d | 2019-07-19 19:31:43 | [diff] [blame] | 116 | gfx::Size allocate_size; |
xhwang | 60f9667 | 2016-06-14 21:47:53 | [diff] [blame] | 117 | std::unique_ptr<Vp9FrameHeader> hdr(new Vp9FrameHeader()); |
Ted Meyer | 0b35c5fd | 2018-11-27 22:29:29 | [diff] [blame] | 118 | Vp9Parser::Result res = |
Hirokazu Honda | 10df95d | 2019-07-19 19:31:43 | [diff] [blame] | 119 | parser_.ParseNextFrame(hdr.get(), &allocate_size, &decrypt_config); |
posciak | d94b2b08 | 2015-09-18 04:03:40 | [diff] [blame] | 120 | switch (res) { |
xhwang | 60f9667 | 2016-06-14 21:47:53 | [diff] [blame] | 121 | case Vp9Parser::kOk: |
brusi_roy | 8e715596 | 2016-09-14 18:22:58 | [diff] [blame] | 122 | curr_frame_hdr_ = std::move(hdr); |
Hirokazu Honda | 10df95d | 2019-07-19 19:31:43 | [diff] [blame] | 123 | curr_frame_size_ = allocate_size; |
posciak | d94b2b08 | 2015-09-18 04:03:40 | [diff] [blame] | 124 | break; |
| 125 | |
xhwang | 60f9667 | 2016-06-14 21:47:53 | [diff] [blame] | 126 | case Vp9Parser::kEOStream: |
posciak | d94b2b08 | 2015-09-18 04:03:40 | [diff] [blame] | 127 | return kRanOutOfStreamData; |
| 128 | |
xhwang | 60f9667 | 2016-06-14 21:47:53 | [diff] [blame] | 129 | case Vp9Parser::kInvalidStream: |
posciak | d94b2b08 | 2015-09-18 04:03:40 | [diff] [blame] | 130 | DVLOG(1) << "Error parsing stream"; |
| 131 | SetError(); |
| 132 | return kDecodeError; |
kcwu | e5a9a629 | 2016-08-17 03:40:02 | [diff] [blame] | 133 | |
| 134 | case Vp9Parser::kAwaitingRefresh: |
posciak | 77118c9 | 2016-08-28 13:18:39 | [diff] [blame] | 135 | DVLOG(4) << "Awaiting context update"; |
| 136 | return kNeedContextUpdate; |
posciak | d94b2b08 | 2015-09-18 04:03:40 | [diff] [blame] | 137 | } |
| 138 | } |
| 139 | |
| 140 | if (state_ != kDecoding) { |
| 141 | // Not kDecoding, so we need a resume point (a keyframe), as we are after |
| 142 | // reset or at the beginning of the stream. Drop anything that is not |
| 143 | // a keyframe in such case, and continue looking for a keyframe. |
Sreerenj Balachandran | 5716330 | 2018-11-28 02:45:57 | [diff] [blame] | 144 | // Only exception is when the stream/sequence starts with an Intra only |
| 145 | // frame. |
| 146 | if (curr_frame_hdr_->IsKeyframe() || |
| 147 | (curr_frame_hdr_->IsIntra() && pic_size_.IsEmpty())) { |
posciak | d94b2b08 | 2015-09-18 04:03:40 | [diff] [blame] | 148 | state_ = kDecoding; |
| 149 | } else { |
| 150 | curr_frame_hdr_.reset(); |
| 151 | continue; |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | if (curr_frame_hdr_->show_existing_frame) { |
| 156 | // This frame header only instructs us to display one of the |
| 157 | // previously-decoded frames, but has no frame data otherwise. Display |
| 158 | // and continue decoding subsequent frames. |
kcwu | e5a9a629 | 2016-08-17 03:40:02 | [diff] [blame] | 159 | size_t frame_to_show = curr_frame_hdr_->frame_to_show_map_idx; |
Sreerenj Balachandran | 1beb548 | 2019-04-03 03:40:05 | [diff] [blame] | 160 | if (frame_to_show >= kVp9NumRefFrames || |
| 161 | !ref_frames_.GetFrame(frame_to_show)) { |
posciak | d94b2b08 | 2015-09-18 04:03:40 | [diff] [blame] | 162 | DVLOG(1) << "Request to show an invalid frame"; |
| 163 | SetError(); |
| 164 | return kDecodeError; |
| 165 | } |
| 166 | |
Chih-Yu Huang | cd5181e | 2018-10-23 06:33:06 | [diff] [blame] | 167 | // Duplicate the VP9Picture and set the current bitstream id to keep the |
| 168 | // correct timestamp. |
Sreerenj Balachandran | 1beb548 | 2019-04-03 03:40:05 | [diff] [blame] | 169 | scoped_refptr<VP9Picture> pic = |
| 170 | ref_frames_.GetFrame(frame_to_show)->Duplicate(); |
Chih-Yu Huang | cd5181e | 2018-10-23 06:33:06 | [diff] [blame] | 171 | if (pic == nullptr) { |
| 172 | DVLOG(1) << "Failed to duplicate the VP9Picture."; |
| 173 | SetError(); |
| 174 | return kDecodeError; |
| 175 | } |
| 176 | pic->set_bitstream_id(stream_id_); |
| 177 | if (!accelerator_->OutputPicture(std::move(pic))) { |
posciak | d94b2b08 | 2015-09-18 04:03:40 | [diff] [blame] | 178 | SetError(); |
| 179 | return kDecodeError; |
| 180 | } |
| 181 | |
| 182 | curr_frame_hdr_.reset(); |
| 183 | continue; |
| 184 | } |
| 185 | |
Hirokazu Honda | 10df95d | 2019-07-19 19:31:43 | [diff] [blame] | 186 | gfx::Size new_pic_size = curr_frame_size_; |
Hirokazu Honda | 436cf27b | 2019-05-21 10:44:39 | [diff] [blame] | 187 | gfx::Rect new_render_rect(curr_frame_hdr_->render_width, |
| 188 | curr_frame_hdr_->render_height); |
| 189 | // For safety, check the validity of render size or leave it as (0, 0). |
| 190 | if (!gfx::Rect(new_pic_size).Contains(new_render_rect)) { |
| 191 | DVLOG(1) << "Render size exceeds picture size. render size: " |
| 192 | << new_render_rect.ToString() |
| 193 | << ", picture size: " << new_pic_size.ToString(); |
| 194 | new_render_rect = gfx::Rect(); |
| 195 | } |
Hirokazu Honda | 7ec3265 | 2019-11-22 09:40:21 | [diff] [blame^] | 196 | VideoCodecProfile new_profile = |
| 197 | VP9ProfileToVideoCodecProfile(curr_frame_hdr_->profile); |
| 198 | if (new_profile == VIDEO_CODEC_PROFILE_UNKNOWN) { |
| 199 | VLOG(1) << "Invalid profile: " << curr_frame_hdr_->profile; |
| 200 | return kDecodeError; |
| 201 | } |
posciak | d94b2b08 | 2015-09-18 04:03:40 | [diff] [blame] | 202 | |
Hirokazu Honda | 436cf27b | 2019-05-21 10:44:39 | [diff] [blame] | 203 | DCHECK(!new_pic_size.IsEmpty()); |
Hirokazu Honda | 7ec3265 | 2019-11-22 09:40:21 | [diff] [blame^] | 204 | if (new_pic_size != pic_size_ || new_profile != profile_) { |
| 205 | DVLOG(1) << "New profile: " << GetProfileName(new_profile) |
| 206 | << ", New resolution: " << new_pic_size.ToString(); |
posciak | d94b2b08 | 2015-09-18 04:03:40 | [diff] [blame] | 207 | |
Sreerenj Balachandran | 5716330 | 2018-11-28 02:45:57 | [diff] [blame] | 208 | if (!curr_frame_hdr_->IsKeyframe() && |
Hirokazu Honda | 7ec3265 | 2019-11-22 09:40:21 | [diff] [blame^] | 209 | !(curr_frame_hdr_->IsIntra() && pic_size_.IsEmpty())) { |
posciak | d94b2b08 | 2015-09-18 04:03:40 | [diff] [blame] | 210 | // TODO(posciak): This is doable, but requires a few modifications to |
| 211 | // VDA implementations to allow multiple picture buffer sets in flight. |
Dongseong Hwang | 4f20ebb | 2018-06-07 00:28:20 | [diff] [blame] | 212 | // http://crbug.com/832264 |
Sreerenj Balachandran | 5716330 | 2018-11-28 02:45:57 | [diff] [blame] | 213 | DVLOG(1) << "Resolution change currently supported for keyframes and " |
| 214 | "sequence begins with Intra only when there is no prior " |
| 215 | "frames in the context"; |
Dongseong Hwang | 4f20ebb | 2018-06-07 00:28:20 | [diff] [blame] | 216 | if (++size_change_failure_counter_ > kVPxMaxNumOfSizeChangeFailures) { |
| 217 | SetError(); |
| 218 | return kDecodeError; |
| 219 | } |
| 220 | |
| 221 | curr_frame_hdr_.reset(); |
| 222 | return kRanOutOfStreamData; |
posciak | d94b2b08 | 2015-09-18 04:03:40 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | // TODO(posciak): This requires us to be on a keyframe (see above) and is |
| 226 | // required, because VDA clients expect all surfaces to be returned before |
Hirokazu Honda | 7ec3265 | 2019-11-22 09:40:21 | [diff] [blame^] | 227 | // they can cycle surface sets after receiving kConfigChange. |
posciak | d94b2b08 | 2015-09-18 04:03:40 | [diff] [blame] | 228 | // This is only an implementation detail of VDAs and can be improved. |
Sreerenj Balachandran | 1beb548 | 2019-04-03 03:40:05 | [diff] [blame] | 229 | ref_frames_.Clear(); |
posciak | d94b2b08 | 2015-09-18 04:03:40 | [diff] [blame] | 230 | |
| 231 | pic_size_ = new_pic_size; |
Hirokazu Honda | 436cf27b | 2019-05-21 10:44:39 | [diff] [blame] | 232 | visible_rect_ = new_render_rect; |
Hirokazu Honda | 7ec3265 | 2019-11-22 09:40:21 | [diff] [blame^] | 233 | profile_ = new_profile; |
Dongseong Hwang | 4f20ebb | 2018-06-07 00:28:20 | [diff] [blame] | 234 | size_change_failure_counter_ = 0; |
Hirokazu Honda | 7ec3265 | 2019-11-22 09:40:21 | [diff] [blame^] | 235 | return kConfigChange; |
posciak | d94b2b08 | 2015-09-18 04:03:40 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | scoped_refptr<VP9Picture> pic = accelerator_->CreateVP9Picture(); |
| 239 | if (!pic) |
| 240 | return kRanOutOfSurfaces; |
johnylin | 7441087 | 2017-06-19 13:05:30 | [diff] [blame] | 241 | DVLOG(2) << "Render resolution: " << new_render_rect.ToString(); |
| 242 | |
Pawel Osciak | ec6e21b | 2018-03-19 09:13:06 | [diff] [blame] | 243 | pic->set_visible_rect(new_render_rect); |
| 244 | pic->set_bitstream_id(stream_id_); |
Fredrik Hubinette | 3cebc62 | 2018-10-27 01:01:12 | [diff] [blame] | 245 | |
Ted Meyer | 0b35c5fd | 2018-11-27 22:29:29 | [diff] [blame] | 246 | pic->set_decrypt_config(std::move(decrypt_config)); |
| 247 | |
Fredrik Hubinette | 3cebc62 | 2018-10-27 01:01:12 | [diff] [blame] | 248 | // For VP9, container color spaces override video stream color spaces. |
| 249 | if (container_color_space_.IsSpecified()) { |
| 250 | pic->set_colorspace(container_color_space_); |
| 251 | } else if (curr_frame_hdr_) { |
| 252 | pic->set_colorspace(curr_frame_hdr_->GetColorSpace()); |
| 253 | } |
kokihoon | fb941e9 | 2018-07-10 18:04:24 | [diff] [blame] | 254 | pic->frame_hdr = std::move(curr_frame_hdr_); |
posciak | d94b2b08 | 2015-09-18 04:03:40 | [diff] [blame] | 255 | |
| 256 | if (!DecodeAndOutputPicture(pic)) { |
| 257 | SetError(); |
| 258 | return kDecodeError; |
| 259 | } |
| 260 | } |
| 261 | } |
| 262 | |
posciak | 77118c9 | 2016-08-28 13:18:39 | [diff] [blame] | 263 | void VP9Decoder::UpdateFrameContext( |
Ted Meyer | 4fac4f6 | 2019-05-08 22:57:15 | [diff] [blame] | 264 | scoped_refptr<VP9Picture> pic, |
posciak | 77118c9 | 2016-08-28 13:18:39 | [diff] [blame] | 265 | const base::Callback<void(const Vp9FrameContext&)>& context_refresh_cb) { |
Dale Curtis | e2516381 | 2018-09-21 22:13:39 | [diff] [blame] | 266 | DCHECK(context_refresh_cb); |
posciak | 77118c9 | 2016-08-28 13:18:39 | [diff] [blame] | 267 | Vp9FrameContext frame_ctx; |
| 268 | memset(&frame_ctx, 0, sizeof(frame_ctx)); |
| 269 | |
Ted Meyer | 4fac4f6 | 2019-05-08 22:57:15 | [diff] [blame] | 270 | if (!accelerator_->GetFrameContext(std::move(pic), &frame_ctx)) { |
posciak | 77118c9 | 2016-08-28 13:18:39 | [diff] [blame] | 271 | SetError(); |
| 272 | return; |
| 273 | } |
| 274 | |
| 275 | context_refresh_cb.Run(frame_ctx); |
| 276 | } |
| 277 | |
posciak | d94b2b08 | 2015-09-18 04:03:40 | [diff] [blame] | 278 | bool VP9Decoder::DecodeAndOutputPicture(scoped_refptr<VP9Picture> pic) { |
| 279 | DCHECK(!pic_size_.IsEmpty()); |
| 280 | DCHECK(pic->frame_hdr); |
| 281 | |
posciak | 77118c9 | 2016-08-28 13:18:39 | [diff] [blame] | 282 | base::Closure done_cb; |
| 283 | const auto& context_refresh_cb = |
| 284 | parser_.GetContextRefreshCb(pic->frame_hdr->frame_context_idx); |
Dale Curtis | e2516381 | 2018-09-21 22:13:39 | [diff] [blame] | 285 | if (context_refresh_cb) |
posciak | 77118c9 | 2016-08-28 13:18:39 | [diff] [blame] | 286 | done_cb = base::Bind(&VP9Decoder::UpdateFrameContext, |
| 287 | base::Unretained(this), pic, context_refresh_cb); |
| 288 | |
| 289 | const Vp9Parser::Context& context = parser_.context(); |
| 290 | if (!accelerator_->SubmitDecode(pic, context.segmentation(), |
| 291 | context.loop_filter(), ref_frames_, done_cb)) |
posciak | d94b2b08 | 2015-09-18 04:03:40 | [diff] [blame] | 292 | return false; |
| 293 | |
| 294 | if (pic->frame_hdr->show_frame) { |
| 295 | if (!accelerator_->OutputPicture(pic)) |
| 296 | return false; |
| 297 | } |
| 298 | |
Ted Meyer | 4fac4f6 | 2019-05-08 22:57:15 | [diff] [blame] | 299 | ref_frames_.Refresh(std::move(pic)); |
posciak | d94b2b08 | 2015-09-18 04:03:40 | [diff] [blame] | 300 | return true; |
| 301 | } |
| 302 | |
| 303 | void VP9Decoder::SetError() { |
| 304 | Reset(); |
| 305 | state_ = kError; |
| 306 | } |
| 307 | |
| 308 | gfx::Size VP9Decoder::GetPicSize() const { |
| 309 | return pic_size_; |
| 310 | } |
| 311 | |
Hirokazu Honda | 436cf27b | 2019-05-21 10:44:39 | [diff] [blame] | 312 | gfx::Rect VP9Decoder::GetVisibleRect() const { |
| 313 | return visible_rect_; |
| 314 | } |
| 315 | |
Hirokazu Honda | 7ec3265 | 2019-11-22 09:40:21 | [diff] [blame^] | 316 | VideoCodecProfile VP9Decoder::GetProfile() const { |
| 317 | return profile_; |
| 318 | } |
| 319 | |
posciak | d94b2b08 | 2015-09-18 04:03:40 | [diff] [blame] | 320 | size_t VP9Decoder::GetRequiredNumOfPictures() const { |
Miguel Casas | 477a706 | 2019-01-04 19:13:45 | [diff] [blame] | 321 | constexpr size_t kPicsInPipeline = limits::kMaxVideoFrames + 1; |
| 322 | return kPicsInPipeline + GetNumReferenceFrames(); |
| 323 | } |
| 324 | |
| 325 | size_t VP9Decoder::GetNumReferenceFrames() const { |
Miguel Casas | 3dd7e56 | 2019-02-14 17:38:46 | [diff] [blame] | 326 | // Maximum number of reference frames |
| 327 | return kVp9NumRefFrames; |
posciak | d94b2b08 | 2015-09-18 04:03:40 | [diff] [blame] | 328 | } |
| 329 | |
markdittmer | 6e70beb8 | 2016-05-02 05:40:47 | [diff] [blame] | 330 | } // namespace media |