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

Side by Side Diff: content/common/gpu/media/h264_decoder.cc

Issue 1318283007: H264 Decoder: move cut off logic from Construct to ModifyRefPicList(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <algorithm> 5 #include <algorithm>
6 #include <limits> 6 #include <limits>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 size_t num_short_refs = ref_pic_list_p0_.size(); 355 size_t num_short_refs = ref_pic_list_p0_.size();
356 356
357 // and sort them to get [1]. 357 // and sort them to get [1].
358 std::sort(ref_pic_list_p0_.begin(), ref_pic_list_p0_.end(), 358 std::sort(ref_pic_list_p0_.begin(), ref_pic_list_p0_.end(),
359 PicNumDescCompare()); 359 PicNumDescCompare());
360 360
361 // Now get long term pics and sort them by long_term_pic_num to get [2]. 361 // Now get long term pics and sort them by long_term_pic_num to get [2].
362 dpb_.GetLongTermRefPicsAppending(&ref_pic_list_p0_); 362 dpb_.GetLongTermRefPicsAppending(&ref_pic_list_p0_);
363 std::sort(ref_pic_list_p0_.begin() + num_short_refs, ref_pic_list_p0_.end(), 363 std::sort(ref_pic_list_p0_.begin() + num_short_refs, ref_pic_list_p0_.end(),
364 LongTermPicNumAscCompare()); 364 LongTermPicNumAscCompare());
365
366 // Cut off if we have more than requested in slice header.
367 ref_pic_list_p0_.resize(slice_hdr->num_ref_idx_l0_active_minus1 + 1);
368 } 365 }
369 366
370 struct POCAscCompare { 367 struct POCAscCompare {
371 bool operator()(const scoped_refptr<H264Picture>& a, 368 bool operator()(const scoped_refptr<H264Picture>& a,
372 const scoped_refptr<H264Picture>& b) const { 369 const scoped_refptr<H264Picture>& b) const {
373 return a->pic_order_cnt < b->pic_order_cnt; 370 return a->pic_order_cnt < b->pic_order_cnt;
374 } 371 }
375 }; 372 };
376 373
377 struct POCDescCompare { 374 struct POCDescCompare {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 // Now add [3] and sort by ascending long_term_pic_num 426 // Now add [3] and sort by ascending long_term_pic_num
430 dpb_.GetShortTermRefPicsAppending(&ref_pic_list_b1_); 427 dpb_.GetShortTermRefPicsAppending(&ref_pic_list_b1_);
431 std::sort(ref_pic_list_b1_.begin() + num_short_refs, ref_pic_list_b1_.end(), 428 std::sort(ref_pic_list_b1_.begin() + num_short_refs, ref_pic_list_b1_.end(),
432 LongTermPicNumAscCompare()); 429 LongTermPicNumAscCompare());
433 430
434 // If lists identical, swap first two entries in RefPicList1 (spec 8.2.4.2.3) 431 // If lists identical, swap first two entries in RefPicList1 (spec 8.2.4.2.3)
435 if (ref_pic_list_b1_.size() > 1 && 432 if (ref_pic_list_b1_.size() > 1 &&
436 std::equal(ref_pic_list_b0_.begin(), ref_pic_list_b0_.end(), 433 std::equal(ref_pic_list_b0_.begin(), ref_pic_list_b0_.end(),
437 ref_pic_list_b1_.begin())) 434 ref_pic_list_b1_.begin()))
438 std::swap(ref_pic_list_b1_[0], ref_pic_list_b1_[1]); 435 std::swap(ref_pic_list_b1_[0], ref_pic_list_b1_[1]);
439
440 // Per 8.2.4.2 it's possible for num_ref_idx_lX_active_minus1 to indicate
441 // there should be more ref pics on list than we constructed.
442 // Those superfluous ones should be treated as non-reference.
443 ref_pic_list_b0_.resize(slice_hdr->num_ref_idx_l0_active_minus1 + 1);
444 ref_pic_list_b1_.resize(slice_hdr->num_ref_idx_l1_active_minus1 + 1);
445 } 436 }
446 437
447 // See 8.2.4 438 // See 8.2.4
448 int H264Decoder::PicNumF(const scoped_refptr<H264Picture>& pic) { 439 int H264Decoder::PicNumF(const scoped_refptr<H264Picture>& pic) {
449 if (!pic) 440 if (!pic)
450 return -1; 441 return -1;
451 442
452 if (!pic->long_term) 443 if (!pic->long_term)
453 return pic->pic_num; 444 return pic->pic_num;
454 else 445 else
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 int num_ref_idx_lX_active_minus1; 483 int num_ref_idx_lX_active_minus1;
493 media::H264ModificationOfPicNum* list_mod; 484 media::H264ModificationOfPicNum* list_mod;
494 485
495 // This can process either ref_pic_list0 or ref_pic_list1, depending on 486 // This can process either ref_pic_list0 or ref_pic_list1, depending on
496 // the list argument. Set up pointers to proper list to be processed here. 487 // the list argument. Set up pointers to proper list to be processed here.
497 if (list == 0) { 488 if (list == 0) {
498 if (!slice_hdr->ref_pic_list_modification_flag_l0) 489 if (!slice_hdr->ref_pic_list_modification_flag_l0)
499 return true; 490 return true;
500 491
501 list_mod = slice_hdr->ref_list_l0_modifications; 492 list_mod = slice_hdr->ref_list_l0_modifications;
493
494 // Cut off if we have more than requested in slice header.
Pawel Osciak 2015/09/01 11:00:36 It would be nice to keep the comment from l.440 an
hshi1 2015/09/01 13:16:55 I see. Would the verbatim comment from l.440 (slig
hshi1 2015/09/01 17:17:10 Done.
495 ref_pic_listx->resize(slice_hdr->num_ref_idx_l0_active_minus1 + 1);
Pawel Osciak 2015/09/01 11:00:36 Per spec we should be trimming the list regardless
hshi1 2015/09/01 17:17:10 Done.
502 } else { 496 } else {
503 if (!slice_hdr->ref_pic_list_modification_flag_l1) 497 if (!slice_hdr->ref_pic_list_modification_flag_l1)
504 return true; 498 return true;
505 499
506 list_mod = slice_hdr->ref_list_l1_modifications; 500 list_mod = slice_hdr->ref_list_l1_modifications;
501
502 // Cut off if we have more than requested in slice header.
503 ref_pic_listx->resize(slice_hdr->num_ref_idx_l1_active_minus1 + 1);
507 } 504 }
508 505
509 num_ref_idx_lX_active_minus1 = ref_pic_listx->size() - 1; 506 num_ref_idx_lX_active_minus1 = ref_pic_listx->size() - 1;
510 DCHECK_GE(num_ref_idx_lX_active_minus1, 0); 507 DCHECK_GE(num_ref_idx_lX_active_minus1, 0);
511 508
512 // Spec 8.2.4.3: 509 // Spec 8.2.4.3:
513 // Reorder pictures on the list in a way specified in the stream. 510 // Reorder pictures on the list in a way specified in the stream.
514 int pic_num_lx_pred = curr_pic_->pic_num; 511 int pic_num_lx_pred = curr_pic_->pic_num;
515 int ref_idx_lx = 0; 512 int ref_idx_lx = 0;
516 int pic_num_lx_no_wrap; 513 int pic_num_lx_no_wrap;
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after
1283 1280
1284 gfx::Size H264Decoder::GetPicSize() const { 1281 gfx::Size H264Decoder::GetPicSize() const {
1285 return pic_size_; 1282 return pic_size_;
1286 } 1283 }
1287 1284
1288 size_t H264Decoder::GetRequiredNumOfPictures() const { 1285 size_t H264Decoder::GetRequiredNumOfPictures() const {
1289 return dpb_.max_num_pics() + kPicsInPipeline; 1286 return dpb_.max_num_pics() + kPicsInPipeline;
1290 } 1287 }
1291 1288
1292 } // namespace content 1289 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698