OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/common/gpu/media/vaapi_video_encode_accelerator.h" | 5 #include "content/common/gpu/media/vaapi_video_encode_accelerator.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 memset(¤t_pic_, 0, sizeof(current_pic_)); | 284 memset(¤t_pic_, 0, sizeof(current_pic_)); |
285 | 285 |
286 current_pic_.frame_num = frame_num_++; | 286 current_pic_.frame_num = frame_num_++; |
287 frame_num_ %= idr_period_; | 287 frame_num_ %= idr_period_; |
288 | 288 |
289 if (current_pic_.frame_num % i_period_ == 0 || force_keyframe) | 289 if (current_pic_.frame_num % i_period_ == 0 || force_keyframe) |
290 current_pic_.type = media::H264SliceHeader::kISlice; | 290 current_pic_.type = media::H264SliceHeader::kISlice; |
291 else | 291 else |
292 current_pic_.type = media::H264SliceHeader::kPSlice; | 292 current_pic_.type = media::H264SliceHeader::kPSlice; |
293 | 293 |
294 if (current_pic_.frame_num % idr_period_ == 0) { | 294 if (current_pic_.frame_num % idr_period_ == 0 || force_keyframe) { |
295 current_pic_.idr = true; | 295 current_pic_.idr = true; |
296 last_idr_frame_num_ = current_pic_.frame_num; | 296 last_idr_frame_num_ = current_pic_.frame_num; |
297 ref_pic_list0_.clear(); | 297 ref_pic_list0_.clear(); |
298 } | 298 } |
299 | 299 |
300 if (current_pic_.type != media::H264SliceHeader::kBSlice) | 300 if (current_pic_.type != media::H264SliceHeader::kBSlice) |
301 current_pic_.ref = true; | 301 current_pic_.ref = true; |
302 | 302 |
303 current_pic_.pic_order_cnt = current_pic_.frame_num * 2; | 303 current_pic_.pic_order_cnt = current_pic_.frame_num * 2; |
304 current_pic_.top_field_order_cnt = current_pic_.pic_order_cnt; | 304 current_pic_.top_field_order_cnt = current_pic_.pic_order_cnt; |
305 current_pic_.pic_order_cnt_lsb = current_pic_.pic_order_cnt; | 305 current_pic_.pic_order_cnt_lsb = current_pic_.pic_order_cnt; |
306 | 306 |
307 current_encode_job_->keyframe = | 307 current_encode_job_->keyframe = current_pic_.idr; |
308 (current_pic_.type == media::H264SliceHeader::kISlice); | |
309 | 308 |
310 DVLOGF(4) << "Starting a new frame, type: " << current_pic_.type | 309 DVLOGF(4) << "Starting a new frame, type: " << current_pic_.type |
311 << (force_keyframe ? " (forced keyframe)" : "") | 310 << (force_keyframe ? " (forced keyframe)" : "") |
312 << " frame_num: " << current_pic_.frame_num | 311 << " frame_num: " << current_pic_.frame_num |
313 << " POC: " << current_pic_.pic_order_cnt; | 312 << " POC: " << current_pic_.pic_order_cnt; |
314 } | 313 } |
315 | 314 |
316 void VaapiVideoEncodeAccelerator::EndFrame() { | 315 void VaapiVideoEncodeAccelerator::EndFrame() { |
317 // Store the picture on the list of reference pictures and keep the list | 316 // Store the picture on the list of reference pictures and keep the list |
318 // below maximum size, dropping oldest references. | 317 // below maximum size, dropping oldest references. |
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1059 } | 1058 } |
1060 | 1059 |
1061 VaapiVideoEncodeAccelerator::EncodeJob::EncodeJob() | 1060 VaapiVideoEncodeAccelerator::EncodeJob::EncodeJob() |
1062 : coded_buffer(VA_INVALID_ID), keyframe(false) { | 1061 : coded_buffer(VA_INVALID_ID), keyframe(false) { |
1063 } | 1062 } |
1064 | 1063 |
1065 VaapiVideoEncodeAccelerator::EncodeJob::~EncodeJob() { | 1064 VaapiVideoEncodeAccelerator::EncodeJob::~EncodeJob() { |
1066 } | 1065 } |
1067 | 1066 |
1068 } // namespace content | 1067 } // namespace content |
OLD | NEW |