forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Revert 137988 - VAVDA is the hardware video decode accelerato…
…r for Chrome on Linux and ChromeOS for Intel CPUs (Sandy Bridge and newer)." This reverts commit 9597042. Checking in with RenderViewImpl changes disabled, so that HW decoder does not get instantiated on x86 as temporary workaround for crbug.com/129103. Change-Id: I9b9c85f30eb3f1d34d93d8717582fc96ab882687 BUG=117062 TEST=Manual run of test streams. TBR=brettw@chromium.org Review URL: https://chromiumcodereview.appspot.com/10542148 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142199 0039d316-1c4b-4281-b951-d872f2087c98
- Loading branch information
posciak@chromium.org
committed
Jun 14, 2012
1 parent
f28a317
commit d4c96e2
Showing
11 changed files
with
3,452 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
include_rules = [ | ||
"+media", | ||
"+third_party/libva", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
// Copyright (c) 2012 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include <algorithm> | ||
|
||
#include "base/logging.h" | ||
#include "base/stl_util.h" | ||
#include "content/common/gpu/media/h264_dpb.h" | ||
|
||
namespace content { | ||
|
||
H264DPB::H264DPB() {} | ||
H264DPB::~H264DPB() {} | ||
|
||
void H264DPB::Clear() { | ||
pics_.reset(); | ||
} | ||
|
||
void H264DPB::RemoveByPOC(int poc) { | ||
for (Pictures::iterator it = pics_.begin(); it != pics_.end(); ++it) { | ||
if ((*it)->pic_order_cnt == poc) { | ||
pics_.erase(it); | ||
return; | ||
} | ||
} | ||
NOTREACHED() << "Missing POC: " << poc; | ||
} | ||
|
||
void H264DPB::RemoveUnused() { | ||
for (Pictures::iterator it = pics_.begin(); it != pics_.end(); ) { | ||
if ((*it)->outputted && !(*it)->ref) | ||
pics_.erase(it++); | ||
else | ||
++it; | ||
} | ||
} | ||
|
||
void H264DPB::StorePic(H264Picture* pic) { | ||
DCHECK_LT(pics_.size(), kDPBMaxSize); | ||
DVLOG(3) << "Adding PicNum: " << pic->pic_num << " ref: " << (int)pic->ref | ||
<< " longterm: " << (int)pic->long_term << " to DPB"; | ||
pics_.push_back(pic); | ||
} | ||
|
||
int H264DPB::CountRefPics() { | ||
int ret = 0; | ||
for (size_t i = 0; i < pics_.size(); ++i) { | ||
if (pics_[i]->ref) | ||
++ret; | ||
} | ||
return ret; | ||
} | ||
|
||
void H264DPB::MarkAllUnusedForRef() { | ||
for (size_t i = 0; i < pics_.size(); ++i) | ||
pics_[i]->ref = false; | ||
} | ||
|
||
H264Picture* H264DPB::GetShortRefPicByPicNum(int pic_num) { | ||
for (size_t i = 0; i < pics_.size(); ++i) { | ||
H264Picture* pic = pics_[i]; | ||
if (pic->ref && !pic->long_term && pic->pic_num == pic_num) | ||
return pic; | ||
} | ||
|
||
DVLOG(1) << "Missing short ref pic num: " << pic_num; | ||
return NULL; | ||
} | ||
|
||
H264Picture* H264DPB::GetLongRefPicByLongTermPicNum(int pic_num) { | ||
for (size_t i = 0; i < pics_.size(); ++i) { | ||
H264Picture* pic = pics_[i]; | ||
if (pic->ref && pic->long_term && pic->long_term_pic_num == pic_num) | ||
return pic; | ||
} | ||
|
||
DVLOG(1) << "Missing long term pic num: " << pic_num; | ||
return NULL; | ||
} | ||
|
||
H264Picture* H264DPB::GetLowestFrameNumWrapShortRefPic() { | ||
H264Picture* ret = NULL; | ||
for (size_t i = 0; i < pics_.size(); ++i) { | ||
H264Picture* pic = pics_[i]; | ||
if (pic->ref && !pic->long_term && | ||
(!ret || pic->frame_num_wrap < ret->frame_num_wrap)) | ||
ret = pic; | ||
} | ||
return ret; | ||
} | ||
|
||
void H264DPB::GetNotOutputtedPicsAppending(H264Picture::PtrVector& out) { | ||
for (size_t i = 0; i < pics_.size(); ++i) { | ||
H264Picture* pic = pics_[i]; | ||
if (!pic->outputted) | ||
out.push_back(pic); | ||
} | ||
} | ||
|
||
void H264DPB::GetShortTermRefPicsAppending(H264Picture::PtrVector& out) { | ||
for (size_t i = 0; i < pics_.size(); ++i) { | ||
H264Picture* pic = pics_[i]; | ||
if (pic->ref && !pic->long_term) | ||
out.push_back(pic); | ||
} | ||
} | ||
|
||
void H264DPB::GetLongTermRefPicsAppending(H264Picture::PtrVector& out) { | ||
for (size_t i = 0; i < pics_.size(); ++i) { | ||
H264Picture* pic = pics_[i]; | ||
if (pic->ref && pic->long_term) | ||
out.push_back(pic); | ||
} | ||
} | ||
|
||
} // namespace content | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
// Copyright (c) 2012 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
// | ||
// This file contains an implementation of an H.264 Decoded Picture Buffer | ||
// used in H264 decoders. | ||
|
||
#ifndef CONTENT_COMMON_GPU_MEDIA_H264_DPB_H_ | ||
#define CONTENT_COMMON_GPU_MEDIA_H264_DPB_H_ | ||
|
||
#include <vector> | ||
|
||
#include "base/basictypes.h" | ||
#include "base/memory/scoped_vector.h" | ||
#include "content/common/gpu/media/h264_parser.h" | ||
|
||
namespace content { | ||
|
||
// A picture (a frame or a field) in the H.264 spec sense. | ||
// See spec at http://www.itu.int/rec/T-REC-H.264 | ||
struct H264Picture { | ||
enum Field { | ||
FIELD_NONE, | ||
FIELD_TOP, | ||
FIELD_BOTTOM, | ||
}; | ||
|
||
// Values calculated per H.264 specification or taken from slice header. | ||
// See spec for more details on each (some names have been converted from | ||
// CamelCase in spec to Chromium-style names). | ||
int top_field_order_cnt; | ||
int bottom_field_order_cnt; | ||
int pic_order_cnt; | ||
int pic_order_cnt_msb; | ||
int pic_order_cnt_lsb; | ||
|
||
int pic_num; | ||
int long_term_pic_num; | ||
int frame_num; // from slice header | ||
int frame_num_wrap; | ||
int long_term_frame_idx; | ||
|
||
bool idr; // IDR picture? | ||
bool ref; // reference picture? | ||
bool long_term; // long term reference picture? | ||
bool outputted; | ||
// Does memory management op 5 needs to be executed after this | ||
// picture has finished decoding? | ||
bool mem_mgmt_5; | ||
|
||
Field field; | ||
|
||
// Values from slice_hdr to be used during reference marking and | ||
// memory management after finishing this picture. | ||
bool long_term_reference_flag; | ||
bool adaptive_ref_pic_marking_mode_flag; | ||
H264DecRefPicMarking ref_pic_marking[H264SliceHeader::kRefListSize]; | ||
|
||
typedef std::vector<H264Picture*> PtrVector; | ||
}; | ||
|
||
// DPB - Decoded Picture Buffer. | ||
// Stores decoded pictures that will be used for future display | ||
// and/or reference. | ||
class H264DPB { | ||
public: | ||
H264DPB(); | ||
~H264DPB(); | ||
|
||
// Remove unused (not reference and already outputted) pictures from DPB. | ||
void RemoveUnused(); | ||
|
||
// Remove a picture by its pic_order_cnt. | ||
void RemoveByPOC(int poc); | ||
|
||
// Clear DPB. | ||
void Clear(); | ||
|
||
// Store picture in DPB. DPB takes ownership of its resources. | ||
void StorePic(H264Picture* pic); | ||
|
||
// Return the number of reference pictures in DPB. | ||
int CountRefPics(); | ||
|
||
// Mark all pictures in DPB as unused for reference. | ||
void MarkAllUnusedForRef(); | ||
|
||
// Return a short-term reference picture by its pic_num. | ||
H264Picture* GetShortRefPicByPicNum(int pic_num); | ||
|
||
// Return a long-term reference picture by its long_term_pic_num. | ||
H264Picture* GetLongRefPicByLongTermPicNum(int pic_num); | ||
|
||
// Return the short reference picture with lowest frame_num. Used for sliding | ||
// window memory management. | ||
H264Picture* GetLowestFrameNumWrapShortRefPic(); | ||
|
||
// Append all pictures that have not been outputted yet to the passed |out| | ||
// vector, sorted by lowest pic_order_cnt (in output order). | ||
void GetNotOutputtedPicsAppending(H264Picture::PtrVector& out); | ||
|
||
// Append all short term reference pictures to the passed |out| vector. | ||
void GetShortTermRefPicsAppending(H264Picture::PtrVector& out); | ||
|
||
// Append all long term reference pictures to the passed |out| vector. | ||
void GetLongTermRefPicsAppending(H264Picture::PtrVector& out); | ||
|
||
// Iterators for direct access to DPB contents. | ||
// Will be invalidated after any of Remove* calls. | ||
typedef ScopedVector<H264Picture> Pictures; | ||
Pictures::iterator begin() { return pics_.begin(); } | ||
Pictures::iterator end() { return pics_.end(); } | ||
Pictures::reverse_iterator rbegin() { return pics_.rbegin(); } | ||
Pictures::reverse_iterator rend() { return pics_.rend(); } | ||
|
||
size_t size() const { return pics_.size(); } | ||
bool IsFull() const { return pics_.size() == kDPBMaxSize; } | ||
|
||
// Per H264 spec, increase to 32 if interlaced video is supported. | ||
enum { kDPBMaxSize = 16 }; | ||
|
||
private: | ||
// Remove a picture from DPB, freeing its resources. | ||
void RemovePic(const Pictures::iterator iter); | ||
|
||
Pictures pics_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(H264DPB); | ||
}; | ||
|
||
} // namespace content | ||
|
||
#endif // CONTENT_COMMON_GPU_MEDIA_H264_DPB_H_ | ||
|
Oops, something went wrong.