OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 30 matching lines...) Expand all Loading... | |
485 | 476 |
486 (*v)[from] = pic; | 477 (*v)[from] = pic; |
487 } | 478 } |
488 | 479 |
489 bool H264Decoder::ModifyReferencePicList(media::H264SliceHeader* slice_hdr, | 480 bool H264Decoder::ModifyReferencePicList(media::H264SliceHeader* slice_hdr, |
490 int list, | 481 int list, |
491 H264Picture::Vector* ref_pic_listx) { | 482 H264Picture::Vector* ref_pic_listx) { |
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 |
486 // Cut off if we have more than requested in slice header. | |
Pawel Osciak
2015/09/02 03:34:58
Hm, this should probably say resize instead of cut
hshi1
2015/09/02 03:49:25
Done.
| |
487 // Note that per 8.2.4.2 it's possible for num_ref_idx_lX_active_minus1 to | |
488 // indicate there should be more ref pics on list than we constructed. | |
489 // Those superfluous ones should be treated as non-reference. | |
490 num_ref_idx_lX_active_minus1 = list == 0 | |
491 ? slice_hdr->num_ref_idx_l0_active_minus1 | |
492 : slice_hdr->num_ref_idx_l1_active_minus1; | |
493 ref_pic_listx->resize(num_ref_idx_lX_active_minus1 + 1); | |
494 | |
Pawel Osciak
2015/09/02 03:34:58
I'm on the fence here, so completely up to you, bu
hshi1
2015/09/02 03:49:25
Done.
| |
495 // This can process either ref_pic_list0 or ref_pic_list1, depending on | 495 // 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. | 496 // the list argument. Set up pointers to proper list to be processed here. |
497 if (list == 0) { | 497 if (list == 0) { |
498 if (!slice_hdr->ref_pic_list_modification_flag_l0) | 498 if (!slice_hdr->ref_pic_list_modification_flag_l0) |
499 return true; | 499 return true; |
500 | 500 |
501 list_mod = slice_hdr->ref_list_l0_modifications; | 501 list_mod = slice_hdr->ref_list_l0_modifications; |
502 } else { | 502 } else { |
503 if (!slice_hdr->ref_pic_list_modification_flag_l1) | 503 if (!slice_hdr->ref_pic_list_modification_flag_l1) |
504 return true; | 504 return true; |
505 | 505 |
506 list_mod = slice_hdr->ref_list_l1_modifications; | 506 list_mod = slice_hdr->ref_list_l1_modifications; |
507 } | 507 } |
508 | 508 |
509 num_ref_idx_lX_active_minus1 = ref_pic_listx->size() - 1; | |
510 DCHECK_GE(num_ref_idx_lX_active_minus1, 0); | |
511 | |
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; |
517 int pic_num_lx; | 514 int pic_num_lx; |
518 bool done = false; | 515 bool done = false; |
519 scoped_refptr<H264Picture> pic; | 516 scoped_refptr<H264Picture> pic; |
520 for (int i = 0; i < media::H264SliceHeader::kRefListModSize && !done; ++i) { | 517 for (int i = 0; i < media::H264SliceHeader::kRefListModSize && !done; ++i) { |
521 switch (list_mod->modification_of_pic_nums_idc) { | 518 switch (list_mod->modification_of_pic_nums_idc) { |
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 |
OLD | NEW |