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

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

Issue 9814001: Add VAVDA, the VAAPI Video Decode Accelerator for Intel CPUs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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 | Annotate | Revision Log
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 // This file contains an implementation of a H.264 Decoded Picture Buffer
6 // used in H264 decoders.
7
8 #ifndef CONTENT_COMMON_GPU_MEDIA_H264_DPB_H_
9 #define CONTENT_COMMON_GPU_MEDIA_H264_DPB_H_
10
11 #include "h264_parser.h"
12
13 #include <vector>
14
15 #include "base/basictypes.h"
16
17 // A picture (a frame or a field) in the H.264 spec sense.
18 // See spec at http://www.itu.int/rec/T-REC-H.264
19 struct H264Picture {
20 enum Field {
21 FIELD_NONE,
22 FIELD_TOP,
23 FIELD_BOTTOM,
24 };
25
26 // Values calculated per H.264 specification or taken from slice header.
27 // See spec for more details on each.
28 int TopFieldOrderCnt;
Ami GONE FROM CHROMIUM 2012/03/21 13:16:24 Naming in this file is inconsistent. Please style
Pawel Osciak 2012/03/21 18:40:35 This is intentional and deliberate. I wanted to ke
Ami GONE FROM CHROMIUM 2012/03/22 17:01:36 Yeah, I think making this code friendly to spec-ex
Pawel Osciak 2012/04/05 10:37:20 Done.
29 int BottomFieldOrderCnt;
30 int PicOrderCnt;
31 int PicOrderCntMsb;
32 int pic_order_cnt_lsb;
33
34 int PicNum;
35 int LongTermPicNum;
36 int frame_num; // from slice header
37 int FrameNumWrap;
38 int LongTermFrameIdx;
39
40 bool idr; // IDR picture?
41 bool ref; // reference picture?
42 bool long_term; // long term reference picture?
43 bool outputted;
44 // Does memory management op 5 needs to be executed after this
45 // picture has finished decoding?
46 bool mem_mgmt_5;
47
48 Field field;
49
50 // Values from slice_hdr to be used during reference marking and
51 // memory management after finishing this picture.
52 bool long_term_reference_flag;
53 bool adaptive_ref_pic_marking_mode_flag;
54 H264DecRefPicMarking ref_pic_marking[H264SliceHeader::kRefListSize];
55
56 // Utility function objects
Ami GONE FROM CHROMIUM 2012/03/21 13:16:24 These make me sad. Are they really all needed? Ca
Pawel Osciak 2012/03/21 18:40:35 Some are used in two different .cc files. I had th
Ami GONE FROM CHROMIUM 2012/03/22 17:01:36 Yes, I think it's better to define them near their
Pawel Osciak 2012/04/05 10:37:20 Done. And got rid of majority of them.
57 struct POCAscCompare {
58 bool operator()(const H264Picture* a, const H264Picture* b) const {
59 return a->PicOrderCnt < b->PicOrderCnt;
60 }
61 };
62
63 struct POCDescCompare {
64 bool operator()(const H264Picture* a, const H264Picture* b) const {
65 return a->PicOrderCnt > b->PicOrderCnt;
66 }
67 };
68
69 struct PicNumDescCompare {
70 bool operator()(const H264Picture* a, const H264Picture* b) const {
71 return a->PicNum > b->PicNum;
72 }
73 };
74
75 struct LongTermPicNumAscCompare {
76 bool operator()(const H264Picture* a, const H264Picture* b) const {
77 return a->LongTermPicNum < b->LongTermPicNum;
78 }
79 };
80
81 struct FrameNumWrapAscCompare {
82 bool operator()(H264Picture*& a, H264Picture*& b) const {
83 return a->FrameNumWrap < b->FrameNumWrap;
84 }
85 };
86
87 struct IsLongTermRefPic
88 : public std::unary_function<H264Picture*, bool> {
89 bool operator()(const H264Picture* pic) const {
90 return (pic->ref && pic->long_term);
91 }
92 };
93
94 struct IsUnused {
95 bool operator()(H264Picture*& pic) {
96 return pic->outputted && !pic->ref;
97 }
98 };
99
100 struct IsOutputted {
101 bool operator()(H264Picture*& pic) {
102 return pic->outputted;
103 }
104 };
105
106 struct IsReference {
107 bool operator()(H264Picture*& pic) {
108 return pic->ref;
109 }
110 };
111 };
112
113 typedef std::vector<H264Picture*> PicsVector;
Ami GONE FROM CHROMIUM 2012/03/21 13:16:24 Move into H264Picture and and rename to just Vecto
Pawel Osciak 2012/04/05 10:37:20 Well, things got quite a bit more verbose with H26
Ami GONE FROM CHROMIUM 2012/04/09 02:41:47 Umm, should it instead by a typedef inside H264DPB
114
115 // DPB - Decoded Picture Buffer.
116 // Stores decoded pictures that will be used for future display
117 // and/or reference.
118 class H264DPB {
Ami GONE FROM CHROMIUM 2012/03/21 13:16:24 Sad that the spec defines DPB as a buffer of decod
Pawel Osciak 2012/03/21 18:40:35 Again, a lot of this is dictated by the idea to ke
119 public:
120 H264DPB();
121 ~H264DPB();
122
123 // Remove unused (not reference and already outputted) pictures from DPB.
124 void RemoveUnused();
125
126 // Remove a picture by its PicOrderCnt.
127 void RemoveByPOC(int poc);
128
129 // Clear DPB.
130 void Clear();
131
132 // Store picture in DPB. DPB takes ownership of its resources.
133 void StorePic(H264Picture* pic);
Ami GONE FROM CHROMIUM 2012/03/21 13:16:24 If you passed by scoped_ptr you wouldn't have to d
Pawel Osciak 2012/03/21 18:40:35 Maybe I'm too hanged on the Google C++ style recom
Ami GONE FROM CHROMIUM 2012/03/22 17:01:36 scoped_ptr<>'s .Pass() is the strongest specificat
Pawel Osciak 2012/04/05 10:37:20 It's just feels dirty to get scoped_ptr and then i
Ami GONE FROM CHROMIUM 2012/04/09 02:41:47 It doesn't feel dirty to me. It feels like a high
134
135 // Return the number of reference pictures in DPB.
136 int CountRefPics();
137
138 // Mark all pictures in DPB as unused for reference.
139 void MarkAllUnusedForRef();
140
141 // Return a short-term reference picture by its PicNum.
142 H264Picture* GetShortRefPicByPicNum(int pic_num);
Ami GONE FROM CHROMIUM 2012/03/21 13:16:24 Assuming this isn't relinquishing ownership, IWBN
Pawel Osciak 2012/04/05 10:37:20 What do you mean by const-ref? Ref to const type?
Ami GONE FROM CHROMIUM 2012/04/09 02:41:47 Oh. I think you have a mental model that the DPB o
143
144 // Return a long-term reference picture by its LongTermPicNum.
145 H264Picture* GetLongRefPicByLongTermPicNum(int pic_num);
146
147 // Return the reference picture with lowest FrameNum. Used for sliding
148 // window memory management.
149 H264Picture* GetLowestFrameNumWrapRefPic();
150
151 // Append all pictures that have not been outputted yet to the passed |out|
152 // vector, sorted by lowest PicOrderCnt (in output order).
153 void GetNotOutputtedPicsSortedByPOCAppending(PicsVector& out);
154
155 // Append all short term reference pictures to the passed |out| vector.
156 void GetShortTermRefPicsAppending(PicsVector& out);
157
158 // Append all long term reference pictures to the passed |out| vector.
159 void GetLongTermRefPicsAppending(PicsVector& out);
160
161 // Iterators for direct access to DPB contents.
Ami GONE FROM CHROMIUM 2012/03/21 13:16:24 These will be invalidated by mutating methods else
Pawel Osciak 2012/04/05 10:37:20 Done.
162 PicsVector::iterator begin() { return pics_.begin(); }
163 PicsVector::iterator end() { return pics_.end(); }
164 PicsVector::reverse_iterator rbegin() { return pics_.rbegin(); }
165 PicsVector::reverse_iterator rend() { return pics_.rend(); }
166
167 size_t size() const { return pics_.size(); }
168 bool IsFull() const { return pics_.size() == kDPBMaxSize; }
169
170 // Per H264 spec, increase to 32 if interlaced video is supported.
171 enum { kDPBMaxSize = 16 };
172
173 private:
174
Ami GONE FROM CHROMIUM 2012/03/21 13:16:24 extra newline
Pawel Osciak 2012/04/05 10:37:20 Done.
175 // Get a reference picture by its (LongTerm)PicNum, short term if |long_term|
176 // is false, long term otherwise.
177 H264Picture* GetRefPicByPicNum(int pic_num, bool long_term);
178
179 // Remove a picture from DPB, freeing its resources.
180 void RemovePic(const PicsVector::iterator iter);
181
182 // TODO posciak: consider using std::list instead.
183 PicsVector pics_;
184
185 DISALLOW_COPY_AND_ASSIGN(H264DPB);
186 };
187
188 #endif // CONTENT_COMMON_GPU_MEDIA_H264_DPB_H_
189
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698