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