Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(318)

Side by Side Diff: media/gpu/vaapi_video_encode_accelerator.cc

Issue 1882373004: Migrate content/common/gpu/media code to media/gpu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix several more bot-identified build issues Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "media/gpu/vaapi_video_encode_accelerator.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/numerics/safe_conversions.h" 14 #include "base/numerics/safe_conversions.h"
15 #include "content/common/gpu/media/h264_dpb.h"
16 #include "content/common/gpu/media/shared_memory_region.h"
17 #include "media/base/bind_to_current_loop.h" 15 #include "media/base/bind_to_current_loop.h"
16 #include "media/gpu/h264_dpb.h"
17 #include "media/gpu/shared_memory_region.h"
18 #include "third_party/libva/va/va_enc_h264.h" 18 #include "third_party/libva/va/va_enc_h264.h"
19 19
20 #define DVLOGF(level) DVLOG(level) << __FUNCTION__ << "(): " 20 #define DVLOGF(level) DVLOG(level) << __FUNCTION__ << "(): "
21 21
22 #define NOTIFY_ERROR(error, msg) \ 22 #define NOTIFY_ERROR(error, msg) \
23 do { \ 23 do { \
24 SetState(kError); \ 24 SetState(kError); \
25 LOG(ERROR) << msg; \ 25 LOG(ERROR) << msg; \
26 LOG(ERROR) << "Calling NotifyError(" << error << ")";\ 26 LOG(ERROR) << "Calling NotifyError(" << error << ")"; \
27 NotifyError(error); \ 27 NotifyError(error); \
28 } while (0) 28 } while (0)
29 29
30 namespace content { 30 namespace media {
31 31
32 namespace { 32 namespace {
33 // Need 2 surfaces for each frame: one for input data and one for 33 // Need 2 surfaces for each frame: one for input data and one for
34 // reconstructed picture, which is later used for reference. 34 // reconstructed picture, which is later used for reference.
35 const size_t kMinSurfacesToEncode = 2; 35 const size_t kMinSurfacesToEncode = 2;
36 36
37 // Subjectively chosen. 37 // Subjectively chosen.
38 const size_t kNumInputBuffers = 4; 38 const size_t kNumInputBuffers = 4;
39 const size_t kMaxNumReferenceFrames = 4; 39 const size_t kMaxNumReferenceFrames = 4;
40 40
(...skipping 24 matching lines...) Expand all
65 // All Intel codecs can do at least 4.1. 65 // All Intel codecs can do at least 4.1.
66 const int kDefaultLevelIDC = 41; 66 const int kDefaultLevelIDC = 41;
67 const int kChromaFormatIDC = 1; // 4:2:0 67 const int kChromaFormatIDC = 1; // 4:2:0
68 68
69 // Arbitrarily chosen bitrate window size for rate control, in ms. 69 // Arbitrarily chosen bitrate window size for rate control, in ms.
70 const int kCPBWindowSizeMs = 1500; 70 const int kCPBWindowSizeMs = 1500;
71 71
72 // UMA errors that the VaapiVideoEncodeAccelerator class reports. 72 // UMA errors that the VaapiVideoEncodeAccelerator class reports.
73 enum VAVEAEncoderFailure { 73 enum VAVEAEncoderFailure {
74 VAAPI_ERROR = 0, 74 VAAPI_ERROR = 0,
75 // UMA requires that max must be greater than 1. 75 VAVEA_ENCODER_FAILURES_MAX,
Pawel Osciak 2016/04/19 09:22:55 Could we please keep the comment at the new locati
Mark Dittmer 2016/05/02 03:51:24 Ditto to other comment. UMA requirements appear to
76 VAVEA_ENCODER_FAILURES_MAX = 2,
77 }; 76 };
78
79 } 77 }
80 78
81 // Round |value| up to |alignment|, which must be a power of 2. 79 // Round |value| up to |alignment|, which must be a power of 2.
82 static inline size_t RoundUpToPowerOf2(size_t value, size_t alignment) { 80 static inline size_t RoundUpToPowerOf2(size_t value, size_t alignment) {
83 // Check that |alignment| is a power of 2. 81 // Check that |alignment| is a power of 2.
84 DCHECK((alignment + (alignment - 1)) == (alignment | (alignment - 1))); 82 DCHECK((alignment + (alignment - 1)) == (alignment | (alignment - 1)));
85 return ((value + (alignment - 1)) & ~(alignment - 1)); 83 return ((value + (alignment - 1)) & ~(alignment - 1));
86 } 84 }
87 85
88 static void ReportToUMA(VAVEAEncoderFailure failure) { 86 static void ReportToUMA(VAVEAEncoderFailure failure) {
89 UMA_HISTOGRAM_ENUMERATION( 87 UMA_HISTOGRAM_ENUMERATION("Media.VAVEA.EncoderFailure", failure,
90 "Media.VAVEA.EncoderFailure", 88 VAVEA_ENCODER_FAILURES_MAX + 1);
91 failure,
92 VAVEA_ENCODER_FAILURES_MAX);
93 } 89 }
94 90
95 struct VaapiVideoEncodeAccelerator::InputFrameRef { 91 struct VaapiVideoEncodeAccelerator::InputFrameRef {
96 InputFrameRef(const scoped_refptr<media::VideoFrame>& frame, 92 InputFrameRef(const scoped_refptr<media::VideoFrame>& frame,
97 bool force_keyframe) 93 bool force_keyframe)
98 : frame(frame), force_keyframe(force_keyframe) {} 94 : frame(frame), force_keyframe(force_keyframe) {}
99 const scoped_refptr<media::VideoFrame> frame; 95 const scoped_refptr<media::VideoFrame> frame;
100 const bool force_keyframe; 96 const bool force_keyframe;
101 }; 97 };
102 98
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 << media::VideoPixelFormatToString(format) 165 << media::VideoPixelFormatToString(format)
170 << ", input_visible_size: " << input_visible_size.ToString() 166 << ", input_visible_size: " << input_visible_size.ToString()
171 << ", output_profile: " << output_profile 167 << ", output_profile: " << output_profile
172 << ", initial_bitrate: " << initial_bitrate; 168 << ", initial_bitrate: " << initial_bitrate;
173 169
174 client_ptr_factory_.reset(new base::WeakPtrFactory<Client>(client)); 170 client_ptr_factory_.reset(new base::WeakPtrFactory<Client>(client));
175 client_ = client_ptr_factory_->GetWeakPtr(); 171 client_ = client_ptr_factory_->GetWeakPtr();
176 172
177 const SupportedProfiles& profiles = GetSupportedProfiles(); 173 const SupportedProfiles& profiles = GetSupportedProfiles();
178 auto profile = find_if(profiles.begin(), profiles.end(), 174 auto profile = find_if(profiles.begin(), profiles.end(),
179 [output_profile](const SupportedProfile& profile) { 175 [output_profile](const SupportedProfile& profile) {
180 return profile.profile == output_profile; 176 return profile.profile == output_profile;
181 }); 177 });
182 if (profile == profiles.end()) { 178 if (profile == profiles.end()) {
183 DVLOGF(1) << "Unsupported output profile " << output_profile; 179 DVLOGF(1) << "Unsupported output profile " << output_profile;
184 return false; 180 return false;
185 } 181 }
186 if (input_visible_size.width() > profile->max_resolution.width() || 182 if (input_visible_size.width() > profile->max_resolution.width() ||
187 input_visible_size.height() > profile->max_resolution.height()) { 183 input_visible_size.height() > profile->max_resolution.height()) {
188 DVLOGF(1) << "Input size too big: " << input_visible_size.ToString() 184 DVLOGF(1) << "Input size too big: " << input_visible_size.ToString()
189 << ", max supported size: " << profile->max_resolution.ToString(); 185 << ", max supported size: " << profile->max_resolution.ToString();
190 return false; 186 return false;
191 } 187 }
192 188
193 if (format != media::PIXEL_FORMAT_I420) { 189 if (format != media::PIXEL_FORMAT_I420) {
194 DVLOGF(1) << "Unsupported input format: " 190 DVLOGF(1) << "Unsupported input format: "
195 << media::VideoPixelFormatToString(format); 191 << media::VideoPixelFormatToString(format);
196 return false; 192 return false;
197 } 193 }
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 362
367 SPS_TO_SP(vui_parameters_present_flag); 363 SPS_TO_SP(vui_parameters_present_flag);
368 #define SPS_TO_SP_VF(a) seq_param.vui_fields.bits.a = current_sps_.a; 364 #define SPS_TO_SP_VF(a) seq_param.vui_fields.bits.a = current_sps_.a;
369 SPS_TO_SP_VF(timing_info_present_flag); 365 SPS_TO_SP_VF(timing_info_present_flag);
370 #undef SPS_TO_SP_VF 366 #undef SPS_TO_SP_VF
371 SPS_TO_SP(num_units_in_tick); 367 SPS_TO_SP(num_units_in_tick);
372 SPS_TO_SP(time_scale); 368 SPS_TO_SP(time_scale);
373 #undef SPS_TO_SP 369 #undef SPS_TO_SP
374 370
375 if (!vaapi_wrapper_->SubmitBuffer(VAEncSequenceParameterBufferType, 371 if (!vaapi_wrapper_->SubmitBuffer(VAEncSequenceParameterBufferType,
376 sizeof(seq_param), 372 sizeof(seq_param), &seq_param))
377 &seq_param))
378 return false; 373 return false;
379 374
380 VAEncPictureParameterBufferH264 pic_param; 375 VAEncPictureParameterBufferH264 pic_param;
381 memset(&pic_param, 0, sizeof(pic_param)); 376 memset(&pic_param, 0, sizeof(pic_param));
382 377
383 pic_param.CurrPic.picture_id = current_encode_job_->recon_surface->id(); 378 pic_param.CurrPic.picture_id = current_encode_job_->recon_surface->id();
384 pic_param.CurrPic.TopFieldOrderCnt = current_pic_->top_field_order_cnt; 379 pic_param.CurrPic.TopFieldOrderCnt = current_pic_->top_field_order_cnt;
385 pic_param.CurrPic.BottomFieldOrderCnt = current_pic_->bottom_field_order_cnt; 380 pic_param.CurrPic.BottomFieldOrderCnt = current_pic_->bottom_field_order_cnt;
386 pic_param.CurrPic.flags = 0; 381 pic_param.CurrPic.flags = 0;
387 382
(...skipping 17 matching lines...) Expand all
405 pic_param.num_ref_idx_l0_active_minus1 = max_ref_idx_l0_size_ - 1; 400 pic_param.num_ref_idx_l0_active_minus1 = max_ref_idx_l0_size_ - 1;
406 pic_param.pic_fields.bits.idr_pic_flag = current_pic_->idr; 401 pic_param.pic_fields.bits.idr_pic_flag = current_pic_->idr;
407 pic_param.pic_fields.bits.reference_pic_flag = current_pic_->ref; 402 pic_param.pic_fields.bits.reference_pic_flag = current_pic_->ref;
408 #define PPS_TO_PP_PF(a) pic_param.pic_fields.bits.a = current_pps_.a; 403 #define PPS_TO_PP_PF(a) pic_param.pic_fields.bits.a = current_pps_.a;
409 PPS_TO_PP_PF(entropy_coding_mode_flag); 404 PPS_TO_PP_PF(entropy_coding_mode_flag);
410 PPS_TO_PP_PF(transform_8x8_mode_flag); 405 PPS_TO_PP_PF(transform_8x8_mode_flag);
411 PPS_TO_PP_PF(deblocking_filter_control_present_flag); 406 PPS_TO_PP_PF(deblocking_filter_control_present_flag);
412 #undef PPS_TO_PP_PF 407 #undef PPS_TO_PP_PF
413 408
414 if (!vaapi_wrapper_->SubmitBuffer(VAEncPictureParameterBufferType, 409 if (!vaapi_wrapper_->SubmitBuffer(VAEncPictureParameterBufferType,
415 sizeof(pic_param), 410 sizeof(pic_param), &pic_param))
416 &pic_param))
417 return false; 411 return false;
418 412
419 VAEncSliceParameterBufferH264 slice_param; 413 VAEncSliceParameterBufferH264 slice_param;
420 memset(&slice_param, 0, sizeof(slice_param)); 414 memset(&slice_param, 0, sizeof(slice_param));
421 415
422 slice_param.num_macroblocks = mb_width_ * mb_height_; 416 slice_param.num_macroblocks = mb_width_ * mb_height_;
423 slice_param.macroblock_info = VA_INVALID_ID; 417 slice_param.macroblock_info = VA_INVALID_ID;
424 slice_param.slice_type = current_pic_->type; 418 slice_param.slice_type = current_pic_->type;
425 slice_param.pic_parameter_set_id = current_pps_.pic_parameter_set_id; 419 slice_param.pic_parameter_set_id = current_pps_.pic_parameter_set_id;
426 slice_param.idr_pic_id = idr_pic_id_; 420 slice_param.idr_pic_id = idr_pic_id_;
(...skipping 10 matching lines...) Expand all
437 iter = ref_pic_list0_.begin(); 431 iter = ref_pic_list0_.begin();
438 for (size_t i = 0; 432 for (size_t i = 0;
439 i < arraysize(slice_param.RefPicList0) && iter != ref_pic_list0_.end(); 433 i < arraysize(slice_param.RefPicList0) && iter != ref_pic_list0_.end();
440 ++iter, ++i) { 434 ++iter, ++i) {
441 InitVAPicture(&slice_param.RefPicList0[i]); 435 InitVAPicture(&slice_param.RefPicList0[i]);
442 slice_param.RefPicList0[i].picture_id = (*iter)->id(); 436 slice_param.RefPicList0[i].picture_id = (*iter)->id();
443 slice_param.RefPicList0[i].flags = 0; 437 slice_param.RefPicList0[i].flags = 0;
444 } 438 }
445 439
446 if (!vaapi_wrapper_->SubmitBuffer(VAEncSliceParameterBufferType, 440 if (!vaapi_wrapper_->SubmitBuffer(VAEncSliceParameterBufferType,
447 sizeof(slice_param), 441 sizeof(slice_param), &slice_param))
448 &slice_param))
449 return false; 442 return false;
450 443
451 VAEncMiscParameterRateControl rate_control_param; 444 VAEncMiscParameterRateControl rate_control_param;
452 memset(&rate_control_param, 0, sizeof(rate_control_param)); 445 memset(&rate_control_param, 0, sizeof(rate_control_param));
453 rate_control_param.bits_per_second = bitrate_; 446 rate_control_param.bits_per_second = bitrate_;
454 rate_control_param.target_percentage = 90; 447 rate_control_param.target_percentage = 90;
455 rate_control_param.window_size = kCPBWindowSizeMs; 448 rate_control_param.window_size = kCPBWindowSizeMs;
456 rate_control_param.initial_qp = qp_; 449 rate_control_param.initial_qp = qp_;
457 rate_control_param.rc_flags.bits.disable_frame_skip = true; 450 rate_control_param.rc_flags.bits.disable_frame_skip = true;
458 451
459 if (!vaapi_wrapper_->SubmitVAEncMiscParamBuffer( 452 if (!vaapi_wrapper_->SubmitVAEncMiscParamBuffer(
460 VAEncMiscParameterTypeRateControl, 453 VAEncMiscParameterTypeRateControl, sizeof(rate_control_param),
461 sizeof(rate_control_param),
462 &rate_control_param)) 454 &rate_control_param))
463 return false; 455 return false;
464 456
465 VAEncMiscParameterFrameRate framerate_param; 457 VAEncMiscParameterFrameRate framerate_param;
466 memset(&framerate_param, 0, sizeof(framerate_param)); 458 memset(&framerate_param, 0, sizeof(framerate_param));
467 framerate_param.framerate = framerate_; 459 framerate_param.framerate = framerate_;
468 if (!vaapi_wrapper_->SubmitVAEncMiscParamBuffer( 460 if (!vaapi_wrapper_->SubmitVAEncMiscParamBuffer(
469 VAEncMiscParameterTypeFrameRate, 461 VAEncMiscParameterTypeFrameRate, sizeof(framerate_param),
470 sizeof(framerate_param),
471 &framerate_param)) 462 &framerate_param))
472 return false; 463 return false;
473 464
474 VAEncMiscParameterHRD hrd_param; 465 VAEncMiscParameterHRD hrd_param;
475 memset(&hrd_param, 0, sizeof(hrd_param)); 466 memset(&hrd_param, 0, sizeof(hrd_param));
476 hrd_param.buffer_size = cpb_size_; 467 hrd_param.buffer_size = cpb_size_;
477 hrd_param.initial_buffer_fullness = cpb_size_ / 2; 468 hrd_param.initial_buffer_fullness = cpb_size_ / 2;
478 if (!vaapi_wrapper_->SubmitVAEncMiscParamBuffer(VAEncMiscParameterTypeHRD, 469 if (!vaapi_wrapper_->SubmitVAEncMiscParamBuffer(
479 sizeof(hrd_param), 470 VAEncMiscParameterTypeHRD, sizeof(hrd_param), &hrd_param))
480 &hrd_param))
481 return false; 471 return false;
482 472
483 return true; 473 return true;
484 } 474 }
485 475
486 bool VaapiVideoEncodeAccelerator::SubmitHeadersIfNeeded() { 476 bool VaapiVideoEncodeAccelerator::SubmitHeadersIfNeeded() {
487 DCHECK(current_pic_); 477 DCHECK(current_pic_);
488 if (current_pic_->type != media::H264SliceHeader::kISlice) 478 if (current_pic_->type != media::H264SliceHeader::kISlice)
489 return true; 479 return true;
490 480
491 // Submit PPS. 481 // Submit PPS.
492 VAEncPackedHeaderParameterBuffer par_buffer; 482 VAEncPackedHeaderParameterBuffer par_buffer;
493 memset(&par_buffer, 0, sizeof(par_buffer)); 483 memset(&par_buffer, 0, sizeof(par_buffer));
494 par_buffer.type = VAEncPackedHeaderSequence; 484 par_buffer.type = VAEncPackedHeaderSequence;
495 par_buffer.bit_length = packed_sps_.BytesInBuffer() * 8; 485 par_buffer.bit_length = packed_sps_.BytesInBuffer() * 8;
496 486
497 if (!vaapi_wrapper_->SubmitBuffer(VAEncPackedHeaderParameterBufferType, 487 if (!vaapi_wrapper_->SubmitBuffer(VAEncPackedHeaderParameterBufferType,
498 sizeof(par_buffer), 488 sizeof(par_buffer), &par_buffer))
499 &par_buffer))
500 return false; 489 return false;
501 490
502 if (!vaapi_wrapper_->SubmitBuffer(VAEncPackedHeaderDataBufferType, 491 if (!vaapi_wrapper_->SubmitBuffer(VAEncPackedHeaderDataBufferType,
503 packed_sps_.BytesInBuffer(), 492 packed_sps_.BytesInBuffer(),
504 packed_sps_.data())) 493 packed_sps_.data()))
505 return false; 494 return false;
506 495
507 // Submit PPS. 496 // Submit PPS.
508 memset(&par_buffer, 0, sizeof(par_buffer)); 497 memset(&par_buffer, 0, sizeof(par_buffer));
509 par_buffer.type = VAEncPackedHeaderPicture; 498 par_buffer.type = VAEncPackedHeaderPicture;
510 par_buffer.bit_length = packed_pps_.BytesInBuffer() * 8; 499 par_buffer.bit_length = packed_pps_.BytesInBuffer() * 8;
511 500
512 if (!vaapi_wrapper_->SubmitBuffer(VAEncPackedHeaderParameterBufferType, 501 if (!vaapi_wrapper_->SubmitBuffer(VAEncPackedHeaderParameterBufferType,
513 sizeof(par_buffer), 502 sizeof(par_buffer), &par_buffer))
514 &par_buffer))
515 return false; 503 return false;
516 504
517 if (!vaapi_wrapper_->SubmitBuffer(VAEncPackedHeaderDataBufferType, 505 if (!vaapi_wrapper_->SubmitBuffer(VAEncPackedHeaderDataBufferType,
518 packed_pps_.BytesInBuffer(), 506 packed_pps_.BytesInBuffer(),
519 packed_pps_.data())) 507 packed_pps_.data()))
520 return false; 508 return false;
521 509
522 return true; 510 return true;
523 } 511 }
524 512
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 void VaapiVideoEncodeAccelerator::Destroy() { 743 void VaapiVideoEncodeAccelerator::Destroy() {
756 DCHECK(child_task_runner_->BelongsToCurrentThread()); 744 DCHECK(child_task_runner_->BelongsToCurrentThread());
757 745
758 // Can't call client anymore after Destroy() returns. 746 // Can't call client anymore after Destroy() returns.
759 client_ptr_factory_.reset(); 747 client_ptr_factory_.reset();
760 weak_this_ptr_factory_.InvalidateWeakPtrs(); 748 weak_this_ptr_factory_.InvalidateWeakPtrs();
761 749
762 // Early-exit encoder tasks if they are running and join the thread. 750 // Early-exit encoder tasks if they are running and join the thread.
763 if (encoder_thread_.IsRunning()) { 751 if (encoder_thread_.IsRunning()) {
764 encoder_thread_.message_loop()->PostTask( 752 encoder_thread_.message_loop()->PostTask(
765 FROM_HERE, 753 FROM_HERE, base::Bind(&VaapiVideoEncodeAccelerator::DestroyTask,
766 base::Bind(&VaapiVideoEncodeAccelerator::DestroyTask, 754 base::Unretained(this)));
767 base::Unretained(this)));
768 encoder_thread_.Stop(); 755 encoder_thread_.Stop();
769 } 756 }
770 757
771 delete this; 758 delete this;
772 } 759 }
773 760
774 void VaapiVideoEncodeAccelerator::DestroyTask() { 761 void VaapiVideoEncodeAccelerator::DestroyTask() {
775 DVLOGF(2); 762 DVLOGF(2);
776 DCHECK(encoder_thread_task_runner_->BelongsToCurrentThread()); 763 DCHECK(encoder_thread_task_runner_->BelongsToCurrentThread());
777 SetState(kError); 764 SetState(kError);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 current_sps_.time_scale = framerate_ * 2; // See equation D-2 in spec. 831 current_sps_.time_scale = framerate_ * 2; // See equation D-2 in spec.
845 current_sps_.fixed_frame_rate_flag = true; 832 current_sps_.fixed_frame_rate_flag = true;
846 833
847 current_sps_.nal_hrd_parameters_present_flag = true; 834 current_sps_.nal_hrd_parameters_present_flag = true;
848 // H.264 spec ch. E.2.2. 835 // H.264 spec ch. E.2.2.
849 current_sps_.cpb_cnt_minus1 = 0; 836 current_sps_.cpb_cnt_minus1 = 0;
850 current_sps_.bit_rate_scale = kBitRateScale; 837 current_sps_.bit_rate_scale = kBitRateScale;
851 current_sps_.cpb_size_scale = kCPBSizeScale; 838 current_sps_.cpb_size_scale = kCPBSizeScale;
852 current_sps_.bit_rate_value_minus1[0] = 839 current_sps_.bit_rate_value_minus1[0] =
853 (bitrate_ >> 840 (bitrate_ >>
854 (kBitRateScale + media::H264SPS::kBitRateScaleConstantTerm)) - 1; 841 (kBitRateScale + media::H264SPS::kBitRateScaleConstantTerm)) -
842 1;
855 current_sps_.cpb_size_value_minus1[0] = 843 current_sps_.cpb_size_value_minus1[0] =
856 (cpb_size_ >> 844 (cpb_size_ >>
857 (kCPBSizeScale + media::H264SPS::kCPBSizeScaleConstantTerm)) - 1; 845 (kCPBSizeScale + media::H264SPS::kCPBSizeScaleConstantTerm)) -
846 1;
858 current_sps_.cbr_flag[0] = true; 847 current_sps_.cbr_flag[0] = true;
859 current_sps_.initial_cpb_removal_delay_length_minus_1 = 848 current_sps_.initial_cpb_removal_delay_length_minus_1 =
860 media::H264SPS::kDefaultInitialCPBRemovalDelayLength - 1; 849 media::H264SPS::kDefaultInitialCPBRemovalDelayLength - 1;
861 current_sps_.cpb_removal_delay_length_minus1 = 850 current_sps_.cpb_removal_delay_length_minus1 =
862 media::H264SPS::kDefaultInitialCPBRemovalDelayLength - 1; 851 media::H264SPS::kDefaultInitialCPBRemovalDelayLength - 1;
863 current_sps_.dpb_output_delay_length_minus1 = 852 current_sps_.dpb_output_delay_length_minus1 =
864 media::H264SPS::kDefaultDPBOutputDelayLength - 1; 853 media::H264SPS::kDefaultDPBOutputDelayLength - 1;
865 current_sps_.time_offset_length = media::H264SPS::kDefaultTimeOffsetLength; 854 current_sps_.time_offset_length = media::H264SPS::kDefaultTimeOffsetLength;
866 current_sps_.low_delay_hrd_flag = false; 855 current_sps_.low_delay_hrd_flag = false;
867 } 856 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 packed_sps_.AppendBits(5, current_sps_.cpb_removal_delay_length_minus1); 940 packed_sps_.AppendBits(5, current_sps_.cpb_removal_delay_length_minus1);
952 packed_sps_.AppendBits(5, current_sps_.dpb_output_delay_length_minus1); 941 packed_sps_.AppendBits(5, current_sps_.dpb_output_delay_length_minus1);
953 packed_sps_.AppendBits(5, current_sps_.time_offset_length); 942 packed_sps_.AppendBits(5, current_sps_.time_offset_length);
954 } 943 }
955 944
956 packed_sps_.AppendBool(false); // vcl_hrd_parameters_flag 945 packed_sps_.AppendBool(false); // vcl_hrd_parameters_flag
957 if (current_sps_.nal_hrd_parameters_present_flag) 946 if (current_sps_.nal_hrd_parameters_present_flag)
958 packed_sps_.AppendBool(current_sps_.low_delay_hrd_flag); 947 packed_sps_.AppendBool(current_sps_.low_delay_hrd_flag);
959 948
960 packed_sps_.AppendBool(false); // pic_struct_present_flag 949 packed_sps_.AppendBool(false); // pic_struct_present_flag
961 packed_sps_.AppendBool(true); // bitstream_restriction_flag 950 packed_sps_.AppendBool(true); // bitstream_restriction_flag
962 951
963 packed_sps_.AppendBool(false); // motion_vectors_over_pic_boundaries_flag 952 packed_sps_.AppendBool(false); // motion_vectors_over_pic_boundaries_flag
964 packed_sps_.AppendUE(2); // max_bytes_per_pic_denom 953 packed_sps_.AppendUE(2); // max_bytes_per_pic_denom
965 packed_sps_.AppendUE(1); // max_bits_per_mb_denom 954 packed_sps_.AppendUE(1); // max_bits_per_mb_denom
966 packed_sps_.AppendUE(16); // log2_max_mv_length_horizontal 955 packed_sps_.AppendUE(16); // log2_max_mv_length_horizontal
967 packed_sps_.AppendUE(16); // log2_max_mv_length_vertical 956 packed_sps_.AppendUE(16); // log2_max_mv_length_vertical
968 957
969 // Explicitly set max_num_reorder_frames to 0 to allow the decoder to 958 // Explicitly set max_num_reorder_frames to 0 to allow the decoder to
970 // output pictures early. 959 // output pictures early.
971 packed_sps_.AppendUE(0); // max_num_reorder_frames 960 packed_sps_.AppendUE(0); // max_num_reorder_frames
972 961
973 // The value of max_dec_frame_buffering shall be greater than or equal to 962 // The value of max_dec_frame_buffering shall be greater than or equal to
974 // max_num_ref_frames. 963 // max_num_ref_frames.
975 const unsigned int max_dec_frame_buffering = 964 const unsigned int max_dec_frame_buffering =
976 current_sps_.max_num_ref_frames; 965 current_sps_.max_num_ref_frames;
977 packed_sps_.AppendUE(max_dec_frame_buffering); 966 packed_sps_.AppendUE(max_dec_frame_buffering);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 return; 1045 return;
1057 } 1046 }
1058 1047
1059 if (client_) { 1048 if (client_) {
1060 client_->NotifyError(error); 1049 client_->NotifyError(error);
1061 client_ptr_factory_.reset(); 1050 client_ptr_factory_.reset();
1062 } 1051 }
1063 } 1052 }
1064 1053
1065 VaapiVideoEncodeAccelerator::EncodeJob::EncodeJob() 1054 VaapiVideoEncodeAccelerator::EncodeJob::EncodeJob()
1066 : coded_buffer(VA_INVALID_ID), keyframe(false) { 1055 : coded_buffer(VA_INVALID_ID), keyframe(false) {}
1067 }
1068 1056
1069 VaapiVideoEncodeAccelerator::EncodeJob::~EncodeJob() { 1057 VaapiVideoEncodeAccelerator::EncodeJob::~EncodeJob() {}
1070 }
1071 1058
1072 } // namespace content 1059 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698