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

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

Issue 852103002: Revert of Add accelerated video decoder interface, VP8 and H.264 implementations and hook up to V4L2SVDA (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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 | « content/common/gpu/media/h264_dpb.h ('k') | content/common/gpu/media/tegra_v4l2_video_device.h » ('j') | 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 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "content/common/gpu/media/h264_dpb.h" 9 #include "content/common/gpu/media/h264_dpb.h"
10 10
11 namespace content { 11 namespace content {
12 12
13 H264PictureBase::H264PictureBase() {
14 memset(this, 0, sizeof(*this));
15 }
16
17 H264Picture::H264Picture() {
18 }
19
20 H264Picture::~H264Picture() {
21 }
22
23 V4L2H264Picture* H264Picture::AsV4L2H264Picture() {
24 return nullptr;
25 }
26
27 H264DPB::H264DPB() : max_num_pics_(0) {} 13 H264DPB::H264DPB() : max_num_pics_(0) {}
28 H264DPB::~H264DPB() {} 14 H264DPB::~H264DPB() {}
29 15
30 void H264DPB::Clear() { 16 void H264DPB::Clear() {
31 pics_.clear(); 17 pics_.clear();
32 } 18 }
33 19
34 void H264DPB::set_max_num_pics(size_t max_num_pics) { 20 void H264DPB::set_max_num_pics(size_t max_num_pics) {
35 DCHECK_LE(max_num_pics, kDPBMaxSize); 21 DCHECK_LE(max_num_pics, kDPBMaxSize);
36 max_num_pics_ = max_num_pics; 22 max_num_pics_ = max_num_pics;
37 if (pics_.size() > max_num_pics_) 23 if (pics_.size() > max_num_pics_)
38 pics_.resize(max_num_pics_); 24 pics_.resize(max_num_pics_);
39 } 25 }
40 26
41 void H264DPB::UpdatePicPositions() {
42 size_t i = 0;
43 for (auto& pic : pics_) {
44 pic->dpb_position = i;
45 ++i;
46 }
47 }
48
49 void H264DPB::DeleteByPOC(int poc) { 27 void H264DPB::DeleteByPOC(int poc) {
50 for (H264Picture::Vector::iterator it = pics_.begin(); 28 for (Pictures::iterator it = pics_.begin(); it != pics_.end(); ++it) {
51 it != pics_.end(); ++it) {
52 if ((*it)->pic_order_cnt == poc) { 29 if ((*it)->pic_order_cnt == poc) {
53 pics_.erase(it); 30 pics_.erase(it);
54 UpdatePicPositions();
55 return; 31 return;
56 } 32 }
57 } 33 }
58 NOTREACHED() << "Missing POC: " << poc; 34 NOTREACHED() << "Missing POC: " << poc;
59 } 35 }
60 36
61 void H264DPB::DeleteUnused() { 37 void H264DPB::DeleteUnused() {
62 for (H264Picture::Vector::iterator it = pics_.begin(); it != pics_.end(); ) { 38 for (Pictures::iterator it = pics_.begin(); it != pics_.end(); ) {
63 if ((*it)->outputted && !(*it)->ref) 39 if ((*it)->outputted && !(*it)->ref)
64 it = pics_.erase(it); 40 it = pics_.erase(it);
65 else 41 else
66 ++it; 42 ++it;
67 } 43 }
68 UpdatePicPositions();
69 } 44 }
70 45
71 void H264DPB::StorePic(const scoped_refptr<H264Picture>& pic) { 46 void H264DPB::StorePic(H264Picture* pic) {
72 DCHECK_LT(pics_.size(), max_num_pics_); 47 DCHECK_LT(pics_.size(), max_num_pics_);
73 DVLOG(3) << "Adding PicNum: " << pic->pic_num << " ref: " << (int)pic->ref 48 DVLOG(3) << "Adding PicNum: " << pic->pic_num << " ref: " << (int)pic->ref
74 << " longterm: " << (int)pic->long_term << " to DPB"; 49 << " longterm: " << (int)pic->long_term << " to DPB";
75 pic->dpb_position = pics_.size();
76 pics_.push_back(pic); 50 pics_.push_back(pic);
77 } 51 }
78 52
79 int H264DPB::CountRefPics() { 53 int H264DPB::CountRefPics() {
80 int ret = 0; 54 int ret = 0;
81 for (size_t i = 0; i < pics_.size(); ++i) { 55 for (size_t i = 0; i < pics_.size(); ++i) {
82 if (pics_[i]->ref) 56 if (pics_[i]->ref)
83 ++ret; 57 ++ret;
84 } 58 }
85 return ret; 59 return ret;
86 } 60 }
87 61
88 void H264DPB::MarkAllUnusedForRef() { 62 void H264DPB::MarkAllUnusedForRef() {
89 for (size_t i = 0; i < pics_.size(); ++i) 63 for (size_t i = 0; i < pics_.size(); ++i)
90 pics_[i]->ref = false; 64 pics_[i]->ref = false;
91 } 65 }
92 66
93 scoped_refptr<H264Picture> H264DPB::GetShortRefPicByPicNum(int pic_num) { 67 H264Picture* H264DPB::GetShortRefPicByPicNum(int pic_num) {
94 for (const auto& pic : pics_) { 68 for (size_t i = 0; i < pics_.size(); ++i) {
69 H264Picture* pic = pics_[i];
95 if (pic->ref && !pic->long_term && pic->pic_num == pic_num) 70 if (pic->ref && !pic->long_term && pic->pic_num == pic_num)
96 return pic; 71 return pic;
97 } 72 }
98 73
99 DVLOG(1) << "Missing short ref pic num: " << pic_num; 74 DVLOG(1) << "Missing short ref pic num: " << pic_num;
100 return nullptr; 75 return NULL;
101 } 76 }
102 77
103 scoped_refptr<H264Picture> H264DPB::GetLongRefPicByLongTermPicNum(int pic_num) { 78 H264Picture* H264DPB::GetLongRefPicByLongTermPicNum(int pic_num) {
104 for (const auto& pic : pics_) { 79 for (size_t i = 0; i < pics_.size(); ++i) {
80 H264Picture* pic = pics_[i];
105 if (pic->ref && pic->long_term && pic->long_term_pic_num == pic_num) 81 if (pic->ref && pic->long_term && pic->long_term_pic_num == pic_num)
106 return pic; 82 return pic;
107 } 83 }
108 84
109 DVLOG(1) << "Missing long term pic num: " << pic_num; 85 DVLOG(1) << "Missing long term pic num: " << pic_num;
110 return nullptr; 86 return NULL;
111 } 87 }
112 88
113 scoped_refptr<H264Picture> H264DPB::GetLowestFrameNumWrapShortRefPic() { 89 H264Picture* H264DPB::GetLowestFrameNumWrapShortRefPic() {
114 scoped_refptr<H264Picture> ret; 90 H264Picture* ret = NULL;
115 for (const auto& pic : pics_) { 91 for (size_t i = 0; i < pics_.size(); ++i) {
92 H264Picture* pic = pics_[i];
116 if (pic->ref && !pic->long_term && 93 if (pic->ref && !pic->long_term &&
117 (!ret || pic->frame_num_wrap < ret->frame_num_wrap)) 94 (!ret || pic->frame_num_wrap < ret->frame_num_wrap))
118 ret = pic; 95 ret = pic;
119 } 96 }
120 return ret; 97 return ret;
121 } 98 }
122 99
123 void H264DPB::GetNotOutputtedPicsAppending(H264Picture::Vector* out) { 100 void H264DPB::GetNotOutputtedPicsAppending(H264Picture::PtrVector& out) {
124 for (const auto& pic : pics_) { 101 for (size_t i = 0; i < pics_.size(); ++i) {
102 H264Picture* pic = pics_[i];
125 if (!pic->outputted) 103 if (!pic->outputted)
126 out->push_back(pic); 104 out.push_back(pic);
127 } 105 }
128 } 106 }
129 107
130 void H264DPB::GetShortTermRefPicsAppending(H264Picture::Vector* out) { 108 void H264DPB::GetShortTermRefPicsAppending(H264Picture::PtrVector& out) {
131 for (const auto& pic : pics_) { 109 for (size_t i = 0; i < pics_.size(); ++i) {
110 H264Picture* pic = pics_[i];
132 if (pic->ref && !pic->long_term) 111 if (pic->ref && !pic->long_term)
133 out->push_back(pic); 112 out.push_back(pic);
134 } 113 }
135 } 114 }
136 115
137 void H264DPB::GetLongTermRefPicsAppending(H264Picture::Vector* out) { 116 void H264DPB::GetLongTermRefPicsAppending(H264Picture::PtrVector& out) {
138 for (const auto& pic : pics_) { 117 for (size_t i = 0; i < pics_.size(); ++i) {
118 H264Picture* pic = pics_[i];
139 if (pic->ref && pic->long_term) 119 if (pic->ref && pic->long_term)
140 out->push_back(pic); 120 out.push_back(pic);
141 } 121 }
142 } 122 }
143 123
144 } // namespace content 124 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/media/h264_dpb.h ('k') | content/common/gpu/media/tegra_v4l2_video_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698