Commit 764fb8c8 authored by Miguel Casas's avatar Miguel Casas Committed by Commit Bot

media/gpu: simplify Vp9ReferenceFrameVector

This CL cleans up the code in said class and applies Chromium style.
vp9_reference_frame_vector.h file:
- Removes a a prescriptive class comment, instead uses a
descriptive one.
- Removes closed TODO from class documentation.

vp9_reference_frame_vector.cc file:
- Uses =default for destructor instead of {}
- Uses a std::bitset<> instead of bit shifting and testing,
which is error prone and more verbose.
- Uses std::fill() instead of an explicit for loop.

Comments are supposed to be in descriptive style ("uses")
and not imperative ("use"):
> These comments should open with descriptive verbs in the indicative mood ("Opens the file") rather than verbs in the imperative ("Open the file").

https://google.github.io/styleguide/cppguide.html#Function_Comments

Also fixed orthographic and grammar mistakes where applicable.

Change-Id: Ie78e2fbad5f3317e2c291127ac678360ce96d625
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2207749
Commit-Queue: Miguel Casas <mcasas@chromium.org>
Reviewed-by: default avatarHirokazu Honda <hiroh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#771134}
parent b205720e
...@@ -12,32 +12,26 @@ Vp9ReferenceFrameVector::Vp9ReferenceFrameVector() { ...@@ -12,32 +12,26 @@ Vp9ReferenceFrameVector::Vp9ReferenceFrameVector() {
DETACH_FROM_SEQUENCE(sequence_checker_); DETACH_FROM_SEQUENCE(sequence_checker_);
} }
Vp9ReferenceFrameVector::~Vp9ReferenceFrameVector() {} Vp9ReferenceFrameVector::~Vp9ReferenceFrameVector() = default;
// Refresh the reference frame buffer slots with current frame // Refreshes |reference_frames_| slots with the current |pic|s frame header.
// based on refresh_frame_flags set in the frame_hdr.
void Vp9ReferenceFrameVector::Refresh(scoped_refptr<VP9Picture> pic) { void Vp9ReferenceFrameVector::Refresh(scoped_refptr<VP9Picture> pic) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(pic); DCHECK(pic);
const auto& frame_hdr = pic->frame_hdr; const std::bitset<kVp9NumRefFrames> refresh_frame_flags(
pic->frame_hdr->refresh_frame_flags);
for (size_t i = 0, mask = frame_hdr->refresh_frame_flags; mask; for (size_t i = 0; i < kVp9NumRefFrames; ++i) {
mask >>= 1, ++i) { if (refresh_frame_flags[i])
if (mask & 1)
reference_frames_[i] = pic; reference_frames_[i] = pic;
} }
} }
void Vp9ReferenceFrameVector::Clear() { void Vp9ReferenceFrameVector::Clear() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
reference_frames_.fill(nullptr);
for (auto& f : reference_frames_)
f = nullptr;
} }
// VP9 can maintains up to eight active reference frames and each
// frame can use up to three reference frames from this list.
// GetFrame will return the reference frame placed in reference_frames_[index]
scoped_refptr<VP9Picture> Vp9ReferenceFrameVector::GetFrame( scoped_refptr<VP9Picture> Vp9ReferenceFrameVector::GetFrame(
size_t index) const { size_t index) const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
......
...@@ -15,9 +15,8 @@ namespace media { ...@@ -15,9 +15,8 @@ namespace media {
class VP9Picture; class VP9Picture;
// class to share reference frame management code // This class encapsulates VP9-specific reference frame management code. This
// between encoder and decoder classes. // class is thread afine.
// TODO(crbug.com/924804): Add the support in Decoder class.
class Vp9ReferenceFrameVector { class Vp9ReferenceFrameVector {
public: public:
Vp9ReferenceFrameVector(); Vp9ReferenceFrameVector();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment