Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "h264_dpb.h" | |
|
brettw
2012/05/07 20:34:10
Full include path.
Pawel Osciak
2012/05/07 20:49:56
Done.
| |
| 6 | |
| 7 #include <algorithm> | |
| 8 | |
| 9 #include "base/logging.h" | |
| 10 #include "base/stl_util.h" | |
| 11 | |
| 12 namespace content { | |
| 13 | |
| 14 H264DPB::H264DPB() {} | |
| 15 H264DPB::~H264DPB() {} | |
| 16 | |
| 17 void H264DPB::Clear() { | |
| 18 pics_.reset(); | |
| 19 } | |
| 20 | |
| 21 void H264DPB::RemoveByPOC(int poc) { | |
| 22 for (Pictures::iterator it = pics_.begin(); it != pics_.end(); ++it) { | |
| 23 if ((*it)->pic_order_cnt == poc) { | |
| 24 pics_.erase(it); | |
| 25 return; | |
| 26 } | |
| 27 } | |
| 28 NOTREACHED() << "Missing POC: " << poc; | |
| 29 } | |
| 30 | |
| 31 void H264DPB::RemoveUnused() { | |
| 32 for (Pictures::iterator it = pics_.begin(); it != pics_.end(); ) { | |
| 33 if ((*it)->outputted && !(*it)->ref) | |
| 34 pics_.erase(it++); | |
| 35 else | |
| 36 ++it; | |
| 37 } | |
| 38 } | |
| 39 | |
| 40 void H264DPB::StorePic(H264Picture* pic) { | |
| 41 DCHECK_LT(pics_.size(), kDPBMaxSize); | |
| 42 DVLOG(3) << "Adding PicNum: " << pic->pic_num << " ref: " << (int)pic->ref | |
| 43 << " longterm: " << (int)pic->long_term << " to DPB"; | |
| 44 pics_.push_back(pic); | |
| 45 } | |
| 46 | |
| 47 int H264DPB::CountRefPics() { | |
| 48 int ret = 0; | |
| 49 for (size_t i = 0; i < pics_.size(); ++i) { | |
| 50 if (pics_[i]->ref) | |
| 51 ++ret; | |
| 52 } | |
| 53 return ret; | |
| 54 } | |
| 55 | |
| 56 void H264DPB::MarkAllUnusedForRef() { | |
| 57 for (size_t i = 0; i < pics_.size(); ++i) | |
| 58 pics_[i]->ref = false; | |
| 59 } | |
| 60 | |
| 61 H264Picture* H264DPB::GetShortRefPicByPicNum(int pic_num) { | |
| 62 for (size_t i = 0; i < pics_.size(); ++i) { | |
| 63 H264Picture* pic = pics_[i]; | |
| 64 if (pic->ref && !pic->long_term && pic->pic_num == pic_num) | |
| 65 return pic; | |
| 66 } | |
| 67 | |
| 68 DVLOG(1) << "Missing short ref pic num: " << pic_num; | |
| 69 return NULL; | |
| 70 } | |
| 71 | |
| 72 H264Picture* H264DPB::GetLongRefPicByLongTermPicNum(int pic_num) { | |
| 73 for (size_t i = 0; i < pics_.size(); ++i) { | |
| 74 H264Picture* pic = pics_[i]; | |
| 75 if (pic->ref && pic->long_term && pic->long_term_pic_num == pic_num) | |
| 76 return pic; | |
| 77 } | |
| 78 | |
| 79 DVLOG(1) << "Missing long term pic num: " << pic_num; | |
| 80 return NULL; | |
| 81 } | |
| 82 | |
| 83 H264Picture* H264DPB::GetLowestFrameNumWrapShortRefPic() { | |
| 84 H264Picture* ret = NULL; | |
| 85 for (size_t i = 0; i < pics_.size(); ++i) { | |
| 86 H264Picture* pic = pics_[i]; | |
| 87 if (pic->ref && !pic->long_term && | |
| 88 (!ret || pic->frame_num_wrap < ret->frame_num_wrap)) | |
| 89 ret = pic; | |
| 90 } | |
| 91 return ret; | |
| 92 } | |
| 93 | |
| 94 void H264DPB::GetNotOutputtedPicsAppending(H264Picture::PtrVector& out) { | |
| 95 for (size_t i = 0; i < pics_.size(); ++i) { | |
| 96 H264Picture* pic = pics_[i]; | |
| 97 if (!pic->outputted) | |
| 98 out.push_back(pic); | |
| 99 } | |
| 100 } | |
| 101 | |
| 102 void H264DPB::GetShortTermRefPicsAppending(H264Picture::PtrVector& out) { | |
| 103 for (size_t i = 0; i < pics_.size(); ++i) { | |
| 104 H264Picture* pic = pics_[i]; | |
| 105 if (pic->ref && !pic->long_term) | |
| 106 out.push_back(pic); | |
| 107 } | |
| 108 } | |
| 109 | |
| 110 void H264DPB::GetLongTermRefPicsAppending(H264Picture::PtrVector& out) { | |
| 111 for (size_t i = 0; i < pics_.size(); ++i) { | |
| 112 H264Picture* pic = pics_[i]; | |
| 113 if (pic->ref && pic->long_term) | |
| 114 out.push_back(pic); | |
| 115 } | |
| 116 } | |
| 117 | |
| 118 } // namespace content | |
| 119 | |
| OLD | NEW |