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

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

Issue 1040513003: VAVDA: Use the new, generic video decoder and accelerator infrastructure. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 8 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
OLDNEW
(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/vaapi_h264_dpb.h"
10
11 namespace content {
12
13 VaapiH264DPB::VaapiH264DPB() : max_num_pics_(0) {
14 }
15 VaapiH264DPB::~VaapiH264DPB() {
16 }
17
18 void VaapiH264DPB::Clear() {
19 pics_.clear();
20 }
21
22 void VaapiH264DPB::set_max_num_pics(size_t max_num_pics) {
23 DCHECK_LE(max_num_pics, kDPBMaxSize);
24 max_num_pics_ = max_num_pics;
25 if (pics_.size() > max_num_pics_)
26 pics_.resize(max_num_pics_);
27 }
28
29 void VaapiH264DPB::DeleteByPOC(int poc) {
30 for (Pictures::iterator it = pics_.begin(); it != pics_.end(); ++it) {
31 if ((*it)->pic_order_cnt == poc) {
32 pics_.erase(it);
33 return;
34 }
35 }
36 NOTREACHED() << "Missing POC: " << poc;
37 }
38
39 void VaapiH264DPB::DeleteUnused() {
40 for (Pictures::iterator it = pics_.begin(); it != pics_.end(); ) {
41 if ((*it)->outputted && !(*it)->ref)
42 it = pics_.erase(it);
43 else
44 ++it;
45 }
46 }
47
48 void VaapiH264DPB::StorePic(VaapiH264Picture* pic) {
49 DCHECK_LT(pics_.size(), max_num_pics_);
50 DVLOG(3) << "Adding PicNum: " << pic->pic_num << " ref: " << (int)pic->ref
51 << " longterm: " << (int)pic->long_term << " to DPB";
52 pics_.push_back(pic);
53 }
54
55 int VaapiH264DPB::CountRefPics() {
56 int ret = 0;
57 for (size_t i = 0; i < pics_.size(); ++i) {
58 if (pics_[i]->ref)
59 ++ret;
60 }
61 return ret;
62 }
63
64 void VaapiH264DPB::MarkAllUnusedForRef() {
65 for (size_t i = 0; i < pics_.size(); ++i)
66 pics_[i]->ref = false;
67 }
68
69 VaapiH264Picture* VaapiH264DPB::GetShortRefPicByPicNum(int pic_num) {
70 for (size_t i = 0; i < pics_.size(); ++i) {
71 VaapiH264Picture* pic = pics_[i];
72 if (pic->ref && !pic->long_term && pic->pic_num == pic_num)
73 return pic;
74 }
75
76 DVLOG(1) << "Missing short ref pic num: " << pic_num;
77 return NULL;
78 }
79
80 VaapiH264Picture* VaapiH264DPB::GetLongRefPicByLongTermPicNum(int pic_num) {
81 for (size_t i = 0; i < pics_.size(); ++i) {
82 VaapiH264Picture* pic = pics_[i];
83 if (pic->ref && pic->long_term && pic->long_term_pic_num == pic_num)
84 return pic;
85 }
86
87 DVLOG(1) << "Missing long term pic num: " << pic_num;
88 return NULL;
89 }
90
91 VaapiH264Picture* VaapiH264DPB::GetLowestFrameNumWrapShortRefPic() {
92 VaapiH264Picture* ret = NULL;
93 for (size_t i = 0; i < pics_.size(); ++i) {
94 VaapiH264Picture* pic = pics_[i];
95 if (pic->ref && !pic->long_term &&
96 (!ret || pic->frame_num_wrap < ret->frame_num_wrap))
97 ret = pic;
98 }
99 return ret;
100 }
101
102 void VaapiH264DPB::GetNotOutputtedPicsAppending(
103 VaapiH264Picture::PtrVector& out) {
104 for (size_t i = 0; i < pics_.size(); ++i) {
105 VaapiH264Picture* pic = pics_[i];
106 if (!pic->outputted)
107 out.push_back(pic);
108 }
109 }
110
111 void VaapiH264DPB::GetShortTermRefPicsAppending(
112 VaapiH264Picture::PtrVector& out) {
113 for (size_t i = 0; i < pics_.size(); ++i) {
114 VaapiH264Picture* pic = pics_[i];
115 if (pic->ref && !pic->long_term)
116 out.push_back(pic);
117 }
118 }
119
120 void VaapiH264DPB::GetLongTermRefPicsAppending(
121 VaapiH264Picture::PtrVector& out) {
122 for (size_t i = 0; i < pics_.size(); ++i) {
123 VaapiH264Picture* pic = pics_[i];
124 if (pic->ref && pic->long_term)
125 out.push_back(pic);
126 }
127 }
128
129 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/media/vaapi_h264_dpb.h ('k') | content/common/gpu/media/vaapi_video_decode_accelerator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698